Blame aclocal.m4

Packit Service c0f7c7
dnl Copyright (c) 1995, 1996, 1997, 1998
Packit Service c0f7c7
dnl	The Regents of the University of California.  All rights reserved.
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl Redistribution and use in source and binary forms, with or without
Packit Service c0f7c7
dnl modification, are permitted provided that: (1) source code distributions
Packit Service c0f7c7
dnl retain the above copyright notice and this paragraph in its entirety, (2)
Packit Service c0f7c7
dnl distributions including binary code include the above copyright notice and
Packit Service c0f7c7
dnl this paragraph in its entirety in the documentation or other materials
Packit Service c0f7c7
dnl provided with the distribution, and (3) all advertising materials mentioning
Packit Service c0f7c7
dnl features or use of this software display the following acknowledgement:
Packit Service c0f7c7
dnl ``This product includes software developed by the University of California,
Packit Service c0f7c7
dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
Packit Service c0f7c7
dnl the University nor the names of its contributors may be used to endorse
Packit Service c0f7c7
dnl or promote products derived from this software without specific prior
Packit Service c0f7c7
dnl written permission.
Packit Service c0f7c7
dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
Packit Service c0f7c7
dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
Packit Service c0f7c7
dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl LBL autoconf macros
Packit Service c0f7c7
dnl
Packit Service c0f7c7
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl Do whatever AC_LBL_C_INIT work is necessary before using AC_PROG_CC.
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl It appears that newer versions of autoconf (2.64 and later) will,
Packit Service c0f7c7
dnl if you use AC_TRY_COMPILE in a macro, stick AC_PROG_CC at the
Packit Service c0f7c7
dnl beginning of the macro, even if the macro itself calls AC_PROG_CC.
Packit Service c0f7c7
dnl See the "Prerequisite Macros" and "Expanded Before Required" sections
Packit Service c0f7c7
dnl in the Autoconf documentation.
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl This causes a steaming heap of fail in our case, as we were, in
Packit Service c0f7c7
dnl AC_LBL_C_INIT, doing the tests we now do in AC_LBL_C_INIT_BEFORE_CC,
Packit Service c0f7c7
dnl calling AC_PROG_CC, and then doing the tests we now do in
Packit Service c0f7c7
dnl AC_LBL_C_INIT.  Now, we run AC_LBL_C_INIT_BEFORE_CC, AC_PROG_CC,
Packit Service c0f7c7
dnl and AC_LBL_C_INIT at the top level.
Packit Service c0f7c7
dnl
Packit Service c0f7c7
AC_DEFUN(AC_LBL_C_INIT_BEFORE_CC,
Packit Service c0f7c7
[
Packit Service c0f7c7
    AC_BEFORE([$0], [AC_LBL_C_INIT])
Packit Service c0f7c7
    AC_BEFORE([$0], [AC_PROG_CC])
Packit Service c0f7c7
    AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
Packit Service c0f7c7
    AC_BEFORE([$0], [AC_LBL_DEVEL])
Packit Service c0f7c7
    AC_ARG_WITH(gcc, [  --without-gcc           don't use gcc])
Packit Service c0f7c7
    $1=""
Packit Service c0f7c7
    if test "${srcdir}" != "." ; then
Packit Service c0f7c7
	    $1="-I\$(srcdir)"
Packit Service c0f7c7
    fi
Packit Service c0f7c7
    if test "${CFLAGS+set}" = set; then
Packit Service c0f7c7
	    LBL_CFLAGS="$CFLAGS"
Packit Service c0f7c7
    fi
Packit Service c0f7c7
    if test -z "$CC" ; then
Packit Service c0f7c7
	    case "$host_os" in
Packit Service c0f7c7
Packit Service c0f7c7
	    bsdi*)
Packit Service c0f7c7
		    AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
Packit Service c0f7c7
		    if test $SHLICC2 = yes ; then
Packit Service c0f7c7
			    CC=shlicc2
Packit Service c0f7c7
			    export CC
Packit Service c0f7c7
		    fi
Packit Service c0f7c7
		    ;;
Packit Service c0f7c7
	    esac
Packit Service c0f7c7
    fi
Packit Service c0f7c7
    if test -z "$CC" -a "$with_gcc" = no ; then
Packit Service c0f7c7
	    CC=cc
Packit Service c0f7c7
	    export CC
Packit Service c0f7c7
    fi
Packit Service c0f7c7
])
Packit Service c0f7c7
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl Determine which compiler we're using (cc or gcc)
Packit Service c0f7c7
dnl If using gcc, determine the version number
Packit Service c0f7c7
dnl If using cc:
Packit Service c0f7c7
dnl     require that it support ansi prototypes
Packit Service c0f7c7
dnl     use -O (AC_PROG_CC will use -g -O2 on gcc, so we don't need to
Packit Service c0f7c7
dnl     do that ourselves for gcc)
Packit Service c0f7c7
dnl     add -g flags, as appropriate
Packit Service c0f7c7
dnl     explicitly specify /usr/local/include
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl NOTE WELL: with newer versions of autoconf, "gcc" means any compiler
Packit Service c0f7c7
dnl that defines __GNUC__, which means clang, for example, counts as "gcc".
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl usage:
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl	AC_LBL_C_INIT(copt, incls)
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl results:
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl	$1 (copt set)
Packit Service c0f7c7
dnl	$2 (incls set)
Packit Service c0f7c7
dnl	CC
Packit Service c0f7c7
dnl	LDFLAGS
Packit Service c0f7c7
dnl	LBL_CFLAGS
Packit Service c0f7c7
dnl
Packit Service c0f7c7
AC_DEFUN(AC_LBL_C_INIT,
Packit Service c0f7c7
[
Packit Service c0f7c7
    AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
Packit Service c0f7c7
    AC_BEFORE([$0], [AC_LBL_DEVEL])
Packit Service c0f7c7
    AC_BEFORE([$0], [AC_LBL_SHLIBS_INIT])
Packit Service c0f7c7
    if test "$GCC" = yes ; then
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    # -Werror forces warnings to be errors.
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    ac_lbl_cc_force_warning_errors=-Werror
Packit Service c0f7c7
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    # Try to have the compiler default to hiding symbols,
Packit Service c0f7c7
	    # so that only symbols explicitly exported with
Packit Service c0f7c7
	    # PCAP_API will be visible outside (shared) libraries.
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    AC_LBL_CHECK_COMPILER_OPT($1, -fvisibility=hidden)
Packit Service c0f7c7
    else
Packit Service c0f7c7
	    $2="$$2 -I/usr/local/include"
Packit Service c0f7c7
	    LDFLAGS="$LDFLAGS -L/usr/local/lib"
Packit Service c0f7c7
Packit Service c0f7c7
	    case "$host_os" in
Packit Service c0f7c7
Packit Service c0f7c7
	    darwin*)
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # This is assumed either to be GCC or clang, both
Packit Service c0f7c7
		    # of which use -Werror to force warnings to be errors.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    ac_lbl_cc_force_warning_errors=-Werror
Packit Service c0f7c7
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # Try to have the compiler default to hiding symbols,
Packit Service c0f7c7
		    # so that only symbols explicitly exported with
Packit Service c0f7c7
		    # PCAP_API will be visible outside (shared) libraries.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -fvisibility=hidden)
Packit Service c0f7c7
		    ;;
Packit Service c0f7c7
Packit Service c0f7c7
	    hpux*)
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # HP C, which is what we presume we're using, doesn't
Packit Service c0f7c7
		    # exit with a non-zero exit status if we hand it an
Packit Service c0f7c7
		    # invalid -W flag, can't be forced to do so even with
Packit Service c0f7c7
		    # +We, and doesn't handle GCC-style -W flags, so we
Packit Service c0f7c7
		    # don't want to try using GCC-style -W flags.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    ac_lbl_cc_dont_try_gcc_dashW=yes
Packit Service c0f7c7
		    ;;
Packit Service c0f7c7
Packit Service c0f7c7
	    irix*)
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # MIPS C, which is what we presume we're using, doesn't
Packit Service c0f7c7
		    # necessarily exit with a non-zero exit status if we
