| 1 | # Process this file with autoconf to produce a configure script. |
|---|
| 2 | |
|---|
| 3 | LIBTRACE_MAJOR=3 |
|---|
| 4 | LIBTRACE_MID=0 |
|---|
| 5 | LIBTRACE_MINOR=0 |
|---|
| 6 | |
|---|
| 7 | AC_INIT(libtrace,3.0.0,[contact@wand.net.nz],libtrace) |
|---|
| 8 | AC_CONFIG_SRCDIR(lib/trace.c) |
|---|
| 9 | AM_INIT_AUTOMAKE(libtrace,3.0.0) |
|---|
| 10 | |
|---|
| 11 | 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 tools/tracestats/Makefile ]) |
|---|
| 12 | dnl GNU C library |
|---|
| 13 | dnl AC_GNU_SOURCE |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | AM_CONFIG_HEADER(config.h) |
|---|
| 17 | #AC_CONFIG_HEADERS([config.h]) |
|---|
| 18 | dnl Checks for programs. |
|---|
| 19 | AC_PROG_CC |
|---|
| 20 | AC_PROG_CXX |
|---|
| 21 | AC_PROG_INSTALL |
|---|
| 22 | AC_LIBTOOL_DLOPEN |
|---|
| 23 | AC_PROG_LIBTOOL |
|---|
| 24 | |
|---|
| 25 | AC_CONFIG_LIBOBJ_DIR(lib) |
|---|
| 26 | |
|---|
| 27 | # Checks for typedefs, structures, and compiler characteristics. |
|---|
| 28 | AC_C_CONST |
|---|
| 29 | AC_C_INLINE |
|---|
| 30 | AC_C_BIGENDIAN |
|---|
| 31 | AC_TYPE_SIZE_T |
|---|
| 32 | AC_HEADER_TIME |
|---|
| 33 | AC_SYS_LARGEFILE |
|---|
| 34 | |
|---|
| 35 | # Checks for library functions. |
|---|
| 36 | AC_PROG_GCC_TRADITIONAL |
|---|
| 37 | AC_CHECK_FUNCS(socket strdup) |
|---|
| 38 | |
|---|
| 39 | AC_CHECK_SIZEOF([long int]) |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | # Check for various broken functions |
|---|
| 44 | AC_FUNC_MALLOC |
|---|
| 45 | AC_FUNC_REALLOC |
|---|
| 46 | |
|---|
| 47 | # *BSD doesn't have strndup. Currently provide our own. |
|---|
| 48 | AC_REPLACE_FUNCS(strndup) |
|---|
| 49 | |
|---|
| 50 | # Checks for header files. |
|---|
| 51 | AC_HEADER_STDC |
|---|
| 52 | 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) |
|---|
| 53 | 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 ) |
|---|
| 54 | |
|---|
| 55 | AC_CHECK_HEADERS(netinet/in.h) |
|---|
| 56 | AC_CHECK_HEADER(netpacket/packet.h, |
|---|
| 57 | libtrace_netpacket_packet_h=true |
|---|
| 58 | AC_DEFINE(HAVE_NETPACKET_PACKET_H,1,[We have netpacket/packet.h]), |
|---|
| 59 | [libtrace_netpacket_packet_h=false]) |
|---|
| 60 | |
|---|
| 61 | AC_CHECK_HEADER(net/if.h, |
|---|
| 62 | AC_DEFINE(HAVE_NET_IF_H,1,[We have net/if.h]), [], |
|---|
| 63 | [#include <sys/types.h> |
|---|
| 64 | #include <sys/socket.h> |
|---|
| 65 | ]) |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | AC_CHECK_HEADER(netinet/ether.h, |
|---|
| 69 | AC_DEFINE(HAVE_NETINET_ETHER_H,1,[We have netinet/ether.h] |
|---|
| 70 | ), [], |
|---|
| 71 | [ |
|---|
| 72 | #include <sys/types.h> |
|---|
| 73 | #include <sys/socket.h> |
|---|
| 74 | #include <netinet/in.h> |
|---|
| 75 | #include <net/if.h> |
|---|
| 76 | ]) |
|---|
| 77 | |
|---|
| 78 | AC_CHECK_HEADER(netinet/if_ether.h, |
|---|
| 79 | AC_DEFINE(HAVE_NETINET_IF_ETHER_H,1,[We have netinet/if_ether.h]), [], |
|---|
| 80 | [ |
|---|
| 81 | #include <sys/types.h> |
|---|
| 82 | #include <sys/socket.h> |
|---|
| 83 | #include <netinet/in.h> |
|---|
| 84 | #include <net/if.h> |
|---|
| 85 | ]) |
|---|
| 86 | |
|---|
| 87 | AC_CHECK_HEADER(net/if_arp.h, |
|---|
| 88 | AC_DEFINE(HAVE_NET_IF_ARP_H,1,[We have net/if_arp.h]), [], |
|---|
| 89 | [ |
|---|
| 90 | #include <sys/types.h> |
|---|
| 91 | #include <sys/socket.h> |
|---|
| 92 | #include <netinet/in.h> |
|---|
| 93 | #include <net/if.h> |
|---|
| 94 | ]) |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | # Checking for the right bpf header to include |
|---|
| 98 | AC_MSG_CHECKING([where the bpf headers are kept]) |
|---|
| 99 | echo "" |
|---|
| 100 | bpfh=no |
|---|
| 101 | AC_CHECK_HEADER(pcap-bpf.h, |
|---|
| 102 | [AC_DEFINE([HAVE_PCAP_BPF_H]) bpfh=pcap-bpf.h]) |
|---|
| 103 | if test $bpfh = no; then |
|---|
| 104 | AC_CHECK_HEADER(net/bpf.h, |
|---|
| 105 | [AC_DEFINE([HAVE_NET_BPF_H]) bpfh=net/bpf.h]) |
|---|
| 106 | fi |
|---|
| 107 | |
|---|
| 108 | if test $bpfh = no; then |
|---|
| 109 | AC_MSG_RESULT([No BPF headers, compiling without support for BPF filters]) |
|---|
| 110 | AC_DEFINE(HAVE_BPF,0,[Conditional for building bpf support]) |
|---|
| 111 | libtrace_bpf=false |
|---|
| 112 | else |
|---|
| 113 | AC_MSG_RESULT([Using $bpfh]) |
|---|
| 114 | AC_DEFINE(HAVE_BPF,1,[Conditional for building bpf support]) |
|---|
| 115 | libtrace_bpf=true |
|---|
| 116 | fi |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | AC_CHECK_HEADER(gdc.h, |
|---|
| 120 | [AC_DEFINE(HAVE_GDC_H,1,[Conditional for building with libGDC support]) libtrace_gdc=true], |
|---|
| 121 | [AC_DEFINE(HAVE_GDC_H,0,[Conditional for building with libGDC support]) libtrace_gdc=false]) |
|---|
| 122 | |
|---|
| 123 | |
|---|
| 124 | # Check to see if we have libpcap |
|---|
| 125 | AC_CHECK_LIB(pcap,pcap_open_live, |
|---|
| 126 | libtrace_pcap=true, |
|---|
| 127 | libtrace_pcap=false) |
|---|
| 128 | |
|---|
| 129 | if test "$libtrace_pcap" = true; then |
|---|
| 130 | AC_DEFINE(HAVE_PCAP,1,[Conditional for building PCAP support]) |
|---|
| 131 | ADD_LIBS="$ADD_LIBS -lpcap" |
|---|
| 132 | else |
|---|
| 133 | AC_DEFINE(HAVE_PCAP,0,[Conditional for building PCAP support]) |
|---|
| 134 | fi |
|---|
| 135 | |
|---|
| 136 | # Only test for these functions if we have PCAP installed |
|---|
| 137 | if test "$libtrace_pcap" = true; then |
|---|
| 138 | # Earlier versions of pcap don't have pcap_open_dead. EG: the one |
|---|
| 139 | # OpenBSD ships with. Even Debian Woody is more up to date. |
|---|
| 140 | AC_CHECK_LIB(pcap,pcap_open_dead, |
|---|
| 141 | have_pcap_open_dead=true, |
|---|
| 142 | have_pcap_open_dead=false) |
|---|
| 143 | |
|---|
| 144 | if test "$have_pcap_open_dead" = false; then |
|---|
| 145 | AC_REPLACE_FUNCS(pcap_open_dead) |
|---|
| 146 | fi |
|---|
| 147 | |
|---|
| 148 | # Versions of libpcap earlier than 0.8 don't have pcap_dump_flush |
|---|
| 149 | AC_CHECK_LIB(pcap,pcap_dump_flush, |
|---|
| 150 | have_pcap_dump_flush=true, |
|---|
| 151 | have_pcap_dump_flush=false) |
|---|
| 152 | |
|---|
| 153 | if test "$have_pcap_dump_flush" = false; then |
|---|
| 154 | AC_REPLACE_FUNCS(pcap_dump_flush) |
|---|
| 155 | fi |
|---|
| 156 | fi |
|---|
| 157 | |
|---|
| 158 | |
|---|
| 159 | # configure time options for man pages |
|---|
| 160 | AC_ARG_WITH(man, |
|---|
| 161 | AC_HELP_STRING([--with-man], |
|---|
| 162 | [install man pages by default]), |
|---|
| 163 | |
|---|
| 164 | if test "$withval" = yes |
|---|
| 165 | then |
|---|
| 166 | MANPAGES="docs/man/man3/[a-zA-Z]*.3]" |
|---|
| 167 | else |
|---|
| 168 | MANPAGES="" |
|---|
| 169 | fi |
|---|
| 170 | ) |
|---|
| 171 | |
|---|
| 172 | # configure time option for building libpacketdump |
|---|
| 173 | # libpacketdump needs a C++ compiler to build, so we should do some tests |
|---|
| 174 | # at this point to see if one is installed |
|---|
| 175 | libtrace_libpacketdump=true |
|---|
| 176 | AC_ARG_ENABLE(libpacketdump, |
|---|
| 177 | AC_HELP_STRING([--disable-libpacketdump], |
|---|
| 178 | [disable building of libpacketdump (enabled by default). libpacketdump needs a c++ compiler to build] ), |
|---|
| 179 | [ |
|---|
| 180 | if test "$enableval" = no -o "$enableval" = false |
|---|
| 181 | then |
|---|
| 182 | libtrace_libpacketdump=false |
|---|
| 183 | else |
|---|
| 184 | libtrace_libpacketdump=true |
|---|
| 185 | fi |
|---|
| 186 | ], |
|---|
| 187 | [ |
|---|
| 188 | libtrace_libpacketdump=true |
|---|
| 189 | ]) |
|---|
| 190 | |
|---|
| 191 | if test "$libtrace_libpacketdump" = true; then |
|---|
| 192 | AC_LANG_PUSH(C++) |
|---|
| 193 | AC_MSG_CHECKING([if we can compile C++ ]) |
|---|
| 194 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
|---|
| 195 | [[ |
|---|
| 196 | #include <iostream> |
|---|
| 197 | ]])], |
|---|
| 198 | [AC_DEFINE(HAVE_CXX,1,[define to test for presence of a working C++ compiler]) libtrace_cxx=true], |
|---|
| 199 | [AC_DEFINE(HAVE_CXX,0,[define to test for presence of a working C++ compiler]) libtrace_cxx=false]) |
|---|
| 200 | |
|---|
| 201 | AC_MSG_RESULT($libtrace_cxx) |
|---|
| 202 | AC_LANG_POP(C++) |
|---|
| 203 | |
|---|
| 204 | if test "$libtrace_cxx" = false; then |
|---|
| 205 | AC_MSG_ERROR([libpacketdump requested, but no C++ compiler found. Build with --disable-libpacketdump if you wish to continue anyway ]) |
|---|
| 206 | fi |
|---|
| 207 | fi |
|---|
| 208 | |
|---|
| 209 | # configure time option for building the libtrace tools |
|---|
| 210 | # one of the tools requires libpacketdump, so won't build if libpacketdump |
|---|
| 211 | # hasn't also been built |
|---|
| 212 | libtrace_tools=true |
|---|
| 213 | AC_ARG_ENABLE(tools, |
|---|
| 214 | AC_HELP_STRING([--disable-tools], |
|---|
| 215 | [disable building of the tools contained in the tools/ directory]), |
|---|
| 216 | [ |
|---|
| 217 | if test "$enableval" = no -o "$enableval" = false |
|---|
| 218 | then |
|---|
| 219 | libtrace_tools=false |
|---|
| 220 | else |
|---|
| 221 | libtrace_tools=true |
|---|
| 222 | fi |
|---|
| 223 | |
|---|
| 224 | ], |
|---|
| 225 | [ |
|---|
| 226 | libtrace_tools=true |
|---|
| 227 | ]) |
|---|
| 228 | |
|---|
| 229 | # configure time options for use of DAG cards |
|---|
| 230 | # borrowed from libpcap! |
|---|
| 231 | AC_ARG_WITH(dag, |
|---|
| 232 | AC_HELP_STRING([--with-dag[=DIR]], |
|---|
| 233 | [include DAG support (located in directory DIR, if supplied)]), |
|---|
| 234 | [ |
|---|
| 235 | if test "$withval" = no |
|---|
| 236 | then |
|---|
| 237 | want_dag=no |
|---|
| 238 | elif test "$withval" = yes |
|---|
| 239 | then |
|---|
| 240 | want_dag=yes |
|---|
| 241 | dag_root=/root/dag |
|---|
| 242 | else |
|---|
| 243 | want_dag=yes |
|---|
| 244 | dag_root=$withval |
|---|
| 245 | fi |
|---|
| 246 | ],[ |
|---|
| 247 | # |
|---|
| 248 | # Use DAG API if present, otherwise don't |
|---|
| 249 | # |
|---|
| 250 | want_dag=ifpresent |
|---|
| 251 | dag_root=/root/dag/ |
|---|
| 252 | ]) |
|---|
| 253 | |
|---|
| 254 | # turn the test part of the next block into a function, so it can be |
|---|
| 255 | # called multiple times for $dag_root, /root/dag, /usr/local/lib |
|---|
| 256 | libtrace_dag=false |
|---|
| 257 | libtrace_dag2_4=false |
|---|
| 258 | if test "$with_dag" != no; then |
|---|
| 259 | AC_MSG_CHECKING(whether we have DAG API) |
|---|
| 260 | |
|---|
| 261 | if test -r "$dag_root/lib"; then |
|---|
| 262 | dag_lib_dir="$dag_root/lib" |
|---|
| 263 | else |
|---|
| 264 | dag_lib_dir="$dag_root" |
|---|
| 265 | fi |
|---|
| 266 | |
|---|
| 267 | if test -r "$dag_root/tools" -a -r "$dag_root/include"; then |
|---|
| 268 | dag_tools_dir="$dag_root/tools" |
|---|
| 269 | dag_include_dir="$dag_root/include" |
|---|
| 270 | else |
|---|
| 271 | dag_tools_dir="$dag_root" |
|---|
| 272 | dag_include_dir="$dag_root" |
|---|
| 273 | fi |
|---|
| 274 | |
|---|
| 275 | if test -r "$dag_include_dir/dagapi.h" -a -r "$dag_lib_dir/libdag.a"; |
|---|
| 276 | then |
|---|
| 277 | ADD_INCLS="$ADD_INCLS -I $dag_include_dir" |
|---|
| 278 | ADD_LIBS="$ADD_LIBS -ldag" |
|---|
| 279 | ADD_LDFLAGS="$ADD_LDFLAGS -L$dag_lib_dir" |
|---|
| 280 | DAG_TOOLS_DIR=$dag_tools_dir |
|---|
| 281 | AC_SUBST([DAG_TOOLS_DIR]) |
|---|
| 282 | libtrace_dag=true |
|---|
| 283 | |
|---|
| 284 | AC_DEFINE(HAVE_DAG_API, 1, [define if you have a DAG API]) |
|---|
| 285 | AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG support]) |
|---|
| 286 | else |
|---|
| 287 | if test "$want_dag" = yes; then |
|---|
| 288 | AC_MSG_ERROR(DAG API not found under directory $dag_root |
|---|
| 289 | ; use --without-dag) |
|---|
| 290 | fi |
|---|
| 291 | libtrace_dag=false |
|---|
| 292 | fi |
|---|
| 293 | AC_MSG_RESULT($libtrace_dag) |
|---|
| 294 | |
|---|
| 295 | AC_MSG_CHECKING(if we are using DAG 2.4) |
|---|
| 296 | if grep '2.4.' $dag_root/VERSION > /dev/null 2>&1; then |
|---|
| 297 | libtrace_dag2_4=true |
|---|
| 298 | else |
|---|
| 299 | libtrace_dag2_4=false |
|---|
| 300 | fi |
|---|
| 301 | AC_MSG_RESULT($libtrace_dag2_4) |
|---|
| 302 | else |
|---|
| 303 | AC_DEFINE(HAVE_DAG,0,[conditional for building with DAG support]) |
|---|
| 304 | fi |
|---|
| 305 | |
|---|
| 306 | |
|---|
| 307 | |
|---|
| 308 | |
|---|
| 309 | |
|---|
| 310 | AC_ARG_WITH([zlib], |
|---|
| 311 | AC_HELP_STRING([--with-zlib], |
|---|
| 312 | [name of zlib library (default is z)]), |
|---|
| 313 | [ac_cv_use_zlib=$withval], |
|---|
| 314 | [ac_cv_use_zlib=z]) |
|---|
| 315 | |
|---|
| 316 | AC_ARG_WITH([zlib-path], |
|---|
| 317 | AC_HELP_STRING([--with-zlib-path], |
|---|
| 318 | [location of zlib library (default is /usr/lib)]), |
|---|
| 319 | [ac_cv_use_zlib_path=$withval], |
|---|
| 320 | [ac_cv_use_zlib_path=/usr/lib]) |
|---|
| 321 | |
|---|
| 322 | libtrace_zlib=false |
|---|
| 323 | if test "$ac_cv_use_zlib" != no; then |
|---|
| 324 | |
|---|
| 325 | zlib_lib_file="${ac_cv_use_zlib_path}/lib${ac_cv_use_zlib}.so" |
|---|
| 326 | |
|---|
| 327 | # if the library is in /usr/lib/, then just use AC_CHECK_LIB |
|---|
| 328 | if test x"${ac_cv_use_zlib_path}" == x"/usr/lib"; then |
|---|
| 329 | AC_CHECK_LIB(${ac_cv_use_zlib}, gzopen, |
|---|
| 330 | libtrace_zlib=true, |
|---|
| 331 | libtrace_zlib=false) |
|---|
| 332 | else |
|---|
| 333 | ADD_LDFLAGS="$ADD_LDFLAGS -L$ac_cv_use_zlib_path" |
|---|
| 334 | # if it's not in /usr/lib/, check manually. This isn't nice |
|---|
| 335 | # and will probably break. |
|---|
| 336 | if test ! -r "$ac_cv_use_zlib_path" -o ! -r "$zlib_lib_file"; then |
|---|
| 337 | AC_MSG_NOTICE([Cannot find zlib library $zlib_lib_file.]) |
|---|
| 338 | AC_MSG_ERROR([Exiting]); |
|---|
| 339 | else |
|---|
| 340 | libtrace_zlib=true |
|---|
| 341 | fi |
|---|
| 342 | fi |
|---|
| 343 | fi |
|---|
| 344 | |
|---|
| 345 | if test $libtrace_zlib = true; then |
|---|
| 346 | ADD_LIBS="$ADD_LIBS -l$ac_cv_use_zlib" |
|---|
| 347 | AC_DEFINE(HAVE_ZLIB,1,[Conditional for building zlib support]) |
|---|
| 348 | else |
|---|
| 349 | AC_DEFINE(HAVE_ZLIB,0,[Conditional for building zlib support]) |
|---|
| 350 | fi |
|---|
| 351 | |
|---|
| 352 | AM_CONDITIONAL([HAVE_DAG], [test "$libtrace_dag" = true]) |
|---|
| 353 | AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag2_4" = true]) |
|---|
| 354 | AM_CONDITIONAL([HAVE_CXX], [test "$libtrace_cxx" = true]) |
|---|
| 355 | AM_CONDITIONAL([HAVE_ZLIB], [test "$libtrace_zlib" = true]) |
|---|
| 356 | AM_CONDITIONAL([HAVE_NETPACKET_PACKET_H], [test "$libtrace_netpacket_packet_h" = true]) |
|---|
| 357 | AM_CONDITIONAL([LIBPACKETDUMP], [test "$libtrace_libpacketdump" = true]) |
|---|
| 358 | AM_CONDITIONAL([LIBTRACE_TOOLS], [test "$libtrace_tools" = true]) |
|---|
| 359 | AM_CONDITIONAL([LIBGDC], [test "$libtrace_gdc" = true]) |
|---|
| 360 | |
|---|
| 361 | |
|---|
| 362 | # Check for miscellaneous programs |
|---|
| 363 | AC_CHECK_PROG([libtrace_doxygen], [doxygen], [true], [false]) |
|---|
| 364 | |
|---|
| 365 | AM_CONDITIONAL(HAS_DOXYGEN, [test x"$libtrace_doxygen" = xtrue]) |
|---|
| 366 | |
|---|
| 367 | |
|---|
| 368 | AC_SUBST([ADD_LIBS]) |
|---|
| 369 | AC_SUBST([ADD_LDFLAGS]) |
|---|
| 370 | AC_SUBST([ADD_INCLS]) |
|---|
| 371 | AC_SUBST([LTLIBOBJS]) |
|---|
| 372 | AC_SUBST([MANPAGES]) |
|---|
| 373 | |
|---|
| 374 | dnl and finally, output our Makefiles |
|---|
| 375 | AC_OUTPUT |
|---|
| 376 | |
|---|
| 377 | reportopt() { |
|---|
| 378 | if test x"$2" = xtrue -o x"$2" = xyes; then |
|---|
| 379 | AC_MSG_NOTICE([$1: Yes]) |
|---|
| 380 | else |
|---|
| 381 | AC_MSG_NOTICE([$1: No]) |
|---|
| 382 | fi |
|---|
| 383 | } |
|---|
| 384 | |
|---|
| 385 | reportopt "Compiled with BPF filter support" $libtrace_bpf |
|---|
| 386 | reportopt "Compiled with PCAP support" $libtrace_pcap |
|---|
| 387 | reportopt "Compiled with compressed trace (zlib) support" $libtrace_zlib |
|---|
| 388 | reportopt "Compiled with DAG support (libdag)" $libtrace_dag |
|---|
| 389 | reportopt "Compiled with DAG support (DAG 2.4)" $libtrace_dag2_4 |
|---|
| 390 | reportopt "Building man pages/documentation" $libtrace_doxygen |
|---|
| 391 | reportopt "Building libpacketdump" $libtrace_libpacketdump |
|---|
| 392 | reportopt "Building tools/ directory" $libtrace_tools |
|---|
| 393 | |
|---|