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
106 $2="$$2 -I/usr/local/include"
107 LDFLAGS="$LDFLAGS -L/usr/local/lib"
113 # This is assumed either to be GCC or clang, both
114 # of which use -Werror to force warnings to be errors.
116 ac_lbl_cc_force_warning_errors=-Werror
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
194 AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
195 AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
197 [#include <sys/types.h>],
198 [struct a { int b; };
199 void c(const struct a *)],
200 ac_cv_lbl_cc_const_proto=yes,
201 ac_cv_lbl_cc_const_proto=no))
202 AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
203 if test $ac_cv_lbl_cc_const_proto = no ; then
205 [to handle Ultrix compilers that don't support const in prototypes])
214 dnl Check whether, if you pass an unknown warning option to the
215 dnl compiler, it fails or just prints a warning message and succeeds.
216 dnl Set ac_lbl_unknown_warning_option_error to the appropriate flag
217 dnl to force an error if it would otherwise just print a warning message
220 AC_DEFUN(AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR,
222 AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option])
223 save_CFLAGS="$CFLAGS"
224 CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
231 # We're assuming this is clang, where
232 # -Werror=unknown-warning-option is the appropriate
233 # option to force the compiler to fail.
235 ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
240 CFLAGS="$save_CFLAGS"
244 dnl Check whether the compiler option specified as the second argument
245 dnl is supported by the compiler and, if so, add it to the macro
246 dnl specified as the first argument
248 AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
250 AC_MSG_CHECKING([whether the compiler supports the $2 option])
251 save_CFLAGS="$CFLAGS"
252 CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2"
258 CFLAGS="$save_CFLAGS"
263 CFLAGS="$save_CFLAGS"
268 dnl Check whether the compiler supports an option to generate
269 dnl Makefile-style dependency lines
271 dnl GCC uses -M for this. Non-GCC compilers that support this
272 dnl use a variety of flags, including but not limited to -M.
274 dnl We test whether the flag in question is supported, as older
275 dnl versions of compilers might not support it.
277 dnl We don't try all the possible flags, just in case some flag means
278 dnl "generate dependencies" on one compiler but means something else
279 dnl on another compiler.
281 dnl Most compilers that support this send the output to the standard
282 dnl output by default. IBM's XLC, however, supports -M but sends
283 dnl the output to {sourcefile-basename}.u, and AIX has no /dev/stdout
284 dnl to work around that, so we don't bother with XLC.
286 AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT,
288 AC_MSG_CHECKING([whether the compiler supports generating dependencies])
289 if test "$GCC" = yes ; then
291 # GCC, or a compiler deemed to be GCC by AC_PROG_CC (even
292 # though it's not); we assume that, in this case, the flag
295 ac_lbl_dependency_flag="-M"
298 # Not GCC or a compiler deemed to be GCC; what platform is
299 # this? (We're assuming that if the compiler isn't GCC
300 # it's the compiler from the vendor of the OS; that won't
301 # necessarily be true for x86 platforms, where it might be
302 # the Intel C compiler.)
308 # MIPS C for IRIX, DEC C, and clang all use -M.
310 ac_lbl_dependency_flag="-M"
317 ac_lbl_dependency_flag="-xM"
322 # HP's older C compilers don't support this.
323 # HP's newer C compilers support this with
324 # either +M or +Make; the older compilers
325 # interpret +M as something completely
326 # different, so we use +Make so we don't
327 # think it works with the older compilers.
329 ac_lbl_dependency_flag="+Make"
334 # Not one of the above; assume no support for
335 # generating dependencies.
337 ac_lbl_dependency_flag=""
343 # Is ac_lbl_dependency_flag defined and, if so, does the compiler
346 # Note: clang doesn't seem to exit with an error status when handed
347 # an unknown non-warning error, even if you pass it
348 # -Werror=unknown-warning-option. However, it always supports
349 # -M, so the fact that this test always succeeds with clang
352 if test ! -z "$ac_lbl_dependency_flag"; then
354 [AC_LANG_SOURCE([[int main(void) { return 0; }]])])
355 echo "$CC" $ac_lbl_dependency_flag conftest.c >&5
356 if "$CC" $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1; then
357 AC_MSG_RESULT([yes, with $ac_lbl_dependency_flag])
358 DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
359 MKDEP='${srcdir}/mkdep'
363 # We can't run mkdep, so have "make depend" do
372 # We can't run mkdep, so have "make depend" do
377 AC_SUBST(DEPENDENCY_CFLAG)
382 dnl Determine what options are needed to build a shared library
386 dnl AC_LBL_SHLIBS_INIT
390 dnl V_CCOPT (modified to build position-independent code)
396 AC_DEFUN(AC_LBL_SHLIBS_INIT,
398 if test "$GCC" = yes ; then
400 # On platforms where we build a shared library:
402 # add options to generate position-independent code,
403 # if necessary (it's the default in AIX and Darwin/OS X);
405 # define option to set the soname of the shared library,
406 # if the OS supports that;
408 # add options to specify, at link time, a directory to
409 # add to the run-time search path, if that's necessary.
412 V_SHLIB_OPT="-shared"
418 freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*)
420 # Platforms where the linker is the GNU linker
421 # or accepts command-line arguments like
422 # those the GNU linker accepts.
424 # Some instruction sets require -fPIC on some
425 # operating systems. Check for them. If you
426 # have a combination that requires it, add it
441 V_CCOPT="$V_CCOPT $PIC_OPT"
442 V_SONAME_OPT="-Wl,-soname,"
443 V_RPATH_OPT="-Wl,-rpath,"
447 V_CCOPT="$V_CCOPT -fpic"
449 # XXX - this assumes GCC is using the HP linker,
450 # rather than the GNU linker, and that the "+h"
451 # option is used on all HP-UX platforms, both .sl
454 V_SONAME_OPT="-Wl,+h,"
456 # By default, directories specifed with -L
457 # are added to the run-time search path, so
458 # we don't add them in pcap-config.
463 V_CCOPT="$V_CCOPT -fpic"
465 # XXX - this assumes GCC is using the Sun linker,
466 # rather than the GNU linker.
468 V_SONAME_OPT="-Wl,-h,"
469 V_RPATH_OPT="-Wl,-R,"
474 # Set the appropriate compiler flags and, on platforms
475 # where we build a shared library:
477 # add options to generate position-independent code,
478 # if necessary (it's the default in Darwin/OS X);
480 # if we generate ".so" shared libraries, define the
481 # appropriate options for building the shared library;
483 # add options to specify, at link time, a directory to
484 # add to the run-time search path, if that's necessary.
486 # Note: spaces after V_SONAME_OPT are significant; on
487 # some platforms the soname is passed with a GCC-like
488 # "-Wl,-soname,{soname}" option, with the soname part
489 # of the option, while on other platforms the C compiler
490 # driver takes it as a regular option with the soname
491 # following the option. The same applies to V_RPATH_OPT.
497 V_SHLIB_OPT="-G -bnoentry -bexpall"
500 freebsd*|netbsd*|openbsd*|dragonfly*|linux*)
504 V_CCOPT="$V_CCOPT -fpic"
506 V_SHLIB_OPT="-shared"
507 V_SONAME_OPT="-Wl,-soname,"
508 V_RPATH_OPT="-Wl,-rpath,"
512 V_CCOPT="$V_CCOPT +z"
517 # By default, directories specifed with -L
518 # are added to the run-time search path, so
519 # we don't add them in pcap-config.
525 # Presumed to be DEC OSF/1, Digital UNIX, or
529 V_SHLIB_OPT="-shared"
530 V_SONAME_OPT="-soname "
531 V_RPATH_OPT="-rpath "
535 V_CCOPT="$V_CCOPT -Kpic"
546 # Try compiling a sample of the type of code that appears in
547 # gencode.c with "inline", "__inline__", and "__inline".
549 # Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough,
550 # as it just tests whether a function returning "int" can be inlined;
551 # at least some versions of HP's C compiler can inline that, but can't
552 # inline a function that returns a struct pointer.
554 # Make sure we use the V_CCOPT flags, because some of those might
557 AC_DEFUN(AC_LBL_C_INLINE,
558 [AC_MSG_CHECKING(for inline)
559 save_CFLAGS="$CFLAGS"
561 AC_CACHE_VAL(ac_cv_lbl_inline, [
564 for ac_lbl_inline in inline __inline__ __inline
567 [#define inline $ac_lbl_inline
568 static inline struct iltest *foo(void);
574 static inline struct iltest *
577 static struct iltest xxx;
580 }],,ac_lbl_cc_inline=yes,)
581 if test "$ac_lbl_cc_inline" = yes ; then
585 if test "$ac_lbl_cc_inline" = yes ; then
586 ac_cv_lbl_inline=$ac_lbl_inline
588 CFLAGS="$save_CFLAGS"
589 if test ! -z "$ac_cv_lbl_inline" ; then
590 AC_MSG_RESULT($ac_cv_lbl_inline)
594 AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
597 dnl If using gcc, make sure we have ANSI ioctl definitions
601 dnl AC_LBL_FIXINCLUDES
603 AC_DEFUN(AC_LBL_FIXINCLUDES,
604 [if test "$GCC" = yes ; then
605 AC_MSG_CHECKING(for ANSI ioctl definitions)
606 AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes,
609 * This generates a "duplicate case value" when fixincludes
612 # include <sys/types.h>
613 # include <sys/time.h>
614 # include <sys/ioctl.h>
615 # ifdef HAVE_SYS_IOCCOM_H
616 # include <sys/ioccom.h>
622 ac_cv_lbl_gcc_fixincludes=yes,
623 ac_cv_lbl_gcc_fixincludes=no))
624 AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes)
625 if test $ac_cv_lbl_gcc_fixincludes = no ; then
626 # Don't cache failure
627 unset ac_cv_lbl_gcc_fixincludes
628 AC_MSG_ERROR(see the INSTALL for more info)
633 dnl Check for flex, default to lex
634 dnl Require flex 2.4 or higher
635 dnl Check for bison, default to yacc
636 dnl Default to lex/yacc if both flex and bison are not available
638 dnl If we're using flex and bison, pass -P to flex and -p to bison
639 dnl to define a prefix string for the lexer and parser
641 dnl If we're not using flex and bison, don't pass those options
642 dnl (as they might not work - although if "lex" is a wrapper for
643 dnl Flex and "yacc" is a wrapper for Bison, they will work), and
644 dnl define NEED_YYPARSE_WRAPPER (we *CANNOT* use YYBISON to check
645 dnl whether the wrapper is needed, as some people apparently, for
646 dnl some unknown reason, choose to use --without-flex and
647 dnl --without-bison on systems that have Flex and Bison, which
648 dnl means that the "yacc" they end up using is a wrapper that
649 dnl runs "bison -y", and at least some versions of Bison define
650 dnl YYBISON even if run with "-y", so we end up not compiling
651 dnl the yyparse wrapper and end up with a libpcap that doesn't
652 dnl define pcap_parse())
656 dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
661 dnl $2 (yacc appended)
662 dnl $3 (optional flex and bison -P prefix)
664 AC_DEFUN(AC_LBL_LEX_AND_YACC,
665 [AC_ARG_WITH(flex, [ --without-flex don't use flex])
666 AC_ARG_WITH(bison, [ --without-bison don't use bison])
667 if test "$with_flex" = no ; then
670 AC_CHECK_PROGS($1, flex, lex)
672 if test "$$1" = flex ; then
673 # The -V flag was added in 2.4
674 AC_MSG_CHECKING(for flex 2.4 or higher)
675 AC_CACHE_VAL(ac_cv_lbl_flex_v24,
676 if flex -V >/dev/null 2>&1; then
677 ac_cv_lbl_flex_v24=yes
679 ac_cv_lbl_flex_v24=no
681 AC_MSG_RESULT($ac_cv_lbl_flex_v24)
682 if test $ac_cv_lbl_flex_v24 = no ; then
683 s="2.4 or higher required"
684 AC_MSG_WARN(ignoring obsolete flex executable ($s))
688 if test "$with_bison" = no ; then
691 AC_CHECK_PROGS($2, bison, yacc)
693 if test "$$2" = bison ; then
696 if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
697 AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
701 if test "$$1" = flex -a -n "$3" ; then
705 AC_DEFINE(NEED_YYPARSE_WRAPPER,1,[if we need a pcap_parse wrapper around yyparse])
709 dnl Checks to see if union wait is used with WEXITSTATUS()
713 dnl AC_LBL_UNION_WAIT
717 dnl DECLWAITSTATUS (defined)
719 AC_DEFUN(AC_LBL_UNION_WAIT,
720 [AC_MSG_CHECKING(if union wait is used)
721 AC_CACHE_VAL(ac_cv_lbl_union_wait,
723 # include <sys/types.h>
724 # include <sys/wait.h>],
726 u_int i = WEXITSTATUS(status);
727 u_int j = waitpid(0, &status, 0);],
728 ac_cv_lbl_union_wait=no,
729 ac_cv_lbl_union_wait=yes))
730 AC_MSG_RESULT($ac_cv_lbl_union_wait)
731 if test $ac_cv_lbl_union_wait = yes ; then
732 AC_DEFINE(DECLWAITSTATUS,union wait,[type for wait])
734 AC_DEFINE(DECLWAITSTATUS,int,[type for wait])
738 dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
742 dnl AC_LBL_SOCKADDR_SA_LEN
746 dnl HAVE_SOCKADDR_SA_LEN (defined)
748 AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
749 [AC_MSG_CHECKING(if sockaddr struct has the sa_len member)
750 AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len,
752 # include <sys/types.h>
753 # include <sys/socket.h>],
754 [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
755 ac_cv_lbl_sockaddr_has_sa_len=yes,
756 ac_cv_lbl_sockaddr_has_sa_len=no))
757 AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len)
758 if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then
759 AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[if struct sockaddr has the sa_len member])
763 dnl Checks to see if there's a sockaddr_storage structure
767 dnl AC_LBL_SOCKADDR_STORAGE
771 dnl HAVE_SOCKADDR_STORAGE (defined)
773 AC_DEFUN(AC_LBL_SOCKADDR_STORAGE,
774 [AC_MSG_CHECKING(if sockaddr_storage struct exists)
775 AC_CACHE_VAL(ac_cv_lbl_has_sockaddr_storage,
777 # include <sys/types.h>
778 # include <sys/socket.h>],
779 [u_int i = sizeof (struct sockaddr_storage)],
780 ac_cv_lbl_has_sockaddr_storage=yes,
781 ac_cv_lbl_has_sockaddr_storage=no))
782 AC_MSG_RESULT($ac_cv_lbl_has_sockaddr_storage)
783 if test $ac_cv_lbl_has_sockaddr_storage = yes ; then
784 AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[if struct sockaddr_storage exists])
788 dnl Checks to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
789 dnl dl_module_id_1 member
793 dnl AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
797 dnl HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 (defined)
799 dnl NOTE: any compile failure means we conclude that it doesn't have
800 dnl that member, so if we don't have DLPI, don't have a <sys/dlpi_ext.h>
801 dnl header, or have one that doesn't declare a dl_hp_ppa_info_t type,
802 dnl we conclude it doesn't have that member (which is OK, as either we
803 dnl won't be using code that would use that member, or we wouldn't
804 dnl compile in any case).
806 AC_DEFUN(AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1,
807 [AC_MSG_CHECKING(if dl_hp_ppa_info_t struct has dl_module_id_1 member)
808 AC_CACHE_VAL(ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1,
810 # include <sys/types.h>
811 # include <sys/dlpi.h>
812 # include <sys/dlpi_ext.h>],
813 [u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)],
814 ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes,
815 ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no))
816 AC_MSG_RESULT($ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1)
817 if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then
818 AC_DEFINE(HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1,1,[if ppa_info_t_dl_module_id exists])
822 dnl Checks to see if -R is used
826 dnl AC_LBL_HAVE_RUN_PATH
830 dnl ac_cv_lbl_have_run_path (yes or no)
832 AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
833 [AC_MSG_CHECKING(for ${CC-cc} -R)
834 AC_CACHE_VAL(ac_cv_lbl_have_run_path,
835 [echo 'main(){}' > conftest.c
836 ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
837 if test ! -s conftest.out ; then
838 ac_cv_lbl_have_run_path=yes
840 ac_cv_lbl_have_run_path=no
843 AC_MSG_RESULT($ac_cv_lbl_have_run_path)
847 dnl Checks to see if unaligned memory accesses fail
851 dnl AC_LBL_UNALIGNED_ACCESS
855 dnl LBL_ALIGN (DEFINED)
857 AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
858 [AC_MSG_CHECKING(if unaligned accesses fail)
859 AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
863 # These are CPU types where:
865 # the CPU faults on an unaligned access, but at least some
866 # OSes that support that CPU catch the fault and simulate
867 # the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) -
868 # the simulation is slow, so we don't want to use it;
870 # the CPU, I infer (from the old
872 # XXX: should also check that they don't do weird things (like on arm)
874 # comment) doesn't fault on unaligned accesses, but doesn't
875 # do a normal unaligned fetch, either (e.g., presumably, ARM);
877 # for whatever reason, the test program doesn't work
878 # (this has been claimed to be the case for several of those
879 # CPUs - I don't know what the problem is; the problem
880 # was reported as "the test program dumps core" for SuperH,
881 # but that's what the test program is *supposed* to do -
882 # it dumps core before it writes anything, so the test
883 # for an empty output file should find an empty output
884 # file and conclude that unaligned accesses don't work).
886 # This run-time test won't work if you're cross-compiling, so
887 # in order to support cross-compiling for a particular CPU,
888 # we have to wire in the list of CPU types anyway, as far as
889 # I know, so perhaps we should just have a set of CPUs on
890 # which we know it doesn't work, a set of CPUs on which we
891 # know it does work, and have the script just fail on other
892 # cpu types and update it when such a failure occurs.
894 alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1)
895 ac_cv_lbl_unaligned_fail=yes
899 cat >conftest.c <<EOF
900 # include <sys/types.h>
901 # include <sys/wait.h>
903 unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
908 /* avoid "core dumped" message */
914 pid = waitpid(pid, &status, 0);
917 exit(!WIFEXITED(status));
920 i = *(unsigned int *)&a[[1]];
925 ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
926 conftest.c $LIBS >/dev/null 2>&1
927 if test ! -x conftest ; then
928 dnl failed to compile for some reason
929 ac_cv_lbl_unaligned_fail=yes
931 ./conftest >conftest.out
932 if test ! -s conftest.out ; then
933 ac_cv_lbl_unaligned_fail=yes
935 ac_cv_lbl_unaligned_fail=no
938 rm -f -r conftest* core core.conftest
941 AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
942 if test $ac_cv_lbl_unaligned_fail = yes ; then
943 AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails])
947 dnl If the file .devel exists:
948 dnl Add some warning flags if the compiler supports them
949 dnl If an os prototype include exists, symlink os-proto.h to it
953 dnl AC_LBL_DEVEL(copt)
957 dnl $1 (copt appended)
958 dnl HAVE_OS_PROTO_H (defined)
959 dnl os-proto.h (symlinked)
961 AC_DEFUN(AC_LBL_DEVEL,
963 if test "${LBL_CFLAGS+set}" = set; then
964 $1="$$1 ${LBL_CFLAGS}"
966 if test -f .devel ; then
968 # Skip all the warning option stuff on some compilers.
970 if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
971 AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR()
972 AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
973 AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
974 AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
976 AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
978 # We used to set -n32 for IRIX 6 when not using GCC (presumed
979 # to mean that we're using MIPS C or MIPSpro C); it specified
980 # the "new" faster 32-bit ABI, introduced in IRIX 6.2. I'm
981 # not sure why that would be something to do *only* with a
982 # .devel file; why should the ABI for which we produce code
985 os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
987 if test -f $name ; then
988 ln -s $name os-proto.h
989 AC_DEFINE(HAVE_OS_PROTO_H, 1,
990 [if there's an os_proto.h for this platform, to use additional prototypes])
992 AC_MSG_WARN(can't find $name)
997 dnl Improved version of AC_CHECK_LIB
999 dnl Thanks to John Hawkinson (jhawk@mit.edu)
1003 dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
1004 dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
1010 dnl XXX - "AC_LBL_LIBRARY_NET" was redone to use "AC_SEARCH_LIBS"
1011 dnl rather than "AC_LBL_CHECK_LIB", so this isn't used any more.
1012 dnl We keep it around for reference purposes in case it's ever
1013 dnl useful in the future.
1016 define(AC_LBL_CHECK_LIB,
1017 [AC_MSG_CHECKING([for $2 in -l$1])
1018 dnl Use a cache variable name containing the library, function
1019 dnl name, and extra libraries to link with, because the test really is
1020 dnl for library $1 defining function $2, when linked with potinal
1021 dnl library $5, not just for library $1. Separate tests with the same
1022 dnl $1 and different $2's or $5's may have different results.
1023 ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
1024 AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
1025 [ac_save_LIBS="$LIBS"
1026 LIBS="-l$1 $5 $LIBS"
1028 ifelse([$2], [main], , dnl Avoid conflicting decl of main.
1029 [/* Override any gcc2 internal prototype to avoid an error. */
1030 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
1034 [/* We use char because int might match the return type of a gcc2
1035 builtin and then its argument prototype would still apply. */
1039 eval "ac_cv_lbl_lib_$ac_lib_var=yes",
1040 eval "ac_cv_lbl_lib_$ac_lib_var=no")
1041 LIBS="$ac_save_LIBS"
1043 if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
1047 ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
1048 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1049 changequote([, ])dnl
1050 AC_DEFINE_UNQUOTED($ac_tr_lib)
1055 ifelse([$4], , , [$4
1061 dnl AC_LBL_LIBRARY_NET
1063 dnl This test is for network applications that need socket() and
1064 dnl gethostbyname() -ish functions. Under Solaris, those applications
1065 dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link
1066 dnl with "-lnsl" but should *not* link with "-lsocket" because
1067 dnl libsocket.a breaks a number of things (for instance:
1068 dnl gethostbyname() under IRIX 5.2, and snoop sockets under most
1069 dnl versions of IRIX).
1071 dnl Unfortunately, many application developers are not aware of this,
1072 dnl and mistakenly write tests that cause -lsocket to be used under
1073 dnl IRIX. It is also easy to write tests that cause -lnsl to be used
1074 dnl under operating systems where neither are necessary (or useful),
1075 dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
1077 dnl This test exists so that every application developer does not test
1078 dnl this in a different, and subtly broken fashion.
1080 dnl It has been argued that this test should be broken up into two
1081 dnl seperate tests, one for the resolver libraries, and one for the
1082 dnl libraries necessary for using Sockets API. Unfortunately, the two
1083 dnl are carefully intertwined and allowing the autoconf user to use
1084 dnl them independantly potentially results in unfortunate ordering
1085 dnl dependancies -- as such, such component macros would have to
1086 dnl carefully use indirection and be aware if the other components were
1087 dnl executed. Since other autoconf macros do not go to this trouble,
1088 dnl and almost no applications use sockets without the resolver, this
1089 dnl complexity has not been implemented.
1091 dnl The check for libresolv is in case you are attempting to link
1092 dnl statically and happen to have a libresolv.a lying around (and no
1095 AC_DEFUN(AC_LBL_LIBRARY_NET, [
1096 # Most operating systems have gethostbyname() in the default searched
1097 # libraries (i.e. libc):
1098 # Some OSes (eg. Solaris) place it in libnsl
1099 # Some strange OSes (SINIX) have it in libsocket:
1100 AC_SEARCH_LIBS(gethostbyname, nsl socket resolv)
1101 # Unfortunately libsocket sometimes depends on libnsl and
1102 # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this.
1103 if test "$ac_cv_search_gethostbyname" = "no"
1105 AC_CHECK_LIB(socket, gethostbyname,
1106 LIBS="-lsocket -lnsl $LIBS", , -lnsl)
1108 AC_SEARCH_LIBS(socket, socket, ,
1109 AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl))
1110 # DLPI needs putmsg under HPUX so test for -lstr while we're at it
1111 AC_SEARCH_LIBS(putmsg, str)
1115 dnl Test for __attribute__
1118 AC_DEFUN(AC_C___ATTRIBUTE__, [
1119 AC_MSG_CHECKING(for __attribute__)
1120 AC_CACHE_VAL(ac_cv___attribute__, [
1125 static void foo(void) __attribute__ ((noreturn));
1134 main(int argc, char **argv)
1139 ac_cv___attribute__=yes,
1140 ac_cv___attribute__=no)])
1141 if test "$ac_cv___attribute__" = "yes"; then
1142 AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
1145 # We can't use __attribute__, so we can't use __attribute__((unused)),
1146 # so we define _U_ to an empty string.
1148 V_DEFS="$V_DEFS -D_U_=\"\""
1150 AC_MSG_RESULT($ac_cv___attribute__)
1154 dnl Test whether __attribute__((unused)) can be used without warnings
1157 AC_DEFUN(AC_C___ATTRIBUTE___UNUSED, [
1158 AC_MSG_CHECKING([whether __attribute__((unused)) can be used without warnings])
1159 AC_CACHE_VAL(ac_cv___attribute___unused, [
1160 save_CFLAGS="$CFLAGS"
1161 CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
1168 main(int argc __attribute((unused)), char **argv __attribute((unused)))
1170 printf("Hello, world!\n");
1174 ac_cv___attribute___unused=yes,
1175 ac_cv___attribute___unused=no)])
1176 CFLAGS="$save_CFLAGS"
1177 if test "$ac_cv___attribute___unused" = "yes"; then
1178 V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
1180 V_DEFS="$V_DEFS -D_U_=\"\""
1182 AC_MSG_RESULT($ac_cv___attribute___unused)
1186 dnl Test whether __attribute__((format)) can be used without warnings
1189 AC_DEFUN(AC_C___ATTRIBUTE___FORMAT, [
1190 AC_MSG_CHECKING([whether __attribute__((format)) can be used without warnings])
1191 AC_CACHE_VAL(ac_cv___attribute___format, [
1192 save_CFLAGS="$CFLAGS"
1193 CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
1198 extern int foo(const char *fmt, ...)
1199 __attribute__ ((format (printf, 1, 2)));
1202 main(int argc, char **argv)
1207 ac_cv___attribute___format=yes,
1208 ac_cv___attribute___format=no)])
1209 CFLAGS="$save_CFLAGS"
1210 if test "$ac_cv___attribute___format" = "yes"; then
1211 AC_DEFINE(__ATTRIBUTE___FORMAT_OK, 1,
1212 [define if your compiler allows __attribute__((format)) without a warning])
1214 AC_MSG_RESULT($ac_cv___attribute___format)
1218 dnl Checks to see if tpacket_stats is defined in linux/if_packet.h
1219 dnl If so then pcap-linux.c can use this to report proper statistics.
1223 AC_DEFUN(AC_LBL_TPACKET_STATS,
1224 [AC_MSG_CHECKING(if if_packet.h has tpacket_stats defined)
1225 AC_CACHE_VAL(ac_cv_lbl_tpacket_stats,
1227 # include <linux/if_packet.h>],
1228 [struct tpacket_stats stats],
1229 ac_cv_lbl_tpacket_stats=yes,
1230 ac_cv_lbl_tpacket_stats=no))
1231 AC_MSG_RESULT($ac_cv_lbl_tpacket_stats)
1232 if test $ac_cv_lbl_tpacket_stats = yes; then
1233 AC_DEFINE(HAVE_TPACKET_STATS,1,[if if_packet.h has tpacket_stats defined])
1237 dnl Checks to see if the tpacket_auxdata struct has a tp_vlan_tci member.
1241 dnl AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
1245 dnl HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI (defined)
1247 dnl NOTE: any compile failure means we conclude that it doesn't have
1248 dnl that member, so if we don't have tpacket_auxdata, we conclude it
1249 dnl doesn't have that member (which is OK, as either we won't be using
1250 dnl code that would use that member, or we wouldn't compile in any case).
1252 AC_DEFUN(AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,
1253 [AC_MSG_CHECKING(if tpacket_auxdata struct has tp_vlan_tci member)
1254 AC_CACHE_VAL(ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci,
1256 # include <sys/types.h>
1257 # include <linux/if_packet.h>],
1258 [u_int i = sizeof(((struct tpacket_auxdata *)0)->tp_vlan_tci)],
1259 ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=yes,
1260 ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=no))
1261 AC_MSG_RESULT($ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci)
1262 if test $ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci = yes ; then
1263 HAVE_LINUX_TPACKET_AUXDATA=tp_vlan_tci
1264 AC_SUBST(HAVE_LINUX_TPACKET_AUXDATA)
1265 AC_DEFINE(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,1,[if tp_vlan_tci exists])
1269 dnl Checks to see if Solaris has the dl_passive_req_t struct defined
1270 dnl in <sys/dlpi.h>.
1274 dnl AC_LBL_DL_PASSIVE_REQ_T
1278 dnl HAVE_DLPI_PASSIVE (defined)
1280 AC_DEFUN(AC_LBL_DL_PASSIVE_REQ_T,
1281 [AC_MSG_CHECKING(if dl_passive_req_t struct exists)
1282 AC_CACHE_VAL(ac_cv_lbl_has_dl_passive_req_t,
1284 # include <sys/types.h>
1285 # include <sys/dlpi.h>],
1286 [u_int i = sizeof(dl_passive_req_t)],
1287 ac_cv_lbl_has_dl_passive_req_t=yes,
1288 ac_cv_lbl_has_dl_passive_req_t=no))
1289 AC_MSG_RESULT($ac_cv_lbl_has_dl_passive_req_t)
1290 if test $ac_cv_lbl_has_dl_passive_req_t = yes ; then
1291 AC_DEFINE(HAVE_DLPI_PASSIVE,1,[if passive_req_t primitive