]> The Tcpdump Group git mirrors - tcpdump/blob - aclocal.m4
ntp: always make sure the entire extension field is in the capture.
[tcpdump] / aclocal.m4
1 dnl Copyright (c) 1995, 1996, 1997, 1998
2 dnl The Regents of the University of California. All rights reserved.
3 dnl
4 dnl Redistribution and use in source and binary forms, with or without
5 dnl modification, are permitted provided that: (1) source code distributions
6 dnl retain the above copyright notice and this paragraph in its entirety, (2)
7 dnl distributions including binary code include the above copyright notice and
8 dnl this paragraph in its entirety in the documentation or other materials
9 dnl provided with the distribution, and (3) all advertising materials mentioning
10 dnl features or use of this software display the following acknowledgement:
11 dnl ``This product includes software developed by the University of California,
12 dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
13 dnl the University nor the names of its contributors may be used to endorse
14 dnl or promote products derived from this software without specific prior
15 dnl written permission.
16 dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
17 dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
18 dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 dnl
20 dnl LBL autoconf macros
21 dnl
22
23 dnl
24 dnl Do whatever AC_LBL_C_INIT work is necessary before using AC_PROG_CC.
25 dnl
26 dnl It appears that newer versions of autoconf (2.64 and later) will,
27 dnl if you use AC_TRY_COMPILE in a macro, stick AC_PROG_CC at the
28 dnl beginning of the macro, even if the macro itself calls AC_PROG_CC.
29 dnl See the "Prerequisite Macros" and "Expanded Before Required" sections
30 dnl in the Autoconf documentation.
31 dnl
32 dnl This causes a steaming heap of fail in our case, as we were, in
33 dnl AC_LBL_C_INIT, doing the tests we now do in AC_LBL_C_INIT_BEFORE_CC,
34 dnl calling AC_PROG_CC, and then doing the tests we now do in
35 dnl AC_LBL_C_INIT. Now, we run AC_LBL_C_INIT_BEFORE_CC, AC_PROG_CC,
36 dnl and AC_LBL_C_INIT at the top level.
37 dnl
38 AC_DEFUN(AC_LBL_C_INIT_BEFORE_CC,
39 [
40 AC_BEFORE([$0], [AC_LBL_C_INIT])
41 AC_BEFORE([$0], [AC_PROG_CC])
42 AC_BEFORE([$0], [AC_LBL_DEVEL])
43 AC_ARG_WITH(gcc, [ --without-gcc don't use gcc])
44 $1=""
45 if test "${srcdir}" != "." ; then
46 $1="-I$srcdir"
47 fi
48 if test "${CFLAGS+set}" = set; then
49 LBL_CFLAGS="$CFLAGS"
50 fi
51 if test -z "$CC" -a "$with_gcc" = no ; then
52 CC=cc
53 export CC
54 fi
55 ])
56
57 dnl
58 dnl Determine which compiler we're using (cc or gcc)
59 dnl If using gcc, determine the version number
60 dnl If using cc:
61 dnl require that it support ansi prototypes
62 dnl use -O (AC_PROG_CC will use -g -O2 on gcc, so we don't need to
63 dnl do that ourselves for gcc)
64 dnl add -g flags, as appropriate
65 dnl explicitly specify /usr/local/include
66 dnl
67 dnl NOTE WELL: with newer versions of autoconf, "gcc" means any compiler
68 dnl that defines __GNUC__, which means clang, for example, counts as "gcc".
69 dnl
70 dnl usage:
71 dnl
72 dnl AC_LBL_C_INIT(copt, incls)
73 dnl
74 dnl results:
75 dnl
76 dnl $1 (copt set)
77 dnl $2 (incls set)
78 dnl CC
79 dnl LDFLAGS
80 dnl LBL_CFLAGS
81 dnl
82 AC_DEFUN(AC_LBL_C_INIT,
83 [
84 AC_BEFORE([$0], [AC_LBL_DEVEL])
85 if test "$GCC" = yes ; then
86 #
87 # -Werror forces warnings to be errors.
88 #
89 ac_lbl_cc_force_warning_errors=-Werror
90 else
91 $2="$$2 -I/usr/local/include"
92 LDFLAGS="$LDFLAGS -L/usr/local/lib"
93
94 case "$host_os" in
95
96 darwin*)
97 #
98 # This is assumed either to be GCC or clang, both
99 # of which use -Werror to force warnings to be errors.
100 #
101 # XXX - they also both cause GCC to be set to yes,
102 # so we should never get here in the first place.
103 #
104 ac_lbl_cc_force_warning_errors=-Werror
105 ;;
106
107 hpux*)
108 #
109 # HP C, which is what we presume we're using, doesn't
110 # exit with a non-zero exit status if we hand it an
111 # invalid -W flag, can't be forced to do so even with
112 # +We, and doesn't handle GCC-style -W flags, so we
113 # don't want to try using GCC-style -W flags.
114 #
115 ac_lbl_cc_dont_try_gcc_dashW=yes
116 ;;
117
118 solaris*)
119 #
120 # Assumed to be Sun C, which requires -errwarn to force
121 # warnings to be treated as errors.
122 #
123 ac_lbl_cc_force_warning_errors=-errwarn
124 ;;
125 esac
126 $1="$$1 -O"
127 fi
128 ])
129
130 dnl
131 dnl Check whether the compiler option specified as the second argument
132 dnl is supported by the compiler and, if so, add it to the macro
133 dnl specified as the first argument
134 dnl
135 AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
136 [
137 AC_MSG_CHECKING([whether the compiler supports the $2 option])
138 save_CFLAGS="$CFLAGS"
139 CFLAGS="$CFLAGS $2"
140 #
141 # XXX - yes, this depends on the way AC_LANG_WERROR works,
142 # but no mechanism is provided to turn AC_LANG_WERROR on
143 # *and then turn it back off*, so that we *only* do it when
144 # testing compiler options - 15 years after somebody asked
145 # for it:
146 #
147 # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
148 #
149 save_ac_c_werror_flag="$ac_c_werror_flag"
150 ac_c_werror_flag=yes
151 #
152 # We use AC_LANG_SOURCE() so that we can control the complete
153 # content of the program being compiled. We do not, for example,
154 # want the default "int main()" that AC_LANG_PROGRAM() generates,
155 # as it will generate a warning with -Wold-style-definition, meaning
156 # that we would treat it as not working, as the test will fail if
157 # *any* error output, including a warning due to the flag we're
158 # testing, is generated; see
159 #
160 # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
161 # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
162 #
163 # This may, as per those two messages, be fixed in autoconf 2.70,
164 # but we only require 2.69 or newer for now.
165 #
166 AC_COMPILE_IFELSE(
167 [AC_LANG_SOURCE([[int main(void) { return 0; }]])],
168 [
169 AC_MSG_RESULT([yes])
170 CFLAGS="$save_CFLAGS"
171 $1="$$1 $2"
172 ],
173 [
174 AC_MSG_RESULT([no])
175 CFLAGS="$save_CFLAGS"
176 ])
177 ac_c_werror_flag="$save_ac_c_werror_flag"
178 ])
179
180 dnl
181 dnl Check whether the compiler supports an option to generate
182 dnl Makefile-style dependency lines
183 dnl
184 dnl GCC uses -M for this. Non-GCC compilers that support this
185 dnl use a variety of flags, including but not limited to -M.
186 dnl
187 dnl We test whether the flag in question is supported, as older
188 dnl versions of compilers might not support it.
189 dnl
190 dnl We don't try all the possible flags, just in case some flag means
191 dnl "generate dependencies" on one compiler but means something else
192 dnl on another compiler.
193 dnl
194 dnl Most compilers that support this send the output to the standard
195 dnl output by default. IBM's XLC, however, supports -M but sends
196 dnl the output to {sourcefile-basename}.u, and AIX has no /dev/stdout
197 dnl to work around that, so we don't bother with XLC.
198 dnl
199 AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT,
200 [
201 AC_MSG_CHECKING([whether the compiler supports generating dependencies])
202 if test "$GCC" = yes ; then
203 #
204 # GCC, or a compiler deemed to be GCC by AC_PROG_CC (even
205 # though it's not); we assume that, in this case, the flag
206 # would be -M.
207 #
208 ac_lbl_dependency_flag="-M"
209 else
210 #
211 # Not GCC or a compiler deemed to be GCC; what platform is
212 # this? (We're assuming that if the compiler isn't GCC
213 # it's the compiler from the vendor of the OS; that won't
214 # necessarily be true for x86 platforms, where it might be
215 # the Intel C compiler.)
216 #
217 case "$host_os" in
218
219 darwin*)
220 #
221 # Clang uses -M.
222 #
223 ac_lbl_dependency_flag="-M"
224 ;;
225
226 solaris*)
227 #
228 # Sun C uses -xM.
229 #
230 ac_lbl_dependency_flag="-xM"
231 ;;
232
233 hpux*)
234 #
235 # HP's older C compilers don't support this.
236 # HP's newer C compilers support this with
237 # either +M or +Make; the older compilers
238 # interpret +M as something completely
239 # different, so we use +Make so we don't
240 # think it works with the older compilers.
241 #
242 ac_lbl_dependency_flag="+Make"
243 ;;
244
245 *)
246 #
247 # Not one of the above; assume no support for
248 # generating dependencies.
249 #
250 ac_lbl_dependency_flag=""
251 ;;
252 esac
253 fi
254
255 #
256 # Is ac_lbl_dependency_flag defined and, if so, does the compiler
257 # complain about it?
258 #
259 # Note: clang doesn't seem to exit with an error status when handed
260 # an unknown non-warning error, even if you pass it
261 # -Werror=unknown-warning-option. However, it always supports
262 # -M, so the fact that this test always succeeds with clang
263 # isn't an issue.
264 #
265 if test ! -z "$ac_lbl_dependency_flag"; then
266 AC_LANG_CONFTEST(
267 [AC_LANG_SOURCE([[int main(void) { return 0; }]])])
268 if AC_RUN_LOG([eval "$CC $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1"]); then
269 AC_MSG_RESULT([yes, with $ac_lbl_dependency_flag])
270 DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
271 MKDEP='${top_srcdir}/mkdep'
272 else
273 AC_MSG_RESULT([no])
274 #
275 # We can't run mkdep, so have "make depend" do
276 # nothing.
277 #
278 MKDEP=:
279 fi
280 rm -rf conftest*
281 else
282 AC_MSG_RESULT([no])
283 #
284 # We can't run mkdep, so have "make depend" do
285 # nothing.
286 #
287 MKDEP=:
288 fi
289 AC_SUBST(DEPENDENCY_CFLAG)
290 AC_SUBST(MKDEP)
291 ])
292
293 dnl
294 dnl Require libpcap
295 dnl Look for libpcap in directories under ..; those are local versions.
296 dnl Look for an installed libpcap if there is no local version or if
297 dnl the user said not to look for a local version.
298 dnl
299 dnl usage:
300 dnl
301 dnl AC_LBL_LIBPCAP(pcapdep, incls)
302 dnl
303 dnl results:
304 dnl
305 dnl $1 (pcapdep set)
306 dnl $2 (incls appended)
307 dnl LIBS
308 dnl
309 AC_DEFUN(AC_LBL_LIBPCAP,
310 [
311 AC_REQUIRE([AC_PROG_EGREP])
312 AC_REQUIRE([AC_LBL_LIBRARY_NET])
313 libpcap=FAIL
314 AC_MSG_CHECKING([whether to look for a local libpcap])
315 AC_ARG_ENABLE(local-libpcap,
316 AS_HELP_STRING([--disable-local-libpcap],
317 [don't look for a local libpcap @<:@default=check for a local libpcap@:>@]),,
318 enableval=yes)
319 case "$enableval" in
320
321 no)
322 AC_MSG_RESULT(no)
323 #
324 # Don't look for a local libpcap.
325 #
326 using_local_libpcap=no
327 ;;
328
329 *)
330 AC_MSG_RESULT(yes)
331 #
332 # Look for a local pcap library.
333 #
334 AC_MSG_CHECKING(for local pcap library)
335 lastdir=FAIL
336 places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
337 $EGREP '/libpcap-[[0-9]]+\.[[0-9]]+(\.[[0-9]]*)?([[ab]][[0-9]]*|-PRE-GIT|rc.)?$'`
338 places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \
339 $EGREP '/libpcap-[[0-9]]+\.[[0-9]]+(\.[[0-9]]*)?([[ab]][[0-9]]*|-PRE-GIT|rc.)?$'`
340 for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do
341 basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//' | \
342 sed -e 's/-PRE-GIT$//' `
343 if test $lastdir = $basedir ; then
344 dnl skip alphas when an actual release is present
345 continue;
346 fi
347 lastdir=$dir
348 if test -r $dir/libpcap.a ; then
349 libpcap=$dir/libpcap.a
350 local_pcap_dir=$dir
351 dnl continue and select the last one that exists
352 fi
353 done
354 if test $libpcap = FAIL ; then
355 #
356 # We didn't find a local libpcap.
357 #
358 AC_MSG_RESULT(not found)
359 using_local_libpcap=no;
360 else
361 #
362 # We found a local libpcap.
363 #
364 AC_MSG_RESULT($libpcap)
365 using_local_libpcap=yes
366 fi
367 ;;
368 esac
369
370 if test $using_local_libpcap = no ; then
371 #
372 # We didn't find a local libpcap.
373 # Look for an installed pkg-config.
374 #
375 AC_PATH_TOOL(PKG_CONFIG, pkg-config)
376 if test -n "$PKG_CONFIG" ; then
377 #
378 # We have it. Are there .pc files for libpcap?
379 #
380 # --exists was introduced in pkg-config 0.4.0; that
381 # dates back to late 2000, so we won't worry about
382 # earlier releases that lack it.
383 #
384 AC_MSG_CHECKING(whether there are .pc files for libpcap)
385 if "$PKG_CONFIG" libpcap --exists ; then
386 #
387 # Yes, so we can use pkg-config to get configuration
388 # information for libpcap.
389 #
390 AC_MSG_RESULT(yes)
391 pkg_config_usable=yes
392 else
393 #
394 # No, so we can't use pkg-config to get configuration
395 # information for libpcap.
396 #
397 AC_MSG_RESULT(no)
398 pkg_config_usable=no
399 fi
400 else
401 #
402 # We don't have it, so we obviously can't use it.
403 #
404 pkg_config_usable=no
405 fi
406 if test "$pkg_config_usable" = "yes" ; then
407 #
408 # Found both - use pkg-config to get the include flags for
409 # libpcap and the flags to link with libpcap.
410 #
411 # Please read section 11.6 "Shell Substitutions"
412 # in the autoconf manual before doing anything
413 # to this that involves quoting. Especially note
414 # the statement "There is just no portable way to use
415 # double-quoted strings inside double-quoted back-quoted
416 # expressions (pfew!)."
417 #
418 cflags=`"$PKG_CONFIG" libpcap --cflags`
419 $2="$cflags $$2"
420 libpcap=`"$PKG_CONFIG" libpcap --libs`
421 else
422 #
423 # No pkg-config
424 # Look for an installed pcap-config.
425 #
426 AC_PATH_TOOL(PCAP_CONFIG, pcap-config)
427 if test -n "$PCAP_CONFIG" ; then
428 #
429 # Found - use it to get the include flags for
430 # libpcap and the flags to link with libpcap.
431 #
432 # If this is a vendor-supplied pcap-config, which
433 # we define as being "a pcap-config in /usr/bin
434 # or /usr/ccs/bin" (the latter is for Solaris and
435 # Sun/Oracle Studio), there are some issues. Work
436 # around them.
437 #
438 if test \( "$PCAP_CONFIG" = "/usr/bin/pcap-config" \) -o \
439 \( "$PCAP_CONFIG" = "/usr/ccs/bin/pcap-config" \) ; then
440 #
441 # It's vendor-supplied.
442 #
443 case "$host_os" in
444
445 darwin*)
446 #
447 # This is macOS or another Darwin-based OS.
448 #
449 # That means that /usr/bin/pcap-config it
450 # may provide -I/usr/local/include with --cflags
451 # and -L/usr/local/lib with --libs, rather than
452 # pointing to the OS-supplied library and
453 # Xcode-supplied headers. Remember that, so we
454 # ignore those values.
455 #
456 _broken_apple_pcap_config=yes
457 ;;
458
459 solaris*)
460 #
461 # This is Solaris 2 or later, i.e. SunOS 5.x.
462 #
463 # At least on Solaris 11; there's /usr/bin/pcap-config,
464 # which reports -L/usr/lib with --libs, causing
465 # the 32-bit libraries to be found, and there's
466 # /usr/bin/{64bitarch}/pcap-config, where {64bitarch}
467 # is a name for the 64-bit version of the instruction
468 # set, which reports -L /usr/lib/{64bitarch}, causing
469 # the 64-bit libraries to be found.
470 #
471 # So if we're building 64-bit targets, we replace
472 # PCAP_CONFIG with /usr/bin/{64bitarch}; we get
473 # {64bitarch} as the output of "isainfo -n".
474 #
475 # Are we building 32-bit or 64-bit? Get the
476 # size of void *, and check that.
477 #
478 AC_CHECK_SIZEOF([void *])
479 if test ac_cv_sizeof_void_p -eq 8 ; then
480 isainfo_output=`isainfo -n`
481 if test ! -z "$isainfo_output" ; then
482 #
483 # Success - change PCAP_CONFIG.
484 #
485 PCAP_CONFIG=`echo $PCAP_CONFIG | sed "s;/bin/;/bin/$isainfo_output/;"`
486 fi
487 fi
488 ;;
489 esac
490 fi
491 #
492 # Please read section 11.6 "Shell Substitutions"
493 # in the autoconf manual before doing anything
494 # to this that involves quoting. Especially note
495 # the statement "There is just no portable way to use
496 # double-quoted strings inside double-quoted back-quoted
497 # expressions (pfew!)."
498 #
499 cflags=`"$PCAP_CONFIG" --cflags`
500 #
501 # Work around macOS (and probably other Darwin) brokenness,
502 # by not adding /usr/local/include if it's from the broken
503 # Apple pcap-config.
504 #
505 if test "$_broken_apple_pcap_config" = "yes" ; then
506 #
507 # Strip -I/usr/local/include with sed.
508 #
509 cflags=`echo $cflags | sed 's;-I/usr/local/include;;'`
510 fi
511 $2="$cflags $$2"
512 libpcap=`"$PCAP_CONFIG" --libs`
513 #
514 # Work around macOS (and probably other Darwin) brokenness,
515 # by not adding /usr/local/lib if it's from the broken
516 # Apple pcap-config.
517 #
518 if test "$_broken_apple_pcap_config" = "yes" ; then
519 #
520 # Strip -L/usr/local/lib with sed.
521 #
522 libpcap=`echo $libpcap | sed 's;-L/usr/local/lib;;'`
523 fi
524 else
525 #
526 # Not found; look for an installed pcap.
527 #
528 AC_CHECK_LIB(pcap, main, libpcap="-lpcap")
529 if test $libpcap = FAIL ; then
530 AC_MSG_ERROR(see the INSTALL.md file for more info)
531 fi
532 dnl
533 dnl Some versions of Red Hat Linux put "pcap.h" in
534 dnl "/usr/include/pcap"; had the LBL folks done so,
535 dnl that would have been a good idea, but for
536 dnl the Red Hat folks to do so just breaks source
537 dnl compatibility with other systems.
538 dnl
539 dnl We work around this by assuming that, as we didn't
540 dnl find a local libpcap, libpcap is in /usr/lib or
541 dnl /usr/local/lib and that the corresponding header
542 dnl file is under one of those directories; if we don't
543 dnl find it in either of those directories, we check to
544 dnl see if it's in a "pcap" subdirectory of them and,
545 dnl if so, add that subdirectory to the "-I" list.
546 dnl
547 dnl (We now also put pcap.h in /usr/include/pcap, but we
548 dnl leave behind a /usr/include/pcap.h that includes it,
549 dnl so you can still just include <pcap.h>.)
550 dnl
551 AC_MSG_CHECKING(for extraneous pcap header directories)
552 if test \( ! -r /usr/local/include/pcap.h \) -a \
553 \( ! -r /usr/include/pcap.h \); then
554 if test -r /usr/local/include/pcap/pcap.h; then
555 d="/usr/local/include/pcap"
556 elif test -r /usr/include/pcap/pcap.h; then
557 d="/usr/include/pcap"
558 fi
559 fi
560 if test -z "$d" ; then
561 AC_MSG_RESULT(not found)
562 else
563 $2="-I$d $$2"
564 AC_MSG_RESULT(found -- -I$d added)
565 fi
566 fi
567 fi
568 else
569 #
570 # We found a local libpcap. Add it to the dependencies for
571 # tcpdump.
572 #
573 $1=$libpcap
574
575 #
576 # Look for its pcap-config script.
577 #
578 AC_PATH_PROG(PCAP_CONFIG, pcap-config,, $local_pcap_dir)
579
580 if test -n "$PCAP_CONFIG"; then
581 #
582 # We don't want its --cflags or --libs output, because
583 # those presume it's installed. For the C compiler flags,
584 # we add the source directory for the local libpcap, so
585 # we pick up its header files.
586 #
587 # We do, however, want its additional libraries, as required
588 # when linking statically, because it makes calls to
589 # routines in those libraries, so we'll need to link with
590 # them, because we'll be linking statically with it.
591 #
592 # If it supports --static-pcap-only. use that, as we will be
593 # linking with a static libpcap but won't be linking
594 # statically with any of the libraries on which it depends;
595 # those libraries might not even have static versions
596 # installed.
597 #
598 # That means we need to find out the libraries on which
599 # libpcap directly depends, so we can link with them, but we
600 # don't need to link with the libraries on which those
601 # libraries depend as, on all UN*Xes with which I'm
602 # familiar, the libraries on which a shared library depends
603 # are stored in the library and are automatically loaded by
604 # the run-time linker, without the executable having to be
605 # linked with those libraries. (This allows a library to be
606 # changed to depend on more libraries without breaking that
607 # library's ABI.)
608 #
609 # The only way to test for that support is to see if the
610 # script contains the string "static-pcap-only"; we can't
611 # try using that flag and checking for errors, as the
612 # versions of the script that didn't have that flag wouldn't
613 # report or return an error for an unsupported command-line
614 # flag. Those older versions provided, with --static, only
615 # the libraries on which libpcap depends, not the
616 # dependencies of those libraries; the versions with
617 # --static-pcap-only provide all the dependencies with
618 # --static, for the benefit of programs that are completely
619 # statically linked, and provide only the direct
620 # dependencies with --static-pcap-only.
621 #
622 if grep "static-pcap-only" "$PCAP_CONFIG" >/dev/null 2>&1
623 then
624 static_opt="--static-pcap-only"
625 else
626 static_opt="--static"
627 fi
628 $2="-I$local_pcap_dir $$2"
629 additional_libs=`"$PCAP_CONFIG" $static_opt --additional-libs`
630 libpcap="$libpcap $additional_libs"
631 else
632 #
633 # It doesn't have a pcap-config script.
634 # Make sure it has a pcap.h file.
635 #
636 places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
637 $EGREP '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
638 places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \
639 $EGREP '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
640 pcapH=FAIL
641 if test -r $local_pcap_dir/pcap.h; then
642 pcapH=$local_pcap_dir
643 else
644 for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do
645 if test -r $dir/pcap.h ; then
646 pcapH=$dir
647 fi
648 done
649 fi
650
651 if test $pcapH = FAIL ; then
652 AC_MSG_ERROR(cannot find pcap.h: see the INSTALL.md file)
653 fi
654
655 #
656 # Force the compiler to look for header files in the
657 # directory containing pcap.h.
658 #
659 $2="-I$pcapH $$2"
660 fi
661 fi
662
663 if test -z "$PKG_CONFIG" -a -z "$PCAP_CONFIG"; then
664 #
665 # We don't have pkg-config or pcap-config; find out any additional
666 # link flags we need. (If we have pkg-config or pcap-config, we
667 # assume it tells us what we need.)
668 #
669 case "$host_os" in
670
671 aix*)
672 #
673 # If libpcap is DLPI-based, we have to use /lib/pse.exp if
674 # present, as we use the STREAMS routines.
675 #
676 # (XXX - true only if we're linking with a static libpcap?)
677 #
678 pseexe="/lib/pse.exp"
679 AC_MSG_CHECKING(for $pseexe)
680 if test -f $pseexe ; then
681 AC_MSG_RESULT(yes)
682 LIBS="$LIBS -I:$pseexe"
683 fi
684
685 #
686 # If libpcap is BPF-based, we need "-lodm" and "-lcfg", as
687 # we use them to load the BPF module.
688 #
689 # (XXX - true only if we're linking with a static libpcap?)
690 #
691 LIBS="$LIBS -lodm -lcfg"
692 ;;
693
694 solaris*)
695 # libdlpi is needed for Solaris 11 and later.
696 AC_CHECK_LIB(dlpi, dlpi_walk, LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS", ,-L/lib)
697 ;;
698 esac
699 fi
700
701 LIBS="$libpcap $LIBS"
702
703 dnl
704 dnl Check for "pcap_loop()", to make sure we found a working
705 dnl libpcap and have all the right other libraries with which
706 dnl to link. (Otherwise, the checks below will fail, not
707 dnl because the routines are missing from the library, but
708 dnl because we aren't linking properly with libpcap, and
709 dnl that will cause confusing errors at build time.)
710 dnl
711 AC_CHECK_FUNC(pcap_loop,,
712 [
713 AC_MSG_ERROR(
714 [This is a bug, please follow the guidelines in CONTRIBUTING.md and include the
715 config.log file in your report. If you have downloaded libpcap from
716 tcpdump.org, and built it yourself, please also include the config.log
717 file from the libpcap source directory, the Makefile from the libpcap
718 source directory, and the output of the make process for libpcap, as
719 this could be a problem with the libpcap that was built, and we will
720 not be able to determine why this is happening, and thus will not be
721 able to fix it, without that information, as we have not been able to
722 reproduce this problem ourselves.])
723 ])
724 ])
725
726 dnl
727 dnl If the file .devel exists:
728 dnl Add some warning flags if the compiler supports them
729 dnl If an os prototype include exists, symlink os-proto.h to it
730 dnl
731 dnl usage:
732 dnl
733 dnl AC_LBL_DEVEL(copt)
734 dnl
735 dnl results:
736 dnl
737 dnl $1 (copt appended)
738 dnl HAVE_OS_PROTO_H (defined)
739 dnl os-proto.h (symlinked)
740 dnl
741 AC_DEFUN(AC_LBL_DEVEL,
742 [rm -f os-proto.h
743 if test "${LBL_CFLAGS+set}" = set; then
744 $1="$$1 ${LBL_CFLAGS}"
745 fi
746 if test -f .devel ; then
747 #
748 # Skip all the warning option stuff on some compilers.
749 #
750 if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
751 AC_LBL_CHECK_COMPILER_OPT($1, -W)
752 AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
753 AC_LBL_CHECK_COMPILER_OPT($1, -Wassign-enum)
754 AC_LBL_CHECK_COMPILER_OPT($1, -Wcast-qual)
755 AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
756 AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-variable-declarations)
757 AC_LBL_CHECK_COMPILER_OPT($1, -Wnull-pointer-subtraction)
758 AC_LBL_CHECK_COMPILER_OPT($1, -Wold-style-definition)
759 AC_LBL_CHECK_COMPILER_OPT($1, -Wpedantic)
760 AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-arith)
761 AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-sign)
762 AC_LBL_CHECK_COMPILER_OPT($1, -Wshadow)
763 AC_LBL_CHECK_COMPILER_OPT($1, -Wsign-compare)
764 AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
765 AC_LBL_CHECK_COMPILER_OPT($1, -Wunreachable-code-return)
766 AC_LBL_CHECK_COMPILER_OPT($1, -Wunused-but-set-parameter)
767 AC_LBL_CHECK_COMPILER_OPT($1, -Wunused-but-set-variable)
768 AC_LBL_CHECK_COMPILER_OPT($1, -Wused-but-marked-unused)
769 AC_LBL_CHECK_COMPILER_OPT($1, -Wwrite-strings)
770 fi
771 AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
772 AC_MSG_CHECKING([whether to use an os-proto.h header])
773 os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
774 name="lbl/os-$os.h"
775 if test -f $name ; then
776 AC_MSG_RESULT([yes, at "$name"])
777 ln -s $name os-proto.h
778 AC_DEFINE(HAVE_OS_PROTO_H, 1,
779 [if there's an os-proto.h for this platform, to use additional prototypes])
780 else
781 AC_MSG_RESULT([no])
782 fi
783 fi])
784
785 dnl
786 dnl This is a simplified adaptation of AC_LBL_LIBRARY_NET from libpcap.
787 dnl In this context tcpdump needs gethostbyaddr() only.
788 dnl
789 AC_DEFUN(AC_LBL_LIBRARY_NET, [
790 AC_CHECK_FUNC(gethostbyaddr,,
791 [
792 AC_CHECK_LIB(socket, gethostbyaddr,
793 [
794 LIBS="-lsocket -lnsl $LIBS"
795 ],
796 [
797 AC_CHECK_LIB(network, gethostbyaddr,
798 [
799 LIBS="-lnetwork $LIBS"
800 ],
801 [
802 AC_MSG_ERROR([gethostbyaddr is required, but wasn't found])
803 ])
804 ], -lnsl)
805 ])
806 ])