-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconfigure
executable file
·153 lines (120 loc) · 3.04 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
export QUACK_ROOT="$( cd "$(dirname "$0")" ; pwd -P )"
echo "QUACK_ROOT="$QUACK_ROOT
# Force GCC for dependencies
unset CC
unset CCXX
export CC=gcc
# Download submodules
git submodule init # Initialize submodules configuration
git submodule update # Fetch submodule content
cd ${QUACK_ROOT}/external/dependencies
git checkout master
git pull
cd ${QUACK_ROOT}
# Update ARM or x86 dependencies
SYSTEM=$(uname -s)
if [[ $SYSTEM = "Linux" ]] ; then
SYSTEM=""
fi
ARCHITECTURE=$(uname -m)$SYSTEM
echo "Architecture: $ARCHITECTURE"
function help()
{
cat <<EOF
QuAcK configuration script.
Usage:
$(basename $0) -h
$(basename $0) -i <package>
Options:
-h Print the HELP message
-i <package> INSTALL <package>.
Example:
./$(basename $0) -i ninja
EOF
exit
}
function error() {
>&2 echo "$(basename $0): $@"
exit 2
}
function execute () {
local _command
echo "Executing:"
while read -r line; do
echo " " $line
_command+="${line} ;"
done
sleep 1
echo ""
printf "\e[0;94m"
( eval "set -x ; $_command set +x" ) || exit -1
printf "\e[m"
echo ""
}
function fail() {
echo "You can try to install it using the -i option."
exit -1
}
function not_found() {
echo 'not_found'
}
function find_exe() {
which $1 2> /dev/null || not_found
}
PACKAGES=""
while getopts "i:h" c ; do
case "$c" in
i)
case "$OPTARG" in
"") help ; break;;
*) PACKAGES="${PACKAGE} $OPTARG"
esac;;
h)
help
exit 0;;
*)
error $(basename $0)": unknown option $c, try -h for help"
exit 2;;
esac
done
source ${QUACK_ROOT}/quack.rc
# Trim leading and trailing spaces
PACKAGES=$(echo $PACKAGES | xargs)
if [[ "${PACKAGES}.x" != ".x" ]] ; then
printf "\e[0;31m"
echo ""
echo "#########################################################"
echo "# #"
echo "# Automatic installation of dependencies #"
echo "# #"
echo "# Quantum-Package dependencies will be used: #"
echo "# https://github.com/QuantumPackage/qp2-dependencies #"
echo "# #"
echo "#########################################################"
printf "\e[m"
echo ""
sleep 1
fi
if [[ ${PACKAGES} = all ]] ; then
PACKAGES="ninja"
fi
for PACKAGE in ${PACKAGES} ; do
if [[ ${PACKAGE} = ninja ]] ; then
execute << EOF
rm -f "\${QUACK_ROOT}"/bin/ninja
tar -zxvf "\${QUACK_ROOT}"/external/dependencies/${ARCHITECTURE}/ninja.tar.gz
mv ninja "\${QUACK_ROOT}"/bin/
EOF
else
error "${PACKAGE} unknown."
fail
fi
done
source ${QUACK_ROOT}/quack.rc
NINJA=$(find_exe ninja)
if [[ ${NINJA} = $(not_found) ]] ; then
error "Ninja (ninja) is not installed."
fail
fi
exit 0