blob: 4b643ef0d36ca79870b9f79276e146b6f5945c07 [file] [log] [blame]
JP Abgrall511eca32014-02-12 13:46:45 -08001dnl @(#) $Header: /tcpdump/master/libpcap/aclocal.m4,v 1.93 2008-11-18 07:29:48 guy Exp $ (LBL)
The Android Open Source Project478ab6c2009-03-03 19:30:05 -08002dnl
3dnl Copyright (c) 1995, 1996, 1997, 1998
4dnl The Regents of the University of California. All rights reserved.
5dnl
6dnl Redistribution and use in source and binary forms, with or without
7dnl modification, are permitted provided that: (1) source code distributions
8dnl retain the above copyright notice and this paragraph in its entirety, (2)
9dnl distributions including binary code include the above copyright notice and
10dnl this paragraph in its entirety in the documentation or other materials
11dnl provided with the distribution, and (3) all advertising materials mentioning
12dnl features or use of this software display the following acknowledgement:
13dnl ``This product includes software developed by the University of California,
14dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
15dnl the University nor the names of its contributors may be used to endorse
16dnl or promote products derived from this software without specific prior
17dnl written permission.
18dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21dnl
22dnl LBL autoconf macros
23dnl
24
25dnl
JP Abgrall511eca32014-02-12 13:46:45 -080026dnl Do whatever AC_LBL_C_INIT work is necessary before using AC_PROG_CC.
The Android Open Source Project478ab6c2009-03-03 19:30:05 -080027dnl
JP Abgrall511eca32014-02-12 13:46:45 -080028dnl It appears that newer versions of autoconf (2.64 and later) will,
29dnl if you use AC_TRY_COMPILE in a macro, stick AC_PROG_CC at the
30dnl beginning of the macro, even if the macro itself calls AC_PROG_CC.
31dnl See the "Prerequisite Macros" and "Expanded Before Required" sections
32dnl in the Autoconf documentation.
The Android Open Source Project478ab6c2009-03-03 19:30:05 -080033dnl
JP Abgrall511eca32014-02-12 13:46:45 -080034dnl This causes a steaming heap of fail in our case, as we were, in
35dnl AC_LBL_C_INIT, doing the tests we now do in AC_LBL_C_INIT_BEFORE_CC,
36dnl calling AC_PROG_CC, and then doing the tests we now do in
37dnl AC_LBL_C_INIT. Now, we run AC_LBL_C_INIT_BEFORE_CC, AC_PROG_CC,
38dnl and AC_LBL_C_INIT at the top level.
The Android Open Source Project478ab6c2009-03-03 19:30:05 -080039dnl
JP Abgrall511eca32014-02-12 13:46:45 -080040AC_DEFUN(AC_LBL_C_INIT_BEFORE_CC,
41[
42 AC_BEFORE([$0], [AC_LBL_C_INIT])
The Android Open Source Project478ab6c2009-03-03 19:30:05 -080043 AC_BEFORE([$0], [AC_PROG_CC])
44 AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
45 AC_BEFORE([$0], [AC_LBL_DEVEL])
46 AC_ARG_WITH(gcc, [ --without-gcc don't use gcc])
JP Abgrall511eca32014-02-12 13:46:45 -080047 $1=""
The Android Open Source Project478ab6c2009-03-03 19:30:05 -080048 if test "${srcdir}" != "." ; then
JP Abgrall511eca32014-02-12 13:46:45 -080049 $1="-I\$(srcdir)"
The Android Open Source Project478ab6c2009-03-03 19:30:05 -080050 fi
51 if test "${CFLAGS+set}" = set; then
52 LBL_CFLAGS="$CFLAGS"
53 fi
54 if test -z "$CC" ; then
JP Abgrall511eca32014-02-12 13:46:45 -080055 case "$host_os" in
The Android Open Source Project478ab6c2009-03-03 19:30:05 -080056
57 bsdi*)
58 AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
59 if test $SHLICC2 = yes ; then
60 CC=shlicc2
61 export CC
62 fi
63 ;;
64 esac
65 fi
66 if test -z "$CC" -a "$with_gcc" = no ; then
67 CC=cc
68 export CC
69 fi
JP Abgrall511eca32014-02-12 13:46:45 -080070])
71
72dnl
73dnl Determine which compiler we're using (cc or gcc)
74dnl If using gcc, determine the version number
75dnl If using cc:
76dnl require that it support ansi prototypes
77dnl use -O (AC_PROG_CC will use -g -O2 on gcc, so we don't need to
78dnl do that ourselves for gcc)
79dnl add -g flags, as appropriate
80dnl explicitly specify /usr/local/include
81dnl
82dnl NOTE WELL: with newer versions of autoconf, "gcc" means any compiler
83dnl that defines __GNUC__, which means clang, for example, counts as "gcc".
84dnl
85dnl usage:
86dnl
87dnl AC_LBL_C_INIT(copt, incls)
88dnl
89dnl results:
90dnl
91dnl $1 (copt set)
92dnl $2 (incls set)
93dnl CC
94dnl LDFLAGS
95dnl LBL_CFLAGS
96dnl
97AC_DEFUN(AC_LBL_C_INIT,
98[
99 AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
100 AC_BEFORE([$0], [AC_LBL_DEVEL])
101 AC_BEFORE([$0], [AC_LBL_SHLIBS_INIT])
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800102 if test "$GCC" = yes ; then
JP Abgrall511eca32014-02-12 13:46:45 -0800103 #
104 # -Werror forces warnings to be errors.
105 #
106 ac_lbl_cc_force_warning_errors=-Werror
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800107 else
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800108 $2="$$2 -I/usr/local/include"
109 LDFLAGS="$LDFLAGS -L/usr/local/lib"
110
JP Abgrall511eca32014-02-12 13:46:45 -0800111 case "$host_os" in
112
113 darwin*)
114 #
115 # This is assumed either to be GCC or clang, both
116 # of which use -Werror to force warnings to be errors.
117 #
118 ac_lbl_cc_force_warning_errors=-Werror
119 ;;
120
121 hpux*)
122 #
123 # HP C, which is what we presume we're using, doesn't
124 # exit with a non-zero exit status if we hand it an
125 # invalid -W flag, can't be forced to do so even with
126 # +We, and doesn't handle GCC-style -W flags, so we
127 # don't want to try using GCC-style -W flags.
128 #
129 ac_lbl_cc_dont_try_gcc_dashW=yes
130 ;;
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800131
132 irix*)
JP Abgrall511eca32014-02-12 13:46:45 -0800133 #
134 # MIPS C, which is what we presume we're using, doesn't
135 # necessarily exit with a non-zero exit status if we
136 # hand it an invalid -W flag, can't be forced to do
137 # so, and doesn't handle GCC-style -W flags, so we
138 # don't want to try using GCC-style -W flags.
139 #
140 ac_lbl_cc_dont_try_gcc_dashW=yes
141 #
142 # It also, apparently, defaults to "char" being
143 # unsigned, unlike most other C implementations;
144 # I suppose we could say "signed char" whenever
145 # we want to guarantee a signed "char", but let's
146 # just force signed chars.
147 #
148 # -xansi is normally the default, but the
149 # configure script was setting it; perhaps -cckr
150 # was the default in the Old Days. (Then again,
151 # that would probably be for backwards compatibility
152 # in the days when ANSI C was Shiny and New, i.e.
153 # 1989 and the early '90's, so maybe we can just
154 # drop support for those compilers.)
155 #
156 # -g is equivalent to -g2, which turns off
157 # optimization; we choose -g3, which generates
158 # debugging information but doesn't turn off
159 # optimization (even if the optimization would
160 # cause inaccuracies in debugging).
161 #
162 $1="$$1 -xansi -signed -g3"
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800163 ;;
164
165 osf*)
JP Abgrall511eca32014-02-12 13:46:45 -0800166 #
167 # Presumed to be DEC OSF/1, Digital UNIX, or
168 # Tru64 UNIX.
169 #
170 # The DEC C compiler, which is what we presume we're
171 # using, doesn't exit with a non-zero exit status if we
172 # hand it an invalid -W flag, can't be forced to do
173 # so, and doesn't handle GCC-style -W flags, so we
174 # don't want to try using GCC-style -W flags.
175 #
176 ac_lbl_cc_dont_try_gcc_dashW=yes
177 #
178 # -g is equivalent to -g2, which turns off
179 # optimization; we choose -g3, which generates
180 # debugging information but doesn't turn off
181 # optimization (even if the optimization would
182 # cause inaccuracies in debugging).
183 #
184 $1="$$1 -g3"
185 ;;
186
187 solaris*)
188 #
189 # Assumed to be Sun C, which requires -errwarn to force
190 # warnings to be treated as errors.
191 #
192 ac_lbl_cc_force_warning_errors=-errwarn
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800193 ;;
194
195 ultrix*)
196 AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
197 AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
198 AC_TRY_COMPILE(
199 [#include <sys/types.h>],
200 [struct a { int b; };
201 void c(const struct a *)],
202 ac_cv_lbl_cc_const_proto=yes,
203 ac_cv_lbl_cc_const_proto=no))
204 AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
205 if test $ac_cv_lbl_cc_const_proto = no ; then
JP Abgrall511eca32014-02-12 13:46:45 -0800206 AC_DEFINE(const,[],
207 [to handle Ultrix compilers that don't support const in prototypes])
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800208 fi
209 ;;
210 esac
JP Abgrall511eca32014-02-12 13:46:45 -0800211 $1="$$1 -O"
212 fi
213])
214
215dnl
216dnl Check whether, if you pass an unknown warning option to the
217dnl compiler, it fails or just prints a warning message and succeeds.
218dnl Set ac_lbl_unknown_warning_option_error to the appropriate flag
219dnl to force an error if it would otherwise just print a warning message
220dnl and succeed.
221dnl
222AC_DEFUN(AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR,
223 [
224 AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option])
225 save_CFLAGS="$CFLAGS"
226 CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
227 AC_TRY_COMPILE(
228 [],
229 [return 0],
230 [
231 AC_MSG_RESULT([no])
232 #
233 # We're assuming this is clang, where
234 # -Werror=unknown-warning-option is the appropriate
235 # option to force the compiler to fail.
236 #
237 ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
238 ],
239 [
240 AC_MSG_RESULT([yes])
241 ])
242 CFLAGS="$save_CFLAGS"
243 ])
244
245dnl
246dnl Check whether the compiler option specified as the second argument
247dnl is supported by the compiler and, if so, add it to the macro
248dnl specified as the first argument
249dnl
250AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
251 [
252 AC_MSG_CHECKING([whether the compiler supports the $2 option])
253 save_CFLAGS="$CFLAGS"
254 CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2"
255 AC_TRY_COMPILE(
256 [],
257 [return 0],
258 [
259 AC_MSG_RESULT([yes])
260 CFLAGS="$save_CFLAGS"
261 $1="$$1 $2"
262 ],
263 [
264 AC_MSG_RESULT([no])
265 CFLAGS="$save_CFLAGS"
266 ])
267 ])
268
269dnl
270dnl Check whether the compiler supports an option to generate
271dnl Makefile-style dependency lines
272dnl
273dnl GCC uses -M for this. Non-GCC compilers that support this
274dnl use a variety of flags, including but not limited to -M.
275dnl
276dnl We test whether the flag in question is supported, as older
277dnl versions of compilers might not support it.
278dnl
279dnl We don't try all the possible flags, just in case some flag means
280dnl "generate dependencies" on one compiler but means something else
281dnl on another compiler.
282dnl
283dnl Most compilers that support this send the output to the standard
284dnl output by default. IBM's XLC, however, supports -M but sends
285dnl the output to {sourcefile-basename}.u, and AIX has no /dev/stdout
286dnl to work around that, so we don't bother with XLC.
287dnl
288AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT,
289 [
290 AC_MSG_CHECKING([whether the compiler supports generating dependencies])
291 if test "$GCC" = yes ; then
292 #
293 # GCC, or a compiler deemed to be GCC by AC_PROG_CC (even
294 # though it's not); we assume that, in this case, the flag
295 # would be -M.
296 #
297 ac_lbl_dependency_flag="-M"
298 else
299 #
300 # Not GCC or a compiler deemed to be GCC; what platform is
301 # this? (We're assuming that if the compiler isn't GCC
302 # it's the compiler from the vendor of the OS; that won't
303 # necessarily be true for x86 platforms, where it might be
304 # the Intel C compiler.)
305 #
306 case "$host_os" in
307
308 irix*|osf*|darwin*)
309 #
310 # MIPS C for IRIX, DEC C, and clang all use -M.
311 #
312 ac_lbl_dependency_flag="-M"
313 ;;
314
315 solaris*)
316 #
317 # Sun C uses -xM.
318 #
319 ac_lbl_dependency_flag="-xM"
320 ;;
321
322 hpux*)
323 #
324 # HP's older C compilers don't support this.
325 # HP's newer C compilers support this with
326 # either +M or +Make; the older compilers
327 # interpret +M as something completely
328 # different, so we use +Make so we don't
329 # think it works with the older compilers.
330 #
331 ac_lbl_dependency_flag="+Make"
332 ;;
333
334 *)
335 #
336 # Not one of the above; assume no support for
337 # generating dependencies.
338 #
339 ac_lbl_dependency_flag=""
340 ;;
341 esac
342 fi
343
344 #
345 # Is ac_lbl_dependency_flag defined and, if so, does the compiler
346 # complain about it?
347 #
348 # Note: clang doesn't seem to exit with an error status when handed
349 # an unknown non-warning error, even if you pass it
350 # -Werror=unknown-warning-option. However, it always supports
351 # -M, so the fact that this test always succeeds with clang
352 # isn't an issue.
353 #
354 if test ! -z "$ac_lbl_dependency_flag"; then
355 AC_LANG_CONFTEST(
356 [AC_LANG_SOURCE([[int main(void) { return 0; }]])])
357 echo "$CC" $ac_lbl_dependency_flag conftest.c >&5
358 if "$CC" $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1; then
359 AC_MSG_RESULT([yes, with $ac_lbl_dependency_flag])
360 DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
361 MKDEP='${srcdir}/mkdep'
362 else
363 AC_MSG_RESULT([no])
364 #
365 # We can't run mkdep, so have "make depend" do
366 # nothing.
367 #
368 MKDEP=:
369 fi
370 rm -rf conftest*
371 else
372 AC_MSG_RESULT([no])
373 #
374 # We can't run mkdep, so have "make depend" do
375 # nothing.
376 #
377 MKDEP=:
378 fi
379 AC_SUBST(DEPENDENCY_CFLAG)
380 AC_SUBST(MKDEP)
381 ])
382
383dnl
384dnl Determine what options are needed to build a shared library
385dnl
386dnl usage:
387dnl
388dnl AC_LBL_SHLIBS_INIT
389dnl
390dnl results:
391dnl
392dnl V_CCOPT (modified to build position-independent code)
393dnl V_SHLIB_CMD
394dnl V_SHLIB_OPT
395dnl V_SONAME_OPT
396dnl V_RPATH_OPT
397dnl
398AC_DEFUN(AC_LBL_SHLIBS_INIT,
399 [AC_PREREQ(2.50)
400 if test "$GCC" = yes ; then
401 #
402 # On platforms where we build a shared library:
403 #
404 # add options to generate position-independent code,
405 # if necessary (it's the default in AIX and Darwin/OS X);
406 #
407 # define option to set the soname of the shared library,
408 # if the OS supports that;
409 #
410 # add options to specify, at link time, a directory to
411 # add to the run-time search path, if that's necessary.
412 #
413 V_SHLIB_CMD="\$(CC)"
414 V_SHLIB_OPT="-shared"
415 case "$host_os" in
416
417 aix*)
418 ;;
419
420 freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*)
421 #
422 # Platforms where the linker is the GNU linker
423 # or accepts command-line arguments like
424 # those the GNU linker accepts.
425 #
426 # Some instruction sets require -fPIC on some
427 # operating systems. Check for them. If you
428 # have a combination that requires it, add it
429 # here.
430 #
431 PIC_OPT=-fpic
432 case "$host_cpu" in
433
434 sparc64*)
435 case "$host_os" in
436
437 freebsd*|openbsd*)
438 PIC_OPT=-fPIC
439 ;;
440 esac
441 ;;
442 esac
443 V_CCOPT="$V_CCOPT $PIC_OPT"
444 V_SONAME_OPT="-Wl,-soname,"
445 V_RPATH_OPT="-Wl,-rpath,"
446 ;;
447
448 hpux*)
449 V_CCOPT="$V_CCOPT -fpic"
450 #
451 # XXX - this assumes GCC is using the HP linker,
452 # rather than the GNU linker, and that the "+h"
453 # option is used on all HP-UX platforms, both .sl
454 # and .so.
455 #
456 V_SONAME_OPT="-Wl,+h,"
457 #
458 # By default, directories specifed with -L
459 # are added to the run-time search path, so
460 # we don't add them in pcap-config.
461 #
462 ;;
463
464 solaris*)
465 V_CCOPT="$V_CCOPT -fpic"
466 #
467 # XXX - this assumes GCC is using the Sun linker,
468 # rather than the GNU linker.
469 #
470 V_SONAME_OPT="-Wl,-h,"
471 V_RPATH_OPT="-Wl,-R,"
472 ;;
473 esac
474 else
475 #
476 # Set the appropriate compiler flags and, on platforms
477 # where we build a shared library:
478 #
479 # add options to generate position-independent code,
480 # if necessary (it's the default in Darwin/OS X);
481 #
482 # if we generate ".so" shared libraries, define the
483 # appropriate options for building the shared library;
484 #
485 # add options to specify, at link time, a directory to
486 # add to the run-time search path, if that's necessary.
487 #
488 # Note: spaces after V_SONAME_OPT are significant; on
489 # some platforms the soname is passed with a GCC-like
490 # "-Wl,-soname,{soname}" option, with the soname part
491 # of the option, while on other platforms the C compiler
492 # driver takes it as a regular option with the soname
493 # following the option. The same applies to V_RPATH_OPT.
494 #
495 case "$host_os" in
496
497 aix*)
498 V_SHLIB_CMD="\$(CC)"
499 V_SHLIB_OPT="-G -bnoentry -bexpall"
500 ;;
501
502 freebsd*|netbsd*|openbsd*|dragonfly*|linux*)
503 #
504 # "cc" is GCC.
505 #
506 V_CCOPT="$V_CCOPT -fpic"
507 V_SHLIB_CMD="\$(CC)"
508 V_SHLIB_OPT="-shared"
509 V_SONAME_OPT="-Wl,-soname,"
510 V_RPATH_OPT="-Wl,-rpath,"
511 ;;
512
513 hpux*)
514 V_CCOPT="$V_CCOPT +z"
515 V_SHLIB_CMD="\$(LD)"
516 V_SHLIB_OPT="-b"
517 V_SONAME_OPT="+h "
518 #
519 # By default, directories specifed with -L
520 # are added to the run-time search path, so
521 # we don't add them in pcap-config.
522 #
523 ;;
524
525 osf*)
526 #
527 # Presumed to be DEC OSF/1, Digital UNIX, or
528 # Tru64 UNIX.
529 #
530 V_SHLIB_CMD="\$(CC)"
531 V_SHLIB_OPT="-shared"
532 V_SONAME_OPT="-soname "
533 V_RPATH_OPT="-rpath "
534 ;;
535
536 solaris*)
537 V_CCOPT="$V_CCOPT -Kpic"
538 V_SHLIB_CMD="\$(CC)"
539 V_SHLIB_OPT="-G"
540 V_SONAME_OPT="-h "
541 V_RPATH_OPT="-R"
542 ;;
543 esac
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800544 fi
545])
546
547#
548# Try compiling a sample of the type of code that appears in
549# gencode.c with "inline", "__inline__", and "__inline".
550#
551# Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough,
552# as it just tests whether a function returning "int" can be inlined;
553# at least some versions of HP's C compiler can inline that, but can't
554# inline a function that returns a struct pointer.
555#
556# Make sure we use the V_CCOPT flags, because some of those might
557# disable inlining.
558#
559AC_DEFUN(AC_LBL_C_INLINE,
560 [AC_MSG_CHECKING(for inline)
561 save_CFLAGS="$CFLAGS"
562 CFLAGS="$V_CCOPT"
563 AC_CACHE_VAL(ac_cv_lbl_inline, [
564 ac_cv_lbl_inline=""
565 ac_lbl_cc_inline=no
566 for ac_lbl_inline in inline __inline__ __inline
567 do
568 AC_TRY_COMPILE(
569 [#define inline $ac_lbl_inline
570 static inline struct iltest *foo(void);
571 struct iltest {
572 int iltest1;
573 int iltest2;
574 };
575
576 static inline struct iltest *
577 foo()
578 {
579 static struct iltest xxx;
580
581 return &xxx;
582 }],,ac_lbl_cc_inline=yes,)
583 if test "$ac_lbl_cc_inline" = yes ; then
584 break;
585 fi
586 done
587 if test "$ac_lbl_cc_inline" = yes ; then
588 ac_cv_lbl_inline=$ac_lbl_inline
589 fi])
590 CFLAGS="$save_CFLAGS"
591 if test ! -z "$ac_cv_lbl_inline" ; then
592 AC_MSG_RESULT($ac_cv_lbl_inline)
593 else
594 AC_MSG_RESULT(no)
595 fi
596 AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
597
598dnl
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800599dnl If using gcc, make sure we have ANSI ioctl definitions
600dnl
601dnl usage:
602dnl
603dnl AC_LBL_FIXINCLUDES
604dnl
605AC_DEFUN(AC_LBL_FIXINCLUDES,
606 [if test "$GCC" = yes ; then
607 AC_MSG_CHECKING(for ANSI ioctl definitions)
608 AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes,
609 AC_TRY_COMPILE(
610 [/*
611 * This generates a "duplicate case value" when fixincludes
612 * has not be run.
613 */
614# include <sys/types.h>
615# include <sys/time.h>
616# include <sys/ioctl.h>
617# ifdef HAVE_SYS_IOCCOM_H
618# include <sys/ioccom.h>
619# endif],
620 [switch (0) {
621 case _IO('A', 1):;
622 case _IO('B', 1):;
623 }],
624 ac_cv_lbl_gcc_fixincludes=yes,
625 ac_cv_lbl_gcc_fixincludes=no))
626 AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes)
627 if test $ac_cv_lbl_gcc_fixincludes = no ; then
628 # Don't cache failure
629 unset ac_cv_lbl_gcc_fixincludes
630 AC_MSG_ERROR(see the INSTALL for more info)
631 fi
632 fi])
633
634dnl
635dnl Check for flex, default to lex
636dnl Require flex 2.4 or higher
637dnl Check for bison, default to yacc
638dnl Default to lex/yacc if both flex and bison are not available
JP Abgrall511eca32014-02-12 13:46:45 -0800639dnl
640dnl If we're using flex and bison, pass -P to flex and -p to bison
641dnl to define a prefix string for the lexer and parser
642dnl
643dnl If we're not using flex and bison, don't pass those options
644dnl (as they might not work - although if "lex" is a wrapper for
645dnl Flex and "yacc" is a wrapper for Bison, they will work), and
646dnl define NEED_YYPARSE_WRAPPER (we *CANNOT* use YYBISON to check
647dnl whether the wrapper is needed, as some people apparently, for
648dnl some unknown reason, choose to use --without-flex and
649dnl --without-bison on systems that have Flex and Bison, which
650dnl means that the "yacc" they end up using is a wrapper that
651dnl runs "bison -y", and at least some versions of Bison define
652dnl YYBISON even if run with "-y", so we end up not compiling
653dnl the yyparse wrapper and end up with a libpcap that doesn't
654dnl define pcap_parse())
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800655dnl
656dnl usage:
657dnl
658dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
659dnl
660dnl results:
661dnl
662dnl $1 (lex set)
663dnl $2 (yacc appended)
664dnl $3 (optional flex and bison -P prefix)
665dnl
666AC_DEFUN(AC_LBL_LEX_AND_YACC,
667 [AC_ARG_WITH(flex, [ --without-flex don't use flex])
668 AC_ARG_WITH(bison, [ --without-bison don't use bison])
669 if test "$with_flex" = no ; then
670 $1=lex
671 else
672 AC_CHECK_PROGS($1, flex, lex)
673 fi
674 if test "$$1" = flex ; then
675 # The -V flag was added in 2.4
676 AC_MSG_CHECKING(for flex 2.4 or higher)
677 AC_CACHE_VAL(ac_cv_lbl_flex_v24,
678 if flex -V >/dev/null 2>&1; then
679 ac_cv_lbl_flex_v24=yes
680 else
681 ac_cv_lbl_flex_v24=no
682 fi)
683 AC_MSG_RESULT($ac_cv_lbl_flex_v24)
684 if test $ac_cv_lbl_flex_v24 = no ; then
685 s="2.4 or higher required"
686 AC_MSG_WARN(ignoring obsolete flex executable ($s))
687 $1=lex
688 fi
689 fi
690 if test "$with_bison" = no ; then
691 $2=yacc
692 else
693 AC_CHECK_PROGS($2, bison, yacc)
694 fi
695 if test "$$2" = bison ; then
696 $2="$$2 -y"
697 fi
698 if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
699 AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
700 $1=lex
701 $2=yacc
702 fi
703 if test "$$1" = flex -a -n "$3" ; then
704 $1="$$1 -P$3"
705 $2="$$2 -p $3"
JP Abgrall511eca32014-02-12 13:46:45 -0800706 else
707 AC_DEFINE(NEED_YYPARSE_WRAPPER,1,[if we need a pcap_parse wrapper around yyparse])
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800708 fi])
709
710dnl
711dnl Checks to see if union wait is used with WEXITSTATUS()
712dnl
713dnl usage:
714dnl
715dnl AC_LBL_UNION_WAIT
716dnl
717dnl results:
718dnl
719dnl DECLWAITSTATUS (defined)
720dnl
721AC_DEFUN(AC_LBL_UNION_WAIT,
722 [AC_MSG_CHECKING(if union wait is used)
723 AC_CACHE_VAL(ac_cv_lbl_union_wait,
724 AC_TRY_COMPILE([
725# include <sys/types.h>
726# include <sys/wait.h>],
727 [int status;
728 u_int i = WEXITSTATUS(status);
729 u_int j = waitpid(0, &status, 0);],
730 ac_cv_lbl_union_wait=no,
731 ac_cv_lbl_union_wait=yes))
732 AC_MSG_RESULT($ac_cv_lbl_union_wait)
733 if test $ac_cv_lbl_union_wait = yes ; then
734 AC_DEFINE(DECLWAITSTATUS,union wait,[type for wait])
735 else
736 AC_DEFINE(DECLWAITSTATUS,int,[type for wait])
737 fi])
738
739dnl
740dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
741dnl
742dnl usage:
743dnl
744dnl AC_LBL_SOCKADDR_SA_LEN
745dnl
746dnl results:
747dnl
748dnl HAVE_SOCKADDR_SA_LEN (defined)
749dnl
750AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
JP Abgrall511eca32014-02-12 13:46:45 -0800751 [AC_MSG_CHECKING(if sockaddr struct has the sa_len member)
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800752 AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len,
753 AC_TRY_COMPILE([
754# include <sys/types.h>
755# include <sys/socket.h>],
756 [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
757 ac_cv_lbl_sockaddr_has_sa_len=yes,
758 ac_cv_lbl_sockaddr_has_sa_len=no))
759 AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len)
760 if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then
JP Abgrall511eca32014-02-12 13:46:45 -0800761 AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[if struct sockaddr has the sa_len member])
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800762 fi])
763
764dnl
765dnl Checks to see if there's a sockaddr_storage structure
766dnl
767dnl usage:
768dnl
769dnl AC_LBL_SOCKADDR_STORAGE
770dnl
771dnl results:
772dnl
773dnl HAVE_SOCKADDR_STORAGE (defined)
774dnl
775AC_DEFUN(AC_LBL_SOCKADDR_STORAGE,
776 [AC_MSG_CHECKING(if sockaddr_storage struct exists)
777 AC_CACHE_VAL(ac_cv_lbl_has_sockaddr_storage,
778 AC_TRY_COMPILE([
779# include <sys/types.h>
780# include <sys/socket.h>],
781 [u_int i = sizeof (struct sockaddr_storage)],
782 ac_cv_lbl_has_sockaddr_storage=yes,
783 ac_cv_lbl_has_sockaddr_storage=no))
784 AC_MSG_RESULT($ac_cv_lbl_has_sockaddr_storage)
785 if test $ac_cv_lbl_has_sockaddr_storage = yes ; then
786 AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[if struct sockaddr_storage exists])
787 fi])
788
789dnl
790dnl Checks to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
791dnl dl_module_id_1 member
792dnl
793dnl usage:
794dnl
795dnl AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
796dnl
797dnl results:
798dnl
799dnl HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 (defined)
800dnl
801dnl NOTE: any compile failure means we conclude that it doesn't have
802dnl that member, so if we don't have DLPI, don't have a <sys/dlpi_ext.h>
803dnl header, or have one that doesn't declare a dl_hp_ppa_info_t type,
804dnl we conclude it doesn't have that member (which is OK, as either we
805dnl won't be using code that would use that member, or we wouldn't
806dnl compile in any case).
807dnl
808AC_DEFUN(AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1,
809 [AC_MSG_CHECKING(if dl_hp_ppa_info_t struct has dl_module_id_1 member)
810 AC_CACHE_VAL(ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1,
811 AC_TRY_COMPILE([
812# include <sys/types.h>
813# include <sys/dlpi.h>
814# include <sys/dlpi_ext.h>],
815 [u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)],
816 ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes,
817 ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no))
818 AC_MSG_RESULT($ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1)
819 if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then
820 AC_DEFINE(HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1,1,[if ppa_info_t_dl_module_id exists])
821 fi])
822
823dnl
824dnl Checks to see if -R is used
825dnl
826dnl usage:
827dnl
828dnl AC_LBL_HAVE_RUN_PATH
829dnl
830dnl results:
831dnl
832dnl ac_cv_lbl_have_run_path (yes or no)
833dnl
834AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
835 [AC_MSG_CHECKING(for ${CC-cc} -R)
836 AC_CACHE_VAL(ac_cv_lbl_have_run_path,
837 [echo 'main(){}' > conftest.c
838 ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
839 if test ! -s conftest.out ; then
840 ac_cv_lbl_have_run_path=yes
841 else
842 ac_cv_lbl_have_run_path=no
843 fi
JP Abgrall511eca32014-02-12 13:46:45 -0800844 rm -f -r conftest*])
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800845 AC_MSG_RESULT($ac_cv_lbl_have_run_path)
846 ])
847
848dnl
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800849dnl Checks to see if unaligned memory accesses fail
850dnl
851dnl usage:
852dnl
853dnl AC_LBL_UNALIGNED_ACCESS
854dnl
855dnl results:
856dnl
857dnl LBL_ALIGN (DEFINED)
858dnl
859AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
860 [AC_MSG_CHECKING(if unaligned accesses fail)
861 AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
862 [case "$host_cpu" in
863
864 #
865 # These are CPU types where:
866 #
867 # the CPU faults on an unaligned access, but at least some
868 # OSes that support that CPU catch the fault and simulate
869 # the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) -
870 # the simulation is slow, so we don't want to use it;
871 #
872 # the CPU, I infer (from the old
873 #
874 # XXX: should also check that they don't do weird things (like on arm)
875 #
876 # comment) doesn't fault on unaligned accesses, but doesn't
877 # do a normal unaligned fetch, either (e.g., presumably, ARM);
878 #
879 # for whatever reason, the test program doesn't work
880 # (this has been claimed to be the case for several of those
881 # CPUs - I don't know what the problem is; the problem
882 # was reported as "the test program dumps core" for SuperH,
883 # but that's what the test program is *supposed* to do -
884 # it dumps core before it writes anything, so the test
885 # for an empty output file should find an empty output
886 # file and conclude that unaligned accesses don't work).
887 #
888 # This run-time test won't work if you're cross-compiling, so
889 # in order to support cross-compiling for a particular CPU,
890 # we have to wire in the list of CPU types anyway, as far as
891 # I know, so perhaps we should just have a set of CPUs on
892 # which we know it doesn't work, a set of CPUs on which we
893 # know it does work, and have the script just fail on other
894 # cpu types and update it when such a failure occurs.
895 #
JP Abgrall511eca32014-02-12 13:46:45 -0800896 alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1)
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800897 ac_cv_lbl_unaligned_fail=yes
898 ;;
899
900 *)
901 cat >conftest.c <<EOF
902# include <sys/types.h>
903# include <sys/wait.h>
904# include <stdio.h>
905 unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
906 main() {
907 unsigned int i;
908 pid_t pid;
909 int status;
910 /* avoid "core dumped" message */
911 pid = fork();
912 if (pid < 0)
913 exit(2);
914 if (pid > 0) {
915 /* parent */
916 pid = waitpid(pid, &status, 0);
917 if (pid < 0)
918 exit(3);
919 exit(!WIFEXITED(status));
920 }
921 /* child */
922 i = *(unsigned int *)&a[[1]];
923 printf("%d\n", i);
924 exit(0);
925 }
926EOF
927 ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
928 conftest.c $LIBS >/dev/null 2>&1
929 if test ! -x conftest ; then
930 dnl failed to compile for some reason
931 ac_cv_lbl_unaligned_fail=yes
932 else
933 ./conftest >conftest.out
934 if test ! -s conftest.out ; then
935 ac_cv_lbl_unaligned_fail=yes
936 else
937 ac_cv_lbl_unaligned_fail=no
938 fi
939 fi
JP Abgrall511eca32014-02-12 13:46:45 -0800940 rm -f -r conftest* core core.conftest
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800941 ;;
942 esac])
943 AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
944 if test $ac_cv_lbl_unaligned_fail = yes ; then
945 AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails])
946 fi])
947
948dnl
JP Abgrall511eca32014-02-12 13:46:45 -0800949dnl If the file .devel exists:
950dnl Add some warning flags if the compiler supports them
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800951dnl If an os prototype include exists, symlink os-proto.h to it
952dnl
953dnl usage:
954dnl
955dnl AC_LBL_DEVEL(copt)
956dnl
957dnl results:
958dnl
959dnl $1 (copt appended)
960dnl HAVE_OS_PROTO_H (defined)
961dnl os-proto.h (symlinked)
962dnl
963AC_DEFUN(AC_LBL_DEVEL,
964 [rm -f os-proto.h
965 if test "${LBL_CFLAGS+set}" = set; then
966 $1="$$1 ${LBL_CFLAGS}"
967 fi
968 if test -f .devel ; then
JP Abgrall511eca32014-02-12 13:46:45 -0800969 #
970 # Skip all the warning option stuff on some compilers.
971 #
972 if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
973 AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR()
974 AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
975 AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
976 AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800977 fi
JP Abgrall511eca32014-02-12 13:46:45 -0800978 AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
979 #
980 # We used to set -n32 for IRIX 6 when not using GCC (presumed
981 # to mean that we're using MIPS C or MIPSpro C); it specified
982 # the "new" faster 32-bit ABI, introduced in IRIX 6.2. I'm
983 # not sure why that would be something to do *only* with a
984 # .devel file; why should the ABI for which we produce code
985 # depend on .devel?
986 #
987 os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800988 name="lbl/os-$os.h"
989 if test -f $name ; then
990 ln -s $name os-proto.h
JP Abgrall511eca32014-02-12 13:46:45 -0800991 AC_DEFINE(HAVE_OS_PROTO_H, 1,
992 [if there's an os_proto.h for this platform, to use additional prototypes])
The Android Open Source Project478ab6c2009-03-03 19:30:05 -0800993 else
994 AC_MSG_WARN(can't find $name)
995 fi
996 fi])
997
998dnl
999dnl Improved version of AC_CHECK_LIB
1000dnl
1001dnl Thanks to John Hawkinson (jhawk@mit.edu)
1002dnl
1003dnl usage:
1004dnl
1005dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
1006dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
1007dnl
1008dnl results:
1009dnl
1010dnl LIBS
1011dnl
JP Abgrall511eca32014-02-12 13:46:45 -08001012dnl XXX - "AC_LBL_LIBRARY_NET" was redone to use "AC_SEARCH_LIBS"
1013dnl rather than "AC_LBL_CHECK_LIB", so this isn't used any more.
1014dnl We keep it around for reference purposes in case it's ever
1015dnl useful in the future.
1016dnl
The Android Open Source Project478ab6c2009-03-03 19:30:05 -08001017
1018define(AC_LBL_CHECK_LIB,
1019[AC_MSG_CHECKING([for $2 in -l$1])
JP Abgrall511eca32014-02-12 13:46:45 -08001020dnl Use a cache variable name containing the library, function
1021dnl name, and extra libraries to link with, because the test really is
1022dnl for library $1 defining function $2, when linked with potinal
1023dnl library $5, not just for library $1. Separate tests with the same
1024dnl $1 and different $2's or $5's may have different results.
The Android Open Source Project478ab6c2009-03-03 19:30:05 -08001025ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
1026AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
1027[ac_save_LIBS="$LIBS"
1028LIBS="-l$1 $5 $LIBS"
1029AC_TRY_LINK(dnl
1030ifelse([$2], [main], , dnl Avoid conflicting decl of main.
1031[/* Override any gcc2 internal prototype to avoid an error. */
1032]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
1033extern "C"
1034#endif
1035])dnl
1036[/* We use char because int might match the return type of a gcc2
1037 builtin and then its argument prototype would still apply. */
1038char $2();
1039]),
1040 [$2()],
1041 eval "ac_cv_lbl_lib_$ac_lib_var=yes",
1042 eval "ac_cv_lbl_lib_$ac_lib_var=no")
1043LIBS="$ac_save_LIBS"
1044])dnl
1045if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
1046 AC_MSG_RESULT(yes)
1047 ifelse([$3], ,
1048[changequote(, )dnl
1049 ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
1050 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1051changequote([, ])dnl
1052 AC_DEFINE_UNQUOTED($ac_tr_lib)
1053 LIBS="-l$1 $LIBS"
1054], [$3])
1055else
1056 AC_MSG_RESULT(no)
1057ifelse([$4], , , [$4
1058])dnl
1059fi
1060])
1061
1062dnl
1063dnl AC_LBL_LIBRARY_NET
1064dnl
1065dnl This test is for network applications that need socket() and
1066dnl gethostbyname() -ish functions. Under Solaris, those applications
1067dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link
1068dnl with "-lnsl" but should *not* link with "-lsocket" because
1069dnl libsocket.a breaks a number of things (for instance:
1070dnl gethostbyname() under IRIX 5.2, and snoop sockets under most
1071dnl versions of IRIX).
1072dnl
1073dnl Unfortunately, many application developers are not aware of this,
1074dnl and mistakenly write tests that cause -lsocket to be used under
1075dnl IRIX. It is also easy to write tests that cause -lnsl to be used
1076dnl under operating systems where neither are necessary (or useful),
1077dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
1078dnl
1079dnl This test exists so that every application developer does not test
1080dnl this in a different, and subtly broken fashion.
1081
1082dnl It has been argued that this test should be broken up into two
1083dnl seperate tests, one for the resolver libraries, and one for the
1084dnl libraries necessary for using Sockets API. Unfortunately, the two
1085dnl are carefully intertwined and allowing the autoconf user to use
1086dnl them independantly potentially results in unfortunate ordering
1087dnl dependancies -- as such, such component macros would have to
1088dnl carefully use indirection and be aware if the other components were
1089dnl executed. Since other autoconf macros do not go to this trouble,
1090dnl and almost no applications use sockets without the resolver, this
1091dnl complexity has not been implemented.
1092dnl
1093dnl The check for libresolv is in case you are attempting to link
1094dnl statically and happen to have a libresolv.a lying around (and no
1095dnl libnsl.a).
1096dnl
1097AC_DEFUN(AC_LBL_LIBRARY_NET, [
1098 # Most operating systems have gethostbyname() in the default searched
1099 # libraries (i.e. libc):
1100 # Some OSes (eg. Solaris) place it in libnsl
1101 # Some strange OSes (SINIX) have it in libsocket:
1102 AC_SEARCH_LIBS(gethostbyname, nsl socket resolv)
1103 # Unfortunately libsocket sometimes depends on libnsl and
1104 # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this.
1105 if test "$ac_cv_search_gethostbyname" = "no"
1106 then
1107 AC_CHECK_LIB(socket, gethostbyname,
1108 LIBS="-lsocket -lnsl $LIBS", , -lnsl)
1109 fi
1110 AC_SEARCH_LIBS(socket, socket, ,
1111 AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl))
1112 # DLPI needs putmsg under HPUX so test for -lstr while we're at it
1113 AC_SEARCH_LIBS(putmsg, str)
1114 ])
1115
1116dnl
1117dnl Test for __attribute__
1118dnl
1119
1120AC_DEFUN(AC_C___ATTRIBUTE__, [
1121AC_MSG_CHECKING(for __attribute__)
1122AC_CACHE_VAL(ac_cv___attribute__, [
JP Abgrall511eca32014-02-12 13:46:45 -08001123AC_COMPILE_IFELSE([
The Android Open Source Project478ab6c2009-03-03 19:30:05 -08001124 AC_LANG_SOURCE([[
1125#include <stdlib.h>
1126
1127static void foo(void) __attribute__ ((noreturn));
1128
1129static void
1130foo(void)
1131{
1132 exit(1);
1133}
1134
1135int
1136main(int argc, char **argv)
1137{
1138 foo();
1139}
JP Abgrall511eca32014-02-12 13:46:45 -08001140 ]])],
The Android Open Source Project478ab6c2009-03-03 19:30:05 -08001141ac_cv___attribute__=yes,
1142ac_cv___attribute__=no)])
1143if test "$ac_cv___attribute__" = "yes"; then
1144 AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
JP Abgrall511eca32014-02-12 13:46:45 -08001145else
1146 #
1147 # We can't use __attribute__, so we can't use __attribute__((unused)),
1148 # so we define _U_ to an empty string.
1149 #
1150 V_DEFS="$V_DEFS -D_U_=\"\""
1151fi
1152AC_MSG_RESULT($ac_cv___attribute__)
1153])
1154
1155dnl
1156dnl Test whether __attribute__((unused)) can be used without warnings
1157dnl
1158
1159AC_DEFUN(AC_C___ATTRIBUTE___UNUSED, [
1160AC_MSG_CHECKING([whether __attribute__((unused)) can be used without warnings])
1161AC_CACHE_VAL(ac_cv___attribute___unused, [
1162save_CFLAGS="$CFLAGS"
1163CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
1164AC_COMPILE_IFELSE([
1165 AC_LANG_SOURCE([[
1166#include <stdlib.h>
1167#include <stdio.h>
1168
1169int
1170main(int argc __attribute((unused)), char **argv __attribute((unused)))
1171{
1172 printf("Hello, world!\n");
1173 return 0;
1174}
1175 ]])],
1176ac_cv___attribute___unused=yes,
1177ac_cv___attribute___unused=no)])
1178CFLAGS="$save_CFLAGS"
1179if test "$ac_cv___attribute___unused" = "yes"; then
The Android Open Source Project478ab6c2009-03-03 19:30:05 -08001180 V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
1181else
1182 V_DEFS="$V_DEFS -D_U_=\"\""
1183fi
JP Abgrall511eca32014-02-12 13:46:45 -08001184AC_MSG_RESULT($ac_cv___attribute___unused)
1185])
1186
1187dnl
1188dnl Test whether __attribute__((format)) can be used without warnings
1189dnl
1190
1191AC_DEFUN(AC_C___ATTRIBUTE___FORMAT, [
1192AC_MSG_CHECKING([whether __attribute__((format)) can be used without warnings])
1193AC_CACHE_VAL(ac_cv___attribute___format, [
1194save_CFLAGS="$CFLAGS"
1195CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
1196AC_COMPILE_IFELSE([
1197 AC_LANG_SOURCE([[
1198#include <stdlib.h>
1199
1200extern int foo(const char *fmt, ...)
1201 __attribute__ ((format (printf, 1, 2)));
1202
1203int
1204main(int argc, char **argv)
1205{
1206 foo("%s", "test");
1207}
1208 ]])],
1209ac_cv___attribute___format=yes,
1210ac_cv___attribute___format=no)])
1211CFLAGS="$save_CFLAGS"
1212if test "$ac_cv___attribute___format" = "yes"; then
1213 AC_DEFINE(__ATTRIBUTE___FORMAT_OK, 1,
1214 [define if your compiler allows __attribute__((format)) without a warning])
1215fi
1216AC_MSG_RESULT($ac_cv___attribute___format)
The Android Open Source Project478ab6c2009-03-03 19:30:05 -08001217])
1218
1219dnl
1220dnl Checks to see if tpacket_stats is defined in linux/if_packet.h
1221dnl If so then pcap-linux.c can use this to report proper statistics.
1222dnl
1223dnl -Scott Barron
1224dnl
1225AC_DEFUN(AC_LBL_TPACKET_STATS,
1226 [AC_MSG_CHECKING(if if_packet.h has tpacket_stats defined)
1227 AC_CACHE_VAL(ac_cv_lbl_tpacket_stats,
1228 AC_TRY_COMPILE([
1229# include <linux/if_packet.h>],
1230 [struct tpacket_stats stats],
1231 ac_cv_lbl_tpacket_stats=yes,
1232 ac_cv_lbl_tpacket_stats=no))
1233 AC_MSG_RESULT($ac_cv_lbl_tpacket_stats)
1234 if test $ac_cv_lbl_tpacket_stats = yes; then
1235 AC_DEFINE(HAVE_TPACKET_STATS,1,[if if_packet.h has tpacket_stats defined])
1236 fi])
JP Abgrall511eca32014-02-12 13:46:45 -08001237
1238dnl
1239dnl Checks to see if the tpacket_auxdata struct has a tp_vlan_tci member.
1240dnl
1241dnl usage:
1242dnl
1243dnl AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
1244dnl
1245dnl results:
1246dnl
1247dnl HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI (defined)
1248dnl
1249dnl NOTE: any compile failure means we conclude that it doesn't have
1250dnl that member, so if we don't have tpacket_auxdata, we conclude it
1251dnl doesn't have that member (which is OK, as either we won't be using
1252dnl code that would use that member, or we wouldn't compile in any case).
1253dnl
1254AC_DEFUN(AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,
1255 [AC_MSG_CHECKING(if tpacket_auxdata struct has tp_vlan_tci member)
1256 AC_CACHE_VAL(ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci,
1257 AC_TRY_COMPILE([
1258# include <sys/types.h>
1259# include <linux/if_packet.h>],
1260 [u_int i = sizeof(((struct tpacket_auxdata *)0)->tp_vlan_tci)],
1261 ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=yes,
1262 ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=no))
1263 AC_MSG_RESULT($ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci)
1264 if test $ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci = yes ; then
1265 HAVE_LINUX_TPACKET_AUXDATA=tp_vlan_tci
1266 AC_SUBST(HAVE_LINUX_TPACKET_AUXDATA)
1267 AC_DEFINE(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,1,[if tp_vlan_tci exists])
1268 fi])
1269
1270dnl
1271dnl Checks to see if Solaris has the dl_passive_req_t struct defined
1272dnl in <sys/dlpi.h>.
1273dnl
1274dnl usage:
1275dnl
1276dnl AC_LBL_DL_PASSIVE_REQ_T
1277dnl
1278dnl results:
1279dnl
1280dnl HAVE_DLPI_PASSIVE (defined)
1281dnl
1282AC_DEFUN(AC_LBL_DL_PASSIVE_REQ_T,
1283 [AC_MSG_CHECKING(if dl_passive_req_t struct exists)
1284 AC_CACHE_VAL(ac_cv_lbl_has_dl_passive_req_t,
1285 AC_TRY_COMPILE([
1286# include <sys/types.h>
1287# include <sys/dlpi.h>],
1288 [u_int i = sizeof(dl_passive_req_t)],
1289 ac_cv_lbl_has_dl_passive_req_t=yes,
1290 ac_cv_lbl_has_dl_passive_req_t=no))
1291 AC_MSG_RESULT($ac_cv_lbl_has_dl_passive_req_t)
1292 if test $ac_cv_lbl_has_dl_passive_req_t = yes ; then
1293 AC_DEFINE(HAVE_DLPI_PASSIVE,1,[if passive_req_t primitive
1294 exists])
1295 fi])