Packit Service c0f7c7
		    # hand it an invalid -W flag, can't be forced to do
Packit Service c0f7c7
		    # so, and doesn't handle GCC-style -W flags, so we
Packit Service c0f7c7
		    # don't want to try using GCC-style -W flags.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    ac_lbl_cc_dont_try_gcc_dashW=yes
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # It also, apparently, defaults to "char" being
Packit Service c0f7c7
		    # unsigned, unlike most other C implementations;
Packit Service c0f7c7
		    # I suppose we could say "signed char" whenever
Packit Service c0f7c7
		    # we want to guarantee a signed "char", but let's
Packit Service c0f7c7
		    # just force signed chars.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # -xansi is normally the default, but the
Packit Service c0f7c7
		    # configure script was setting it; perhaps -cckr
Packit Service c0f7c7
		    # was the default in the Old Days.  (Then again,
Packit Service c0f7c7
		    # that would probably be for backwards compatibility
Packit Service c0f7c7
		    # in the days when ANSI C was Shiny and New, i.e.
Packit Service c0f7c7
		    # 1989 and the early '90's, so maybe we can just
Packit Service c0f7c7
		    # drop support for those compilers.)
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # -g is equivalent to -g2, which turns off
Packit Service c0f7c7
		    # optimization; we choose -g3, which generates
Packit Service c0f7c7
		    # debugging information but doesn't turn off
Packit Service c0f7c7
		    # optimization (even if the optimization would
Packit Service c0f7c7
		    # cause inaccuracies in debugging).
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    $1="$$1 -xansi -signed -g3"
Packit Service c0f7c7
		    ;;
Packit Service c0f7c7
Packit Service c0f7c7
	    osf*)
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # Presumed to be DEC OSF/1, Digital UNIX, or
Packit Service c0f7c7
		    # Tru64 UNIX.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # The DEC C compiler, which is what we presume we're
Packit Service c0f7c7
		    # using, doesn't exit with a non-zero exit status if we
Packit Service c0f7c7
		    # hand it an invalid -W flag, can't be forced to do
Packit Service c0f7c7
		    # so, and doesn't handle GCC-style -W flags, so we
Packit Service c0f7c7
		    # don't want to try using GCC-style -W flags.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    ac_lbl_cc_dont_try_gcc_dashW=yes
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # -g is equivalent to -g2, which turns off
Packit Service c0f7c7
		    # optimization; we choose -g3, which generates
Packit Service c0f7c7
		    # debugging information but doesn't turn off
Packit Service c0f7c7
		    # optimization (even if the optimization would
Packit Service c0f7c7
		    # cause inaccuracies in debugging).
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    $1="$$1 -g3"
Packit Service c0f7c7
		    ;;
Packit Service c0f7c7
Packit Service c0f7c7
	    solaris*)
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # Assumed to be Sun C, which requires -errwarn to force
Packit Service c0f7c7
		    # warnings to be treated as errors.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    ac_lbl_cc_force_warning_errors=-errwarn
Packit Service c0f7c7
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # Try to have the compiler default to hiding symbols,
Packit Service c0f7c7
		    # so that only symbols explicitly exported with
Packit Service c0f7c7
		    # PCAP_API will be visible outside (shared) libraries.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -xldscope=hidden)
Packit Service c0f7c7
		    ;;
Packit Service c0f7c7
Packit Service c0f7c7
	    ultrix*)
Packit Service c0f7c7
		    AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
Packit Service c0f7c7
		    AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
Packit Service c0f7c7
			AC_TRY_COMPILE(
Packit Service c0f7c7
			    [#include <sys/types.h>],
Packit Service c0f7c7
			    [struct a { int b; };
Packit Service c0f7c7
			    void c(const struct a *)],
Packit Service c0f7c7
			    ac_cv_lbl_cc_const_proto=yes,
Packit Service c0f7c7
			    ac_cv_lbl_cc_const_proto=no))
Packit Service c0f7c7
		    AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
Packit Service c0f7c7
		    if test $ac_cv_lbl_cc_const_proto = no ; then
Packit Service c0f7c7
			    AC_DEFINE(const,[],
Packit Service c0f7c7
			        [to handle Ultrix compilers that don't support const in prototypes])
Packit Service c0f7c7
		    fi
Packit Service c0f7c7
		    ;;
Packit Service c0f7c7
	    esac
Packit Service c0f7c7
	    $1="$$1 -O"
Packit Service c0f7c7
    fi
Packit Service c0f7c7
])
Packit Service c0f7c7
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl Check whether, if you pass an unknown warning option to the
Packit Service c0f7c7
dnl compiler, it fails or just prints a warning message and succeeds.
Packit Service c0f7c7
dnl Set ac_lbl_unknown_warning_option_error to the appropriate flag
Packit Service c0f7c7
dnl to force an error if it would otherwise just print a warning message
Packit Service c0f7c7
dnl and succeed.
Packit Service c0f7c7
dnl
Packit Service c0f7c7
AC_DEFUN(AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR,
Packit Service c0f7c7
    [
Packit Service c0f7c7
	AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option])
Packit Service c0f7c7
	save_CFLAGS="$CFLAGS"
Packit Service c0f7c7
	CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
Packit Service c0f7c7
	AC_TRY_COMPILE(
Packit Service c0f7c7
	    [],
Packit Service c0f7c7
	    [return 0],
Packit Service c0f7c7
	    [
Packit Service c0f7c7
		AC_MSG_RESULT([no])
Packit Service c0f7c7
		#
Packit Service c0f7c7
		# We're assuming this is clang, where
Packit Service c0f7c7
		# -Werror=unknown-warning-option is the appropriate
Packit Service c0f7c7
		# option to force the compiler to fail.
Packit Service c0f7c7
		#
Packit Service c0f7c7
		ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
Packit Service c0f7c7
	    ],
Packit Service c0f7c7
	    [
Packit Service c0f7c7
		AC_MSG_RESULT([yes])
Packit Service c0f7c7
	    ])
Packit Service c0f7c7
	CFLAGS="$save_CFLAGS"
Packit Service c0f7c7
    ])
