1 dnl Copyright (c) 1995, 1996, 1997, 1998
2 dnl The Regents of the University of California. All rights reserved.
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.
20 dnl LBL autoconf macros
24 dnl Do whatever AC_LBL_C_INIT work is necessary before using AC_PROG_CC.
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.
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.
38 AC_DEFUN(AC_LBL_C_INIT_BEFORE_CC,
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])
45 if test "${srcdir}" != "." ; then
48 if test "${CFLAGS+set}" = set; then
51 if test -z "$CC" ; then
55 AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
56 if test $SHLICC2 = yes ; then
63 if test -z "$CC" -a "$with_gcc" = no ; then
70 dnl Determine which compiler we're using (cc or gcc)
71 dnl If using gcc, determine the version number
73 dnl require that it support ansi prototypes
74 dnl use -O (AC_PROG_CC will use -g -O2 on gcc, so we don't need to
75 dnl do that ourselves for gcc)
76 dnl add -g flags, as appropriate
77 dnl explicitly specify /usr/local/include
79 dnl NOTE WELL: with newer versions of autoconf, "gcc" means any compiler
80 dnl that defines __GNUC__, which means clang, for example, counts as "gcc".
84 dnl AC_LBL_C_INIT(copt, incls)
94 AC_DEFUN(AC_LBL_C_INIT,
96 AC_BEFORE([$0], [AC_LBL_DEVEL])
97 if test "$GCC" = yes ; then
99 # -Werror forces warnings to be errors.
101 ac_lbl_cc_force_warning_errors=-Werror
103 $2="$$2 -I/usr/local/include"
104 LDFLAGS="$LDFLAGS -L/usr/local/lib"
110 # This is assumed either to be GCC or clang, both
111 # of which use -Werror to force warnings to be errors.
113 ac_lbl_cc_force_warning_errors=-Werror
118 # HP C, which is what we presume we're using, doesn't
119 # exit with a non-zero exit status if we hand it an
120 # invalid -W flag, can't be forced to do so even with
121 # +We, and doesn't handle GCC-style -W flags, so we
122 # don't want to try using GCC-style -W flags.
124 ac_lbl_cc_dont_try_gcc_dashW=yes
129 # MIPS C, which is what we presume we're using, doesn't
130 # necessarily exit with a non-zero exit status if we
131 # hand it an invalid -W flag, can't be forced to do
132 # so, and doesn't handle GCC-style -W flags, so we
133 # don't want to try using GCC-style -W flags.
135 ac_lbl_cc_dont_try_gcc_dashW=yes
137 # It also, apparently, defaults to "char" being
138 # unsigned, unlike most other C implementations;
139 # I suppose we could say "signed char" whenever
140 # we want to guarantee a signed "char", but let's
141 # just force signed chars.
143 # -xansi is normally the default, but the
144 # configure script was setting it; perhaps -cckr
145 # was the default in the Old Days. (Then again,
146 # that would probably be for backwards compatibility
147 # in the days when ANSI C was Shiny and New, i.e.
148 # 1989 and the early '90's, so maybe we can just
149 # drop support for those compilers.)
151 # -g is equivalent to -g2, which turns off
152 # optimization; we choose -g3, which generates
153 # debugging information but doesn't turn off
154 # optimization (even if the optimization would
155 # cause inaccuracies in debugging).
157 $1="$$1 -xansi -signed -g3"
162 # Presumed to be DEC OSF/1, Digital UNIX, or
165 # The DEC C compiler, which is what we presume we're
166 # using, doesn't exit with a non-zero exit status if we
167 # hand it an invalid -W flag, can't be forced to do
168 # so, and doesn't handle GCC-style -W flags, so we
169 # don't want to try using GCC-style -W flags.
171 ac_lbl_cc_dont_try_gcc_dashW=yes
173 # -g is equivalent to -g2, which turns off
174 # optimization; we choose -g3, which generates
175 # debugging information but doesn't turn off
176 # optimization (even if the optimization would
177 # cause inaccuracies in debugging).
184 # Assumed to be Sun C, which requires -errwarn to force
185 # warnings to be treated as errors.
187 ac_lbl_cc_force_warning_errors=-errwarn
191 AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
192 AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
194 [#include <sys/types.h>],
195 [struct a { int b; };
196 void c(const struct a *)],
197 ac_cv_lbl_cc_const_proto=yes,
198 ac_cv_lbl_cc_const_proto=no))
199 AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
200 if test $ac_cv_lbl_cc_const_proto = no ; then
202 [to handle Ultrix compilers that don't support const in prototypes])
211 dnl Save the values of various variables that affect compilation and
212 dnl linking, and that we don't ourselves modify persistently; done
213 dnl before a test involving compiling or linking is done, so that we
214 dnl can restore those variables after the test is done.
216 AC_DEFUN(AC_LBL_SAVE_CHECK_STATE,
218 save_CFLAGS="$CFLAGS"
220 save_LDFLAGS="$LDFLAGS"
224 dnl Restore the values of variables saved by AC_LBL_SAVE_CHECK_STATE.
226 AC_DEFUN(AC_LBL_RESTORE_CHECK_STATE,
228 CFLAGS="$save_CFLAGS"
230 LDFLAGS="$save_LDFLAGS"
234 dnl Check whether the compiler option specified as the second argument
235 dnl is supported by the compiler and, if so, add it to the macro
236 dnl specified as the first argument
238 AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
240 AC_MSG_CHECKING([whether the compiler supports the $2 option])
241 save_CFLAGS="$CFLAGS"
244 # XXX - yes, this depends on the way AC_LANG_WERROR works,
245 # but no mechanism is provided to turn AC_LANG_WERROR on
246 # *and then turn it back off*, so that we *only* do it when
247 # testing compiler options - 15 years after somebody asked
250 # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
252 save_ac_c_werror_flag="$ac_c_werror_flag"
255 # We use AC_LANG_SOURCE() so that we can control the complete
256 # content of the program being compiled. We do not, for example,
257 # want the default "int main()" that AC_LANG_PROGRAM() generates,
258 # as it will generate a warning with -Wold-style-definition, meaning
259 # that we would treat it as not working, as the test will fail if
260 # *any* error output, including a warning due to the flag we're
261 # testing, is generated; see
263 # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
264 # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
266 # This may, as per those two messages, be fixed in autoconf 2.70,
267 # but we only require 2.69 or newer for now.
270 [AC_LANG_SOURCE([[int main(void) { return 0; }]])],
273 CFLAGS="$save_CFLAGS"
278 CFLAGS="$save_CFLAGS"
280 ac_c_werror_flag="$save_ac_c_werror_flag"
284 dnl Check whether the compiler supports an option to generate
285 dnl Makefile-style dependency lines
287 dnl GCC uses -M for this. Non-GCC compilers that support this
288 dnl use a variety of flags, including but not limited to -M.
290 dnl We test whether the flag in question is supported, as older
291 dnl versions of compilers might not support it.
293 dnl We don't try all the possible flags, just in case some flag means
294 dnl "generate dependencies" on one compiler but means something else
295 dnl on another compiler.
297 dnl Most compilers that support this send the output to the standard
298 dnl output by default. IBM's XLC, however, supports -M but sends
299 dnl the output to {sourcefile-basename}.u, and AIX has no /dev/stdout
300 dnl to work around that, so we don't bother with XLC.
302 AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT,
304 AC_MSG_CHECKING([whether the compiler supports generating dependencies])
305 if test "$GCC" = yes ; then
307 # GCC, or a compiler deemed to be GCC by AC_PROG_CC (even
308 # though it's not); we assume that, in this case, the flag
311 ac_lbl_dependency_flag="-M"
314 # Not GCC or a compiler deemed to be GCC; what platform is
315 # this? (We're assuming that if the compiler isn't GCC
316 # it's the compiler from the vendor of the OS; that won't
317 # necessarily be true for x86 platforms, where it might be
318 # the Intel C compiler.)
324 # MIPS C for IRIX, DEC C, and clang all use -M.
326 ac_lbl_dependency_flag="-M"
333 ac_lbl_dependency_flag="-xM"
338 # HP's older C compilers don't support this.
339 # HP's newer C compilers support this with
340 # either +M or +Make; the older compilers
341 # interpret +M as something completely
342 # different, so we use +Make so we don't
343 # think it works with the older compilers.
345 ac_lbl_dependency_flag="+Make"
350 # Not one of the above; assume no support for
351 # generating dependencies.
353 ac_lbl_dependency_flag=""
359 # Is ac_lbl_dependency_flag defined and, if so, does the compiler
362 # Note: clang doesn't seem to exit with an error status when handed
363 # an unknown non-warning error, even if you pass it
364 # -Werror=unknown-warning-option. However, it always supports
365 # -M, so the fact that this test always succeeds with clang
368 if test ! -z "$ac_lbl_dependency_flag"; then
370 [AC_LANG_SOURCE([[int main(void) { return 0; }]])])
371 if AC_RUN_LOG([eval "$CC $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1"]); then
372 AC_MSG_RESULT([yes, with $ac_lbl_dependency_flag])
373 DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
374 MKDEP='${top_srcdir}/mkdep'
378 # We can't run mkdep, so have "make depend" do
387 # We can't run mkdep, so have "make depend" do
392 AC_SUBST(DEPENDENCY_CFLAG)
397 # Try compiling a sample of the type of code that appears in
398 # gencode.c with "inline", "__inline__", and "__inline".
400 # Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough,
401 # as it just tests whether a function returning "int" can be inlined;
402 # at least some versions of HP's C compiler can inline that, but can't
403 # inline a function that returns a struct pointer.
405 # Make sure we use the V_CCOPT flags, because some of those might
408 AC_DEFUN(AC_LBL_C_INLINE,
409 [AC_MSG_CHECKING(for inline)
410 save_CFLAGS="$CFLAGS"
412 AC_CACHE_VAL(ac_cv_lbl_inline, [
415 for ac_lbl_inline in inline __inline__ __inline
418 [#define inline $ac_lbl_inline
419 static inline struct iltest *foo(void);
425 static inline struct iltest *
428 static struct iltest xxx;
431 }],,ac_lbl_cc_inline=yes,)
432 if test "$ac_lbl_cc_inline" = yes ; then
436 if test "$ac_lbl_cc_inline" = yes ; then
437 ac_cv_lbl_inline=$ac_lbl_inline
439 CFLAGS="$save_CFLAGS"
440 if test ! -z "$ac_cv_lbl_inline" ; then
441 AC_MSG_RESULT($ac_cv_lbl_inline)
445 AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
448 dnl Use pfopen.c if available and pfopen() not in standard libraries
450 dnl Look for libpcap in directories under ..; those are local versions.
451 dnl Look for an installed libpcap if there is no local version or if
452 dnl the user said not to look for a local version.
456 dnl AC_LBL_LIBPCAP(pcapdep, incls)
461 dnl $2 (incls appended)
465 AC_DEFUN(AC_LBL_LIBPCAP,
467 AC_REQUIRE([AC_PROG_EGREP])
468 AC_REQUIRE([AC_LBL_LIBRARY_NET])
470 dnl save a copy before locating libpcap.a
473 pfopen=/usr/examples/packetfilter/pfopen.c
474 if test -f $pfopen ; then
475 AC_CHECK_FUNCS(pfopen)
476 if test $ac_cv_func_pfopen = "no" ; then
477 AC_MSG_RESULT(Using $pfopen)
482 AC_MSG_CHECKING([whether to look for a local libpcap])
483 AC_ARG_ENABLE(local-libpcap,
484 AS_HELP_STRING([--disable-local-libpcap],
485 [don't look for a local libpcap @<:@default=check for a local libpcap@:>@]),,
492 # Don't look for a local libpcap.
494 using_local_libpcap=no
500 # Look for a local pcap library.
502 AC_MSG_CHECKING(for local pcap library)
504 places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
505 $EGREP '/libpcap-[[0-9]]+\.[[0-9]]+(\.[[0-9]]*)?([[ab]][[0-9]]*|-PRE-GIT|rc.)?$'`
506 places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \
507 $EGREP '/libpcap-[[0-9]]+\.[[0-9]]+(\.[[0-9]]*)?([[ab]][[0-9]]*|-PRE-GIT|rc.)?$'`
508 for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do
509 basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//' | \
510 sed -e 's/-PRE-GIT$//' `
511 if test $lastdir = $basedir ; then
512 dnl skip alphas when an actual release is present
516 if test -r $dir/libpcap.a ; then
517 libpcap=$dir/libpcap.a
519 dnl continue and select the last one that exists
522 if test $libpcap = FAIL ; then
524 # We didn't find a local libpcap.
526 AC_MSG_RESULT(not found)
527 using_local_libpcap=no;
530 # We found a local libpcap.
532 AC_MSG_RESULT($libpcap)
533 using_local_libpcap=yes
538 if test $using_local_libpcap = no ; then
540 # We didn't find a local libpcap.
541 # Look for an installed pkg-config.
543 if test -n "$PKG_CONFIG" ; then
545 # We have it. Are there .pc files for libpcap?
547 # --exists was introduced in pkg-config 0.4.0; that
548 # dates back to late 2000, so we won't worry about
549 # earlier releases that lack it.
551 AC_MSG_CHECKING(whether there are .pc files for libpcap)
552 if "$PKG_CONFIG" libpcap --exists ; then
554 # Yes, so we can use pkg-config to get configuration
555 # information for libpcap.
558 pkg_config_usable=yes
561 # No, so we can't use pkg-config to get configuration
562 # information for libpcap.
569 # We don't have it, so we obviously can't use it.
573 if test "$pkg_config_usable" = "yes" ; then
575 # Found both - use pkg-config to get the include flags for
576 # libpcap and the flags to link with libpcap.
578 # Please read section 11.6 "Shell Substitutions"
579 # in the autoconf manual before doing anything
580 # to this that involves quoting. Especially note
581 # the statement "There is just no portable way to use
582 # double-quoted strings inside double-quoted back-quoted
583 # expressions (pfew!)."
585 cflags=`"$PKG_CONFIG" libpcap --cflags`
587 libpcap=`"$PKG_CONFIG" libpcap --libs`
591 # Look for an installed pcap-config.
593 AC_PATH_TOOL(PCAP_CONFIG, pcap-config)
594 if test -n "$PCAP_CONFIG" ; then
596 # Found - use it to get the include flags for
597 # libpcap and the flags to link with libpcap.
599 # If this is a vendor-supplied pcap-config, which
600 # we define as being "a pcap-config in /usr/bin
601 # or /usr/ccs/bin" (the latter is for Solaris and
602 # Sun/Oracle Studio), there are some issues. Work
605 if test \( "$PCAP_CONFIG" = "/usr/bin/pcap-config" \) -o \
606 \( "$PCAP_CONFIG" = "/usr/ccs/bin/pcap-config" \) ; then
608 # It's vendor-supplied.
614 # This is macOS or another Darwin-based OS.
616 # That means that /usr/bin/pcap-config it
617 # may provide -I/usr/local/include with --cflags
618 # and -L/usr/local/lib with --libs, rather than
619 # pointing to the OS-supplied library and
620 # Xcode-supplied headers. Remember that, so we
621 # ignore those values.
623 _broken_apple_pcap_config=yes
628 # macOS Sonoma's libpcap includes stub versions
629 # of the remote-capture APIs. They are exported
630 # as "weakly linked symbols".
632 # Xcode 15 offers only a macOS Sonoma SDK, which
633 # has a .tbd file for libpcap that claims it
634 # includes those APIs. (Newer versions of macOS
635 # don't provide the system shared libraries,
636 # they only provide the dyld shared cache
637 # containing those libraries, so the OS provides
638 # SDKs that include a .tbd file to use when
641 # This means that AC_CHECK_FUNCS() will think
642 # that the remote-capture APIs are present,
643 # including pcap_open() and
644 # pcap_findalldevs_ex().
646 # However, they are *not* present in macOS
647 # Ventura and earlier, which means that building
648 # on Ventura with Xcode 15 produces executables
649 # that fail to start because one of those APIs
650 # isn't found in the system libpcap.
652 # Protecting calls to those APIs with
653 # __builtin_available() does not appear to
654 # prevent this, for some unknown reason, and it
655 # doesn't even allow the program to compile with
656 # versions of Xcode prior to Xcode 15, as the
657 # pcap.h file doesn't specify minimum OS
658 # versions for those functions.
660 # Given all that, and given that the versions of
661 # the remote-capture APIs in Sonoma are stubs
662 # that always fail, there doesn't seem to be any
663 # point in checking for pcap_open() if we're
664 # linking against the Apple libpcap.
666 # However, if we're *not* linking against the
667 # Apple libpcap, we should check for it, so that
668 # we can use it if it's present.
670 # We know this is macOS and that we're using
671 # the system-provided pcap-config to find
672 # libpcap, so we know it'll be the system
673 # libpcap, and note that we should not search
674 # for remote-capture APIs.
676 _dont_check_for_remote_apis=yes
681 # This is Solaris 2 or later, i.e. SunOS 5.x.
683 # At least on Solaris 11; there's /usr/bin/pcap-config,
684 # which reports -L/usr/lib with --libs, causing
685 # the 32-bit libraries to be found, and there's
686 # /usr/bin/{64bitarch}/pcap-config, where {64bitarch}
687 # is a name for the 64-bit version of the instruction
688 # set, which reports -L /usr/lib/{64bitarch}, causing
689 # the 64-bit libraries to be found.
691 # So if we're building 64-bit targets, we replace
692 # PCAP_CONFIG with /usr/bin/{64bitarch}; we get
693 # {64bitarch} as the output of "isainfo -n".
695 # Are we building 32-bit or 64-bit? Get the
696 # size of void *, and check that.
698 AC_CHECK_SIZEOF([void *])
699 if test ac_cv_sizeof_void_p -eq 8 ; then
700 isainfo_output=`isainfo -n`
701 if test ! -z "$isainfo_output" ; then
703 # Success - change PCAP_CONFIG.
705 PCAP_CONFIG=`echo $PCAP_CONFIG | sed "s;/bin/;/bin/$isainfo_output/;"`
712 # Please read section 11.6 "Shell Substitutions"
713 # in the autoconf manual before doing anything
714 # to this that involves quoting. Especially note
715 # the statement "There is just no portable way to use
716 # double-quoted strings inside double-quoted back-quoted
717 # expressions (pfew!)."
719 cflags=`"$PCAP_CONFIG" --cflags`
721 # Work around macOS (and probably other Darwin) brokenness,
722 # by not adding /usr/local/include if it's from the broken
725 if test "$_broken_apple_pcap_config" = "yes" ; then
727 # Strip -I/usr/local/include with sed.
729 cflags=`echo $cflags | sed 's;-I/usr/local/include;;'`
732 libpcap=`"$PCAP_CONFIG" --libs`
734 # Work around macOS (and probably other Darwin) brokenness,
735 # by not adding /usr/local/lib if it's from the broken
738 if test "$_broken_apple_pcap_config" = "yes" ; then
740 # Strip -L/usr/local/lib with sed.
742 libpcap=`echo $libpcap | sed 's;-L/usr/local/lib;;'`
746 # Not found; look for an installed pcap.
748 AC_CHECK_LIB(pcap, main, libpcap="-lpcap")
749 if test $libpcap = FAIL ; then
750 AC_MSG_ERROR(see the INSTALL.md file for more info)
753 dnl Some versions of Red Hat Linux put "pcap.h" in
754 dnl "/usr/include/pcap"; had the LBL folks done so,
755 dnl that would have been a good idea, but for
756 dnl the Red Hat folks to do so just breaks source
757 dnl compatibility with other systems.
759 dnl We work around this by assuming that, as we didn't
760 dnl find a local libpcap, libpcap is in /usr/lib or
761 dnl /usr/local/lib and that the corresponding header
762 dnl file is under one of those directories; if we don't
763 dnl find it in either of those directories, we check to
764 dnl see if it's in a "pcap" subdirectory of them and,
765 dnl if so, add that subdirectory to the "-I" list.
767 dnl (We now also put pcap.h in /usr/include/pcap, but we
768 dnl leave behind a /usr/include/pcap.h that includes it,
769 dnl so you can still just include <pcap.h>.)
771 AC_MSG_CHECKING(for extraneous pcap header directories)
772 if test \( ! -r /usr/local/include/pcap.h \) -a \
773 \( ! -r /usr/include/pcap.h \); then
774 if test -r /usr/local/include/pcap/pcap.h; then
775 d="/usr/local/include/pcap"
776 elif test -r /usr/include/pcap/pcap.h; then
777 d="/usr/include/pcap"
780 if test -z "$d" ; then
781 AC_MSG_RESULT(not found)
784 AC_MSG_RESULT(found -- -I$d added)
790 # We found a local libpcap. Add it to the dependencies for
796 # Look for its pcap-config script.
798 AC_PATH_PROG(PCAP_CONFIG, pcap-config,, $local_pcap_dir)
800 if test -n "$PCAP_CONFIG"; then
802 # We don't want its --cflags or --libs output, because
803 # those presume it's installed. For the C compiler flags,
804 # we add the source directory for the local libpcap, so
805 # we pick up its header files.
807 # We do, however, want its additional libraries, as required
808 # when linking statically, because it makes calls to
809 # routines in those libraries, so we'll need to link with
810 # them, because we'll be linking statically with it.
812 # If it supports --static-pcap-only. use that, as we will be
813 # linking with a static libpcap but won't be linking
814 # statically with any of the libraries on which it depends;
815 # those libraries might not even have static versions
818 # That means we need to find out the libraries on which
819 # libpcap directly depends, so we can link with them, but we
820 # don't need to link with the libraries on which those
821 # libraries depend as, on all UN*Xes with which I'm
822 # familiar, the libraries on which a shared library depends
823 # are stored in the library and are automatically loaded by
824 # the run-time linker, without the executable having to be
825 # linked with those libraries. (This allows a library to be
826 # changed to depend on more libraries without breaking that
829 # The only way to test for that support is to see if the
830 # script contains the string "static-pcap-only"; we can't
831 # try using that flag and checking for errors, as the
832 # versions of the script that didn't have that flag wouldn't
833 # report or return an error for an unsupported command-line
834 # flag. Those older versions provided, with --static, only
835 # the libraries on which libpcap depends, not the
836 # dependencies of those libraries; the versions with
837 # --static-pcap-only provide all the dependencies with
838 # --static, for the benefit of programs that are completely
839 # statically linked, and provide only the direct
840 # dependencies with --static-pcap-only.
842 if grep "static-pcap-only" "$PCAP_CONFIG" >/dev/null 2>&1
844 static_opt="--static-pcap-only"
846 static_opt="--static"
848 $2="-I$local_pcap_dir $$2"
849 additional_libs=`"$PCAP_CONFIG" $static_opt --additional-libs`
850 libpcap="$libpcap $additional_libs"
853 # It doesn't have a pcap-config script.
854 # Make sure it has a pcap.h file.
856 places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
857 $EGREP '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
858 places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \
859 $EGREP '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
861 if test -r $local_pcap_dir/pcap.h; then
862 pcapH=$local_pcap_dir
864 for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do
865 if test -r $dir/pcap.h ; then
871 if test $pcapH = FAIL ; then
872 AC_MSG_ERROR(cannot find pcap.h: see the INSTALL.md file)
876 # Force the compiler to look for header files in the
877 # directory containing pcap.h.
883 if test -z "$PKG_CONFIG" -a -z "$PCAP_CONFIG"; then
885 # We don't have pkg-config or pcap-config; find out any additional
886 # link flags we need. (If we have pkg-config or pcap-config, we
887 # assume it tells us what we need.)
893 # If libpcap is DLPI-based, we have to use /lib/pse.exp if
894 # present, as we use the STREAMS routines.
896 # (XXX - true only if we're linking with a static libpcap?)
898 pseexe="/lib/pse.exp"
899 AC_MSG_CHECKING(for $pseexe)
900 if test -f $pseexe ; then
902 LIBS="$LIBS -I:$pseexe"
906 # If libpcap is BPF-based, we need "-lodm" and "-lcfg", as
907 # we use them to load the BPF module.
909 # (XXX - true only if we're linking with a static libpcap?)
911 LIBS="$LIBS -lodm -lcfg"
915 # libdlpi is needed for Solaris 11 and later.
916 AC_CHECK_LIB(dlpi, dlpi_walk, LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS", ,-L/lib)
921 LIBS="$libpcap $LIBS"
924 dnl Check for "pcap_loop()", to make sure we found a working
925 dnl libpcap and have all the right other libraries with which
926 dnl to link. (Otherwise, the checks below will fail, not
927 dnl because the routines are missing from the library, but
928 dnl because we aren't linking properly with libpcap, and
929 dnl that will cause confusing errors at build time.)
931 AC_CHECK_FUNC(pcap_loop,,
935 1. Do you try to build a 32-bit tcpdump with a 64-bit libpcap or vice versa?
936 2. This is a bug, please follow the guidelines in CONTRIBUTING.md and include
937 the config.log file in your report. If you have downloaded libpcap from
938 tcpdump.org, and built it yourself, please also include the config.log
939 file from the libpcap source directory, the Makefile from the libpcap
940 source directory, and the output of the make process for libpcap, as
941 this could be a problem with the libpcap that was built, and we will
942 not be able to determine why this is happening, and thus will not be
943 able to fix it, without that information, as we have not been able to
944 reproduce this problem ourselves.])
949 dnl Check whether a given format can be used to print 64-bit integers
951 AC_DEFUN(AC_LBL_CHECK_64BIT_FORMAT,
953 AC_MSG_CHECKING([whether %$1x can be used to format 64-bit integers])
958 # ifdef HAVE_INTTYPES_H
959 #include <inttypes.h>
962 #include <sys/types.h>
968 sprintf(strbuf, "%016$1x", t << 32);
969 if (strcmp(strbuf, "0000000100000000") == 0)
977 AC_DEFINE(PRId64, "$1d", [define if the platform doesn't define PRId64])
978 AC_DEFINE(PRIo64, "$1o", [define if the platform doesn't define PRIo64])
979 AC_DEFINE(PRIx64, "$1x", [define if the platform doesn't define PRIu64])
980 AC_DEFINE(PRIu64, "$1u", [define if the platform doesn't define PRIx64])
990 dnl If the file .devel exists:
991 dnl Add some warning flags if the compiler supports them
992 dnl If an os prototype include exists, symlink os-proto.h to it
996 dnl AC_LBL_DEVEL(copt)
1000 dnl $1 (copt appended)
1001 dnl HAVE_OS_PROTO_H (defined)
1002 dnl os-proto.h (symlinked)
1004 AC_DEFUN(AC_LBL_DEVEL,
1006 if test "${LBL_CFLAGS+set}" = set; then
1007 $1="$$1 ${LBL_CFLAGS}"
1009 if test -f .devel ; then
1011 # Skip all the warning option stuff on some compilers.
1013 if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
1014 AC_LBL_CHECK_COMPILER_OPT($1, -W)
1015 AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
1016 AC_LBL_CHECK_COMPILER_OPT($1, -Wassign-enum)
1017 AC_LBL_CHECK_COMPILER_OPT($1, -Wcast-qual)
1018 AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
1019 AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-variable-declarations)
1020 AC_LBL_CHECK_COMPILER_OPT($1, -Wnull-pointer-subtraction)
1021 AC_LBL_CHECK_COMPILER_OPT($1, -Wold-style-definition)
1022 AC_LBL_CHECK_COMPILER_OPT($1, -Wpedantic)
1023 AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-arith)
1024 AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-sign)
1025 AC_LBL_CHECK_COMPILER_OPT($1, -Wshadow)
1026 AC_LBL_CHECK_COMPILER_OPT($1, -Wsign-compare)
1027 AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
1028 AC_LBL_CHECK_COMPILER_OPT($1, -Wundef)
1029 AC_LBL_CHECK_COMPILER_OPT($1, -Wunreachable-code-return)
1030 AC_LBL_CHECK_COMPILER_OPT($1, -Wunused-but-set-parameter)
1031 AC_LBL_CHECK_COMPILER_OPT($1, -Wunused-but-set-variable)
1032 AC_LBL_CHECK_COMPILER_OPT($1, -Wused-but-marked-unused)
1033 AC_LBL_CHECK_COMPILER_OPT($1, -Wwrite-strings)
1035 AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
1037 # We used to set -n32 for IRIX 6 when not using GCC (presumed
1038 # to mean that we're using MIPS C or MIPSpro C); it specified
1039 # the "new" faster 32-bit ABI, introduced in IRIX 6.2. I'm
1040 # not sure why that would be something to do *only* with a
1041 # .devel file; why should the ABI for which we produce code
1044 os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
1046 if test -f $name ; then
1047 ln -s $name os-proto.h
1048 AC_DEFINE(HAVE_OS_PROTO_H, 1,
1049 [if there's an os_proto.h for this platform, to use additional prototypes])
1051 AC_MSG_WARN(can't find $name)
1056 dnl Improved version of AC_CHECK_LIB
1058 dnl Thanks to John Hawkinson (jhawk@mit.edu)
1062 dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
1063 dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
1069 dnl XXX - "AC_LBL_LIBRARY_NET" was redone to use "AC_SEARCH_LIBS"
1070 dnl rather than "AC_LBL_CHECK_LIB", so this isn't used any more.
1071 dnl We keep it around for reference purposes in case it's ever
1072 dnl useful in the future.
1075 define(AC_LBL_CHECK_LIB,
1076 [AC_MSG_CHECKING([for $2 in -l$1])
1077 dnl Use a cache variable name containing the library, function
1078 dnl name, and extra libraries to link with, because the test really is
1079 dnl for library $1 defining function $2, when linked with potinal
1080 dnl library $5, not just for library $1. Separate tests with the same
1081 dnl $1 and different $2's or $5's may have different results.
1082 ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
1083 AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
1084 [ac_save_LIBS="$LIBS"
1085 LIBS="-l$1 $5 $LIBS"
1087 ifelse([$2], [main], , dnl Avoid conflicting decl of main.
1088 [/* Override any gcc2 internal prototype to avoid an error. */
1089 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
1093 [/* We use char because int might match the return type of a gcc2
1094 builtin and then its argument prototype would still apply. */
1098 eval "ac_cv_lbl_lib_$ac_lib_var=yes",
1099 eval "ac_cv_lbl_lib_$ac_lib_var=no")
1100 LIBS="$ac_save_LIBS"
1102 if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
1106 ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
1107 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1108 changequote([, ])dnl
1109 AC_DEFINE_UNQUOTED($ac_tr_lib)
1114 ifelse([$4], , , [$4
1120 dnl AC_LBL_LIBRARY_NET
1122 dnl This test is for network applications that need socket() and
1123 dnl gethostbyaddr() -ish functions. Under Solaris, those applications
1124 dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link
1125 dnl with "-lnsl" but should *not* link with "-lsocket" because
1126 dnl libsocket.a breaks a number of things (for instance:
1127 dnl gethostbyaddr() under IRIX 5.2, and snoop sockets under most
1128 dnl versions of IRIX).
1130 dnl Unfortunately, many application developers are not aware of this,
1131 dnl and mistakenly write tests that cause -lsocket to be used under
1132 dnl IRIX. It is also easy to write tests that cause -lnsl to be used
1133 dnl under operating systems where neither are necessary (or useful),
1134 dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
1136 dnl This test exists so that every application developer does not test
1137 dnl this in a different, and subtly broken fashion.
1139 dnl It has been argued that this test should be broken up into two
1140 dnl separate tests, one for the resolver libraries, and one for the
1141 dnl libraries necessary for using Sockets API. Unfortunately, the two
1142 dnl are carefully intertwined and allowing the autoconf user to use
1143 dnl them independently potentially results in unfortunate ordering
1144 dnl dependencies -- as such, such component macros would have to
1145 dnl carefully use indirection and be aware if the other components were
1146 dnl executed. Since other autoconf macros do not go to this trouble,
1147 dnl and almost no applications use sockets without the resolver, this
1148 dnl complexity has not been implemented.
1150 dnl The check for libresolv is in case you are attempting to link
1151 dnl statically and happen to have a libresolv.a lying around (and no
1154 AC_DEFUN(AC_LBL_LIBRARY_NET, [
1155 # Most operating systems have gethostbyaddr() in the default searched
1156 # libraries (i.e. libc):
1157 # Some OSes (eg. Solaris) place it in libnsl
1158 # Some strange OSes (SINIX) have it in libsocket:
1159 AC_SEARCH_LIBS(gethostbyaddr, network nsl socket resolv)
1160 # Unfortunately libsocket sometimes depends on libnsl and
1161 # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this.
1162 if test "$ac_cv_search_gethostbyaddr" = "no"
1164 AC_CHECK_LIB(socket, gethostbyaddr,
1165 LIBS="-lsocket -lnsl $LIBS", , -lnsl)
1167 AC_SEARCH_LIBS(socket, socket, ,
1168 AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl))
1169 # DLPI needs putmsg under HPUX so test for -lstr while we're at it
1170 AC_SEARCH_LIBS(putmsg, str)
1173 dnl Copyright (c) 1999 WIDE Project. All rights reserved.
1175 dnl Redistribution and use in source and binary forms, with or without
1176 dnl modification, are permitted provided that the following conditions
1178 dnl 1. Redistributions of source code must retain the above copyright
1179 dnl notice, this list of conditions and the following disclaimer.
1180 dnl 2. Redistributions in binary form must reproduce the above copyright
1181 dnl notice, this list of conditions and the following disclaimer in the
1182 dnl documentation and/or other materials provided with the distribution.
1183 dnl 3. Neither the name of the project nor the names of its contributors
1184 dnl may be used to endorse or promote products derived from this software
1185 dnl without specific prior written permission.
1187 dnl THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
1188 dnl ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1189 dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1190 dnl ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
1191 dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1192 dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1193 dnl OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1194 dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1195 dnl LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1196 dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1199 AC_DEFUN(AC_LBL_SSLEAY,
1202 # Find the last component of $libdir; it's not necessarily
1203 # "lib" - it might be "lib64" on, for example, x86-64
1206 # We assume the directory in which we're looking for
1207 # libcrypto has a subdirectory with that as its name.
1209 tmplib=`echo "$libdir" | sed 's,.*/,,'`
1212 # XXX - is there a better way to check if a given library is
1213 # in a given directory than checking each of the possible
1214 # shared library suffixes?
1216 # Are there any other suffixes we need to look for? Do we
1217 # have to worry about ".so.{version}"?
1219 # Or should we just look for "libcrypto.*"?
1221 if test -d "$1/$tmplib" -a \( -f "$1/$tmplib/libcrypto.a" -o \
1222 -f "$1/$tmplib/libcrypto.so" -o \
1223 -f "$1/$tmplib/libcrypto.sl" -o \
1224 -f "$1/$tmplib/libcrypto.dylib" \); then
1225 ac_cv_ssleay_path="$1"
1229 # Make sure we have the headers as well.
1231 if test -d "$1/include/openssl" -a -f "$1/include/openssl/des.h"; then
1232 incdir="-I$1/include"
1236 m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
1237 dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
1238 dnl serial 11 (pkg-config-0.29)
1240 dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
1241 dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
1243 dnl This program is free software; you can redistribute it and/or modify
1244 dnl it under the terms of the GNU General Public License as published by
1245 dnl the Free Software Foundation; either version 2 of the License, or
1246 dnl (at your option) any later version.
1248 dnl This program is distributed in the hope that it will be useful, but
1249 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
1250 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1251 dnl General Public License for more details.
1253 dnl You should have received a copy of the GNU General Public License
1254 dnl along with this program; if not, write to the Free Software
1255 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1256 dnl 02111-1307, USA.
1258 dnl As a special exception to the GNU General Public License, if you
1259 dnl distribute this file as part of a program that contains a
1260 dnl configuration script generated by Autoconf, you may include it under
1261 dnl the same distribution terms that you use for the rest of that
1264 dnl PKG_PREREQ(MIN-VERSION)
1265 dnl -----------------------
1268 dnl Verify that the version of the pkg-config macros are at least
1269 dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
1270 dnl installed version of pkg-config, this checks the developer's version
1271 dnl of pkg.m4 when generating configure.
1273 dnl To ensure that this macro is defined, also add:
1274 dnl m4_ifndef([PKG_PREREQ],
1275 dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
1277 dnl See the "Since" comment for each macro you use to see what version
1278 dnl of the macros you require.
1279 m4_defun([PKG_PREREQ],
1280 [m4_define([PKG_MACROS_VERSION], [0.29])
1281 m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
1282 [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
1285 dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
1286 dnl ----------------------------------
1289 dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
1290 dnl first found in the path. Checks that the version of pkg-config found
1291 dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.17.0 is
1292 dnl used since that's the first version where --static was supported.
1293 AC_DEFUN([PKG_PROG_PKG_CONFIG],
1294 [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
1295 m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
1296 m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
1297 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
1298 AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
1299 AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
1301 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
1302 AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
1304 if test -n "$PKG_CONFIG"; then
1305 _pkg_min_version=m4_default([$1], [0.17.0])
1306 AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
1307 if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
1308 AC_MSG_RESULT([yes])
1314 ])dnl PKG_PROG_PKG_CONFIG
1316 dnl PKG_CHECK_EXISTS(MODULE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1317 dnl -------------------------------------------------------------------
1320 dnl Check to see whether a particular module exists. Similar to
1321 dnl PKG_CHECK_MODULE(), but does not set variables or print errors.
1322 AC_DEFUN([PKG_CHECK_EXISTS],
1324 if test -n "$PKG_CONFIG" && \
1325 AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
1326 m4_default([$2], [:])
1327 m4_ifvaln([$3], [else
1331 dnl _PKG_CONFIG_WITH_FLAGS([VARIABLE], [FLAGS], [MODULE])
1332 dnl ---------------------------------------------
1333 dnl Internal wrapper calling pkg-config via PKG_CONFIG and, if
1334 dnl pkg-config fails, reporting the error and quitting.
1335 m4_define([_PKG_CONFIG_WITH_FLAGS],
1336 [if test ! -n "$$1"; then
1337 $1=`$PKG_CONFIG $2 "$3" 2>/dev/null`
1338 if test "x$?" != "x0"; then
1340 # That failed - report an error.
1341 # Re-run the command, telling pkg-config to print an error
1342 # message, capture the error message, and report it.
1343 # This causes the configuration script to fail, as it means
1344 # the script is almost certainly doing something wrong.
1346 _PKG_SHORT_ERRORS_SUPPORTED
1347 if test $_pkg_short_errors_supported = yes; then
1348 _pkg_error_string=`$PKG_CONFIG --short-errors --print-errors $2 "$3" 2>&1`
1350 _pkg_error_string=`$PKG_CONFIG --print-errors $2 "$3" 2>&1`
1352 AC_MSG_ERROR([$PKG_CONFIG $2 "$3" failed: $_pkg_error_string])
1355 ])dnl _PKG_CONFIG_WITH_FLAGS
1358 dnl _PKG_CONFIG([VARIABLE], [FLAGS], [MODULE])
1359 dnl ---------------------------------------------
1360 dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
1361 dnl pkg_failed based on the result.
1362 m4_define([_PKG_CONFIG],
1363 [if test -n "$$1"; then
1365 elif test -n "$PKG_CONFIG"; then
1366 PKG_CHECK_EXISTS([$3],
1367 [pkg_cv_[]$1=`$PKG_CONFIG $2 "$3" 2>/dev/null`
1368 test "x$?" != "x0" && pkg_failed=yes ],
1375 dnl _PKG_SHORT_ERRORS_SUPPORTED
1376 dnl ---------------------------
1377 dnl Internal check to see if pkg-config supports short errors.
1378 AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
1380 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
1381 _pkg_short_errors_supported=yes
1383 _pkg_short_errors_supported=no
1385 ])dnl _PKG_SHORT_ERRORS_SUPPORTED
1388 dnl PKG_CHECK_MODULE(VARIABLE-PREFIX, MODULE, [ACTION-IF-FOUND],
1389 dnl [ACTION-IF-NOT-FOUND])
1390 dnl --------------------------------------------------------------
1392 AC_DEFUN([PKG_CHECK_MODULE],
1394 AC_MSG_CHECKING([for $2 with pkg-config])
1395 if test -n "$PKG_CONFIG"; then
1396 AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $2, overriding pkg-config])dnl
1397 AC_ARG_VAR([$1][_LIBS], [linker flags for $2, overriding pkg-config])dnl
1398 AC_ARG_VAR([$1][_LIBS_STATIC], [static-link linker flags for $2, overriding pkg-config])dnl
1400 if AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$2"]); then
1402 # The package was found, so try to get its C flags and
1405 AC_MSG_RESULT([found])
1406 _PKG_CONFIG_WITH_FLAGS([$1][_CFLAGS], [--cflags], [$2])
1407 _PKG_CONFIG_WITH_FLAGS([$1][_LIBS], [--libs], [$2])
1408 _PKG_CONFIG_WITH_FLAGS([$1][_LIBS_STATIC], [--libs --static], [$2])
1409 m4_default([$3], [:])
1411 AC_MSG_RESULT([not found])
1412 m4_default([$4], [:])
1415 # No pkg-config, so obviously not found with pkg-config.
1416 AC_MSG_RESULT([pkg-config not found])
1417 m4_default([$4], [:])
1419 ])dnl PKG_CHECK_MODULE
1422 dnl PKG_CHECK_MODULE_STATIC(VARIABLE-PREFIX, MODULE, [ACTION-IF-FOUND],
1423 dnl [ACTION-IF-NOT-FOUND])
1424 dnl ---------------------------------------------------------------------
1427 dnl Checks for existence of MODULE and gathers its build flags with
1428 dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
1429 dnl and VARIABLE-PREFIX_LIBS from --libs.
1430 AC_DEFUN([PKG_CHECK_MODULE_STATIC],
1432 _save_PKG_CONFIG=$PKG_CONFIG
1433 PKG_CONFIG="$PKG_CONFIG --static"
1434 PKG_CHECK_MODULE($@)
1435 PKG_CONFIG=$_save_PKG_CONFIG[]dnl
1436 ])dnl PKG_CHECK_MODULE_STATIC
1439 dnl PKG_INSTALLDIR([DIRECTORY])
1440 dnl -------------------------
1443 dnl Substitutes the variable pkgconfigdir as the location where a module
1444 dnl should install pkg-config .pc files. By default the directory is
1445 dnl $libdir/pkgconfig, but the default can be changed by passing
1446 dnl DIRECTORY. The user can override through the --with-pkgconfigdir
1448 AC_DEFUN([PKG_INSTALLDIR],
1449 [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
1450 m4_pushdef([pkg_description],
1451 [pkg-config installation directory @<:@]pkg_default[@:>@])
1452 AC_ARG_WITH([pkgconfigdir],
1453 [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
1454 [with_pkgconfigdir=]pkg_default)
1455 AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
1456 m4_popdef([pkg_default])
1457 m4_popdef([pkg_description])
1458 ])dnl PKG_INSTALLDIR
1461 dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
1462 dnl --------------------------------
1465 dnl Substitutes the variable noarch_pkgconfigdir as the location where a
1466 dnl module should install arch-independent pkg-config .pc files. By
1467 dnl default the directory is $datadir/pkgconfig, but the default can be
1468 dnl changed by passing DIRECTORY. The user can override through the
1469 dnl --with-noarch-pkgconfigdir parameter.
1470 AC_DEFUN([PKG_NOARCH_INSTALLDIR],
1471 [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
1472 m4_pushdef([pkg_description],
1473 [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
1474 AC_ARG_WITH([noarch-pkgconfigdir],
1475 [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
1476 [with_noarch_pkgconfigdir=]pkg_default)
1477 AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
1478 m4_popdef([pkg_default])
1479 m4_popdef([pkg_description])
1480 ])dnl PKG_NOARCH_INSTALLDIR
1483 dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
1484 dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1485 dnl -------------------------------------------
1488 dnl Retrieves the value of the pkg-config variable for the given module.
1489 AC_DEFUN([PKG_CHECK_VAR],
1491 AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
1493 _PKG_CONFIG([$1], [--variable="][$3]["], [$2])
1494 AS_VAR_COPY([$1], [pkg_cv_][$1])
1496 AS_VAR_IF([$1], [""], [$5], [$4])dnl