-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure
executable file
·67 lines (54 loc) · 1.45 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
# !/bin/sh
set -e
function help_and_quit {
echo "Usage: ./configure --help"
echo " (to print this message)"
echo " or ./configure [options]"
echo " (to generate makefile include)"
echo "where options include:"
echo " -h, --help print help message and exit"
echo " --debug enable debug mode"
echo " --enable-assert enable assertions"
echo " by default assertions are disabled for release builds"
echo " and enabled for debug builds"
echo
exit
}
# Common vars
RELEASE_ENABLED=1
ASSERT_ENABLED=0
# Iterate over command line args
for ARG in "$@"; do
if [ $ARG = "--debug" ]; then
RELEASE_ENABLED=0
ASSERT_ENABLED=1
elif [ $ARG = "--enable-assert" ]; then
ASSERT_ENABLED=1
elif [ $ARG = "--help" ] || [ $ARG = "-h" ]; then
help_and_quit
else
echo "Unknown argument $ARG, skipping"
fi
done
mkdir -p target
# Write common header
echo "# Generated file, do not edit" > target/config.mk
# Write optimization options
if [ $RELEASE_ENABLED -eq 1 ]; then
echo '''
CFLAGS = -O3
LFLAGS =
''' >> target/config.mk
else
echo '''
CFLAGS = -O0 -g
LFLAGS = -g
''' >> target/config.mk
fi
# Write assertion options
if [ $ASSERT_ENABLED -eq 0 ]; then
echo "CFLAGS += -DNDEBUG" >> target/config.mk
fi
# Write newline at the end of file
echo >> target/config.mk
echo "DONE"