Packit Service c0f7c7
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl Check whether the compiler option specified as the second argument
Packit Service c0f7c7
dnl is supported by the compiler and, if so, add it to the macro
Packit Service c0f7c7
dnl specified as the first argument
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl If a third argument is supplied, treat it as C code to be compiled
Packit Service c0f7c7
dnl with the flag in question, and the "treat warnings as errors" flag
Packit Service c0f7c7
dnl set, and don't add the flag to the first argument if the compile
Packit Service c0f7c7
dnl fails; this is for warning options cause problems that can't be
Packit Service c0f7c7
dnl worked around.  If a third argument is supplied, a fourth argument
Packit Service c0f7c7
dnl should also be supplied; it's a message desribing what the test
Packit Service c0f7c7
dnl program is checking.
Packit Service c0f7c7
dnl
Packit Service c0f7c7
AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
Packit Service c0f7c7
    [
Packit Service c0f7c7
	AC_MSG_CHECKING([whether the compiler supports the $2 option])
Packit Service c0f7c7
	save_CFLAGS="$CFLAGS"
Packit Service c0f7c7
	if expr "x$2" : "x-W.*" >/dev/null
Packit Service c0f7c7
	then
Packit Service c0f7c7
	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2"
Packit Service c0f7c7
	elif expr "x$2" : "x-f.*" >/dev/null
Packit Service c0f7c7
	then
Packit Service c0f7c7
	    CFLAGS="$CFLAGS -Werror $2"
Packit Service c0f7c7
	elif expr "x$2" : "x-m.*" >/dev/null
Packit Service c0f7c7
	then
Packit Service c0f7c7
	    CFLAGS="$CFLAGS -Werror $2"
Packit Service c0f7c7
	else
Packit Service c0f7c7
	    CFLAGS="$CFLAGS $2"
Packit Service c0f7c7
	fi
Packit Service c0f7c7
	AC_TRY_COMPILE(
Packit Service c0f7c7
	    [],
Packit Service c0f7c7
	    [return 0],
Packit Service c0f7c7
	    [
Packit Service c0f7c7
		AC_MSG_RESULT([yes])
Packit Service c0f7c7
		can_add_to_cflags=yes
Packit Service c0f7c7
		#
Packit Service c0f7c7
		# The compile supports this; do we have some C code for
Packit Service c0f7c7
		# which the warning should *not* appear?
Packit Service c0f7c7
		# We test the fourth argument because the third argument
Packit Service c0f7c7
		# could contain quotes, breaking the test.
Packit Service c0f7c7
		#
Packit Service c0f7c7
		if test "x$4" != "x"
Packit Service c0f7c7
		then
Packit Service c0f7c7
		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
Packit Service c0f7c7
		    AC_MSG_CHECKING(whether $2 $4)
Packit Service c0f7c7
		    AC_COMPILE_IFELSE(
Packit Service c0f7c7
		      [AC_LANG_SOURCE($3)],
Packit Service c0f7c7
		      [
Packit Service c0f7c7
			#
Packit Service c0f7c7
			# Not a problem.
Packit Service c0f7c7
			#
Packit Service c0f7c7
			AC_MSG_RESULT(no)
Packit Service c0f7c7
		      ],
Packit Service c0f7c7
		      [
Packit Service c0f7c7
			#
Packit Service c0f7c7
			# A problem.
Packit Service c0f7c7
			#
Packit Service c0f7c7
			AC_MSG_RESULT(yes)
Packit Service c0f7c7
			can_add_to_cflags=no
Packit Service c0f7c7
		      ])
Packit Service c0f7c7
		fi
Packit Service c0f7c7
		CFLAGS="$save_CFLAGS"
Packit Service c0f7c7
		if test x"$can_add_to_cflags" = "xyes"
Packit Service c0f7c7
		then
Packit Service c0f7c7
		    $1="$$1 $2"
Packit Service c0f7c7
		fi
Packit Service c0f7c7
	    ],
Packit Service c0f7c7
	    [
Packit Service c0f7c7
		AC_MSG_RESULT([no])
Packit Service c0f7c7
		CFLAGS="$save_CFLAGS"
Packit Service c0f7c7
	    ])
Packit Service c0f7c7
    ])
Packit Service c0f7c7
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl Check whether the compiler supports an option to generate
Packit Service c0f7c7
dnl Makefile-style dependency lines
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl GCC uses -M for this.  Non-GCC compilers that support this
Packit Service c0f7c7
dnl use a variety of flags, including but not limited to -M.
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl We test whether the flag in question is supported, as older
Packit Service c0f7c7
dnl versions of compilers might not support it.
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl We don't try all the possible flags, just in case some flag means
Packit Service c0f7c7
dnl "generate dependencies" on one compiler but means something else
Packit Service c0f7c7
dnl on another compiler.
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl Most compilers that support this send the output to the standard
Packit Service c0f7c7
dnl output by default.  IBM's XLC, however, supports -M but sends
Packit Service c0f7c7
dnl the output to {sourcefile-basename}.u, and AIX has no /dev/stdout
Packit Service c0f7c7
dnl to work around that, so we don't bother with XLC.
Packit Service c0f7c7
dnl
Packit Service c0f7c7
AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT,
Packit Service c0f7c7
    [
Packit Service c0f7c7
	AC_MSG_CHECKING([whether the compiler supports generating dependencies])
Packit Service c0f7c7
	if test "$GCC" = yes ; then
Packit Service c0f7c7
		#
Packit Service c0f7c7
		# GCC, or a compiler deemed to be GCC by AC_PROG_CC (even
Packit Service c0f7c7
		# though it's not); we assume that, in this case, the flag
Packit Service c0f7c7
		# would be -M.
Packit Service c0f7c7
		#
Packit Service c0f7c7
		ac_lbl_dependency_flag="-M"
Packit Service c0f7c7
	else
Packit Service c0f7c7
		#
Packit Service c0f7c7
		# Not GCC or a compiler deemed to be GCC; what platform is
Packit Service c0f7c7
		# this?  (We're assuming that if the compiler isn't GCC
Packit Service c0f7c7
		# it's the compiler from the vendor of the OS; that won't
Packit Service c0f7c7
		# necessarily be true for x86 platforms, where it might be
Packit Service c0f7c7
		# the Intel C compiler.)
Packit Service c0f7c7
		#
Packit Service c0f7c7
		case "$host_os" in
Packit Service c0f7c7
Packit Service c0f7c7
		irix*|osf*|darwin*)
Packit Service c0f7c7
			#
Packit Service c0f7c7
			# MIPS C for IRIX, DEC C, and clang all use -M.
Packit Service c0f7c7
			#
Packit Service c0f7c7
			ac_lbl_dependency_flag="-M"
Packit Service c0f7c7
			;;
Packit Service c0f7c7
Packit Service c0f7c7
		solaris*)
Packit Service c0f7c7
			#
Packit Service c0f7c7
			# Sun C uses -xM.
Packit Service c0f7c7
			#
Packit Service c0f7c7
			ac_lbl_dependency_flag="-xM"
Packit Service c0f7c7
			;;
Packit Service c0f7c7
Packit Service c0f7c7
		hpux*)
Packit Service c0f7c7
			#
Packit Service c0f7c7
			# HP's older C compilers don't support this.
Packit Service c0f7c7
			# HP's newer C compilers support this with
Packit Service c0f7c7
			# either +M or +Make; the older compilers
Packit Service c0f7c7
			# interpret +M as something completely
Packit Service c0f7c7
			# different, so we use +Make so we don't
Packit Service c0f7c7
			# think it works with the older compilers.
