configure.ac

来自「Ubuntu packages of security software。 相」· AC 代码 · 共 796 行 · 第 1/2 页

AC
796
字号
# Require autoconf 2.13 -*- mode: fundamental; -*-AC_PREREQ(2.13)dnl Process this file with autoconf to produce a configure script.AC_INIT(nmap.cc)AC_ARG_WITH(localdirs,  [  --with-localdirs        Explicitly ask compiler to use /usr/local/{include,libs} if they exist ],  [ case "$with_localdirs" in      yes)        user_localdirs=1        ;;      no)        user_localdirs=0        ;;    esac    ],  [ user_localdirs=0 ] )if test "$user_localdirs" = 1; then   if test -d /usr/local/lib; then     LDFLAGS="$LDFLAGS -L/usr/local/lib"     fi   if test -d /usr/local/include; then     CFLAGS="$CFLAGS -I/usr/local/include"     CXXFLAGS="$CFLAGS -I/usr/local/include"   fifilibpcapdir=libpcapAC_SUBST(libpcapdir)pcredir=libpcreAC_SUBST(pcredir)dnl use config.h instead of -D macrosAC_CONFIG_HEADER(config.h)dnl Checks for programs.AC_PROG_CCAC_PROG_CXX if test -n "$GXX"; then      CXXFLAGS="$CXXFLAGS -Wall " fiAC_CHECK_PROG(CXXPROG, "$CXX", "AVAILABLE", "MISSING", "$PATH":/)if test $CXXPROG = "MISSING"; then  AC_MSG_ERROR([Could not locate a C++ compiler. If it exists, add it to your PATH or give configure the CXX=path_to_compiler argument.  Otherwise, install a C++ compiler such as g++ or install a binary package of Nmap (see http://www.insecure.org/nmap/nmap_download.html ))])finmap_gcc_major_version=0AC_MSG_CHECKING([whether the compiler is gcc 4 or greater])if test x"$GXX" = xno; then  AC_MSG_RESULT([no])else  # On some distros, there are snapshots available as gcc4  if test -z "$ac_cv_prog_CC" || test x"$CC" = xgcc4; then    our_gcc="$CC"  else    our_gcc="$ac_cv_prog_CC"  fi  # new major versions must be added here  case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in    *4.)      nmap_gcc_major_version=4      ;;    *3.)      nmap_gcc_major_version=3      ;;    *2.)      nmap_gcc_major_version=2      ;;    *1.)      nmap_gcc_major_version=1      ;;  esac  if test "$nmap_gcc_major_version" -ge 4; then    AC_MSG_RESULT([yes])  else    AC_MSG_RESULT([no])  fifi# Remember that all following tests will run with this CXXFLAGS by defaultif test "$nmap_gcc_major_version" -ge 4; then  CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"fidnl AC_PROG_INSTALLdnl AC_PATH_PROG(MAKEDEPEND, makedepend)dnl Checks for typedefs, structures, and compiler characteristics.dnl check for void should be put indnl AC_MSG_CHECKING(for void)dnl AC_TRY_COMPILE(, [void *foo = 0;], dnl [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)], [AC_MSG_RESULT(no)])dnl so should check for 'const'dnl AC_MSG_CHECKING(for const)dnl AC_TRY_COMPILE(, [const int foo = 0;], dnl [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CONST)], [AC_MSG_RESULT(no)])dnl equiv to '#define inline' to 'inline', '__inline__', '__inline' or ''AC_C_INLINEif test -n "$sgi_cc"; then   AC_DEFINE(inline, )fiAC_SUBST(COMPAT_OBJS)AC_SUBST(COMPAT_SRCS)dnl Host specific hacksAC_CANONICAL_HOSTlinux=nomacosx=noneeds_cpp_precomp=nocase "$host" in  *alpha-dec-osf*)    AC_DEFINE(DEC)    ;;  *-netbsd* | *-knetbsd*-gnu)    AC_DEFINE(NETBSD)    ;;  *-openbsd*)    AC_DEFINE(OPENBSD)    ;;  *-sgi-irix5*)    AC_DEFINE(IRIX)    if test -z "$GCC"; then      sgi_cc=yes    fi    ;;  *-sgi-irix6*)    AC_DEFINE(IRIX)    if test -z "$GCC"; then      sgi_cc=yes    fi    ;;  *-hpux*)    AC_DEFINE(HPUX)    # To link with libnet and NM (/usr/lib/libnm.sl) library    # on HP-UX 11.11 (other versions?) Mikhail Zakharov (zmey20000@yahoo.com)    AC_CHECK_LIB(nm, open_mib)    ;;  *-solaris2.0*)      AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)    AC_DEFINE(SOLARIS)    ;;  *-solaris2.[[1-9]][[0-9]]*)    AC_DEFINE(SOLARIS)    ;;  *-solaris2.1*)    AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)    AC_DEFINE(SOLARIS)    ;;  *-solaris2.2*)    AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)    AC_DEFINE(SOLARIS)    ;;  *-solaris2.3*)    AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)    AC_DEFINE(SOLARIS)    ;;  *-solaris2.4*)    AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)    AC_DEFINE(SOLARIS)    ;;  *-solaris2.5.1)    AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)    AC_DEFINE(SOLARIS)    ;;  *-solaris*)    AC_DEFINE(SOLARIS)    ;;  *-sunos4*)    AC_DEFINE(SUNOS)    AC_DEFINE(SPRINTF_RETURNS_STRING)    ;;  *-linux*)    linux=yes    AC_DEFINE(LINUX)    AC_DEFINE(PCAP_TIMEOUT_IGNORED)  # libpcap doesn't even LOOK at                                     # the timeout you give it under Linux    ;;  *-freebsd* | *-kfreebsd*-gnu | *-dragonfly*)    AC_DEFINE(FREEBSD)    ;;  *-bsdi*)    AC_DEFINE(BSDI)    ;;  *-apple-darwin*)    macosx=yes    AC_DEFINE(MACOSX)    needs_cpp_precomp=yes    ;;esacdnl Checks for header files.AC_HEADER_STDCAC_CHECK_HEADERS(string.h getopt.h strings.h memory.h sys/param.h sys/sockio.h bstring.h sys/time.h sys/stat.h fcntl.h termios.h pwd.h unistd.h )AC_CHECK_HEADERS(netinet/in.h)AC_CHECK_HEADERS(sys/socket.h)AC_CHECK_HEADERS([net/if.h],[],[],[#if HAVE_SYS_TYPES_H# include <sys/types.h># endif#if HAVE_NETINET_IN_H# include <netinet/in.h># endif#if HAVE_SYS_SOCKET_H# include <sys/socket.h># endif])AC_CHECK_HEADERS([netinet/if_ether.h],[],[],[#if HAVE_SYS_TYPES_H# include <sys/types.h># endif#if HAVE_NETINET_IN_H# include <netinet/in.h># endif# if HAVE_SYS_SOCKET_H# include <sys/socket.h># endif# if HAVE_NET_IF_H# include <net/if.h># endif])AC_HEADER_TIMEdnl Checks for libraries.dnl AC_CHECK_LIB(m, pow)dnl on Mac OSX the math library seems to contain unwanted getopt cruftif test $macosx = no; then  AC_CHECK_LIB(m, main)fidnl If any socket libraries neededAC_SEARCH_LIBS(gethostent, nsl)AC_SEARCH_LIBS(setsockopt, socket)dnl need posix4/nanosleep for solaris 2.4AC_SEARCH_LIBS(nanosleep, posix4)# By default, try to build nmapfe if possibletest "${with_nmapfe+set}" != "set" && with_nmapfe=yes TARGETNMAPFE=nmapfe/nmapfeINSTALLNMAPFE=install-nmapfeAC_ARG_WITH(nmapfe, [  --without-nmapfe    skip nmapfe X-window GUI], [  case "$with_nmapfe" in  no)    TARGETNMAPFE=""; INSTALLNMAPFE=""    ;;  esac])AC_SUBST(TARGETNMAPFE)AC_SUBST(INSTALLNMAPFE)# First we test whether they specified openssl desires explicitlyuse_openssl="yes"specialssldir=""AC_ARG_WITH(openssl,[  --with-openssl=DIR    Use optional openssl libs and includes from [DIR]/lib/ and [DIR]/include/openssl/)],[  case "$with_openssl" in  yes)    ;;  no)    use_openssl="no"    ;;  *)    specialssldir="$with_openssl"    CXXFLAGS="$CXXFLAGS -I$with_openssl/include"    LDFLAGS="$LDFLAGS -L$with_openssl/lib"    ;;  esac])# If they didn't specify it, we try to find itif test "$use_openssl" = "yes" -a -z "$specialssldir"; then  AC_CHECK_HEADER(openssl/ssl.h,,  [ use_openssl="no"    AC_MSG_WARN([Failed to find openssl/ssl.h so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument]) ]) if test "$use_openssl" = "yes"; then   AC_CHECK_HEADER(openssl/err.h,,    [ use_openssl="no"    AC_MSG_WARN([Failed to find openssl/err.h so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument]) ]) fi if test "$use_openssl" = "yes"; then   AC_CHECK_HEADER(openssl/rand.h,,    [ use_openssl="no"    AC_MSG_WARN([Failed to find openssl/rand.h so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument]) ]) fi# use_openssl="yes" given explicitly in next 2 rules to avoid adding lib to $LIBS if test "$use_openssl" = "yes"; then   AC_CHECK_LIB(crypto, BIO_int_ctrl,    [ use_openssl="yes"],    [ use_openssl="no"    AC_MSG_WARN([Failed to find libcrypto so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument]) ]) fi if test "$use_openssl" = "yes"; then   AC_CHECK_LIB(ssl, SSL_new,    [ use_openssl="yes" ],    [ use_openssl="no"    AC_MSG_WARN([Failed to find libssl so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument]) ]) fifiOPENSSL_LIBS=if test "$use_openssl" = "yes"; then  AC_DEFINE(HAVE_OPENSSL)  OPENSSL_LIBS="-lssl -lcrypto"fiAC_SUBST(OPENSSL_LIBS)dnl Check whether libpcap is already availablehave_libpcap=no# By default, search for pcap librarytest "${with_libpcap+set}" != "set" && with_libpcap=yesAC_ARG_WITH(libpcap,[  --with-libpcap[=DIR]    Look for pcap in DIR/include and DIR/libs. Specify --with-libpcap=included to always use version included with Nmap],[  case "$with_libpcap" in  yes)    AC_CHECK_HEADER(pcap.h,[      AC_CHECK_LIB(pcap, pcap_datalink,      [have_libpcap=yes ])])    ;;  included)    have_libpcap=no   ;;  *)    _cppflags=$CXXFLAGS    _ldflags=$LDFLAGS    CXXFLAGS="-I$with_libpcap/include $CXXFLAGS"    LDFLAGS="-L$with_libpcap/lib $LDFLAGS"    AC_CHECK_HEADER(pcap.h,[      AC_CHECK_LIB(pcap, pcap_datalink,	[have_libpcap=yes	LIBPCAP_INC=$with_libpcap/include	LIBPCAP_LIB=$with_libpcap/lib])])    LDFLAGS=$_ldflags    CXXFLAGS=$_cppflags    ;;  esac])#if test $linux = yes; then#  have_libpcap=no#fiif test $needs_cpp_precomp = yes; then  CXXFLAGS="-no-cpp-precomp $CXXFLAGS"fiif test $have_libpcap = yes; then  if test "${LIBPCAP_INC+set}" = "set"; then    _cflags=$CXXFLAGS    _ldflags=$LDFLAGS    CXXFLAGS="-I$LIBPCAP_INC $CXXFLAGS"    LDFLAGS="-L$LIBPCAP_LIB $LDFLAGS"  fi  # link with -lpcap for the purposes of this test  LIBS_OLD="$LIBS"  LIBS="$LIBS -lpcap"  AC_MSG_CHECKING(if libpcap version is recent enough)  AC_TRY_RUN([#include <stdio.h>extern char pcap_version[];int main() {  int major, minor1, minor2;  sscanf(pcap_version,"%d.%d.%d", &major, &minor1, &minor2);  if (major > 0)     exit(0);  if (minor1 < 9)    exit(1);  if (minor2 < 4)    exit(1);  exit(0);}],[AC_MSG_RESULT(yes); have_libpcap=yes],[AC_MSG_RESULT(no); have_libpcap=no],[AC_MSG_RESULT(no); have_libpcap=no])LIBS="$LIBS_OLD"fi

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?