-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.in
480 lines (452 loc) · 14.2 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
dnl $Id$
dnl Process this file with autoconf to produce a configure script.
AC_INIT(dds.c)
dnl Checks for programs.
AC_PROG_CC
AC_PATH_PROG(PERL, perl, perl)
CFLAGS=
dnl Checks for header files.
AC_CHECK_HEADERS(sys/ioctl.h getopt.h grp.h)
AC_CHECK_HEADERS(net/ethernet.h netinet/if_ether.h net/if_dl.h)
dnl Checks for typedefs, structures, and compiler characteristics.
dnl Checks for library functions.
AC_CHECK_FUNCS(inet_addr)
case x$ac_cv_func_inet_addr in
xno)
AC_MSG_CHECKING(for inet_addr in -lxnet)
OLD_LIBS=$LIBS
LIBS="$LIBS -lxnet"
AC_TRY_LINK([#include <arpa/inet.h>],[inet_addr("");],
AC_MSG_RESULT(yes), AC_MSG_RESULT(no); AC_ERROR(no inet_addr() found))
;;
esac
AC_CHECK_FUNCS(daemon getifaddrs localtime_r strsignal initgroups strtoull)
dnl Check for strsignal declaration
case x$ac_cv_func_strsignal in
xyes)
AC_MSG_CHECKING(for strsignal declaration)
AC_TRY_COMPILE([#include <signal.h>
#include <string.h>
int strsignal(int signo);],[], AC_MSG_RESULT(no), AC_DEFINE(HAVE_STRSIGNAL_DECL) AC_MSG_RESULT(yes))
;;
esac
dnl Check for pcap
withval=""
AC_ARG_WITH(pcap,
[ --with-pcap packet capture support (default auto)],
do_pcap=yes, do_pcap=no)
case x$withval in
xno)
do_pcap=no
;;
*)
OLD_LIBS=$LIBS
LIBS="$LIBS -lpcap"
AC_MSG_CHECKING(for libpcap)
AC_TRY_LINK([],[pcap_open_live();],AC_MSG_RESULT(yes); have_pcap=yes,
AC_MSG_RESULT(no); LIBS=$OLD_LIBS; have_pcap=no)
case x$have_pcap in
xno)
case x$do_pcap in
xyes)
AC_MSG_WARN([no libpcap found, pcap support disabled])
;;
esac
do_pcap=no
;;
*)
AC_DEFINE(WITH_PCAP)
do_pcap=yes
;;
esac
;;
esac
case x$do_pcap in
xyes)
AC_CHECK_HEADERS(pcap.h)
case x$ac_cv_header_pcap_h in
xno)
AC_CHECK_HEADERS(pcap/pcap.h)
case x$ac_cv_header_pcap_pcap_h in
xno)
AC_MSG_CHECKING(for -I /usr/include/pcap needed for pcap.h)
OLD_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -I /usr/include/pcap"
AC_TRY_COMPILE([#include <pcap.h>],[],
AC_DEFINE(HAVE_PCAP_H) AC_MSG_RESULT(yes); ac_cv_header_ext_pcap_h=yes,
AC_MSG_RESULT(no))
case x$ac_cv_header_ext_pcap_h in
xno)
AC_MSG_CHECKING(for -I /usr/contrib/include needed for pcap.h)
CFLAGS="$OLD_CFLAGS -I /usr/contrib/include"
AC_TRY_COMPILE([#include <pcap.h>],[],
AC_DEFINE(HAVE_PCAP_H) AC_MSG_RESULT(yes); ac_cv_header_ext2_pcap_h=yes,
AC_MSG_RESULT(no))
;;
esac
;;
esac
;;
esac
AC_MSG_CHECKING(for pcap_open_live_new())
AC_TRY_LINK([],[pcap_open_live_new();],
dnl AC_CHECK_LIB(pcap, pcap_open_live_new,
AC_DEFINE(HAVE_PCAP_OPEN_LIVE_NEW) AC_MSG_RESULT(yes); live_new=yes,
AC_MSG_RESULT(no))
case x$live_new in
xyes)
OLD_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -Wimplicit-function-declaration -Werror"
AC_MSG_CHECKING(for pcap_open_live_new() proto)
AC_TRY_COMPILE([
#if defined(HAVE_PCAP_H)
#include <pcap.h>
#elif defined(HAVE_PCAP_PCAP_H)
#include <pcap/pcap.h>
#endif
], [pcap_open_live_new();],
AC_MSG_RESULT(yes),
AC_DEFINE(NEED_PCAP_OPEN_LIVE_NEW_PROTO) AC_MSG_RESULT(no))
CFLAGS=$OLD_CFLAGS
OLD_CFLAGS=
;;
esac
AC_MSG_CHECKING(for pkt_type in struct pcap_pkthdr)
AC_TRY_COMPILE([
#if defined(HAVE_PCAP_H)
#include <pcap.h>
#elif defined(HAVE_PCAP_PCAP_H)
#include <pcap/pcap.h>
#endif
], [struct pcap_pkthdr pk; pk.pkt_type;],
AC_DEFINE(HAVE_PKT_TYPE) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
;;
esac
dnl Check for embedded perl
AC_ARG_WITH(perl,
[ --with-perl embedded perl support (default no)],
do_perl=yes, do_perl=no)
case x$do_perl in
xyes)
AC_MSG_CHECKING(for libperl)
PERLDIR=`$PERL -MConfig -e 'print $Config{archlib}' 2>/dev/null`
if PERLCOPT=`$PERL -MExtUtils::Embed -e ccopts 2>/dev/null`
then
PERLLOPT=`$PERL -MExtUtils::Embed -e ldopts`
case x$PERLDIR in
x)
AC_MSG_RESULT(yes)
;;
*)
AC_MSG_RESULT($PERLDIR)
;;
esac
else
case x$PERLDIR in
x)
AC_MSG_RESULT(no)
;;
*)
PERLCOPT="-I $PERLDIR/CORE -Dbool=char -DHAS_BOOL"
PERLLOPT="$PERLDIR/auto/DynaLoader/DynaLoader.a -L$PERLDIR/CORE -lperl -ldl -lcrypt -lm"
AC_CHECK_LIB(dl, main, PERLLOPT="$PERLLOPT -ldl")
AC_CHECK_LIB(crypt, main, PERLLOPT="$PERLLOPT -lcrypt")
AC_CHECK_LIB(m, main, PERLLOPT="$PERLLOPT -lm")
AC_CHECK_LIB(socket, main, PERLLOPT="$PERLLOPT -lsocket")
AC_MSG_RESULT($PERLDIR)
;;
esac
fi
case x$PERLCOPT in
x)
;;
*)
AC_MSG_CHECKING(for working libperl)
OLD_LIBS=$LIBS
OLD_CFLAGS=$CFLAGS
LIBS="$LIBS $PERLLOPT"
CFLAGS="$CFLAGS $PERLCOPT"
AC_TRY_RUN([
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
int main(int argc, char** argv, char** env) {
return perl_alloc() ? 0 : 1;
}],
AC_DEFINE(DO_PERL) AC_MSG_RESULT(yes); WORKING_PERL=yes;
perlsrc=ddsperl.c,
AC_MSG_RESULT(no); CFLAGS=$OLD_CFLAGS; LIBS=$OLD_LIBS,
AC_MSG_RESULT(cross-compiling. No assumptions made); CFLAGS=$OLD_CFLAGS; LIBS=$OLD_LIBS
)
;;
esac
;;
esac
dnl Check for trunk
AC_ARG_WITH(vlans,
[ --with-vlans 802.1q vlans support (default no)],
do_trunk=yes, do_trunk=no)
case x$do_trunk in
xyes)
case x$do_pcap in
xno)
AC_MSG_WARN([vlans support declared but no pcap])
;;
*)
AC_CHECK_HEADERS(net/if_vlan_var.h)
;;
esac
;;
*)
AC_DEFINE(NO_TRUNK)
;;
esac
dnl check for struct tcphdr fields
AC_MSG_CHECKING(for th_sport in struct tcphdr)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <netinet/tcp.h>
], [struct tcphdr th; th.th_sport;],
AC_MSG_RESULT(yes),
AC_DEFINE_UNQUOTED(th_sport, source)
AC_DEFINE_UNQUOTED(th_dport, dest)
AC_DEFINE_UNQUOTED(uh_sport, source)
AC_DEFINE_UNQUOTED(uh_dport, dest)
AC_MSG_RESULT(no))
dnl Check for snmp
do_snmp=auto
withval=""
AC_ARG_WITH(snmp,
[ --with-snmp SNMP support (default auto)],
do_snmp=yes, do_snmp=no)
case x$withval in
xno)
;;
*)
AC_CHECK_FUNC(strdup)
AC_CHECK_HEADERS(stdarg.h)
OLD_CFLAGS=$CFLAGS
AC_CHECK_HEADERS(net-snmp/net-snmp-config.h)
case x$ac_cv_header_net_snmp_net_snmp_config_h in
xyes)
snmp_ok=yes
AC_DEFINE(HAVE_NET_SNMP_SNMP_H)
AC_DEFINE(NET_SNMP)
net_snmp=yes
;;
*)
AC_MSG_CHECKING(if net-snmp-config.h is in /usr/local/include/net-snmp)
CFLAGS="$CFLAGS -I /usr/local/include"
AC_TRY_COMPILE([#include <sys/types.h>
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>], [],
AC_MSG_RESULT(yes); snmp_ok=yes,
AC_MSG_RESULT(no); snmp_ok=no)
case x$snmp_ok in
xyes)
AC_DEFINE(HAVE_NET_SNMP_SNMP_H)
AC_DEFINE(NET_SNMP)
net_snmp=yes
;;
*)
CFLAGS="$OLD_CFLAGS"
AC_CHECK_HEADERS(ucd-snmp/ucd-snmp-config.h)
case x$ac_cv_header_ucd_snmp_ucd_snmp_config_h in
xyes)
snmp_ok=yes
AC_DEFINE(HAVE_UCD_SNMP_SNMP_H)
;;
*)
AC_MSG_CHECKING(if ucd-snmp-config.h is in /usr/local/include/ucd-snmp)
OLD_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -I /usr/local/include"
AC_TRY_COMPILE([#include <sys/types.h>
#include <ucd-snmp/ucd-snmp-config.h>
#include <ucd-snmp/asn1.h>
#include <ucd-snmp/snmp.h>], [],
AC_MSG_RESULT(yes); snmp_ok=yes,
AC_MSG_RESULT(no); snmp_ok=no)
case x$snmp_ok in
xyes)
AC_DEFINE(HAVE_UCD_SNMP_SNMP_H)
;;
*)
CFLAGS="$OLD_CFLAGS"
case x$do_snmp in
xyes)
AC_MSG_WARN([net-snmp or ucd-snmp not found, SNMP support disabled])
do_snmp=no
;;
esac
;;
esac
;;
esac
;;
esac
;;
esac
case x$snmp_ok in
xyes)
case x$net_snmp in
xyes)
AC_MSG_CHECKING(for libnetsnmp)
OLD_LIBS="$LIBS"
LIBS="$LIBS -lnetsnmp -lcrypto"
AC_TRY_LINK([],[snmp_sess_init()],
AC_MSG_RESULT(yes), AC_MSG_RESULT(no); snmp_ok=no,
AC_MSG_RESULT(cross-compiling. No assumptions made); snmp_ok=no)
case x$snmp_ok in
xno)
AC_MSG_CHECKING(for libnetsnmp in /usr/local/lib)
OLD_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
AC_TRY_LINK([],[snmp_sess_init()],
AC_MSG_RESULT(yes); snmp_ok=yes, AC_MSG_RESULT(no),
AC_MSG_RESULT(cross-compiling. No assumptions made))
case x$snmp_ok in
xno)
AC_MSG_CHECKING(for -fstack-protector needed for libnetsnmp)
LDFLAGS="$OLD_LDFLAGS -fstack-protector"
AC_TRY_LINK([],[snmp_sess_init()],
AC_MSG_RESULT(yes); snmp_ok=yes, AC_MSG_RESULT(no),
AC_MSG_RESULT(cross-compiling. No assumptions made))
case x$snmp_ok in
xno)
AC_MSG_CHECKING(for -fstack-protector needed for libnetsnmp in /usr/local/lib)
LDFLAGS="$LDFLAGS -L/usr/local/lib"
AC_TRY_LINK([],[snmp_sess_init()],
AC_MSG_RESULT(yes); snmp_ok=yes, AC_MSG_RESULT(no),
AC_MSG_RESULT(cross-compiling. No assumptions made))
case x$snmp_ok in
xno)
LIBS="$OLD_LIBS"
LDFLAGS="$OLD_LDFLAGS"
;;
esac
;;
esac
;;
esac
;;
esac
;;
*)
snmp_ok=no
;;
esac
case x$snmp_ok in
xno)
AC_MSG_CHECKING(for libsnmp)
OLD_LIBS="$LIBS"
LIBS="$LIBS -lsnmp -lcrypto"
AC_TRY_LINK([],[snmp_sess_init()],
AC_MSG_RESULT(yes), AC_MSG_RESULT(no); snmp_ok=no,
AC_MSG_RESULT(cross-compiling. No assumptions made); snmp_ok=no)
case x$snmp_ok in
xno)
AC_MSG_CHECKING(for libsnmp in /usr/local/lib)
OLD_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
AC_TRY_LINK([],[snmp_sess_init()],
AC_MSG_RESULT(yes); snmp_ok=yes, AC_MSG_RESULT(no),
AC_MSG_RESULT(cross-compiling. No assumptions made))
case x$snmp_ok in
xno)
case x$do_snmp in
xyes)
AC_MSG_WARN([libsnmp not found, SNMP support disabled])
do_snmp=no
;;
esac
CFLAGS="$OLD_CFLAGS"
LIBS="$OLD_LIBS"
LDFLAGS="$OLD_LDFLAGS"
;;
esac
;;
esac
;;
esac
;;
esac
case x$snmp_ok in
xyes)
AC_DEFINE(DO_SNMP)
;;
esac
;;
esac
AC_ARG_WITH(zlib,
[ --with-zlib[=path] zlib compression (default auto)],
[do_zlib=$withval],
[do_zlib=auto])
if test ".$do_zlib" != ".no" ; then
AC_MSG_CHECKING(for libz)
save_LIBS="$LIBS"
save_CFLAGS="$CFLAGS"
found_zlib=no
if test ".$do_zlib" = ".yes" -o ".$do_zlib" = ".auto"; then
zlib_paths="/usr /usr/local /usr/local/zlib"
else
zlib_paths="$do_zlib"
fi
for zlib_path in $zlib_paths ; do
if test ! -d "$zlib_path/lib" ; then
continue
fi
if test "$zlib_path" = "/usr" ; then
LIBS="-lz $save_LIBS"
CFLAGS="$save_CFLAGS"
else
LIBS="-L$zlib_path/lib -lz $save_LIBS"
CFLAGS="-I$zlib_path/include $save_CFLAGS"
fi
AC_TRY_LINK(
[
#include <zlib.h>
#ifdef __cplusplus
extern "C"
#endif
],
[
compress2(0, (unsigned long*) 0, "", 0, 6);
uncompress(0, (unsigned long*) 0, "", 0);
],
found_zlib="$zlib_path", found_zlib=no
)
if test ".$found_zlib" != ".no"; then
break
fi
done
if test ".$found_zlib" != ".no"; then
AC_MSG_RESULT(yes: $found_zlib)
AC_DEFINE(WITH_ZLIB)
if test ".$compress_inc." != ".yes." ; then
OPT_SRC="$OPT_SRC compress.c"
compress_inc=yes
fi
else
AC_MSG_RESULT(no)
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
if test ".$do_zlib" != ".auto"; then
AC_ERROR(zlib not found in $zlib_paths)
fi
fi
fi
#AC_ARG_WITH(huge-counters,
# [ --with-huge-counters use 64-bit counters even for single IP-address],
# [AC_DEFINE(WITH_LONGLONG_COUNTERS)],[])
dnl Set dirs
logdir=/var/log/dds
AC_ARG_WITH(logdir,
[ --with-logdir=path log files directory (default /var/log/dds)],
[logdir=$withval],[])
AC_DEFINE_UNQUOTED(LOGDIR, "$logdir")
dnl Set debug flags
AC_ARG_WITH(debug,
[ --with-debug compile with debug info],
[CFLAGS="-g $CFLAGS"],[CFLAGS="-O3 $CFLAGS"])
AC_SUBST(perlsrc)
AC_OUTPUT(Makefile)