# Process this file with autoconf to produce a configure script. LIBTRACE_MAJOR=2 LIBTRACE_MID=0 LIBTRACE_MINOR=25 AC_INIT(libtrace,2.0.25,[contact@wand.net.nz],libtrace) AC_CONFIG_SRCDIR(lib/trace.c) AM_INIT_AUTOMAKE(libtrace,2.0.25) AC_CONFIG_FILES([Makefile lib/Makefile docs/Makefile libpacketdump/Makefile tools/Makefile tools/traceanon/Makefile tools/tracedump/Makefile tools/tracemerge/Makefile tools/tracereport/Makefile tools/tracertstats/Makefile tools/tracesplit/Makefile ]) dnl GNU C library dnl AC_GNU_SOURCE AM_CONFIG_HEADER(config.h) #AC_CONFIG_HEADERS([config.h]) dnl Checks for programs. AC_PROG_CC AC_PROG_CXX AC_PROG_INSTALL AC_LIBTOOL_DLOPEN AC_PROG_LIBTOOL AC_CONFIG_LIBOBJ_DIR(lib) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_INLINE AC_C_BIGENDIAN AC_TYPE_SIZE_T AC_HEADER_TIME AC_SYS_LARGEFILE # Checks for library functions. AC_PROG_GCC_TRADITIONAL AC_CHECK_FUNCS(socket strdup) AC_CHECK_SIZEOF([long int]) # Check for various broken functions AC_FUNC_MALLOC AC_FUNC_REALLOC # *BSD doesn't have strndup. Currently provide our own. AC_REPLACE_FUNCS(strndup) # Checks for header files. AC_HEADER_STDC dnl AC_CHECK_HEADERS(errno.h stdlib.h stdio.h assert.h string.h netinet/in.h assert.h errno.h fcntl.h net/ethernet.h netdb.h pcap.h stdio.h stdlib.h string.h sys/stat.h sys/types.h sys/socket.h sys/un.h unistd.h time.h sys/ioctl.h net/bpf.h pcap.h zlib.h pcap-bpf.h) AC_CHECK_HEADERS(pcap.h pcap-int.h pcap-bpf.h net/bpf.h zlib.h sys/limits.h stddef.h inttypes.h limits.h net/ethernet.h ) AC_CHECK_HEADERS(netinet/in.h) AC_CHECK_HEADER(net/if.h, AC_DEFINE(HAVE_NET_IF_H,1,[We have net/if.h]), [], [#include #include ]) AC_CHECK_HEADER(netinet/ether.h, AC_DEFINE(HAVE_NETINET_ETHER_H,1,[We have netinet/ether.h] ), [], [ #include #include #include #include ]) AC_CHECK_HEADER(netinet/if_ether.h, AC_DEFINE(HAVE_NETINET_IF_ETHER_H,1,[We have netinet/if_ether.h]), [], [ #include #include #include #include ]) AC_CHECK_HEADER(net/if_arp.h, AC_DEFINE(HAVE_NET_IF_ARP_H,1,[We have net/if_arp.h]), [], [ #include #include #include #include ]) # Checking for the right bpf header to include AC_MSG_CHECKING([where the bpf headers are kept]) echo "" bpfh=no AC_CHECK_HEADER(pcap-bpf.h, [AC_DEFINE([HAVE_PCAP_BPF_H]) bpfh=pcap-bpf.h]) if test $bpfh = no; then AC_CHECK_HEADER(net/bpf.h, [AC_DEFINE([HAVE_NET_BPF_H]) bpfh=net/bpf.h]) fi if test $bpfh = no; then AC_MSG_RESULT([No BPF headers, compiling without support for BPF filters]) AC_DEFINE(HAVE_BPF,0,[Conditional for building bpf support]) libtrace_bpf=false else AC_MSG_RESULT([Using $bpfh]) AC_DEFINE(HAVE_BPF,1,[Conditional for building bpf support]) libtrace_bpf=true fi AC_CHECK_HEADER(gdc.h, [AC_DEFINE(HAVE_GDC_H,1,[Conditional for building with libGDC support]) libtrace_gdc=true], [AC_DEFINE(HAVE_GDC_H,0,[Conditional for building with libGDC support]) libtrace_gdc=false]) # Check to see if we have libpcap AC_CHECK_LIB(pcap,pcap_open_live, libtrace_pcap=true, libtrace_pcap=false) if test "$libtrace_pcap" = true; then AC_DEFINE(HAVE_PCAP,1,[Conditional for building PCAP support]) ADD_LIBS="$ADD_LIBS -lpcap" else AC_DEFINE(HAVE_PCAP,0,[Conditional for building PCAP support]) fi # Only test for these functions if we have PCAP installed if test "$libtrace_pcap" = true; then # Earlier versions of pcap don't have pcap_open_dead. EG: the one # OpenBSD ships with. Even Debian Woody is more up to date. AC_CHECK_LIB(pcap,pcap_open_dead, have_pcap_open_dead=true, have_pcap_open_dead=false) if test "$have_pcap_open_dead" = false; then AC_REPLACE_FUNCS(pcap_open_dead) fi # Versions of libpcap earlier than 0.8 don't have pcap_dump_flush AC_CHECK_LIB(pcap,pcap_dump_flush, have_pcap_dump_flush=true, have_pcap_dump_flush=false) if test "$have_pcap_dump_flush" = false; then AC_REPLACE_FUNCS(pcap_dump_flush) fi fi # configure time options for man pages AC_ARG_WITH(man, AC_HELP_STRING([--with-man], [install man pages by default]), if test "$withval" = yes then MANPAGES="docs/man/man3/[a-zA-Z]*.3]" else MANPAGES="" fi ) # configure time option for building libpacketdump # libpacketdump needs a C++ compiler to build, so we should do some tests # at this point to see if one is installed libtrace_libpacketdump=true AC_ARG_ENABLE(libpacketdump, AC_HELP_STRING([--disable-libpacketdump], [disable building of libpacketdump (enabled by default). libpacketdump needs a c++ compiler to build] ), [ if test "$enableval" = no -o "$enableval" = false then libtrace_libpacketdump=false else libtrace_libpacketdump=true fi ], [ libtrace_libpacketdump=true ]) if test "$libtrace_libpacketdump" = true; then AC_LANG_PUSH(C++) AC_MSG_CHECKING([if we can compile C++ ]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[ #include ]])], [AC_DEFINE(HAVE_CXX,1,[define to test for presence of a working C++ compiler]) libtrace_cxx=true], [AC_DEFINE(HAVE_CXX,0,[define to test for presence of a working C++ compiler]) libtrace_cxx=false]) AC_MSG_RESULT($libtrace_cxx) AC_LANG_POP(C++) if test "$libtrace_cxx" = false; then AC_MSG_ERROR([libpacketdump requested, but no C++ compiler found. Build with --disable-libpacketdump if you wish to continue anyway ]) fi fi # configure time option for building the libtrace tools # one of the tools requires libpacketdump, so won't build if libpacketdump # hasn't also been built libtrace_tools=true AC_ARG_ENABLE(tools, AC_HELP_STRING([--disable-tools], [disable building of the tools contained in the tools/ directory]), [ if test "$enableval" = no -o "$enableval" = false then libtrace_tools=false else libtrace_tools=true fi ], [ libtrace_tools=true ]) # configure time options for use of DAG cards # borrowed from libpcap! AC_ARG_WITH(dag, AC_HELP_STRING([--with-dag[=DIR]], [include DAG support (located in directory DIR, if supplied)]), [ if test "$withval" = no then want_dag=no elif test "$withval" = yes then want_dag=yes dag_root=/root/dag else want_dag=yes dag_root=$withval fi ],[ # # Use DAG API if present, otherwise don't # want_dag=ifpresent dag_root=/root/dag/ ]) # turn the test part of the next block into a function, so it can be # called multiple times for $dag_root, /root/dag, /usr/local/lib libtrace_dag=false libtrace_dag2_4=false if test "$with_dag" != no; then AC_MSG_CHECKING(whether we have DAG API) if test -r "$dag_root/lib"; then dag_lib_dir="$dag_root/lib" else dag_lib_dir="$dag_root" fi if test -r "$dag_root/tools" -a -r "$dag_root/include"; then dag_tools_dir="$dag_root/tools" dag_include_dir="$dag_root/include" else dag_tools_dir="$dag_root" dag_include_dir="$dag_root" fi if test -r "$dag_include_dir/dagapi.h" -a -r "$dag_lib_dir/libdag.a"; then ADD_INCLS="$ADD_INCLS -I $dag_include_dir" ADD_LIBS="$ADD_LIBS -ldag" ADD_LDFLAGS="$ADD_LDFLAGS -L$dag_lib_dir" DAG_TOOLS_DIR=$dag_tools_dir AC_SUBST([DAG_TOOLS_DIR]) libtrace_dag=true AC_DEFINE(HAVE_DAG_API, 1, [define if you have a DAG API]) AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG support]) else if test "$want_dag" = yes; then AC_MSG_ERROR(DAG API not found under directory $dag_root ; use --without-dag) fi libtrace_dag=false fi AC_MSG_RESULT($libtrace_dag) AC_MSG_CHECKING(if we are using DAG 2.4) if grep '2.4.' $dag_root/VERSION > /dev/null 2>&1; then libtrace_dag2_4=true else libtrace_dag2_4=false fi AC_MSG_RESULT($libtrace_dag2_4) else AC_DEFINE(HAVE_DAG,0,[conditional for building with DAG support]) fi AC_ARG_WITH([zlib], AC_HELP_STRING([--with-zlib], [name of zlib library (default is z)]), [ac_cv_use_zlib=$withval], [ac_cv_use_zlib=z]) AC_ARG_WITH([zlib-path], AC_HELP_STRING([--with-zlib-path], [location of zlib library (default is /usr/lib)]), [ac_cv_use_zlib_path=$withval], [ac_cv_use_zlib_path=/usr/lib]) libtrace_zlib=false if test "$ac_cv_use_zlib" != no; then zlib_lib_file="${ac_cv_use_zlib_path}/lib${ac_cv_use_zlib}.so" # if the library is in /usr/lib/, then just use AC_CHECK_LIB if test x"${ac_cv_use_zlib_path}" == x"/usr/lib"; then AC_CHECK_LIB(${ac_cv_use_zlib}, gzopen, libtrace_zlib=true, libtrace_zlib=false) else ADD_LDFLAGS="$ADD_LDFLAGS -L$ac_cv_use_zlib_path" # if it's not in /usr/lib/, check manually. This isn't nice # and will probably break. if test ! -r "$ac_cv_use_zlib_path" -o ! -r "$zlib_lib_file"; then AC_MSG_NOTICE([Cannot find zlib library $zlib_lib_file.]) AC_MSG_ERROR([Exiting]); else libtrace_zlib=true fi fi fi if test $libtrace_zlib = true; then ADD_LIBS="$ADD_LIBS -l$ac_cv_use_zlib" AC_DEFINE(HAVE_ZLIB,1,[Conditional for building zlib support]) else AC_DEFINE(HAVE_ZLIB,0,[Conditional for building zlib support]) fi AM_CONDITIONAL([HAVE_DAG], [test "$libtrace_dag" = true]) AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag2_4" = true]) AM_CONDITIONAL([HAVE_CXX], [test "$libtrace_cxx" = true]) AM_CONDITIONAL([LIBPACKETDUMP], [test "$libtrace_libpacketdump" = true]) AM_CONDITIONAL([LIBTRACE_TOOLS], [test "$libtrace_tools" = true]) AM_CONDITIONAL([LIBGDC], [test "$libtrace_gdc" = true]) # Check for miscellaneous programs AC_CHECK_PROG([libtrace_doxygen], [doxygen], [true], [false]) AM_CONDITIONAL(HAS_DOXYGEN, [test x"$libtrace_doxygen" = xtrue]) AC_SUBST([ADD_LIBS]) AC_SUBST([ADD_LDFLAGS]) AC_SUBST([ADD_INCLS]) AC_SUBST([LTLIBOBJS]) AC_SUBST([MANPAGES]) dnl and finally, output our Makefiles AC_OUTPUT reportopt() { if test x"$2" = xtrue -o x"$2" = xyes; then AC_MSG_NOTICE([$1: Yes]) else AC_MSG_NOTICE([$1: No]) fi } reportopt "Compiled with BPF filter support" $libtrace_bpf reportopt "Compiled with PCAP support" $libtrace_pcap reportopt "Compiled with compressed trace (zlib) support" $libtrace_zlib reportopt "Compiled with DAG support (libdag)" $libtrace_dag reportopt "Compiled with DAG support (DAG 2.4)" $libtrace_dag2_4 reportopt "Building man pages/documentation" $libtrace_doxygen reportopt "Building libpacketdump" $libtrace_libpacketdump reportopt "Building tools/ directory" $libtrace_tools