Packit Service c0f7c7
			#
Packit Service c0f7c7
			ac_lbl_dependency_flag="+Make"
Packit Service c0f7c7
			;;
Packit Service c0f7c7
Packit Service c0f7c7
		*)
Packit Service c0f7c7
			#
Packit Service c0f7c7
			# Not one of the above; assume no support for
Packit Service c0f7c7
			# generating dependencies.
Packit Service c0f7c7
			#
Packit Service c0f7c7
			ac_lbl_dependency_flag=""
Packit Service c0f7c7
			;;
Packit Service c0f7c7
		esac
Packit Service c0f7c7
	fi
Packit Service c0f7c7
Packit Service c0f7c7
	#
Packit Service c0f7c7
	# Is ac_lbl_dependency_flag defined and, if so, does the compiler
Packit Service c0f7c7
	# complain about it?
Packit Service c0f7c7
	#
Packit Service c0f7c7
	# Note: clang doesn't seem to exit with an error status when handed
Packit Service c0f7c7
	# an unknown non-warning error, even if you pass it
Packit Service c0f7c7
	# -Werror=unknown-warning-option.  However, it always supports
Packit Service c0f7c7
	# -M, so the fact that this test always succeeds with clang
Packit Service c0f7c7
	# isn't an issue.
Packit Service c0f7c7
	#
Packit Service c0f7c7
	if test ! -z "$ac_lbl_dependency_flag"; then
Packit Service c0f7c7
		AC_LANG_CONFTEST(
Packit Service c0f7c7
		    [AC_LANG_SOURCE([[int main(void) { return 0; }]])])
Packit Service c0f7c7
		if AC_RUN_LOG([eval "$CC $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1"]); then
Packit Service c0f7c7
			AC_MSG_RESULT([yes, with $ac_lbl_dependency_flag])
Packit Service c0f7c7
			DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
Packit Service c0f7c7
			MKDEP='${srcdir}/mkdep'
Packit Service c0f7c7
		else
Packit Service c0f7c7
			AC_MSG_RESULT([no])
Packit Service c0f7c7
			#
Packit Service c0f7c7
			# We can't run mkdep, so have "make depend" do
Packit Service c0f7c7
			# nothing.
Packit Service c0f7c7
			#
Packit Service c0f7c7
			MKDEP='${srcdir}/nomkdep'
Packit Service c0f7c7
		fi
Packit Service c0f7c7
		rm -rf conftest*
Packit Service c0f7c7
	else
Packit Service c0f7c7
		AC_MSG_RESULT([no])
Packit Service c0f7c7
		#
Packit Service c0f7c7
		# We can't run mkdep, so have "make depend" do
Packit Service c0f7c7
		# nothing.
Packit Service c0f7c7
		#
Packit Service c0f7c7
		MKDEP='${srcdir}/nomkdep'
Packit Service c0f7c7
	fi
Packit Service c0f7c7
	AC_SUBST(DEPENDENCY_CFLAG)
Packit Service c0f7c7
	AC_SUBST(MKDEP)
Packit Service c0f7c7
    ])
Packit Service c0f7c7
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl Determine what options are needed to build a shared library
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl usage:
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl	AC_LBL_SHLIBS_INIT
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl results:
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl	V_SHLIB_CCOPT (modified to build position-independent code)
Packit Service c0f7c7
dnl	V_SHLIB_CMD
Packit Service c0f7c7
dnl	V_SHLIB_OPT
Packit Service c0f7c7
dnl	V_SONAME_OPT
Packit Service c0f7c7
dnl	V_RPATH_OPT
Packit Service c0f7c7
dnl
Packit Service c0f7c7
AC_DEFUN(AC_LBL_SHLIBS_INIT,
Packit Service c0f7c7
    [AC_PREREQ(2.50)
Packit Service c0f7c7
    if test "$GCC" = yes ; then
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    # On platforms where we build a shared library:
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    #	add options to generate position-independent code,
Packit Service c0f7c7
	    #	if necessary (it's the default in AIX and Darwin/macOS);
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    #	define option to set the soname of the shared library,
Packit Service c0f7c7
	    #	if the OS supports that;
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    #	add options to specify, at link time, a directory to
Packit Service c0f7c7
	    #	add to the run-time search path, if that's necessary.
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    V_SHLIB_CMD="\$(CC)"
Packit Service c0f7c7
	    V_SHLIB_OPT="-shared"
Packit Service c0f7c7
	    case "$host_os" in
Packit Service c0f7c7
Packit Service c0f7c7
	    aix*)
Packit Service c0f7c7
		    ;;
Packit Service c0f7c7
Packit Service c0f7c7
	    freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*|midipix*)
Packit Service c0f7c7
	    	    #
Packit Service c0f7c7
		    # Platforms where the linker is the GNU linker
Packit Service c0f7c7
		    # or accepts command-line arguments like
Packit Service c0f7c7
		    # those the GNU linker accepts.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # Some instruction sets require -fPIC on some
Packit Service c0f7c7
		    # operating systems.  Check for them.  If you
Packit Service c0f7c7
		    # have a combination that requires it, add it
Packit Service c0f7c7
		    # here.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    PIC_OPT=-fpic
Packit Service c0f7c7
		    case "$host_cpu" in
Packit Service c0f7c7
Packit Service c0f7c7
		    sparc64*)
Packit Service c0f7c7
			case "$host_os" in
Packit Service c0f7c7
Packit Service c0f7c7
			freebsd*|openbsd*|linux*)
Packit Service c0f7c7
			    PIC_OPT=-fPIC
Packit Service c0f7c7
			    ;;
Packit Service c0f7c7
			esac
Packit Service c0f7c7
			;;
Packit Service c0f7c7
		    esac
Packit Service c0f7c7
		    V_SHLIB_CCOPT="$V_SHLIB_CCOPT $PIC_OPT"
Packit Service c0f7c7
		    V_SONAME_OPT="-Wl,-soname,"
Packit Service c0f7c7
		    V_RPATH_OPT="-Wl,-rpath,"
Packit Service c0f7c7
		    ;;
Packit Service c0f7c7
Packit Service c0f7c7
	    hpux*)
Packit Service c0f7c7
		    V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
Packit Service c0f7c7
	    	    #
Packit Service c0f7c7
		    # XXX - this assumes GCC is using the HP linker,
Packit Service c0f7c7
		    # rather than the GNU linker, and that the "+h"
Packit Service c0f7c7
		    # option is used on all HP-UX platforms, both .sl
Packit Service c0f7c7
		    # and .so.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    V_SONAME_OPT="-Wl,+h,"
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # By default, directories specifed with -L
Packit Service c0f7c7
		    # are added to the run-time search path, so
Packit Service c0f7c7
		    # we don't add them in pcap-config.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    ;;
Packit Service c0f7c7
Packit Service c0f7c7
	    solaris*)
Packit Service c0f7c7
		    V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # XXX - this assumes GCC is using the Sun linker,
Packit Service c0f7c7
		    # rather than the GNU linker.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    V_SONAME_OPT="-Wl,-h,"
Packit Service c0f7c7
		    V_RPATH_OPT="-Wl,-R,"
Packit Service c0f7c7
		    ;;
Packit Service c0f7c7
	    esac
