dnl dnl #Id: configure.in,v 1.7 2001/12/31 21:44:04 jpr5 Exp # dnl dnl $Id: configure.in,v 1.2 2002/01/02 03:30:48 mavetju Exp $ dnl dnl Copyright (c) 2001 Jordan Ritter dnl dnl Modifications for ngrep-lib by Edwin Groothuis dnl dnl Please refer to the COPYRIGHT file for more information. AC_INIT(ngrep-lib.c test-lib.c) AC_CANONICAL_SYSTEM AC_PROG_CC AC_PREFIX(gcc) AC_HEADER_STDC AC_C_CONST AC_TYPE_SIZE_T AC_TYPE_SIGNAL AC_FUNC_ALLOCA AC_CHECK_HEADER(strings.h,,echo need strings header; exit) AC_CHECK_HEADER(netinet/if_ether.h,AC_DEFINE(HAVE_IF_ETHER_H,1),) dnl dnl Find ourselves some usable pcap headers. dnl AC_MSG_CHECKING(for a complete set of pcap headers) possible_dirs="`eval echo -n ${includedir}` \ /usr/include /usr/include/pcap \ /usr/local/include /usr/local/include/pcap \ /usr/share/include /usr/share/include/pcap" AC_ARG_WITH(pcap-includes, [ --with-pcap-includes specify the pcap include directory], [PCAP_DIR=$withval], [PCAP_DIR=$possible_dirs]) pcap_dir="" for dir in $PCAP_DIR ; do if test -d $dir -a -r "$dir/pcap.h" -a \ -r "$dir/net/bpf.h" ; then if test -n "$pcap_dir" -a "$pcap_dir" != "$dir"; then echo echo; echo more than one set found in: echo $pcap_dir echo $dir echo; echo please wipe out all unused pcap installations exit else pcap_dir="$dir" fi fi done if test -z "$pcap_dir" ; then echo no; echo couldn\'t find a complete set of pcap headers exit else echo found $pcap_dir PCAP_INCLUDE="-I$pcap_dir" PCAP_LINK="-L`dirname $pcap_dir`/lib" AC_SUBST(PCAP_INCLUDE) AC_SUBST(PCAP_LINK) AC_MSG_CHECKING(for usable bpf.h) if test -n "`grep DLT_RAW $pcap_dir/net/bpf.h`" ; then echo yep else echo nope echo '***************************************************************' echo an important define is missing from the bpf.h I found. this echo probably means that your installation of pcap is outdated and echo needs upgrading. I\'ll go ahead and add the define for you but echo understand that matching certain types of packets may not echo function properly. echo '***************************************************************' sleep 3 AC_DEFINE(DLT_RAW, 12) fi fi dnl dnl pcre library compatibility stuff dnl AC_ARG_WITH(pcre, [ --with-pcre use libnet build directory], [ ( cd pcre-3.4; ./configure && make libtool chartables.c ) AC_DEFINE(USE_PCRE) REGEX_TARGET='pcre' REGEX_OBJS='pcre.o study.o' ], [ ( cd regex-0.12; ./configure ) REGEX_TARGET='regex' REGEX_OBJS='regex.o' ] ) AC_SUBST(REGEX_TARGET) AC_SUBST(REGEX_OBJS) dnl dnl OS-specific options dnl AC_DEFINE(_BSD_SOURCE) AC_DEFINE(__FAVOR_BSD) STRIPFLAG="-s" case "$target_os" in *linux*) AC_DEFINE(LINUX) AC_MSG_CHECKING(for a dumb udphdr declaration) AC_TRY_COMPILE(, #ifndef __FAVOR_BSD #define __FAVOR_BSD #endif #ifndef _BSD_SOURCE #define _BSD_SOURCE 1 #endif #include struct udphdr foo; unsigned short bar = foo.uh_sport; , echo nope, echo yep dumb; AC_DEFINE(HAVE_DUMB_UDPHDR)) ;; *bsd*) AC_DEFINE(BSD) ;; *solaris*) AC_DEFINE(SOLARIS) AC_CHECK_LIB(socket, socket,, echo no socket in -lsocket\?; exit) AC_CHECK_LIB(nsl, gethostbyname,, echo no gethostbyname in -lnsl\?; exit) LIBS="$LIBS -lnsl -lsocket" AC_SUBST(EXTRA_LIBS) EXTRA_LIBS='-lnsl -lsocket' ;; *osf*) AC_DEFINE(OSF1) AC_DEFINE(__STDC__, 2) ;; *hpux11*) AC_DEFINE(BSD) ;; *aix*) AC_DEFINE(AIX) ;; *darwin*) AC_DEFINE(MACOSX) STRIPFLAG="" ;; *) AC_MSG_WARN(Your OS ($target_os) is not supported yet. Try\ playing with the build host and target options.) ;; esac AC_SUBST(STRIPFLAG) AC_CHECK_LIB(pcap, pcap_open_live,,echo need pcap lib; exit) dnl dnl Here's where we should check to see if we require the use of a dnl PCAP_RESTART function. Should run a test program that calls dnl pcap_compile() twice and checks the exit value, or something. For dnl now, just let the user the flag itself, until I come up with a dnl working methodology. dnl AC_ARG_WITH(restart, [ --with-restart use libpcap restart func], [ if test "$withval" = "yes"; then AC_DEFINE(NEED_RESTART) need_restart="yes" else need_restart="no" fi ], [ AC_DEFINE(NEED_RESTART) need_restart="yes" ]) dnl dnl Now find the function in the lib.. dnl if test "$need_restart" = "yes" ; then 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\? exit))) fi AC_OUTPUT(Makefile)