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