Packit Service c0f7c7
    else
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    # Set the appropriate compiler flags and, on platforms
Packit Service c0f7c7
	    # where we build a shared library:
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    #	add options to generate position-independent code,
Packit Service c0f7c7
	    #	if necessary (it's the default in Darwin/macOS);
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    #	if we generate ".so" shared libraries, define the
Packit Service c0f7c7
	    #	appropriate options for building the shared library;
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    #	add options to specify, at link time, a directory to
Packit Service c0f7c7
	    #	add to the run-time search path, if that's necessary.
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    # Note: spaces after V_SONAME_OPT are significant; on
Packit Service c0f7c7
	    # some platforms the soname is passed with a GCC-like
Packit Service c0f7c7
	    # "-Wl,-soname,{soname}" option, with the soname part
Packit Service c0f7c7
	    # of the option, while on other platforms the C compiler
Packit Service c0f7c7
	    # driver takes it as a regular option with the soname
Packit Service c0f7c7
	    # following the option.  The same applies to V_RPATH_OPT.
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    case "$host_os" in
Packit Service c0f7c7
Packit Service c0f7c7
	    aix*)
Packit Service c0f7c7
		    V_SHLIB_CMD="\$(CC)"
Packit Service c0f7c7
		    V_SHLIB_OPT="-G -bnoentry -bexpall"
Packit Service c0f7c7
		    ;;
Packit Service c0f7c7
Packit Service c0f7c7
	    freebsd*|netbsd*|openbsd*|dragonfly*|linux*)
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # "cc" is GCC.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
Packit Service c0f7c7
		    V_SHLIB_CMD="\$(CC)"
Packit Service c0f7c7
		    V_SHLIB_OPT="-shared"
Packit Service c0f7c7
		    V_SONAME_OPT="-Wl,-soname,"
Packit Service c0f7c7
		    V_RPATH_OPT="-Wl,-rpath,"
Packit Service c0f7c7
		    ;;
Packit Service c0f7c7
Packit Service c0f7c7
	    hpux*)
Packit Service c0f7c7
		    V_SHLIB_CCOPT="$V_SHLIB_CCOPT +z"
Packit Service c0f7c7
		    V_SHLIB_CMD="\$(LD)"
Packit Service c0f7c7
		    V_SHLIB_OPT="-b"
Packit Service c0f7c7
		    V_SONAME_OPT="+h "
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # By default, directories specifed with -L
Packit Service c0f7c7
		    # are added to the run-time search path, so
Packit Service c0f7c7
		    # we don't add them in pcap-config.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    ;;
Packit Service c0f7c7
Packit Service c0f7c7
	    osf*)
Packit Service c0f7c7
	    	    #
Packit Service c0f7c7
		    # Presumed to be DEC OSF/1, Digital UNIX, or
Packit Service c0f7c7
		    # Tru64 UNIX.
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    V_SHLIB_CMD="\$(CC)"
Packit Service c0f7c7
		    V_SHLIB_OPT="-shared"
Packit Service c0f7c7
		    V_SONAME_OPT="-soname "
Packit Service c0f7c7
		    V_RPATH_OPT="-rpath "
Packit Service c0f7c7
		    ;;
Packit Service c0f7c7
Packit Service c0f7c7
	    solaris*)
Packit Service c0f7c7
		    V_SHLIB_CCOPT="$V_SHLIB_CCOPT -Kpic"
Packit Service c0f7c7
		    V_SHLIB_CMD="\$(CC)"
Packit Service c0f7c7
		    V_SHLIB_OPT="-G"
Packit Service c0f7c7
		    V_SONAME_OPT="-h "
Packit Service c0f7c7
		    V_RPATH_OPT="-R"
Packit Service c0f7c7
		    ;;
Packit Service c0f7c7
	    esac
Packit Service c0f7c7
    fi
