-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfigure-helper.sh
executable file
·112 lines (99 loc) · 2.11 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
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
#!/bin/bash
NB_TOOLCHAIN=0
function usage {
echo "usage: ./configure [options]"
echo "options:"
echo " -h --help"
echo " -t --toolchain <TOOLCHAIN>"
for i in "${LINEHELPER[@]}"
do
echo " $i"
done
echo "toolchaines: "
for i in "${TOOLCHAINS[@]}"
do
echo " $i"
done
echo "usefull variables:"
echo " COMMON_CFLAGS CFLAGS for C and C++"
echo " CFLAGS CFLAGS for C"
}
function parse_args {
echo "" > config.mk
echo 'c_to_o_dir = $(join $(addsuffix $(1)/, $(dir $(2))), $(notdir $(2:.c=.o)))' >> config.mk
if [ ! -z ${CFLAGS+x} ]; then
echo CFLAGS: $CFLAGS
echo CFLAGS=$CFLAGS >> config.mk
fi
if [ ! -z ${COMMON_CFLAGS+x} ]; then
echo COMMON_CFLAGS: $COMMON_CFLAGS
echo COMMON_CFLAGS=$COMMON_CFLAGS >> config.mk
fi
while true ; do
case "$1" in
-t|--toolchain)
echo use toolchain: $2
eval $2
shift 2 ;;
-h|--help)
usage
exit 0;;
*"+="*)
echo $1
echo $1 >> config.mk
shift 1 ;;
*"="*)
echo $1
export $1
echo $1 >> config.mk
shift 1 ;;
*)
break ;;
esac
echo "toolchains: "
for i in "${TOOLCHAINS[@]}"
do
echo -n " $i"
done
done
}
function add_toolchain {
if [ ! $NB_TOOLCHAIN ]; then
export TOOLCHAINS[$NB_TOOLCHAIN]="$1"
else
TOOLCHAINS[$NB_TOOLCHAIN]="$1"
fi
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
}