dnl dnl autoconf script for Nessus dnl dnl dnl Supported options : dnl dnl --enable-release dnl --enable-debug dnl --enable-pthreads (experimental dont use dont use dont use!) dnl --enable-cipher dnl --enable-pubkey-auth dnl --enable-syslog AC_INIT(.root-dir) AC_REVISION($Revision$)dnl PWDD=`pwd` save_IFS="${IFS}" IFS=. read NESSUS_MAJOR NESSUS_MINOR NESSUS_PATCH /dev/null || AC_MSG_ERROR([ *** Panic: Corrupt version file]) version=$NESSUS_MAJOR.$NESSUS_MINOR.$NESSUS_PATCH GCC_NO_PIPE=no dnl some compiler option AC_ARG_ENABLE(gccpipe,[ --enable-gccpipe use \"gcc -pipe\" for compilation, where possible], [case $enable_gccpipe in n*|N*) GCC_NO_PIPE=yes ;; y*|Y*) unset GCC_NO_PIPE ;; esac]) test x$GCC_NO_PIPE = xno && unset GCC_NO_PIPE test "x$prefix" != "xNONE" || prefix=/usr/local PATH=$DESTDIR${prefix}/bin:$PATH; export PATH dnl Set up the main lines of the config script AC_CONFIG_HEADER(include/config.h nasl/strutils.h) AC_PREFIX_DEFAULT("/usr/local") AC_LANG_C dnl Check for several programs AC_PROG_CC AC_LIBTOOL_WIN32_DLL AM_PROG_LIBTOOL AC_PROG_MAKE_SET AC_PROG_INSTALL echo "$INSTALL" | egrep "^\./" 2>&1 > /dev/null && { INSTALL="$PWDD/install-sh" } INSTALL_DIR="$INSTALL -d" case $host in *cygwin*) AC_DEFINE(_CYGWIN_) ;; esac # test, whether the compiler understands the -pipe command # (thanks to Tatu Illonen: ssh/configure.in) CC_NOPIPE="$CC" if test -z "$GCC_NO_PIPE" -a -n "$GCC"; then AC_MSG_CHECKING([if the compiler understands -pipe]) CC="$CC -pipe" AC_TRY_COMPILE(,, AC_MSG_RESULT(yes), CC="$CC_NOPIPE" AC_MSG_RESULT(no)) fi AC_PATH_PROG(NESSUSCONFIG, nessus-config) test "x$NESSUSCONFIG" = x && AC_ERROR("" "" "*** nessus-libraries is not installed ! You need to install it before you" "compile libnasl." "Get it at ftp://ftp.nessus.org/pub/nessus/") XFLAGS="$CFLAGS" CPPFLAGS=`$NESSUSCONFIG --cflags` AC_CHECK_HEADERS(openssl/md2.h openssl/md4.h openssl/md5.h) CPPFLAGS="$XFLAGS" AC_PATH_PROG(BISON, bison) test "x$BISON" = "x" && AC_ERROR("" "" "*** bison is not installed on this host ! You need to install it before you" "compile libnasl" "Get it at ftp://ftp.gnu.org/pub/gnu/bison/ or check your operating system" "packages") AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_HEADER_TIME AC_HEADER_DIRENT AC_HAVE_LIBRARY(rpcsvc, rpcsvc_lib="-lrpcsvc") AC_CHECK_HEADER(/usr/ucbinclude/fcntl.h, have_ucbinclude="-DHAVE_UCBINCLUDE") AC_CHECK_HEADERS(unistd.h getopt.h string.h strings.h sys/sockio.h sys/socketio.h) AC_CHECK_HEADERS(netinet/in.h,,,[#include ]) AC_CHECK_HEADERS(netinet/in_systm.h,,,[#include ]) AC_CHECK_HEADERS(netinet/ip.h,,,[#include #include #include ]) AC_CHECK_HEADERS(netinet/ip_icmp.h,,,[#include #include #include #include ]) AC_CHECK_HEADERS(netinet/ip.h netinet/udp.h netinet/protocols.h netinet/ip_udp.h netinet/ip_tcp.h netinet/tcpip.h ,,,[#include #include #include #include #include ]) AC_CHECK_HEADERS(sys/param.h) AC_CHECK_HEADERS(sys/ioctl.h) AC_CHECK_HEADERS(rpc/rpc.h dlfcn.h sys/un.h memory.h ctype.h errno.h) AC_CHECK_HEADERS(sys/types.h stdlib.h stdio.h pthread.h sys/filio.h pwd.h) AC_CHECK_HEADERS(assert.h netdb.h netinet/in.h arpa/inet.h) AC_CHECK_HEADERS(poll.h sys/poll.h netinet/ip_tcp.h) AC_CHECK_HEADERS(sys/stat.h stat.h net/if.h sys/mman.h search.h) dnl ./configure fails to determine the existence of some dnl headers under IRIX case "$host" in *-irix*) AC_DEFINE(HAVE_SYS_SOCKET_H) AC_DEFINE(HAVE_NETINET_IP_H) AC_DEFINE(HAVE_NETINET_TCP_H) ;; *) AC_CHECK_HEADERS(sys/socket.h netinet/ip.h netinet/tcp.h) ;; esac dnl Check for several functions AC_FUNC_ALLOCA AC_CHECK_FUNCS(lstat memmove gettimeofday gethrtime getrusage rand) AC_CHECK_FUNCS(strchr memcpy select poll) AC_CHECK_FUNC(vsnprintf,AC_DEFINE(HAVE_VSNPRINTF)) AC_CHECK_FUNC(memmem, AC_DEFINE(HAVE_MEMMEM)) AC_CHECK_FUNCS(bzero bcopy) AC_CHECK_FUNCS(addr2ascii inet_neta) AC_CHECK_FUNCS(signal sigaction wait wait3 wait4 waitpid) AC_CHECK_FUNCS(lfind) AC_CHECK_LIB(compat, lfind, compat_lib="-lcompat") test -n "$compat_lib" && AC_DEFINE(HAVE_LFIND) dnl Check for sevral types and guess our byte ordering AC_C_BIGENDIAN AC_CHECK_TYPE(time_t,int) AC_TYPE_PID_T AC_TYPE_SIZE_T AC_TYPE_UID_T AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) dnl Check that the struct ip has member ip_csum AC_MSG_CHECKING([struct ip contains ip_csum]) AC_TRY_COMPILE([#ifdef __linux__ #define __BSD_SOURCE #define _BSD_SOURCE #define __FAVOR_BSD #endif #include #include #include #include ], [ struct ip ip; ip.ip_csum = 0; ], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRUCT_IP_CSUM)], [AC_MSG_RESULT(no);]) dnl Check whether we have to redefine the structs ip and icmp AC_MSG_CHECKING([struct ip]) AC_TRY_COMPILE([#include #include #include #include ], [struct ip ip;], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRUCT_IP)], [AC_MSG_RESULT(no)]) dnl Check whether we have to redefine the structs ip and icmp AC_MSG_CHECKING([struct ip has ip_hl]) AC_TRY_COMPILE([#include #include #include #include ], [struct ip ip;ip.ip_hl = 1], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_IP_HL)], [AC_MSG_RESULT(no)]) AC_MSG_CHECKING([struct icmp]) AC_TRY_COMPILE([#include #include #include #include #include ], [struct icmp icmp;], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRUCT_ICMP)], [AC_MSG_RESULT(no)]) AC_MSG_CHECKING([struct udphdr]) AC_TRY_COMPILE([#include #include #include #include #include ], [struct udphdr udp;], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRUCT_UDPHDR)], [AC_MSG_RESULT(no)]) AC_MSG_CHECKING([BSD struct udphdr]) AC_TRY_COMPILE([#ifdef __linux__ #define __BSD_SOURCE #define _BSD_SOURCE #define __FAVOR_BSD #endif #include #include #include #include #include ], [struct udphdr udp;udp.uh_dport = 0;], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_BSD_STRUCT_UDPHDR)], [AC_MSG_RESULT(no)]) AC_MSG_CHECKING([struct tcphdr]) AC_TRY_COMPILE([#include #include #include #include #include ], [struct tcphdr tcp;], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRUCT_TCPHDR)], [AC_MSG_RESULT(no)]) AC_MSG_CHECKING([struct tcphdr has th_off]) AC_TRY_COMPILE([#include #ifdef __linux__ #define __FAVOR_BSD #endif #include #include #include #include ], [struct tcphdr tcp;tcp.th_off = 0;], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TCPHDR_TH_OFF)], [AC_MSG_RESULT(no)]) AC_MSG_CHECKING([struct tcphdr has th_x2_off]) AC_TRY_COMPILE([#include #ifdef __linux__ #define __FAVOR_BSD #endif #include #include #include #include ], [struct tcphdr tcp;tcp.th_x2_off = 0;], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TCPHDR_TH_X2_OFF)], [AC_MSG_RESULT(no)]) dnl Define several paths AC_SYS_LONG_FILE_NAMES dnl Check for the libraries we may want to use AC_CHECK_LIB(c, inet_aton, AC_DEFINE(HAVE_INET_ATON)) AC_CHECK_LIB(resolv, inet_aton, AC_DEFINE(HAVE_INET_ATON)) if [ test "`uname`" != "IRIX" ]; then AC_CHECK_LIB(socket, inet_aton, AC_DEFINE(HAVE_INET_ATON)) AC_CHECK_LIB(nsl, inet_aton, AC_DEFINE(HAVE_INET_ATON)) fi dnl This test is from the configure.in of Unix Network Programming second dnl edition example code by W. Richard Stevens dnl ################################################################## dnl Check if sockaddr{} has sa_len member. dnl AC_CACHE_CHECK(if sockaddr{} has sa_len member, ac_cv_sockaddr_has_sa_len, AC_TRY_COMPILE([ # include # include ], [unsigned int i = sizeof(((struct sockaddr *)0)->sa_len)], ac_cv_sockaddr_has_sa_len=yes, ac_cv_sockaddr_has_sa_len=no)) if test $ac_cv_sockaddr_has_sa_len = yes ; then AC_DEFINE(HAVE_SOCKADDR_SA_LEN) fi BROKEN_REGEXP="" # # RedHat 8.0 ships with a broken regexp library (Nessus bug#90) # test -f /etc/redhat-release && { cat /etc/redhat-release | egrep "(8\.0|9)" >/dev/null && BROKEN_REGEXP=y } test -z "$BROKEN_REGEXP" && { AC_MSG_CHECKING([for a working regexp implementation]) AC_TRY_RUN([ #include #include #include #include int main() { char fastmap[1 << 8]; struct re_pattern_buffer pb; struct re_registers regs; pb.allocated = 8; pb.buffer = malloc(8); pb.fastmap = fastmap; pb.translate = 0; re_set_syntax(RE_SYNTAX_POSIX_EGREP); re_compile_pattern(".*nessus.*", strlen(".*nessus.*"), &pb); re_compile_fastmap(&pb); return re_search(&pb, "i use nessus everyday", strlen("i use nessus everyday"), 0, strlen("i use nessus everyday"), ®s); } ], [AC_MSG_RESULT([yes]);AC_DEFINE(HAVE_REGEX_SUPPORT)],[AC_MSG_RESULT([no])]) } AC_MSG_CHECKING([for a working strndup implementation]) AC_TRY_RUN([ int main() { char * a = "foobar"; char * b; b = strndup(a, strlen(a)); if( b == NULL ) return 1; if( b == a ) return 1; return strcmp(a, b); } ], [AC_MSG_RESULT([yes]);AC_DEFINE(HAVE_STRNDUP_ALREADY)],[AC_MSG_RESULT([no])]) case "$host" in *-freebsd*|*-bsdi*|*-netbsd*) AC_DEFINE(BSD_BYTE_ORDERING) esac case "$host" in *-netbsd*) AC_DEFINE(NETBSD) ;; *-openbsd*) AC_DEFINE(OPENBSD) ;; *-sgi-irix5*) AC_DEFINE(IRIX) no_libsocket=yes no_libnsl=yes if test -z "$GCC"; then sgi_cc=yes fi ;; *-sgi-irix6*) AC_DEFINE(IRIX) no_libsocket=yes no_libnsl=yes if test -z "$GCC"; then sgi_cc=yes fi ;; *-solaris2.0*) AC_DEFINE(STUPID_SOLARIS_CHECKSUM_BUG) 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) no_libnsl=yes no_libsocket=yes ;; *-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*) AC_DEFINE(FREEBSD) ;; *-bsdi*) AC_DEFINE(BSDI) ;; esac OLD_CFLAGS=$CFLAGS CFLAGS="$CFLAGS `$NESSUSCONFIG --libs --cflags`" if echo $CFLAGS | grep pcap-nessus 2>&1 > /dev/null; then AC_CHECK_LIB(pcap-nessus, pcap_restart, AC_DEFINE(PCAP_RESTART,pcap_restart), AC_CHECK_LIB(pcap-nessus, pcap_yyrestart, AC_DEFINE(PCAP_RESTART,pcap_yyrestart), AC_CHECK_LIB(pcap-nessus, yyrestart, AC_DEFINE(PCAP_RESTART,yyrestart), echo no yacc restart func found echo perhaps libpcap-nessus wasn\'t compiled with bison/flex\? ))) else AC_CHECK_LIB(pcap, pcap_restart, AC_DEFINE(PCAP_RESTART,pcap_restart), AC_CHECK_LIB(pcap, pcap_yyrestart, AC_DEFINE(PCAP_RESTART,pcap_yyrestart), AC_CHECK_LIB(pcap, yyrestart, AC_DEFINE(PCAP_RESTART,yyrestart), echo no yacc restart func found echo perhaps libpcap wasn\'t compiled with bison/flex\? ))) fi CFLAGS=$OLD_CFLAGS dnl Final step : substitute what we want to AC_SUBST(PWD) AC_SUBST(PWDD) AC_SUBST(CFLAGS) AC_SUBST(CWALL) AC_SUBST(CWARN) AC_SUBST(NESSUSCONFIG) AC_SUBST(INSTALL) AC_SUBST(version) AC_SUBST(NESSUS_MAJOR) AC_SUBST(NESSUS_MINOR) AC_SUBST(NESSUS_SUPER) AC_SUBST(NESSUS_PATCH) AC_SUBST(NESSUS_DATE) AC_SUBST(INSTALL_DIR) AC_SUBST(rpcsvc_lib) AC_SUBST(compat_lib) AC_SUBST(VERSION) AC_SUBST(have_ucbinclude) dnl And we put everything in ONE file AC_OUTPUT(nasl.tmpl nasl-config) exit 0