Annotation of embedaddon/arping/configure.ac, revision 1.1.1.4

1.1       misho       1: #                                               -*- Autoconf -*-
                      2: # Process this file with autoconf to produce a configure script.
                      3: 
                      4: AC_PREREQ(2.61)
1.1.1.4 ! misho       5: AC_INIT(arping, 2.21, thomas@habets.se)
1.1       misho       6: AC_CANONICAL_SYSTEM
                      7: AC_CONFIG_SRCDIR([src/arping.c])
                      8: AM_INIT_AUTOMAKE
                      9: AM_MAINTAINER_MODE
                     10: AC_CONFIG_HEADER(config.h)
                     11: 
                     12: 
                     13: # Checks for programs.
                     14: AC_PROG_CC
                     15: AC_PROG_INSTALL
                     16: AC_PROG_MAKE_SET
                     17: 
1.1.1.4 ! misho      18: # Required to define __USE_MISC, which in turn typedefs uint, which
        !            19: # is used by libnet headers.
        !            20: # This "just works" until running GCC with -std=c99, where uint is
        !            21: # no longer defined by default.
        !            22: CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE=1"
        !            23: 
1.1       misho      24: # Checks for libraries.
1.1.1.2   misho      25: AC_CHECK_LIB([m], [sqrt])
1.1       misho      26: AC_CHECK_LIB([socket], [socket])
                     27: AC_CHECK_LIB([nsl], [gethostbyname])
1.1.1.3   misho      28: AC_CHECK_LIB([cap], [cap_init])
1.1.1.2   misho      29: AC_CHECK_LIB([rt], [clock_gettime])
1.1       misho      30: AC_CHECK_LIB([net], [libnet_name_resolve],
1.1.1.4 ! misho      31:       [AC_MSG_ERROR([libnet 1.0.x found. Arping 2.x requires libnet 1.1 or newer])])
1.1       misho      32: AC_CHECK_LIB([net], [libnet_init], ,[AC_MSG_ERROR([libnet 1.1.x not found])])
                     33: AC_CHECK_LIB([pcap], [pcap_open_live], ,[AC_MSG_ERROR([libpcap not found])])
1.1.1.2   misho      34: AC_SEARCH_LIBS([clock_gettime], [rt])
1.1       misho      35: 
                     36: # Checks for header files.
                     37: AC_HEADER_STDC
                     38: AC_CHECK_HEADERS([\
                     39: arpa/inet.h \
                     40: netinet/in.h \
                     41: stdlib.h \
                     42: sys/socket.h \
1.1.1.4 ! misho      43: getopt.h \
1.1.1.2   misho      44: time.h \
1.1.1.4 ! misho      45: grp.h \
1.1       misho      46: sys/time.h \
                     47: sys/types.h \
1.1.1.4 ! misho      48: sys/param.h \
1.1.1.3   misho      49: sys/capability.h \
1.1       misho      50: stdint.h \
                     51: libnet.h \
                     52: win32/libnet.h \
1.1.1.4 ! misho      53: sys/random.h \
1.1       misho      54: net/bpf.h \
1.1.1.3   misho      55: pwd.h \
1.1       misho      56: unistd.h])
                     57: 
                     58: # Libnet include file is not optional
                     59: if test ! x$ac_cv_header_libnet_h = xyes; then
                     60:   AC_MSG_ERROR([Can't find libnet.h. See INSTALL file for where to get Libnet])
                     61: fi
                     62: 
                     63: # Checks for typedefs, structures, and compiler characteristics.
                     64: AC_C_CONST
                     65: AC_HEADER_TIME
                     66: AC_C_VOLATILE
                     67: AC_TYPE_UINT8_T
                     68: AC_TYPE_UINT16_T
                     69: AC_TYPE_UINT32_T
                     70: AC_TYPE_UINT64_T
                     71: 
                     72: # Checks for library functions.
                     73: AC_PROG_GCC_TRADITIONAL
                     74: AC_FUNC_SELECT_ARGTYPES
                     75: AC_FUNC_SETVBUF_REVERSED
                     76: AC_TYPE_SIGNAL
1.1.1.2   misho      77: AC_CHECK_FUNCS([gettimeofday memset select strchr strdup strerror strstr \
1.1.1.4 ! misho      78: getifaddrs cap_init pcap_create pcap_list_tstamp_types pcap_set_immediate_mode \
        !            79: pledge unveil pcap_findalldevs getrandom])
1.1.1.2   misho      80: 
                     81: if test x$ac_cv_func_getifaddrs = xyes; then
                     82:     AC_LIBOBJ([findif_getifaddrs])
                     83: else
                     84:     case "$target_os" in
                     85:         *linux*)
                     86:             AC_LIBOBJ([findif_linux])
                     87:             ;;
                     88:         *freebsd*|*openbsd*|*darwin*)
                     89:             AC_LIBOBJ([findif_sysctl])
                     90:             ;;
                     91:         *solaris*)
                     92:             AC_LIBOBJ([findif_bsdroute])
                     93:             ;;
                     94:         *)
                     95:             AC_LIBOBJ([findif_other])
                     96:             ;;
                     97:     esac
                     98: fi
                     99: 
