| 1 | # Process this file with autoconf to produce a configure script. |
|---|
| 2 | |
|---|
| 3 | # Now you only need to update the version number in two places - below, |
|---|
| 4 | # and in the README |
|---|
| 5 | |
|---|
| 6 | AC_INIT([libtrace],[3.0.2],[contact@wand.net.nz],[libtrace]) |
|---|
| 7 | |
|---|
| 8 | LIBTRACE_MAJOR=3 |
|---|
| 9 | LIBTRACE_MID=0 |
|---|
| 10 | LIBTRACE_MINOR=2 |
|---|
| 11 | |
|---|
| 12 | AC_CONFIG_SRCDIR(lib/trace.c) |
|---|
| 13 | AM_INIT_AUTOMAKE |
|---|
| 14 | |
|---|
| 15 | AC_DEFINE([LIBTRACE_MAJOR],${LIBTRACE_MAJOR},[libtrace major version]) |
|---|
| 16 | AC_DEFINE([LIBTRACE_MID],${LIBTRACE_MID},[libtrace mid version]) |
|---|
| 17 | AC_DEFINE([LIBTRACE_MINOR],${LIBTRACE_MINOR},[libtrace minor version]) |
|---|
| 18 | |
|---|
| 19 | AC_CONFIG_FILES([Makefile lib/Makefile docs/Makefile libpacketdump/Makefile |
|---|
| 20 | tools/Makefile tools/traceanon/Makefile tools/tracepktdump/Makefile |
|---|
| 21 | tools/tracemerge/Makefile tools/tracereport/Makefile |
|---|
| 22 | tools/tracertstats/Makefile tools/tracesplit/Makefile |
|---|
| 23 | tools/tracestats/Makefile tools/traceflow/Makefile |
|---|
| 24 | examples/Makefile examples/skeleton/Makefile examples/rate/Makefile |
|---|
| 25 | docs/libtrace.doxygen |
|---|
| 26 | lib/libtrace.h |
|---|
| 27 | ]) |
|---|
| 28 | dnl GNU C library |
|---|
| 29 | dnl AC_GNU_SOURCE |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | AM_CONFIG_HEADER([config.h]) |
|---|
| 33 | dnl Checks for programs. |
|---|
| 34 | AC_PROG_CC |
|---|
| 35 | AC_PROG_CXX |
|---|
| 36 | AC_PROG_INSTALL |
|---|
| 37 | AC_PROG_YACC |
|---|
| 38 | AM_PROG_LEX |
|---|
| 39 | |
|---|
| 40 | AC_CONFIG_LIBOBJ_DIR(lib) |
|---|
| 41 | |
|---|
| 42 | # Checks for typedefs, structures, and compiler characteristics. |
|---|
| 43 | AC_C_CONST |
|---|
| 44 | AC_C_INLINE |
|---|
| 45 | AC_C_BIGENDIAN |
|---|
| 46 | AC_TYPE_SIZE_T |
|---|
| 47 | AC_HEADER_TIME |
|---|
| 48 | AC_SYS_LARGEFILE |
|---|
| 49 | |
|---|
| 50 | if test "$GCC" = "yes"; then |
|---|
| 51 | CFLAGS="$CFLAGS -Wall -W -Wmissing-prototypes" |
|---|
| 52 | fi |
|---|
| 53 | |
|---|
| 54 | AC_PROG_LIBTOOL |
|---|
| 55 | |
|---|
| 56 | # Checks for library functions. |
|---|
| 57 | AC_PROG_GCC_TRADITIONAL |
|---|
| 58 | AC_CHECK_FUNCS(socket strdup strlcpy strcasecmp strncasecmp snprintf) |
|---|
| 59 | |
|---|
| 60 | AC_CHECK_SIZEOF([long int]) |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | # Check for various broken functions |
|---|
| 65 | AC_FUNC_MALLOC |
|---|
| 66 | AC_FUNC_REALLOC |
|---|
| 67 | |
|---|
| 68 | # *BSD doesn't have strndup. Currently provide our own. |
|---|
| 69 | AC_REPLACE_FUNCS(strndup) |
|---|
| 70 | |
|---|
| 71 | # Checks for header files. |
|---|
| 72 | AC_HEADER_STDC |
|---|
| 73 | 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 ) |
|---|
| 74 | |
|---|
| 75 | AC_CHECK_HEADERS(netinet/in.h) |
|---|
| 76 | AC_CHECK_HEADERS(netpacket/packet.h,[ |
|---|
| 77 | libtrace_netpacket_packet_h=true |
|---|
| 78 | AC_DEFINE(HAVE_NETPACKET_PACKET_H,1,[has net]) |
|---|
| 79 | ]) |
|---|
| 80 | AC_CHECK_HEADER(net/if.h, |
|---|
| 81 | AC_DEFINE(HAVE_NET_IF_H,1,[has net/if.h header]),,[ |
|---|
| 82 | #include <sys/types.h> |
|---|
| 83 | #include <sys/socket.h> |
|---|
| 84 | ]) |
|---|
| 85 | |
|---|
| 86 | AC_CHECK_HEADER(netinet/ether.h, |
|---|
| 87 | AC_DEFINE(HAVE_NETINET_ETHER_H,1,[has netinet/ether.h header]),,[ |
|---|
| 88 | #include <sys/types.h> |
|---|
| 89 | #include <sys/socket.h> |
|---|
| 90 | #include <netinet/in.h> |
|---|
| 91 | #include <net/if.h> |
|---|
| 92 | ]) |
|---|
| 93 | |
|---|
| 94 | AC_CHECK_HEADER(netinet/if_ether.h, |
|---|
| 95 | AC_DEFINE(HAVE_NETINET_IF_ETHER_H,1,[has netinet/if_ether.h]),,[ |
|---|
| 96 | #include <sys/types.h> |
|---|
| 97 | #include <sys/socket.h> |
|---|
| 98 | #include <netinet/in.h> |
|---|
| 99 | #include <net/if.h> |
|---|
| 100 | ]) |
|---|
| 101 | |
|---|
| 102 | AC_CHECK_HEADER(net/if_arp.h, |
|---|
| 103 | AC_DEFINE(HAVE_NET_IF_ARP_H,1,[has net/if_arp.h]),,[ |
|---|
| 104 | #include <sys/types.h> |
|---|
| 105 | #include <sys/socket.h> |
|---|
| 106 | #include <netinet/in.h> |
|---|
| 107 | #include <net/if.h> |
|---|
| 108 | ]) |
|---|
| 109 | |
|---|
| 110 | # Checking for the right bpf header to include |
|---|
| 111 | AC_CHECK_HEADER(pcap-bpf.h) |
|---|
| 112 | AC_CHECK_HEADER(net/bpf.h) |
|---|
| 113 | AC_CHECK_HEADER(gdc.h) |
|---|
| 114 | |
|---|
| 115 | # Check to see if we have libdl - *BSD has built-in libdl |
|---|
| 116 | AC_CHECK_LIB(dl, dlopen) |
|---|
| 117 | # check pcap |
|---|
| 118 | AC_CHECK_LIB(pcap,pcap_next_ex,pcapfound=1,pcapfound=0) |
|---|
| 119 | #AC_CHECK_LIB(pcap,pcap_next_ex) |
|---|
| 120 | #AC_REPLACE_FUNCS(pcap_open_dead) |
|---|
| 121 | #AC_REPLACE_FUNCS(pcap_dump_flush) |
|---|
| 122 | #AC_REPLACE_FUNCS(pcap_next_ex) |
|---|
| 123 | AC_CHECK_FUNCS(pcap_inject pcap_sendpacket pcap_setnonblock) |
|---|
| 124 | AC_CHECK_DECLS([BIOCSETIF],,,[ |
|---|
| 125 | #include <sys/types.h> |
|---|
| 126 | #include <sys/time.h> |
|---|
| 127 | #include <sys/ioctl.h> |
|---|
| 128 | #include <net/bpf.h> |
|---|
| 129 | ]) |
|---|
| 130 | |
|---|
| 131 | # configure time options for man pages |
|---|
| 132 | AC_ARG_WITH(man, |
|---|
| 133 | AS_HELP_STRING(--with-man,install man pages by default),[ |
|---|
| 134 | if test "$withval" = yes |
|---|
| 135 | then |
|---|
| 136 | MANPAGES="docs/man/man3/[a-zA-Z]*.3" |
|---|
| 137 | else |
|---|
| 138 | MANPAGES="" |
|---|
| 139 | fi |
|---|
| 140 | ]) |
|---|
| 141 | |
|---|
| 142 | AC_PROG_CXX |
|---|
| 143 | |
|---|
| 144 | if test "$pcapfound" = 0; then |
|---|
| 145 | 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) |
|---|
| 146 | else |
|---|
| 147 | ADD_LIBS="$ADD_LIBS -lpcap" |
|---|
| 148 | AC_DEFINE([HAVE_LIBPCAP],1,[compile with libpcap support]) |
|---|
| 149 | fi |
|---|
| 150 | |
|---|
| 151 | # configure time options for use of DAG cards |
|---|
| 152 | # borrowed from libpcap! |
|---|
| 153 | AC_ARG_WITH(dag, |
|---|
| 154 | AS_HELP_STRING(--with-dag[=DIR],include DAG support (located in directory DIR, if supplied)), |
|---|
| 155 | [ |
|---|
| 156 | if test "$withval" = no |
|---|
| 157 | then |
|---|
| 158 | want_dag=no |
|---|
| 159 | elif test "$withval" = yes |
|---|
| 160 | then |
|---|
| 161 | want_dag=yes |
|---|
| 162 | dag_root=/usr/local/dag |
|---|
| 163 | else |
|---|
| 164 | want_dag=yes |
|---|
| 165 | dag_root=$withval |
|---|
| 166 | fi |
|---|
| 167 | ],[ |
|---|
| 168 | # |
|---|
| 169 | # Use DAG API if present, otherwise don't |
|---|
| 170 | # |
|---|
| 171 | want_dag=ifpresent |
|---|
| 172 | dag_root=/usr/local/dag |
|---|
| 173 | ]) |
|---|
| 174 | |
|---|
| 175 | # DAG 3.0 actually puts header files and shared libraries into sensible |
|---|
| 176 | # places now, so we should be able to do a simple CHECK_LIB to see if |
|---|
| 177 | # they're there! |
|---|
| 178 | |
|---|
| 179 | # Addendum: It turns out DAG 2.5 does this too, so we'll match DAG2.5 in here |
|---|
| 180 | # also. This isn't such a bad thing, the DAG2.5 API is essentially the same as |
|---|
| 181 | # DAG 3.0 and libtrace will use the same format_dagXX source for both |
|---|
| 182 | libtrace_dag=false |
|---|
| 183 | libtrace_dag_version=none |
|---|
| 184 | |
|---|
| 185 | if test "$with_dag" != no; then |
|---|
| 186 | AC_CHECK_LIB(dag, dag_open, dag_found=1, dag_found=0) |
|---|
| 187 | if test "$dag_found" = 1; then |
|---|
| 188 | ADD_LIBS="$ADD_LIBS -ldag" |
|---|
| 189 | AC_DEFINE(HAVE_DAG_API, 1, [define if you have a DAG API]) |
|---|
| 190 | AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG support]) |
|---|
| 191 | libtrace_dag=true |
|---|
| 192 | |
|---|
| 193 | AC_DEFINE(DAG_VERSION,30,[defines the DAG driver version]) |
|---|
| 194 | libtrace_dag_version=30 |
|---|
| 195 | fi |
|---|
| 196 | fi |
|---|
| 197 | |
|---|
| 198 | # turn the test part of the next block into a function, so it can be |
|---|
| 199 | # called multiple times for $dag_root, /root/dag, /usr/local/lib |
|---|
| 200 | #dag_drv_v="DAG not present" |
|---|
| 201 | |
|---|
| 202 | # Now check for 2.4 DAG drivers which don't install as cleanly! |
|---|
| 203 | if test "$with_dag" != no -a "$libtrace_dag" = false; then |
|---|
| 204 | AC_MSG_CHECKING(whether we have DAG 2.4 API instead) |
|---|
| 205 | |
|---|
| 206 | if test -r "$dag_root/lib"; then |
|---|
| 207 | dag_lib_dir="$dag_root/lib" |
|---|
| 208 | else |
|---|
| 209 | dag_lib_dir="$dag_root" |
|---|
| 210 | fi |
|---|
| 211 | |
|---|
| 212 | if test -r "$dag_root/include"; then |
|---|
| 213 | dag_tools_dir="$dag_root/tools" |
|---|
| 214 | dag_include_dir="$dag_root/include" |
|---|
| 215 | else |
|---|
| 216 | dag_tools_dir="$dag_root" |
|---|
| 217 | dag_include_dir="$dag_root" |
|---|
| 218 | fi |
|---|
| 219 | |
|---|
| 220 | if test -r "$dag_include_dir/dagapi.h" -a -r "$dag_lib_dir/libdag.a"; |
|---|
| 221 | then |
|---|
| 222 | ADD_INCLS="$ADD_INCLS -I $dag_include_dir" |
|---|
| 223 | ADD_LIBS="$ADD_LIBS -ldag" |
|---|
| 224 | ADD_LDFLAGS="$ADD_LDFLAGS -L$dag_lib_dir" |
|---|
| 225 | DAG_TOOLS_DIR=$dag_tools_dir |
|---|
| 226 | AC_SUBST([DAG_TOOLS_DIR]) |
|---|
| 227 | libtrace_dag=true |
|---|
| 228 | |
|---|
| 229 | AC_DEFINE(HAVE_DAG_API, 1, [define if you have a DAG API]) |
|---|
| 230 | AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG support]) |
|---|
| 231 | AC_DEFINE(DAG_VERSION, 24, [defines the DAG driver version]) |
|---|
| 232 | libtrace_dag_version=24 |
|---|
| 233 | else |
|---|
| 234 | if test "$want_dag" = yes; then |
|---|
| 235 | AC_MSG_ERROR(DAG API not found under directory $dag_root |
|---|
| 236 | ; use --without-dag) |
|---|
| 237 | fi |
|---|
| 238 | libtrace_dag=false |
|---|
| 239 | fi |
|---|
| 240 | AC_MSG_RESULT($libtrace_dag) |
|---|
| 241 | |
|---|
| 242 | fi |
|---|
| 243 | |
|---|
| 244 | AC_CHECK_LIB(z, gzopen) |
|---|
| 245 | |
|---|
| 246 | AM_CONDITIONAL([HAVE_BPF], [test "$ac_cv_have_decl_BIOCSETIF" = yes ]) |
|---|
| 247 | AM_CONDITIONAL([HAVE_DAG], [test "$libtrace_dag" = true]) |
|---|
| 248 | AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag_version" = 24]) |
|---|
| 249 | AM_CONDITIONAL([DAG2_5], [test "$libtrace_dag_version" = 25]) |
|---|
| 250 | AM_CONDITIONAL([DAG3_0], [test "$libtrace_dag_version" = 30]) |
|---|
| 251 | AM_CONDITIONAL([HAVE_ZLIB], [test "$ac_cv_lib_z_gzopen" = yes]) |
|---|
| 252 | AM_CONDITIONAL([HAVE_NETPACKET_PACKET_H], [test "$libtrace_netpacket_packet_h" = true]) |
|---|
| 253 | AM_CONDITIONAL([LIBGDC], [test "$ac_cv_header_gdc_h" = yes]) |
|---|
| 254 | |
|---|
| 255 | # Check for miscellaneous programs |
|---|
| 256 | AC_CHECK_PROG([libtrace_doxygen], [doxygen], [true], [false]) |
|---|
| 257 | |
|---|
| 258 | AM_CONDITIONAL(HAS_DOXYGEN, [test x"$libtrace_doxygen" = xtrue]) |
|---|
| 259 | |
|---|
| 260 | |
|---|
| 261 | AC_SUBST([ADD_LIBS]) |
|---|
| 262 | AC_SUBST([ADD_LDFLAGS]) |
|---|
| 263 | AC_SUBST([ADD_INCLS]) |
|---|
| 264 | AC_SUBST([LTLIBOBJS]) |
|---|
| 265 | AC_SUBST([MANPAGES]) |
|---|
| 266 | AC_SUBST([PACKAGE_VERSION]) |
|---|
| 267 | AC_SUBST([LIBTRACE_MAJOR]) |
|---|
| 268 | AC_SUBST([LIBTRACE_MID]) |
|---|
| 269 | AC_SUBST([LIBTRACE_MINOR]) |
|---|
| 270 | AC_SUBST([DAG_VERSION_NUM]) |
|---|
| 271 | dnl and finally, output our Makefiles |
|---|
| 272 | AC_OUTPUT |
|---|
| 273 | |
|---|
| 274 | reportopt() { |
|---|
| 275 | if test x"$2" = xtrue -o x"$2" = xyes; then |
|---|
| 276 | AC_MSG_NOTICE([$1: Yes]) |
|---|
| 277 | else |
|---|
| 278 | AC_MSG_NOTICE([$1: No]) |
|---|
| 279 | fi |
|---|
| 280 | } |
|---|
| 281 | |
|---|
| 282 | echo |
|---|
| 283 | AC_MSG_NOTICE([Libtrace version $PACKAGE_VERSION]) |
|---|
| 284 | reportopt "Compiled with PCAP 0.8 support" $ac_cv_lib_pcap_pcap_next_ex |
|---|
| 285 | reportopt "Compiled with compressed trace (zlib) support" $ac_cv_lib_z_gzopen |
|---|
| 286 | if test x"$libtrace_dag" = xtrue; then |
|---|
| 287 | if test "$libtrace_dag_version" = 24; then |
|---|
| 288 | AC_MSG_NOTICE([Compiled with DAG support: 2.4]) |
|---|
| 289 | elif test "$libtrace_dag_version" = 30; then |
|---|
| 290 | AC_MSG_NOTICE([Compiled with DAG support: 3.0]) |
|---|
| 291 | else |
|---|
| 292 | AC_MSG_NOTICE([Compiled with DAG support: 2.5]) |
|---|
| 293 | fi |
|---|
| 294 | else |
|---|
| 295 | AC_MSG_NOTICE([Compiled with DAG support: No]) |
|---|
| 296 | fi |
|---|
| 297 | reportopt "Building man pages/documentation" $libtrace_doxygen |
|---|
| 298 | |
|---|