forked from kismetwireless/kismet
-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure.ac
1734 lines (1493 loc) · 48.1 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
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
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Process this file with autoconf to produce a configure script.
AC_INIT
VERSION=`cat VERSION`
AC_SUBST(VERSION)
#m4_include([m4/acx_pthread.m4])
#m4_include([m4/ax_cxx_compile_stdcxx.m4])
#m4_include([m4/ax_cxx_compile_stdcxx_11.m4])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([kismet.h])
AC_PREREQ(2.57)
# Check for host type
AC_CANONICAL_HOST
# Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_CPP
AC_LANG_CPLUSPLUS
BUILD_CAPTURE_LINUX_WIFI=0
BUILD_CAPTURE_LINUX_BLUETOOTH=0
BUILD_CAPTURE_PCAPFILE=0
BUILD_CAPTURE_HACKRF_SWEEP=0
BUILD_CAPTURE_OSX_COREWLAN=0
BUILD_CAPTURE_SDR_RTL433=1
BUILD_CAPTURE_FREAKLABS_ZIGBEE=1
BUILD_CAPTURE_NRF_MOUSEJACK=0
BUILD_PYTHON_MODULES=1
# Liberated from ethereal's configure.in
#
# Add any platform-specific compiler flags needed.
#
AC_MSG_CHECKING(for platform-specific compiler flags)
if test "x$GCC" = x
then
#
# Not GCC - assume it's the vendor's compiler.
#
case "$host_os" in
darwin10*)
# Snow leopard and newer, no -bundle in plugins
CFLAGS="-no-cpp-precomp $CFLAGS"
LDFLAGS="$LDFLAGS -framework Foundation -framework CoreFoundation -F/System/Library/PrivateFrameworks -framework Apple80211 -framework IOKit"
PLUGINLDFLAGS="-flat_namespace -undefined suppress"
AC_MSG_RESULT(Apple OSX Snow Leopard or newer)
AC_DEFINE(SYS_DARWIN, 1, Compiling for OSX/Darwin)
darwin="yes"
;;
darwin*)
#
# It may be called "cc", but it's really a GCC derivative
# with a problematic special precompiler and precompiled
# headers; turn off the special precompiler, as some
# apparently-legal code won't compile with its precompiled
# headers.
#
CFLAGS="-no-cpp-precomp $CFLAGS"
LDFLAGS="$LDFLAGS -framework Foundation -framework CoreFoundation -F/System/Library/PrivateFrameworks -framework Apple80211 -framework IOKit"
PLUGINLDFLAGS="-bundle -flat_namespace -undefined suppress"
AC_MSG_RESULT(Apple GCC - added Apple80211 frameworks and no-precomp)
AC_DEFINE(SYS_DARWIN, 1, Compiling for OSX/Darwin)
darwin="yes"
;;
linux*)
AC_MSG_RESULT(none needed)
AC_DEFINE(SYS_LINUX, 1, Compiling for Linux OS)
linux="yes"
;;
freebsd*)
AC_MSG_RESULT(none needed)
AC_DEFINE(SYS_FREEBSD, 1, Compiling for FreeBSD)
bsd="yes"
;;
openbsd*)
AC_MSG_RESULT(none needed)
AC_DEFINE(SYS_OPENBSD, 1, Compiling for OpenBSD)
bsd="yes"
;;
netbsd*)
AC_MSG_RESULT(adding pkgsrc locations)
CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
LDFLAGS="$LDFLAGS -L/usr/pkg/lib"
AC_DEFINE(SYS_NETBSD, 1, Compiling for NetBSD)
bsd="yes"
;;
cygwin*)
AC_MSG_RESULT(none needed)
AC_DEFINE(SYS_CYGWIN, 1, Compiling for Cygwin)
cygwin="yes"
;;
*)
AC_MSG_RESULT(none needed)
;;
esac
else
case "$host_os" in
darwin10*)
# Snow leopard and newer, no -bundle in plugins
CFLAGS="-no-cpp-precomp $CFLAGS"
LDFLAGS="$LDFLAGS -framework Foundation -framework CoreFoundation -F/System/Library/PrivateFrameworks -framework Apple80211 -framework IOKit"
PLUGINLDFLAGS="-flat_namespace -undefined suppress"
AC_MSG_RESULT(Apple OSX Snow Leopard or newer)
AC_DEFINE(SYS_DARWIN, 1, Compiling for OSX/Darwin)
darwin="yes"
;;
darwin*)
#
# See comments above about Apple's lovely C compiler.
#
CFLAGS="-no-cpp-precomp $CFLAGS"
LDFLAGS="$LDFLAGS -framework Foundation -framework CoreFoundation -F/System/Library/PrivateFrameworks -framework Apple80211 -framework IOKit"
PLUGINLDFLAGS="-bundle -flat_namespace -undefined suppress"
AC_MSG_RESULT(Apple GCC - added Apple80211 frameworks and no-precomp)
AC_DEFINE(SYS_DARWIN, 1, Compiling for OSX/Darwin)
darwin="yes"
;;
linux*)
AC_MSG_RESULT(none needed)
AC_DEFINE(SYS_LINUX, 1, Compiling for Linux OS)
linux="yes"
;;
freebsd*)
AC_MSG_RESULT(none needed)
AC_DEFINE(SYS_FREEBSD, 1, Compiling for FreeBSD)
bsd="yes"
;;
openbsd*)
AC_MSG_RESULT(none needed)
AC_DEFINE(SYS_OPENBSD, 1, Compiling for OpenBSD)
bsd="yes"
;;
netbsd*)
AC_MSG_RESULT(adding pkgsrc locations)
CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
LDFLAGS="$LDFLAGS -L/usr/pkg/lib"
AC_DEFINE(SYS_NETBSD, 1, Compiling for NetBSD)
bsd="yes"
;;
cygwin*)
AC_MSG_RESULT(none needed)
AC_DEFINE(SYS_CYGWIN, 1, Compiling for Cygwin)
cygwin="yes"
;;
*)
AC_MSG_RESULT(none needed)
;;
esac
# Get the GCC version
AX_GCC_VERSION
GCC_MAJOR=$(echo $GCC_VERSION | cut -s -d'.' -f1)
GCC_MINOR=$(echo $GCC_VERSION | cut -s -d'.' -f2)
GCC_PATCH=$(echo $GCC_VERSION | cut -s -d'.' -f3)
if test "$GCC_MAJOR"x == x; then
GCC_MAJOR=$GCC_VERSION
fi
if test "$GCC_MINOR"x == x; then
GCC_MINOR=0
fi
if test "$GCC_PATCH"x == x; then
GCC_PATCH=0
fi
AC_DEFINE_UNQUOTED(GCC_VERSION_MAJOR, $GCC_MAJOR, [gcc version])
AC_DEFINE_UNQUOTED(GCC_VERSION_MINOR, $GCC_MINOR, [gcc version])
AC_DEFINE_UNQUOTED(GCC_VERSION_PATCH, $GCC_PATCH, [gcc version])
fi
AX_CXX_COMPILE_STDCXX(11, , [mandatory])
AX_CXX_COMPILE_STDCXX(14, ,[optional])
AX_CXX_COMPILE_STDCXX(17, , [optional])
AC_SUBST(PLUGINLDFLAGS)
CXXFLAGS="$CXXFLAGS -O3"
CFLAGS="$CFLAGS -O3"
if test "$cygwin" = "yes"; then
AC_MSG_CHECKING(cygwin compile flags)
AC_MSG_RESULT(__MINGW32__)
CXXFLAGS="$CXXFLAGS -D__MINGW32__"
else
# cygwin doesn't like rdynamic, will this hurt us?
LDFLAGS="$LDFLAGS -rdynamic"
fi
AC_CONFIG_SRCDIR([kismet_server.cc])
AC_CONFIG_HEADER([config.h])
# Config location for code to default to
CONFFILE_DIR=$sysconfdir
CONFFILE_DIR=`(
test "$prefix" = NONE && prefix=$ac_default_prefix
test "$exec_prefix" = NONE && exec_prefix=${prefix}
eval echo "$CONFFILE_DIR"
)`
AC_DEFINE_UNQUOTED(SYSCONF_LOC, "$CONFFILE_DIR", system config directory)
AC_SUBST(CONFFILE_DIR)
LOCALSTATE_DIR=$localstatedir
LOCALSTATE_DIR=`(
test "$prefix" = NONE && prefix=$ac_default_prefix
test "$exec_prefix" = NONE && exec_prefix=${prefix}
eval echo "$LOCALSTATE_DIR"
)`
AC_DEFINE_UNQUOTED(LOCALSTATE_DIR, "$LOCALSTATE_DIR", system state directory)
AC_SUBST(LOCALSTATE_DIR)
BIN_DIR=$bindir
BIN_DIR=`(
test "$prefix" = NONE && prefix=$ac_default_prefix
test "$exec_prefix" = NONE && exec_prefix=${prefix}
eval echo "$BIN_DIR"
)`
AC_DEFINE_UNQUOTED(BIN_LOC, "$BIN_DIR", system binary directory)
AC_SUBST(BIN_DIR)
LIB_DIR=$libdir
LIB_DIR=`(
test "$prefix" = NONE && prefix=$ac_default_prefix
test "$exec_prefix" = NONE && exec_prefix=${prefix}
eval echo "$LIB_DIR"
)`
AC_DEFINE_UNQUOTED(LIB_LOC, "$LIB_DIR", system library directory)
AC_SUBST(LIB_DIR)
DATA_DIR=$datarootdir
DATA_DIR=`(
test "$prefix" = NONE && prefix=$ac_default_prefix
test "$exec_prefix" = NONE && exec_prefix=${prefix}
eval echo "$DATA_DIR"
)`
AC_DEFINE_UNQUOTED(DATA_LOC, "$DATA_DIR", system data directory)
AC_SUBST(DATA_DIR)
BASE_DIR=`(
test "$prefix" = NONE && prefix=$ac_default_prefix
test "$exec_prefix" = NONE && exec_prefix=${prefix}
eval echo "$prefix"
)`
AC_SUBST(BASE_DIR)
# Check for endian
AC_C_BIGENDIAN
# Checks for header files.
AC_CHECK_HEADERS([errno.h stdlib.h string.h sys/socket.h sys/time.h sys/wait.h unistd.h sys/types.h netdb.h],
AC_DEFINE(HAVE_SYSHEADERS, 1, System headers are there),
AC_MSG_ERROR(Missing required system header))
AC_CHECK_HEADERS([getopt.h])
AC_CHECK_HEADERS([glob.h])
# Configure for a remote-capture-only build
caponly=0
AC_ARG_ENABLE(capture-tools-only,
[ --enable-capture-tools-only Configure and build for capture tools and remote only],
[case "${enableval}" in
no) caponly=0 ;;
*) caponly=1 ;;
esac],
[caponly=0]
)
AC_ARG_ENABLE([python-tools],
AS_HELP_STRING([--disable-python-tools], [Disable Python modules and Python-only data sources]),
[want_python=no],
[want_python=yes])
if test "$want_python"x == "no"x; then
BUILD_PYTHON_MODULES=0
BUILD_CAPTURE_SDR_RTL433=0
BUILD_CAPTURE_FREAKLABS_ZIGBEE=0
AC_MSG_WARN([Disabling Python and Python-related tools])
else
AC_PYTHON_MODULE(setuptools)
if test "$HAVE_PYMOD_SETUPTOOLS" == "no"; then
AC_MSG_ERROR([Missing python-setuptools, if you would like to build without python entirely, use --disable-python-tools, otherwise install python-setuptools])
else
DATASOURCE_BINS="$DATASOURCE_BINS \$(CAPTURE_SDR_RTL433) \$(CAPTURE_FREAKLABS_ZIGBEE)"
fi
fi
AC_SUBST(BUILD_PYTHON_MODULES)
HAVE_LIBHACKRF=0
HAVE_LIBFFTW3=0
HAVE_HACKRF_H=0
HAVE_FFTW3_H=0
BUILD_CAPTURE_HACKRF_SWEEP=0
HACKRF_MISSING_REASON="Missing required libhack/libfftw3 libraries"
AC_CHECK_HEADERS([libhackrf/hackrf.h],
HAVE_HACKRF_H=1,
AC_MSG_WARN("Missing hackrf.h from libhackrf"))
AC_CHECK_HEADERS([fftw3.h],
HAVE_FFTW3_H=1,
AC_MSG_WARN("Missing fftw3.h from libfftw"))
if test "$HAVE_HACKRF_H" = 1; then
AC_CHECK_LIB([hackrf], [hackrf_init],
HAVE_LIBHACKRF=1,
AC_MSG_WARN([libhackrf not available]))
else
HACKRF_MISSING_REASON="Missing libhackrf/hackrf.h"
fi
if test "$HAVE_FFTW3_H" = 1; then
AC_CHECK_LIB([fftw3], [fftw_malloc],
HAVE_LIBFFTW3=1,
AC_MSG_WARN([libfftw3 not available]))
else
HACKRF_MISSING_REASON="missing libfftw3.h"
fi
if test "$HAVE_LIBHACKRF" = 1 && test "$HAVE_LIBFFTW3" = 1; then
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <libhackrf/hackrf.h>
]], [[
int s = SAMPLES_PER_BLOCK;
return 0;
]])],[hackrfsweep=1],[hackrfsweep=0])
if test "$hackrfsweep" = 1; then
AC_DEFINE(BUILD_CAPTURE_HACKRF_SWEEP, 1, Able to build hackrf sweep source)
# BUILD_CAPTURE_HACKRF_SWEEP=1
# DATASOURCE_BINS="$DATASOURCE_BINS \$(CAPTURE_HACKRF_SWEEP)"
else
AC_MSG_WARN([Old version of libhack does not contain sweep code])
HACKRF_MISSING_REASON="old version of libhackrf found"
fi
else
HACKRF_MISSING_REASON="missing libhackrf or libfftw3"
fi
HAVE_LIBDW=0
HAVE_LIBBFD=0
AC_CHECK_LIB([dw], [dwarf_begin], HAVE_LIBDW=1)
AC_CHECK_LIB([bfd], [bfd_alloc], HAVE_LIBBFD=1)
if test "$HAVE_LIBDW" = 1; then
AC_CHECK_HEADERS([elfutils/libdw.h elfutils/libdwfl.h dwarf.h], DEF_BW_HAS_LIBDW=1)
fi
if test "$HAVE_LIBBFD" = 1; then
AC_CHECK_HEADERS([bfd.h], DEF_BW_HAS_BFD=1)
fi
DEF_BW_HAS_UNWIND=0
DEF_BW_HAS_BACKTRACE=0
BACKTRACE_OK=0
AC_CHECK_HEADERS([unwind.h], DEF_BW_HAS_UNWIND=1)
AC_CHECK_HEADERS([execinfo.h], DEF_BW_HAS_BACKTRACE=1)
if test "$DEF_BW_HAS_UNWIND" = 1; then
BACKTRACE_WARNING="yes - Full debug info available on crash, using unwind"
AC_DEFINE(BACKWARD_HAS_UNWIND, 1, unwind stack support)
AC_DEFINE(BACKWARD_HAS_BACKTRACE, 0, no backtrace stack support)
BACKTRACE_OK=1
elif test "$DEF_BW_HAS_BACKTRACE" = 1; then
BACKTRACE_WARNING="yes - Full debug info available on crash, using backtrace"
AC_DEFINE(BACKWARD_HAS_BACKTRACE, 1, backtrace stack support)
BACKTRACE_OK=1
else
BACKTRACE_OK=0
BACKTRACE_WARNING="no - Backtraces will not be available on crashes"
AC_DEFINE(DISABLE_BACKWARD, 1, cannot support backtrace dumping)
fi
if test "$BACKTRACE_OK" = 1; then
# Libdw is the best support
if test "$DEF_BW_HAS_LIBDW" = 1; then
AC_DEFINE(BACKWARD_HAS_DW, 1, libdl for stack printing)
LIBS="$LIBS -ldw"
elif test "$DEF_BW_HAS_BFD" = 1; then
AC_DEFINE(BACKWARD_HAS_BFD, 1, libbfd for stack printing)
LIBS="$LIBS -lbfd"
elif test "$DEF_BW_HAS_BACKTRACE" = 1; then
AC_DEFINE(BACKWARD_HAS_BACKTRACE_SYMBOL, 1, backtrace stack support)
BACKTRACE_WARNING="partial - Missing libdw or libbfd will not print full stacks on crash"
else
BACKTRACE_OK=0
BACKTRACE_WARNING="no - Backtraces will not be available on crashes"
AC_DEFINE(DISABLE_BACKWARD, 1, cannot support backtrace dumping)
fi
fi
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_HEADER_TIME
AC_STRUCT_TM
# Checks for library functions.
AC_HEADER_STDC
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_CHECK_FUNCS([gettimeofday memset select socket strcasecmp strftime strstr])
# Do we have getopt_long natively?
AC_MSG_CHECKING([for system-level getopt_long()])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include <unistd.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
]], [[
static struct option long_options[] = { /* options table */
{ "null-arg", required_argument, 0, 'n' },
{ 0, 0, 0, 0 }
};
int s;
int option_index;
int argc;
char **argv;
s = getopt_long(argc, argv, "n:", long_options, &option_index);
]])],[sys_getopt=yes],[sys_getopt=no])
if test "$sys_getopt" = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_GETOPT_LONG, 1, system defines getopt_long)
else
AC_MSG_RESULT([no])
fi
# Look for something to define standard int types
stdint=yes
AC_CHECK_HEADER([stdint.h],
AC_DEFINE(HAVE_STDINT_H, 1, stdint.h is present) stdint=yes,
stdint=no)
if test "$stdint" = "no"; then
inttypes=no
AC_CHECK_HEADER([inttypes.h],
AC_DEFINE(HAVE_INTTYPES_H, 1, inttypes.h is present) inttypes=yes,
inttypes=no)
fi
if test "$stdint" = "no"; then
if test "$inttypes" = "no"; then
AC_MSG_RESULT([failed])
AC_MSG_ERROR(could not find stdint.h or inttypes.h.)
fi
fi
# How does accept() work on this system?
AC_MSG_CHECKING([for accept() addrlen type])
OCFL="$CFLAGS"
CFLAGS="-Werror $CFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
]], [[
int s = 0;
struct sockaddr *addr = NULL;
socklen_t *addrlen = NULL;
accept(s, addr, addrlen);
return 0;
]])],[accept_socklen=yes],[accept_socklen=no])
if test "$accept_socklen" = "yes"; then
AC_MSG_RESULT([socklen_t])
AC_DEFINE(HAVE_SOCKLEN_T, 1, accept() takes type socklen_t for addrlen)
else
AC_MSG_RESULT([int])
fi
CFLAGS="$OCFL"
# Do we have pipe2?
AC_MSG_CHECKING([for pipe2])
OCFL="$CFLAGS"
CFLAGS="-Werror $CFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <unistd.h>
]], [[
int fd[2], flags;
pipe2(fd, flags);
return 0;
]])],[have_pipe2=yes],[have_pipe2=no])
if test "$have_pipe2" = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_PIPE2, 1, System has pipe2)
else
AC_MSG_RESULT(NO)
fi
CFLAGS="$OCFL"
# Do we have large file support?
AC_SYS_LARGEFILE
# Do we need to use -ldl?
usedl=0
AC_CHECK_LIB([dl], [dlopen],
usedl=1,
AC_MSG_WARN([libdl doesn't seem to be needed on this system]))
if test "$usedl" = 1; then
LIBS="$LIBS -ldl"
CLIENTCLIBS="$CLIENTCLIBS -ldl"
fi
# We need libz
AC_CHECK_LIB([z], [deflate],
usez=1,
AC_MSG_ERROR([libz is required and could not be found]))
LIBS="$LIBS -lz"
# We need threads
PTHREAD_CFLAGS="-pthread"
PTHREAD_LIBS="-lpthread"
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_LIBS)
AC_MSG_CHECKING([for pthread_mutex_timedlock])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include <pthread.h>
]], [[
pthread_mutex_timedlock(NULL, NULL);
return 0;
]])], [have_timedlock=yes],
[have_timedlock=no])
if test "$have_timedlock" = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_PTHREAD_TIMELOCK, [1], [have pthread timelock])
else
AC_MSG_RESULT([no])
fi
OCPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS -fopenmp"
OLDFLAGS=$LDFLAGS
LDFLAGS="$CPPFLAGS -fopenmp"
AC_MSG_CHECKING([for __gnu_parallel extensions])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <vector>
#include <parallel/algorithm>
]], [[
std::vector<int> m;
__gnu_parallel::sort(m.begin(), m.end());
return 0;
]])], [have_gnuparallel=yes],
[have_gnuparallel=no])
if test "$have_gnuparallel" = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_GNU_PARALLEL, [1], [have __GNU_PARALLEL extensions])
else
AC_MSG_RESULT([no])
CPPFLAGS=$OCPPFLAGS
LDFLAGS=$OLDFLAGS
fi
# Do we need libm for math functions?
AC_MSG_CHECKING([for libm math function in std libs])
OCFL="$CFLAGS"
CFLAGS="-Werror $CFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include <math.h>
]], [[
double x;
pow(x, x);
return 0;
]])],[needlibm=no],[needlibm=yes])
CFLAGS="$OCFL"
if test "$needlibm" = "yes"; then
AC_MSG_RESULT([no])
# Do we need to use -lm?
AC_CHECK_LIB([m], [pow],
LIBS="$LIBS -lm",
AC_MSG_ERROR([libm is needed and is not available]))
else
AC_MSG_RESULT([yes])
LIBMLIB="-lm"
AC_SUBST(LIBMLIB)
fi
# Do we use libstdc++?
# We need to swap to the g++ compiler here
oCC="$CC"
CC="$CXX"
AC_CHECK_LIB([stdc++], [main],
foundcxxl="stdc++" CXXLIBS="$CXXLIBS -lstdc++")
if test "$foundcxxl"x == "x" -a "$caponly" != 1; then
AC_MSG_ERROR(No standard stdc++ libraries found.)
fi
CC="$oCC"
AC_SUBST(CXXLIBS)
# Does the compiler handle various std::foo namespaces properly?
oCC="$CC"
CC="$CXX"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <string>
#include <cstdio>
]], [[
char *foo;
std::snprintf(foo, 10, "x");
return 0;
]])],[],[AC_DEFINE(MISSING_STD_SNPRINTF, 1, we need to shim std snprintf)])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <string>
#include <cstdio>
#include <cmath>
]], [[
std::isnan(1.0f);
return 0;
]])],[],[AC_DEFINE(MISSING_STD_ISNAN, 1, we need to shim isnan)])
CC="$oCC"
AC_MSG_CHECKING([for group 'root'])
if test "`grep -e ^root: /etc/group`" = ""; then
AC_MSG_RESULT([no. Using 'wheel'])
instgrp="wheel"
else
AC_MSG_RESULT([yes])
instgrp="root"
fi
AC_SUBST(instgrp)
termcontrol="none";
# We need microhttpd and curses if we're building kismet_server
if test "$caponly" == 0; then
HAVE_LIBMICROHTTPD=0
AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
KSLIBS="$KSLIBS -lmicrohttpd" HAVE_LIBMICROHTTPD=1,
HAVE_LIBMICROHTTPD=0)
if test "$HAVE_LIBMICROHTTPD" == 0 -a "$caponly" == 0; then
AC_MSG_ERROR([libmicrohttpd is needed and is not available])
elif test "$HAVE_LIBMICROHTTPD" = 1; then
AC_CHECK_HEADER([microhttpd.h],
AC_DEFINE(HAVE_MICROHTTPD_H, 1, microhttpd is present),
AC_MSG_ERROR([microhttpd.h is not available check that libmicrohttpd-dev is installed]))
fi
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <microhttpd.h>
]], [[
#if MHD_VERSION <= 0x00093700
#error MHD_TOO_OLD
#endif
]])],[mhd_too_old=0],[mhd_too_old=1])
if test "$mhd_too_old" = 1; then
AC_MSG_ERROR(sorry - libmicrohttpd is too old. Some distributions such as debian jessie ship a version of libmicrohttpd which has several flaws that break Kismet. You will need a new version from your distribution backports or from https://www.gnu.org/software/libmicrohttpd/)
fi
OLIBS="$LIBS"
LIBS="$LIBS -lmicrohttpd"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <microhttpd.h>
]], [[
struct MHD_Daemon *microhttpd = NULL;
MHD_quiesce_daemon(microhttpd);
return 0;
]])],[mhd_quiesce=1],[mhd_quiesce=0])
LIBS="$OLIBS"
if test "$mhd_quiesce" = 1; then
AC_DEFINE(MHD_QUIESCE, 1, Able to use MHD_quiesce_daemon to shut down)
else
AC_MSG_WARN([Unable to use MHD_quiesce_daemon, this might lead to hangs on shutdown])
fi
# Check for ncurses for pretty wrapper; no longer mandatory
OLIBS="$LIBS"
AC_CHECK_LIB([ncurses], [initscr],
AC_DEFINE(HAVE_LIBNCURSES, 1, NCurses terminal lib) \
foundlcurses=yes curseaux="-lncurses" termcontrol="ncurses" )
if test "$foundlcurses" != "yes"; then
AC_CHECK_LIB([curses], [initscr],
AC_DEFINE(HAVE_LIBCURSES, 1, Curses terminal lib) \
foundlcurses=yes curseaux="-lcurses" termcontrol="curses" )
fi
if test "$foundlcurses" != "yes"; then
AC_MSG_WARN(Failed to find libcurses or libncurses. Kismet will be compiled without the pretty wrapper)
fi
AC_CHECK_LIB([ncurses], [stdscr], [], [])
AC_CHECK_LIB([tinfo], [stdscr], curseaux="$curseaux -ltinfo")
if test "$termcontrol" = "ncurses"; then
AC_CHECK_HEADER([ncurses.h], [foundhcurses=yes])
else
AC_CHECK_HEADER([curses.h], [foundhcurses=yes])
fi
if test "$foundhcurses" != "yes"; then
AC_MSG_WARN(Failed to find curses.h or ncurses.h. You probably need to install the curses-devel package from your distribution)
fi
KSLIBS="$KSLIBS $curseaux"
fi # caponly
# Check for process title manipulation stuff, from proftpd configure.in
AC_CHECK_FUNCS(setproctitle)
AC_CHECK_HEADERS(libutil.h)
AC_CHECK_LIB(util, setproctitle,
[AC_DEFINE(HAVE_SETPROCTITLE)
ac_cv_func_setproctitle="yes" ; LIBS="$LIBS -lutil"])
if test "$ac_cv_func_setproctitle" = "yes"; then
AC_DEFINE(PF_ARGV_TYPE, PF_ARGV_NONE)
else
pf_argv_set="no"
AC_CHECK_HEADERS(sys/pstat.h,have_pstat_h="yes",have_pstat_h="no")
if test "$have_pstat_h" = "yes"; then
AC_CHECK_FUNCS(pstat)
if test "$ac_cv_func_pstat" = "yes"; then
AC_DEFINE(PF_ARGV_TYPE, PF_ARGV_PSTAT, pstat argv type)
else
AC_DEFINE(PF_ARGV_TYPE, PF_ARGV_WRITEABLE, writeable argv type)
fi
pf_argv_set="yes"
fi
if test "$pf_argv_set" = "no"; then
AC_EGREP_HEADER([#define.*PS_STRINGS.*],sys/exec.h,
have_psstrings="yes",have_psstrings="no")
if test "$have_psstrings" = "yes"; then
AC_DEFINE(PF_ARGV_TYPE, PF_ARGV_PSSTRINGS)
pf_argv_set="yes"
fi
fi
if test "$pf_argv_set" = "no"; then
AC_CACHE_CHECK(whether __progname and __progname_full are available,
pf_cv_var_progname,
AC_TRY_LINK([extern char *__progname, *__progname_full;],
[__progname = "foo"; __progname_full = "foo bar";],
pf_cv_var_progname="yes", pf_cv_var_progname="no"))
if test "$pf_cv_var_progname" = "yes"; then
AC_DEFINE(HAVE___PROGNAME, 1, __PROGNAME glibc macro available)
fi
AC_CACHE_CHECK(which argv replacement method to use,
pf_cv_argv_type,
AC_EGREP_CPP(yes,[
#if defined(__GNU_HURD__)
yes
#endif
],pf_cv_argv_type="new", pf_cv_argv_type="writeable"))
if test "$pf_cv_argv_type" = "new"; then
AC_DEFINE(PF_ARGV_TYPE, PF_ARGV_NEW, new argv type)
pf_argv_set="yes"
fi
if test "$pf_argv_set" = "no"; then
AC_DEFINE(PF_ARGV_TYPE, PF_ARGV_WRITEABLE, writeable argv type)
fi
fi
fi
# Allow disabling mutex timeout, use with caution
AC_ARG_ENABLE(mutextimeout,
[ --disable-mutextimeout disable failsafe mutex lock timeout],
[case "${enableval}" in
no) wantmutex=0 ;;
*) wantmutex=1 ;;
esac],
[wantmutex=1]
)
if test "$wantmutex" = 0; then
AC_DEFINE(DISABLE_MUTEX_TIMEOUT, 1, [Remove mutex deadlock timeout protection])
fi
linux_wireless="no"
# Check for linux headers if we're on linux systems
if test "$linux" = "yes"; then
AC_ARG_WITH(linuxheaders,
[ --with-linuxheaders[=DIR] Custom location of the Linux kernel headers if the glibc copies are insufficient ],
[
if test "$withval" != no -a "$withval" != "yes"; then
CPPFLAGS="$CPPFLAGS -I$withval"
fi
])
AC_ARG_ENABLE(linuxwext,
[ --disable-linuxwext disable Linux wireless extensions],
[case "${enableval}" in
no) wantwext=no ;;
*) wantwext=yes ;;
esac],
[wantwext=yes]
)
linux_wireless="no"
if test "$wantwext" = "yes"; then
AC_CHECK_HEADER([linux/wireless.h],
[foundwexth=yes],,
[
#include <sys/types.h>
#include <netdb.h>
#include <linux/socket.h>
#include <asm/types.h>
#include <linux/if.h>
])
if test "$foundwexth" != "yes"; then
AC_MSG_ERROR(Failed to find a usable linux/wireless.h header for Linux Wireless Extensions. Either your kernel headers are missing or are incorrect. See config.log for the exact error. Compiling without wireless headers must be explicitly disabled)
fi
AC_MSG_CHECKING(that linux/wireless.h is what we expect)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include <sys/types.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/resource.h>
#include <asm/types.h>
#include <linux/if.h>
#include <linux/wireless.h>
]], [[
struct iwreq wrq;
wrq.u.essid.flags = 0;
]])],[foundwextok=yes])
if test "$foundwextok" != "yes"; then
AC_MSG_RESULT(no)
AC_MSG_ERROR(Failed to find a usable linux/wireless.h header for Linux Wireless Extensions. Either your kernel headers are missing or are incorrect. See config.log for the exact error.)
fi # wexth
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_LINUX_WIRELESS, 1, Linux wireless extentions present)
linux_wireless="yes";
if test "$linux_wireless" = "yes"; then
iwfreqflag=no
AC_MSG_CHECKING(can we use iw_freq.flags)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <asm/types.h>
#include <linux/if.h>
#include <linux/wireless.h>
]], [[
struct iwreq wrq;
wrq.u.freq.flags = IW_FREQ_FIXED;
]])],[iwfreqflag=yes],[iwfreqflag=no])
if test "$iwfreqflag" = "no"; then
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_LINUX_IWFREQFLAG, 1, [Linux wireless iwfreq.flag])
fi
fi
fi # want headers
fi # linux
# Look for capability support
havecap="yes"
AC_CHECK_LIB([cap], [cap_init],,havecap=no)
AC_CHECK_HEADER([sys/prctl.h],, havecap=no)
AC_CHECK_HEADER([sys/capability.h],, havecap=no)
if test "$havecap" = "yes"; then
AC_DEFINE(HAVE_CAPABILITY, 1, kernel capability support)
caplibs="-lcap"
AC_SUBST(caplibs)
fi
AC_ARG_WITH(pcreheaders,
[ --with-pcreheaders[=DIR] Custom location of the PCRE library headers ],
[
if test "$withval" != no -a "$withval" != "yes"; then
CPPFLAGS="$CPPFLAGS -I$withval"
fi
])
AC_ARG_ENABLE(pcre,
[ --disable-pcre disable building pcre components],
[case "${enableval}" in
no) wantpcre=no ;;
*) wantpcre=yes ;;
esac],
[wantpcre=yes]
)
if test "$wantpcre" = "yes"; then
# Check for pcre
pcrel=no
AC_CHECK_LIB([pcre], [pcre_compile], pcrel=yes, pcrel=no)
if test "$pcrel" != "yes"; then
AC_MSG_WARN(Failed to find libpcre)
wantpcre=no
fi
if test "$wantpcre" = "yes"; then
pcreh=no
AC_CHECK_HEADER([pcre.h], pcreh=yes, pcreh=no)
if test "$pcreh" != "yes"; then
AC_MSG_WARN(Failed to find pcre headers check that the pcre-devel package is installed if your distribution provides separate packages)
wantpcre=no
fi
fi # wantpcre
if test "$wantpcre" = "yes"; then
AC_DEFINE(HAVE_LIBPCRE, 1, libpcre regex support)
LIBS="$LIBS -lpcre"
fi # pcre
fi
# Don't check for sqlite3 if we're only building datasources
if test "$caponly" == 0; then
# Check for sqlite3
sql3l=no
AC_CHECK_LIB([sqlite3], [sqlite3_libversion], sql3l=yes, sql3l=no)
if test "$sql3l" != "yes"; then
AC_MSG_ERROR(Failed to find libsqlite3)
fi
sql3h=no
AC_CHECK_HEADER([sqlite3.h], sql3h=yes, sql3h=no)
if test "$sql3h" != "yes"; then
AC_MSG_ERROR(Failed to find sqlite3 headers check that the libsqlite3-devel package is installed if your distribution provides separate packages)
fi
if test "$sql3h" = "yes" -a "$sql3l" = "yes"; then
AC_DEFINE(HAVE_LIBSQLITE3, 1, libsqlite3 database support)
LIBS="$LIBS -lsqlite3"
else
AC_MSG_ERROR(Failed to find sqlite3)
fi # sqlite3
fi # caponly
AC_ARG_ENABLE(prelude,
AS_HELP_STRING([--enable-prelude],
[Enable Prelude SIEM as a target for alerts.]),
[
wantprelude=no
if test "$enableval" != "no"; then
AM_PATH_LIBPRELUDE(1.2.6, , AC_MSG_ERROR(Cannot find libprelude: Is libprelude-config in the path?), no)
CPPFLAGS="${CPPFLAGS} ${LIBPRELUDE_CFLAGS}"
LDFLAGS="${LDFLAGS} ${LIBPRELUDE_LDFLAGS}"
LIBS="${LIBS} ${LIBPRELUDE_LIBS}"
AC_DEFINE([PRELUDE], [1], [Libprelude support enabled])
wantprelude=yes
fi
],[wantprelude=no])
AC_ARG_ENABLE(pcap,
[ --disable-pcap disable libpcap (most sources) capture support],
[case "${enableval}" in
no) wantpcap=no ;;
*) wantpcap=yes ;;
esac],
[wantpcap=yes]