Packit Service c0f7c7
])
Packit Service c0f7c7
Packit Service c0f7c7
#
Packit Service c0f7c7
# Try compiling a sample of the type of code that appears in
Packit Service c0f7c7
# gencode.c with "inline", "__inline__", and "__inline".
Packit Service c0f7c7
#
Packit Service c0f7c7
# Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough,
Packit Service c0f7c7
# as it just tests whether a function returning "int" can be inlined;
Packit Service c0f7c7
# at least some versions of HP's C compiler can inline that, but can't
Packit Service c0f7c7
# inline a function that returns a struct pointer.
Packit Service c0f7c7
#
Packit Service c0f7c7
# Make sure we use the V_CCOPT flags, because some of those might
Packit Service c0f7c7
# disable inlining.
Packit Service c0f7c7
#
Packit Service c0f7c7
AC_DEFUN(AC_LBL_C_INLINE,
Packit Service c0f7c7
    [AC_MSG_CHECKING(for inline)
Packit Service c0f7c7
    save_CFLAGS="$CFLAGS"
Packit Service c0f7c7
    CFLAGS="$V_CCOPT"
Packit Service c0f7c7
    AC_CACHE_VAL(ac_cv_lbl_inline, [
Packit Service c0f7c7
	ac_cv_lbl_inline=""
Packit Service c0f7c7
	ac_lbl_cc_inline=no
Packit Service c0f7c7
	for ac_lbl_inline in inline __inline__ __inline
Packit Service c0f7c7
	do
Packit Service c0f7c7
	    AC_TRY_COMPILE(
Packit Service c0f7c7
		[#define inline $ac_lbl_inline
Packit Service c0f7c7
		static inline struct iltest *foo(void);
Packit Service c0f7c7
		struct iltest {
Packit Service c0f7c7
		    int iltest1;
Packit Service c0f7c7
		    int iltest2;
Packit Service c0f7c7
		};
Packit Service c0f7c7
Packit Service c0f7c7
		static inline struct iltest *
Packit Service c0f7c7
		foo()
Packit Service c0f7c7
		{
Packit Service c0f7c7
		    static struct iltest xxx;
Packit Service c0f7c7
Packit Service c0f7c7
		    return &xx;;
Packit Service c0f7c7
		}],,ac_lbl_cc_inline=yes,)
Packit Service c0f7c7
	    if test "$ac_lbl_cc_inline" = yes ; then
Packit Service c0f7c7
		break;
Packit Service c0f7c7
	    fi
Packit Service c0f7c7
	done
Packit Service c0f7c7
	if test "$ac_lbl_cc_inline" = yes ; then
Packit Service c0f7c7
	    ac_cv_lbl_inline=$ac_lbl_inline
Packit Service c0f7c7
	fi])
Packit Service c0f7c7
    CFLAGS="$save_CFLAGS"
Packit Service c0f7c7
    if test ! -z "$ac_cv_lbl_inline" ; then
Packit Service c0f7c7
	AC_MSG_RESULT($ac_cv_lbl_inline)
Packit Service c0f7c7
    else
Packit Service c0f7c7
	AC_MSG_RESULT(no)
Packit Service c0f7c7
    fi
Packit Service c0f7c7
    AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
Packit Service c0f7c7
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl If using gcc, make sure we have ANSI ioctl definitions
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl usage:
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl	AC_LBL_FIXINCLUDES
Packit Service c0f7c7
dnl
Packit Service c0f7c7
AC_DEFUN(AC_LBL_FIXINCLUDES,
Packit Service c0f7c7
    [if test "$GCC" = yes ; then
Packit Service c0f7c7
	    AC_MSG_CHECKING(for ANSI ioctl definitions)
Packit Service c0f7c7
	    AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes,
Packit Service c0f7c7
		AC_TRY_COMPILE(
Packit Service c0f7c7
		    [/*
Packit Service c0f7c7
		     * This generates a "duplicate case value" when fixincludes
Packit Service c0f7c7
		     * has not be run.
Packit Service c0f7c7
		     */
Packit Service c0f7c7
#		include <sys/types.h>
Packit Service c0f7c7
#		include <sys/time.h>
Packit Service c0f7c7
#		include <sys/ioctl.h>
Packit Service c0f7c7
#		ifdef HAVE_SYS_IOCCOM_H
Packit Service c0f7c7
#		include <sys/ioccom.h>
Packit Service c0f7c7
#		endif],
Packit Service c0f7c7
		    [switch (0) {
Packit Service c0f7c7
		    case _IO('A', 1):;
Packit Service c0f7c7
		    case _IO('B', 1):;
Packit Service c0f7c7
		    }],
Packit Service c0f7c7
		    ac_cv_lbl_gcc_fixincludes=yes,
Packit Service c0f7c7
		    ac_cv_lbl_gcc_fixincludes=no))
Packit Service c0f7c7
	    AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes)
Packit Service c0f7c7
	    if test $ac_cv_lbl_gcc_fixincludes = no ; then
Packit Service c0f7c7
		    # Don't cache failure
Packit Service c0f7c7
		    unset ac_cv_lbl_gcc_fixincludes
Packit Service c0f7c7
		    AC_MSG_ERROR(see the INSTALL for more info)
Packit Service c0f7c7
	    fi
Packit Service c0f7c7
    fi])
Packit Service c0f7c7
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl Checks to see if union wait is used with WEXITSTATUS()
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl usage:
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl	AC_LBL_UNION_WAIT
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl results:
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl	DECLWAITSTATUS (defined)
Packit Service c0f7c7
dnl
Packit Service c0f7c7
AC_DEFUN(AC_LBL_UNION_WAIT,
Packit Service c0f7c7
    [AC_MSG_CHECKING(if union wait is used)
Packit Service c0f7c7
    AC_CACHE_VAL(ac_cv_lbl_union_wait,
Packit Service c0f7c7
	AC_TRY_COMPILE([
Packit Service c0f7c7
#	include <sys/types.h>
Packit Service c0f7c7
#	include <sys/wait.h>],
Packit Service c0f7c7
	    [int status;
Packit Service c0f7c7
	    u_int i = WEXITSTATUS(status);
Packit Service c0f7c7
	    u_int j = waitpid(0, &status, 0);],
Packit Service c0f7c7
	    ac_cv_lbl_union_wait=no,
Packit Service c0f7c7
	    ac_cv_lbl_union_wait=yes))
Packit Service c0f7c7
    AC_MSG_RESULT($ac_cv_lbl_union_wait)
Packit Service c0f7c7
    if test $ac_cv_lbl_union_wait = yes ; then
Packit Service c0f7c7
	    AC_DEFINE(DECLWAITSTATUS,union wait,[type for wait])
Packit Service c0f7c7
    else
Packit Service c0f7c7
	    AC_DEFINE(DECLWAITSTATUS,int,[type for wait])
Packit Service c0f7c7
    fi])
Packit Service c0f7c7
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl Checks to see if -R is used
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl usage:
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl	AC_LBL_HAVE_RUN_PATH
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl results:
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl	ac_cv_lbl_have_run_path (yes or no)
Packit Service c0f7c7
dnl
Packit Service c0f7c7
AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
Packit Service c0f7c7
    [AC_MSG_CHECKING(for ${CC-cc} -R)
Packit Service c0f7c7
    AC_CACHE_VAL(ac_cv_lbl_have_run_path,
Packit Service c0f7c7
	[echo 'main(){}' > conftest.c
Packit Service c0f7c7
	${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
Packit Service c0f7c7
	if test ! -s conftest.out ; then
Packit Service c0f7c7
		ac_cv_lbl_have_run_path=yes
Packit Service c0f7c7
	else
Packit Service c0f7c7
		ac_cv_lbl_have_run_path=no
Packit Service c0f7c7
	fi
Packit Service c0f7c7
	rm -f -r conftest*])
Packit Service c0f7c7
    AC_MSG_RESULT($ac_cv_lbl_have_run_path)
Packit Service c0f7c7
    ])
Packit Service c0f7c7
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl Checks to see if unaligned memory accesses fail
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl usage:
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl	AC_LBL_UNALIGNED_ACCESS
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl results:
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl	LBL_ALIGN (DEFINED)
Packit Service c0f7c7
dnl
Packit Service c0f7c7
AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
Packit Service c0f7c7
    [AC_MSG_CHECKING(if unaligned accesses fail)
Packit Service c0f7c7
    AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
Packit Service c0f7c7
	[case "$host_cpu" in
Packit Service c0f7c7
Packit Service c0f7c7
	#
Packit Service c0f7c7
	# These are CPU types where:
Packit Service c0f7c7
	#
Packit Service c0f7c7
	#	the CPU faults on an unaligned access, but at least some
Packit Service c0f7c7
	#	OSes that support that CPU catch the fault and simulate
Packit Service c0f7c7
	#	the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) -
Packit Service c0f7c7
	#	the simulation is slow, so we don't want to use it;
Packit Service c0f7c7
	#
Packit Service c0f7c7
	#	the CPU, I infer (from the old
Packit Service c0f7c7
	#
Packit Service c0f7c7
	# XXX: should also check that they don't do weird things (like on arm)
Packit Service c0f7c7
	#
Packit Service c0f7c7
	#	comment) doesn't fault on unaligned accesses, but doesn't
Packit Service c0f7c7
	#	do a normal unaligned fetch, either (e.g., presumably, ARM);
Packit Service c0f7c7
	#
Packit Service c0f7c7
	#	for whatever reason, the test program doesn't work
Packit Service c0f7c7
	#	(this has been claimed to be the case for several of those
Packit Service c0f7c7
	#	CPUs - I don't know what the problem is; the problem
Packit Service c0f7c7
	#	was reported as "the test program dumps core" for SuperH,
Packit Service c0f7c7
	#	but that's what the test program is *supposed* to do -
Packit Service c0f7c7
	#	it dumps core before it writes anything, so the test
Packit Service c0f7c7
	#	for an empty output file should find an empty output
Packit Service c0f7c7
	#	file and conclude that unaligned accesses don't work).
Packit Service c0f7c7
	#
Packit Service c0f7c7
	# This run-time test won't work if you're cross-compiling, so
Packit Service c0f7c7
	# in order to support cross-compiling for a particular CPU,
Packit Service c0f7c7
	# we have to wire in the list of CPU types anyway, as far as
Packit Service c0f7c7
	# I know, so perhaps we should just have a set of CPUs on
Packit Service c0f7c7
	# which we know it doesn't work, a set of CPUs on which we
Packit Service c0f7c7
	# know it does work, and have the script just fail on other
Packit Service c0f7c7
	# cpu types and update it when such a failure occurs.
Packit Service c0f7c7
	#
Packit Service c0f7c7
	alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1)
Packit Service c0f7c7
		ac_cv_lbl_unaligned_fail=yes
Packit Service c0f7c7
		;;
Packit Service c0f7c7
Packit Service c0f7c7
	*)
Packit Service c0f7c7
		cat >conftest.c <
Packit Service c0f7c7
#		include <sys/types.h>
Packit Service c0f7c7
#		include <sys/wait.h>
Packit Service c0f7c7
#		include <stdio.h>
Packit Service c0f7c7
		unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
Packit Service c0f7c7
		main() {
Packit Service c0f7c7
		unsigned int i;
Packit Service c0f7c7
		pid_t pid;
Packit Service c0f7c7
		int status;
Packit Service c0f7c7
		/* avoid "core dumped" message */
Packit Service c0f7c7
		pid = fork();
Packit Service c0f7c7
		if (pid <  0)
Packit Service c0f7c7
			exit(2);
Packit Service c0f7c7
		if (pid > 0) {
Packit Service c0f7c7
			/* parent */
Packit Service c0f7c7
			pid = waitpid(pid, &status, 0);
Packit Service c0f7c7
			if (pid < 0)
Packit Service c0f7c7
				exit(3);
Packit Service c0f7c7
			exit(!WIFEXITED(status));
Packit Service c0f7c7
		}
Packit Service c0f7c7
		/* child */
Packit Service c0f7c7
		i = *(unsigned int *)&a[[1]];
Packit Service c0f7c7
		printf("%d\n", i);
Packit Service c0f7c7
		exit(0);
Packit Service c0f7c7
		}
Packit Service c0f7c7
EOF
Packit Service c0f7c7
		${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
Packit Service c0f7c7
		    conftest.c $LIBS >/dev/null 2>&1
Packit Service c0f7c7
		if test ! -x conftest ; then
Packit Service c0f7c7
			dnl failed to compile for some reason
Packit Service c0f7c7
			ac_cv_lbl_unaligned_fail=yes
Packit Service c0f7c7
		else
Packit Service c0f7c7
			./conftest >conftest.out
Packit Service c0f7c7
			if test ! -s conftest.out ; then
Packit Service c0f7c7
				ac_cv_lbl_unaligned_fail=yes
Packit Service c0f7c7
			else
Packit Service c0f7c7
				ac_cv_lbl_unaligned_fail=no
Packit Service c0f7c7
			fi
Packit Service c0f7c7
		fi
Packit Service c0f7c7
		rm -f -r conftest* core core.conftest
Packit Service c0f7c7
		;;
Packit Service c0f7c7
	esac])
Packit Service c0f7c7
    AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
Packit Service c0f7c7
    if test $ac_cv_lbl_unaligned_fail = yes ; then
Packit Service c0f7c7
	    AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails])
