# Process this file with autoconf to produce a configure script. AC_INIT(libtrace,2.0.23,[libtrace@wand.net.nz],libtrace) AC_CONFIG_SRCDIR(lib/trace.c) AM_INIT_AUTOMAKE(libtrace, 2.0.23) AC_CONFIG_FILES([Makefile lib/Makefile docs/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_INSTALL AC_PROG_LIBTOOL # 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/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 # Check for various broken functions AC_FUNC_MALLOC AC_FUNC_REALLOC # *BSD doesn't have strndup. Currently provide our own. AC_REPLACE_FUNCS(strndup) # 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 # 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 # 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) # configure time option for __attribute__((pure)) test_pure=true AC_ARG_WITH(pure, AC_HELP_STRING([--with-pure], [use __attribute__((pure)) for optimisation]), [ if test "$withval" = no then test_pure=false else test_pure=true fi ],[ test_pure=true ]) libtrace_pure=false if test "$test_pure" = true; then AC_MSG_CHECKING([if compiler supports __attribute__((pure))]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[#define SIMPLE_FUNCTION __attribute__((pure))]])], [AC_DEFINE(HAVE_ATTR_PURE,1,[define to test for __attribute__((pure)) support]) libtrace_pure=true], [AC_DEFINE(HAVE_ATTR_PURE,0,[define to test for __attribute__((pure)) support]) libtrace_pure=false]) AC_MSG_RESULT($libtrace_pure) fi if test "$libtrace_pure" = true; then sed -i 's/#define HAVE_ATTR_PURE.*/#define HAVE_ATTR_PURE 1/' lib/libtrace.h else sed -i 's/#define HAVE_ATTR_PURE.*/#define HAVE_ATTR_PURE 0/' lib/libtrace.h 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 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 AM_CONDITIONAL(HAVE_DAG, test x$libtrace_dag = xtrue) AM_CONDITIONAL(DAG2_4, test x$libtrace_dag2_4 = xtrue) # Check for miscellaneous programs AC_CHECK_PROG([libtrace_doxygen], [doxygen], [true], [false]) AM_CONDITIONAL(HAS_DOXYGEN, [test x"$libtrace_doxygen" = xtrue]) 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]) if test "$ac_cv_use_zlib" != no; then ADD_LIBS="$ADD_LIBS -l$ac_cv_use_zlib" 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, have_libzlib=yes, have_libzlib=no) if test x"{have_libzlib}" == xno; then AC_MSG_NOTICE([Cannot find zlib library $zlib_lib_file.]) AC_MSG_ERROR([Exiting]); fi 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]); fi fi AC_DEFINE(HAVE_ZLIB,1,[Conditional for building zlib support]) libtrace_zlib=true else AC_DEFINE(HAVE_ZLIB,0,[Conditional for building zlib support]) libtrace_zlib=false fi 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 function reportopt() { if test x"$2" = xtrue; 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 __attribute__((pure))" $libtrace_pure 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