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_FIXINCLUDES])
43 AC_BEFORE([$0], [AC_LBL_DEVEL])
44 AC_ARG_WITH(gcc, [ --without-gcc don't use gcc])
46 if test "${srcdir}" != "." ; then
49 if test "${CFLAGS+set}" = set; then
52 if test -z "$CC" ; then
56 AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
57 if test $SHLICC2 = yes ; then
64 if test -z "$CC" -a "$with_gcc" = no ; then
71 dnl Determine which compiler we're using (cc or gcc)
72 dnl If using gcc, determine the version number
74 dnl require that it support ansi prototypes
75 dnl use -O (AC_PROG_CC will use -g -O2 on gcc, so we don't need to
76 dnl do that ourselves for gcc)
77 dnl add -g flags, as appropriate
78 dnl explicitly specify /usr/local/include
80 dnl NOTE WELL: with newer versions of autoconf, "gcc" means any compiler
81 dnl that defines __GNUC__, which means clang, for example, counts as "gcc".
85 dnl AC_LBL_C_INIT(copt, incls)
95 AC_DEFUN(AC_LBL_C_INIT,
97 AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
98 AC_BEFORE([$0], [AC_LBL_DEVEL])
99 AC_BEFORE([$0], [AC_LBL_SHLIBS_INIT])
100 if test "$GCC" = yes ; then
102 # -Werror forces warnings to be errors.
104 ac_lbl_cc_force_warning_errors=-Werror
107 # Try to have the compiler default to hiding symbols,
108 # so that only symbols explicitly exported with
109 # PCAP_API will be visible outside (shared) libraries.
111 AC_LBL_CHECK_COMPILER_OPT($1, -fvisibility=hidden)
113 $2="$$2 -I/usr/local/include"
114 LDFLAGS="$LDFLAGS -L/usr/local/lib"
120 # This is assumed either to be GCC or clang, both
121 # of which use -Werror to force warnings to be errors.
123 ac_lbl_cc_force_warning_errors=-Werror
126 # Try to have the compiler default to hiding symbols,
127 # so that only symbols explicitly exported with
128 # PCAP_API will be visible outside (shared) libraries.
130 AC_LBL_CHECK_COMPILER_OPT($1, -fvisibility=hidden)
135 # HP C, which is what we presume we're using, doesn't
136 # exit with a non-zero exit status if we hand it an
137 # invalid -W flag, can't be forced to do so even with
138 # +We, and doesn't handle GCC-style -W flags, so we
139 # don't want to try using GCC-style -W flags.
141 ac_lbl_cc_dont_try_gcc_dashW=yes
146 # MIPS C, which is what we presume we're using, doesn't
147 # necessarily exit with a non-zero exit status if we
148 # hand it an invalid -W flag, can't be forced to do
149 # so, and doesn't handle GCC-style -W flags, so we
150 # don't want to try using GCC-style -W flags.
152 ac_lbl_cc_dont_try_gcc_dashW=yes
154 # It also, apparently, defaults to "char" being
155 # unsigned, unlike most other C implementations;
156 # I suppose we could say "signed char" whenever
157 # we want to guarantee a signed "char", but let's
158 # just force signed chars.
160 # -xansi is normally the default, but the
161 # configure script was setting it; perhaps -cckr
162 # was the default in the Old Days. (Then again,
163 # that would probably be for backwards compatibility
164 # in the days when ANSI C was Shiny and New, i.e.
165 # 1989 and the early '90's, so maybe we can just
166 # drop support for those compilers.)
168 # -g is equivalent to -g2, which turns off
169 # optimization; we choose -g3, which generates
170 # debugging information but doesn't turn off
171 # optimization (even if the optimization would
172 # cause inaccuracies in debugging).
174 $1="$$1 -xansi -signed -g3"
179 # Presumed to be DEC OSF/1, Digital UNIX, or
182 # The DEC C compiler, which is what we presume we're
183 # using, doesn't exit with a non-zero exit status if we
184 # hand it an invalid -W flag, can't be forced to do
185 # so, and doesn't handle GCC-style -W flags, so we
186 # don't want to try using GCC-style -W flags.
188 ac_lbl_cc_dont_try_gcc_dashW=yes
190 # -g is equivalent to -g2, which turns off
191 # optimization; we choose -g3, which generates
192 # debugging information but doesn't turn off
193 # optimization (even if the optimization would
194 # cause inaccuracies in debugging).
201 # Assumed to be Sun C, which requires -errwarn to force
202 # warnings to be treated as errors.
204 ac_lbl_cc_force_warning_errors=-errwarn
207 # Try to have the compiler default to hiding symbols,
208 # so that only symbols explicitly exported with
209 # PCAP_API will be visible outside (shared) libraries.
211 AC_LBL_CHECK_COMPILER_OPT($1, -xldscope=hidden)
215 AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
216 AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
218 [#include <sys/types.h>],
219 [struct a { int b; };
220 void c(const struct a *)],
221 ac_cv_lbl_cc_const_proto=yes,
222 ac_cv_lbl_cc_const_proto=no))
223 AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
224 if test $ac_cv_lbl_cc_const_proto = no ; then
226 [to handle Ultrix compilers that don't support const in prototypes])
235 dnl Save the values of various variables that affect compilation and
236 dnl linking, and that we don't ourselves modify persistently; done
237 dnl before a test involving compiling or linking is done, so that we
238 dnl can restore those variables after the test is done.
240 AC_DEFUN(AC_LBL_SAVE_CHECK_STATE,
242 save_CFLAGS="$CFLAGS"
244 save_LDFLAGS="$LDFLAGS"
248 dnl Restore the values of variables saved by AC_LBL_SAVE_CHECK_STATE.
250 AC_DEFUN(AC_LBL_RESTORE_CHECK_STATE,
252 CFLAGS="$save_CFLAGS"
254 LDFLAGS="$save_LDFLAGS"
258 dnl Check whether the compiler option specified as the second argument
259 dnl is supported by the compiler and, if so, add it to the macro
260 dnl specified as the first argument
262 dnl If a third argument is supplied, treat it as C code to be compiled
263 dnl with the flag in question, and the "treat warnings as errors" flag
264 dnl set, and don't add the flag to the first argument if the compile
265 dnl fails; this is for warning options cause problems that can't be
266 dnl worked around. If a third argument is supplied, a fourth argument
267 dnl should also be supplied; it's a message describing what the test
268 dnl program is checking.
270 AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
272 AC_MSG_CHECKING([whether the compiler supports the $2 option])
273 save_CFLAGS="$CFLAGS"
276 # XXX - yes, this depends on the way AC_LANG_WERROR works,
277 # but no mechanism is provided to turn AC_LANG_WERROR on
278 # *and then turn it back off*, so that we *only* do it when
279 # testing compiler options - 15 years after somebody asked
282 # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
284 save_ac_c_werror_flag="$ac_c_werror_flag"
287 # We use AC_LANG_SOURCE() so that we can control the complete
288 # content of the program being compiled. We do not, for example,
289 # want the default "int main()" that AC_LANG_PROGRAM() generates,
290 # as it will generate a warning with -Wold-style-definition, meaning
291 # that we would treat it as not working, as the test will fail if
292 # *any* error output, including a warning due to the flag we're
293 # testing, is generated; see
295 # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
296 # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
298 # This may, as per those two messages, be fixed in autoconf 2.70,
299 # but we only require 2.64 or newer for now.
302 [AC_LANG_SOURCE([[int main(void) { return 0; }]])],
305 can_add_to_cflags=yes
307 # The compile supports this; do we have some C code for
308 # which the warning should *not* appear?
309 # We test the fourth argument because the third argument
310 # could contain quotes, breaking the test.
314 CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
315 AC_MSG_CHECKING(whether $2 $4)
317 [AC_LANG_SOURCE($3)],
332 CFLAGS="$save_CFLAGS"
333 if test x"$can_add_to_cflags" = "xyes"
340 CFLAGS="$save_CFLAGS"
342 ac_c_werror_flag="$save_ac_c_werror_flag"
346 dnl Check whether the compiler supports an option to generate
347 dnl Makefile-style dependency lines
349 dnl GCC uses -M for this. Non-GCC compilers that support this
350 dnl use a variety of flags, including but not limited to -M.
352 dnl We test whether the flag in question is supported, as older
353 dnl versions of compilers might not support it.
355 dnl We don't try all the possible flags, just in case some flag means
356 dnl "generate dependencies" on one compiler but means something else
357 dnl on another compiler.
359 dnl Most compilers that support this send the output to the standard
360 dnl output by default. IBM's XLC, however, supports -M but sends
361 dnl the output to {sourcefile-basename}.u, and AIX has no /dev/stdout
362 dnl to work around that, so we don't bother with XLC.
364 AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT,
366 AC_MSG_CHECKING([whether the compiler supports generating dependencies])
367 if test "$GCC" = yes ; then
369 # GCC, or a compiler deemed to be GCC by AC_PROG_CC (even
370 # though it's not); we assume that, in this case, the flag
373 ac_lbl_dependency_flag="-M"
376 # Not GCC or a compiler deemed to be GCC; what platform is
377 # this? (We're assuming that if the compiler isn't GCC
378 # it's the compiler from the vendor of the OS; that won't
379 # necessarily be true for x86 platforms, where it might be
380 # the Intel C compiler.)
386 # MIPS C for IRIX, DEC C, and clang all use -M.
388 ac_lbl_dependency_flag="-M"
395 ac_lbl_dependency_flag="-xM"
400 # HP's older C compilers don't support this.
401 # HP's newer C compilers support this with
402 # either +M or +Make; the older compilers
403 # interpret +M as something completely
404 # different, so we use +Make so we don't
405 # think it works with the older compilers.
407 ac_lbl_dependency_flag="+Make"
412 # Not one of the above; assume no support for
413 # generating dependencies.
415 ac_lbl_dependency_flag=""
421 # Is ac_lbl_dependency_flag defined and, if so, does the compiler
424 # Note: clang doesn't seem to exit with an error status when handed
425 # an unknown non-warning error, even if you pass it
426 # -Werror=unknown-warning-option. However, it always supports
427 # -M, so the fact that this test always succeeds with clang
430 if test ! -z "$ac_lbl_dependency_flag"; then
432 [AC_LANG_SOURCE([[int main(void) { return 0; }]])])
433 if AC_RUN_LOG([eval "$CC $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1"]); then
434 AC_MSG_RESULT([yes, with $ac_lbl_dependency_flag])
435 DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
436 MKDEP='${top_srcdir}/mkdep'
440 # We can't run mkdep, so have "make depend" do
443 MKDEP='${top_srcdir}/nomkdep'
449 # We can't run mkdep, so have "make depend" do
452 MKDEP='${top_srcdir}/nomkdep'
454 AC_SUBST(DEPENDENCY_CFLAG)
459 dnl Determine what options are needed to build a shared library
463 dnl AC_LBL_SHLIBS_INIT
467 dnl V_SHLIB_CCOPT (modified to build position-independent code)
472 AC_DEFUN(AC_LBL_SHLIBS_INIT,
474 if test "$GCC" = yes ; then
476 # On platforms where we build a shared library:
478 # add options to generate position-independent code,
479 # if necessary (it's the default in AIX and Darwin/macOS);
481 # define option to set the soname of the shared library,
482 # if the OS supports that;
484 # add options to specify, at link time, a directory to
485 # add to the run-time search path, if that's necessary.
488 V_SHLIB_OPT="-shared"
494 freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*|haiku*|midipix*)
496 # Platforms where the C compiler is GCC or accepts
497 # compatible command-line arguments, and the linker
498 # is the GNU linker or accepts compatible command-line
501 # Some instruction sets require -fPIC on some
502 # operating systems. Check for them. If you
503 # have a combination that requires it, add it
512 freebsd*|openbsd*|linux*)
518 V_SHLIB_CCOPT="$V_SHLIB_CCOPT $PIC_OPT"
519 V_SONAME_OPT="-Wl,-soname,"
523 V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
525 # XXX - this assumes GCC is using the HP linker,
526 # rather than the GNU linker, and that the "+h"
527 # option is used on all HP-UX platforms, both .sl
530 V_SONAME_OPT="-Wl,+h,"
532 # By default, directories specified with -L
533 # are added to the run-time search path, so
534 # we don't add them in pcap-config.
539 V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
541 # Sun/Oracle's C compiler, GCC, and GCC-compatible
542 # compilers support -Wl,{comma-separated list of options},
543 # and we use the C compiler, not ld, for all linking,
544 # including linking to produce a shared library.
546 V_SONAME_OPT="-Wl,-h,"
551 # Set the appropriate compiler flags and, on platforms
552 # where we build a shared library:
554 # add options to generate position-independent code,
555 # if necessary (it's the default in Darwin/macOS);
557 # if we generate ".so" shared libraries, define the
558 # appropriate options for building the shared library;
560 # add options to specify, at link time, a directory to
561 # add to the run-time search path, if that's necessary.
563 # Note: spaces after V_SONAME_OPT are significant; on
564 # some platforms the soname is passed with a GCC-like
565 # "-Wl,-soname,{soname}" option, with the soname part
566 # of the option, while on other platforms the C compiler
567 # driver takes it as a regular option with the soname
568 # following the option.
574 V_SHLIB_OPT="-G -bnoentry -bexpall"
577 freebsd*|netbsd*|openbsd*|dragonfly*|linux*)
579 # Platforms where the C compiler is GCC or accepts
580 # compatible command-line arguments, and the linker
581 # is the GNU linker or accepts compatible command-line
584 # XXX - does 64-bit SPARC require -fPIC?
586 V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
588 V_SHLIB_OPT="-shared"
589 V_SONAME_OPT="-Wl,-soname,"
593 V_SHLIB_CCOPT="$V_SHLIB_CCOPT +z"
598 # By default, directories specified with -L
599 # are added to the run-time search path, so
600 # we don't add them in pcap-config.
606 # Presumed to be DEC OSF/1, Digital UNIX, or
610 V_SHLIB_OPT="-shared"
611 V_SONAME_OPT="-soname "
615 V_SHLIB_CCOPT="$V_SHLIB_CCOPT -Kpic"
619 # Sun/Oracle's C compiler, GCC, and GCC-compatible
620 # compilers support -Wl,{comma-separated list of options},
621 # and we use the C compiler, not ld, for all linking,
622 # including linking to produce a shared library.
624 V_SONAME_OPT="-Wl,-h,"
631 # Try compiling a sample of the type of code that appears in
632 # gencode.c with "inline", "__inline__", and "__inline".
634 # Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough,
635 # as it just tests whether a function returning "int" can be inlined;
636 # at least some versions of HP's C compiler can inline that, but can't
637 # inline a function that returns a struct pointer.
639 # Make sure we use the V_CCOPT flags, because some of those might
642 AC_DEFUN(AC_LBL_C_INLINE,
643 [AC_MSG_CHECKING(for inline)
644 save_CFLAGS="$CFLAGS"
646 AC_CACHE_VAL(ac_cv_lbl_inline, [
649 for ac_lbl_inline in inline __inline__ __inline
652 [#define inline $ac_lbl_inline
653 static inline struct iltest *foo(void);
659 static inline struct iltest *
662 static struct iltest xxx;
665 }],,ac_lbl_cc_inline=yes,)
666 if test "$ac_lbl_cc_inline" = yes ; then
670 if test "$ac_lbl_cc_inline" = yes ; then
671 ac_cv_lbl_inline=$ac_lbl_inline
673 CFLAGS="$save_CFLAGS"
674 if test ! -z "$ac_cv_lbl_inline" ; then
675 AC_MSG_RESULT($ac_cv_lbl_inline)
679 AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
682 # Test whether we have __atomic_load_n() and __atomic_store_n().
684 # We use AC_TRY_LINK because AC_TRY_COMPILE will succeed, as the
685 # compiler will just think that those functions are undefined,
686 # and perhaps warn about that, but not fail to compile.
688 AC_DEFUN(AC_PCAP_C___ATOMICS,
690 AC_MSG_CHECKING(for __atomic_load_n)
691 AC_CACHE_VAL(ac_cv_have___atomic_load_n,
696 j = __atomic_load_n(&i, __ATOMIC_RELAXED);
698 ac_have___atomic_load_n=yes,
699 ac_have___atomic_load_n=no))
700 AC_MSG_RESULT($ac_have___atomic_load_n)
701 if test $ac_have___atomic_load_n = yes ; then
702 AC_DEFINE(HAVE___ATOMIC_LOAD_N, 1,
703 [define if __atomic_load_n is supported by the compiler])
706 AC_MSG_CHECKING(for __atomic_store_n)
707 AC_CACHE_VAL(ac_cv_have___atomic_store_n,
711 __atomic_store_n(&i, 17, __ATOMIC_RELAXED);
713 ac_have___atomic_store_n=yes,
714 ac_have___atomic_store_n=no))
715 AC_MSG_RESULT($ac_have___atomic_store_n)
716 if test $ac_have___atomic_store_n = yes ; then
717 AC_DEFINE(HAVE___ATOMIC_STORE_N, 1,
718 [define if __atomic_store_n is supported by the compiler])
722 dnl If using gcc, make sure we have ANSI ioctl definitions
726 dnl AC_LBL_FIXINCLUDES
728 AC_DEFUN(AC_LBL_FIXINCLUDES,
729 [if test "$GCC" = yes ; then
730 AC_MSG_CHECKING(for ANSI ioctl definitions)
731 AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes,
734 * This generates a "duplicate case value" when fixincludes
737 # include <sys/types.h>
738 # include <sys/time.h>
739 # include <sys/ioctl.h>
740 # ifdef HAVE_SYS_IOCCOM_H
741 # include <sys/ioccom.h>
747 ac_cv_lbl_gcc_fixincludes=yes,
748 ac_cv_lbl_gcc_fixincludes=no))
749 AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes)
750 if test $ac_cv_lbl_gcc_fixincludes = no ; then
751 # Don't cache failure
752 unset ac_cv_lbl_gcc_fixincludes
753 AC_MSG_ERROR(see the INSTALL for more info)
758 dnl Checks to see if union wait is used with WEXITSTATUS()
762 dnl AC_LBL_UNION_WAIT
766 dnl DECLWAITSTATUS (defined)
768 AC_DEFUN(AC_LBL_UNION_WAIT,
769 [AC_MSG_CHECKING(if union wait is used)
770 AC_CACHE_VAL(ac_cv_lbl_union_wait,
772 # include <sys/types.h>
773 # include <sys/wait.h>],
775 u_int i = WEXITSTATUS(status);
776 u_int j = waitpid(0, &status, 0);],
777 ac_cv_lbl_union_wait=no,
778 ac_cv_lbl_union_wait=yes))
779 AC_MSG_RESULT($ac_cv_lbl_union_wait)
780 if test $ac_cv_lbl_union_wait = yes ; then
781 AC_DEFINE(DECLWAITSTATUS,union wait,[type for wait])
783 AC_DEFINE(DECLWAITSTATUS,int,[type for wait])
787 dnl Checks to see if -R is used
791 dnl AC_LBL_HAVE_RUN_PATH
795 dnl ac_cv_lbl_have_run_path (yes or no)
797 AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
798 [AC_MSG_CHECKING(for ${CC-cc} -R)
799 AC_CACHE_VAL(ac_cv_lbl_have_run_path,
800 [echo 'main(){}' > conftest.c
801 ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
802 if test ! -s conftest.out ; then
803 ac_cv_lbl_have_run_path=yes
805 ac_cv_lbl_have_run_path=no
808 AC_MSG_RESULT($ac_cv_lbl_have_run_path)
812 dnl If the file .devel exists:
813 dnl Add some warning flags if the compiler supports them
814 dnl If an os prototype include exists, symlink os-proto.h to it
818 dnl AC_LBL_DEVEL(copt)
822 dnl $1 (copt appended)
823 dnl HAVE_OS_PROTO_H (defined)
824 dnl os-proto.h (symlinked)
826 AC_DEFUN(AC_LBL_DEVEL,
828 if test "${LBL_CFLAGS+set}" = set; then
829 $1="$$1 ${LBL_CFLAGS}"
831 if test -f .devel ; then
833 # Skip all the warning option stuff on some compilers.
835 if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
836 AC_LBL_CHECK_COMPILER_OPT($1, -W)
837 AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
838 AC_LBL_CHECK_COMPILER_OPT($1, -Wcomma)
839 AC_LBL_CHECK_COMPILER_OPT($1, -Wdocumentation)
840 AC_LBL_CHECK_COMPILER_OPT($1, -Wformat-nonliteral)
841 AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-noreturn)
842 AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
843 AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-variable-declarations)
844 AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-arith)
845 AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-sign)
846 AC_LBL_CHECK_COMPILER_OPT($1, -Wshadow)
847 AC_LBL_CHECK_COMPILER_OPT($1, -Wsign-compare)
848 AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
849 AC_LBL_CHECK_COMPILER_OPT($1, -Wunused-parameter)
850 AC_LBL_CHECK_COMPILER_OPT($1, -Wused-but-marked-unused)
851 # Warns about safeguards added in case the enums are
853 # AC_LBL_CHECK_COMPILER_OPT($1, -Wcovered-switch-default)
855 # This can cause problems with ntohs(), ntohl(),
856 # htons(), and htonl() on some platforms, such
857 # as OpenBSD 6.3 with Clang 5.0.1. I guess the
858 # problem is that the macro that ultimately does
859 # the byte-swapping involves a conditional
860 # expression that tests whether the value being
861 # swapped is a compile-time constant or not,
862 # using __builtin_constant_p(), and, depending
863 # on whether it is, does a compile-time swap or
864 # a run-time swap; perhaps the compiler always
865 # considers one of the two results of the
866 # conditional expressin is never evaluated,
867 # because the conditional check is done at
868 # compile time, and thus always says "that
869 # expression is never executed".
871 # (Perhaps there should be a way of flagging
872 # an expression that you *want* evaluated at
873 # compile time, so that the compiler 1) warns
874 # if it *can't* be evaluated at compile time
875 # and 2) *doesn't* warn that the true or false
876 # branch will never be reached.)
878 AC_LBL_CHECK_COMPILER_OPT($1, -Wunreachable-code,
880 #include <arpa/inet.h>
883 testme(unsigned short a)
888 [generates warnings from ntohs()])
889 AC_LBL_CHECK_COMPILER_OPT($1, -Wshorten-64-to-32)
891 AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
893 # We used to set -n32 for IRIX 6 when not using GCC (presumed
894 # to mean that we're using MIPS C or MIPSpro C); it specified
895 # the "new" faster 32-bit ABI, introduced in IRIX 6.2. I'm
896 # not sure why that would be something to do *only* with a
897 # .devel file; why should the ABI for which we produce code
900 os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
902 if test -f $name ; then
903 ln -s $name os-proto.h
904 AC_DEFINE(HAVE_OS_PROTO_H, 1,
905 [if there's an os_proto.h for this platform, to use additional prototypes])
907 AC_MSG_WARN(can't find $name)
912 dnl Improved version of AC_CHECK_LIB
914 dnl Thanks to John Hawkinson (jhawk@mit.edu)
918 dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
919 dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
925 dnl XXX - "AC_LBL_LIBRARY_NET" was redone to use "AC_SEARCH_LIBS"
926 dnl rather than "AC_LBL_CHECK_LIB", so this isn't used any more.
927 dnl We keep it around for reference purposes in case it's ever
928 dnl useful in the future.
931 define(AC_LBL_CHECK_LIB,
932 [AC_MSG_CHECKING([for $2 in -l$1])
933 dnl Use a cache variable name containing the library, function
934 dnl name, and extra libraries to link with, because the test really is
935 dnl for library $1 defining function $2, when linked with potinal
936 dnl library $5, not just for library $1. Separate tests with the same
937 dnl $1 and different $2's or $5's may have different results.
938 ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
939 AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
940 [ac_save_LIBS="$LIBS"
943 ifelse([$2], [main], , dnl Avoid conflicting decl of main.
944 [/* Override any gcc2 internal prototype to avoid an error. */
945 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
949 [/* We use char because int might match the return type of a gcc2
950 builtin and then its argument prototype would still apply. */
954 eval "ac_cv_lbl_lib_$ac_lib_var=yes",
955 eval "ac_cv_lbl_lib_$ac_lib_var=no")
958 if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
962 ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
963 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
965 AC_DEFINE_UNQUOTED($ac_tr_lib)
976 dnl AC_LBL_LIBRARY_NET
978 dnl This test is for network applications that need socket functions and
979 dnl getaddrinfo()/getnameinfo()-ish functions. We now require
980 dnl getaddrinfo() and getnameinfo(). We also prefer versions of
981 dnl recvmsg() that conform to the Single UNIX Specification, so that we
982 dnl can check whether a datagram received with recvmsg() was truncated
983 dnl when received due to the buffer being too small.
985 dnl On most operating systems, they're available in the system library.
987 dnl Under Solaris, we need to link with libsocket and libnsl to get
988 dnl getaddrinfo() and getnameinfo() and, if we have libxnet, we need to
989 dnl link with libxnet before libsocket to get a version of recvmsg()
990 dnl that conforms to the Single UNIX Specification.
992 dnl We use getaddrinfo() because we want a portable thread-safe way
993 dnl of getting information for a host name or port; there exist _r
994 dnl versions of gethostbyname() and getservbyname() on some platforms,
995 dnl but not on all platforms.
997 AC_DEFUN(AC_LBL_LIBRARY_NET, [
999 # Most operating systems have getaddrinfo() in the default searched
1000 # libraries (i.e. libc). Check there first.
1002 AC_CHECK_FUNC(getaddrinfo,,
1005 # Not found in the standard system libraries.
1006 # Try libsocket, which requires libnsl.
1008 AC_CHECK_LIB(socket, getaddrinfo,
1011 # OK, we found it in libsocket.
1013 LIBS="-lsocket -lnsl $LIBS"
1017 # Not found in libsocket; test for it in libnetwork, which
1018 # is where it is in Haiku.
1020 AC_CHECK_LIB(network, getaddrinfo,
1023 # OK, we found it in libnetwork.
1025 LIBS="-lnetwork $LIBS"
1029 # We didn't find it.
1031 AC_MSG_ERROR([getaddrinfo is required, but wasn't found])
1036 # OK, do we have recvmsg() in libxnet?
1037 # We also link with libsocket and libnsl.
1039 AC_CHECK_LIB(xnet, recvmsg,
1042 # Yes - link with it as well.
1045 ], , -lsocket -lnsl)
1047 # DLPI needs putmsg under HPUX so test for -lstr while we're at it
1048 AC_SEARCH_LIBS(putmsg, str)
1051 m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
1052 dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
1053 dnl serial 11 (pkg-config-0.29)
1055 dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
1056 dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
1058 dnl This program is free software; you can redistribute it and/or modify
1059 dnl it under the terms of the GNU General Public License as published by
1060 dnl the Free Software Foundation; either version 2 of the License, or
1061 dnl (at your option) any later version.
1063 dnl This program is distributed in the hope that it will be useful, but
1064 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
1065 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1066 dnl General Public License for more details.
1068 dnl You should have received a copy of the GNU General Public License
1069 dnl along with this program; if not, write to the Free Software
1070 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1071 dnl 02111-1307, USA.
1073 dnl As a special exception to the GNU General Public License, if you
1074 dnl distribute this file as part of a program that contains a
1075 dnl configuration script generated by Autoconf, you may include it under
1076 dnl the same distribution terms that you use for the rest of that
1079 dnl PKG_PREREQ(MIN-VERSION)
1080 dnl -----------------------
1083 dnl Verify that the version of the pkg-config macros are at least
1084 dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
1085 dnl installed version of pkg-config, this checks the developer's version
1086 dnl of pkg.m4 when generating configure.
1088 dnl To ensure that this macro is defined, also add:
1089 dnl m4_ifndef([PKG_PREREQ],
1090 dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
1092 dnl See the "Since" comment for each macro you use to see what version
1093 dnl of the macros you require.
1094 m4_defun([PKG_PREREQ],
1095 [m4_define([PKG_MACROS_VERSION], [0.29])
1096 m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
1097 [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
1100 dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
1101 dnl ----------------------------------
1104 dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
1105 dnl first found in the path. Checks that the version of pkg-config found
1106 dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
1107 dnl used since that's the first version where most current features of
1108 dnl pkg-config existed.
1109 AC_DEFUN([PKG_PROG_PKG_CONFIG],
1110 [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
1111 m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
1112 m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
1113 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
1114 AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
1115 AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
1117 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
1118 AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
1120 if test -n "$PKG_CONFIG"; then
1121 _pkg_min_version=m4_default([$1], [0.9.0])
1122 AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
1123 if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
1124 AC_MSG_RESULT([yes])
1130 ])dnl PKG_PROG_PKG_CONFIG
1132 dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1133 dnl -------------------------------------------------------------------
1136 dnl Check to see whether a particular set of modules exists. Similar to
1137 dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
1138 AC_DEFUN([PKG_CHECK_EXISTS],
1140 if test -n "$PKG_CONFIG" && \
1141 AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
1142 m4_default([$2], [:])
1143 m4_ifvaln([$3], [else
1147 dnl _PKG_CONFIG([VARIABLE], [FLAGS], [MODULES])
1148 dnl ---------------------------------------------
1149 dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
1150 dnl pkg_failed based on the result.
1151 m4_define([_PKG_CONFIG],
1152 [if test -n "$$1"; then
1154 elif test -n "$PKG_CONFIG"; then
1155 PKG_CHECK_EXISTS([$3],
1156 [pkg_cv_[]$1=`$PKG_CONFIG $2 "$3" 2>/dev/null`
1157 test "x$?" != "x0" && pkg_failed=yes ],
1164 dnl _PKG_SHORT_ERRORS_SUPPORTED
1165 dnl ---------------------------
1166 dnl Internal check to see if pkg-config supports short errors.
1167 AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
1169 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
1170 _pkg_short_errors_supported=yes
1172 _pkg_short_errors_supported=no
1174 ])dnl _PKG_SHORT_ERRORS_SUPPORTED
1177 dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
1178 dnl [ACTION-IF-NOT-FOUND])
1179 dnl --------------------------------------------------------------
1181 AC_DEFUN([PKG_CHECK_MODULES],
1183 AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $2, overriding pkg-config])dnl
1184 AC_ARG_VAR([$1][_LIBS], [linker flags for $2, overriding pkg-config])dnl
1185 AC_ARG_VAR([$1][_LIBS_STATIC], [static-link linker flags for $2, overriding pkg-config])dnl
1188 AC_MSG_CHECKING([for $2 with pkg-config])
1189 PKG_CHECK_EXISTS($2,
1192 # The package was found, so try to get its C flags and
1195 _PKG_CONFIG([$1][_CFLAGS], [--cflags], [$2])
1196 _PKG_CONFIG([$1][_LIBS], [--libs], [$2])
1197 _PKG_CONFIG([$1][_LIBS_STATIC], [--libs --static], [$2])
1199 m4_define([_PKG_TEXT], [
1200 Alternatively, you may set the environment variables $1[]_CFLAGS
1201 and $1[]_LIBS to avoid the need to call pkg-config.
1202 See the pkg-config man page for more details.])
1204 if test $pkg_failed = yes; then
1206 # That failed - report an error.
1208 AC_MSG_RESULT([error])
1209 _PKG_SHORT_ERRORS_SUPPORTED
1210 if test $_pkg_short_errors_supported = yes; then
1211 $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
1213 $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
1215 # Put the nasty error message in config.log where it belongs
1216 echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
1218 m4_default([$4], [AC_MSG_ERROR(
1219 [Package requirements ($2) were not met:
1223 Consider adjusting the PKG_CONFIG_PATH environment variable if you
1224 installed software in a non-standard prefix.
1228 elif test $pkg_failed = untried; then
1230 # We don't have pkg-config, so it didn't work.
1232 AC_MSG_RESULT([not found (pkg-config not found)])
1235 # We found the package.
1237 $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
1238 $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
1239 $1[]_LIBS_STATIC=$pkg_cv_[]$1[]_LIBS_STATIC
1240 AC_MSG_RESULT([found])
1246 # The package isn't present.
1248 AC_MSG_RESULT([not found])
1250 ])dnl PKG_CHECK_MODULES
1253 dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
1254 dnl [ACTION-IF-NOT-FOUND])
1255 dnl ---------------------------------------------------------------------
1258 dnl Checks for existence of MODULES and gathers its build flags with
1259 dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
1260 dnl and VARIABLE-PREFIX_LIBS from --libs.
1261 AC_DEFUN([PKG_CHECK_MODULES_STATIC],
1263 _save_PKG_CONFIG=$PKG_CONFIG
1264 PKG_CONFIG="$PKG_CONFIG --static"
1265 PKG_CHECK_MODULES($@)
1266 PKG_CONFIG=$_save_PKG_CONFIG[]dnl
1267 ])dnl PKG_CHECK_MODULES_STATIC
1270 dnl PKG_INSTALLDIR([DIRECTORY])
1271 dnl -------------------------
1274 dnl Substitutes the variable pkgconfigdir as the location where a module
1275 dnl should install pkg-config .pc files. By default the directory is
1276 dnl $libdir/pkgconfig, but the default can be changed by passing
1277 dnl DIRECTORY. The user can override through the --with-pkgconfigdir
1279 AC_DEFUN([PKG_INSTALLDIR],
1280 [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
1281 m4_pushdef([pkg_description],
1282 [pkg-config installation directory @<:@]pkg_default[@:>@])
1283 AC_ARG_WITH([pkgconfigdir],
1284 [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
1285 [with_pkgconfigdir=]pkg_default)
1286 AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
1287 m4_popdef([pkg_default])
1288 m4_popdef([pkg_description])
1289 ])dnl PKG_INSTALLDIR
1292 dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
1293 dnl --------------------------------
1296 dnl Substitutes the variable noarch_pkgconfigdir as the location where a
1297 dnl module should install arch-independent pkg-config .pc files. By
1298 dnl default the directory is $datadir/pkgconfig, but the default can be
1299 dnl changed by passing DIRECTORY. The user can override through the
1300 dnl --with-noarch-pkgconfigdir parameter.
1301 AC_DEFUN([PKG_NOARCH_INSTALLDIR],
1302 [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
1303 m4_pushdef([pkg_description],
1304 [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
1305 AC_ARG_WITH([noarch-pkgconfigdir],
1306 [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
1307 [with_noarch_pkgconfigdir=]pkg_default)
1308 AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
1309 m4_popdef([pkg_default])
1310 m4_popdef([pkg_description])
1311 ])dnl PKG_NOARCH_INSTALLDIR
1314 dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
1315 dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1316 dnl -------------------------------------------
1319 dnl Retrieves the value of the pkg-config variable for the given module.
1320 AC_DEFUN([PKG_CHECK_VAR],
1322 AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
1324 _PKG_CONFIG([$1], [--variable="][$3]["], [$2])
1325 AS_VAR_COPY([$1], [pkg_cv_][$1])
1327 AS_VAR_IF([$1], [""], [$5], [$4])dnl