1 dnl @(#) $Header: acsite.m4,v 1.38 96/09/26 21:18:41 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_ERROR(see the INSTALL for more info)
109 $2=-I/usr/local/include
114 V_CCOPT="$V_CCOPT -xansi -signed -g3"
118 V_CCOPT="$V_CCOPT -g3"
122 AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
123 AC_CACHE_VAL(ac_cv_cc_const_proto,
125 [#include <sys/types.h>],
126 [struct a { int b; };
127 void c(const struct a *)],
128 ac_cv_cc_const_proto=yes,
129 ac_cv_cc_const_proto=no))
130 AC_MSG_RESULT($ac_cv_cc_const_proto)
131 if test $ac_cv_cc_const_proto = no ; then
140 dnl Use pfopen.c if available and pfopen() not in standard libraries
142 dnl Look for libpcap in ..
143 dnl Use the installed libpcap if there is no local version
147 dnl AC_LBL_LIBPCAP(pcapdep, incls)
152 dnl $2 (incls appended)
155 AC_DEFUN(AC_LBL_LIBPCAP,
156 [pfopen=/usr/examples/packetfilter/pfopen.c
157 if test -f $pfopen ; then
158 AC_CHECK_FUNCS(pfopen)
159 if test $ac_cv_func_pfopen = "no" ; then
160 AC_MSG_RESULT(Using $pfopen)
164 AC_MSG_CHECKING(for local pcap library)
167 places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \
168 egrep '/libpcap-[[0-9]]*\.[[0-9]]*(\.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
169 for dir in $places ../libpcap libpcap ; do
170 basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//'`
171 if test $lastdir = $basedir ; then
172 dnl skip alphas when an actual release is present
176 if test -r $dir/pcap.c ; then
177 libpcap=$dir/libpcap.a
179 dnl continue and select the last one that exists
182 if test $libpcap = FAIL ; then
183 AC_MSG_RESULT(not found)
184 AC_CHECK_LIB(pcap, main, libpcap="-lpcap")
185 if test $libpcap = FAIL ; then
186 AC_MSG_ERROR(see the INSTALL doc for more info)
191 AC_MSG_RESULT($libpcap)
193 LIBS="$libpcap $LIBS"])
196 dnl Define RETSIGTYPE and RETSIGVAL
200 dnl AC_LBL_TYPE_SIGNAL
204 dnl RETSIGTYPE (defined)
205 dnl RETSIGVAL (defined)
207 AC_DEFUN(AC_LBL_TYPE_SIGNAL,
209 if test "$ac_cv_type_signal" = void ; then
210 AC_DEFINE(RETSIGVAL,)
212 AC_DEFINE(RETSIGVAL,(0))
217 AC_DEFINE(_BSD_SIGNALS)
221 AC_CHECK_FUNCS(sigset)
222 if test $ac_cv_func_sigset = yes ; then
223 AC_DEFINE(signal, sigset)
229 dnl If using gcc, see if fixincludes should be run
233 dnl AC_LBL_FIXINCLUDES
235 AC_DEFUN(AC_LBL_FIXINCLUDES,
236 [if test $ac_cv_prog_gcc = yes ; then
237 AC_MSG_CHECKING(if fixincludes is needed)
238 AC_CACHE_VAL(ac_cv_gcc_fixincludes,
241 * This generates a "duplicate case value" when fixincludes
244 # include <sys/types.h>
245 # include <sys/time.h>
246 # include <sys/ioctl.h>
247 # ifdef HAVE_SYS_IOCCOM_H
248 # include <sys/ioccom.h>
254 ac_cv_gcc_fixincludes=yes,
255 ac_cv_gcc_fixincludes=no))
256 AC_MSG_RESULT($ac_cv_gcc_fixincludes)
257 if test $ac_cv_gcc_fixincludes = no ; then
258 # Don't cache failure
259 unset ac_cv_gcc_fixincludes
260 AC_MSG_ERROR(see the INSTALL for more info)
265 dnl Check for flex, default to lex
266 dnl Require flex 2.4 or higher
267 dnl Check for bison, default to yacc
268 dnl Default to lex/yacc if both flex and bison are not available
269 dnl Define the yy prefix string if using flex and bison
273 dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
278 dnl $2 (yacc appended)
279 dnl $3 (optional flex and bison -P prefix)
281 AC_DEFUN(AC_LBL_LEX_AND_YACC,
282 [AC_CHECK_PROGS($1, flex, lex)
283 if test "$$1" = flex ; then
284 # The -V flag was added in 2.4
285 AC_MSG_CHECKING(for flex 2.4 or higher)
286 AC_CACHE_VAL(ac_cv_flex_v24,
287 if flex -V >/dev/null 2>&1; then
292 AC_MSG_RESULT($ac_cv_flex_v24)
293 if test $ac_cv_flex_v24 = no ; then
294 s="2.4 or higher required"
295 AC_MSG_WARN(ignoring obsolete flex executable ($s))
299 AC_CHECK_PROGS($2, bison, yacc)
300 if test "$$2" = bison ; then
303 if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
304 AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
308 if test "$$1" = flex -a -n "$3" ; then
314 dnl Checks to see if union wait is used with WEXITSTATUS()
318 dnl AC_LBL_UNION_WAIT
322 dnl DECLWAITSTATUS (defined)
324 AC_DEFUN(AC_LBL_UNION_WAIT,
325 [AC_MSG_CHECKING(if union wait is used)
326 AC_CACHE_VAL(ac_cv_union_wait,
328 # include <sys/types.h>
329 # include <sys/wait.h>],
331 u_int i = WEXITSTATUS(status);
332 u_int j = waitpid(0, &status, 0);],
334 ac_cv_union_wait=yes))
335 AC_MSG_RESULT($ac_cv_union_wait)
336 if test $ac_cv_union_wait = yes ; then
337 AC_DEFINE(DECLWAITSTATUS,union wait)
339 AC_DEFINE(DECLWAITSTATUS,int)
343 dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
347 dnl AC_LBL_SOCKADDR_SA_LEN
351 dnl HAVE_SOCKADDR_SA_LEN (defined)
353 AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
354 [AC_MSG_CHECKING(if sockaddr struct has sa_len member)
355 AC_CACHE_VAL(ac_cv_sockaddr_has_sa_len,
357 # include <sys/types.h>
358 # include <sys/socket.h>],
359 [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
360 ac_cv_sockaddr_has_sa_len=yes,
361 ac_cv_sockaddr_has_sa_len=no))
362 AC_MSG_RESULT($ac_cv_sockaddr_has_sa_len)
363 if test $ac_cv_sockaddr_has_sa_len = yes ; then
364 AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
368 dnl Checks to see if -R is used
372 dnl AC_LBL_HAVE_RUN_PATH
376 dnl ac_cv_have_run_path (yes or no)
378 AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
379 [AC_MSG_CHECKING(for ${CC-cc} -R)
380 AC_CACHE_VAL(ac_cv_have_run_path,
381 [echo 'main(){}' > conftest.c
382 ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
383 if test ! -s conftest.out ; then
384 ac_cv_have_run_path=yes
386 ac_cv_have_run_path=no
389 AC_MSG_RESULT($ac_cv_have_run_path)
393 dnl Checks to see if unaligned memory accesses fail
397 dnl AC_LBL_UNALIGNED_ACCESS
401 dnl LBL_ALIGN (DEFINED)
403 AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
404 [AC_MSG_CHECKING(if unaligned accesses fail)
405 AC_CACHE_VAL(ac_cv_unaligned_fail,
406 [case "$target_cpu" in
408 alpha|hp*|mips|sparc)
409 ac_cv_unaligned_fail=yes
413 cat >conftest.c <<EOF
414 # include <sys/types.h>
415 # include <sys/wait.h>
417 unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
422 /* avoid "core dumped" message */
428 pid = waitpid(pid, &status, 0);
431 exit(!WIFEXITED(status));
434 i = *(unsigned int *)&a[[1]];
439 ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
440 conftest.c $LIBS >/dev/null 2>&1
441 if test ! -x conftest ; then
442 dnl failed to compile for some reason
443 ac_cv_unaligned_fail=yes
445 ./conftest >conftest.out
446 if test ! -s conftest.out ; then
447 ac_cv_unaligned_fail=yes
449 ac_cv_unaligned_fail=no
452 rm -f conftest* core core.conftest
455 AC_MSG_RESULT($ac_cv_unaligned_fail)
456 if test $ac_cv_unaligned_fail = yes ; then
461 dnl If using gcc and the file .devel exists:
462 dnl Compile with -g (if supported) and -Wall
463 dnl If using gcc 2, do extra prototype checking
464 dnl If an os prototype include exists, symlink os-proto.h to it
468 dnl AC_LBL_DEVEL(copt)
472 dnl $1 (copt appended)
473 dnl HAVE_OS_PROTO_H (defined)
474 dnl os-proto.h (symlinked)
476 AC_DEFUN(AC_LBL_DEVEL,
478 if test $ac_cv_prog_gcc = yes -a -f .devel ; then
479 if test $ac_cv_prog_gcc_g = yes ; then
483 if test $ac_cv_gcc_vers -gt 1 ; then
484 $1="$$1 -Wmissing-prototypes -Wstrict-prototypes"
486 os=`echo $target_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
488 if test -f $name ; then
489 ln -s $name os-proto.h
490 AC_DEFINE(HAVE_OS_PROTO_H)
492 AC_MSG_WARN(can't find $name)