forked from phaag/nfdump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
executable file
·467 lines (407 loc) · 12.3 KB
/
configure.ac
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
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_REVISION($Revision: 244 $)dnl
AC_INIT(nfdump, 1.6.22, [email protected])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE([subdir-objects])
# Checks for programs.
CFLAGS="-g -O3"
AC_PROG_CC([clang gcc])
AX_CHECK_C11
CFLAGS="$CFLAGS -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -fno-strict-aliasing"
LT_INIT
AC_ARG_ENABLE(devel,
[ --enable-devel compile debug and development code into nfdump; default is NO])
if test "${enable_devel}" = "yes" ; then
CFLAGS="$CFLAGS -DDEVEL -fno-omit-frame-pointer -fsanitize=address"
fi
AC_ARG_ENABLE(nsel,
[ --enable-nsel compile nfdump, to read and process ASA/NSEL/NEL event data; default is NO])
if test "${enable_nsel}" = "yes" ; then
CFLAGS="$CFLAGS -DNSEL"
fi
AC_ARG_ENABLE(jnat,
[ --enable-jnat compile nfdump, to read and process Junos NAT event logging; default is NO])
if test "${enable_jnat}" = "yes" ; then
CFLAGS="$CFLAGS -DNSEL -DJUNOS"
fi
if test "${enable_nsel}" = "yes" -a "${enable_jnat}" = "yes"; then
AC_MSG_ERROR(You can use only one of --enable-nsel or --enable-jnat. CISCO and Juniper are not compatible.)
fi
AC_ARG_ENABLE(nel,
[ --enable-nel (depricated) compile nfdump, to read and process NAT/NSEL/NEL event data; default is NO])
if test "${enable_nel}" = "yes" ; then
CFLAGS="$CFLAGS -DNSEL"
fi
AC_ARG_ENABLE(fixtimebug,
[ --enable-fixtimebug enable code for swap time bug of some v5 exporters; default is NO])
if test "${enable_fixtimebug}" = "yes" ; then
CFLAGS="$CFLAGS -DFIXTIMEBUG"
fi
AC_PROG_YACC
AC_PROG_LEX
which $LEX > /dev/null 2>&1
if test $? = 1; then
AC_MSG_ERROR(No lex or flex found on system)
fi
AC_PROG_INSTALL
if test "x$ac_cv_prog_LEX" = "xflex"; then
LFLAGS=-i
fi
# Check if we need to build the flow-tools converter
# FIXME? This should use flow-tools-dev if possible, not local sources..
AC_ARG_WITH(ftpath,
[ --with-ftpath=PATH Expect flow-tool sources in PATH; default /usr/local/flow-tools/],
if test "x$with_ftpath" = "xyes" ; then
WHERE_FTPATH="/usr/local/flow-tools/"
else
WHERE_FTPATH=$with_ftpath
fi
,
WHERE_FTPATH="/usr/local/flow-tools/"
)
AC_ARG_WITH(rrdpath,
[ --with-rrdpath=PATH Expect RRD installed in PATH; default /usr/local],
if test "x$with_rrdpath" = "xyes" ; then
CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
LDFLAGS="${LDFLAGS} -L/usr/local/lib"
else
CPPFLAGS="${CPPFLAGS} -I${with_rrdpath}/include"
LDFLAGS="${LDFLAGS} -L${with_rrdpath}/lib"
fi
,
)
AC_ARG_WITH(pcappath,
[ --with-pcappath=PATH Expect libpcap installed in PATH; default /usr/local],
if test "x$with_pcappath" = "xyes" ; then
CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
LDFLAGS="${LDFLAGS} -L/usr/local/lib"
else
CPPFLAGS="${CPPFLAGS} -I${with_pcappath}/include"
LDFLAGS="${LDFLAGS} -L${with_pcappath}/lib"
fi
,
)
#Tidz up? esp not using in source dist flow-tools
AC_ARG_ENABLE(ftconv,
[ --enable-ftconv Build the flow-tools to nfdump converter; default is NO],
AC_CHECK_LIB(z, zlibVersion,,
AC_MSG_ERROR(Link with "-lz" failed! (Need zlib >= 1.0.2))
)
if test -d "$WHERE_FTPATH"; then
if test ! -f "$WHERE_FTPATH/include/ftlib.h"; then
AC_MSG_ERROR(ftlib.h file not found in flow-tools directory '$WHERE_FTPATH'. Use --with-ftpath=PATH)
fi
if test -f "$WHERE_FTPATH/lib/libft.a" -o -f "$WHERE_FTPATH/lib64/libft.a" -o -f "$WHERE_FTPATH/lib/libft.so" -o -f "$WHERE_FTPATH/lib64/libft.so"; then
FT_INCLUDES="-I$WHERE_FTPATH/include -I$WHERE_FTPATH/lib"
FT_LDFLAGS="-L$WHERE_FTPATH/lib"
else
AC_MSG_ERROR(libft.a not found in flow-tools directory '$WHERE_FTPATH'. Build flow tools first)
fi
else
AC_MSG_ERROR(flow-tools directory '$WHERE_FTPATH' does not exists. Use --with-ftpath=PATH)
fi
AM_CONDITIONAL(FT2NFDUMP, true)
,
AM_CONDITIONAL(FT2NFDUMP, false)
)
#Needs tidy
AC_ARG_ENABLE(nfprofile,
[ --enable-nfprofile Build nfprofile used by NfSen; default is NO],
[
AC_CHECK_LIB(rrd, rrd_update,[
cat >>config.h <<_ACEOF
#define HAVE_LIBRRD 1
_ACEOF
RRD_LIBS="-lrrd"
AC_SUBST(RRD_LIBS)
]
, AC_MSG_ERROR(Can not link librrd. Please specify --with-rrdpath=.. configure failed! ))
AC_CHECK_HEADERS([rrd.h])
if test "$ac_cv_header_rrd_h" = yes; then
AM_CONDITIONAL(NFPROFILE, true)
else
AC_MSG_ERROR(Required rrd.h header file not found!)
fi
AC_COMPILE_IFELSE(
[ AC_LANG_PROGRAM(
[[
#include <stdio.h>
#include <rrd.h>
]],
[[
rrd_value_t d;
]])
],, AC_MSG_ERROR(Can not load rrd library. Not in loader search path! ))
]
,
AM_CONDITIONAL(NFPROFILE, false)
)
AC_ARG_ENABLE(influxdb, [AS_HELP_STRING([--enable-influxdb], [enable stats to influxdb (default is no)])], [
influxdb=${enableval} ], [influxdb=no])
AS_IF([test "x$influxdb" = xyes], [
PKG_CHECK_MODULES([curl], [libcurl],,
[AC_MSG_ERROR([No pkg-config for libcurl])])
AC_SUBST(CURL_CFLAGS)
AC_SUBST(CURL_LIBS)
#CFLAGS="${CFLAGS} ${CURL_CFLAGS}"
#LIBS="${LIBS} ${LIBS_CFLAGS}"
AC_CHECK_LIB([curl], [curl_easy_init],,[AC_MSG_ERROR([libcurl required!])])
AC_CHECK_LIB([curl], [curl_easy_escape],,[AC_MSG_ERROR([libcurl required!])])
AC_CHECK_LIB([curl], [curl_easy_setopt],,[AC_MSG_ERROR([libcurl required!])])
AC_CHECK_LIB([curl], [curl_easy_cleanup],,[AC_MSG_ERROR([libcurl required!])])
AC_CHECK_LIB([curl], [curl_free],,[AC_MSG_ERROR([libcurl required!])])
AC_DEFINE_UNQUOTED(HAVE_INFLUXDB, 1, [enable stats to influxdb])
AM_CONDITIONAL(INFLXDB, true)
],
AM_CONDITIONAL(INFLXDB, false)
)
AC_ARG_ENABLE(nftrack,
[ --enable-nftrack Build nftrack used by PortTracker; default is NO],
[
AC_CHECK_LIB(rrd, rrd_update,[
cat >>config.h <<_ACEOF
#define HAVE_LIBRRD 1
_ACEOF
RRD_LIBS="-lrrd"
AC_SUBST(RRD_LIBS)
]
, AC_MSG_ERROR(Can not link librrd. Please specify --with-rrdpath=.. configure failed! ))
AC_CHECK_HEADERS([rrd.h])
if test "$ac_cv_header_rrd_h" = yes; then
AM_CONDITIONAL(NFTRACK, true)
else
AC_MSG_ERROR(Required rrd.h header file not found!)
fi
AC_COMPILE_IFELSE(
[ AC_LANG_PROGRAM(
[[
#include <stdio.h>
#include <rrd.h>
]],
[[
rrd_value_t d;
]])
],, AC_MSG_ERROR(Can not load rrd library. Not in loader search path! ))
]
,
AM_CONDITIONAL(NFTRACK, false)
)
AC_ARG_ENABLE(sflow,
[ --enable-sflow Build sflow collector sfcpad; default is NO])
AM_CONDITIONAL(SFLOW, test "$enable_sflow" = yes)
AC_ARG_ENABLE(readpcap,
[ --enable-readpcap Build nfcapd collector to read from pcap file instead of network data; default is NO])
AM_CONDITIONAL(READPCAP, test "$enable_readpcap" = yes)
AC_ARG_ENABLE(nfpcapd,
[ --enable-nfpcapd Build nfpcapd collector to create netflow data from interface or pcap data; default is NO],
[
AC_CHECK_LIB(pcap, pcap_create,[
cat >>config.h <<_ACEOF
#define HAVE_LIBPCAP 1
_ACEOF
PCAP_LIBS="-lpcap"
AC_SUBST(PCAP_LIBS)
]
, AC_MSG_ERROR(Can not link libpcap. Please specify --with-pcappath=.. configure failed! ))
AC_CHECK_HEADERS([pcap.h])
if test "$ac_cv_header_pcap_h" = yes; then
AM_CONDITIONAL(BUILDNFPCAPD, true)
else
AC_MSG_ERROR(Required pcap.h header file not found!)
fi
AC_COMPILE_IFELSE(
[ AC_LANG_PROGRAM(
[[
#include <stdio.h>
#include <pcap.h>
]],
[[
struct pcap_pkthdr p;
]])
],, AC_MSG_ERROR(Can not load pcap library. Not in loader search path! ))
]
,
AM_CONDITIONAL(BUILDNFPCAPD, false)
)
# Check for structures
AC_CHECK_MEMBER([struct sockaddr.sa_len],
AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, define if socket address structures have length fields),,[
#include <sys/types.h>
#include <sys/socket.h>])
AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family,
struct sockaddr_storage.__ss_family,
struct sockaddr_storage.ss_len,
struct sockaddr_storage.__ss_len,
struct sockaddr.sa_len], [], [], [
#include <sys/types.h>
#include <sys/socket.h>
])
#AC_SUBST(opt_objects)
AC_SUBST(FT_INCLUDES)
AC_SUBST(FT_LDFLAGS)
AC_SUBST(LFLAGS)
# Checks for libraries.
AC_CHECK_FUNCS(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname,,[AC_CHECK_LIB(socket,gethostbyname)])])
AC_CHECK_FUNCS(setsockopt,,[AC_CHECK_LIB(socket,setsockopt)])
dnl checks for fpurge or __fpurge
AC_CHECK_FUNCS(fpurge __fpurge)
AC_MSG_CHECKING([if htonll is defined])
dnl # Check for htonll
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <arpa/inet.h>
]],
[[
return htonll(0);
]]
)],
[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_HTONLL, 1, [Define to 1 if the function (or macro) htonll exists.])
],
[
AC_MSG_RESULT(no)
]
)
# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS(stdio_ext.h)
AC_CHECK_HEADERS([nameser8_compat.h])
AC_CHECK_HEADERS([features.h arpa/inet.h fcntl.h netinet/in.h fts.h stdint.h stdlib.h stddef.h string.h sys/socket.h syslog.h unistd.h iso/limits_iso.h])
AC_CHECK_HEADERS(pcap-bpf.h net/bpf.h)
AC_CHECK_HEADERS(sys/types.h netinet/in.h arpa/nameser.h arpa/nameser_compat.h netdb.h resolv.h netinet/in_systm.h,
[], [],
[[#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h> /* inet_ functions / structs */
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h> /* DNS HEADER struct */
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif]])
AC_CHECK_HEADERS([bzlib.h])
if test "$ac_cv_header_bzlib_h" = no; then
AC_MSG_ERROR(Required bzlib.h header file not found!)
fi
if test "$ac_cv_header_fts_h" != yes; then
FTS_OBJ=fts_compat.o
fi
AC_SUBST(FTS_OBJ)
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_SIZEOF(void *)
AC_C_CONST
AC_C_INLINE
AC_C_BIGENDIAN
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_STRUCT_TM
AC_HEADER_STDBOOL
# Checks for library functions.
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_FUNC_MKTIME
AC_FUNC_REALLOC
AC_FUNC_STAT
AC_FUNC_STRFTIME
AC_CHECK_FUNCS(inet_ntoa socket strchr strdup strerror strrchr strstr scandir)
dnl The res_search may be in libsocket as well, and if it is
dnl make sure to check for dn_skipname in libresolv, or if res_search
dnl is in neither of these libs, still check for dn_skipname in libresolv
AC_CHECK_LIB(socket, res_search, [
AC_CHECK_LIB(resolv, dn_skipname)
AC_CHECK_LIB(resolv, __dn_skipname)
LIBS="$LIBS -lsocket"
AC_DEFINE(HAVE_LIBSOCKET,1,[ ]) ], [
AC_CHECK_LIB(resolv, res_search, [
LIBS="$LIBS -lresolv"
AC_DEFINE(HAVE_LIBRESOLV,1,[ ])
], [
AC_CHECK_LIB(resolv, dn_skipname)
AC_CHECK_LIB(resolv, __dn_skipname)
])
])
AC_CHECK_LIB(bz2, BZ2_bzCompressInit, [
LIBS="$LIBS -lbz2"
], [])
# lzo compression requirements
AC_CHECK_TYPE(ptrdiff_t, long)
AC_TYPE_SIZE_T
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(__int64)
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(size_t)
AC_CHECK_SIZEOF(time_t)
AC_CHECK_SIZEOF(ptrdiff_t)
AC_C_CONST
AC_CHECK_FUNCS(memcmp memcpy memmove memset)
AC_MSG_CHECKING([for union semun])
AC_CACHE_VAL(ac_cv_struct_semun,
[
AC_TRY_COMPILE(
[
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>;
],
[
union semun semdat;
],
ac_cv_struct_semun=yes, ac_cv_struct_semun=no
)
]
)
AC_MSG_RESULT($ac_cv_struct_semun)
if test "$ac_cv_struct_semun" = "yes"; then
AC_DEFINE(HAVE_SEMUN, 1, [Define if sys/sem.h defines struct semun])
fi
AC_MSG_CHECKING(for the %z format string in printf())
AC_TRY_RUN([
#include <stdio.h>
#include <sys/types.h>
int main() {
int i;
size_t s;
char string[16];
s = 12345;
i = snprintf(string,16,"%zu", s);
return i == 5 ? 0 : 1;
}
],
[
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_SIZE_T_Z_FORMAT], [1],
[Define to 1 if you have a printf() that supports the %z format string.])
],
[
AC_MSG_RESULT(no)
],
[
AC_MSG_RESULT(no)
]
)
AC_PATH_PROG([DOXYGEN], [doxygen], [])
AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
AM_COND_IF([HAVE_DOXYGEN], AC_CONFIG_FILES([doc/Doxyfile]))
AC_OUTPUT(doc/Makefile)
#AC_CONFIG_FILES([Makefile])
AC_OUTPUT(Makefile bin/Makefile man/Makefile)
echo ""
echo "* Many thanks for using nfdump tools"
echo "* Please send bug reports back to me: [email protected]"
echo "* or open a ticket at https://github.com/phaag/nfdump/issues"
echo "* You may want to subscribe to the nfdump-discuss and/or"
echo "* nfsen-discuss mailing list:"
echo "* http://lists.sourceforge.net/lists/listinfo/nfdump-discuss"
echo "* http://lists.sourceforge.net/lists/listinfo/nfsen-discuss"