Packit Service c0f7c7
    fi])
Packit Service c0f7c7
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl If the file .devel exists:
Packit Service c0f7c7
dnl	Add some warning flags if the compiler supports them
Packit Service c0f7c7
dnl	If an os prototype include exists, symlink os-proto.h to it
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl usage:
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl	AC_LBL_DEVEL(copt)
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl results:
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl	$1 (copt appended)
Packit Service c0f7c7
dnl	HAVE_OS_PROTO_H (defined)
Packit Service c0f7c7
dnl	os-proto.h (symlinked)
Packit Service c0f7c7
dnl
Packit Service c0f7c7
AC_DEFUN(AC_LBL_DEVEL,
Packit Service c0f7c7
    [rm -f os-proto.h
Packit Service c0f7c7
    if test "${LBL_CFLAGS+set}" = set; then
Packit Service c0f7c7
	    $1="$$1 ${LBL_CFLAGS}"
Packit Service c0f7c7
    fi
Packit Service c0f7c7
    if test -f .devel ; then
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    # Skip all the warning option stuff on some compilers.
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
Packit Service c0f7c7
		    AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR()
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -W)
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -Wcomma)
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -Wdeclaration-after-statement)
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -Wdocumentation)
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -Wformat-nonliteral)
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-noreturn)
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-variable-declarations)
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -Wshadow)
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -Wsign-compare)
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -Wunused-parameter)
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -Wused-but-marked-unused)
Packit Service c0f7c7
		    # Warns about safeguards added in case the enums are
Packit Service c0f7c7
		    # extended
Packit Service c0f7c7
		    # AC_LBL_CHECK_COMPILER_OPT($1, -Wcovered-switch-default)
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # This can cause problems with ntohs(), ntohl(),
Packit Service c0f7c7
		    # htons(), and htonl() on some platforms, such
Packit Service c0f7c7
		    # as OpenBSD 6.3 with Clang 5.0.1.  I guess the
Packit Service c0f7c7
		    # problem is that the macro that ultimately does
Packit Service c0f7c7
		    # the byte-swapping involves a conditional
Packit Service c0f7c7
		    # expression that tests whether the value being
Packit Service c0f7c7
		    # swapped is a compile-time constant or not,
Packit Service c0f7c7
		    # using __builtin_constant_p(), and, depending
Packit Service c0f7c7
		    # on whether it is, does a compile-time swap or
Packit Service c0f7c7
		    # a run-time swap; perhaps the compiler always
Packit Service c0f7c7
		    # considers one of the two results of the
Packit Service c0f7c7
		    # conditional expressin is never evaluated,
Packit Service c0f7c7
		    # because the conditional check is done at
Packit Service c0f7c7
		    # compile time, and thus always says "that
Packit Service c0f7c7
		    # expression is never executed".
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    # (Perhaps there should be a way of flagging
Packit Service c0f7c7
		    # an expression that you *want* evaluated at
Packit Service c0f7c7
		    # compile time, so that the compiler 1) warns
Packit Service c0f7c7
		    # if it *can't* be evaluated at compile time
Packit Service c0f7c7
		    # and 2) *doesn't* warn that the true or false
Packit Service c0f7c7
		    # branch will never be reached.)
Packit Service c0f7c7
		    #
Packit Service c0f7c7
		    AC_LBL_CHECK_COMPILER_OPT($1, -Wunreachable-code,
Packit Service c0f7c7
		      [
Packit Service c0f7c7
#include <arpa/inet.h>
Packit Service c0f7c7
Packit Service c0f7c7
unsigned short
Packit Service c0f7c7
testme(unsigned short a)
Packit Service c0f7c7
{
Packit Service c0f7c7
	return ntohs(a);
Packit Service c0f7c7
}
Packit Service c0f7c7
		      ],
Packit Service c0f7c7
		      [generates warnings from ntohs()])
Packit Service c0f7c7
	    fi
Packit Service c0f7c7
	    AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    # We used to set -n32 for IRIX 6 when not using GCC (presumed
Packit Service c0f7c7
	    # to mean that we're using MIPS C or MIPSpro C); it specified
Packit Service c0f7c7
	    # the "new" faster 32-bit ABI, introduced in IRIX 6.2.  I'm
Packit Service c0f7c7
	    # not sure why that would be something to do *only* with a
Packit Service c0f7c7
	    # .devel file; why should the ABI for which we produce code
Packit Service c0f7c7
	    # depend on .devel?
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
Packit Service c0f7c7
	    name="lbl/os-$os.h"
Packit Service c0f7c7
	    if test -f $name ; then
