source: configure.in @ deab6dc5

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since deab6dc5 was deab6dc5, checked in by Shane Alcock <salcock@…>, 16 years ago

Fixed libtrace_pure checking - if --without-out pure was specified then
the perl code for replacing the HAVE_ATTR_PURE macro was not being
called.

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