1 dnl @(#) $Header: acsite.m4,v 1.41 96/11/29 15:30:40 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)
44 dnl XXX need to add test to make sure ac_prog_cc hasn't been called
45 AC_DEFUN(AC_LBL_C_INIT,
49 if test "${CFLAGS+set}" = set; then
52 if test -z "$CC" ; then
56 AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
57 if test $SHLICC2 = yes ; then
65 if test $ac_cv_prog_gcc = yes ; then
66 if test "$SHLICC2" = yes ; then
70 AC_MSG_CHECKING(gcc version)
71 AC_CACHE_VAL(ac_cv_gcc_vers,
72 ac_cv_gcc_vers=`$CC -v 2>&1 | \
73 sed -n -e '$s/.* //' -e '$s/\..*//p'`)
74 AC_MSG_RESULT($ac_cv_gcc_vers)
75 if test $ac_cv_gcc_vers -gt 1 ; then
80 AC_MSG_CHECKING(that $CC handles ansi prototypes)
81 AC_CACHE_VAL(ac_cv_cc_ansi_prototypes,
83 [#include <sys/types.h>],
84 [int frob(int, char *)],
85 ac_cv_cc_ansi_prototypes=yes,
86 ac_cv_cc_ansi_prototypes=no))
87 AC_MSG_RESULT($ac_cv_cc_ansi_prototypes)
88 if test $ac_cv_cc_ansi_prototypes = no ; then
92 AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE))
94 CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
95 AC_CACHE_VAL(ac_cv_cc_hpux_cc_aa,
97 [#include <sys/types.h>],
98 [int frob(int, char *)],
99 ac_cv_cc_hpux_cc_aa=yes,
100 ac_cv_cc_hpux_cc_aa=no))
101 AC_MSG_RESULT($ac_cv_cc_hpux_cc_aa)
102 if test $ac_cv_cc_hpux_cc_aa = no ; then
103 AC_MSG_ERROR(see the INSTALL for more info)
105 CFLAGS="$savedcflags"
106 V_CCOPT="-Aa $V_CCOPT"
107 AC_DEFINE(_HPUX_SOURCE)
111 AC_MSG_ERROR(see the INSTALL for more info)
115 $2=-I/usr/local/include
120 V_CCOPT="$V_CCOPT -xansi -signed -g3"
124 V_CCOPT="$V_CCOPT -g3"
128 AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
129 AC_CACHE_VAL(ac_cv_cc_const_proto,
131 [#include <sys/types.h>],
132 [struct a { int b; };
133 void c(const struct a *)],
134 ac_cv_cc_const_proto=yes,
135 ac_cv_cc_const_proto=no))
136 AC_MSG_RESULT($ac_cv_cc_const_proto)
137 if test $ac_cv_cc_const_proto = no ; then
146 dnl Use pfopen.c if available and pfopen() not in standard libraries
148 dnl Look for libpcap in ..
149 dnl Use the installed libpcap if there is no local version
153 dnl AC_LBL_LIBPCAP(pcapdep, incls)
158 dnl $2 (incls appended)
161 AC_DEFUN(AC_LBL_LIBPCAP,
162 [pfopen=/usr/examples/packetfilter/pfopen.c
163 if test -f $pfopen ; then
164 AC_CHECK_FUNCS(pfopen)
165 if test $ac_cv_func_pfopen = "no" ; then
166 AC_MSG_RESULT(Using $pfopen)
170 AC_MSG_CHECKING(for local pcap library)
173 places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \
174 egrep '/libpcap-[[0-9]]*\.[[0-9]]*(\.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
175 for dir in $places ../libpcap libpcap ; do
176 basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//'`
177 if test $lastdir = $basedir ; then
178 dnl skip alphas when an actual release is present
182 if test -r $dir/pcap.c ; then
183 libpcap=$dir/libpcap.a
185 dnl continue and select the last one that exists
188 if test $libpcap = FAIL ; then
189 AC_MSG_RESULT(not found)
190 AC_CHECK_LIB(pcap, main, libpcap="-lpcap")
191 if test $libpcap = FAIL ; then
192 AC_MSG_ERROR(see the INSTALL doc for more info)
197 AC_MSG_RESULT($libpcap)
199 LIBS="$libpcap $LIBS"])
202 dnl Define RETSIGTYPE and RETSIGVAL
206 dnl AC_LBL_TYPE_SIGNAL
210 dnl RETSIGTYPE (defined)
211 dnl RETSIGVAL (defined)
213 AC_DEFUN(AC_LBL_TYPE_SIGNAL,
215 if test "$ac_cv_type_signal" = void ; then
216 AC_DEFINE(RETSIGVAL,)
218 AC_DEFINE(RETSIGVAL,(0))
223 AC_DEFINE(_BSD_SIGNALS)
227 AC_CHECK_FUNCS(sigset)
228 if test $ac_cv_func_sigset = yes ; then
229 AC_DEFINE(signal, sigset)
235 dnl If using gcc, see if fixincludes should be run
239 dnl AC_LBL_FIXINCLUDES
241 AC_DEFUN(AC_LBL_FIXINCLUDES,
242 [if test $ac_cv_prog_gcc = yes ; then
243 AC_MSG_CHECKING(if fixincludes is needed)
244 AC_CACHE_VAL(ac_cv_gcc_fixincludes,
247 * This generates a "duplicate case value" when fixincludes
250 # include <sys/types.h>
251 # include <sys/time.h>
252 # include <sys/ioctl.h>
253 # ifdef HAVE_SYS_IOCCOM_H
254 # include <sys/ioccom.h>
260 ac_cv_gcc_fixincludes=yes,
261 ac_cv_gcc_fixincludes=no))
262 AC_MSG_RESULT($ac_cv_gcc_fixincludes)
263 if test $ac_cv_gcc_fixincludes = no ; then
264 # Don't cache failure
265 unset ac_cv_gcc_fixincludes
266 AC_MSG_ERROR(see the INSTALL for more info)
271 dnl Check for flex, default to lex
272 dnl Require flex 2.4 or higher
273 dnl Check for bison, default to yacc
274 dnl Default to lex/yacc if both flex and bison are not available
275 dnl Define the yy prefix string if using flex and bison
279 dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
284 dnl $2 (yacc appended)
285 dnl $3 (optional flex and bison -P prefix)
287 AC_DEFUN(AC_LBL_LEX_AND_YACC,
288 [AC_CHECK_PROGS($1, flex, lex)
289 if test "$$1" = flex ; then
290 # The -V flag was added in 2.4
291 AC_MSG_CHECKING(for flex 2.4 or higher)
292 AC_CACHE_VAL(ac_cv_flex_v24,
293 if flex -V >/dev/null 2>&1; then
298 AC_MSG_RESULT($ac_cv_flex_v24)
299 if test $ac_cv_flex_v24 = no ; then
300 s="2.4 or higher required"
301 AC_MSG_WARN(ignoring obsolete flex executable ($s))
305 AC_CHECK_PROGS($2, bison, yacc)
306 if test "$$2" = bison ; then
309 if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
310 AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
314 if test "$$1" = flex -a -n "$3" ; then
320 dnl Checks to see if union wait is used with WEXITSTATUS()
324 dnl AC_LBL_UNION_WAIT
328 dnl DECLWAITSTATUS (defined)
330 AC_DEFUN(AC_LBL_UNION_WAIT,
331 [AC_MSG_CHECKING(if union wait is used)
332 AC_CACHE_VAL(ac_cv_union_wait,
334 # include <sys/types.h>
335 # include <sys/wait.h>],
337 u_int i = WEXITSTATUS(status);
338 u_int j = waitpid(0, &status, 0);],
340 ac_cv_union_wait=yes))
341 AC_MSG_RESULT($ac_cv_union_wait)
342 if test $ac_cv_union_wait = yes ; then
343 AC_DEFINE(DECLWAITSTATUS,union wait)
345 AC_DEFINE(DECLWAITSTATUS,int)
349 dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
353 dnl AC_LBL_SOCKADDR_SA_LEN
357 dnl HAVE_SOCKADDR_SA_LEN (defined)
359 AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
360 [AC_MSG_CHECKING(if sockaddr struct has sa_len member)
361 AC_CACHE_VAL(ac_cv_sockaddr_has_sa_len,
363 # include <sys/types.h>
364 # include <sys/socket.h>],
365 [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
366 ac_cv_sockaddr_has_sa_len=yes,
367 ac_cv_sockaddr_has_sa_len=no))
368 AC_MSG_RESULT($ac_cv_sockaddr_has_sa_len)
369 if test $ac_cv_sockaddr_has_sa_len = yes ; then
370 AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
374 dnl Checks to see if -R is used
378 dnl AC_LBL_HAVE_RUN_PATH
382 dnl ac_cv_have_run_path (yes or no)
384 AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
385 [AC_MSG_CHECKING(for ${CC-cc} -R)
386 AC_CACHE_VAL(ac_cv_have_run_path,
387 [echo 'main(){}' > conftest.c
388 ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
389 if test ! -s conftest.out ; then
390 ac_cv_have_run_path=yes
392 ac_cv_have_run_path=no
395 AC_MSG_RESULT($ac_cv_have_run_path)
399 dnl Checks to see if unaligned memory accesses fail
403 dnl AC_LBL_UNALIGNED_ACCESS
407 dnl LBL_ALIGN (DEFINED)
409 AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
410 [AC_MSG_CHECKING(if unaligned accesses fail)
411 AC_CACHE_VAL(ac_cv_unaligned_fail,
412 [case "$target_cpu" in
414 alpha|hp*|mips|sparc)
415 ac_cv_unaligned_fail=yes
419 cat >conftest.c <<EOF
420 # include <sys/types.h>
421 # include <sys/wait.h>
423 unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
428 /* avoid "core dumped" message */
434 pid = waitpid(pid, &status, 0);
437 exit(!WIFEXITED(status));
440 i = *(unsigned int *)&a[[1]];
445 ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
446 conftest.c $LIBS >/dev/null 2>&1
447 if test ! -x conftest ; then
448 dnl failed to compile for some reason
449 ac_cv_unaligned_fail=yes
451 ./conftest >conftest.out
452 if test ! -s conftest.out ; then
453 ac_cv_unaligned_fail=yes
455 ac_cv_unaligned_fail=no
458 rm -f conftest* core core.conftest
461 AC_MSG_RESULT($ac_cv_unaligned_fail)
462 if test $ac_cv_unaligned_fail = yes ; then
467 dnl If using gcc and the file .devel exists:
468 dnl Compile with -g (if supported) and -Wall
469 dnl If using gcc 2, do extra prototype checking
470 dnl If an os prototype include exists, symlink os-proto.h to it
474 dnl AC_LBL_DEVEL(copt)
478 dnl $1 (copt appended)
479 dnl HAVE_OS_PROTO_H (defined)
480 dnl os-proto.h (symlinked)
482 AC_DEFUN(AC_LBL_DEVEL,
484 if test "${LBL_CFLAGS+set}" = set; then
485 $1="$$1 ${LBL_CFLAGS}"
487 if test $ac_cv_prog_gcc = yes -a -f .devel ; then
488 if test "${LBL_CFLAGS+set}" != set; then
489 if test "$ac_cv_prog_cc_g" = yes ; then
493 if test $ac_cv_gcc_vers -gt 1 ; then
494 $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)