-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·290 lines (278 loc) · 7.96 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#!/bin/sh
debug=no
static=no
gcov=no
gprof=no
check=undefined
log=undefined
stats=undefined
trace=undefined
int64=undefined
static=no
fopen64=yes
#*------------------------------------------------------------------------*#
tmp="/tmp/booleforce-configure-$$"
trap "rm -rf $tmp" 2 15
mkdir $tmp || die "could not generate '$tmp'"
#*------------------------------------------------------------------------*#
usage() {
cat <<EOF
usage: [CC=<compiler>] [CFLAGS=<flags>] configure [ <option> ... ]
-h print this command line option summary
-g enable debugging, disable optimization (default)
The following options allow the inclusion of specific code. Default
is to exclude all specific code unless debugging is enabled with '-g'.
--check include run time checking code
(beside basic assertion checking more expensive run time
checking needs to be enabled explicitly at run time)
--log include logging code
--no-log exclude logging code
(logging starts at verbose level 3 and becomes more verbose at
even larger verbose levels)
--stats include code for generating statistics
(statistics are dumped at verbose level 2 and larger)
--no-int64 disable 64 bit integer code for statistics
use 32 bit integer instead
--trace include code for generating resolution traces
--no-trace exclude code for generating resolution traces
--static force static compilation
If debugging is enabled the following two options modify 'CFLAGS' to
generate profiling data during run time. This only works if the compiler
type is 'gcc'.
--gcov instrument code for statement profiling with 'gcov'
--gprof instrument code for function profiling with 'gprof'
EOF
exit 0
}
#*------------------------------------------------------------------------*#
cleanup () {
rm -rf "$tmp"
}
#*------------------------------------------------------------------------*#
die() {
echo "*** configure: $*" 1>&2
cleanup
exit 1
}
#*------------------------------------------------------------------------*#
dienl() {
echo
die "$*"
}
#*------------------------------------------------------------------------*#
while [ $# -gt 0 ]
do
case $1 in
-h) usage;;
-g) debug=yes;;
--gcov) gcov=yes;;
--gprof) gprof=yes;;
--log) log=yes;;
--no-log) log=no;;
--check) check=yes;;
--stats) stats=yes;;
--trace) trace=yes;;
--no-trace) trace=no;;
--no-int64) int64=no;;
--static) static=yes;;
*) die "unknow option '$1' (use '-h')";;
esac
shift
done
#*------------------------------------------------------------------------*#
echo -n "version ..."
VERSION="`cat VERSION`"
echo " $VERSION"
#*------------------------------------------------------------------------*#
echo -n "debug ..."
echo " $debug"
#*------------------------------------------------------------------------*#
echo -n "trace ..."
[ $trace = undefined ] && trace=$debug
echo " $trace"
#*------------------------------------------------------------------------*#
echo -n "stats ..."
statsreason=""
[ $stats = undefined ] && stats=$debug
echo " $stats"
#*------------------------------------------------------------------------*#
echo -n "log ..."
[ $log = undefined ] && log=$debug
echo " $log"
#*------------------------------------------------------------------------*#
echo -n "check ..."
[ $check = undefined ] && check=$debug
echo " $check"
#*------------------------------------------------------------------------*#
echo -n "static ..."
echo " $static"
#*------------------------------------------------------------------------*#
echo -n "CC ..."
if [ "$CC" = "" ]
then
CC=gcc
fi
echo " $CC"
#*------------------------------------------------------------------------*#
echo -n "CC type ..."
RAWCC=unknown
for cc in $CC
do
case $cc in
ccmalloc);;
gcc*) RAWCC=gcc; break;;
cc*) RAWCC=$cc; break;;
*gcc) RAWCC=gcc; break;;
*) ;;
esac
done
[ "$RAWCC" = unknown ] && dienl "invalid compiler"
echo " $RAWCC"
#*------------------------------------------------------------------------*#
echo -n "ar ..."
case $CC in
i[456]86-mingw*) AR="`echo $CC|sed -e 's,gcc,ar,'`";;
*) AR=ar;;
esac
echo " $AR"
#*------------------------------------------------------------------------*#
echo -n "ranlib ..."
case $CC in
i[456]86-mingw*) RANLIB="`echo $CC|sed -e 's,gcc,ranlib,'`";;
*) RANLIB=ranlib;;
esac
echo " $RANLIB"
#*------------------------------------------------------------------------*#
echo -n "int64 ..."
if [ $int64 = no ]
then
int64=int
INT64FMT="d"
else
cat > $tmp/sizeoflong.c <<EOF
#include <stdio.h>
int main (void) { printf ("%d\n", (int) sizeof (long)); return 0; }
EOF
$RAWCC -o $tmp/sizeoflong $tmp/sizeoflong.c || \
dienl "can not compile 'sizeoflong.c'"
if [ "`$tmp/sizeoflong`" = 8 ]
then
int64=long
INT64FMT="ld"
else
cat > $tmp/sizeoflonglong.c <<EOF
#include <stdio.h>
int main (void) { printf ("%d\n", (int) sizeof (long long)); return 0; }
EOF
$RAWCC -o $tmp/sizeoflonglong $tmp/sizeoflonglong.c || \
dienl "can not compile 'sizeoflonglong.c'"
if [ "`$tmp/sizeoflonglong`" = 8 ]
then
int64="long long"
INT64FMT="lld"
else
dienl "can not find 64 bit integer type"
fi
fi
fi
echo " $int64"
#*------------------------------------------------------------------------*#
echo -n "CC version ..."
case $RAWCC in
gcc) CCVERSION="`$CC -dumpversion | head -1`";;
*) CCVERSION="unknown";;
esac
echo " $CCVERSION"
#*------------------------------------------------------------------------*#
echo -n "static ..."
echo " $static"
#*------------------------------------------------------------------------*#
echo -n "CFLAGS ..."
if [ "$CFLAGS" = "" ]
then
case $RAWCC in
gcc)
CFLAGS="-Wall -W"
# -Werror"
[ $static = yes ] && CFLAGS="$CFLAGS --static"
if [ $debug = yes ]
then
CFLAGS="$CFLAGS -g3 -ggdb"
if [ $gcov = yes ]
then
CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
fi
else
case "`uname -m`" in
"Power Macintosh" | ppc | i486 | i586 | i686)
CFLAGS="$CFLAGS -O3"
#CFLAGS="$CFLAGS -funroll-loops"
[ $gprof = no ] && CFLAGS="$CFLAGS -fomit-frame-pointer"
;;
*)
CFLAGS="$CFLAGS -O2"
;;
esac;
case "`uname -m`" in
sparc64|sun4u) CFLAGS="$CFLAGS -march=v8";;
i486) CFLAGS="$CFLAGS -march=i486";;
i586) CFLAGS="$CFLAGS -march=i586";;
i686) CFLAGS="$CFLAGS -march=i686";;
esac
fi
if [ $gprof = yes ]
then
CFLAGS="$CFLAGS -pg"
fi
if [ $static = yes ]
then
CFLAGS="$CFLAGS -static"
fi
;;
*)
if [ $debug = yes ]
then
CFLAGS="-g"
else
CFLAGS="-O"
fi
;;
esac
fi
case `uname` in
Darwin) fopen64=fopen
esac
echo " $CFLAGS"
#*------------------------------------------------------------------------*#
echo -n "Makefile ..."
rm -f Makefile
sed \
-e "s,@CC@,$CC,g" \
-e "s,@CFLAGS@,$CFLAGS,g" \
-e "s,@AR@,$AR,g" \
-e "s,@RANLIB@,$RANLIB,g" \
Makefile.in > Makefile
echo " done"
#*------------------------------------------------------------------------*#
echo -n "config.h ..."
rm -f config.h
echo "#ifndef BOOLEFORCE_bfconfig_h_INCLUDED" >> config.h
echo "#define BOOLEFORCE_bfconfig_h_INCLUDED" >> config.h
echo "#define BOOLEFORCE_VERSION \"$VERSION\"" >> config.h
echo "#define BOOLEFORCE_OS \"`uname -a`\"" >> config.h
echo "#define BOOLEFORCE_CC \"$CC\"" >> config.h
echo "#define BOOLEFORCE_CCVERSION \"$CCVERSION\"" >> config.h
echo "#define BOOLEFORCE_CFLAGS \"$CFLAGS\"" >> config.h
[ $check = no ] && echo "#define NDEBUG" >> config.h
[ $log = yes ] && echo "#define BOOLEFORCE_LOG" >> config.h
[ $stats = yes ] && echo "#define BOOLEFORCE_STATS" >> config.h
[ $trace = yes ] && echo "#define BOOLEFORCE_TRACE" >> config.h
echo "typedef $int64 int64;" >> config.h
echo "#define INT64FMT \"$INT64FMT\"" >> config.h
[ $fopen64 = fopen ] && echo "#define FOPEN64_FOPEN" >> config.h
echo "#endif" >> config.h
echo " done"
#*------------------------------------------------------------------------*#
echo -n "cleaning up ..."
cleanup
echo " done"