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.7],[contact@wand.net.nz],[libtrace]) |
---|
7 | |
---|
8 | LIBTRACE_MAJOR=3 |
---|
9 | LIBTRACE_MID=0 |
---|
10 | LIBTRACE_MINOR=7 |
---|
11 | |
---|
12 | AC_CONFIG_MACRO_DIR([m4]) |
---|
13 | AC_CONFIG_SRCDIR(lib/trace.c) |
---|
14 | AM_INIT_AUTOMAKE |
---|
15 | m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) |
---|
16 | |
---|
17 | AC_DEFINE([LIBTRACE_MAJOR],${LIBTRACE_MAJOR},[libtrace major version]) |
---|
18 | AC_DEFINE([LIBTRACE_MID],${LIBTRACE_MID},[libtrace mid version]) |
---|
19 | AC_DEFINE([LIBTRACE_MINOR],${LIBTRACE_MINOR},[libtrace minor version]) |
---|
20 | |
---|
21 | AC_CONFIG_FILES([Makefile lib/Makefile docs/Makefile libpacketdump/Makefile |
---|
22 | tools/Makefile tools/traceanon/Makefile tools/tracepktdump/Makefile |
---|
23 | tools/tracemerge/Makefile tools/tracereport/Makefile |
---|
24 | tools/tracertstats/Makefile tools/tracesplit/Makefile |
---|
25 | tools/tracestats/Makefile tools/tracetop/Makefile |
---|
26 | tools/tracereplay/Makefile tools/tracediff/Makefile |
---|
27 | examples/Makefile examples/skeleton/Makefile examples/rate/Makefile |
---|
28 | examples/stats/Makefile examples/tutorial/Makefile |
---|
29 | docs/libtrace.doxygen |
---|
30 | lib/libtrace.h |
---|
31 | ]) |
---|
32 | dnl GNU C library |
---|
33 | dnl AC_GNU_SOURCE |
---|
34 | |
---|
35 | |
---|
36 | AM_CONFIG_HEADER([config.h]) |
---|
37 | dnl Checks for programs. |
---|
38 | AC_PROG_CC |
---|
39 | AC_PROG_CXX |
---|
40 | AC_PROG_INSTALL |
---|
41 | dnl AC_PROG_YACC |
---|
42 | AC_CHECK_PROGS(YACC, 'bison -y' byacc yacc) |
---|
43 | AM_PROG_LEX |
---|
44 | |
---|
45 | AC_CONFIG_LIBOBJ_DIR(lib) |
---|
46 | |
---|
47 | # Checks for typedefs, structures, and compiler characteristics. |
---|
48 | AC_C_CONST |
---|
49 | AC_C_INLINE |
---|
50 | AC_C_BIGENDIAN |
---|
51 | AC_TYPE_SIZE_T |
---|
52 | AC_HEADER_TIME |
---|
53 | AC_SYS_LARGEFILE |
---|
54 | |
---|
55 | if test "$GCC" = "yes"; then |
---|
56 | |
---|
57 | gcc_version=`gcc -dumpversion` |
---|
58 | |
---|
59 | # This is probably not the most reliable way to test whether our |
---|
60 | # compiler supports visibility, but it's better than nothing |
---|
61 | # |
---|
62 | # According to the gcc wiki - http://gcc.gnu.org/wiki/Visibility - |
---|
63 | # visibility is supported in gcc 4.0 or later, so we just need to |
---|
64 | # check the major version number |
---|
65 | |
---|
66 | major=${gcc_version%\.*\.*} |
---|
67 | |
---|
68 | if test "$major" -lt 4; then |
---|
69 | vis=no |
---|
70 | else |
---|
71 | vis=yes |
---|
72 | fi |
---|
73 | |
---|
74 | CFLAGS="$CFLAGS -Wall -Wextra -Wmissing-prototypes -O2" |
---|
75 | CXXFLAGS="$CXXFLAGS -Wall -Wextra -O2" |
---|
76 | LIBCFLAGS="$CFLAGS" |
---|
77 | LIBCFLAGS="$LIBCFLAGS -DLT_BUILDING_DLL=1" |
---|
78 | LIBCXXFLAGS="$CXXFLAGS" |
---|
79 | LIBCXXFLAGS="$CXXFLAGS -DLT_BUILDING_DLL=1" |
---|
80 | |
---|
81 | if test "$vis" = "yes"; then |
---|
82 | LIBCFLAGS="$LIBCFLAGS -fvisibility=hidden" |
---|
83 | LIBCXXFLAGS="$CXXFLAGS -fvisibility=hidden" |
---|
84 | fi |
---|
85 | fi |
---|
86 | |
---|
87 | AC_PROG_LIBTOOL |
---|
88 | |
---|
89 | # Checks for library functions. |
---|
90 | AC_PROG_GCC_TRADITIONAL |
---|
91 | AC_CHECK_FUNCS(socket strdup strlcpy strcasecmp strncasecmp snprintf) |
---|
92 | |
---|
93 | AC_CHECK_SIZEOF([long int]) |
---|
94 | |
---|
95 | |
---|
96 | |
---|
97 | # Check for various broken functions |
---|
98 | AC_FUNC_MALLOC |
---|
99 | AC_FUNC_REALLOC |
---|
100 | |
---|
101 | # *BSD doesn't have strndup. Currently provide our own. |
---|
102 | AC_REPLACE_FUNCS(strndup) |
---|
103 | |
---|
104 | # Checks for header files. |
---|
105 | AC_HEADER_STDC |
---|
106 | 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 sys/prctl.h) |
---|
107 | |
---|
108 | AC_CHECK_HEADERS(netinet/in.h) |
---|
109 | AC_CHECK_HEADERS(netpacket/packet.h,[ |
---|
110 | libtrace_netpacket_packet_h=true |
---|
111 | AC_DEFINE(HAVE_NETPACKET_PACKET_H,1,[has net]) |
---|
112 | ]) |
---|
113 | AC_CHECK_HEADER(net/if.h, |
---|
114 | AC_DEFINE(HAVE_NET_IF_H,1,[has net/if.h header]),,[ |
---|
115 | #include <sys/types.h> |
---|
116 | #include <sys/socket.h> |
---|
117 | ]) |
---|
118 | |
---|
119 | AC_CHECK_HEADER(netinet/ether.h, |
---|
120 | AC_DEFINE(HAVE_NETINET_ETHER_H,1,[has netinet/ether.h header]),,[ |
---|
121 | #include <sys/types.h> |
---|
122 | #include <sys/socket.h> |
---|
123 | #include <netinet/in.h> |
---|
124 | #include <net/if.h> |
---|
125 | ]) |
---|
126 | |
---|
127 | AC_CHECK_HEADER(netinet/if_ether.h, |
---|
128 | AC_DEFINE(HAVE_NETINET_IF_ETHER_H,1,[has netinet/if_ether.h]),,[ |
---|
129 | #include <sys/types.h> |
---|
130 | #include <sys/socket.h> |
---|
131 | #include <netinet/in.h> |
---|
132 | #include <net/if.h> |
---|
133 | ]) |
---|
134 | |
---|
135 | AC_CHECK_HEADER(net/if_arp.h, |
---|
136 | AC_DEFINE(HAVE_NET_IF_ARP_H,1,[has net/if_arp.h]),,[ |
---|
137 | #include <sys/types.h> |
---|
138 | #include <sys/socket.h> |
---|
139 | #include <netinet/in.h> |
---|
140 | #include <net/if.h> |
---|
141 | ]) |
---|
142 | |
---|
143 | # Checking for the right bpf header to include |
---|
144 | AC_CHECK_HEADER(pcap-bpf.h) |
---|
145 | AC_CHECK_HEADER(net/bpf.h) |
---|
146 | AC_CHECK_HEADER(gdc.h,AC_DEFINE(HAVE_LIBGDC,1,[has gdc.h])) |
---|
147 | |
---|
148 | # Check to see if we have libdl - *BSD has built-in libdl |
---|
149 | AC_CHECK_LIB(dl, dlopen) |
---|
150 | # check pcap |
---|
151 | AC_CHECK_LIB(pcap,pcap_next_ex,pcapfound=1,pcapfound=0) |
---|
152 | #AC_CHECK_LIB(pcap,pcap_next_ex) |
---|
153 | #AC_REPLACE_FUNCS(pcap_open_dead) |
---|
154 | #AC_REPLACE_FUNCS(pcap_dump_flush) |
---|
155 | #AC_REPLACE_FUNCS(pcap_next_ex) |
---|
156 | AC_CHECK_FUNCS(pcap_inject pcap_sendpacket pcap_setnonblock) |
---|
157 | AC_CHECK_DECLS([BIOCSETIF],,,[ |
---|
158 | #include <sys/types.h> |
---|
159 | #include <sys/time.h> |
---|
160 | #include <sys/ioctl.h> |
---|
161 | #include <net/bpf.h> |
---|
162 | ]) |
---|
163 | |
---|
164 | # configure time options for man pages |
---|
165 | AC_ARG_WITH(man, |
---|
166 | AS_HELP_STRING(--with-man,install man pages by default),[ |
---|
167 | if test "$withval" = yes |
---|
168 | then |
---|
169 | MANPAGES="docs/man/man3/[a-zA-Z]*.3" |
---|
170 | else |
---|
171 | MANPAGES="" |
---|
172 | fi |
---|
173 | ]) |
---|
174 | |
---|
175 | AC_PROG_CXX |
---|
176 | |
---|
177 | if test "$pcapfound" = 0; then |
---|
178 | 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) |
---|
179 | else |
---|
180 | ADD_LIBS="$ADD_LIBS -lpcap" |
---|
181 | AC_DEFINE([HAVE_LIBPCAP],1,[compile with libpcap support]) |
---|
182 | AC_DEFINE([HAVE_BPF_FILTER],1,[compile with bpf filter support]) |
---|
183 | fi |
---|
184 | |
---|
185 | # configure time options for use of DAG cards |
---|
186 | # borrowed from libpcap! |
---|
187 | AC_ARG_WITH(dag, |
---|
188 | AS_HELP_STRING(--with-dag[=DIR],include DAG live capture support (located in directory DIR, if supplied)), |
---|
189 | [ |
---|
190 | if test "$withval" = no |
---|
191 | then |
---|
192 | want_dag=no |
---|
193 | elif test "$withval" = yes |
---|
194 | then |
---|
195 | want_dag=yes |
---|
196 | dag_root=/usr/local/dag |
---|
197 | else |
---|
198 | want_dag=yes |
---|
199 | dag_root=$withval |
---|
200 | fi |
---|
201 | ],[ |
---|
202 | # |
---|
203 | # Use DAG API if present, otherwise don't |
---|
204 | # |
---|
205 | want_dag=ifpresent |
---|
206 | dag_root=/usr/local/dag |
---|
207 | ]) |
---|
208 | |
---|
209 | # DAG 3.0 actually puts header files and shared libraries into sensible |
---|
210 | # places now, so we should be able to do a simple CHECK_LIB to see if |
---|
211 | # they're there! |
---|
212 | |
---|
213 | # Addendum: It turns out DAG 2.5 does this too, so we'll match DAG2.5 in here |
---|
214 | # also. This isn't such a bad thing, the DAG2.5 API is essentially the same as |
---|
215 | # DAG 3.0 and libtrace will use the same format_dagXX source for both |
---|
216 | libtrace_dag=false |
---|
217 | libtrace_dag_version=none |
---|
218 | |
---|
219 | if test "$with_dag" != no; then |
---|
220 | AC_CHECK_LIB(dag, dag_open, dag_found=1, dag_found=0) |
---|
221 | if test "$dag_found" = 1; then |
---|
222 | ADD_LIBS="$ADD_LIBS -ldag" |
---|
223 | AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API]) |
---|
224 | AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support]) |
---|
225 | libtrace_dag=true |
---|
226 | |
---|
227 | AC_DEFINE(DAG_VERSION,30,[defines the DAG driver version]) |
---|
228 | libtrace_dag_version=30 |
---|
229 | fi |
---|
230 | fi |
---|
231 | |
---|
232 | # turn the test part of the next block into a function, so it can be |
---|
233 | # called multiple times for $dag_root, /root/dag, /usr/local/lib |
---|
234 | dag_drv_v="DAG not present" |
---|
235 | |
---|
236 | # Now check for 2.4 DAG drivers which don't install as cleanly! |
---|
237 | if test "$with_dag" != no -a "$libtrace_dag" = false; then |
---|
238 | AC_MSG_CHECKING(whether we have DAG 2.4 API instead) |
---|
239 | |
---|
240 | if test -r "$dag_root/lib"; then |
---|
241 | dag_lib_dir="$dag_root/lib" |
---|
242 | else |
---|
243 | dag_lib_dir="$dag_root" |
---|
244 | fi |
---|
245 | |
---|
246 | if test -r "$dag_root/include"; then |
---|
247 | dag_tools_dir="$dag_root/tools" |
---|
248 | dag_include_dir="$dag_root/include" |
---|
249 | else |
---|
250 | dag_tools_dir="$dag_root" |
---|
251 | dag_include_dir="$dag_root" |
---|
252 | fi |
---|
253 | |
---|
254 | if test -r "$dag_include_dir/dagapi.h" -a -r "$dag_lib_dir/libdag.a"; |
---|
255 | then |
---|
256 | ADD_INCLS="$ADD_INCLS -I $dag_include_dir" |
---|
257 | ADD_LIBS="$ADD_LIBS -ldag" |
---|
258 | ADD_LDFLAGS="$ADD_LDFLAGS -L$dag_lib_dir" |
---|
259 | DAG_TOOLS_DIR=$dag_tools_dir |
---|
260 | AC_SUBST([DAG_TOOLS_DIR]) |
---|
261 | libtrace_dag=true |
---|
262 | |
---|
263 | AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API]) |
---|
264 | AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support]) |
---|
265 | AC_DEFINE(DAG_VERSION, 24, [defines the DAG driver version]) |
---|
266 | libtrace_dag_version=24 |
---|
267 | else |
---|
268 | if test "$want_dag" = yes; then |
---|
269 | AC_MSG_ERROR(DAG API not found under directory $dag_root |
---|
270 | ; use --without-dag) |
---|
271 | fi |
---|
272 | libtrace_dag=false |
---|
273 | fi |
---|
274 | AC_MSG_RESULT($libtrace_dag) |
---|
275 | |
---|
276 | fi |
---|
277 | |
---|
278 | # Try to determine the DAG driver version |
---|
279 | if test x"$libtrace_dag" = xtrue; then |
---|
280 | dag_drv_v="Unknown" |
---|
281 | files=`locate /usr/*dag*/VERSION` |
---|
282 | file_count=0 |
---|
283 | |
---|
284 | for i in $files; do |
---|
285 | if $file_count > 0; then |
---|
286 | dag_drv_v="Indeterminate" |
---|
287 | break |
---|
288 | fi |
---|
289 | dag_drv_v=`cat $i` |
---|
290 | file_count=$file_count+1 |
---|
291 | done |
---|
292 | fi |
---|
293 | DAG_VERSION_NUM=$dag_drv_v |
---|
294 | |
---|
295 | |
---|
296 | AC_CHECK_LIB(z, deflate) |
---|
297 | AC_CHECK_LIB(bz2, BZ2_bzDecompressInit) |
---|
298 | AC_CHECK_LIB(lzo2, lzo1x_1_compress) |
---|
299 | AC_CHECK_LIB(pthread, pthread_create) |
---|
300 | AC_SEARCH_LIBS(mvprintw, ncurses, [], [ AC_MSG_ERROR([NCurses library not available]) ]) |
---|
301 | |
---|
302 | AC_ARG_WITH([llvm], |
---|
303 | [AC_HELP_STRING([--with-llvm], |
---|
304 | [support Just In Time compiler])], |
---|
305 | use_llvm="yes", |
---|
306 | use_llvm="check") |
---|
307 | |
---|
308 | AC_PATH_PROG(llvm_config, llvm-config) |
---|
309 | |
---|
310 | if (test "$use_llvm" != "no"); then |
---|
311 | AC_PATH_PROG(LLVM_CONFIG, llvm-config, no) |
---|
312 | if test "$LLVM_CONFIG" = "no" ; then |
---|
313 | AC_MSG_NOTICE([Unable to find llvm-config. JIT support disabled.]) |
---|
314 | JIT=no |
---|
315 | else |
---|
316 | LIBCXXFLAGS="`$LLVM_CONFIG --cxxflags` $CXXFLAGS" |
---|
317 | ADD_LIBS="$ADD_LIBS `$LLVM_CONFIG --libs all`"; |
---|
318 | LDFLAGS="`$LLVM_CONFIG --ldflags` $LDFLAGS"; |
---|
319 | JIT=yes |
---|
320 | AC_DEFINE(HAVE_LLVM, 1, [Set to 1 if you have LLVM installed]) |
---|
321 | fi |
---|
322 | fi |
---|
323 | |
---|
324 | |
---|
325 | AM_CONDITIONAL([HAVE_BPF_CAPTURE], [test "$ac_cv_have_decl_BIOCSETIF" = yes ]) |
---|
326 | AM_CONDITIONAL([HAVE_DAG], [test "$libtrace_dag" = true]) |
---|
327 | AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag_version" = 24]) |
---|
328 | AM_CONDITIONAL([DAG2_5], [test "$libtrace_dag_version" = 25]) |
---|
329 | AM_CONDITIONAL([DAG3_0], [test "$libtrace_dag_version" = 30]) |
---|
330 | AM_CONDITIONAL([HAVE_ZLIB], [test "$ac_cv_lib_z_deflate" = yes]) |
---|
331 | AM_CONDITIONAL([HAVE_BZLIB], [test "$ac_cv_lib_bz2_BZ2_bzDecompressInit" = yes]) |
---|
332 | AM_CONDITIONAL([HAVE_LZO], [test "$ac_cv_lib_lzo2_lzo1x_1_compress" = yes]) |
---|
333 | AM_CONDITIONAL([HAVE_NETPACKET_PACKET_H], [test "$libtrace_netpacket_packet_h" = true]) |
---|
334 | AM_CONDITIONAL([HAVE_LIBGDC], [test "$ac_cv_header_gdc_h" = yes]) |
---|
335 | AM_CONDITIONAL([HAVE_LLVM], [test "x$LLVM_CONFIG" != "xno" ]) |
---|
336 | |
---|
337 | # Check for miscellaneous programs |
---|
338 | AC_CHECK_PROG([libtrace_doxygen], [doxygen], [true], [false]) |
---|
339 | |
---|
340 | AM_CONDITIONAL(HAS_DOXYGEN, [test x"$libtrace_doxygen" = xtrue]) |
---|
341 | |
---|
342 | AC_SUBST([ADD_LIBS]) |
---|
343 | AC_SUBST([ADD_LDFLAGS]) |
---|
344 | AC_SUBST([ADD_INCLS]) |
---|
345 | AC_SUBST([LTLIBOBJS]) |
---|
346 | AC_SUBST([MANPAGES]) |
---|
347 | AC_SUBST([PACKAGE_VERSION]) |
---|
348 | AC_SUBST([LIBTRACE_MAJOR]) |
---|
349 | AC_SUBST([LIBTRACE_MID]) |
---|
350 | AC_SUBST([LIBTRACE_MINOR]) |
---|
351 | AC_SUBST([DAG_VERSION_NUM]) |
---|
352 | AC_SUBST([HAVE_BPF_CAPTURE]) |
---|
353 | AC_SUBST([HAVE_LIBGDC]) |
---|
354 | AC_SUBST([HAVE_LLVM]) |
---|
355 | AC_SUBST([LIBCFLAGS]) |
---|
356 | AC_SUBST([LIBCXXFLAGS]) |
---|
357 | dnl and finally, output our Makefiles |
---|
358 | AC_OUTPUT |
---|
359 | |
---|
360 | reportopt() { |
---|
361 | if test x"$2" = xtrue -o x"$2" = xyes; then |
---|
362 | AC_MSG_NOTICE([$1: Yes]) |
---|
363 | else |
---|
364 | AC_MSG_NOTICE([$1: No]) |
---|
365 | fi |
---|
366 | } |
---|
367 | |
---|
368 | echo |
---|
369 | AC_MSG_NOTICE([Libtrace version $PACKAGE_VERSION]) |
---|
370 | reportopt "Compiled with PCAP 0.8 support" $ac_cv_lib_pcap_pcap_next_ex |
---|
371 | reportopt "Compiled with compressed trace (zlib) support" $ac_cv_lib_z_deflate |
---|
372 | reportopt "Compiled with compressed trace (bz2) support" $ac_cv_lib_bz2_BZ2_bzDecompressInit |
---|
373 | reportopt "Compiled with compressed trace (lzo write only) support" $ac_cv_lib_lzo2_lzo1x_1_compress |
---|
374 | if test x"$libtrace_dag" = xtrue; then |
---|
375 | if test "$libtrace_dag_version" = 24; then |
---|
376 | AC_MSG_NOTICE([Compiled with DAG live capture support: 2.4]) |
---|
377 | elif test "$libtrace_dag_version" = 30; then |
---|
378 | AC_MSG_NOTICE([Compiled with DAG live capture support: 3.0]) |
---|
379 | else |
---|
380 | AC_MSG_NOTICE([Compiled with DAG live capture support: 2.5]) |
---|
381 | fi |
---|
382 | else |
---|
383 | AC_MSG_NOTICE([Compiled with DAG live capture support: No]) |
---|
384 | fi |
---|
385 | reportopt "Compiled with LLVM BPF JIT support" $JIT |
---|
386 | reportopt "Building man pages/documentation" $libtrace_doxygen |
---|
387 | |
---|
388 | echo |
---|
389 | ac_cv_errcount=0; |
---|
390 | if test -z "$YACC"; then |
---|
391 | AC_MSG_WARN(bison or yacc not found. Please install bison before continuing) |
---|
392 | ac_cv_errcount=$((ac_cv_errcount + 1)) |
---|
393 | fi |
---|
394 | |
---|
395 | if test -z "$LEXLIB"; then |
---|
396 | AC_MSG_WARN(flex or lex not found. Please install flex before continuing) |
---|
397 | ac_cv_errcount=$((ac_cv_errcount + 1)) |
---|
398 | fi |
---|
399 | |
---|
400 | if test $ac_cv_errcount -gt 0; then |
---|
401 | AC_MSG_ERROR(Critical packages are missing and compilation will fail. Please install the packages listed above and rerun ./configure) |
---|
402 | fi |
---|
403 | |
---|