-
-
Notifications
You must be signed in to change notification settings - Fork 308
/
configure.ac
2453 lines (2109 loc) · 68.5 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=$(grep VERSION_MAJOR version.h | cut -d'"' -f 2)-$(grep VERSION_MINOR version.h | cut -d'"' -f 2)-$(grep VERSION_TINY version.h | cut -d'"' -f 2)-$(git rev-parse --short HEAD 2>/dev/null || echo 'non-git-release')
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_OPENBSD_WIFI=0
BUILD_CAPTURE_PCAPFILE=0
BUILD_CAPTURE_KISMETDB=1
BUILD_CAPTURE_HACKRF_SWEEP=0
BUILD_CAPTURE_OSX_COREWLAN=0
BUILD_CAPTURE_NRF_MOUSEJACK=0
BUILD_CAPTURE_TI_CC_2540=0
BUILD_CAPTURE_TI_CC_2531=0
BUILD_CAPTURE_UBERTOOTH_ONE=0
BUILD_CAPTURE_SDR_RTL433V2=0
BUILD_CAPTURE_SDR_RTLADSBV2=0
BUILD_CATPURE_FREAKLABS_ZIGBEEV2=1
BUILD_CAPTURE_NRF_51822=0
BUILD_CAPTURE_NXP_KW41Z=0
BUILD_CAPTURE_RZ_KILLERBEE=0
BUILD_CAPTURE_BLADERF_WLAN=0
BUILD_CAPTURE_NRF_52840=0
BUILD_CAPTURE_HAK5_COCONUT=0
BUILD_CAPTURE_USB_RADIACODE=0
BUILD_CAPTURE_ANTSDR_DRONEID=1
# deprecated
BUILD_CAPTURE_SDR_RTL433=0
BUILD_CAPTURE_SDR_RTLAMR=0
BUILD_CAPTURE_SDR_RTLADSB=0
BUILD_CAPTURE_BT_GEIGER=0
BUILD_CAPTURE_FREAKLABS_ZIGBEE=0
BUILD_CAPTURE_PROXY_ADSB=0
DATASOURCE_BINS="\$(CAPTURE_KISMETDB)"
BUILD_PYTHON_MODULES=0
# 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)
openbsd="yes"
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)
openbsd="yes"
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
# Start at the newest C++ and define our way back
AX_CXX_COMPILE_STDCXX(20, , [optional])
if test "$HAVE_CXX20" = "1"; then
AC_DEFINE(HAVE_CXX20, 1, [cpp20 available])
AC_DEFINE(HAVE_CXX17, 1, [cpp17 available])
AC_DEFINE(HAVE_CXX14, 1, [cpp14 available])
AC_DEFINE(HAVE_CXX11, 1, [cpp11 available])
else
AX_CXX_COMPILE_STDCXX(17, , [mandatory])
AC_DEFINE(HAVE_CXX17, 1, [cpp17 available])
AC_DEFINE(HAVE_CXX14, 1, [cpp14 available])
AC_DEFINE(HAVE_CXX11, 1, [cpp11 available])
# else
# AX_CXX_COMPILE_STDCXX(14, ,[mandatory])
# if test "$HAVE_CXX14" = "1"; then
# AC_DEFINE(HAVE_CXX14, 1, [cpp14 available])
# AC_DEFINE(HAVE_CXX11, 1, [cpp11 available])
# fi
fi
# GCC13/14 seem to have over-aggressive/known bad dangling reference detection.
# This gets SUPER noisy in libfmt.
AS_IF([test x"$GCC_MAJOR" = x"13" -o x"$GCC_MAJOR" = x"14"],
[
AC_MSG_WARN([setting -Wno-dangling-reference for gcc${GCC_MAJOR}])
CPPFLAGS="${CPPFLAGS} -Wno-dangling-reference"
],
[]
)
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
# Check for brew
want_homebrew=no
AC_ARG_ENABLE([homebrew],
AS_HELP_STRING([--enable-homebrew], [Automatically enable detecting libraries from homebrew on macOS]),
[case "${enableval}" in
yes) want_homebrew=yes ;;
*) want_homebrew=no ;;
esac],
[want_homebrew=no]
)
AS_IF([test x"$want_homebrew" != x"no"],
[
AC_MSG_CHECKING([for paths from homebrew])
AC_MSG_RESULT([ok])
LDFLAGS="-L`brew --prefix`/lib $LDFLAGS"
CPPFLAGS="-I`brew --prefix`/include -I`brew --prefix openssl`/include $CPPFLAGS"
SSL_DIRS=`brew --prefix openssl`
],
[]
)
# Enable thread debugging
AC_ARG_ENABLE([mutex-name-debug],
AS_HELP_STRING([--disable-mutex-name-debug], [Disable naming of mutexes to help in debugging, debugging will use slightly more RAM]),
[case "${enableval}" in
no) want_mutex_debugging=no ;;
*) AC_DEFINE(DEBUG_MUTEX_NAME, 1, Named mutex debugging) ;;
esac], [AC_DEFINE(DEBUG_MUTEX_NAME, 1, Named mutex debugging)])
# 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]
)
if test $caponly = 0; then
ALLTARGETS='$(STD_ALL)'
else
ALLTARGETS='$(DS_ONLY)'
fi
AC_SUBST(ALLTARGETS)
want_te_typesafety=no
AC_ARG_ENABLE([element-typesafety],
AS_HELP_STRING([--enable-element-typesafety], [Enable runtime type safety debugging of the tracked element system]),
[case "${enableval}" in
no) want_te_typesafety=no ;;
*) want_te_typesafety=yes ;;
esac],
[want_te_typesafety=no]
)
if test "$want_te_typesafety"x == "yes"x; then
AC_DEFINE(TE_TYPE_SAFETY, 1, Enforce runtime type safety)
else
AC_DEFINE(TE_TYPE_SAFETY, 0, Do not enforce runtime type safety)
fi
PROTOBUF=protobuf
AC_ARG_ENABLE([protobuflite],
AS_HELP_STRING([--enable-protobuflite], [Force building with protobuf-lite instead of full protobuf]),
[case "${enableval}" in
yes) PROTOBUF=protobuf-lite ;;
*) ;;
esac],
[]
)
want_python=yes
AC_ARG_ENABLE([python-tools],
AS_HELP_STRING([--disable-python-tools], [Disable building Python modules and Python-only data sources]),
[case "${enableval}" in
no) want_python=no ;;
*) want_python=yes ;;
esac],
[want_python=yes]
)
PYTHON=python3
PYTHON_VERSION=3
AC_ARG_WITH([python-interpreter],
AS_HELP_STRING([--with-python-interpreter=PATH], [Custom location of python interpreter if not in normal PATH]))
AS_IF([test "x$with_python_interpreter" != "x"],
[
PYTHON=$with_python_interpreter
],
[]
)
AC_SUBST(PYTHON)
AC_SUBST(PYTHON_VERSION)
# 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
# Allow disabling mutex timeout, use with caution
AC_ARG_ENABLE(debuglibs,
AS_HELP_STRING([--disable-debuglibs], [Disable libdw and bfd libs which aid in debugging]),
[case "${enableval}" in
no) wantdebuglibs=0 ;;
*) wantdebuglibs=1 ;;
esac],
[wantdebuglibs=1]
)
if test "$wantdebuglibs" = 1; then
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
else
BACKTRACE_WARNING="no - debug libraries disabled by configure"
AC_DEFINE(DISABLE_BACKWARD, 1, disabled by configure arguments)
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 do we do strerror?
AC_MSG_CHECKING([for strerror_r() return])
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <string.h>
], [
int r;
r = strerror_r(1, (char *) NULL, 0);
return 0;
])],[strerror_r_int=yes], [strerror_r_int=no])
if test "$strerror_r_int" = "yes"; then
AC_MSG_RESULT([int])
AC_DEFINE(STRERROR_R_T, [int], [strerror_r return type])
else
AC_MSG_RESULT([char *])
AC_DEFINE(STRERROR_R_T, [char *], [strerror_r return type])
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 always need libz
AC_CHECK_LIB([z], [deflate],
usez=1,
AC_MSG_ERROR([libz is required and could not be found]))
LIBS="$LIBS -lz"
# Do we need -latomic
AC_MSG_CHECKING([for libatomic])
OLIBS="$LIBS"
LIBS="$LIBS -latomic"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
]],
[[
return 0;
]] )], [have_atomic=yes], [have_atomic=no])
if test "$have_atomic" = "yes"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
LIBS="$OLIBS"
fi
# 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
# 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)
# 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,
AS_HELP_STRING([--disable-mutextimeout], [Disable failsafe thread mutex timer, use with caution]),
[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,
AS_HELP_STRING([--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
# Look for capability support
AC_ARG_ENABLE(libcap,
AS_HELP_STRING([--disable-libcap], [Disable libcap capabilities]),
[case "${enableval}" in
no) wantlibcap=no ;;
*) wantlibcap=yes ;;
esac],
[wantlibcap=yes]
)
if test "$wantlibcap" = "yes"; then
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
fi
fi # linux
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,
AS_HELP_STRING([--disable-pcre], [Disable PCRE regex]),
[case "${enableval}" in
no) wantpcre=no ;;
*) wantpcre=yes ;;
esac],
[wantpcre=yes]
)
AC_ARG_ENABLE(require-pcre2,
AS_HELP_STRING([--enable-require-pcre2], [Explicitly require libpcre2]),
[case "${enableval}" in
yes) needpcre2=yes ;;
*) needpcre2=no ;;
esac],
[needpcre2=no]
)
if test "${wantpcre}x" = "nox" -a "${needpcre2}x" = "yesx"; then
AC_MSG_ERROR([Can not combine --disable-pcre and --enable-require-pcre2])
fi
if test "$caponly" == 0; then
if test "$HAVE_CXX17" = "1"; then
AC_MSG_CHECKING([Checking C++17 parallel functions])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <execution>
#include <vector>
]], [[
std::vector<int> x{1, 2};
std::stable_sort(std::execution::par_unseq, x.begin(), x.end(), [&](int, int) -> bool { return false; });
return 0;
]])],
[
AC_MSG_RESULT([ok])
USE_CPP17_PARALLEL=1
AC_DEFINE(HAVE_CPP17_PARALLEL, 1, CPP17 parallel functions work)
],[
AC_MSG_RESULT([fail])
AC_MSG_WARN([Could not use basic C++17 parallel functions])
USE_CPP17_PARALLEL=0
])
if test "$USE_CPP17_PARALLEL" = "0"; then
OCXLIBS="$CXXLIBS"
CXXLIBS="$CXXLIBS -ltbb"
AC_MSG_CHECKING([Checking C++17 parallel functions with libtbb])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <execution>
#include <vector>
]], [[
std::vector<int> x{1, 2};