forked from the-tcpdump-group/libpcap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
2989 lines (2781 loc) · 84.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
dnl
dnl Copyright (c) 1994, 1995, 1996, 1997
dnl The Regents of the University of California. All rights reserved.
dnl
dnl Process this file with autoconf to produce a configure script.
dnl
#
# See
#
# https://ftp.gnu.org/gnu/config/README
#
# for the URLs to use to fetch new versions of config.guess and
# config.sub.
#
AC_PREREQ([2.69])
AC_INIT([pcap],[m4_esyscmd_s(cat VERSION)],[https://github.com/the-tcpdump-group/libpcap/issues])
AC_CONFIG_SRCDIR(pcap.c)
AC_SUBST(PACKAGE_NAME)
#
# These are the variables that are used in Makefile, pcap-config, and
# libpcap.pc.
#
# CFLAGS: inherited from the environment, not modified by us except
# for flags required for the platform for which we're building (and
# except temporarily during tests that involve compilation). Used only
# when compiling C source.
#
# LDFLAGS: inherited from the environment, not modified by us.
#
# LIBS: inherited from the environment; we add libraries required by
# libpcap. Libraries that the core libpcap code requires are added
# first; libraries required by additional pcap modules are first
# added to ADDITIONAL_LIBS, and only added to LIBS at the end, after
# we're finished doing configuration tests for the modules.
#
# LIBS_STATIC: libraries with which a program using the libpcap *static*
# library needs to be linked. This is a superset of LIBS, used in
# pcap-config, so that "pcap-config --libs --static" will report them.
# Initialized to LIBS.
#
# REQUIRES_PRIVATE: pkg-config package names for additional libraries
# with which a program using the libpcap *static* library needs to be
# linked and for which a .pc file exists. This is used in libpcap.pc,
# so that "pkg-config --libs --static" will report them, and so that
# those libraries will be determined using the library's .pc file, not
# from our .pc file. Initialized to an empty string.
#
# V_CCOPT: additional compiler flags other than -I and -D flags
# needed when compiling libpcap. Used in Makefile for both C and
# C++ source.
#
# V_DEFS: additional -D compiler flags needed when compiling
# libpcap. Used in Makefile for both C and C++ source.
#
# V_INCLS: additional -I compiler flags needed when compiling
# libpcap. Used in Makefile for both C and C++ source.
#
# ADDITIONAL_LIBS: additional libraries with which the libpcap dynamic
# library needs to be linked. Used in Makefile; not used in pcap-config
# or libpcap.pc, as, in all platforms on which we run, if a dynamic
# library is linked with other dynamic libraries, a program using
# that dynamic library doesn't have to link with those libraries -
# they will be automatically loaded at run time. Initialized to an
# empty string.
#
# ADDITIONAL_LIBS_STATIC: additional libraries with which a program
# using the libpcap *static* library needs to be linked. This is used
# in pcap-config, so that "pcap-config --libs --static" will report
# them. Initialized to an empty string.
#
# REQUIRES_PRIVATE: pkg-config package names for additional libraries
# with which a program using the libpcap *static* library needs to be
# linked and for which a .pc file exists. This is used in libpcap.pc,
# so that "pkg-config --libs --static" will report them, and so that
# those libraries will be determined using the library's .pc file, not
# from our .pc file. Initialized to an empty string.
#
# LIBS_PRIVATE: pkg-config package names for additional libraries with
# which a program using the libpcap *static* library needs to be linked
# and for which a .pc file does not exist. This is used in libpcap.pc,
# so that "pkg-config --libs --static" will report them (those libraries
# cannot be determined using the library's .pc file, as there is no such
# file, so it has to come from our .pc file. Initialized to an empty
# string.
#
LIBS_STATIC=""
REQUIRES_PRIVATE=""
LIBS_PRIVATE=""
AC_SUBST(V_CCOPT)
AC_SUBST(V_DEFS)
AC_SUBST(V_INCLS)
AC_SUBST(LIBS_STATIC)
AC_SUBST(REQUIRES_PRIVATE)
AC_SUBST(LIBS_PRIVATE)
AC_CANONICAL_HOST
AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
#
# We require C99 or later.
# Try to get it, which may involve adding compiler flags;
# if that fails, give up.
#
AC_PROG_CC_C99
if test "$ac_cv_prog_cc_c99" = "no"; then
AC_MSG_WARN([The C compiler does not support C99; there may be compiler errors])
fi
#
# Try to arrange for large file support.
#
AC_SYS_LARGEFILE
AC_FUNC_FSEEKO
#
# Get the size of a void *, to determine whether this is a 32-bit
# or 64-bit build.
#
AC_CHECK_SIZEOF([void *])
ac_lbl_c_sizeof_void_p="$ac_cv_sizeof_void_p"
#
# Get the size of a time_t, to know whether it's 32-bit or 64-bit.
#
AC_CHECK_SIZEOF([time_t],,[#include <time.h>])
AC_LBL_C_INIT(V_CCOPT, V_INCLS)
AC_LBL_SHLIBS_INIT
AC_PCAP_C___ATOMICS
dnl
dnl HAVE_SYS_IOCCOM_H will be required for a few workarounds until all
dnl supported OSes that use BPF have <net/bpf.h> that includes <sys/ioccom.h>
dnl (this might have already happened).
dnl
AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h)
AC_CHECK_HEADERS(netpacket/packet.h)
#
# Check whether the platform for which we're compiling requires extra
# defines and libraries. If so, add them to CFLAGS and LIBS, as we want
# all subsequent tests to be done with those defines and libraries.
#
case "$host_os" in
haiku*)
#
# Haiku needs _BSD_SOURCE for the _IO* macros because it doesn't
# use them.
#
CFLAGS="$CFLAGS -D_BSD_SOURCE"
#
# Haiku has getpass in libbsd.
#
AC_CHECK_LIB(bsd, getpass)
;;
esac
AC_CHECK_FUNC(strerror_r,
[
#
# We have strerror_r; if we define _GNU_SOURCE, is it a
# POSIX-compliant strerror_r() or a GNU strerror_r()?
#
AC_MSG_CHECKING(whether strerror_r is GNU-style)
AC_COMPILE_IFELSE(
[
AC_LANG_SOURCE(
#define _GNU_SOURCE
#include <string.h>
/* Define it GNU-style; that will cause an error if it's not GNU-style */
extern char *strerror_r(int, char *, size_t);
int
main(void)
{
return 0;
}
)
],
[
# GNU-style
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GNU_STRERROR_R, 1,
[Define to 1 if you have a GNU-style `strerror_r' function.])
],
[
AC_MSG_RESULT(no)
AC_DEFINE(HAVE_POSIX_STRERROR_R, 1,
[Define to 1 if you have a POSIX-style `strerror_r' function.])
])
],
[
#
# We don't have strerror_r; do we have _wcserror_s?
#
AC_CHECK_FUNCS(_wcserror_s)
])
#
# Thanks, IBM, for not providing vsyslog() in AIX!
#
AC_CHECK_FUNCS(vsyslog)
#
# Require a proof of suitable snprintf(3), same as in tcpdump.
#
AC_MSG_CHECKING([whether snprintf is suitable])
AC_RUN_IFELSE(
[
AC_LANG_SOURCE([[
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <sys/types.h>
#if defined(_WIN32) && !defined(_SSIZE_T_DEFINED)
/*
* On UN*Xes, this is a signed integer type of the same size as size_t.
*
* It's not defined by Visual Studio; we assume that ptrdiff_t will
* be a type that is a signed integer type of the same size as size_t.
*/
typedef ptrdiff_t ssize_t;
#endif
/*
* Avoid trying to cast negative values to unsigned types, or doing
* shifts of signed types, in order not to have the test program fail
* if we're building with undefined-behavior sanitizers enabled.
*/
int main()
{
char buf[100];
unsigned int ui = sizeof(buf);
int i = sizeof(buf);
int64_t i64 = INT64_C(0x100000000);
uint64_t ui64 = UINT64_C(0x100000000);
snprintf(buf, sizeof(buf), "%zu", (size_t)ui);
if (strncmp(buf, "100", sizeof(buf)))
return 1;
snprintf(buf, sizeof(buf), "%zd", (ssize_t)(-i));
if (strncmp(buf, "-100", sizeof(buf)))
return 2;
snprintf(buf, sizeof(buf), "%" PRId64, -i64);
if (strncmp(buf, "-4294967296", sizeof(buf)))
return 3;
snprintf(buf, sizeof(buf), "0o%" PRIo64, ui64);
if (strncmp(buf, "0o40000000000", sizeof(buf)))
return 4;
snprintf(buf, sizeof(buf), "0x%" PRIx64, ui64);
if (strncmp(buf, "0x100000000", sizeof(buf)))
return 5;
snprintf(buf, sizeof(buf), "%" PRIu64, ui64);
if (strncmp(buf, "4294967296", sizeof(buf)))
return 6;
return 0;
}
]])
],
[
AC_MSG_RESULT(yes)
],
[
AC_MSG_RESULT(no)
AC_MSG_ERROR(
[The snprintf(3) implementation in this libc is not suitable,
libpcap would not work correctly even if it managed to compile.])
],
[
AC_MSG_RESULT(not while cross-compiling)
]
)
needasprintf=no
AC_CHECK_FUNCS(vasprintf asprintf,,
[needasprintf=yes])
if test $needasprintf = yes; then
AC_LIBOBJ([asprintf])
fi
needstrlcat=no
AC_CHECK_FUNCS(strlcat,,
[needstrlcat=yes])
if test $needstrlcat = yes; then
AC_LIBOBJ([strlcat])
fi
needstrlcpy=no
AC_CHECK_FUNCS(strlcpy,,
[needstrlcpy=yes])
if test $needstrlcpy = yes; then
AC_LIBOBJ([strlcpy])
fi
needstrtok_r=no
AC_CHECK_FUNCS(strtok_r,,
[needstrtok_r=yes])
if test $needstrtok_r = yes; then
AC_LIBOBJ([strtok_r])
fi
#
# Do this before checking for ether_hostton(), as it's a
# "getaddrinfo()-ish function".
#
AC_LBL_LIBRARY_NET
#
# Check for reentrant versions of getnetbyname_r(), as provided by
# Linux (glibc), Solaris, and AIX (with three different APIs!).
# If we don't find one, we just use getnetbyname(), which uses
# thread-specific data on many platforms, but doesn't use it on
# NetBSD or OpenBSD, and may not use it on older versions of other
# platforms.
#
# Only do the check if we have a declaration of getnetbyname_r();
# without it, we can't check which API it has. (We assume that
# if there's a declaration, it has a prototype, so that the API
# can be checked.)
#
AC_CHECK_DECL(getnetbyname_r,
[
AC_MSG_CHECKING([for the Linux getnetbyname_r()])
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <netdb.h>]],
[[
struct netent netent_buf;
char buf[1024];
struct netent *resultp;
int h_errnoval;
return getnetbyname_r((const char *)0, &netent_buf, buf, sizeof buf, &resultp, &h_errnoval);
]])],
[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_LINUX_GETNETBYNAME_R, 1,
[define if we have the Linux getnetbyname_r()])
],
[
AC_MSG_RESULT(no)
AC_MSG_CHECKING([for Solaris getnetbyname_r()])
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <netdb.h>]],
[[
struct netent netent_buf;
char buf[1024];
return getnetbyname_r((const char *)0, &netent_buf, buf, (int)sizeof buf) != NULL;
]])],
[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_SOLARIS_GETNETBYNAME_R, 1,
[define if we have the Solaris getnetbyname_r()])
],
[
AC_MSG_RESULT(no)
AC_MSG_CHECKING([for AIX getnetbyname_r()])
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <netdb.h>]],
[[
struct netent netent_buf;
struct netent_data net_data;
return getnetbyname_r((const char *)0, &netent_buf, &net_data);
]])],
[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_AIX_GETNETBYNAME_R, 1,
[define if we have the AIX getnetbyname_r()])
],
[
AC_MSG_RESULT(no)
])
])
])
],,[#include <netdb.h>])
#
# Check for reentrant versions of getprotobyname_r(), as provided by
# Linux (glibc), Solaris, and AIX (with three different APIs!).
# If we don't find one, we just use getprotobyname(), which uses
# thread-specific data on many platforms, but doesn't use it on
# NetBSD or OpenBSD, and may not use it on older versions of other
# platforms.
#
# Only do the check if we have a declaration of getprotobyname_r();
# without it, we can't check which API it has. (We assume that
# if there's a declaration, it has a prototype, so that the API
# can be checked.)
#
AC_CHECK_DECL(getprotobyname_r,
[
AC_MSG_CHECKING([for the Linux getprotobyname_r()])
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <netdb.h>]],
[[
struct protoent protoent_buf;
char buf[1024];
struct protoent *resultp;
return getprotobyname_r((const char *)0, &protoent_buf, buf, sizeof buf, &resultp);
]])],
[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_LINUX_GETPROTOBYNAME_R, 1,
[define if we have the Linux getprotobyname_r()])
],
[
AC_MSG_RESULT(no)
AC_MSG_CHECKING([for Solaris getprotobyname_r()])
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <netdb.h>]],
[[
struct protoent protoent_buf;
char buf[1024];
return getprotobyname_r((const char *)0, &protoent_buf, buf, (int)sizeof buf) != NULL;
]])],
[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_SOLARIS_GETPROTOBYNAME_R, 1,
[define if we have the Solaris getprotobyname_r()])
],
[
AC_MSG_RESULT(no)
AC_MSG_CHECKING([for AIX getprotobyname_r()])
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <netdb.h>]],
[[
struct protoent protoent_buf;
struct protoent_data proto_data;
return getprotobyname_r((const char *)0, &protoent_buf, &proto_data);
]])],
[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_AIX_GETPROTOBYNAME_R, 1,
[define if we have the AIX getprotobyname_r()])
],
[
AC_MSG_RESULT(no)
])
])
])
],,[#include <netdb.h>])
#
# You are in a twisty little maze of UN*Xes, all different.
# Some might not have ether_hostton().
# Some might have it and declare it in <net/ethernet.h>.
# Some might have it and declare it in <netinet/ether.h>
# Some might have it and declare it in <sys/ethernet.h>.
# Some might have it and declare it in <arpa/inet.h>.
# Some might have it and declare it in <netinet/if_ether.h>.
# Some might have it and not declare it in any header file.
#
# Before you is a C compiler.
#
AC_CHECK_FUNCS(ether_hostton)
if test "$ac_cv_func_ether_hostton" = yes; then
#
# OK, we have ether_hostton(). Is it declared in <net/ethernet.h>?
#
# This test fails if we don't have <net/ethernet.h> or if we do
# but it doesn't declare ether_hostton().
#
AC_CHECK_DECL(ether_hostton,
[
AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_HOSTTON, 1,
[Define to 1 if net/ethernet.h declares `ether_hostton'])
],,
[
#include <net/ethernet.h>
])
#
# Did that succeed?
#
if test "$ac_cv_have_decl_ether_hostton" != yes; then
#
# No, how about <netinet/ether.h>, as on Linux?
#
# This test fails if we don't have <netinet/ether.h>
# or if we do but it doesn't declare ether_hostton().
#
# Unset ac_cv_have_decl_ether_hostton so we don't
# treat the previous failure as a cached value and
# suppress the next test.
#
unset ac_cv_have_decl_ether_hostton
AC_CHECK_DECL(ether_hostton,
[
AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON, 1,
[Define to 1 if netinet/ether.h declares `ether_hostton'])
],,
[
#include <netinet/ether.h>
])
fi
#
# Did that succeed?
#
if test "$ac_cv_have_decl_ether_hostton" != yes; then
#
# No, how about <sys/ethernet.h>, as on Solaris 10
# and later?
#
# This test fails if we don't have <sys/ethernet.h>
# or if we do but it doesn't declare ether_hostton().
#
# Unset ac_cv_have_decl_ether_hostton so we don't
# treat the previous failure as a cached value and
# suppress the next test.
#
unset ac_cv_have_decl_ether_hostton
AC_CHECK_DECL(ether_hostton,
[
AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON, 1,
[Define to 1 if sys/ethernet.h declares `ether_hostton'])
],,
[
#include <sys/ethernet.h>
])
fi
#
# Did that succeed?
#
if test "$ac_cv_have_decl_ether_hostton" != yes; then
#
# No, how about <arpa/inet.h>, as in AIX?
#
# This test fails if we don't have <arpa/inet.h>
# (if we have ether_hostton(), we should have
# networking, and if we have networking, we should
# have <arpa/inet.h>) or if we do but it doesn't
# declare ether_hostton().
#
# Unset ac_cv_have_decl_ether_hostton so we don't
# treat the previous failure as a cached value and
# suppress the next test.
#
unset ac_cv_have_decl_ether_hostton
AC_CHECK_DECL(ether_hostton,
[
AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_HOSTTON, 1,
[Define to 1 if arpa/inet.h declares `ether_hostton'])
],,
[
#include <arpa/inet.h>
])
fi
#
# Did that succeed?
#
if test "$ac_cv_have_decl_ether_hostton" != yes; then
#
# No, how about <netinet/if_ether.h>?
# On some platforms, it requires <net/if.h> and
# <netinet/in.h>, and we always include it with
# both of them, so test it with both of them.
#
# This test fails if we don't have <netinet/if_ether.h>
# and the headers we include before it, or if we do but
# <netinet/if_ether.h> doesn't declare ether_hostton().
#
# Unset ac_cv_have_decl_ether_hostton so we don't
# treat the previous failure as a cached value and
# suppress the next test.
#
unset ac_cv_have_decl_ether_hostton
AC_CHECK_DECL(ether_hostton,
[
AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON, 1,
[Define to 1 if netinet/if_ether.h declares `ether_hostton'])
],,
[
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
])
fi
#
# After all that, is ether_hostton() declared?
#
if test "$ac_cv_have_decl_ether_hostton" = yes; then
#
# Yes.
#
AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1,
[Define to 1 if you have the declaration of `ether_hostton'])
else
#
# No, we'll have to declare it ourselves.
# Do we have "struct ether_addr" if we include
# <netinet/if_ether.h>?
#
AC_CHECK_TYPES(struct ether_addr,,,
[
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
])
fi
fi
#
# For various things that might use pthreads.
#
AC_CHECK_HEADER(pthread.h,
[
#
# OK, we have pthread.h. Do we have pthread_create in the
# system libraries?
#
AC_CHECK_FUNC(pthread_create,
[
#
# Yes.
#
ac_lbl_have_pthreads="found"
],
[
#
# No - do we have it in -lpthreads?
#
AC_CHECK_LIB(pthreads, pthread_create,
[
#
# Yes - add -lpthreads.
#
ac_lbl_have_pthreads="found"
PTHREAD_LIBS="$PTHREAD_LIBS -lpthreads"
],
[
#
# No - do we have it in -lpthread?
#
AC_CHECK_LIB(pthread, pthread_create,
[
#
# Yes - add -lpthread.
#
ac_lbl_have_pthreads="found"
PTHREAD_LIBS="$PTHREAD_LIBS -lpthread"
],
[
#
# No.
#
ac_lbl_have_pthreads="not found"
])
])
])
],
[
#
# We didn't find pthread.h.
#
ac_lbl_have_pthreads="not found"
]
)
AC_MSG_CHECKING([whether to enable the instrument functions code])
AC_ARG_ENABLE([instrument-functions],
[AS_HELP_STRING([--enable-instrument-functions],
[enable instrument functions code [default=no]])],
[],
[enableval=no])
case "$enableval" in
yes) AC_MSG_RESULT(yes)
AC_DEFINE(ENABLE_INSTRUMENT_FUNCTIONS, 1,
[define if you want to build the instrument functions code])
# Add '-finstrument-functions' instrumentation option to generate
# instrumentation calls for entry and exit to functions.
# Use '--enable-instrument-functions' also with tcpdump (or tcpslice)
# to see the output. See also https://www.tcpdump.org/faq.html#q17.
CFLAGS="$CFLAGS -O0 -ggdb -finstrument-functions"
;;
*) AC_MSG_RESULT(no)
;;
esac
dnl to pacify those who hate protochain insn
AC_MSG_CHECKING(if --disable-protochain option is specified)
AC_ARG_ENABLE(protochain,
AS_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
case "x$enable_protochain" in
xyes) enable_protochain=enabled ;;
xno) enable_protochain=disabled ;;
x) enable_protochain=enabled ;;
esac
if test "$enable_protochain" = "disabled"; then
AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
fi
AC_MSG_RESULT(${enable_protochain})
#
# valgrindtest directly uses the native capture mechanism, but
# only tests with BPF and PF_PACKET sockets; only enable it if
# we have BPF or PF_PACKET sockets.
#
VALGRINDTEST_SRC=
AC_ARG_WITH(pcap,
AS_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
if test ! -z "$with_pcap" ; then
V_PCAP="$withval"
else
#
# Check for a bunch of headers for various packet
# capture mechanisms.
#
AC_CHECK_HEADERS(net/bpf.h)
if test "$ac_cv_header_net_bpf_h" = yes; then
#
# Does it define BIOCSETIF?
# I.e., is it a header for an LBL/BSD-style capture
# mechanism, or is it just a header for a BPF filter
# engine? Some versions of Arch Linux, for example,
# have a net/bpf.h that doesn't define BIOCSETIF;
# as it's a Linux, it should use packet sockets,
# instead.
#
# We need:
#
# sys/types.h, because FreeBSD 10's net/bpf.h
# requires that various BSD-style integer types
# be defined;
#
# sys/time.h, because AIX 5.2 and 5.3's net/bpf.h
# doesn't include it but does use struct timeval
# in ioctl definitions;
#
# sys/ioctl.h and, if we have it, sys/ioccom.h,
# because net/bpf.h defines ioctls;
#
# net/if.h, because it defines some structures
# used in ioctls defined by net/bpf.h;
#
# sys/socket.h, because OpenBSD 5.9's net/bpf.h
# defines some structure fields as being
# struct sockaddrs;
#
# and net/bpf.h doesn't necessarily include all
# of those headers itself.
#
AC_MSG_CHECKING(if net/bpf.h defines BIOCSETIF)
AC_CACHE_VAL(ac_cv_lbl_bpf_h_defines_biocsetif,
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#ifdef HAVE_SYS_IOCCOM_H
#include <sys/ioccom.h>
#endif
#include <net/bpf.h>
#include <net/if.h>
]],
[[u_int i = BIOCSETIF;]])],
[ac_cv_lbl_bpf_h_defines_biocsetif=yes],
[ac_cv_lbl_bpf_h_defines_biocsetif=no]))
AC_MSG_RESULT($ac_cv_lbl_bpf_h_defines_biocsetif)
fi
AC_CHECK_HEADERS(linux/socket.h sys/dlpi.h)
AC_CHECK_HEADERS(config/HaikuConfig.h)
AC_CHECK_HEADERS(hurd.h)
if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then
#
# BPF.
# Check this before DLPI, so that we pick BPF on
# Solaris 11 and later.
#
V_PCAP=bpf
#
# We have BPF, so build valgrindtest with "make test"
# on macOS and FreeBSD (add your OS once there's a
# valgrind for it).
#
case "$host_os" in
freebsd*|darwin*|linux*)
VALGRINDTEST_SRC=valgrindtest.c
;;
esac
elif test "$ac_cv_header_linux_socket_h" = yes; then
#
# No prizes for guessing this one.
#
V_PCAP=linux
VALGRINDTEST_SRC=valgrindtest.c
elif test "$ac_cv_header_sys_dlpi_h" = yes; then
#
# DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others.
#
V_PCAP=dlpi
elif test "$ac_cv_header_config_HaikuConfig_h" = yes; then
#
# Haiku.
#
V_PCAP=haiku
elif test "$ac_cv_header_hurd_h" = yes; then
#
# Hurd.
#
V_PCAP=hurd
else
#
# We don't have any capture type we know about.
# Report an error, and tell the user to configure with
# --with-pcap=null if they want a libpcap that can't
# capture but that can read capture files. That way,
# nobody gets surprised by getting a no-capture
# libpcap without asking for that.
#
AC_MSG_ERROR([No supported packet capture interface was found.
See the INSTALL.md file for information on packet capture support in
various operating systems.
If you want a libpcap that cannot capture packets but that can read
pcap and pcapng files, run configure with --with-pcap=null.])
fi
fi
AC_MSG_CHECKING(packet capture type)
AC_MSG_RESULT($V_PCAP)
AC_SUBST(VALGRINDTEST_SRC)
#
# Do we have pkg-config?
#
PKG_PROG_PKG_CONFIG
#
# Do we have the brew command from Homebrew?
#
AC_PATH_PROG([BREW], [brew])
#
# Solaris pkg-config is annoying. For at least one package (D-Bus, I'm
# looking at *you*!), there are separate include files for 32-bit and
# 64-bit builds (I guess using "unsigned long long" as a 64-bit integer
# type on a 64-bit build is like crossing the beams or something), and
# there are two separate .pc files, so if we're doing a 32-bit build we
# should make sure we look in /usr/lib/pkgconfig for .pc files and if
# we're doing a 64-bit build we should make sure we look in
# /usr/lib/amd64/pkgconfig for .pc files.
#
case "$host_os" in
solaris*)
if test "$ac_cv_sizeof_void_p" -eq 8; then
#
# 64-bit build. If the path is empty, set it to
# /usr/lib/amd64/pkgconfig; otherwise, if
# /usr/lib/pkgconfig appears in the path, prepend
# /usr/lib/amd64/pkgconfig to it; otherwise, put
# /usr/lib/amd64/pkgconfig at the end.
#
if test -z "$PKG_CONFIG_PATH"; then
#
# Not set, or empty. Set it to
# /usr/lib/amd64/pkgconfig.
#
PKG_CONFIG_PATH=/usr/lib/amd64/pkgconfig
elif test ! -z `echo "$PKG_CONFIG_PATH" | grep "/usr/lib/pkgconfig"`; then
#
# It contains /usr/lib/pkgconfig. Prepend
# /usr/lib/amd64/pkgconfig to /usr/lib/pkgconfig.
#
PKG_CONFIG_PATH=`echo "$PKG_CONFIG_PATH" | sed "s;/usr/lib/pkgconfig;/usr/lib/amd64/pkgconfig:/usr/lib/pkgconfig;"`
else
#
# Not empty, but doesn't contain /usr/lib/pkgconfig.
# Append /usr/lib/amd64/pkgconfig to it.
#
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/lib/amd64/pkgconfig"
fi
export PKG_CONFIG_PATH
elif test "$ac_cv_sizeof_void_p" -eq 4; then
#
# 32-bit build. If /usr/amd64/lib/pkgconfig appears
# in the path, prepend /usr/lib/pkgconfig to it.
#
if test ! -z `echo "$PKG_CONFIG_PATH" | grep "/usr/lib/amd64/pkgconfig"`; then
#
# It contains /usr/lib/amd64/pkgconfig. Prepend
# /usr/lib/pkgconfig to /usr/lib/amd64/pkgconfig.
#
PKG_CONFIG_PATH=`echo "$PKG_CONFIG_PATH" | sed "s;/usr/lib/amd64/pkgconfig;/usr/lib/pkgconfig:/usr/lib/amd64/pkgconfig;"`
export PKG_CONFIG_PATH
fi
fi
esac
#
# Handle each capture type.
#
case "$V_PCAP" in
dlpi)
#
# Checks for some header files.
#
AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
#
# Checks to see if Solaris has the public libdlpi(3LIB) library.
# Note: The existence of /usr/include/libdlpi.h does not mean it is the
# public libdlpi(3LIB) version. Before libdlpi was made public, a
# private version also existed, which did not have the same APIs.
# Due to a gcc bug, the default search path for 32-bit libraries does
# not include /lib, we add it explicitly here.
# [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485].
# Also, due to the bug above applications that link to libpcap with
# libdlpi will have to add "-L/lib" option to "configure".
#
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LIBS -L/lib"
AC_CHECK_LIB(dlpi, dlpi_walk,
[
LIBS="-ldlpi $LIBS"
LIBS_STATIC="-ldlpi $LIBS_STATIC"
LIBS_PRIVATE="-ldlpi $LIBS_PRIVATE"
V_PCAP=libdlpi
#
# Capture module plus common code needed for
# common functions used by pcap-[dlpi,libdlpi].c
#
PLATFORM_C_SRC="pcap-libdlpi.c dlpisubs.c"
AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists])
],
[
V_PCAP=dlpi
#
# Capture module plus common code needed for
# common functions used by pcap-[dlpi,libdlpi].c
#
PLATFORM_C_SRC="pcap-dlpi.c dlpisubs.c"
])
LDFLAGS="$save_LDFLAGS"
#
# Checks whether <sys/dlpi.h> is usable, to catch weird SCO
# versions of DLPI.
#
AC_MSG_CHECKING(whether <sys/dlpi.h> is usable)
AC_CACHE_VAL(ac_cv_sys_dlpi_usable,
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[
#include <sys/types.h>
#include <sys/time.h>
#include <sys/dlpi.h>
]],
[[int i = DL_PROMISC_PHYS;]])],
[ac_cv_sys_dlpi_usable=yes],
[ac_cv_sys_dlpi_usable=no]))
AC_MSG_RESULT($ac_cv_sys_dlpi_usable)
if test $ac_cv_sys_dlpi_usable = no ; then
AC_MSG_ERROR(<sys/dlpi.h> is not usable on this system; it probably has a non-standard DLPI)
fi
#
# Check to see if Solaris has the dl_passive_req_t struct defined
# in <sys/dlpi.h>.
# This check is for DLPI support for passive modes.
# See dlpi(7P) for more details.
#
AC_CHECK_TYPES(dl_passive_req_t,,,
[
#include <sys/types.h>
#include <sys/dlpi.h>
])
;;
haiku)
#