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