forked from outscale/packetgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure-helper.sh
61 lines (53 loc) · 1.22 KB
/
configure-helper.sh
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
#!/bin/bash
NB_TOOLCHAIN=0
function usage {
echo "usage: ./configure [options]"
echo "options:"
echo "-h --help"
echo "-t --toolchain <TOOLCHAIN>"
for i in "${TOOLCHAINS[@]}"
do
echo " $i"
done
}
function add_toolchain {
if [ ! $NB_TOOLCHAIN ]; then
export TOOLCHAINS[$NB_TOOLCHAIN]="$1"
else
TOOLCHAINS[$NB_TOOLCHAIN]="$1"
fi
echo add toolchain ${TOOLCHAINS[$NB_TOOLCHAIN]}
NB_TOOLCHAIN=$(($NB_TOOLCHAIN + 1))
}
function var_add {
eval "[ ! -z \${$1+x} ]"
IS_LIB_HERE=$?
if [ $IS_LIB_HERE -eq 0 ]; then
TOADD="\$$1"
else
TOADD="$2"
eval "export $1='$2'"
fi
echo -n "$1 = "
eval "echo $TOADD"
echo -n "$1 = " >> config.mk
eval "echo $TOADD" >> config.mk
}
function var_append {
eval "export $1=\"\$$1 $2\""
eval "echo change $1 to: \$$1"
echo -n "$1 = " >> config.mk
eval "echo \$$1" >> config.mk
}
function define_add {
echo -n "add define: "
var_add $1 $2
echo -n "COMMON_CFLAGS+=-D$1=" >> config.mk
eval "echo \$$1" >> config.mk
}
function str_define_add {
echo -n "add string define: "
var_add $1 $2
echo -n "COMMON_CFLAGS+=-D$1=" >> config.mk
eval "echo \\\\\\\"\$$1\\\\\\\"" >> config.mk
}