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" -a "$with_gcc" = no ; then
58 dnl Determine which compiler we're using (cc or gcc)
59 dnl If using gcc, determine the version number
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
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".
72 dnl AC_LBL_C_INIT(copt, incls)
82 AC_DEFUN(AC_LBL_C_INIT,
84 AC_BEFORE([$0], [AC_LBL_DEVEL])
85 AC_BEFORE([$0], [AC_LBL_SHLIBS_INIT])
86 if test "$GCC" = yes ; then
88 # -Werror forces warnings to be errors.
90 ac_lbl_cc_force_warning_errors=-Werror
93 # Try to have the compiler default to hiding symbols,
94 # so that only symbols explicitly exported with
95 # PCAP_API will be visible outside (shared) libraries.
97 AC_LBL_CHECK_COMPILER_OPT($1, -fvisibility=hidden)
99 $2="$$2 -I/usr/local/include"
100 LDFLAGS="$LDFLAGS -L/usr/local/lib"
106 # This is assumed either to be GCC or clang, both
107 # of which use -Werror to force warnings to be errors.
109 ac_lbl_cc_force_warning_errors=-Werror
112 # Try to have the compiler default to hiding symbols,
113 # so that only symbols explicitly exported with
114 # PCAP_API will be visible outside (shared) libraries.
116 AC_LBL_CHECK_COMPILER_OPT($1, -fvisibility=hidden)
121 # HP C, which is what we presume we're using, doesn't
122 # exit with a non-zero exit status if we hand it an
123 # invalid -W flag, can't be forced to do so even with
124 # +We, and doesn't handle GCC-style -W flags, so we
125 # don't want to try using GCC-style -W flags.
127 ac_lbl_cc_dont_try_gcc_dashW=yes
132 # MIPS C, which is what we presume we're using, doesn't
133 # necessarily exit with a non-zero exit status if we
134 # hand it an invalid -W flag, can't be forced to do
135 # so, and doesn't handle GCC-style -W flags, so we
136 # don't want to try using GCC-style -W flags.
138 ac_lbl_cc_dont_try_gcc_dashW=yes
140 # It also, apparently, defaults to "char" being
141 # unsigned, unlike most other C implementations;
142 # I suppose we could say "signed char" whenever
143 # we want to guarantee a signed "char", but let's
144 # just force signed chars.
146 # -xansi is normally the default, but the
147 # configure script was setting it; perhaps -cckr
148 # was the default in the Old Days. (Then again,
149 # that would probably be for backwards compatibility
150 # in the days when ANSI C was Shiny and New, i.e.
151 # 1989 and the early '90's, so maybe we can just
152 # drop support for those compilers.)
154 # -g is equivalent to -g2, which turns off
155 # optimization; we choose -g3, which generates
156 # debugging information but doesn't turn off
157 # optimization (even if the optimization would
158 # cause inaccuracies in debugging).
160 $1="$$1 -xansi -signed -g3"
165 # Presumed to be DEC OSF/1, Digital UNIX, or
168 # The DEC C compiler, which is what we presume we're
169 # using, doesn't exit with a non-zero exit status if we
170 # hand it an invalid -W flag, can't be forced to do
171 # so, and doesn't handle GCC-style -W flags, so we
172 # don't want to try using GCC-style -W flags.
174 ac_lbl_cc_dont_try_gcc_dashW=yes
176 # -g is equivalent to -g2, which turns off
177 # optimization; we choose -g3, which generates
178 # debugging information but doesn't turn off
179 # optimization (even if the optimization would
180 # cause inaccuracies in debugging).
187 # Assumed to be Sun C, which requires -errwarn to force
188 # warnings to be treated as errors.
190 ac_lbl_cc_force_warning_errors=-errwarn
193 # Try to have the compiler default to hiding symbols,
194 # so that only symbols explicitly exported with
195 # PCAP_API will be visible outside (shared) libraries.
197 AC_LBL_CHECK_COMPILER_OPT($1, -xldscope=hidden)
205 dnl Save the values of various variables that affect compilation and
206 dnl linking, and that we don't ourselves modify persistently; done
207 dnl before a test involving compiling or linking is done, so that we
208 dnl can restore those variables after the test is done.
210 AC_DEFUN(AC_LBL_SAVE_CHECK_STATE,
212 save_CFLAGS="$CFLAGS"
214 save_LDFLAGS="$LDFLAGS"
218 dnl Restore the values of variables saved by AC_LBL_SAVE_CHECK_STATE.
220 AC_DEFUN(AC_LBL_RESTORE_CHECK_STATE,
222 CFLAGS="$save_CFLAGS"
224 LDFLAGS="$save_LDFLAGS"
228 dnl Check whether the compiler option specified as the second argument
229 dnl is supported by the compiler and, if so, add it to the macro
230 dnl specified as the first argument
232 dnl If a third argument is supplied, treat it as C code to be compiled
233 dnl with the flag in question, and the "treat warnings as errors" flag
234 dnl set, and don't add the flag to the first argument if the compile
235 dnl fails; this is for warning options cause problems that can't be
236 dnl worked around. If a third argument is supplied, a fourth argument
237 dnl should also be supplied; it's a message describing what the test
238 dnl program is checking.
240 AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
242 AC_MSG_CHECKING([whether the compiler supports the $2 option])
243 save_CFLAGS="$CFLAGS"
246 # XXX - yes, this depends on the way AC_LANG_WERROR works,
247 # but no mechanism is provided to turn AC_LANG_WERROR on
248 # *and then turn it back off*, so that we *only* do it when
249 # testing compiler options - 15 years after somebody asked
252 # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
254 save_ac_c_werror_flag="$ac_c_werror_flag"
257 # We use AC_LANG_SOURCE() so that we can control the complete
258 # content of the program being compiled. We do not, for example,
259 # want the default "int main()" that AC_LANG_PROGRAM() generates,
260 # as it will generate a warning with -Wold-style-definition, meaning
261 # that we would treat it as not working, as the test will fail if
262 # *any* error output, including a warning due to the flag we're
263 # testing, is generated; see
265 # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
266 # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
268 # This may, as per those two messages, be fixed in autoconf 2.70,
269 # but we only require 2.69 or newer for now.
272 [AC_LANG_SOURCE([[int main(void) { return 0; }]])],
275 can_add_to_cflags=yes
277 # The compile supports this; do we have some C code for
278 # which the warning should *not* appear?
279 # We test the fourth argument because the third argument
280 # could contain quotes, breaking the test.
284 CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
285 AC_MSG_CHECKING(whether $2 $4)
287 [AC_LANG_SOURCE($3)],
302 CFLAGS="$save_CFLAGS"
303 if test x"$can_add_to_cflags" = "xyes"
310 CFLAGS="$save_CFLAGS"
312 ac_c_werror_flag="$save_ac_c_werror_flag"
316 dnl Check whether the compiler supports an option to generate
317 dnl Makefile-style dependency lines
319 dnl GCC uses -M for this. Non-GCC compilers that support this
320 dnl use a variety of flags, including but not limited to -M.
322 dnl We test whether the flag in question is supported, as older
323 dnl versions of compilers might not support it.
325 dnl We don't try all the possible flags, just in case some flag means
326 dnl "generate dependencies" on one compiler but means something else
327 dnl on another compiler.
329 dnl Most compilers that support this send the output to the standard
330 dnl output by default. IBM's XLC, however, supports -M but sends
331 dnl the output to {sourcefile-basename}.u, and AIX has no /dev/stdout
332 dnl to work around that, so we don't bother with XLC.
334 AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT,
336 AC_MSG_CHECKING([whether the compiler supports generating dependencies])
337 if test "$GCC" = yes ; then
339 # GCC, or a compiler deemed to be GCC by AC_PROG_CC (even
340 # though it's not); we assume that, in this case, the flag
343 ac_lbl_dependency_flag="-M"
346 # Not GCC or a compiler deemed to be GCC; what platform is
347 # this? (We're assuming that if the compiler isn't GCC
348 # it's the compiler from the vendor of the OS; that won't
349 # necessarily be true for x86 platforms, where it might be
350 # the Intel C compiler.)
356 # MIPS C for IRIX, DEC C, and clang all use -M.
358 ac_lbl_dependency_flag="-M"
365 ac_lbl_dependency_flag="-xM"
370 # HP's older C compilers don't support this.
371 # HP's newer C compilers support this with
372 # either +M or +Make; the older compilers
373 # interpret +M as something completely
374 # different, so we use +Make so we don't
375 # think it works with the older compilers.
377 ac_lbl_dependency_flag="+Make"
382 # Not one of the above; assume no support for
383 # generating dependencies.
385 ac_lbl_dependency_flag=""
391 # Is ac_lbl_dependency_flag defined and, if so, does the compiler
394 # Note: clang doesn't seem to exit with an error status when handed
395 # an unknown non-warning error, even if you pass it
396 # -Werror=unknown-warning-option. However, it always supports
397 # -M, so the fact that this test always succeeds with clang
400 if test ! -z "$ac_lbl_dependency_flag"; then
402 [AC_LANG_SOURCE([[int main(void) { return 0; }]])])
403 if AC_RUN_LOG([eval "$CC $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1"]); then
404 AC_MSG_RESULT([yes, with $ac_lbl_dependency_flag])
405 DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
406 MKDEP='${top_srcdir}/mkdep'
410 # We can't run mkdep, so have "make depend" do
413 MKDEP='${top_srcdir}/nomkdep'
419 # We can't run mkdep, so have "make depend" do
422 MKDEP='${top_srcdir}/nomkdep'
424 AC_SUBST(DEPENDENCY_CFLAG)
429 dnl Determine what options are needed to build a shared library
433 dnl AC_LBL_SHLIBS_INIT
437 dnl V_SHLIB_CCOPT (modified to build position-independent code)
442 AC_DEFUN(AC_LBL_SHLIBS_INIT,
444 if test "$GCC" = yes ; then
446 # On platforms where we build a shared library:
448 # add options to generate position-independent code,
449 # if necessary (it's the default in AIX and Darwin/macOS);
451 # define option to set the soname of the shared library,
452 # if the OS supports that;
454 # add options to specify, at link time, a directory to
455 # add to the run-time search path, if that's necessary.
458 V_SHLIB_OPT="-shared"
464 freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*|haiku*|midipix*|gnu*)
466 # Platforms where the C compiler is GCC or accepts
467 # compatible command-line arguments, and the linker
468 # is the GNU linker or accepts compatible command-line
471 # Some instruction sets require -fPIC on some
472 # operating systems. Check for them. If you
473 # have a combination that requires it, add it
482 freebsd*|openbsd*|linux*)
488 V_SHLIB_CCOPT="$V_SHLIB_CCOPT $PIC_OPT"
489 V_SONAME_OPT="-Wl,-soname,"
493 V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
495 # XXX - this assumes GCC is using the HP linker,
496 # rather than the GNU linker, and that the "+h"
497 # option is used on all HP-UX platforms, both .sl
500 V_SONAME_OPT="-Wl,+h,"
502 # By default, directories specified with -L
503 # are added to the run-time search path, so
504 # we don't add them in pcap-config.
509 V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
511 # Sun/Oracle's C compiler, GCC, and GCC-compatible
512 # compilers support -Wl,{comma-separated list of options},
513 # and we use the C compiler, not ld, for all linking,
514 # including linking to produce a shared library.
516 V_SONAME_OPT="-Wl,-h,"
521 # Set the appropriate compiler flags and, on platforms
522 # where we build a shared library:
524 # add options to generate position-independent code,
525 # if necessary (it's the default in Darwin/macOS);
527 # if we generate ".so" shared libraries, define the
528 # appropriate options for building the shared library;
530 # add options to specify, at link time, a directory to
531 # add to the run-time search path, if that's necessary.
533 # Note: spaces after V_SONAME_OPT are significant; on
534 # some platforms the soname is passed with a GCC-like
535 # "-Wl,-soname,{soname}" option, with the soname part
536 # of the option, while on other platforms the C compiler
537 # driver takes it as a regular option with the soname
538 # following the option.
544 V_SHLIB_OPT="-G -bnoentry -bexpall"
547 freebsd*|netbsd*|openbsd*|dragonfly*|linux*)
549 # Platforms where the C compiler is GCC or accepts
550 # compatible command-line arguments, and the linker
551 # is the GNU linker or accepts compatible command-line
554 # XXX - does 64-bit SPARC require -fPIC?
556 V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
558 V_SHLIB_OPT="-shared"
559 V_SONAME_OPT="-Wl,-soname,"
563 V_SHLIB_CCOPT="$V_SHLIB_CCOPT +z"
568 # By default, directories specified with -L
569 # are added to the run-time search path, so
570 # we don't add them in pcap-config.
576 # Presumed to be DEC OSF/1, Digital UNIX, or
580 V_SHLIB_OPT="-shared"
581 V_SONAME_OPT="-soname "
585 V_SHLIB_CCOPT="$V_SHLIB_CCOPT -Kpic"
589 # Sun/Oracle's C compiler, GCC, and GCC-compatible
590 # compilers support -Wl,{comma-separated list of options},
591 # and we use the C compiler, not ld, for all linking,
592 # including linking to produce a shared library.
594 V_SONAME_OPT="-Wl,-h,"
601 # Test whether we have __atomic_load_n() and __atomic_store_n().
603 # We use AC_LINK_IFELSE because AC_TRY_COMPILE will succeed, as the
604 # compiler will just think that those functions are undefined,
605 # and perhaps warn about that, but not fail to compile.
607 AC_DEFUN(AC_PCAP_C___ATOMICS,
609 AC_MSG_CHECKING(for __atomic_load_n)
610 AC_CACHE_VAL(ac_cv_have___atomic_load_n,
611 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
615 j = __atomic_load_n(&i, __ATOMIC_RELAXED);
617 [ac_have___atomic_load_n=yes],
618 [ac_have___atomic_load_n=no]))
619 AC_MSG_RESULT($ac_have___atomic_load_n)
620 if test $ac_have___atomic_load_n = yes ; then
621 AC_DEFINE(HAVE___ATOMIC_LOAD_N, 1,
622 [define if __atomic_load_n is supported by the compiler])
625 AC_MSG_CHECKING(for __atomic_store_n)
626 AC_CACHE_VAL(ac_cv_have___atomic_store_n,
627 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
630 __atomic_store_n(&i, 17, __ATOMIC_RELAXED);
632 [ac_have___atomic_store_n=yes],
633 [ac_have___atomic_store_n=no]))
634 AC_MSG_RESULT($ac_have___atomic_store_n)
635 if test $ac_have___atomic_store_n = yes ; then
636 AC_DEFINE(HAVE___ATOMIC_STORE_N, 1,
637 [define if __atomic_store_n is supported by the compiler])
641 dnl If the file .devel exists:
642 dnl Add some warning flags if the compiler supports them
643 dnl If an os prototype include exists, symlink os-proto.h to it
647 dnl AC_LBL_DEVEL(copt)
651 dnl $1 (copt appended)
652 dnl HAVE_OS_PROTO_H (defined)
653 dnl os-proto.h (symlinked)
655 AC_DEFUN(AC_LBL_DEVEL,
657 if test "${LBL_CFLAGS+set}" = set; then
658 $1="$$1 ${LBL_CFLAGS}"
660 if test -f .devel ; then
662 # Skip all the warning option stuff on some compilers.
664 if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
665 AC_LBL_CHECK_COMPILER_OPT($1, -W)
666 AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
667 AC_LBL_CHECK_COMPILER_OPT($1, -Wcomma)
668 AC_LBL_CHECK_COMPILER_OPT($1, -Wdocumentation)
669 AC_LBL_CHECK_COMPILER_OPT($1, -Wformat-nonliteral)
670 AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-noreturn)
671 AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
672 AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-variable-declarations)
673 AC_LBL_CHECK_COMPILER_OPT($1, -Wnull-pointer-subtraction)
674 AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-arith)
675 AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-sign)
676 AC_LBL_CHECK_COMPILER_OPT($1, -Wshadow)
677 AC_LBL_CHECK_COMPILER_OPT($1, -Wsign-compare)
678 AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
679 AC_LBL_CHECK_COMPILER_OPT($1, -Wunused-but-set-parameter)
680 AC_LBL_CHECK_COMPILER_OPT($1, -Wunused-but-set-variable)
681 AC_LBL_CHECK_COMPILER_OPT($1, -Wunused-parameter)
682 AC_LBL_CHECK_COMPILER_OPT($1, -Wused-but-marked-unused)
683 # Warns about safeguards added in case the enums are
685 # AC_LBL_CHECK_COMPILER_OPT($1, -Wcovered-switch-default)
687 # This can cause problems with ntohs(), ntohl(),
688 # htons(), and htonl() on some platforms, such
689 # as OpenBSD 6.3 with Clang 5.0.1. I guess the
690 # problem is that the macro that ultimately does
691 # the byte-swapping involves a conditional
692 # expression that tests whether the value being
693 # swapped is a compile-time constant or not,
694 # using __builtin_constant_p(), and, depending
695 # on whether it is, does a compile-time swap or
696 # a run-time swap; perhaps the compiler always
697 # considers one of the two results of the
698 # conditional expression is never evaluated,
699 # because the conditional check is done at
700 # compile time, and thus always says "that
701 # expression is never executed".
703 # (Perhaps there should be a way of flagging
704 # an expression that you *want* evaluated at
705 # compile time, so that the compiler 1) warns
706 # if it *can't* be evaluated at compile time
707 # and 2) *doesn't* warn that the true or false
708 # branch will never be reached.)
710 AC_LBL_CHECK_COMPILER_OPT($1, -Wunreachable-code,
712 #include <arpa/inet.h>
715 testme(unsigned short a)
720 [generates warnings from ntohs()])
721 AC_LBL_CHECK_COMPILER_OPT($1, -Wshorten-64-to-32)
723 AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
725 # We used to set -n32 for IRIX 6 when not using GCC (presumed
726 # to mean that we're using MIPS C or MIPSpro C); it specified
727 # the "new" faster 32-bit ABI, introduced in IRIX 6.2. I'm
728 # not sure why that would be something to do *only* with a
729 # .devel file; why should the ABI for which we produce code
732 AC_MSG_CHECKING([whether to use an os-proto.h header])
733 os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
735 if test -f $name ; then
736 AC_MSG_RESULT([yes, at "$name"])
737 ln -s $name os-proto.h
738 AC_DEFINE(HAVE_OS_PROTO_H, 1,
739 [if there's an os-proto.h for this platform, to use additional prototypes])
746 dnl AC_LBL_LIBRARY_NET
748 dnl Look for various networking-related libraries that we may need.
750 dnl We need getaddrinfo() to translate host names in filters to IP
751 dnl addresses. We use getaddrinfo() because we want a portable
752 dnl thread-safe way of getting information for a host name or port;
753 dnl there exist _r versions of gethostbyname() and getservbyname() on
754 dnl some platforms, but not on all platforms.
756 dnl We may also need socket() and other socket functions to support:
758 dnl Local packet capture with capture mechanisms that use sockets.
760 dnl Local capture device enumeration if a socket call is needed to
761 dnl enumerate devices or get device attributes.
763 dnl Packet capture from services that put captured packets on the
764 dnl network, such as rpcap servers.
766 dnl We may also need getnameinfo() for packet capture from services
767 dnl that put packets on the network.
769 AC_DEFUN(AC_LBL_LIBRARY_NET, [
771 # Most operating systems have getaddrinfo(), and the other routines
772 # we may need, in the default searched libraries (e.g., libc).
775 AC_CHECK_FUNC(getaddrinfo,,
778 # Not found in the standard system libraries.
780 # In some versions of Solaris, we need to link with libsocket
781 # and libnsl, so check in libsocket and also link with liblnsl
782 # when doing this test.
784 # Linking with libsocket and libnsl will find all the routines
787 AC_CHECK_LIB(socket, getaddrinfo,
790 # OK, we found it in libsocket.
792 LIBS="-lsocket -lnsl $LIBS"
796 # Not found in libsocket; test for it in libnetwork, which
797 # is where it is in Haiku.
799 # Linking with libnetwork will find all the routines we
802 AC_CHECK_LIB(network, getaddrinfo,
805 # OK, we found it in libnetwork.
807 LIBS="-lnetwork $LIBS"
813 AC_MSG_ERROR([getaddrinfo is required, but wasn't found])
818 # We require a version of recvmsg() that conforms to the Single
819 # UNIX Specification, so that we can check whether a datagram
820 # received with recvmsg() was truncated when received due to the
821 # buffer being too small.
823 # On most systems, the version of recvmsg() in the libraries
824 # found above conforms to the SUS.
826 # On at least some versions of Solaris, it does not conform to
827 # the SUS, and we need the version in libxnet, which does
830 # Check whether libxnet exists and has a version of recvmsg();
831 # if it does, link with libxnet before we link with libsocket,
832 # to get that version.
834 # This test also links with libsocket and libnsl.
836 AC_CHECK_LIB(xnet, recvmsg,
839 # libxnet has recvmsg(); link with it as well.
846 # DLPI needs putmsg under HP-UX, so test for -lstr while we're at it.
848 AC_SEARCH_LIBS(putmsg, str)
851 m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
852 dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
853 dnl serial 11 (pkg-config-0.29)
855 dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
856 dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
858 dnl This program is free software; you can redistribute it and/or modify
859 dnl it under the terms of the GNU General Public License as published by
860 dnl the Free Software Foundation; either version 2 of the License, or
861 dnl (at your option) any later version.
863 dnl This program is distributed in the hope that it will be useful, but
864 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
865 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
866 dnl General Public License for more details.
868 dnl You should have received a copy of the GNU General Public License
869 dnl along with this program; if not, write to the Free Software
870 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
873 dnl As a special exception to the GNU General Public License, if you
874 dnl distribute this file as part of a program that contains a
875 dnl configuration script generated by Autoconf, you may include it under
876 dnl the same distribution terms that you use for the rest of that
879 dnl PKG_PREREQ(MIN-VERSION)
880 dnl -----------------------
883 dnl Verify that the version of the pkg-config macros are at least
884 dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
885 dnl installed version of pkg-config, this checks the developer's version
886 dnl of pkg.m4 when generating configure.
888 dnl To ensure that this macro is defined, also add:
889 dnl m4_ifndef([PKG_PREREQ],
890 dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
892 dnl See the "Since" comment for each macro you use to see what version
893 dnl of the macros you require.
894 m4_defun([PKG_PREREQ],
895 [m4_define([PKG_MACROS_VERSION], [0.29])
896 m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
897 [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
900 dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
901 dnl ----------------------------------
904 dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
905 dnl first found in the path. Checks that the version of pkg-config found
906 dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.17.0 is
907 dnl used since that's the first version where --static was supported.
908 AC_DEFUN([PKG_PROG_PKG_CONFIG],
909 [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
910 m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
911 m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
912 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
913 AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
914 AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
916 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
917 AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
919 if test -n "$PKG_CONFIG"; then
920 _pkg_min_version=m4_default([$1], [0.17.0])
921 AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
922 if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
929 ])dnl PKG_PROG_PKG_CONFIG
931 dnl PKG_CHECK_EXISTS(MODULE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
932 dnl -------------------------------------------------------------------
935 dnl Check to see whether a particular module exists. Similar to
936 dnl PKG_CHECK_MODULE(), but does not set variables or print errors.
937 AC_DEFUN([PKG_CHECK_EXISTS],
939 if test -n "$PKG_CONFIG" && \
940 AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
941 m4_default([$2], [:])
942 m4_ifvaln([$3], [else
946 dnl _PKG_CONFIG_WITH_FLAGS([VARIABLE], [FLAGS], [MODULE])
947 dnl ---------------------------------------------
948 dnl Internal wrapper calling pkg-config via PKG_CONFIG and, if
949 dnl pkg-config fails, reporting the error and quitting.
950 m4_define([_PKG_CONFIG_WITH_FLAGS],
951 [if test ! -n "$$1"; then
952 $1=`$PKG_CONFIG $2 "$3" 2>/dev/null`
953 if test "x$?" != "x0"; then
955 # That failed - report an error.
956 # Re-run the command, telling pkg-config to print an error
957 # message, capture the error message, and report it.
958 # This causes the configuration script to fail, as it means
959 # the script is almost certainly doing something wrong.
961 _PKG_SHORT_ERRORS_SUPPORTED
962 if test $_pkg_short_errors_supported = yes; then
963 _pkg_error_string=`$PKG_CONFIG --short-errors --print-errors $2 "$3" 2>&1`
965 _pkg_error_string=`$PKG_CONFIG --print-errors $2 "$3" 2>&1`
967 AC_MSG_ERROR([$PKG_CONFIG $2 "$3" failed: $_pkg_error_string])
970 ])dnl _PKG_CONFIG_WITH_FLAGS
973 dnl _PKG_CONFIG([VARIABLE], [FLAGS], [MODULE])
974 dnl ---------------------------------------------
975 dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
976 dnl pkg_failed based on the result.
977 m4_define([_PKG_CONFIG],
978 [if test -n "$$1"; then
980 elif test -n "$PKG_CONFIG"; then
981 PKG_CHECK_EXISTS([$3],
982 [pkg_cv_[]$1=`$PKG_CONFIG $2 "$3" 2>/dev/null`
983 test "x$?" != "x0" && pkg_failed=yes ],
990 dnl _PKG_SHORT_ERRORS_SUPPORTED
991 dnl ---------------------------
992 dnl Internal check to see if pkg-config supports short errors.
993 AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
995 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
996 _pkg_short_errors_supported=yes
998 _pkg_short_errors_supported=no
1000 ])dnl _PKG_SHORT_ERRORS_SUPPORTED
1003 dnl PKG_CHECK_MODULE(VARIABLE-PREFIX, MODULE, [ACTION-IF-FOUND],
1004 dnl [ACTION-IF-NOT-FOUND])
1005 dnl --------------------------------------------------------------
1007 AC_DEFUN([PKG_CHECK_MODULE],
1009 AC_MSG_CHECKING([for $2 with pkg-config])
1010 if test -n "$PKG_CONFIG"; then
1011 AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $2, overriding pkg-config])dnl
1012 AC_ARG_VAR([$1][_LIBS], [linker flags for $2, overriding pkg-config])dnl
1013 AC_ARG_VAR([$1][_LIBS_STATIC], [static-link linker flags for $2, overriding pkg-config])dnl
1015 if AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$2"]); then
1017 # The package was found, so try to get its C flags and
1020 AC_MSG_RESULT([found])
1021 _PKG_CONFIG_WITH_FLAGS([$1][_CFLAGS], [--cflags], [$2])
1022 _PKG_CONFIG_WITH_FLAGS([$1][_LIBS], [--libs], [$2])
1023 _PKG_CONFIG_WITH_FLAGS([$1][_LIBS_STATIC], [--libs --static], [$2])
1024 m4_default([$3], [:])
1026 AC_MSG_RESULT([not found])
1027 m4_default([$4], [:])
1030 # No pkg-config, so obviously not found with pkg-config.
1031 AC_MSG_RESULT([pkg-config not found])
1032 m4_default([$4], [:])
1034 ])dnl PKG_CHECK_MODULE
1037 dnl PKG_CHECK_MODULE_STATIC(VARIABLE-PREFIX, MODULE, [ACTION-IF-FOUND],
1038 dnl [ACTION-IF-NOT-FOUND])
1039 dnl ---------------------------------------------------------------------
1042 dnl Checks for existence of MODULE and gathers its build flags with
1043 dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
1044 dnl and VARIABLE-PREFIX_LIBS from --libs.
1045 AC_DEFUN([PKG_CHECK_MODULE_STATIC],
1047 _save_PKG_CONFIG=$PKG_CONFIG
1048 PKG_CONFIG="$PKG_CONFIG --static"
1049 PKG_CHECK_MODULE($@)
1050 PKG_CONFIG=$_save_PKG_CONFIG[]dnl
1051 ])dnl PKG_CHECK_MODULE_STATIC
1054 dnl PKG_INSTALLDIR([DIRECTORY])
1055 dnl -------------------------
1058 dnl Substitutes the variable pkgconfigdir as the location where a module
1059 dnl should install pkg-config .pc files. By default the directory is
1060 dnl $libdir/pkgconfig, but the default can be changed by passing
1061 dnl DIRECTORY. The user can override through the --with-pkgconfigdir
1063 AC_DEFUN([PKG_INSTALLDIR],
1064 [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
1065 m4_pushdef([pkg_description],
1066 [pkg-config installation directory @<:@]pkg_default[@:>@])
1067 AC_ARG_WITH([pkgconfigdir],
1068 [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
1069 [with_pkgconfigdir=]pkg_default)
1070 AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
1071 m4_popdef([pkg_default])
1072 m4_popdef([pkg_description])
1073 ])dnl PKG_INSTALLDIR
1076 dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
1077 dnl --------------------------------
1080 dnl Substitutes the variable noarch_pkgconfigdir as the location where a
1081 dnl module should install arch-independent pkg-config .pc files. By
1082 dnl default the directory is $datadir/pkgconfig, but the default can be
1083 dnl changed by passing DIRECTORY. The user can override through the
1084 dnl --with-noarch-pkgconfigdir parameter.
1085 AC_DEFUN([PKG_NOARCH_INSTALLDIR],
1086 [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
1087 m4_pushdef([pkg_description],
1088 [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
1089 AC_ARG_WITH([noarch-pkgconfigdir],
1090 [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
1091 [with_noarch_pkgconfigdir=]pkg_default)
1092 AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
1093 m4_popdef([pkg_default])
1094 m4_popdef([pkg_description])
1095 ])dnl PKG_NOARCH_INSTALLDIR
1098 dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
1099 dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1100 dnl -------------------------------------------
1103 dnl Retrieves the value of the pkg-config variable for the given module.
1104 AC_DEFUN([PKG_CHECK_VAR],
1106 AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
1108 _PKG_CONFIG([$1], [--variable="][$3]["], [$2])
1109 AS_VAR_COPY([$1], [pkg_cv_][$1])
1111 AS_VAR_IF([$1], [""], [$5], [$4])dnl