# Process this file with autoconf to produce a configure script. # Now you only need to update the version number in two places - below, # and in the README AC_INIT([libtrace],[3.0.7],[contact@wand.net.nz],[libtrace]) LIBTRACE_MAJOR=3 LIBTRACE_MID=0 LIBTRACE_MINOR=7 AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR(lib/trace.c) AM_INIT_AUTOMAKE m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) AC_DEFINE([LIBTRACE_MAJOR],${LIBTRACE_MAJOR},[libtrace major version]) AC_DEFINE([LIBTRACE_MID],${LIBTRACE_MID},[libtrace mid version]) AC_DEFINE([LIBTRACE_MINOR],${LIBTRACE_MINOR},[libtrace minor version]) AC_CONFIG_FILES([Makefile lib/Makefile docs/Makefile libpacketdump/Makefile tools/Makefile tools/traceanon/Makefile tools/tracepktdump/Makefile tools/tracemerge/Makefile tools/tracereport/Makefile tools/tracertstats/Makefile tools/tracesplit/Makefile tools/tracestats/Makefile tools/tracetop/Makefile tools/tracereplay/Makefile examples/Makefile examples/skeleton/Makefile examples/rate/Makefile examples/stats/Makefile docs/libtrace.doxygen lib/libtrace.h ]) dnl GNU C library dnl AC_GNU_SOURCE AM_CONFIG_HEADER([config.h]) dnl Checks for programs. AC_PROG_CC AC_PROG_CXX AC_PROG_INSTALL dnl AC_PROG_YACC AC_CHECK_PROGS(YACC, 'bison -y' byacc yacc) AM_PROG_LEX 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 if test "$GCC" = "yes"; then CFLAGS="$CFLAGS -Wall -Wextra -Wmissing-prototypes -O2" # We assume that gcc knows about -fvisibility and friends, as I can't see # a good easy way of testing for it here. CFLAGS="$CFLAGS -DLT_BUILDING_DLL=1" CFLAGS="$CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden" fi AC_PROG_LIBTOOL # Checks for library functions. AC_PROG_GCC_TRADITIONAL AC_CHECK_FUNCS(socket strdup strlcpy strcasecmp strncasecmp snprintf) 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 AC_CHECK_HEADERS(pcap.h pcap-int.h pcap-bpf.h net/bpf.h sys/limits.h stddef.h inttypes.h limits.h net/ethernet.h ) AC_CHECK_HEADERS(netinet/in.h) AC_CHECK_HEADERS(netpacket/packet.h,[ libtrace_netpacket_packet_h=true AC_DEFINE(HAVE_NETPACKET_PACKET_H,1,[has net]) ]) AC_CHECK_HEADER(net/if.h, AC_DEFINE(HAVE_NET_IF_H,1,[has net/if.h header]),,[ #include #include ]) AC_CHECK_HEADER(netinet/ether.h, AC_DEFINE(HAVE_NETINET_ETHER_H,1,[has netinet/ether.h header]),,[ #include #include #include #include ]) AC_CHECK_HEADER(netinet/if_ether.h, AC_DEFINE(HAVE_NETINET_IF_ETHER_H,1,[has netinet/if_ether.h]),,[ #include #include #include #include ]) AC_CHECK_HEADER(net/if_arp.h, AC_DEFINE(HAVE_NET_IF_ARP_H,1,[has net/if_arp.h]),,[ #include #include #include #include ]) # Checking for the right bpf header to include AC_CHECK_HEADER(pcap-bpf.h) AC_CHECK_HEADER(net/bpf.h) AC_CHECK_HEADER(gdc.h,AC_DEFINE(HAVE_LIBGDC,1,[has gdc.h])) # Check to see if we have libdl - *BSD has built-in libdl AC_CHECK_LIB(dl, dlopen) # check pcap AC_CHECK_LIB(pcap,pcap_next_ex,pcapfound=1,pcapfound=0) #AC_CHECK_LIB(pcap,pcap_next_ex) #AC_REPLACE_FUNCS(pcap_open_dead) #AC_REPLACE_FUNCS(pcap_dump_flush) #AC_REPLACE_FUNCS(pcap_next_ex) AC_CHECK_FUNCS(pcap_inject pcap_sendpacket pcap_setnonblock) AC_CHECK_DECLS([BIOCSETIF],,,[ #include #include #include #include ]) # configure time options for man pages AC_ARG_WITH(man, AS_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 ]) AC_PROG_CXX if test "$pcapfound" = 0; then AC_MSG_ERROR(libpcap0.8 or greater is required to compile libtrace. If you have installed it in a non-standard location please use LDFLAGS to specify the location of the library) else ADD_LIBS="$ADD_LIBS -lpcap" AC_DEFINE([HAVE_LIBPCAP],1,[compile with libpcap support]) AC_DEFINE([HAVE_BPF_FILTER],1,[compile with bpf filter support]) fi # configure time options for use of DAG cards # borrowed from libpcap! AC_ARG_WITH(dag, AS_HELP_STRING(--with-dag[=DIR],include DAG live capture 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=/usr/local/dag else want_dag=yes dag_root=$withval fi ],[ # # Use DAG API if present, otherwise don't # want_dag=ifpresent dag_root=/usr/local/dag ]) # DAG 3.0 actually puts header files and shared libraries into sensible # places now, so we should be able to do a simple CHECK_LIB to see if # they're there! # Addendum: It turns out DAG 2.5 does this too, so we'll match DAG2.5 in here # also. This isn't such a bad thing, the DAG2.5 API is essentially the same as # DAG 3.0 and libtrace will use the same format_dagXX source for both libtrace_dag=false libtrace_dag_version=none if test "$with_dag" != no; then AC_CHECK_LIB(dag, dag_open, dag_found=1, dag_found=0) if test "$dag_found" = 1; then ADD_LIBS="$ADD_LIBS -ldag" AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API]) AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support]) libtrace_dag=true AC_DEFINE(DAG_VERSION,30,[defines the DAG driver version]) libtrace_dag_version=30 fi fi # 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 dag_drv_v="DAG not present" # Now check for 2.4 DAG drivers which don't install as cleanly! if test "$with_dag" != no -a "$libtrace_dag" = false; then AC_MSG_CHECKING(whether we have DAG 2.4 API instead) 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/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 the DAG API]) AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support]) AC_DEFINE(DAG_VERSION, 24, [defines the DAG driver version]) libtrace_dag_version=24 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) fi # Try to determine the DAG driver version if test x"$libtrace_dag" = xtrue; then dag_drv_v="Unknown" files=`locate /usr/*dag*/VERSION` file_count=0 for i in $files; do if $file_count > 0; then dag_drv_v="Indeterminate" break fi dag_drv_v=`cat $i` file_count=$file_count+1 done fi DAG_VERSION_NUM=$dag_drv_v AC_CHECK_LIB(z, deflate) AC_CHECK_LIB(bz2, BZ2_bzDecompressInit) AC_CHECK_LIB(pthread, pthread_create) AC_SEARCH_LIBS(mvprintw, ncurses, [], [ AC_MSG_ERROR([NCurses library not available]) ]) AM_CONDITIONAL([HAVE_BPF_CAPTURE], [test "$ac_cv_have_decl_BIOCSETIF" = yes ]) AM_CONDITIONAL([HAVE_DAG], [test "$libtrace_dag" = true]) AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag_version" = 24]) AM_CONDITIONAL([DAG2_5], [test "$libtrace_dag_version" = 25]) AM_CONDITIONAL([DAG3_0], [test "$libtrace_dag_version" = 30]) AM_CONDITIONAL([HAVE_ZLIB], [test "$ac_cv_lib_z_deflate" = yes]) AM_CONDITIONAL([HAVE_BZLIB], [test "$ac_cv_lib_bz2_BZ2_bzDecompressInit" = yes]) AM_CONDITIONAL([HAVE_NETPACKET_PACKET_H], [test "$libtrace_netpacket_packet_h" = true]) AM_CONDITIONAL([HAVE_LIBGDC], [test "$ac_cv_header_gdc_h" = yes]) # 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]) AC_SUBST([PACKAGE_VERSION]) AC_SUBST([LIBTRACE_MAJOR]) AC_SUBST([LIBTRACE_MID]) AC_SUBST([LIBTRACE_MINOR]) AC_SUBST([DAG_VERSION_NUM]) AC_SUBST([HAVE_BPF_CAPTURE]) AC_SUBST([HAVE_LIBGDC]) 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 } echo AC_MSG_NOTICE([Libtrace version $PACKAGE_VERSION]) reportopt "Compiled with PCAP 0.8 support" $ac_cv_lib_pcap_pcap_next_ex reportopt "Compiled with compressed trace (zlib) support" $ac_cv_lib_z_deflate reportopt "Compiled with compressed trace (bz2) support" $ac_cv_lib_bz2_BZ2_bzDecompressInit if test x"$libtrace_dag" = xtrue; then if test "$libtrace_dag_version" = 24; then AC_MSG_NOTICE([Compiled with DAG live capture support: 2.4]) elif test "$libtrace_dag_version" = 30; then AC_MSG_NOTICE([Compiled with DAG live capture support: 3.0]) else AC_MSG_NOTICE([Compiled with DAG live capture support: 2.5]) fi else AC_MSG_NOTICE([Compiled with DAG live capture support: No]) fi reportopt "Building man pages/documentation" $libtrace_doxygen echo ac_cv_errcount=0; if test -z "$YACC"; then AC_MSG_WARN(bison or yacc not found. Please install bison before continuing) ac_cv_errcount=$((ac_cv_errcount + 1)) fi if test -z "$LEXLIB"; then AC_MSG_WARN(flex or lex not found. Please install flex before continuing) ac_cv_errcount=$((ac_cv_errcount + 1)) fi if test $ac_cv_errcount -gt 0; then AC_MSG_ERROR(Critical packages are missing and compilation will fail. Please install the packages listed above and rerun ./configure) fi