-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathconfigure.in
520 lines (446 loc) · 13.6 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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
dnl ## Configuration file for NETMATE
dnl # backup cflags set already (we do this to
dnl # avoid getting the autoconf default flags
_CFLAGS = $CFLAGS
_CXXFLAGS = $CXXFLAGS
# Standard autoconf prolog
AC_PREREQ(2.52)
AC_REVISION([1.0])
# NETMATE initialization
AC_INIT(src/netmate/Meter.h)
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_SRCDIR(src/netmate/Meter.h)
#AC_CONFIG_HEADER(config.h)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE(netmate, 0.9.5)
AM_CONFIG_HEADER(config.h)
AC_PREFIX_DEFAULT(/usr/local)
dnl # Checking build environment
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_RANLIB
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL
AC_SET_MAKE
dnl # Platform
case "$target" in
*-linux*)
OS=LINUX
AC_DEFINE(LINUX, 1, "Linux OS")
;;
*-sunos*)
OS=SUNOS
AC_DEFINE(SUNOS, 1, "SUNOS")
;;
*-irix*)
OS=IRIX
AC_DEFINE(IRIX, 1, "IRIX OS")
;;
*-solaris*)
OS=SOLARIS
AC_DEFINE(SOLARIS, 1, "Solaris OS")
;;
*-freebsd*)
OS=FREEBSD
AC_DEFINE(FREEBSD, 1, "FreeBSD OS")
;;
*dec-os*)
OS=ALPHA
AC_DEFINE(ALPHA, 1, "Alpha")
;;
*)
OS=UNIX
AC_DEFINE(UNIX, 1, "Unix")
;;
esac
dnl # Hardware
case "$target" in
*i*86*)
PROC=LINUX
AC_DEFINE(INTEL, 1, "Intel")
;;
esac
# use our own defaults
LDFLAGS="$LDFLAGS -L/lib -L/usr/local/lib -L/usr/lib "
CFLAGS="$_CFLAGS -Wall"
CXXFLAGS="$_CXXFLAGS -Wall -Wno-deprecated "
dnl # check the options
AC_WITH(iptables,
[LDFLAGS="$LDFLAGS -L$withval/libipulog -L$withval/libiptc"
CXXFLAGS="$CXXFLAGS -I$withval/include"
CFLAGS="$CFLAGS -I$withval/include"
CPPFLAGS="$CPPFLAGS -I$withval/include"
IPTABLES_DIR=$withval
])
AC_WITH(ssl,
[LDFLAGS="$LDFLAGS -L$withval/lib"
CXXFLAGS="$CXXFLAGS -I$withval/include"
CFLAGS="$CFLAGS -I$withval/include"
CPPFLAGS="$CPPFLAGS -I$withval/include"
SSL_DIR=$withval
])
AC_WITH(xml2,
[XML2_DIR=$withval
])
AC_WITH(xslt,
[XSLT_DIR=$withval
])
AC_WITH(curl,
[CURL_DIR=$withval
])
AC_WITH(pcap,
[PCAP_DIR=$withval
])
AC_ARG_ENABLE(debug,
[ --enable-debug enable debug build ],
[case "${enableval}" in
yes) debug=true ;;
no) debug=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
esac],[debug=false])
AM_CONDITIONAL(ENABLE_DEBUG, test x$debug = xtrue)
if test $debug = true ; then
AC_DEFINE(ENABLE_DEBUG, 1, [enable debug build])
fi
AC_ARG_ENABLE(test,
[ --enable-test enable all test applications ],
[case "${enableval}" in
yes) tst=true ;;
no) tst=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-test) ;;
esac],[tst=false])
AM_CONDITIONAL(ENABLE_TEST, test x$tst = xtrue)
if test $tst = true ; then
AC_DEFINE(ENABLE_TEST, 1, [enable test applications])
fi
AC_ARG_ENABLE(mp,
[ --enable-mp enable mpatrol memory surveillance ],
[case "${enableval}" in
yes) mp=true ;;
no) mp=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-mp) ;;
esac],[mp=false])
AM_CONDITIONAL(ENABLE_MP, test x$mp = xtrue)
if test $mp = true ; then
AC_DEFINE(ENABLE_MP, 1, [enable mpatrol linking])
fi
AC_ARG_ENABLE(nf,
[ --enable-nf enable netfilter classifier ],
[case "${enableval}" in
yes) nf=true ;;
no) nf=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-nf) ;;
esac],[nf=false])
AM_CONDITIONAL(ENABLE_NF, test x$nf = xtrue)
if test $nf = true ; then
if ! test $OS = LINUX ; then
AC_MSG_ERROR([netfilter can only be used with Linux])
else
VERSION_FILE=/usr/src/linux/include/linux/version.h
KVERSION=`cc -E -dM $VERSION_FILE | grep UTS | awk '{ print $3; }' | sed -e 's/\\"//g'`
KMAVERSION=`echo $KVERSION | sed -e 's/\(.*\\..*\)\\..*/\\1/g'`
KMIVERSION=`echo $KVERSION | sed -e 's/.*\\..*\\.\(.*\)-.*/\\1/g'`
fi
if ! test $KMAVERSION = 2.4 ; then
AC_MSG_ERROR([Linux version must be 2.4])
fi
if ! test /usr/src/linux ; then
AC_MSG_ERROR([Linux kernel source must be installed])
fi
AC_CHECK_HEADERS(iptables.h libipulog/libipulog.h libiptc/libiptc.h,,
[AC_MSG_ERROR([cant find libipulog.h])])
AC_CHECK_LIB(ipulog, ipulog_create_handle,
[ULOGLIB="-lipulog -liptc"],
[AC_MSG_ERROR([cannot find open ulog, please read README.netfilter])])
# get iptables version
IPTABLES_VERSION=`cat $IPTABLES_DIR/Makefile | egrep '^IPTABLES_VERSION' | sed -e 's/^IPTABLES_VERSION:=\(.*\)/\\1/g'`
AC_DEFINE(ENABLE_NF, 1, [enable netfilter classifier])
fi
AC_ARG_ENABLE(ssl,
[ --enable-ssl enable ssl ],
[case "${enableval}" in
yes) ssl=true ;;
no) ssl=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-ssl) ;;
esac],[ssl=false])
AM_CONDITIONAL(ENABLE_SSL, test x$ssl = xtrue)
if test $ssl = true ; then
if test -z "$SSL_DIR" && test -d /usr/local/ssl ; then
LDFLAGS="$LDFLAGS -L/usr/local/ssl/lib"
CXXFLAGS="$CXXFLAGS -I/usr/local/ssl/include"
CFLAGS="$CFLAGS -I/usr/local/ssl/include"
CPPFLAGS="$CPPFLAGS -I/usr/local/ssl/include"
fi
LIBS="$LIBS -lcrypto"
AC_CHECK_HEADERS([openssl/ssl.h openssl/err.h openssl/bio.h openssl/evp.h],,
[AC_MSG_ERROR([cannot find ssl headers])])
AC_CHECK_LIB(ssl, [SSL_library_init],
[SSLLIB="-lssl"],
[AC_MSG_ERROR([cannot find open ssl])])
USE_SSL="-DUSE_SSL"
SSL_PASSWD=netmate
AC_DEFINE_UNQUOTED(SSL_PASSWD, "$SSL_PASSWD", [password for ssl encryption])
AC_DEFINE(USE_SSL, 1, [use ssl flag])
fi
AC_ARG_ENABLE(threads,
[ --enable-threads enable threads ],
[case "${enableval}" in
yes) threads=true ;;
no) threads=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-threads) ;;
esac],[threads=false])
AM_CONDITIONAL(ENABLE_THREADS, test x$threads = xtrue)
if test $threads = true ; then
AC_DEFINE(ENABLE_THREADS, 1, [enable multi threading])
fi
dnl # check size
AC_CHECK_SIZEOF(off_t)
dnl # check for headers
# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([net/bpf.h net/ethernet.h ether.h arpa/inet.h fcntl.h float.h types.h limits.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h termios.h unistd.h float.h])
dnl # Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM
# Checks for library functions.
#AC_FUNC_MALLOC
#AC_FUNC_MKTIME
#AC_TYPE_SIGNAL
#AC_FUNC_STAT
#AC_FUNC_STRFTIME
AC_CHECK_FUNCS([alarm bzero floor getaddrinfo inet_ntoa gettimeofday memmove memset select socket strdup strchr strerror strstr atoll strtof getopt_long])
dnl # Checks for libraries.
if test $threads = true ; then
AC_CHECK_HEADERS([pthread.h])
if test $OS = FREEBSD ; then
OCCFLAGS=$CXXFLAGS
OCFLAGS=$CFLAGS
CXXFLAGS="$CXXFLAGS -D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads"
CFLAGS="$CFLAGS -D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads"
have_linux_threads="yes"
AC_CHECK_LIB(lthread, pthread_create,
[PTHREADLIB="-llthread -llgcc_r"],[ have_linux_threads="no" ] )
#if no linuxthreads try libc_r
CXXFLAGS="$OCXXFLAGS -pthread"
CFLAGS="$OCFLAGS -pthread"
AC_CHECK_LIB(c_r, pthread_create, [PTHREADLIB="-lc_r"])
# actually newer FREEBSD version should have pthread...
else
AC_CHECK_LIB(pthread, pthread_create,
[PTHREADLIB="-lpthread"])
fi
fi
if test $mp = true ; then
LDFLAGS="$LDFLAGS -lbfd"
if test $threads = true ; then
LDFLAGS="$LDFLAGS -lpthread"
AC_CHECK_LIB(mpatrolmt, xmalloc,
[MPATROLLIB="-lmpatrolmt"],
[AC_MSG_ERROR([cannot find libmpatrolmt])])
else
AC_CHECK_LIB(mpatrol, xmalloc,
[MPATROLLIB="-lmpatrol"],
[AC_MSG_ERROR([cannot find libmpatrol])])
fi
fi
AC_CHECK_LIB(m, floor,
[MATHLIB="-lm"],
[AC_MSG_ERROR([cannot find libm])])
if test $OS = "SOLARIS" ; then
LDFLAGS="$LDFLAGS -lcurses"
fi
READLINELIB=""
# some readlines (Redhat) need -ltermcap
AC_CHECK_LIB(termcap, tgetent, LDFLAGS="$LDFLAGS -ltermcap",[])
AC_CHECK_HEADERS([readline/readline.h readline/history.h],,
[AC_MSG_ERROR([cannot find libreadline headers])])
AC_CHECK_LIB(readline, readline,
[READLINELIB="$READLINELIB -lreadline"],
[AC_MSG_ERROR([cannot find libreadline])])
if test "$PCAP_DIR" ; then
LDFLAGS="$LDFLAGS -L$PCAP_DIR"
CFLAGS="$CFLAGS -I$PCAP_DIR"
CXXFLAGS="$CXXFLAGS -I$PCAP_DIR"
CPPFLAGS="$CPPFLAGS -I$PCAP_DIR"
fi
if test $OS = "SOLARIS" ; then
LDFLAGS="$LDFLAGS -lnsl -lsocket"
fi
AC_CHECK_HEADERS([pcap.h],,[AC_MSG_ERROR([cannot find libpcap headers])])
AC_CHECK_LIB(pcap, pcap_open_live,
[PCAPLIB="-lpcap"],
[AC_MSG_ERROR([cannot find libpcap])])
AC_MSG_CHECKING([for pcap_setnonblock in pcap.h])
_TMP=$LIBS
LIBS=$PCAPLIB
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ pcap_setnonblock(); ]])],[ have_pcap_setnonblock="yes" ],[ have_pcap_setnonblock="no" ])
LIBS=$_TMP
if test x$have_pcap_setnonblock = "xyes"; then
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_PCAP_SETNONBLOCK, 1, [have pcap_nonblock()])
else
AC_MSG_RESULT([no])
fi
AC_CHECK_LIB(dl, dlopen,
[DLLIB="-ldl"])
dnl # Checks for XML lib
if test -z "$XML2_DIR" ; then
AC_PATH_PROG(XML_CONFIG, xml2-config, no)
if test "$XML_CONFIG" = "no" ; then
AC_MSG_WARN([cannot find xml2-config])
else
XML_LIBS=`$XML_CONFIG --libs`
XML_CFLAGS=`$XML_CONFIG --cflags`
LDFLAGS="$LDFLAGS $XML_LIBS"
CFLAGS="$CFLAGS $XML_CFLAGS"
CXXFLAGS="$CXXFLAGS $XML_CFLAGS"
CPPFLAGS="$CPPFLAGS $XML_CFLAGS"
fi
else
LDFLAGS="$LDFLAGS -L$XML2_DIR/lib -lz -lm"
CFLAGS="$CFLAGS -I$XML2_DIR/include"
CXXFLAGS="$CXXFLAGS -I$XML2_DIR/include"
CPPFLAGS="$CPPFLAGS -I$XML2_DIR/include"
fi
if test "$XSLT_DIR" ; then
LDFLAGS="$LDFLAGS -L$XSLT_DIR/lib"
CFLAGS="$CFLAGS -I$XSLT_DIR/include"
CXXFLAGS="$CXXFLAGS -I$XSLT_DIR/include"
CPPFLAGS="$CPPFLAGS -I$XSLT_DIR/include"
fi
AC_CHECK_HEADERS([libxml/parser.h],,[AC_MSG_ERROR([cannot find libxml2 headers])])
AC_CHECK_LIB(xml2, xmlParseFile,
[XMLLIB="-lxml2"],
[AC_MSG_ERROR([cannot find libxml2])])
dnl # check xslt lib
AC_CHECK_HEADERS([libxslt/transform.h libxslt/xsltutils.h],,
[AC_MSG_WARN([cannot find xslt headers])])
AC_CHECK_LIB(xslt, xsltApplyStylesheet,
[XSLTLIB="-lxslt"],
[AC_MSG_WARN([cannot find libxsltl])])
if test "$CURL_DIR" ; then
LDFLAGS="$LDFLAGS -L$CURL_DIR/lib -lxslt"
CFLAGS="$CFLAGS -I$CURL_DIR/include"
CXXFLAGS="$CXXFLAGS -I$CURL_DIR/include"
CPPFLAGS="$CPPFLAGS -I$CURL_DIR/include"
fi
dnl # check for libcurl
AC_CHECK_HEADERS([curl/curl.h],,[AC_MSG_WARN([cannot find curl headers])])
AC_CHECK_LIB(curl, curl_easy_init,
[CURLLIB="-lcurl"],
[AC_MSG_WARN([cannot find libcurl])])
if test "$CURLLIB" ; then
AC_MSG_CHECKING([for curl_free in curl.h])
_TMP=$LIBS
LIBS=$CURLLIB
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ curl_free(); ]])],[ have_curl_free="yes" ],[ have_curl_free="no" ])
LIBS=$_TMP
if test x$have_curl_free = "xyes"; then
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_CURL_FREE, 1, [have curl_free()])
else
AC_MSG_RESULT([no])
AC_MSG_WARN([you should install libcurl 7.10 or newer])
fi
fi
dnl # dont try to build nmrsh if we don't have the libs
AM_CONDITIONAL(BUILD_NMRSH, test "$XSLTLIB" && test "$CURLLIB")
dnl # check for ERF lib
have_erf="yes"
AC_CHECK_HEADERS([erf.h],,[ have_erf="no" ])
AC_CHECK_LIB(dagtools, erf_create_context,
[ERFLIB="-ldagtools"],[ have_erf="no" ])
if test x$have_erf = "xyes"; then
AC_DEFINE(HAVE_ERF, 1, [have erf lib])
fi
AM_CONDITIONAL(ENABLE_ERF, test x$have_erf = xyes)
dnl # check for FOKUS ipfix lib
have_ipfix="yes"
AC_CHECK_HEADERS([ipfix.h ipfix_fields.h],,[ have_ipfix="no" ])
AC_CHECK_LIB(ipfix, ipfix_open, [IPFIXLIB="-lipfix"],[have_ipfix="no"])
AM_CONDITIONAL(ENABLE_IPFIX, test x$have_ipfix = xyes)
dnl # checks for programs
AC_CHECK_PROG(DOXY,doxygen,doxygen,[])
if test "$DOXY" = "" ; then
AC_MSG_WARN([doxygen not installed, can not build documentation])
fi
dnl # set version and data
dnl # Output substitution
AC_DEFINE_UNQUOTED(BUILD_TIME, "`date +"%d/%m/%Y %H:%M:%S"`", "release date")
dnl # set default directories
if test "${prefix}" = "NONE" ; then
prefix=${ac_default_prefix}
fi
sysconfdir="${sysconfdir}/$PACKAGE"
DEF_SYSCONFDIR=`eval echo ${sysconfdir}`
AC_DEFINE_UNQUOTED(DEF_SYSCONFDIR, "$DEF_SYSCONFDIR", "sysconfig dir")
DEF_STATEDIR=`eval echo ${localstatedir}`
AC_DEFINE_UNQUOTED(DEF_STATEDIR, "$DEF_STATEDIR", "state dir")
libdir="${libdir}/$PACKAGE"
if test "${exec_prefix}" = "NONE" ; then
exec_prefix=${prefix}
fi
DEF_LIBDIR=`eval echo ${libdir}`
AC_DEFINE_UNQUOTED(DEF_LIBDIR, "$DEF_LIBDIR", "lib dir")
DEF_BINDIR=`eval echo ${bindir}`
AC_DEFINE_UNQUOTED(DEF_BINDIR, "$DEF_BINDIR", "bin dir")
AC_SUBST(VERSION)
AC_SUBST(REL_DATE)
AC_SUBST(OS)
AC_SUBST(ENABLE_NF)
AC_SUBST(ENABLE_TEST)
AC_SUBST(ENABLE_DEBUG)
AC_SUBST(ENABLE_ERF)
AC_SUBST(ENABLE_IPFIX)
AC_SUBST(READLINELIB)
AC_SUBST(HISTORYLIB)
AC_SUBST(PTHREADLIB)
AC_SUBST(DLLIB)
AC_SUBST(PCAPLIB)
AC_SUBST(SSLLIB)
AC_SUBST(ULOGLIB)
AC_SUBST(XMLLIB)
AC_SUBST(XSLTLIB)
AC_SUBST(MATHLIB)
AC_SUBST(ERFLIB)
AC_SUBST(IPFIXLIB)
AC_SUBST(USE_SSL)
AC_SUBST(SSL_PASSWD)
AC_SUBST(IPTABLES_VERSION)
AC_SUBST(MPATROLLIB)
AC_SUBST(CURLLIB)
AC_SUBST(DEF_SYSCONFDIR)
AC_SUBST(DEF_STATEDIR)
AC_SUBST(DEF_LIBDIR)
AC_SUBST(DEF_BINDIR)
AC_SUBST(DOXY)
AC_OUTPUT(Makefile \
src/Makefile \
src/include/Makefile \
src/lib/Makefile \
src/lib/httpd/Makefile \
src/lib/getopt_long/Makefile \
src/lib/getpass/Makefile \
src/netmate/Makefile \
src/proc_modules/Makefile \
src/export_modules/Makefile \
src/nmrsh/Makefile \
src/test/Makefile \
doc/Makefile \
doc/Doxyfile \
etc/Makefile \
etc/netmate.conf.xml \
etc/nmctl \
etc/gen_cert.sh \
dist/Makefile \
dist/netmate.spec \
dist/netmate-ssl.spec \
tools/Makefile
)