1 dnl @(#) $Header: aclocal.m4,v 1.32 96/07/23 22:55:48 leres Exp $ (LBL)
3 dnl Copyright (c) 1995, 1996
4 dnl The Regents of the University of California. All rights reserved.
6 dnl Redistribution and use in source and binary forms, with or without
7 dnl modification, are permitted provided that: (1) source code distributions
8 dnl retain the above copyright notice and this paragraph in its entirety, (2)
9 dnl distributions including binary code include the above copyright notice and
10 dnl this paragraph in its entirety in the documentation or other materials
11 dnl provided with the distribution, and (3) all advertising materials mentioning
12 dnl features or use of this software display the following acknowledgement:
13 dnl ``This product includes software developed by the University of California,
14 dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
15 dnl the University nor the names of its contributors may be used to endorse
16 dnl or promote products derived from this software without specific prior
17 dnl written permission.
18 dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19 dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20 dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 dnl LBL autoconf macros
26 dnl Determine which compiler we're using (cc or gcc)
27 dnl If using gcc, determine the version number
28 dnl If using cc, require that it support ansi prototypes
29 dnl If using gcc, use -O2 (otherwise use -O)
30 dnl If using cc, explicitly specify /usr/local/include
34 dnl AC_LBL_C_INIT(copt, incls)
43 AC_DEFUN(AC_LBL_C_INIT,
46 if test -z "$CC" ; then
50 AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
51 if test $SHLICC2 = yes ; then
59 if test $ac_cv_prog_gcc = yes ; then
60 if test "$SHLICC2" = yes ; then
64 AC_MSG_CHECKING(gcc version)
65 AC_CACHE_VAL(ac_cv_gcc_vers,
66 ac_cv_gcc_vers=`$CC -v 2>&1 | \
67 sed -n -e '$s/.* //' -e '$s/\..*//p'`)
68 AC_MSG_RESULT($ac_cv_gcc_vers)
69 if test $ac_cv_gcc_vers -gt 1 ; then
74 AC_MSG_CHECKING(that $CC handles ansi prototypes)
75 AC_CACHE_VAL(ac_cv_cc_ansi_prototypes,
77 [#include <sys/types.h>],
78 [int frob(int, char *)],
79 ac_cv_cc_ansi_prototypes=yes,
80 ac_cv_cc_ansi_prototypes=no))
81 AC_MSG_RESULT($ac_cv_cc_ansi_prototypes)
82 if test $ac_cv_cc_ansi_prototypes = no ; then
86 AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE))
88 CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
89 AC_CACHE_VAL(ac_cv_cc_hpux_cc_aa,
91 [#include <sys/types.h>],
92 [int frob(int, char *)],
93 ac_cv_cc_hpux_cc_aa=yes,
94 ac_cv_cc_hpux_cc_aa=no))
95 AC_MSG_RESULT($ac_cv_cc_hpux_cc_aa)
96 if test $ac_cv_cc_hpux_cc_aa = no ; then
97 AC_MSG_ERROR(see the INSTALL for more info)
100 V_CCOPT="-Aa $V_CCOPT"
101 AC_DEFINE(_HPUX_SOURCE)
105 AC_MSG_CHECKING(for SINIX ansi compiler ($CC -kansi))
106 savedcflags="$CFLAGS"
108 AC_CACHE_VAL(ac_cv_cc_sinix_kansi,
110 [#include <sys/types.h>],
111 [int frob(int, char *)],
112 ac_cv_cc_sinix_kansi=yes,
113 ac_cv_cc_sinix_kansi=no))
114 AC_MSG_RESULT($ac_cv_cc_sinix_kansi)
115 if test $ac_cv_cc_sinix_kansi = no ; then
116 AC_MSG_ERROR(see the INSTALL for more info)
118 CFLAGS="$savedcflags"
119 V_CCOPT="-kansi $V_CCOPT"
123 AC_MSG_ERROR(see the INSTALL for more info)
127 $2=-I/usr/local/include
132 V_CCOPT="$V_CCOPT -xansi -signed -g3"
136 V_CCOPT="$V_CCOPT -g3"
140 AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
141 AC_CACHE_VAL(ac_cv_cc_const_proto,
143 [#include <sys/types.h>],
144 [struct a { int b; };
145 void c(const struct a *)],
146 ac_cv_cc_const_proto=yes,
147 ac_cv_cc_const_proto=no))
148 AC_MSG_RESULT($ac_cv_cc_const_proto)
149 if test $ac_cv_cc_const_proto = no ; then
158 dnl Use pfopen.c if available and pfopen() not in standard libraries
160 dnl Look for libpcap in ..
161 dnl Use the installed libpcap if there is no local version
165 dnl AC_LBL_LIBPCAP(pcapdep, incls)
170 dnl $2 (incls appended)
173 AC_DEFUN(AC_LBL_LIBPCAP,
174 [pfopen=/usr/examples/packetfilter/pfopen.c
175 if test -f $pfopen ; then
176 AC_CHECK_FUNCS(pfopen)
177 if test $ac_cv_func_pfopen = "no" ; then
178 AC_MSG_RESULT(Using $pfopen)
182 AC_MSG_CHECKING(for local pcap library)
184 places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \
185 egrep '/libpcap-[[0-9]]*\.[[0-9]]*(\.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
186 for dir in ../libpcap $places libpcap ; do
187 if test -r $dir/pcap.c ; then
188 libpcap=$dir/libpcap.a
190 dnl continue and select the last one that exists
193 if test $libpcap = FAIL ; then
194 AC_MSG_RESULT(not found)
195 AC_CHECK_LIB(pcap, main, libpcap="-lpcap")
196 if test $libpcap = FAIL ; then
197 AC_MSG_ERROR(see the INSTALL doc for more info)
202 AC_MSG_RESULT($libpcap)
204 LIBS="$libpcap $LIBS"])
207 dnl Define RETSIGTYPE and RETSIGVAL
211 dnl AC_LBL_TYPE_SIGNAL
215 dnl RETSIGTYPE (defined)
216 dnl RETSIGVAL (defined)
218 AC_DEFUN(AC_LBL_TYPE_SIGNAL,
220 if test "$ac_cv_type_signal" = void ; then
221 AC_DEFINE(RETSIGVAL,)
223 AC_DEFINE(RETSIGVAL,(0))
228 AC_DEFINE(_BSD_SIGNALS)
232 AC_CHECK_FUNCS(sigset)
233 if test $ac_cv_func_sigset = yes ; then
234 AC_DEFINE(signal, sigset)
240 dnl If using gcc, see if fixincludes should be run
244 dnl AC_LBL_FIXINCLUDES
246 AC_DEFUN(AC_LBL_FIXINCLUDES,
247 [if test $ac_cv_prog_gcc = yes ; then
248 AC_MSG_CHECKING(if fixincludes is needed)
249 AC_CACHE_VAL(ac_cv_gcc_fixincludes,
252 * This generates a "duplicate case value" when fixincludes
255 # include <sys/types.h>
256 # include <sys/time.h>
257 # include <sys/ioctl.h>
258 # ifdef HAVE_SYS_IOCCOM_H
259 # include <sys/ioccom.h>
265 ac_cv_gcc_fixincludes=yes,
266 ac_cv_gcc_fixincludes=no))
267 AC_MSG_RESULT($ac_cv_gcc_fixincludes)
268 if test $ac_cv_gcc_fixincludes = no ; then
269 # Don't cache failure
270 unset ac_cv_gcc_fixincludes
271 AC_MSG_ERROR(see the INSTALL for more info)
276 dnl Check for flex, default to lex
277 dnl Require flex 2.4 or higher
278 dnl Check for bison, default to yacc
279 dnl Default to lex/yacc if both flex and bison are not available
280 dnl Define the yy prefix string if using flex and bison
284 dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
289 dnl $2 (yacc appended)
290 dnl $3 (optional flex and bison -P prefix)
292 AC_DEFUN(AC_LBL_LEX_AND_YACC,
293 [AC_CHECK_PROGS($1, flex, lex)
294 if test "$$1" = flex ; then
295 # The -V flag was added in 2.4
296 AC_MSG_CHECKING(for flex 2.4 or higher)
297 AC_CACHE_VAL(ac_cv_flex_v24,
298 if flex -V >/dev/null 2>&1; then
303 AC_MSG_RESULT($ac_cv_flex_v24)
304 if test $ac_cv_flex_v24 = no ; then
305 s="2.4 or higher required"
306 AC_MSG_WARN(ignoring obsolete flex executable ($s))
310 AC_CHECK_PROGS($2, bison, yacc)
311 if test "$$2" = bison ; then
314 if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
315 AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
319 if test "$$1" = flex -a -n "$3" ; then
325 dnl Checks to see if union wait is used with WEXITSTATUS()
329 dnl AC_LBL_UNION_WAIT
333 dnl DECLWAITSTATUS (defined)
335 AC_DEFUN(AC_LBL_UNION_WAIT,
336 [AC_MSG_CHECKING(if union wait is used)
337 AC_CACHE_VAL(ac_cv_union_wait,
339 # include <sys/types.h>
340 # include <sys/wait.h>],
342 u_int i = WEXITSTATUS(status);
343 u_int j = waitpid(0, &status, 0);],
345 ac_cv_union_wait=yes))
346 AC_MSG_RESULT($ac_cv_union_wait)
347 if test $ac_cv_union_wait = yes ; then
348 AC_DEFINE(DECLWAITSTATUS,union wait)
350 AC_DEFINE(DECLWAITSTATUS,int)
354 dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
358 dnl AC_LBL_SOCKADDR_SA_LEN
362 dnl HAVE_SOCKADDR_SA_LEN (defined)
364 AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
365 [AC_MSG_CHECKING(if sockaddr struct has sa_len member)
366 AC_CACHE_VAL(ac_cv_sockaddr_has_sa_len,
368 # include <sys/types.h>
369 # include <sys/socket.h>],
370 [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
371 ac_cv_sockaddr_has_sa_len=yes,
372 ac_cv_sockaddr_has_sa_len=no))
373 AC_MSG_RESULT($ac_cv_sockaddr_has_sa_len)
374 if test $ac_cv_sockaddr_has_sa_len = yes ; then
375 AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
379 dnl Checks to see if -R is used
383 dnl AC_LBL_HAVE_RUN_PATH
387 dnl ac_cv_have_run_path (yes or no)
389 AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
390 [AC_MSG_CHECKING(for ${CC-cc} -R)
391 AC_CACHE_VAL(ac_cv_have_run_path,
392 [echo 'main(){}' > conftest.c
393 ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
394 if test ! -s conftest.out ; then
395 ac_cv_have_run_path=yes
397 ac_cv_have_run_path=no
400 AC_MSG_RESULT($ac_cv_have_run_path)
404 dnl Checks to see if unaligned memory accesses fail
408 dnl AC_LBL_UNALIGNED_ACCESS
412 dnl LBL_ALIGN (DEFINED)
414 AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
415 [AC_MSG_CHECKING(if unaligned accesses fail)
416 AC_CACHE_VAL(ac_cv_unaligned_fail,
417 [case "$target_cpu" in
419 alpha|hp*|mips|sparc)
420 ac_cv_unaligned_fail=yes
424 cat >conftest.c <<EOF
425 # include <sys/types.h>
426 # include <sys/wait.h>
428 unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
433 /* avoid "core dumped" message */
439 pid = waitpid(pid, &status, 0);
442 exit(!WIFEXITED(status));
445 i = *(unsigned int *)&a[1];
450 ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
451 conftest.c $LIBS >/dev/null 2>&1
452 if test ! -x conftest ; then
453 dnl failed to compile for some reason
454 ac_cv_unaligned_fail=yes
456 ./conftest >conftest.out
457 if test ! -s conftest.out ; then
458 ac_cv_unaligned_fail=yes
460 ac_cv_unaligned_fail=no
463 rm -f conftest* core core.conftest
466 AC_MSG_RESULT($ac_cv_unaligned_fail)
467 if test $ac_cv_unaligned_fail = yes ; then
472 dnl If using gcc and the file .devel exists:
473 dnl Compile with -g (if supported) and -Wall
474 dnl If using gcc 2, do extra prototype checking
475 dnl If an os prototype include exists, symlink os-proto.h to it
479 dnl AC_LBL_DEVEL(copt)
483 dnl $1 (copt appended)
484 dnl HAVE_OS_PROTO_H (defined)
485 dnl os-proto.h (symlinked)
487 AC_DEFUN(AC_LBL_DEVEL,
489 if test $ac_cv_prog_gcc = yes -a -f .devel ; then
490 if test $ac_cv_prog_gcc_g = yes ; then
494 if test $ac_cv_gcc_vers -gt 1 ; then
495 $1="$$1 -Wmissing-prototypes -Wstrict-prototypes"
497 os=`echo $target_os | sed -e 's/\([[0-9]]\)[[0-9.]][[0-9.]]*$/\1/'`
499 if test -f $name ; then
500 ln -s $name os-proto.h
501 AC_DEFINE(HAVE_OS_PROTO_H)
503 AC_MSG_WARN(can't find $name)