home *** CD-ROM | disk | FTP | other *** search
/ Steganos Hacker Tools / SHT151.iso / programme / scanner / nmapNTsp1 / Win_2000.exe / nmapNT-src / configure.in < prev    next >
Encoding:
Text File  |  2000-04-22  |  10.8 KB  |  390 lines

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