forked from Tripwire/tripwire-open-source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.in
436 lines (397 loc) · 11.5 KB
/
configure.in
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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
dnl Process this file with autoconf to produce a configure script.
dnl
dnl
AC_INIT
AC_CONFIG_SRCDIR([src/tw/tw.cpp])
AC_CANONICAL_TARGET([])
AM_INIT_AUTOMAKE(tripwire, 2.4.3.1)
AM_CONFIG_HEADER(config.h)
dnl #################################
dnl Cleanup Cruft Leftover From Patch
dnl #################################
rm -f src/tripwire/syslog.h 2> /dev/null
chmod 755 install-sh 2> /dev/null
dnl ###############
dnl Setup defaults
dnl ###############
CFLAGS=${CFLAGS:-"-O -pipe -Wall -Wextra -Wno-unused-parameter -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"}
CXXFLAGS=${CXXFLAGS:-"-O -pipe -Wall -Wextra -Wno-unused-parameter -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"}
dnl #####################
dnl Configuration options
dnl #####################
AC_ARG_ENABLE(static, [ --enable-static compile static binaries])
if test "x$enable_static" = xyes
then LDFLAGS="${LDFLAGS} -static"
fi
AC_ARG_ENABLE(debug, [ --enable-debug compile with debuging enabled])
if test "x$enable_debug" = xyes
then
CFLAGS="${CFLAGS} -g"
CXXFLAGS="${CXXFLAGS} -g"
AC_DEFINE(DEBUG, 1, [Compile with debug code])
fi
dnl ###################
dnl Checks for programs
dnl ###################
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
AC_PROG_YACC
AC_PROG_LN_S
AC_PROG_LN
AC_PATH_PROG(path_to_vi, vi)
AC_PATH_PROG(path_to_sendmail, sendmail, "", [$PATH:/usr/libexec])
if test "x${GXX}" != "x"; then
AC_DEFINE(HAVE_GCC, 1, [Uses the GNU gcc compiler])
else
AC_DEFINE(HAVE_GCC, 0, [Uses the GNU gcc compiler])
fi
dnl #######################
dnl Checks for header files
dnl #######################
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/param.h)
AC_CHECK_HEADERS(sys/mount.h,,,
[[#if defined(HAVE_SYS_PARAM_H)
#include <sys/param.h>
#endif
]])
AC_CHECK_HEADERS(sys/ustat.h sys/sysmacros.h sys/syslog.h)
AC_CHECK_HEADERS(unistd.h syslog.h iconv.h langinfo.h sys/statfs.h)
AC_CHECK_HEADERS(signum.h bits/signum.h, break )
AC_CHECK_HEADERS(stdarg.h varargs.h, break )
dnl # Special case for malloc.h, because it's depreciated on most systems.
CPPFLAGS_SAVE="${CPPFLAGS}"
CPPFLAGS="${CPPFLAGS} -Werror"
AC_CHECK_HEADERS(malloc.h)
CPPFLAGS="${CPPFLAGS_SAVE}"
dnl #############################################################
dnl Checks for typedefs, structures, and compiler characteristics
dnl #############################################################
AC_C_CONST
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_C_BIGENDIAN
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
dnl All platforms we support use 2's complement, are byte aligned, etc...
AC_DEFINE(USES_1S_COMPLEMENT, 0, [Uses one's complement])
AC_DEFINE(USES_2S_COMPLEMENT, 1, [Uses two's complement])
AC_DEFINE(USES_SIGNED_MAGNITUDE, 0, [Uses signed magnitute])
AC_DEFINE(IS_BYTE_ALIGNED, 1, [Is byte aligned])
AC_DEFINE(EXCEPTION_NAMESPACE, std::, [this is the prefix for STL exception functions])
dnl We used to check for UNIX or Unix-like target platforms,
dnl but that is a little extreme, so just assume that the
dnl target is unix. This can still be changed in config.h
AC_DEFINE(IS_UNIX, 1, [Is a unix type platform])
dnl whether or not to generate debuging code?
AC_DEFINE(NDEBUG, 1, [don't generate debuging code])
dnl #############################
dnl Checks for standard functions
dnl #############################
AC_CHECK_FUNCS(strftime gethostname gethostid)
AC_CHECK_FUNCS(mkstemp mktemp, break)
dnl ##############################################
dnl Checks for various platform specific libraries
dnl ##############################################
dnl socket? Solaris has it somewhere else.
AC_CHECK_LIB(c, socket, [:], [
AC_CHECK_LIB(socket, socket, [
LIBS="-lsocket $LIBS"
], [:]) ])
dnl gethostbyname? Solaris has it somewhere else.
AC_CHECK_LIB(c, gethostbyname, [:], [
AC_CHECK_LIB(nsl, gethostbyname, [
LIBS="-lnsl $LIBS"
], [
AC_CHECK_LIB(network, gethostbyname, [LIBS="-lnetwork $LIBS"] [:])
]) ])
dnl check for stl library
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
dnl
dnl Check for STL headers
dnl
AC_CHECK_HEADER(locale,, [
dnl Don't have native STL headers, look in other places
AC_CACHE_CHECK([for STLport directory], ac_cv_stlportdir, [
found_locale=""
for inclpath in /usr/local/include /usr/local/include/stlport
do
CPPFLAGS_save=${CPPFLAGS}
CPPFLAGS="${CPPFLAGS} -I${inclpath}"
AC_TRY_COMPILE([
#include <locale>
]
, , [ found_locale="1" ], )
CPPFLAGS=${CPPFLAGS_save}
if test "x${found_locale}" = "x1"
then
ac_cv_stlportdir=${inclpath}
break
fi
done
if test "x${found_locale}" = "x"; then
echo "not found"
AC_MSG_WARN( [
*** You don't seem to have STL support in your C++ compiler.
*** You can try to build tripwire, but it probably won't compile.
])
fi
])
])
if test "x${ac_cv_stlportdir}" != "x"
then
CPPFLAGS="${CPPFLAGS} -I${ac_cv_stlportdir}"
fi
AC_TRY_LINK([#include <locale>],,,[
dnl Don't have native STL library, look in other places
dnl First check for POSIX threads if we compile STLport, because it needs it
AC_CHECK_FUNC(pthread_getspecific, [:], [
LDFLAGS_TEMP="${LDFLAGS}"
LDFLAGS="${LDFLAGS_TEMP} -pthread"
unset ac_cv_func_pthread_getspecific
AC_CHECK_FUNC(pthread_getspecific, [:], [
LDFLAGS="${LDFLAGS_TEMP} -lpthread"
unset ac_cv_func_pthread_getspecific
AC_CHECK_FUNC(pthread_getspecific, [:], [
LDFLAGS="${LDFLAGS_TEMP}"
AC_MSG_ERROR([No posix threads detected, cannot continue.]) ])
])
])
AC_CACHE_CHECK([for STLport library directory], ac_cv_stlportlib, [
found_lib=""
for inclpath in /usr/local/lib /usr/local/lib/stlport
do
for stllib in stlport stlport_gcc
do
LDFLAGS_save=${LDFLAGS}
LIBS_save=${LIBS}
LDFLAGS="${LDFLAGS} -L${inclpath}"
LIBS="${LIBS} -l${stllib}"
AC_TRY_LINK([
#include <locale>
]
, , [ found_lib="1" ], )
LDFLAGS=${LDFLAGS_save}
LIBS=${LIBS_save}
if test "x${found_lib}" = "x1"
then
ac_cv_stlportlib=${inclpath}
break
fi
done
if test "x${found_lib}" = "x1"
then
break
fi
done
if test "x${found_lib}" = "x"; then
echo "not found"
AC_MSG_WARN( [
*** You don't seem to have STL support in your C++ compiler.
*** You can try to build tripwire, but it probably won't compile.
])
fi
])
if test "x${ac_cv_stlportdir}" != "x"
then
LDFLAGS="${LDFLAGS} -L${ac_cv_stlportlib}"
LIBS="${LIBS} -l${stllib}"
fi
])
AC_LANG_RESTORE
dnl #####################
dnl STL specific headers
dnl #####################
AC_CHECK_HEADERS(wchar.h)
dnl #######################################################################
dnl Local checks/hacks. The goal is to make this part as short as possible
dnl #######################################################################
AC_DEFINE_UNQUOTED(TARGET_OS, "${target}", [Target OS])
case $target in
i386-*-freebsd*)
;;
alpha-*-freebsd*)
;;
i386-*-openbsd*)
;;
*-*-netbsd*)
;;
i[[0-9]]86-pc-linux*)
;;
sparc-*-linux*)
;;
*-sun-solaris*)
if test "x$enable_static" = xyes
then
AC_MSG_WARN( [
Sorry, tripwire will not properly link staticaly under Solaris.
This is due to tripwire's extensive use of gethostbyname(),
which can only be linked dynamicaly. Please rerun configure
without the --enable-static option.
])
AC_DEFINE(SOLARIS_NO_GETHOSTBYNAME, 1, [Don't use gethostbyname() on Solaris])
fi
LIBS="-ldl $LIBS"
AC_CHECK_HEADERS(strings.h)
;;
alpha*-*-osf*)
CXXFLAGS="${CXXFLAGS} -D_ALPHA"
;;
*)
;;
esac
dnl ###################################################
dnl Try linking a simple program with the flags we have
dnl ###################################################
AC_TRY_LINK( , return 0 , , [ AC_MSG_WARN( [
Hmmm... doesn't look so good. I just tried linking a program
and it failed. One reason could be missing static libraries
if you are trying to compile a static binary.
]) ] )
dnl Check for OpenSSL, now that we have a working compiler
AC_ARG_ENABLE(openssl,
[ --disable-openssl don't link against OpenSSL libraries])
AC_ARG_WITH(ssl-dir,
[ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
[
if test "x$withval" != "xno" ; then
tryssldir=$withval
fi
]
)
dnl #################
dnl Check for OpenSSL
dnl #################
CORE_CRYPT_O="md5.o sha.o"
if test "x${enable_openssl}" != "xno"
then
saved_LIBS="$LIBS"
saved_LDFLAGS="$LDFLAGS"
saved_CPPFLAGS="$CPPFLAGS"
if test "x$prefix" != "xNONE" ; then
tryssldir="$tryssldir $prefix"
fi
AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
CPPFLAGS="$saved_CPPFLAGS"
LDFLAGS="$saved_LDFLAGS"
LIBS="$saved_LIBS -lcrypto"
# Skip directories if they don't exist
if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
continue;
fi
if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
# Try to use $ssldir/lib if it exists, otherwise
# $ssldir
if test -d "$ssldir/lib" ; then
LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
if test ! -z "$need_dash_r" ; then
LDFLAGS="-R$ssldir/lib $LDFLAGS"
fi
else
LDFLAGS="-L$ssldir $saved_LDFLAGS"
if test ! -z "$need_dash_r" ; then
LDFLAGS="-R$ssldir $LDFLAGS"
fi
fi
# Try to use $ssldir/include if it exists, otherwise
# $ssldir
if test -d "$ssldir/include" ; then
CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
else
CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
fi
fi
# Basic test to check for compatible library and
# correct linking
AC_TRY_RUN(
[
#include <string.h>
#include <openssl/rand.h>
int main(void)
{
char a[2048];
memset(a, 0, sizeof(a));
RAND_add(a, sizeof(a), sizeof(a));
return(RAND_status() <= 0);
}
],
[
found_crypto=1
break;
], []
)
if test ! -z "$found_crypto" ; then
break;
fi
done
if test -z "$ssldir" ; then
ssldir="(system)"
fi
if test -z "$found_crypto" ; then
ac_cv_openssldir="not found"
else
ac_cv_openssldir=$ssldir
fi
])
LIBS="$saved_LIBS"
if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "xnot found") ; then
dnl Need to recover ssldir - test above runs in subshell
ssldir=$ac_cv_openssldir
if test "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
# Try to use $ssldir/lib if it exists, otherwise
# $ssldir
if test -d "$ssldir/lib" ; then
LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
if test ! -z "$need_dash_r" ; then
LDFLAGS="-R$ssldir/lib $LDFLAGS"
fi
else
LDFLAGS="-L$ssldir $saved_LDFLAGS"
if test ! -z "$need_dash_r" ; then
LDFLAGS="-R$ssldir $LDFLAGS"
fi
fi
# Try to use $ssldir/include if it exists, otherwise
# $ssldir
if test -d "$ssldir/include" ; then
CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
else
CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
fi
fi
LIBS="$saved_LIBS -lcrypto"
AC_CHECK_HEADERS(openssl/md5.h openssl/sha.h)
CORE_CRYPT_O=""
fi
fi
dnl #####################################
dnl Export the variables we use
dnl #####################################
AC_SUBST(CORE_CRYPT_O)
AC_CONFIG_FILES([
Makefile
man/Makefile
man/man4/Makefile
man/man5/Makefile
man/man8/Makefile
src/Makefile
src/cryptlib/Makefile
src/core/Makefile
src/db/Makefile
src/fco/Makefile
src/fs/Makefile
src/tw/Makefile
src/twcrypto/Makefile
src/twparser/Makefile
src/util/Makefile
src/twprint/Makefile
src/twadmin/Makefile
src/siggen/Makefile
src/tripwire/Makefile
src/twtest/Makefile
])
AC_OUTPUT