-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfigure.ac
More file actions
400 lines (364 loc) · 11.1 KB
/
configure.ac
File metadata and controls
400 lines (364 loc) · 11.1 KB
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
dnl Dirt - Mud Client for Unix (mcl fork)
dnl process this file with autoconf to produce a configure script.
AC_REVISION($Revision: 1.3 $)
AC_INIT
AC_CONFIG_SRCDIR([main.cc])
AC_CONFIG_AUX_DIR(admin)
AC_LANG(C++)
dirt_major=0
dirt_minor=60
dirt_micro=00
PACKAGE=dirt
VERSION=$dirt_major.$dirt_minor.$dirt_micro
DIRT_VERSION1=$dirt_minor$dirt_micro
DIRT_VERSION2=$dirt_major.$dirt_minor.$dirt_micro
DIRT_HOME=
AC_ARG_ENABLE(debug, [ --enable-debug enable debugging], DEBUG="$enable_debug")
AC_ARG_ENABLE(efence, [ --enable-efence enable electric fence malloc debugger], EFENCE="$enable_efence")
AC_ARG_ENABLE(perl, [ --disable-perl disable perl scripting support], PERL="$enable_perl")
AC_ARG_ENABLE(python, [ --enable-python enable python scripting support], PYTHON="$enable_python")
AC_ARG_WITH(install_root, [ --with-install-root directory to consider as the install root [default=/]], INSTALL_ROOT="$with_install_root")
AC_PATH_PROG(sedpath, sed)
if test "_$sedpath" = _; then
AC_MSG_ERROR("Cannot find sed: I need it\!")
fi
dnl supply default CFLAGS, if not specified by `CFLAGS=flags ./configure'
if test -z "${CFLAGS}"; then
save_have_cflags="no"
fi
dnl supply default CXXFLAGS, if not specified by `CXXFLAGS=flags ./configure'
if test -z "${CXXFLAGS}"; then
save_have_cxxflags="no"
fi
dnl supply default LDFLAGS, if not specified by `LDFLAGS=flags ./configure'
if test -z "${LDFLAGS}"; then
save_have_ldflags="no"
fi
dnl Rules
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
AC_CANONICAL_HOST
AC_PROG_LN_S
dnl libraries
AC_CHECK_LIB(dl, main, [LIBDL="-ldl"], LIBDL=)
AC_CHECK_LIB(m, main, [LIBM="-lm"], LIBM=)
AC_CHECK_LIB(ncurses, main, [LIBNCURSES="-lncurses"], LIBNCURSES=)
AC_CHECK_LIB(pthread, main, [LIBPTHREAD="-lpthread"], LIBPTHREAD=)
AC_CHECK_LIB(z, main, [LIBZ="-lz"], LIBZ=)
AC_CHECK_LIB(stdc++, main, [LIBSTDCPP="-lstdc++"], LIBSTDCPP=)
dnl compiler features
AC_CHECK_HEADERS(hash_map)
AC_CHECK_HEADERS(ext/hash_map)
AC_MSG_CHECKING(whether we have hash<string>)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <string>
#include <hash_map>
]], [[
int main() {
hash_map<string,int> stuff;
stuff["shit"] = 4;
}
]])],[have_hash_string=yes],[have_hash_string=no])
AC_MSG_RESULT($have_hash_string)
if test "x$have_hash_string" = "xyes"; then
AC_DEFINE(HAVE_HASH_STRING)
fi
dnl debugging
if test "x$enable_debug" = "xyes"; then
echo "debug build enabled."
CFLAGS="-g"
dnl CFLAGS="$CFLAGS -g"
CXXFLAGS="-g"
dnl CXXFLAGS="$CXXFLAGS -g"
LDFLAGS=
else
if test "x$save_have_cflags" = "xno"; then
CFLAGS=""
fi
CFLAGS="-O2"
if test "x$save_have_cxxflags" = "xno"; then
CXXFLAGS=""
fi
CXXFLAGS="-O2"
if test "x$save_have_ldflags" = "xno"; then
LDFLAGS="-s"
fi
fi
dnl electric fence malloc debugger
case "x$enable_efence" in
"xno")
LIBEFENCE=""
;;
"x")
LIBEFENCE=""
;;
"xyes")
AC_CHECK_LIB(efence, main, [LIBEFENCE="-lefence"], LIBEFENCE=)
if test "x$LIBEFENCE" = "x"; then
echo "could not find electric fence"
echo "malloc debugging support disabled"
fi
;;
*)
AC_CHECK_LIB(efence, main, [LIBEFENCE="-lefence"], LIBEFENCE=)
if test "x$LIBEFENCE" = "x"; then
echo "could not find electric fence"
echo "malloc debugging support disabled"
fi
;;
esac
dnl do we have perl installed in this system?
case "x$enable_perl" in
"xyes")
AC_PATH_PROGS(PERL,perl5 perl,no)
;;
"x")
AC_PATH_PROGS(PERL,perl5 perl,no)
;;
"xno")
echo "perl scripting support disabled in command line"
WITH_PERL=""
;;
*)
echo "using $enable_perl as the perl binary"
;;
esac
if test "x$enable_perl" != "xno" -a "x$PERL" != "xno"; then
AC_MSG_CHECKING(for perl version)
$PERL -e 'require 5.008' > /dev/null 2>&1
if test $? -ne 0 ; then
echo "perl 5.008 (or greater) is required"
echo "disabling perl scripting support"
PERL="no"
WITH_PERL=""
else
AC_PATH_PROG(perlpath, perl)
AC_MSG_CHECKING(for Perl compile flags)
PERL_CFLAGS=`$perlpath -MExtUtils::Embed -e ccopts 2>/dev/null`
PERL_CPPFLAGS=`$perlpath -MExtUtils::Embed -e ccopts 2>/dev/null`
if test "_$PERL_CFLAGS" = _ ; then
AC_MSG_RESULT([not found, building without perl.])
perl=no
else
PERL_LDFLAGS=`$perlpath -MExtUtils::Embed -e ldopts |$sedpath 's/-lgdbm //'`
PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-ldb //'`
PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lndbm //'`
if test "$system" = "Linux"; then
PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lnsl //'`
PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lposix //'`
fi
PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lc //'`
AC_MSG_RESULT(ok)
CFLAGS="$CFLAGS $PERL_CFLAGS"
LIBS="$LIBS $PERL_LDFLAGS"
AC_DEFINE(USE_PERL)
AC_CHECK_FUNCS(eval_pv)
fi
# perl_version=`$PERL -e 'print $]'`
# AC_MSG_RESULT($perl_version)
# PERL_CPPFLAGS=`$PERL -MExtUtils::Embed -e perl_inc`
# PERL_LDFLAGS=`$PERL -MExtUtils::Embed -e ldopts`
dnl | $PERL -pe 's/-l(gdbm|ndbm|posix|db)\b//g'`
WITH_PERL="perl"
fi
else
WITH_PERL=""
echo "could not find a valid perl interpreter"
echo "disabling perl scripting support"
fi
if test "$perl" = yes; then
AC_PATH_PROG(perlpath, perl)
AC_MSG_CHECKING(for Perl compile flags)
PERL_CFLAGS=`$perlpath -MExtUtils::Embed -e ccopts 2>/dev/null`
if test "_$PERL_CFLAGS" = _ ; then
AC_MSG_RESULT([not found, building without perl.])
perl=no
else
PERL_LDFLAGS=`$perlpath -MExtUtils::Embed -e ldopts |$sedpath 's/-lgdbm //'`
PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-ldb //'`
PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lndbm //'`
if test "$system" = "Linux"; then
PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lnsl //'`
PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lposix //'`
fi
PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lc //'`
AC_MSG_RESULT(ok)
CFLAGS="$CFLAGS $PERL_CFLAGS"
LIBS="$LIBS $PERL_LDFLAGS"
AC_DEFINE(USE_PERL)
AC_CHECK_FUNCS(eval_pv)
AC_MSG_CHECKING(for old perl)
PERL_OLD=`$perlpath -e 'if($]<5.006){printf"yes\n";}else{printf"no\n";}'`
if test "$PERL_OLD" = "yes"; then
AC_DEFINE(OLD_PERL)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
fi
fi
dnl do we have python installed in this system
case "x$enable_python" in
"xyes")
AC_PATH_PROGS(PYTHON,python python2.2 python2.1 python2.0 python1.6 python1.5 python1.4 python1.3,no)
;;
"xno")
echo "python scripting support disabled in command line"
WITH_PYTHON=""
;;
esac
if test "x$enable_python" = "xyes" -o "x$PYTHON" = "xyes"; then
dnl python {cpp,ld}flags
changequote(, )dnl
PYTHON_CPPFLAGS=`$PYTHON -c '
import sys
print "-I%s/include/python%s" % (sys.prefix, sys.version[:3])'`
PYTHON_LDFLAGS=`$PYTHON -c '
import sys
print "-L%s/lib/python%s/config -lpython%s" % (sys.prefix, sys.version[:3], sys.version[:3])'`
changequote([, ])dnl
WITH_PYTHON="python"
PYTHON_CPPFLAGS+=" -fPIC"
echo "PYTHON_CPPFLAGS=$PYTHON_CPPFLAGS"
echo "PYTHON_LDFLAGS=$PYTHON_LDFLAGS"
else
WITH_PYTHON=""
echo "disabling python scripting support"
fi
dnl check if this system support the flag -fno-rtti
save_CFLAGS="$CFLAGS"
CFLAGS="-fno-rtti"
AC_MSG_CHECKING(if the flag -fno-rtti is supported by the system compiler)
AC_CACHE_VAL(ac_cv_flag_no_rtti,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int a;]], [[int a;]])],[ac_cv_flag_no_rtti=yes],[ac_cv_flag_no_rtti=no])])
AC_MSG_RESULT($ac_cv_flag_no_rtti)
CFLAGS="$save_CFLAGS"
case "x$ac_cv_flag_no_rtti" in
"xyes")
HAVE_FLAG_NO_RTTI="-fno-rtti"
;;
"xno")
HAVE_FLAG_NO_RTTI=""
;;
*)
HAVE_FLAG_NO_RTTI=""
dnl this should never happen
;;
esac
dnl check if this system support the flag -fno-exceptions
save_CFLAGS="$CFLAGS"
CFLAGS="-fno-exceptions"
AC_MSG_CHECKING(if the flag -fno-exceptions is supported by the system compiler)
AC_CACHE_VAL(ac_cv_flag_no_exceptions,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int a;]], [[int a;]])],[ac_cv_flag_no_exceptions=yes],[ac_cv_flag_no_exceptions=no])])
AC_MSG_RESULT($ac_cv_flag_no_exceptions)
CFLAGS="$save_CFLAGS"
case "x$ac_cv_flag_no_exceptions" in
"xyes")
HAVE_FLAG_NO_EXCEPTIONS="-fno-exceptions"
;;
"xno")
HAVE_FLAG_NO_EXCEPTIONS=""
;;
*)
HAVE_FLAG_NO_EXCEPTIONS=""
dnl this should never happen
;;
esac
case "$host" in
*-*-linux*)
LOCAL_CFLAGS="-fPIC -Wall -pipe -Wno-write-strings -Wno-deprecated -Wno-narrowing"
LOCAL_CPPFLAGS="-Ih"
LOCAL_CXXFLAGS="-W $LOCAL_CFLAGS"
dnl Which version of gcc and g++ are we using?
dnl if ((gcc > 2.7) && (g++ > 2.7)) we do not
dnl need to add even more compile flags
cat > conftest.c <<EOF
#if __GNUC__ > 2
yes;
#endif
#if __GNUC__ > 1
#if __GNUC_MINOR__ > 7
yes;
#endif
#endif
EOF
ac_good_gcc_try='${CC-cc} -E conftest.c'
if eval "$ac_good_gcc_try" | egrep yes >/dev/null 2>&1; then
have_good_gcc=yes
fi
ac_good_gpp_try='${CXX-cc} -E conftest.c'
if eval "$ac_good_gpp_try" | egrep yes >/dev/null 2>&1; then
have_good_gpp=yes
fi
rm conftest.c
if test "x$have_good_gcc" = "xyes" -a "x$have_good_gpp" = "xyes"; then
LOCAL_LDFLAGS="-rdynamic"
LOCAL_LIBS=""
else
LOCAL_LDFLAGS="-nodefaultlibs -rdynamic"
LOCAL_LIBS="-lc -lgcc"
fi
;;
*)
LOCAL_CFLAGS=""
LOCAL_CPPFLAGS="-Ih"
LOCAL_CXXFLAGS="$LOCAL_CFLAGS"
LOCAL_LDFLAGS=""
LOCAL_LIBS=""
;;
esac
COMPILED_BY=`whoami`@`uname -n`
AC_PATH_PROG(RM,rm,true)
AC_PATH_PROG(FIND,find,true)
AC_PATH_PROG(XARGS,xargs,true)
AC_PATH_PROG(CTAGS,ctags,true)
AC_PATH_PROG(ECHO,echo,true)
AC_CONFIG_HEADERS(h/config.h)
AC_SUBST(CFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(PACKAGE)
AC_SUBST(DIRT_VERSION1)
AC_SUBST(DIRT_VERSION2)
AC_SUBST(INSTALL_ROOT)
AC_SUBST(LIBDL)
AC_SUBST(LIBEFENCE)
AC_SUBST(LIBM)
AC_SUBST(LIBNCURSES)
AC_SUBST(LIBPTHREAD)
AC_SUBST(LIBZ)
AC_SUBST(LIBSTDCPP)
AC_SUBST(PERL)
AC_SUBST(PERL_CPPFLAGS)
AC_SUBST(PERL_LDFLAGS)
AC_SUBST(WITH_PERL)
AC_SUBST(PYTHON)
AC_SUBST(PYTHON_CPPFLAGS)
AC_SUBST(PYTHON_LDFLAGS)
AC_SUBST(WITH_PYTHON)
AC_SUBST(HAVE_FLAG_NO_RTTI)
AC_SUBST(HAVE_FLAG_NO_EXCEPTIONS)
AC_SUBST(LOCAL_CFLAGS)
AC_SUBST(LOCAL_CPPFLAGS)
AC_SUBST(LOCAL_CXXFLAGS)
AC_SUBST(LOCAL_LDFLAGS)
AC_SUBST(LOCAL_LIBS)
AC_SUBST(COMPILED_BY)
AC_SUBST(RM)
AC_SUBST(FIND)
AC_SUBST(XARGS)
AC_SUBST(CTAGS)
AC_SUBST(ECHO)
AC_SUBST(LOCAL_CFLAGS)
AC_SUBST(LOCAL_CPPFLAGS)
AC_SUBST(LOCAL_CXXFLAGS)
AC_SUBST(LOCAL_LDFLAGS)
AC_SUBST(LOCAL_LIBS)
AC_CONFIG_FILES([Makefile
VERSION
admin/Makefile
dirt.spec
h/defs.h])
AC_OUTPUT