]> The Tcpdump Group git mirrors - libpcap/blob - aclocal.m4
Improve dag_platform_finddevs range and efficiency.
[libpcap] / aclocal.m4
1 dnl @(#) $Header: /tcpdump/master/libpcap/aclocal.m4,v 1.93 2008-11-18 07:29:48 guy Exp $ (LBL)
2 dnl
3 dnl Copyright (c) 1995, 1996, 1997, 1998
4 dnl The Regents of the University of California. All rights reserved.
5 dnl
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.
21 dnl
22 dnl LBL autoconf macros
23 dnl
24
25 dnl
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
31 dnl
32 dnl usage:
33 dnl
34 dnl AC_LBL_C_INIT(copt, incls)
35 dnl
36 dnl results:
37 dnl
38 dnl $1 (copt set)
39 dnl $2 (incls set)
40 dnl CC
41 dnl LDFLAGS
42 dnl ac_cv_lbl_gcc_vers
43 dnl LBL_CFLAGS
44 dnl
45 AC_DEFUN(AC_LBL_C_INIT,
46 [AC_PREREQ(2.12)
47 AC_BEFORE([$0], [AC_PROG_CC])
48 AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
49 AC_BEFORE([$0], [AC_LBL_DEVEL])
50 AC_ARG_WITH(gcc, [ --without-gcc don't use gcc])
51 $1="-O"
52 $2=""
53 if test "${srcdir}" != "." ; then
54 $2="-I\$(srcdir)"
55 fi
56 if test "${CFLAGS+set}" = set; then
57 LBL_CFLAGS="$CFLAGS"
58 fi
59 if test -z "$CC" ; then
60 case "$host_os" in
61
62 bsdi*)
63 AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
64 if test $SHLICC2 = yes ; then
65 CC=shlicc2
66 export CC
67 fi
68 ;;
69 esac
70 fi
71 if test -z "$CC" -a "$with_gcc" = no ; then
72 CC=cc
73 export CC
74 fi
75 AC_PROG_CC
76 if test "$GCC" = yes ; then
77 if test "$SHLICC2" = yes ; then
78 ac_cv_lbl_gcc_vers=2
79 $1="-O2"
80 else
81 AC_MSG_CHECKING(gcc version)
82 AC_CACHE_VAL(ac_cv_lbl_gcc_vers,
83 ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \
84 sed -e '/^gcc version /!d' \
85 -e 's/^gcc version //' \
86 -e 's/ .*//' -e 's/^[[[^0-9]]]*//' \
87 -e 's/\..*//'`)
88 AC_MSG_RESULT($ac_cv_lbl_gcc_vers)
89 if test $ac_cv_lbl_gcc_vers -gt 1 ; then
90 $1="-O2"
91 fi
92 fi
93
94 #
95 # On platforms where we build a shared library:
96 #
97 # add options to generate position-independent code,
98 # if necessary (it's the default in AIX and Darwin/OS X);
99 #
100 # define option to set the soname of the shared library,
101 # if the OS supports that;
102 #
103 # add options to specify, at link time, a directory to
104 # add to the run-time search path, if that's necessary.
105 #
106 V_SHLIB_CMD="\$(CC)"
107 V_SHLIB_OPT="-shared"
108 case "$host_os" in
109
110 aix*)
111 ;;
112
113 freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*)
114 #
115 # Platforms where the linker is the GNU linker
116 # or accepts command-line arguments like
117 # those the GNU linker accepts.
118 #
119 V_CCOPT="$V_CCOPT -fpic"
120 V_SONAME_OPT="-Wl,-soname,"
121 V_RPATH_OPT="-Wl,-rpath,"
122 ;;
123
124 hpux*)
125 V_CCOPT="$V_CCOPT -fpic"
126 #
127 # XXX - this assumes GCC is using the HP linker,
128 # rather than the GNU linker, and that the "+h"
129 # option is used on all HP-UX platforms, both .sl
130 # and .so.
131 #
132 V_SONAME_OPT="-Wl,+h,"
133 #
134 # By default, directories specifed with -L
135 # are added to the run-time search path, so
136 # we don't add them in pcap-config.
137 #
138 ;;
139
140 solaris*)
141 V_CCOPT="$V_CCOPT -fpic"
142 #
143 # XXX - this assumes GCC is using the Sun linker,
144 # rather than the GNU linker.
145 #
146 V_SONAME_OPT="-Wl,-h,"
147 V_RPATH_OPT="-Wl,-R,"
148 ;;
149 esac
150 else
151 AC_MSG_CHECKING(that $CC handles ansi prototypes)
152 AC_CACHE_VAL(ac_cv_lbl_cc_ansi_prototypes,
153 AC_TRY_COMPILE(
154 [#include <sys/types.h>],
155 [int frob(int, char *)],
156 ac_cv_lbl_cc_ansi_prototypes=yes,
157 ac_cv_lbl_cc_ansi_prototypes=no))
158 AC_MSG_RESULT($ac_cv_lbl_cc_ansi_prototypes)
159 if test $ac_cv_lbl_cc_ansi_prototypes = no ; then
160 case "$host_os" in
161
162 hpux*)
163 AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE))
164 savedcflags="$CFLAGS"
165 CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
166 AC_CACHE_VAL(ac_cv_lbl_cc_hpux_cc_aa,
167 AC_TRY_COMPILE(
168 [#include <sys/types.h>],
169 [int frob(int, char *)],
170 ac_cv_lbl_cc_hpux_cc_aa=yes,
171 ac_cv_lbl_cc_hpux_cc_aa=no))
172 AC_MSG_RESULT($ac_cv_lbl_cc_hpux_cc_aa)
173 if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then
174 AC_MSG_ERROR(see the INSTALL doc for more info)
175 fi
176 CFLAGS="$savedcflags"
177 $1="-Aa $$1"
178 AC_DEFINE(_HPUX_SOURCE,1,[needed on HP-UX])
179 ;;
180
181 osf*)
182 AC_MSG_CHECKING(for ansi mode in DEC compiler ($CC -std1))
183 savedcflags="$CFLAGS"
184 CFLAGS="-std1"
185 AC_CACHE_VAL(ac_cv_lbl_cc_osf1_cc_std1,
186 AC_TRY_COMPILE(
187 [#include <sys/types.h>],
188 [int frob(int, char *)],
189 ac_cv_lbl_cc_osf1_cc_std1=yes,
190 ac_cv_lbl_cc_osf1_cc_std1=no))
191 AC_MSG_RESULT($ac_cv_lbl_cc_osf1_cc_std1)
192 if test $ac_cv_lbl_cc_osf1_cc_std1 = no ; then
193 AC_MSG_ERROR(see the INSTALL doc for more info)
194 fi
195 CFLAGS="$savedcflags"
196 $1="-std1 $$1"
197 ;;
198
199 *)
200 AC_MSG_ERROR(see the INSTALL doc for more info)
201 ;;
202 esac
203 fi
204 $2="$$2 -I/usr/local/include"
205 LDFLAGS="$LDFLAGS -L/usr/local/lib"
206
207 #
208 # Set the appropriate compiler flags and, on platforms
209 # where we build a shared library:
210 #
211 # add options to generate position-independent code,
212 # if necessary (it's the default in Darwin/OS X);
213 #
214 # if we generate ".so" shared libraries, define the
215 # appropriate options for building the shared library;
216 #
217 # add options to specify, at link time, a directory to
218 # add to the run-time search path, if that's necessary.
219 #
220 # Note: spaces after V_SONAME_OPT are significant; on
221 # some platforms the soname is passed with a GCC-like
222 # "-Wl,-soname,{soname}" option, with the soname part
223 # of the option, while on other platforms the C compiler
224 # driver takes it as a regular option with the soname
225 # following the option. The same applies to V_RPATH_OPT.
226 #
227 case "$host_os" in
228
229 aix*)
230 V_SHLIB_CMD="\$(CC)"
231 V_SHLIB_OPT="-G -bnoentry -bexpall"
232 ;;
233
234 freebsd*|netbsd*|openbsd*|dragonfly*|linux*)
235 #
236 # "cc" is GCC.
237 #
238 $1="$$1 -fpic"
239 V_SHLIB_CMD="\$(CC)"
240 V_SHLIB_OPT="-shared"
241 V_SONAME_OPT="-Wl,-soname,"
242 V_RPATH_OPT="-Wl,-rpath,"
243 ;;
244
245 hpux*)
246 $1="$$1 +z"
247 V_SHLIB_CMD="\$(LD)"
248 V_SHLIB_OPT="-b"
249 V_SONAME_OPT="+h "
250 #
251 # By default, directories specifed with -L
252 # are added to the run-time search path, so
253 # we don't add them in pcap-config.
254 #
255 ;;
256
257 irix*)
258 $1="$$1 -xansi -signed -g3"
259 ;;
260
261 osf*)
262 #
263 # Presumed to be DEC OSF/1, Digital UNIX, or
264 # Tru64 UNIX.
265 #
266 $1="$$1 -g3"
267 V_SHLIB_CMD="\$(CC)"
268 V_SHLIB_OPT="-shared"
269 V_SONAME_OPT="-soname "
270 V_RPATH_OPT="-rpath "
271 ;;
272
273 solaris*)
274 V_CCOPT="$V_CCOPT -Kpic"
275 V_SHLIB_CMD="\$(CC)"
276 V_SHLIB_OPT="-G"
277 V_SONAME_OPT="-h "
278 V_RPATH_OPT="-R"
279 ;;
280
281 ultrix*)
282 AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
283 AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
284 AC_TRY_COMPILE(
285 [#include <sys/types.h>],
286 [struct a { int b; };
287 void c(const struct a *)],
288 ac_cv_lbl_cc_const_proto=yes,
289 ac_cv_lbl_cc_const_proto=no))
290 AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
291 if test $ac_cv_lbl_cc_const_proto = no ; then
292 AC_DEFINE(const,[],
293 [to handle Ultrix compilers that don't support const in prototypes])
294 fi
295 ;;
296 esac
297 fi
298 ])
299
300 #
301 # Try compiling a sample of the type of code that appears in
302 # gencode.c with "inline", "__inline__", and "__inline".
303 #
304 # Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough,
305 # as it just tests whether a function returning "int" can be inlined;
306 # at least some versions of HP's C compiler can inline that, but can't
307 # inline a function that returns a struct pointer.
308 #
309 # Make sure we use the V_CCOPT flags, because some of those might
310 # disable inlining.
311 #
312 AC_DEFUN(AC_LBL_C_INLINE,
313 [AC_MSG_CHECKING(for inline)
314 save_CFLAGS="$CFLAGS"
315 CFLAGS="$V_CCOPT"
316 AC_CACHE_VAL(ac_cv_lbl_inline, [
317 ac_cv_lbl_inline=""
318 ac_lbl_cc_inline=no
319 for ac_lbl_inline in inline __inline__ __inline
320 do
321 AC_TRY_COMPILE(
322 [#define inline $ac_lbl_inline
323 static inline struct iltest *foo(void);
324 struct iltest {
325 int iltest1;
326 int iltest2;
327 };
328
329 static inline struct iltest *
330 foo()
331 {
332 static struct iltest xxx;
333
334 return &xxx;
335 }],,ac_lbl_cc_inline=yes,)
336 if test "$ac_lbl_cc_inline" = yes ; then
337 break;
338 fi
339 done
340 if test "$ac_lbl_cc_inline" = yes ; then
341 ac_cv_lbl_inline=$ac_lbl_inline
342 fi])
343 CFLAGS="$save_CFLAGS"
344 if test ! -z "$ac_cv_lbl_inline" ; then
345 AC_MSG_RESULT($ac_cv_lbl_inline)
346 else
347 AC_MSG_RESULT(no)
348 fi
349 AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
350
351 dnl
352 dnl If using gcc, make sure we have ANSI ioctl definitions
353 dnl
354 dnl usage:
355 dnl
356 dnl AC_LBL_FIXINCLUDES
357 dnl
358 AC_DEFUN(AC_LBL_FIXINCLUDES,
359 [if test "$GCC" = yes ; then
360 AC_MSG_CHECKING(for ANSI ioctl definitions)
361 AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes,
362 AC_TRY_COMPILE(
363 [/*
364 * This generates a "duplicate case value" when fixincludes
365 * has not be run.
366 */
367 # include <sys/types.h>
368 # include <sys/time.h>
369 # include <sys/ioctl.h>
370 # ifdef HAVE_SYS_IOCCOM_H
371 # include <sys/ioccom.h>
372 # endif],
373 [switch (0) {
374 case _IO('A', 1):;
375 case _IO('B', 1):;
376 }],
377 ac_cv_lbl_gcc_fixincludes=yes,
378 ac_cv_lbl_gcc_fixincludes=no))
379 AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes)
380 if test $ac_cv_lbl_gcc_fixincludes = no ; then
381 # Don't cache failure
382 unset ac_cv_lbl_gcc_fixincludes
383 AC_MSG_ERROR(see the INSTALL for more info)
384 fi
385 fi])
386
387 dnl
388 dnl Check for flex, default to lex
389 dnl Require flex 2.4 or higher
390 dnl Check for bison, default to yacc
391 dnl Default to lex/yacc if both flex and bison are not available
392 dnl Define the yy prefix string if using flex and bison
393 dnl
394 dnl usage:
395 dnl
396 dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
397 dnl
398 dnl results:
399 dnl
400 dnl $1 (lex set)
401 dnl $2 (yacc appended)
402 dnl $3 (optional flex and bison -P prefix)
403 dnl
404 AC_DEFUN(AC_LBL_LEX_AND_YACC,
405 [AC_ARG_WITH(flex, [ --without-flex don't use flex])
406 AC_ARG_WITH(bison, [ --without-bison don't use bison])
407 if test "$with_flex" = no ; then
408 $1=lex
409 else
410 AC_CHECK_PROGS($1, flex, lex)
411 fi
412 if test "$$1" = flex ; then
413 # The -V flag was added in 2.4
414 AC_MSG_CHECKING(for flex 2.4 or higher)
415 AC_CACHE_VAL(ac_cv_lbl_flex_v24,
416 if flex -V >/dev/null 2>&1; then
417 ac_cv_lbl_flex_v24=yes
418 else
419 ac_cv_lbl_flex_v24=no
420 fi)
421 AC_MSG_RESULT($ac_cv_lbl_flex_v24)
422 if test $ac_cv_lbl_flex_v24 = no ; then
423 s="2.4 or higher required"
424 AC_MSG_WARN(ignoring obsolete flex executable ($s))
425 $1=lex
426 fi
427 fi
428 if test "$with_bison" = no ; then
429 $2=yacc
430 else
431 AC_CHECK_PROGS($2, bison, yacc)
432 fi
433 if test "$$2" = bison ; then
434 $2="$$2 -y"
435 fi
436 if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
437 AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
438 $1=lex
439 $2=yacc
440 fi
441 if test "$$1" = flex -a -n "$3" ; then
442 $1="$$1 -P$3"
443 $2="$$2 -p $3"
444 fi])
445
446 dnl
447 dnl Checks to see if union wait is used with WEXITSTATUS()
448 dnl
449 dnl usage:
450 dnl
451 dnl AC_LBL_UNION_WAIT
452 dnl
453 dnl results:
454 dnl
455 dnl DECLWAITSTATUS (defined)
456 dnl
457 AC_DEFUN(AC_LBL_UNION_WAIT,
458 [AC_MSG_CHECKING(if union wait is used)
459 AC_CACHE_VAL(ac_cv_lbl_union_wait,
460 AC_TRY_COMPILE([
461 # include <sys/types.h>
462 # include <sys/wait.h>],
463 [int status;
464 u_int i = WEXITSTATUS(status);
465 u_int j = waitpid(0, &status, 0);],
466 ac_cv_lbl_union_wait=no,
467 ac_cv_lbl_union_wait=yes))
468 AC_MSG_RESULT($ac_cv_lbl_union_wait)
469 if test $ac_cv_lbl_union_wait = yes ; then
470 AC_DEFINE(DECLWAITSTATUS,union wait,[type for wait])
471 else
472 AC_DEFINE(DECLWAITSTATUS,int,[type for wait])
473 fi])
474
475 dnl
476 dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
477 dnl
478 dnl usage:
479 dnl
480 dnl AC_LBL_SOCKADDR_SA_LEN
481 dnl
482 dnl results:
483 dnl
484 dnl HAVE_SOCKADDR_SA_LEN (defined)
485 dnl
486 AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
487 [AC_MSG_CHECKING(if sockaddr struct has the sa_len member)
488 AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len,
489 AC_TRY_COMPILE([
490 # include <sys/types.h>
491 # include <sys/socket.h>],
492 [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
493 ac_cv_lbl_sockaddr_has_sa_len=yes,
494 ac_cv_lbl_sockaddr_has_sa_len=no))
495 AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len)
496 if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then
497 AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[if struct sockaddr has the sa_len member])
498 fi])
499
500 dnl
501 dnl Checks to see if there's a sockaddr_storage structure
502 dnl
503 dnl usage:
504 dnl
505 dnl AC_LBL_SOCKADDR_STORAGE
506 dnl
507 dnl results:
508 dnl
509 dnl HAVE_SOCKADDR_STORAGE (defined)
510 dnl
511 AC_DEFUN(AC_LBL_SOCKADDR_STORAGE,
512 [AC_MSG_CHECKING(if sockaddr_storage struct exists)
513 AC_CACHE_VAL(ac_cv_lbl_has_sockaddr_storage,
514 AC_TRY_COMPILE([
515 # include <sys/types.h>
516 # include <sys/socket.h>],
517 [u_int i = sizeof (struct sockaddr_storage)],
518 ac_cv_lbl_has_sockaddr_storage=yes,
519 ac_cv_lbl_has_sockaddr_storage=no))
520 AC_MSG_RESULT($ac_cv_lbl_has_sockaddr_storage)
521 if test $ac_cv_lbl_has_sockaddr_storage = yes ; then
522 AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[if struct sockaddr_storage exists])
523 fi])
524
525 dnl
526 dnl Checks to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
527 dnl dl_module_id_1 member
528 dnl
529 dnl usage:
530 dnl
531 dnl AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
532 dnl
533 dnl results:
534 dnl
535 dnl HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 (defined)
536 dnl
537 dnl NOTE: any compile failure means we conclude that it doesn't have
538 dnl that member, so if we don't have DLPI, don't have a <sys/dlpi_ext.h>
539 dnl header, or have one that doesn't declare a dl_hp_ppa_info_t type,
540 dnl we conclude it doesn't have that member (which is OK, as either we
541 dnl won't be using code that would use that member, or we wouldn't
542 dnl compile in any case).
543 dnl
544 AC_DEFUN(AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1,
545 [AC_MSG_CHECKING(if dl_hp_ppa_info_t struct has dl_module_id_1 member)
546 AC_CACHE_VAL(ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1,
547 AC_TRY_COMPILE([
548 # include <sys/types.h>
549 # include <sys/dlpi.h>
550 # include <sys/dlpi_ext.h>],
551 [u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)],
552 ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes,
553 ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no))
554 AC_MSG_RESULT($ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1)
555 if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then
556 AC_DEFINE(HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1,1,[if ppa_info_t_dl_module_id exists])
557 fi])
558
559 dnl
560 dnl Checks to see if -R is used
561 dnl
562 dnl usage:
563 dnl
564 dnl AC_LBL_HAVE_RUN_PATH
565 dnl
566 dnl results:
567 dnl
568 dnl ac_cv_lbl_have_run_path (yes or no)
569 dnl
570 AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
571 [AC_MSG_CHECKING(for ${CC-cc} -R)
572 AC_CACHE_VAL(ac_cv_lbl_have_run_path,
573 [echo 'main(){}' > conftest.c
574 ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
575 if test ! -s conftest.out ; then
576 ac_cv_lbl_have_run_path=yes
577 else
578 ac_cv_lbl_have_run_path=no
579 fi
580 rm -f conftest*])
581 AC_MSG_RESULT($ac_cv_lbl_have_run_path)
582 ])
583
584 dnl
585 dnl Checks to see if unaligned memory accesses fail
586 dnl
587 dnl usage:
588 dnl
589 dnl AC_LBL_UNALIGNED_ACCESS
590 dnl
591 dnl results:
592 dnl
593 dnl LBL_ALIGN (DEFINED)
594 dnl
595 AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
596 [AC_MSG_CHECKING(if unaligned accesses fail)
597 AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
598 [case "$host_cpu" in
599
600 #
601 # These are CPU types where:
602 #
603 # the CPU faults on an unaligned access, but at least some
604 # OSes that support that CPU catch the fault and simulate
605 # the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) -
606 # the simulation is slow, so we don't want to use it;
607 #
608 # the CPU, I infer (from the old
609 #
610 # XXX: should also check that they don't do weird things (like on arm)
611 #
612 # comment) doesn't fault on unaligned accesses, but doesn't
613 # do a normal unaligned fetch, either (e.g., presumably, ARM);
614 #
615 # for whatever reason, the test program doesn't work
616 # (this has been claimed to be the case for several of those
617 # CPUs - I don't know what the problem is; the problem
618 # was reported as "the test program dumps core" for SuperH,
619 # but that's what the test program is *supposed* to do -
620 # it dumps core before it writes anything, so the test
621 # for an empty output file should find an empty output
622 # file and conclude that unaligned accesses don't work).
623 #
624 # This run-time test won't work if you're cross-compiling, so
625 # in order to support cross-compiling for a particular CPU,
626 # we have to wire in the list of CPU types anyway, as far as
627 # I know, so perhaps we should just have a set of CPUs on
628 # which we know it doesn't work, a set of CPUs on which we
629 # know it does work, and have the script just fail on other
630 # cpu types and update it when such a failure occurs.
631 #
632 alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1)
633 ac_cv_lbl_unaligned_fail=yes
634 ;;
635
636 *)
637 cat >conftest.c <<EOF
638 # include <sys/types.h>
639 # include <sys/wait.h>
640 # include <stdio.h>
641 unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
642 main() {
643 unsigned int i;
644 pid_t pid;
645 int status;
646 /* avoid "core dumped" message */
647 pid = fork();
648 if (pid < 0)
649 exit(2);
650 if (pid > 0) {
651 /* parent */
652 pid = waitpid(pid, &status, 0);
653 if (pid < 0)
654 exit(3);
655 exit(!WIFEXITED(status));
656 }
657 /* child */
658 i = *(unsigned int *)&a[[1]];
659 printf("%d\n", i);
660 exit(0);
661 }
662 EOF
663 ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
664 conftest.c $LIBS >/dev/null 2>&1
665 if test ! -x conftest ; then
666 dnl failed to compile for some reason
667 ac_cv_lbl_unaligned_fail=yes
668 else
669 ./conftest >conftest.out
670 if test ! -s conftest.out ; then
671 ac_cv_lbl_unaligned_fail=yes
672 else
673 ac_cv_lbl_unaligned_fail=no
674 fi
675 fi
676 rm -f conftest* core core.conftest
677 ;;
678 esac])
679 AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
680 if test $ac_cv_lbl_unaligned_fail = yes ; then
681 AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails])
682 fi])
683
684 dnl
685 dnl If using gcc and the file .devel exists:
686 dnl Compile with -g (if supported) and -Wall
687 dnl If using gcc 2 or later, do extra prototype checking
688 dnl If an os prototype include exists, symlink os-proto.h to it
689 dnl
690 dnl usage:
691 dnl
692 dnl AC_LBL_DEVEL(copt)
693 dnl
694 dnl results:
695 dnl
696 dnl $1 (copt appended)
697 dnl HAVE_OS_PROTO_H (defined)
698 dnl os-proto.h (symlinked)
699 dnl
700 AC_DEFUN(AC_LBL_DEVEL,
701 [rm -f os-proto.h
702 if test "${LBL_CFLAGS+set}" = set; then
703 $1="$$1 ${LBL_CFLAGS}"
704 fi
705 if test -f .devel ; then
706 if test "$GCC" = yes ; then
707 if test "${LBL_CFLAGS+set}" != set; then
708 if test "$ac_cv_prog_cc_g" = yes ; then
709 $1="-g $$1"
710 fi
711 $1="$$1 -Wall"
712 if test $ac_cv_lbl_gcc_vers -gt 1 ; then
713 $1="$$1 -Wmissing-prototypes -Wstrict-prototypes"
714 fi
715 fi
716 else
717 case "$host_os" in
718
719 irix6*)
720 V_CCOPT="$V_CCOPT -n32"
721 ;;
722
723 *)
724 ;;
725 esac
726 fi
727 os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
728 name="lbl/os-$os.h"
729 if test -f $name ; then
730 ln -s $name os-proto.h
731 AC_DEFINE(HAVE_OS_PROTO_H, 1,
732 [if there's an os_proto.h for this platform, to use additional prototypes])
733 else
734 AC_MSG_WARN(can't find $name)
735 fi
736 fi])
737
738 dnl
739 dnl Improved version of AC_CHECK_LIB
740 dnl
741 dnl Thanks to John Hawkinson (jhawk@mit.edu)
742 dnl
743 dnl usage:
744 dnl
745 dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
746 dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
747 dnl
748 dnl results:
749 dnl
750 dnl LIBS
751 dnl
752 dnl XXX - "AC_LBL_LIBRARY_NET" was redone to use "AC_SEARCH_LIBS"
753 dnl rather than "AC_LBL_CHECK_LIB", so this isn't used any more.
754 dnl We keep it around for reference purposes in case it's ever
755 dnl useful in the future.
756 dnl
757
758 define(AC_LBL_CHECK_LIB,
759 [AC_MSG_CHECKING([for $2 in -l$1])
760 dnl Use a cache variable name containing the library, function
761 dnl name, and extra libraries to link with, because the test really is
762 dnl for library $1 defining function $2, when linked with potinal
763 dnl library $5, not just for library $1. Separate tests with the same
764 dnl $1 and different $2's or $5's may have different results.
765 ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
766 AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
767 [ac_save_LIBS="$LIBS"
768 LIBS="-l$1 $5 $LIBS"
769 AC_TRY_LINK(dnl
770 ifelse([$2], [main], , dnl Avoid conflicting decl of main.
771 [/* Override any gcc2 internal prototype to avoid an error. */
772 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
773 extern "C"
774 #endif
775 ])dnl
776 [/* We use char because int might match the return type of a gcc2
777 builtin and then its argument prototype would still apply. */
778 char $2();
779 ]),
780 [$2()],
781 eval "ac_cv_lbl_lib_$ac_lib_var=yes",
782 eval "ac_cv_lbl_lib_$ac_lib_var=no")
783 LIBS="$ac_save_LIBS"
784 ])dnl
785 if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
786 AC_MSG_RESULT(yes)
787 ifelse([$3], ,
788 [changequote(, )dnl
789 ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
790 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
791 changequote([, ])dnl
792 AC_DEFINE_UNQUOTED($ac_tr_lib)
793 LIBS="-l$1 $LIBS"
794 ], [$3])
795 else
796 AC_MSG_RESULT(no)
797 ifelse([$4], , , [$4
798 ])dnl
799 fi
800 ])
801
802 dnl
803 dnl AC_LBL_LIBRARY_NET
804 dnl
805 dnl This test is for network applications that need socket() and
806 dnl gethostbyname() -ish functions. Under Solaris, those applications
807 dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link
808 dnl with "-lnsl" but should *not* link with "-lsocket" because
809 dnl libsocket.a breaks a number of things (for instance:
810 dnl gethostbyname() under IRIX 5.2, and snoop sockets under most
811 dnl versions of IRIX).
812 dnl
813 dnl Unfortunately, many application developers are not aware of this,
814 dnl and mistakenly write tests that cause -lsocket to be used under
815 dnl IRIX. It is also easy to write tests that cause -lnsl to be used
816 dnl under operating systems where neither are necessary (or useful),
817 dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
818 dnl
819 dnl This test exists so that every application developer does not test
820 dnl this in a different, and subtly broken fashion.
821
822 dnl It has been argued that this test should be broken up into two
823 dnl seperate tests, one for the resolver libraries, and one for the
824 dnl libraries necessary for using Sockets API. Unfortunately, the two
825 dnl are carefully intertwined and allowing the autoconf user to use
826 dnl them independantly potentially results in unfortunate ordering
827 dnl dependancies -- as such, such component macros would have to
828 dnl carefully use indirection and be aware if the other components were
829 dnl executed. Since other autoconf macros do not go to this trouble,
830 dnl and almost no applications use sockets without the resolver, this
831 dnl complexity has not been implemented.
832 dnl
833 dnl The check for libresolv is in case you are attempting to link
834 dnl statically and happen to have a libresolv.a lying around (and no
835 dnl libnsl.a).
836 dnl
837 AC_DEFUN(AC_LBL_LIBRARY_NET, [
838 # Most operating systems have gethostbyname() in the default searched
839 # libraries (i.e. libc):
840 # Some OSes (eg. Solaris) place it in libnsl
841 # Some strange OSes (SINIX) have it in libsocket:
842 AC_SEARCH_LIBS(gethostbyname, nsl socket resolv)
843 # Unfortunately libsocket sometimes depends on libnsl and
844 # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this.
845 if test "$ac_cv_search_gethostbyname" = "no"
846 then
847 AC_CHECK_LIB(socket, gethostbyname,
848 LIBS="-lsocket -lnsl $LIBS", , -lnsl)
849 fi
850 AC_SEARCH_LIBS(socket, socket, ,
851 AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl))
852 # DLPI needs putmsg under HPUX so test for -lstr while we're at it
853 AC_SEARCH_LIBS(putmsg, str)
854 ])
855
856 dnl
857 dnl Test for __attribute__
858 dnl
859
860 AC_DEFUN(AC_C___ATTRIBUTE__, [
861 AC_MSG_CHECKING(for __attribute__)
862 AC_CACHE_VAL(ac_cv___attribute__, [
863 AC_COMPILE_IFELSE(
864 AC_LANG_SOURCE([[
865 #include <stdlib.h>
866
867 static void foo(void) __attribute__ ((noreturn));
868
869 static void
870 foo(void)
871 {
872 exit(1);
873 }
874
875 int
876 main(int argc, char **argv)
877 {
878 foo();
879 }
880 ]]),
881 ac_cv___attribute__=yes,
882 ac_cv___attribute__=no)])
883 if test "$ac_cv___attribute__" = "yes"; then
884 AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
885 V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
886 else
887 V_DEFS="$V_DEFS -D_U_=\"\""
888 fi
889 AC_MSG_RESULT($ac_cv___attribute__)
890 ])
891
892 dnl
893 dnl Checks to see if tpacket_stats is defined in linux/if_packet.h
894 dnl If so then pcap-linux.c can use this to report proper statistics.
895 dnl
896 dnl -Scott Barron
897 dnl
898 AC_DEFUN(AC_LBL_TPACKET_STATS,
899 [AC_MSG_CHECKING(if if_packet.h has tpacket_stats defined)
900 AC_CACHE_VAL(ac_cv_lbl_tpacket_stats,
901 AC_TRY_COMPILE([
902 # include <linux/if_packet.h>],
903 [struct tpacket_stats stats],
904 ac_cv_lbl_tpacket_stats=yes,
905 ac_cv_lbl_tpacket_stats=no))
906 AC_MSG_RESULT($ac_cv_lbl_tpacket_stats)
907 if test $ac_cv_lbl_tpacket_stats = yes; then
908 AC_DEFINE(HAVE_TPACKET_STATS,1,[if if_packet.h has tpacket_stats defined])
909 fi])
910
911 dnl
912 dnl Checks to see if the tpacket_auxdata struct has a tp_vlan_tci member.
913 dnl
914 dnl usage:
915 dnl
916 dnl AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
917 dnl
918 dnl results:
919 dnl
920 dnl HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI (defined)
921 dnl
922 dnl NOTE: any compile failure means we conclude that it doesn't have
923 dnl that member, so if we don't have tpacket_auxdata, we conclude it
924 dnl doesn't have that member (which is OK, as either we won't be using
925 dnl code that would use that member, or we wouldn't compile in any case).
926 dnl
927 AC_DEFUN(AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,
928 [AC_MSG_CHECKING(if tpacket_auxdata struct has tp_vlan_tci member)
929 AC_CACHE_VAL(ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1,
930 AC_TRY_COMPILE([
931 # include <linux/if_packet.h>],
932 [u_int i = sizeof(((struct tpacket_auxdata *)0)->tp_vlan_tci)],
933 ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=yes,
934 ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=no))
935 AC_MSG_RESULT($ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci)
936 if test $ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci = yes ; then
937 HAVE_LINUX_TPACKET_AUXDATA=tp_vlan_tci
938 AC_SUBST(HAVE_LINUX_TPACKET_AUXDATA)
939 AC_DEFINE(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,1,[if tp_vlan_tci exists])
940 fi])
941
942 dnl
943 dnl Checks to see if Solaris has the dl_passive_req_t struct defined
944 dnl in <sys/dlpi.h>.
945 dnl
946 dnl usage:
947 dnl
948 dnl AC_LBL_DL_PASSIVE_REQ_T
949 dnl
950 dnl results:
951 dnl
952 dnl HAVE_DLPI_PASSIVE (defined)
953 dnl
954 AC_DEFUN(AC_LBL_DL_PASSIVE_REQ_T,
955 [AC_MSG_CHECKING(if dl_passive_req_t struct exists)
956 AC_CACHE_VAL(ac_cv_lbl_has_dl_passive_req_t,
957 AC_TRY_COMPILE([
958 # include <sys/types.h>
959 # include <sys/dlpi.h>],
960 [u_int i = sizeof(dl_passive_req_t)],
961 ac_cv_lbl_has_dl_passive_req_t=yes,
962 ac_cv_lbl_has_dl_passive_req_t=no))
963 AC_MSG_RESULT($ac_cv_lbl_has_dl_passive_req_t)
964 if test $ac_cv_lbl_has_dl_passive_req_t = yes ; then
965 AC_DEFINE(HAVE_DLPI_PASSIVE,1,[if passive_req_t primitive
966 exists])
967 fi])