Packit Service c0f7c7
		    ln -s $name os-proto.h
Packit Service c0f7c7
		    AC_DEFINE(HAVE_OS_PROTO_H, 1,
Packit Service c0f7c7
			[if there's an os_proto.h for this platform, to use additional prototypes])
Packit Service c0f7c7
	    else
Packit Service c0f7c7
		    AC_MSG_WARN(can't find $name)
Packit Service c0f7c7
	    fi
Packit Service c0f7c7
    fi])
Packit Service c0f7c7
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl Improved version of AC_CHECK_LIB
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl Thanks to John Hawkinson (jhawk@mit.edu)
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl usage:
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl	AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
Packit Service c0f7c7
dnl	    ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl results:
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl	LIBS
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl XXX - "AC_LBL_LIBRARY_NET" was redone to use "AC_SEARCH_LIBS"
Packit Service c0f7c7
dnl rather than "AC_LBL_CHECK_LIB", so this isn't used any more.
Packit Service c0f7c7
dnl We keep it around for reference purposes in case it's ever
Packit Service c0f7c7
dnl useful in the future.
Packit Service c0f7c7
dnl
Packit Service c0f7c7
Packit Service c0f7c7
define(AC_LBL_CHECK_LIB,
Packit Service c0f7c7
[AC_MSG_CHECKING([for $2 in -l$1])
Packit Service c0f7c7
dnl Use a cache variable name containing the library, function
Packit Service c0f7c7
dnl name, and extra libraries to link with, because the test really is
Packit Service c0f7c7
dnl for library $1 defining function $2, when linked with potinal
Packit Service c0f7c7
dnl library $5, not just for library $1.  Separate tests with the same
Packit Service c0f7c7
dnl $1 and different $2's or $5's may have different results.
Packit Service c0f7c7
ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
Packit Service c0f7c7
AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
Packit Service c0f7c7
[ac_save_LIBS="$LIBS"
Packit Service c0f7c7
LIBS="-l$1 $5 $LIBS"
Packit Service c0f7c7
AC_TRY_LINK(dnl
Packit Service c0f7c7
ifelse([$2], [main], , dnl Avoid conflicting decl of main.
Packit Service c0f7c7
[/* Override any gcc2 internal prototype to avoid an error.  */
Packit Service c0f7c7
]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
Packit Service c0f7c7
extern "C"
Packit Service c0f7c7
#endif
Packit Service c0f7c7
])dnl
Packit Service c0f7c7
[/* We use char because int might match the return type of a gcc2
Packit Service c0f7c7
    builtin and then its argument prototype would still apply.  */
Packit Service c0f7c7
char $2();
Packit Service c0f7c7
]),
Packit Service c0f7c7
	    [$2()],
Packit Service c0f7c7
	    eval "ac_cv_lbl_lib_$ac_lib_var=yes",
Packit Service c0f7c7
	    eval "ac_cv_lbl_lib_$ac_lib_var=no")
Packit Service c0f7c7
LIBS="$ac_save_LIBS"
Packit Service c0f7c7
])dnl
Packit Service c0f7c7
if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
Packit Service c0f7c7
  AC_MSG_RESULT(yes)
Packit Service c0f7c7
  ifelse([$3], ,
Packit Service c0f7c7
[changequote(, )dnl
Packit Service c0f7c7
  ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
Packit Service c0f7c7
    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
Packit Service c0f7c7
changequote([, ])dnl
Packit Service c0f7c7
  AC_DEFINE_UNQUOTED($ac_tr_lib)
Packit Service c0f7c7
  LIBS="-l$1 $LIBS"
Packit Service c0f7c7
], [$3])
Packit Service c0f7c7
else
Packit Service c0f7c7
  AC_MSG_RESULT(no)
Packit Service c0f7c7
ifelse([$4], , , [$4
Packit Service c0f7c7
])dnl
Packit Service c0f7c7
fi
Packit Service c0f7c7
])
Packit Service c0f7c7
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl AC_LBL_LIBRARY_NET
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl This test is for network applications that need socket functions and
Packit Service c0f7c7
dnl getaddrinfo()/getnameinfo()-ish functions.  We now require
Packit Service c0f7c7
dnl getaddrinfo() and getnameinfo().  We also prefer versions of
Packit Service c0f7c7
dnl recvmsg() that conform to the Single UNIX Specification, so that we
Packit Service c0f7c7
dnl can check whether a datagram received with recvmsg() was truncated
Packit Service c0f7c7
dnl when received due to the buffer being too small.
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl On most operating systems, they're available in the system library.
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl Under Solaris, we need to link with libsocket and libnsl to get
Packit Service c0f7c7
dnl getaddrinfo() and getnameinfo() and, if we have libxnet, we need to
Packit Service c0f7c7
dnl link with libxnet before libsocket to get a version of recvmsg()
Packit Service c0f7c7
dnl that conforms to the Single UNIX Specification.
Packit Service c0f7c7
dnl
Packit Service c0f7c7
dnl We use getaddrinfo() because we want a portable thread-safe way
Packit Service c0f7c7
dnl of getting information for a host name or port; there exist _r
Packit Service c0f7c7
dnl versions of gethostbyname() and getservbyname() on some platforms,
Packit Service c0f7c7
dnl but not on all platforms.
Packit Service c0f7c7
dnl
Packit Service c0f7c7
AC_DEFUN(AC_LBL_LIBRARY_NET, [
Packit Service c0f7c7
    #
Packit Service c0f7c7
    # Most operating systems have getaddrinfo() in the default searched
Packit Service c0f7c7
    # libraries (i.e. libc).  Check there first.
Packit Service c0f7c7
    #
Packit Service c0f7c7
    AC_CHECK_FUNC(getaddrinfo,,
Packit Service c0f7c7
    [
Packit Service c0f7c7
	#
Packit Service c0f7c7
	# Not found in the standard system libraries.
Packit Service c0f7c7
	# Try libsocket, which requires libnsl.
Packit Service c0f7c7
	#
Packit Service c0f7c7
	AC_CHECK_LIB(socket, getaddrinfo,
Packit Service c0f7c7
	[
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    # OK, we found it in libsocket.
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    LIBS="-lsocket -lnsl $LIBS"
Packit Service c0f7c7
	],
Packit Service c0f7c7
	[
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    # We didn't find it.
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    AC_MSG_ERROR([getaddrinfo is required, but wasn't found])
Packit Service c0f7c7
	], -lnsl)
Packit Service c0f7c7
Packit Service c0f7c7
	#
Packit Service c0f7c7
	# OK, do we have recvmsg() in libxnet?
Packit Service c0f7c7
	# We also link with libsocket and libnsl.
Packit Service c0f7c7
	#
Packit Service c0f7c7
	AC_CHECK_LIB(xnet, recvmsg,
Packit Service c0f7c7
	[
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    # Yes - link with it as well.
Packit Service c0f7c7
	    #
Packit Service c0f7c7
	    LIBS="-lxnet $LIBS"
Packit Service c0f7c7
	], , -lsocket -lnsl)
Packit Service c0f7c7
    ])
Packit Service c0f7c7
    # DLPI needs putmsg under HPUX so test for -lstr while we're at it
Packit Service c0f7c7
    AC_SEARCH_LIBS(putmsg, str)
Packit Service c0f7c7
])