-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure-helper.sh
executable file
·76 lines (65 loc) · 1.25 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/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 parse_args {
echo "" > config.mk
while true ; do
case "$1" in
-t|--toolchain)
echo use toolchain: $2
eval $2
shift 2 ;;
-h|--help)
usage
exit 0;;
*"="*)
export $1
shift 1 ;;
*)
break ;;
esac
done
if [ ! -z ${CC+x} ]; then
echo comiller: $CC
echo "CC=$CC" >> config.mk
fi
if [ ! -z ${CFLAGS+x} ]; then
echo CFLAGS: $CFLAGS
echo CFLAGS=$CFLAGS >> config.mk
fi
if [ ! -z ${LDFLAGS+x} ]; then
echo LDFLAGS: $LDFLAGS
echo LDFLAGS=$LDFLAGS >> config.mk
fi
}
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"
fi
echo -n "$1 = "
eval "echo $TOADD"
echo -n "$1 = " >> config.mk
eval "echo $TOADD" >> config.mk
}