home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / nmap254b.zip / configure.in < prev    next >
Text File  |  2001-06-02  |  11KB  |  420 lines

  1.  
  2. # Require autoconf 2.13
  3. AC_PREREQ(2.13)
  4.  
  5. dnl Process this file with autoconf to produce a configure script.
  6. AC_INIT(nmap.c)
  7.  
  8. if test -d /usr/local/lib; then
  9.   LDFLAGS="$LDFLAGS -L/usr/local/lib"
  10. fi
  11. if test -d /usr/local/include; then
  12.   CFLAGS="$CFLAGS -I/usr/local/include"
  13. fi
  14.  
  15. libpcapdir=libpcap-possiblymodified
  16. AC_SUBST(libpcapdir)
  17.  
  18. dnl use config.h instad of -D macros
  19. AC_CONFIG_HEADER(config.h)
  20.  
  21. dnl Checks for programs.
  22. AC_PROG_CC
  23.  if test -n "$GCC"; then
  24.       CFLAGS="$CFLAGS -Wall "
  25.  fi
  26. dnl AC_PROG_INSTALL
  27. dnl AC_PATH_PROG(MAKEDEPEND, makedepend)
  28.  
  29. AC_SUBST(COMPAT_OBJS)
  30. AC_SUBST(COMPAT_SRCS)
  31.  
  32. dnl Host specific hacks
  33. AC_CANONICAL_HOST
  34.  
  35. linux=no
  36.  
  37. case "$host" in
  38.   *-netbsd*)
  39.     AC_DEFINE(NETBSD)
  40.     ;;
  41.   *-openbsd*)
  42.     AC_DEFINE(OPENBSD)
  43.     ;;
  44.   *-sgi-irix5*)
  45.     AC_DEFINE(IRIX)
  46.     if test -z "$GCC"; then
  47.       sgi_cc=yes
  48.     fi
  49.     ;;
  50.   *-sgi-irix6*)
  51.     AC_DEFINE(IRIX)
  52.     if test -z "$GCC"; then
  53.       sgi_cc=yes
  54.     fi
  55.     ;;
  56.   *-solaris2.0*)  
  57.     AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)
  58.     AC_DEFINE(SOLARIS)
  59.     ;;
  60.   *-solaris2.1*)
  61.     AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)
  62.     AC_DEFINE(SOLARIS)
  63.     ;;
  64.   *-solaris2.2*)
  65.     AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)
  66.     AC_DEFINE(SOLARIS)
  67.     ;;
  68.   *-solaris2.3*)
  69.     AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)
  70.     AC_DEFINE(SOLARIS)
  71.     ;;
  72.   *-solaris2.4*)
  73.     AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)
  74.     AC_DEFINE(SOLARIS)
  75.     ;;
  76.   *-solaris2.5.1)
  77.     AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG)
  78.     AC_DEFINE(SOLARIS)
  79.     ;;
  80.   *-solaris*)
  81.     AC_DEFINE(SOLARIS)
  82.     ;;
  83.   *-sunos4*)
  84.     AC_DEFINE(SUNOS)
  85.     AC_DEFINE(SPRINTF_RETURNS_STRING)
  86.     ;;
  87.   *-linux*)
  88.     linux=yes
  89.     AC_DEFINE(LINUX)
  90.     AC_DEFINE(PCAP_TIMEOUT_IGNORED)  # libpcap doesn't even LOOK at
  91.                                      # the timeout you give it under Linux
  92.     ;;
  93.   *-freebsd*)
  94.     AC_DEFINE(FREEBSD)
  95.     ;;
  96.   *-bsdi*)
  97.     AC_DEFINE(BSDI)
  98.     ;;
  99.   *-apple-darwin*)
  100.     macosx=yes
  101.     AC_DEFINE(MACOSX)
  102.     ;;
  103. esac
  104.  
  105. dnl Checks for libraries.
  106. dnl AC_CHECK_LIB(m, pow)
  107. dnl on Mac OSX the math library seems to contain unwanted getopt cruft
  108. if test xx$macosx = xx; then
  109.   AC_CHECK_LIB(m, main)
  110. fi
  111.  
  112.  
  113. dnl If any socket libraries needed
  114. AC_CHECK_FUNC(gethostent, , AC_CHECK_LIB(nsl, gethostent))
  115. AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
  116.  
  117. dnl need posix4/nanosleep for solaris 2.4
  118. AC_CHECK_FUNC(nanosleep, , AC_CHECK_LIB(posix4, nanosleep))
  119.  
  120. dnl Check whether libpcap is already available
  121. have_libpcap=no
  122.  
  123. # By default, search for pcap library
  124. test "${with_libpcap+set}" != "set" && with_libpcap=yes
  125.  
  126. AC_ARG_WITH(libpcap,
  127. [  --with-libpcap[=DIR]    Look for pcap include/libs in DIR],
  128. [  case "$with_libpcap" in
  129.   yes)
  130.     AC_CHECK_HEADER(pcap.h,
  131.       AC_CHECK_LIB(pcap, pcap_datalink,
  132.       [have_libpcap=yes LIBS="-lpcap $LIBS"]))
  133.     ;;
  134.   *)
  135.     _cppflags=$CPPFLAGS
  136.     _ldflags=$LDFLAGS
  137.  
  138.     CPPFLAGS="-I$with_libpcap/include $CPPFLAGS"
  139.     LDFLAGS="-L$with_libpcap/lib $LDFLAGS"
  140.  
  141.     AC_CHECK_HEADER(pcap.h,[
  142.       AC_CHECK_LIB(pcap, pcap_datalink,
  143.     [have_libpcap=yes LIBS="-lpcap $LIBS"
  144.     LIBPCAP_INC=$with_libpcap/include
  145.     LIBPCAP_LIB=$with_libpcap/lib])])
  146.  
  147.     LDFLAGS=$_ldflags
  148.     CPPFLAGS=$_cppflags
  149.     ;;
  150.   esac]
  151. )
  152. if test $linux = yes; then
  153.   have_libpcap=no
  154. fi
  155.  
  156. if test $have_libpcap = yes; then
  157.   if test "${LIBPCAP_INC+set}" = "set"; then
  158.     _cflags=$CFLAGS
  159.     _ldflags=$LDFLAGS
  160.  
  161.     CFLAGS="-I$LIBPCAP_INC $CFLAGS"
  162.     LDFLAGS="-L$LIBPCAP_LIB $LDFLAGS"
  163.   fi
  164.  
  165.   AC_MSG_CHECKING(if libpcap version is recent enough)
  166.   AC_TRY_RUN([
  167. #include <stdio.h>
  168. extern char pcap_version[];
  169. int main() {
  170.   int major, minor;
  171.   sscanf(pcap_version,"%d.%d", &major, &minor);
  172.   if (major > 0) 
  173.     exit(0);
  174.   if (minor > 4)
  175.     exit(0);
  176.   if (minor < 4)
  177.     exit(1);
  178.   if (pcap_version[3] > 'a')
  179.     exit(0);
  180.   if (pcap_version[3] == 'a') {
  181.     if(!sscanf(&pcap_version[4], "%d", &minor))
  182.       exit(1);
  183.     if (minor >= 6)
  184.       exit(0);
  185.     else
  186.       exit(1);
  187.   }
  188.   exit(1);
  189. }],
  190. [AC_MSG_RESULT(yes); have_libpcap=yes],
  191. [AC_MSG_RESULT(no); have_libpcap=no],
  192. [AC_MSG_RESULT(no); have_libpcap=no])
  193. fi
  194. if test $have_libpcap = yes; then
  195.   PCAP_DEPENDS=""
  196.   PCAP_CLEAN=""
  197.   PCAP_DIST_CLEAN=""
  198.   AC_DEFINE(HAVE_LIBPCAP)
  199. else
  200.   if test "${LIBPCAP_INC+set}" = "set"; then
  201.     LDFLAGS="-L$libpcapdir $_ldflags"
  202.     CFLAGS="$_cflags -I$libpcapdir"
  203.   else
  204.     LDFLAGS="-L$libpcapdir $LDFLAGS"
  205.     CFLAGS="$CFLAGS -I$libpcapdir"
  206.   fi
  207.   PCAP_DEPENDS='$(LIBPCAPDIR)/libpcap.a'
  208.   PCAP_CLEAN="pcap_clean"
  209.   PCAP_DIST_CLEAN="pcap_dist_clean"
  210. fi
  211.  
  212. AC_SUBST(PCAP_DEPENDS)
  213. AC_SUBST(PCAP_CLEAN)
  214. AC_SUBST(PCAP_DIST_CLEAN)
  215.  
  216. dnl Checks for header files.
  217. AC_HEADER_STDC
  218. AC_CHECK_HEADERS(string.h getopt.h strings.h memory.h sys/param.h sys/sockio.h  netinet/if_ether.h bstring.h sys/time.h pwd.h )
  219. AC_HEADER_TIME
  220.  
  221. dnl AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h)
  222.  
  223. dnl Checks for typedefs, structures, and compiler characteristics.
  224.  
  225. dnl check for void should be put in
  226. dnl AC_MSG_CHECKING(for void)
  227. dnl AC_TRY_COMPILE(, [void *foo = 0;], 
  228. dnl [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)], [AC_MSG_RESULT(no)])
  229.  
  230. dnl so should check for 'const'
  231. dnl AC_MSG_CHECKING(for const)
  232. dnl AC_TRY_COMPILE(, [const int foo = 0;], 
  233. dnl [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CONST)], [AC_MSG_RESULT(no)])
  234.  
  235. dnl equiv to '#define inline' to 'inline', '__inline__', '__inline' or ''
  236. AC_C_INLINE
  237. if test -n "$sgi_cc"; then
  238.    AC_DEFINE(inline, )
  239. fi
  240.  
  241. dnl AC_HEADER_TIME
  242.  
  243. AC_MSG_CHECKING([struct ip])
  244. AC_TRY_COMPILE([#include <sys/types.h>
  245. #include <netinet/in.h>
  246. #include <netinet/in_systm.h>
  247. #include <netinet/ip.h>],
  248.                [struct ip ip;],
  249.                [AC_MSG_RESULT(yes); bsd_networking=yes],
  250.                [AC_MSG_RESULT(no); bsd_networking=no]);
  251. if test $bsd_networking = yes; then
  252.  
  253.   AC_DEFINE(BSD_NETWORKING)
  254.   AC_MSG_CHECKING([ip_v in struct ip])
  255.   AC_TRY_COMPILE([#include <sys/types.h>
  256. #include <netinet/in.h>
  257. #include <netinet/in_systm.h>
  258. #include <netinet/ip.h>],
  259.                  [struct ip ip; ip.ip_v;],
  260.                  [AC_MSG_RESULT(yes); has_bitfields=yes],
  261.                  [AC_MSG_RESULT(no); has_bitfields=no])
  262.  
  263.   if test $has_bitfields = no; then
  264.     SAVE_CFLAGS="$CFLAGS"
  265.     CFLAGS="-D__STDC__=2"
  266.  
  267.     AC_MSG_CHECKING([if setting __STDC__=2 gives ip_v])
  268.     AC_TRY_COMPILE([#include <sys/types.h>
  269. #include <netinet/in.h>
  270. #include <netinet/in_systm.h>
  271. #include <netinet/ip.h>],
  272.                    [struct ip ip; ip.ip_v;],
  273.                    [AC_MSG_RESULT(yes); setting_stdc_helps=yes],
  274.                   [AC_MSG_RESULT(no); setting_stdc_helps=no])
  275.  
  276.     CFLAGS="$SAVE_CFLAGS"
  277.     if test $setting_stdc_helps = yes; then
  278.       CFLAGS="$CFLAGS -D__STDC__=2"
  279.     else
  280.       AC_MSG_RESULT(Can't figure out how to get bitfields - configure failed)
  281.       exit 1
  282.     fi
  283.   fi
  284. fi
  285.  
  286. AC_SUBST(CFLAGS)
  287.  
  288. dnl This test is from the configure.in of Unix Network Programming second
  289. dnl edition example code by W. Richard Stevens
  290. dnl ##################################################################
  291. dnl Check if sockaddr{} has sa_len member.
  292. dnl
  293. AC_CACHE_CHECK(if sockaddr{} has sa_len member, ac_cv_sockaddr_has_sa_len,
  294.         AC_TRY_COMPILE([
  295. #               include <sys/types.h>
  296. #               include <sys/socket.h>],
  297.                 [unsigned int i = sizeof(((struct sockaddr *)0)->sa_len)],
  298.         ac_cv_sockaddr_has_sa_len=yes,
  299.         ac_cv_sockaddr_has_sa_len=no))
  300. if test $ac_cv_sockaddr_has_sa_len = yes ; then
  301.         AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
  302. fi
  303.  
  304. dnl check endedness
  305. AC_C_BIGENDIAN
  306.  
  307. AC_MSG_CHECKING([if struct in_addr is a wacky huge structure (some Sun boxes)])
  308.  
  309. AC_TRY_COMPILE([#include <netinet/in.h>], struct in_addr i; i._S_un._S_addr;, \
  310.               AC_DEFINE(IN_ADDR_DEEPSTRUCT) \
  311.               AC_MSG_RESULT(yes) , \
  312.               AC_TRY_COMPILE([#include <sys/types.h>
  313. #include <netinet/in.h>], struct in_addr i; i.S_un.S_addr;, \
  314.                              AC_DEFINE(IN_ADDR_DEEPSTRUCT) \
  315.                              AC_MSG_RESULT(yes) , \
  316.                              AC_MSG_RESULT(no);))
  317.  
  318. AC_CACHE_CHECK(if struct icmp exists, ac_cv_struct_icmp_exists,
  319.         AC_TRY_COMPILE([
  320. #               include <sys/types.h>
  321. #               include <sys/param.h>
  322. #               include <netinet/in_systm.h>
  323. #               include <netinet/in.h>               
  324. #               define __USE_BSD
  325. #               define __FAVOR_BSD
  326. #               define __BSD_SOURCE
  327. #               include <netinet/ip.h>
  328. #               include <netinet/ip_icmp.h>],
  329.                 [unsigned int i = sizeof(struct icmp)],
  330.         ac_cv_struct_icmp_exists=yes,
  331.         ac_cv_struct_icmp_exists=no))
  332. if test $ac_cv_struct_icmp_exists = yes ; then
  333.         AC_DEFINE(HAVE_STRUCT_ICMP)
  334. fi
  335.  
  336. AC_CACHE_CHECK(if struct ip exists, ac_cv_struct_ip_exists,
  337.         AC_TRY_COMPILE([
  338. #               include <sys/types.h>
  339. #               include <sys/param.h>
  340. #               include <netinet/in_systm.h>
  341. #               include <netinet/in.h>               
  342. #               define __USE_BSD
  343. #               define __FAVOR_BSD
  344. #               define __BSD_SOURCE
  345. #               include <netinet/ip.h>],
  346.                 [unsigned int i = sizeof(struct ip)],
  347.         ac_cv_struct_ip_exists=yes,
  348.         ac_cv_struct_ip_exists=no))
  349. if test $ac_cv_struct_ip_exists = yes ; then
  350.         AC_DEFINE(HAVE_STRUCT_IP)
  351. fi
  352.  
  353. AC_CACHE_CHECK(if struct ip has ip_sum member, ac_cv_ip_has_ip_sum,
  354.         AC_TRY_COMPILE([
  355. #               include <sys/types.h>
  356. #               include <sys/param.h>
  357. #               include <netinet/in_systm.h>
  358. #               include <netinet/in.h>
  359. #               define __USE_BSD
  360. #               define __FAVOR_BSD
  361. #               define __BSD_SOURCE
  362. #               include <netinet/ip.h>
  363. #               include <netinet/ip_icmp.h>],
  364.                 [unsigned int i = sizeof(((struct ip *)0)->ip_sum)],
  365.         ac_cv_ip_has_ip_sum=yes,
  366.         ac_cv_ip_has_ip_sum=no))
  367. if test $ac_cv_ip_has_ip_sum = yes ; then
  368.         AC_DEFINE(HAVE_IP_IP_SUM)
  369. fi
  370.  
  371.  
  372. dnl Checks for library functions.
  373. dnl AC_TYPE_SIGNAL
  374. AC_CHECK_FUNCS( bzero snprintf vsnprintf memcpy usleep nanosleep strerror strcasestr inet_aton getopt_long_only )
  375.  
  376. dnl AC_CHECK_FUNCS(gethostname gettimeofday select socket strdup strstr )
  377.  
  378. AC_ARG_WITH(libnbase,
  379. [  --with-libnbase=DIR     Look for nbase include/libs in DIR],
  380. [  case "$with_libnbase" in
  381.   yes)
  382.     ;;
  383.   *)
  384.     NBASEDIR="$with_libnbase"
  385.     ;;
  386.   esac],
  387. NBASEDIR="nbase"
  388. )
  389.  
  390. LDFLAGS="$LDFLAGS -L$NBASEDIR"
  391. CFLAGS="$CFLAGS -I$NBASEDIR"
  392. LIBS="$LIBS -lnbase"
  393.  
  394. AC_SUBST(NBASEDIR)
  395.  
  396. dnl I need to configure nmapfe and libpcap here since the user might
  397. dnl have specified special options (such as --prefix )
  398. dnl
  399. dnl But I only have to configure libpcap if I am going to use it
  400. if test $have_libpcap = yes ; then
  401.         subdirs="$NBASEDIR nmapfe"
  402. else
  403.         subdirs="$NBASEDIR $libpcapdir nmapfe"
  404. fi
  405. AC_CONFIG_SUBDIRS( $subdirs )
  406.  
  407. dnl Configure libpcap if we need to since a lot of lamers don't
  408. dnl already have it installed ...
  409. dnl if test $have_libpcap = nsadf ; then
  410. dnl    echo "Have libpcap is set to $have_libpcap ";
  411. dnl    asdfasdf sdsdf sfd sdfsd
  412. dnl    AC_CONFIG_SUBDIRS( $libpcapdir )
  413. dnl fi
  414.  
  415. AC_OUTPUT(Makefile)
  416.  
  417.  
  418.  
  419.  
  420.