1.1.1.4 ! misho     100: AC_CACHE_CHECK([for libnet_init signature has const],
        !           101:                    ac_cv_have_libnet_init_const, [
        !           102:                    AC_TRY_LINK([#include<libnet.h>],
        !           103: [libnet_t*libnet_init(int a,const char* b,char* c);],
        !           104:   [ ac_cv_have_libnet_init_const="yes" ],
        !           105:   [ ac_cv_have_libnet_init_const="no" ])
        !           106: ])
        !           107: if test x$ac_cv_have_libnet_init_const = xyes; then
        !           108:    AC_DEFINE([HAVE_LIBNET_INIT_CONST], [1], [Libnet init takes const char device])
        !           109: fi
        !           110: 
        !           111: AC_CACHE_CHECK([for libnet_name2addr4 signature has const],
        !           112:                    ac_cv_have_libnet_name2addr4_const, [
        !           113:                    AC_TRY_LINK([#include<libnet.h>],
        !           114: [uint32_t libnet_name2addr4(libnet_t*a, const char* b,uint8_t c);],
        !           115:   [ ac_cv_have_libnet_name2addr4_const="yes" ],
        !           116:   [ ac_cv_have_libnet_name2addr4_const="no" ])
        !           117: ])
        !           118: if test x$ac_cv_have_libnet_name2addr4_const = xyes; then
        !           119:    AC_DEFINE([HAVE_LIBNET_NAME2ADDR4_CONST], [1], [Libnet name2addr4 takes const char* addr])
        !           120: fi
1.1.1.2   misho     121: 
                    122: 
                    123: # check for CLOCK_MONOTONIC
1.1.1.4 ! misho     124: AC_CHECK_DECL([CLOCK_MONOTONIC], [], [],
        !           125:               [
        !           126:                 #include <time.h>
        !           127:                 #include <sys/time.h>
        !           128:               ]
        !           129: )
        !           130: AM_CONDITIONAL(HAVE_CLOCK_MONOTONIC, test x$ac_cv_have_decl_CLOCK_MONOTONIC = xyes)
        !           131: if test x$ac_cv_have_decl_CLOCK_MONOTONIC = xyes; then
1.1.1.2   misho     132:    AC_DEFINE([HAVE_CLOCK_MONOTONIC], [1], [Monotonic clock])
                    133: fi
1.1       misho     134: 
1.1.1.4 ! misho     135: AC_ARG_ENABLE(hardened, AS_HELP_STRING([--enable-hardened], [Enable security build options]),
        !           136:                         [
        !           137:                           CFLAGS+=" -pie -fPIE -fstack-protector-all --param ssp-buffer-size=1 -D_FORTIFY_SOURCE=2"
        !           138:                           LDFLAGS+=" -pie -fPIE -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack"
        !           139:                         ])
        !           140: AC_ARG_ENABLE(warnings, AS_HELP_STRING([--enable-warnings], [Enable build warnings]),
        !           141:                         [
        !           142:                           CFLAGS+=" -Wall -Wpedantic -Wextra -Wformat -Wstack-protector -Wformat-security -Werror=format-security"
        !           143:                         ])
        !           144: 
1.1       misho     145: AC_CONFIG_FILES([Makefile])
                    146: AC_CONFIG_FILES([src/Makefile])
                    147: AC_CONFIG_FILES([doc/Makefile])
                    148: AC_OUTPUT
                    149: 
                    150: echo "
                    151:   $PACKAGE_NAME version $PACKAGE_VERSION
                    152:   Prefix.........: $prefix
                    153:   Debug Build....: $debug
                    154:   C Compiler.....: $CC $CFLAGS $CPPFLAGS
                    155:   Linker.........: $LD $LDFLAGS $LIBS
                    156: "

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>