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 | CFLAGS="$CFLAGS -Wall -Wextra -Wmissing-prototypes -O2" |
---|
57 | # We assume that gcc knows about -fvisibility and friends, as I can't see |
---|
58 | # a good easy way of testing for it here. |
---|
59 | LIBCFLAGS="$CFLAGS" |
---|
60 | LIBCFLAGS="$LIBCFLAGS -DLT_BUILDING_DLL=1" |
---|
61 | LIBCFLAGS="$LIBCFLAGS -fvisibility=hidden" |
---|
62 | fi |
---|
63 | |
---|
64 | AC_PROG_LIBTOOL |
---|
65 | |
---|
66 | # Checks for library functions. |
---|
67 | AC_PROG_GCC_TRADITIONAL |
---|
68 | AC_CHECK_FUNCS(socket strdup strlcpy strcasecmp strncasecmp snprintf) |
---|
69 | |
---|
70 | AC_CHECK_SIZEOF([long int]) |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | # Check for various broken functions |
---|
75 | AC_FUNC_MALLOC |
---|
76 | AC_FUNC_REALLOC |
---|
77 | |
---|
78 | # *BSD doesn't have strndup. Currently provide our own. |
---|
79 | AC_REPLACE_FUNCS(strndup) |
---|
80 | |
---|
81 | # Checks for header files. |
---|
82 | AC_HEADER_STDC |
---|
83 | 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) |
---|
84 | |
---|
85 | AC_CHECK_HEADERS(netinet/in.h) |
---|
86 | AC_CHECK_HEADERS(netpacket/packet.h,[ |
---|
87 | libtrace_netpacket_packet_h=true |
---|
88 | AC_DEFINE(HAVE_NETPACKET_PACKET_H,1,[has net]) |
---|
89 | ]) |
---|
90 | AC_CHECK_HEADER(net/if.h, |
---|
91 | AC_DEFINE(HAVE_NET_IF_H,1,[has net/if.h header]),,[ |
---|
92 | #include <sys/types.h> |
---|
93 | #include <sys/socket.h> |
---|
94 | ]) |
---|
95 | |
---|
96 | AC_CHECK_HEADER(netinet/ether.h, |
---|
97 | AC_DEFINE(HAVE_NETINET_ETHER_H,1,[has netinet/ether.h header]),,[ |
---|
98 | #include <sys/types.h> |
---|
99 | #include <sys/socket.h> |
---|
100 | #include <netinet/in.h> |
---|
101 | #include <net/if.h> |
---|
102 | ]) |
---|
103 | |
---|
104 | AC_CHECK_HEADER(netinet/if_ether.h, |
---|
105 | AC_DEFINE(HAVE_NETINET_IF_ETHER_H,1,[has netinet/if_ether.h]),,[ |
---|
106 | #include <sys/types.h> |
---|
107 | #include <sys/socket.h> |
---|
108 | #include <netinet/in.h> |
---|
109 | #include <net/if.h> |
---|
110 | ]) |
---|
111 | |
---|
112 | AC_CHECK_HEADER(net/if_arp.h, |
---|
113 | AC_DEFINE(HAVE_NET_IF_ARP_H,1,[has net/if_arp.h]),,[ |
---|
114 | #include <sys/types.h> |
---|
115 | #include <sys/socket.h> |
---|
116 | #include <netinet/in.h> |
---|
117 | #include <net/if.h> |
---|
118 | ]) |
---|
119 | |
---|
120 | # Checking for the right bpf header to include |
---|
121 | AC_CHECK_HEADER(pcap-bpf.h) |
---|
122 | AC_CHECK_HEADER(net/bpf.h) |
---|
123 | AC_CHECK_HEADER(gdc.h,AC_DEFINE(HAVE_LIBGDC,1,[has gdc.h])) |
---|
124 | |
---|
125 | # Check to see if we have libdl - *BSD has built-in libdl |
---|
126 | AC_CHECK_LIB(dl, dlopen) |
---|
127 | # check pcap |
---|
128 | AC_CHECK_LIB(pcap,pcap_next_ex,pcapfound=1,pcapfound=0) |
---|
129 | #AC_CHECK_LIB(pcap,pcap_next_ex) |
---|
130 | #AC_REPLACE_FUNCS(pcap_open_dead) |
---|
131 | #AC_REPLACE_FUNCS(pcap_dump_flush) |
---|
132 | #AC_REPLACE_FUNCS(pcap_next_ex) |
---|
133 | AC_CHECK_FUNCS(pcap_inject pcap_sendpacket pcap_setnonblock) |
---|
134 | AC_CHECK_DECLS([BIOCSETIF],,,[ |
---|
135 | #include <sys/types.h> |
---|
136 | #include <sys/time.h> |
---|
137 | #include <sys/ioctl.h> |
---|
138 | #include <net/bpf.h> |
---|
139 | ]) |
---|
140 | |
---|
141 | # configure time options for man pages |
---|
142 | AC_ARG_WITH(man, |
---|
143 | AS_HELP_STRING(--with-man,install man pages by default),[ |
---|
144 | if test "$withval" = yes |
---|
145 | then |
---|
146 | MANPAGES="docs/man/man3/[a-zA-Z]*.3" |
---|
147 | else |
---|
148 | MANPAGES="" |
---|
149 | fi |
---|
150 | ]) |
---|
151 | |
---|
152 | AC_PROG_CXX |
---|
153 | |
---|
154 | if test "$pcapfound" = 0; then |
---|
155 | 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) |
---|
156 | else |
---|
157 | ADD_LIBS="$ADD_LIBS -lpcap" |
---|
158 | AC_DEFINE([HAVE_LIBPCAP],1,[compile with libpcap support]) |
---|
159 | AC_DEFINE([HAVE_BPF_FILTER],1,[compile with bpf filter support]) |
---|
160 | fi |
---|
161 | |
---|
162 | # configure time options for use of DAG cards |
---|
163 | # borrowed from libpcap! |
---|
164 | AC_ARG_WITH(dag, |
---|
165 | AS_HELP_STRING(--with-dag[=DIR],include DAG live capture support (located in directory DIR, if supplied)), |
---|
166 | [ |
---|
167 | if test "$withval" = no |
---|
168 | then |
---|
169 | want_dag=no |
---|
170 | elif test "$withval" = yes |
---|
171 | then |
---|
172 | want_dag=yes |
---|
173 | dag_root=/usr/local/dag |
---|
174 | else |
---|
175 | want_dag=yes |
---|
176 | dag_root=$withval |
---|
177 | fi |
---|
178 | ],[ |
---|
179 | # |
---|
180 | # Use DAG API if present, otherwise don't |
---|
181 | # |
---|
182 | want_dag=ifpresent |
---|
183 | dag_root=/usr/local/dag |
---|
184 | ]) |
---|
185 | |
---|
186 | # DAG 3.0 actually puts header files and shared libraries into sensible |
---|
187 | # places now, so we should be able to do a simple CHECK_LIB to see if |
---|
188 | # they're there! |
---|
189 | |
---|
190 | # Addendum: It turns out DAG 2.5 does this too, so we'll match DAG2.5 in here |
---|
191 | # also. This isn't such a bad thing, the DAG2.5 API is essentially the same as |
---|
192 | # DAG 3.0 and libtrace will use the same format_dagXX source for both |
---|
193 | libtrace_dag=false |
---|
194 | libtrace_dag_version=none |
---|
195 | |
---|
196 | if test "$with_dag" != no; then |
---|
197 | AC_CHECK_LIB(dag, dag_open, dag_found=1, dag_found=0) |
---|
198 | if test "$dag_found" = 1; then |
---|
199 | ADD_LIBS="$ADD_LIBS -ldag" |
---|
200 | AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API]) |
---|
201 | AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support]) |
---|
202 | libtrace_dag=true |
---|
203 | |
---|
204 | AC_DEFINE(DAG_VERSION,30,[defines the DAG driver version]) |
---|
205 | libtrace_dag_version=30 |
---|
206 | fi |
---|
207 | fi |
---|
208 | |
---|
209 | # turn the test part of the next block into a function, so it can be |
---|
210 | # called multiple times for $dag_root, /root/dag, /usr/local/lib |
---|
211 | dag_drv_v="DAG not present" |
---|
212 | |
---|
213 | # Now check for 2.4 DAG drivers which don't install as cleanly! |
---|
214 | if test "$with_dag" != no -a "$libtrace_dag" = false; then |
---|
215 | AC_MSG_CHECKING(whether we have DAG 2.4 API instead) |
---|
216 | |
---|
217 | if test -r "$dag_root/lib"; then |
---|
218 | dag_lib_dir="$dag_root/lib" |
---|
219 | else |
---|
220 | dag_lib_dir="$dag_root" |
---|
221 | fi |
---|
222 | |
---|
223 | if test -r "$dag_root/include"; then |
---|
224 | dag_tools_dir="$dag_root/tools" |
---|
225 | dag_include_dir="$dag_root/include" |
---|
226 | else |
---|
227 | dag_tools_dir="$dag_root" |
---|
228 | dag_include_dir="$dag_root" |
---|
229 | fi |
---|
230 | |
---|
231 | if test -r "$dag_include_dir/dagapi.h" -a -r "$dag_lib_dir/libdag.a"; |
---|
232 | then |
---|
233 | ADD_INCLS="$ADD_INCLS -I $dag_include_dir" |
---|
234 | ADD_LIBS="$ADD_LIBS -ldag" |
---|
235 | ADD_LDFLAGS="$ADD_LDFLAGS -L$dag_lib_dir" |
---|
236 | DAG_TOOLS_DIR=$dag_tools_dir |
---|
237 | AC_SUBST([DAG_TOOLS_DIR]) |
---|
238 | libtrace_dag=true |
---|
239 | |
---|
240 | AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API]) |
---|
241 | AC_DEFINE(HAVE_DAG,1,[conditional for building with DAG live capture support]) |
---|
242 | AC_DEFINE(DAG_VERSION, 24, [defines the DAG driver version]) |
---|
243 | libtrace_dag_version=24 |
---|
244 | else |
---|
245 | if test "$want_dag" = yes; then |
---|
246 | AC_MSG_ERROR(DAG API not found under directory $dag_root |
---|
247 | ; use --without-dag) |
---|
248 | fi |
---|
249 | libtrace_dag=false |
---|
250 | fi |
---|
251 | AC_MSG_RESULT($libtrace_dag) |
---|
252 | |
---|
253 | fi |
---|
254 | |
---|
255 | # Try to determine the DAG driver version |
---|
256 | if test x"$libtrace_dag" = xtrue; then |
---|
257 | dag_drv_v="Unknown" |
---|
258 | files=`locate /usr/*dag*/VERSION` |
---|
259 | file_count=0 |
---|
260 | |
---|
261 | for i in $files; do |
---|
262 | if $file_count > 0; then |
---|
263 | dag_drv_v="Indeterminate" |
---|
264 | break |
---|
265 | fi |
---|
266 | dag_drv_v=`cat $i` |
---|
267 | file_count=$file_count+1 |
---|
268 | done |
---|
269 | fi |
---|
270 | DAG_VERSION_NUM=$dag_drv_v |
---|
271 | |
---|
272 | |
---|
273 | AC_CHECK_LIB(z, deflate) |
---|
274 | AC_CHECK_LIB(bz2, BZ2_bzDecompressInit) |
---|
275 | AC_CHECK_LIB(lzo2, lzo1x_1_compress) |
---|
276 | AC_CHECK_LIB(pthread, pthread_create) |
---|
277 | AC_SEARCH_LIBS(mvprintw, ncurses, [], [ AC_MSG_ERROR([NCurses library not available]) ]) |
---|
278 | |
---|
279 | AM_CONDITIONAL([HAVE_BPF_CAPTURE], [test "$ac_cv_have_decl_BIOCSETIF" = yes ]) |
---|
280 | AM_CONDITIONAL([HAVE_DAG], [test "$libtrace_dag" = true]) |
---|
281 | AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag_version" = 24]) |
---|
282 | AM_CONDITIONAL([DAG2_5], [test "$libtrace_dag_version" = 25]) |
---|
283 | AM_CONDITIONAL([DAG3_0], [test "$libtrace_dag_version" = 30]) |
---|
284 | AM_CONDITIONAL([HAVE_ZLIB], [test "$ac_cv_lib_z_deflate" = yes]) |
---|
285 | AM_CONDITIONAL([HAVE_BZLIB], [test "$ac_cv_lib_bz2_BZ2_bzDecompressInit" = yes]) |
---|
286 | AM_CONDITIONAL([HAVE_LZO], [test "$ac_cv_lib_lzo2_lzo1x_1_compress" = yes]) |
---|
287 | AM_CONDITIONAL([HAVE_NETPACKET_PACKET_H], [test "$libtrace_netpacket_packet_h" = true]) |
---|
288 | AM_CONDITIONAL([HAVE_LIBGDC], [test "$ac_cv_header_gdc_h" = yes]) |
---|
289 | |
---|
290 | # Check for miscellaneous programs |
---|
291 | AC_CHECK_PROG([libtrace_doxygen], [doxygen], [true], [false]) |
---|
292 | |
---|
293 | AM_CONDITIONAL(HAS_DOXYGEN, [test x"$libtrace_doxygen" = xtrue]) |
---|
294 | |
---|
295 | AC_SUBST([ADD_LIBS]) |
---|
296 | AC_SUBST([ADD_LDFLAGS]) |
---|
297 | AC_SUBST([ADD_INCLS]) |
---|
298 | AC_SUBST([LTLIBOBJS]) |
---|
299 | AC_SUBST([MANPAGES]) |
---|
300 | AC_SUBST([PACKAGE_VERSION]) |
---|
301 | AC_SUBST([LIBTRACE_MAJOR]) |
---|
302 | AC_SUBST([LIBTRACE_MID]) |
---|
303 | AC_SUBST([LIBTRACE_MINOR]) |
---|
304 | AC_SUBST([DAG_VERSION_NUM]) |
---|
305 | AC_SUBST([HAVE_BPF_CAPTURE]) |
---|
306 | AC_SUBST([HAVE_LIBGDC]) |
---|
307 | AC_SUBST([LIBCFLAGS]) |
---|
308 | dnl and finally, output our Makefiles |
---|
309 | AC_OUTPUT |
---|
310 | |
---|
311 | reportopt() { |
---|
312 | if test x"$2" = xtrue -o x"$2" = xyes; then |
---|
313 | AC_MSG_NOTICE([$1: Yes]) |
---|
314 | else |
---|
315 | AC_MSG_NOTICE([$1: No]) |
---|
316 | fi |
---|
317 | } |
---|
318 | |
---|
319 | echo |
---|
320 | AC_MSG_NOTICE([Libtrace version $PACKAGE_VERSION]) |
---|
321 | reportopt "Compiled with PCAP 0.8 support" $ac_cv_lib_pcap_pcap_next_ex |
---|
322 | reportopt "Compiled with compressed trace (zlib) support" $ac_cv_lib_z_deflate |
---|
323 | reportopt "Compiled with compressed trace (bz2) support" $ac_cv_lib_bz2_BZ2_bzDecompressInit |
---|
324 | reportopt "Compiled with compressed trace (lzo write only) support" $ac_cv_lib_lzo2_lzo1x_1_compress |
---|
325 | if test x"$libtrace_dag" = xtrue; then |
---|
326 | if test "$libtrace_dag_version" = 24; then |
---|
327 | AC_MSG_NOTICE([Compiled with DAG live capture support: 2.4]) |
---|
328 | elif test "$libtrace_dag_version" = 30; then |
---|
329 | AC_MSG_NOTICE([Compiled with DAG live capture support: 3.0]) |
---|
330 | else |
---|
331 | AC_MSG_NOTICE([Compiled with DAG live capture support: 2.5]) |
---|
332 | fi |
---|
333 | else |
---|
334 | AC_MSG_NOTICE([Compiled with DAG live capture support: No]) |
---|
335 | fi |
---|
336 | reportopt "Building man pages/documentation" $libtrace_doxygen |
---|
337 | |
---|
338 | echo |
---|
339 | ac_cv_errcount=0; |
---|
340 | if test -z "$YACC"; then |
---|
341 | AC_MSG_WARN(bison or yacc not found. Please install bison before continuing) |
---|
342 | ac_cv_errcount=$((ac_cv_errcount + 1)) |
---|
343 | fi |
---|
344 | |
---|
345 | if test -z "$LEXLIB"; then |
---|
346 | AC_MSG_WARN(flex or lex not found. Please install flex before continuing) |
---|
347 | ac_cv_errcount=$((ac_cv_errcount + 1)) |
---|
348 | fi |
---|
349 | |
---|
350 | if test $ac_cv_errcount -gt 0; then |
---|
351 | AC_MSG_ERROR(Critical packages are missing and compilation will fail. Please install the packages listed above and rerun ./configure) |
---|
352 | fi |
---|
353 | |
---|