-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·131 lines (107 loc) · 3.25 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
#!/usr/bin/env sh
DIR="$( cd "$( dirname "${0}" )" && pwd )"
TMP_TARGET_FILE_NAME=Makefile.tmp
TARGET_FILE_NAME=Makefile
# Configurable options
prefix=/usr/local
debugsym=true
sanitizer=true
coverage=false
profile=false
# Figure out project name:
project_name=$(basename $DIR)
if [ -f "PROJECT.name" ]; then
project_name=$(cat "PROJECT.name")
else
echo "Warning: no file 'PROJECT.name' found, guessing project name: '${project_name}'"
fi
for arg in "$@"; do
case "$arg" in
--prefix=*)
prefix=`echo $arg | sed 's/--prefix=//'`
;;
--conan-profile=*)
conan_profile=`echo $arg | sed 's/--conan-profile=//'`
;;
--enable-debug )
debugsym=true
;;
--disable-debug )
debugsym=false
;;
--enable-sanitizer )
sanitizer=true
;;
--disable-sanitizer )
sanitizer=false
;;
--enable-coverage )
coverage=true
;;
--disable-coverage )
coverage=false
;;
--enable-profile )
profile=true
;;
--disable-profile )
profile=true
;;
--help)
echo 'usage: ./configure [options]'
echo 'options:'
echo ' --prefix=<path>: installation prefix'
echo ' --conan-profile=<profile>: Use custom conan profil'
echo ' --enable-debug include debug symbols'
echo ' --disable-debug do not include debug symbols'
echo ' --enable-sanitizer To enable -fsanitize compiler option'
echo ' --disable-sanitizer To disable -fsanitize compiler option'
echo ' --enable-coverage To enable compiler coverage option'
echo ' --disable-coverage To disable compiler coverage option'
echo ' --enable-profile To enable compiler profiler info generation'
echo ' --disable-profile To disable compiler profiler info generation'
echo ''
echo 'all invalid options are silently ignored'
exit 0
;;
*)
echo "Unexpected option '$arg'"
exit 0
;;
esac
done
echo "Generating Makefile for ${project_name}..."
echo "# Generated Makefile for ${project_name}: $(date)" > $TMP_TARGET_FILE_NAME
echo "PREFIX ?= ${prefix}" >> $TMP_TARGET_FILE_NAME
echo "PROJECT ?= ${project_name}" >> $TMP_TARGET_FILE_NAME
if $debugsym; then
echo 'dbg = -g' >> $TMP_TARGET_FILE_NAME
fi
if $sanitizer; then
echo 'sanitize = address,undefined,leak' >> $TMP_TARGET_FILE_NAME
fi
if $coverage; then
echo 'coverage = -coverage' >> $TMP_TARGET_FILE_NAME
fi
if $profile; then
echo 'profile = -pg' >> $TMP_TARGET_FILE_NAME
fi
if [ ! -z "$conan_profile" ] ; then
echo "CONAN_PROFILE ?= ${conan_profile}" >> $TMP_TARGET_FILE_NAME
fi
if [ ! -z "${CXX}" ] || [ ! -z "${CC}" ] ; then
echo "Using custom copiler: CXX=$CXX CC=$CC"
printf "\n# Compiler config\n" >> $TMP_TARGET_FILE_NAME
if [ ! -z "${CXX}" ] ; then
echo "CXX ?= ${CXX}" >> $TMP_TARGET_FILE_NAME
fi
if [ ! -z "${CC}" ]; then
echo "CC ?= ${CC}" >> $TMP_TARGET_FILE_NAME
fi
fi
echo '' >> $TMP_TARGET_FILE_NAME
cat Makefile.in >> $TMP_TARGET_FILE_NAME
# Atomic move if above was successful
mv $TMP_TARGET_FILE_NAME $TARGET_FILE_NAME
# Congrats
echo "Configuration complete, type 'make' to build ${project_name}."