1 dnl Macros that test for specific features.
2 dnl This file is part of the Autoconf packaging for Wireshark.
3 dnl Copyright (C) 1998-2000 by Gerald Combs.
7 dnl This program is free software; you can redistribute it and/or modify
8 dnl it under the terms of the GNU General Public License as published by
9 dnl the Free Software Foundation; either version 2, or (at your option)
10 dnl any later version.
12 dnl This program is distributed in the hope that it will be useful,
13 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 dnl GNU General Public License for more details.
17 dnl You should have received a copy of the GNU General Public License
18 dnl along with this program; if not, write to the Free Software
19 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 dnl As a special exception, the Free Software Foundation gives unlimited
23 dnl permission to copy, distribute and modify the configure scripts that
24 dnl are the output of Autoconf. You need not follow the terms of the GNU
25 dnl General Public License when using or distributing such scripts, even
26 dnl though portions of the text of Autoconf appear in them. The GNU
27 dnl General Public License (GPL) does govern all other use of the material
28 dnl that constitutes the Autoconf program.
30 dnl Certain portions of the Autoconf source text are designed to be copied
31 dnl (in certain cases, depending on the input) into the output of
32 dnl Autoconf. We call these the "data" portions. The rest of the Autoconf
33 dnl source text consists of comments plus executable code that decides which
34 dnl of the data portions to output in any given case. We call these
35 dnl comments and executable code the "non-data" portions. Autoconf never
36 dnl copies any of the non-data portions into its output.
38 dnl This special exception to the GPL applies to versions of Autoconf
39 dnl released by the Free Software Foundation. When you make and
40 dnl distribute a modified version of Autoconf, you may extend this special
41 dnl exception to the GPL to apply to your modified version as well, *unless*
42 dnl your modified version has the potential to copy into its output some
43 dnl of the text that was the non-data portion of the version that you started
44 dnl with. (In other words, unless your change moves or copies text from
45 dnl the non-data portions to the data portions.) If your modification has
46 dnl such potential, you must delete any notice of this special exception
47 dnl to the GPL from your modified version.
49 dnl Written by David MacKenzie, with help from
50 dnl Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
51 dnl Roland McGrath, Noah Friedman, david d zuhn, and many others.
54 # AC_WIRESHARK_ADD_DASH_L
56 # Add to the variable specified as the first argument a "-L" flag for the
57 # directory specified as the second argument, and, on Solaris, add a
58 # "-R" flag for it as well.
60 # XXX - IRIX, and other OSes, may require some flag equivalent to
63 AC_DEFUN([AC_WIRESHARK_ADD_DASH_L],
73 # AC_WIRESHARK_TIMEZONE_ABBREV
76 AC_DEFUN([AC_WIRESHARK_TIMEZONE_ABBREV],
78 AC_CACHE_CHECK([for tm_zone in struct tm],
79 ac_cv_wireshark_have_tm_zone,
83 [struct tm t; t.tm_zone;],
84 ac_cv_wireshark_have_tm_zone=yes,
85 ac_cv_wireshark_have_tm_zone=no)
87 if test $ac_cv_wireshark_have_tm_zone = yes; then
88 AC_DEFINE(HAVE_TM_ZONE, 1, [Define if tm_zone field exists in struct tm])
90 AC_CACHE_CHECK([for tzname],
91 ac_cv_wireshark_have_tzname,
96 [printf("%s", tzname[0]);],
97 ac_cv_wireshark_have_tzname=yes,
98 ac_cv_wireshark_have_tzname=no)
100 if test $ac_cv_wireshark_have_tzname = yes; then
101 AC_DEFINE(HAVE_TZNAME, 1, [Define if tzname array exists])
108 # AC_WIRESHARK_STRUCT_ST_FLAGS
110 dnl AC_STRUCT_ST_BLKSIZE extracted from the file in question,
111 dnl "acspecific.m4" in GNU Autoconf 2.12, and turned into
112 dnl AC_WIRESHARK_STRUCT_ST_FLAGS, which checks if "struct stat"
113 dnl has the 4.4BSD "st_flags" member, and defines HAVE_ST_FLAGS; that's
114 dnl what's in this file.
115 dnl Done by Guy Harris <guy@alum.mit.edu> on 2012-06-02.
117 dnl ### Checks for structure members
119 AC_DEFUN([AC_WIRESHARK_STRUCT_ST_FLAGS],
120 [AC_CACHE_CHECK([for st_flags in struct stat], ac_cv_wireshark_struct_st_flags,
121 [AC_TRY_COMPILE([#include <sys/stat.h>], [struct stat s; s.st_flags;],
122 ac_cv_wireshark_struct_st_flags=yes, ac_cv_wireshark_struct_st_flags=no)])
123 if test $ac_cv_wireshark_struct_st_flags = yes; then
124 AC_DEFINE(HAVE_ST_FLAGS, 1, [Define if st_flags field exists in struct stat])
130 # AC_WIRESHARK_STRUCT_SA_LEN
132 dnl AC_STRUCT_ST_BLKSIZE extracted from the file in question,
133 dnl "acspecific.m4" in GNU Autoconf 2.12, and turned into
134 dnl AC_WIRESHARK_STRUCT_SA_LEN, which checks if "struct sockaddr"
135 dnl has the 4.4BSD "sa_len" member, and defines HAVE_SA_LEN; that's
136 dnl what's in this file.
137 dnl Done by Guy Harris <guy@alum.mit.edu> on 1998-11-14.
139 dnl ### Checks for structure members
141 AC_DEFUN([AC_WIRESHARK_STRUCT_SA_LEN],
142 [AC_CACHE_CHECK([for sa_len in struct sockaddr], ac_cv_wireshark_struct_sa_len,
143 [AC_TRY_COMPILE([#include <sys/types.h>
144 #include <sys/socket.h>], [struct sockaddr s; s.sa_len;],
145 ac_cv_wireshark_struct_sa_len=yes, ac_cv_wireshark_struct_sa_len=no)])
146 if test $ac_cv_wireshark_struct_sa_len = yes; then
147 AC_DEFINE(HAVE_SA_LEN, 1, [Define if sa_len field exists in struct sockaddr])
153 # AC_WIRESHARK_IPV6_STACK
155 # By Jun-ichiro "itojun" Hagino, <itojun@iijlab.net>
157 AC_DEFUN([AC_WIRESHARK_IPV6_STACK],
162 AC_MSG_CHECKING([ipv6 stack type])
163 for i in v6d toshiba kame inria zeta linux linux-glibc solaris; do
167 #include </usr/local/v6/include/sys/types.h>
171 [v6type=$i; v6lib=v6;
172 v6libdir=/usr/local/v6/lib;
174 # XXX - this doesn't define INET6;
177 CPPFLAGS="-I/usr/local/v6/include $CPPFLAGS"])
181 #include <sys/param.h>
182 #ifdef _TOSHIBA_INET6
185 [v6type=$i; v6lib=inet6;
186 v6libdir=/usr/local/v6/lib;
187 AC_DEFINE(INET6, 1, [Define if the platform supports IPv6])])
191 #include <netinet/in.h>
195 [v6type=$i; v6lib=inet6;
196 v6libdir=/usr/local/v6/lib;
197 AC_DEFINE(INET6, 1, [Define if the platform supports IPv6])])
201 #include <netinet/in.h>
202 #ifdef IPV6_INRIA_VERSION
206 AC_DEFINE(INET6, 1, [Define if the platform supports IPv6])])
210 #include <sys/param.h>
211 #ifdef _ZETA_MINAMI_INET6
214 [v6type=$i; v6lib=inet6;
215 v6libdir=/usr/local/v6/lib;
216 AC_DEFINE(INET6, 1, [Define if the platform supports IPv6])])
219 if test -d /usr/inet6; then
223 AC_DEFINE(INET6, 1, [Define if the platform supports IPv6])
228 #include <features.h>
229 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
230 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || __GLIBC__ > 2
234 [v6type=$i; v6lib=inet6;
235 AC_DEFINE(INET6, 1, [Define if the platform supports IPv6])])
239 # There's nothing we can check for in the header
240 # file, so we just check for SunOS (pre-SunOS 5
241 # versions didn't include IPv6 support, so we
242 # just check the OS, not the version).
244 if test "`uname -s`" = "SunOS"; then
247 AC_DEFINE(INET6, 1, [Define if the platform supports IPv6])
251 if test "$v6type" != "unknown"; then
256 if test "$v6lib" != "none"; then
257 for dir in $v6libdir /usr/local/v6/lib /usr/local/lib; do
258 if test -d $dir -a -f $dir/lib$v6lib.a; then
259 LIBS="-L$dir $LIBS -l$v6lib"
267 AC_MSG_RESULT(["$v6type, $v6lib"])
271 # AC_WIRESHARK_GETADDRINFO_LIB_CHECK
273 # Checks whether we have "getaddrinfo()" and whether we need "-lnsl" to get it.
274 AC_DEFUN([AC_WIRESHARK_GETADDRINFO_LIB_CHECK],
276 AC_CHECK_FUNCS(getaddrinfo, ,
277 AC_CHECK_LIB(nsl, getaddrinfo,
280 AC_DEFINE(HAVE_GETADDRINFO, 1, [Defined if we have getaddrinfo])
286 # AC_WIRESHARK_GETHOSTBY_LIB_CHECK
288 # Checks whether we need "-lnsl" to get "gethostby*()", which we use
291 # Adapted from stuff in the AC_PATH_XTRA macro in "acspecific.m4" in
292 # GNU Autoconf 2.13; the comment came from there.
293 # Done by Guy Harris <guy@alum.mit.edu> on 2000-01-14.
295 AC_DEFUN([AC_WIRESHARK_GETHOSTBY_LIB_CHECK],
297 # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
298 # to get the SysV transport functions.
299 # chad@anasazi.com says the Pyramid MIS-ES running DC/OSx (SVR4)
301 # The nsl library prevents programs from opening the X display
302 # on Irix 5.2, according to dickey@clark.net.
303 AC_CHECK_FUNCS(gethostbyname, ,
304 AC_CHECK_LIB(nsl, gethostbyname,
307 AC_DEFINE(HAVE_GETHOSTBYNAME, 1, [Defined if we have gethostbyname])
313 # AC_WIRESHARK_SOCKET_LIB_CHECK
315 # Checks whether we need "-lsocket" to get "socket()", which is used
316 # by libpcap on some platforms - and, in effect, "gethostbyname()" or
317 # "getaddrinfo()" on most if not all platforms (so that it can use NIS or
318 # DNS or... to look up host names).
320 # Adapted from stuff in the AC_PATH_XTRA macro in "acspecific.m4" in
321 # GNU Autoconf 2.13; the comment came from there.
322 # Done by Guy Harris <guy@alum.mit.edu> on 2000-01-14.
324 # We use "connect" because that's what AC_PATH_XTRA did.
326 AC_DEFUN([AC_WIRESHARK_SOCKET_LIB_CHECK],
328 # lieder@skyler.mavd.honeywell.com says without -lsocket,
329 # socket/setsockopt and other routines are undefined under SCO ODT
330 # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary
331 # on later versions), says simon@lia.di.epfl.ch: it contains
332 # gethostby* variants that don't use the nameserver (or something).
333 # -lsocket must be given before -lnsl if both are needed.
334 # We assume that if connect needs -lnsl, so does gethostbyname.
335 AC_CHECK_FUNC(connect, ,
336 AC_CHECK_LIB(socket, connect, SOCKET_LIBS="-lsocket",
337 AC_MSG_ERROR(Function 'socket' not found.), $NSL_LIBS))
338 AC_SUBST(SOCKET_LIBS)
342 # AC_WIRESHARK_BREAKLOOP_TRY_LINK
344 AC_DEFUN([AC_WIRESHARK_PCAP_BREAKLOOP_TRY_LINK],
360 ws_breakloop_compiled=yes
363 ws_breakloop_compiled=no
370 # AC_WIRESHARK_PCAP_CHECK
372 AC_DEFUN([AC_WIRESHARK_PCAP_CHECK],
374 if test -z "$pcap_dir"
377 # XXX need to set a var AC_CHECK_HEADER(pcap.h,,)
380 # The user didn't specify a directory in which libpcap resides.
381 # First, look for a pcap-config script.
383 AC_PATH_PROG(PCAP_CONFIG, pcap-config)
385 if test -n "$PCAP_CONFIG" ; then
389 # Now check whether it's the libpcap 1.0 version, which
390 # put a space after "-L" - on some platforms, that doesn't
393 AC_MSG_CHECKING(for broken pcap-config)
394 case "`\"$PCAP_CONFIG\" --libs`" in
398 # Space after -L. Pretend pcap-config doesn't exist.
412 if test -n "$PCAP_CONFIG" ; then
414 # Found it, and it's usable; use it to get the include flags
417 CPPFLAGS="$CPPFLAGS `\"$PCAP_CONFIG\" --cflags`"
420 # Didn't find it; we have to look for libpcap ourselves.
421 # We assume that the current library search path will work,
422 # but we may have to look for the header in a "pcap"
423 # subdirectory of "/usr/include" or "/usr/local/include",
424 # as some systems apparently put "pcap.h" in a "pcap"
425 # subdirectory, and we also check "$prefix/include" - and
426 # "$prefix/include/pcap", in case $prefix is set to
427 # "/usr/include" or "/usr/local/include".
429 # XXX - should we just add "$prefix/include" to the include
430 # search path and "$prefix/lib" to the library search path?
432 AC_MSG_CHECKING(for extraneous pcap header directories)
434 pcap_dir_list="/usr/include/pcap $prefix/include/pcap $prefix/include"
435 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
436 pcap_dir_list="$pcap_dir_list /usr/local/include/pcap"
438 for pcap_dir in $pcap_dir_list
440 if test -d $pcap_dir ; then
441 if test x$pcap_dir != x/usr/include -a x$pcap_dir != x/usr/local/include ; then
442 CPPFLAGS="$CPPFLAGS -I$pcap_dir"
444 found_pcap_dir=" $found_pcap_dir -I$pcap_dir"
449 if test "$found_pcap_dir" != "" ; then
450 AC_MSG_RESULT(found --$found_pcap_dir added to CFLAGS)
452 AC_MSG_RESULT(not found)
457 # The user specified a directory in which libpcap resides,
458 # so add the "include" subdirectory of that directory to
459 # the include file search path and the "lib" subdirectory
460 # of that directory to the library search path.
462 # XXX - if there's also a libpcap in a directory that's
463 # already in CPPFLAGS or LDFLAGS, this won't make us find
464 # the version in the specified directory, as the compiler
465 # and/or linker will search that other directory before it
466 # searches the specified directory.
468 CPPFLAGS="$CPPFLAGS -I$pcap_dir/include"
469 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, $pcap_dir/lib)
473 AC_CHECK_HEADER(pcap.h,,
474 AC_MSG_ERROR([[Header file pcap.h not found; if you installed libpcap
475 from source, did you also do \"make install-incl\", and if you installed a
476 binary package of libpcap, is there also a developer's package of libpcap,
477 and did you also install that package?]]))
479 if test -n "$PCAP_CONFIG" ; then
481 # We have pcap-config; we assume that means we have libpcap
482 # installed and that pcap-config will tell us whatever
483 # libraries libpcap needs.
485 if test x$enable_static = xyes; then
486 PCAP_LIBS="`\"$PCAP_CONFIG\" --libs --static`"
488 PCAP_LIBS="`\"$PCAP_CONFIG\" --libs`"
490 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library])
493 # Check to see if we find "pcap_open_live" in "-lpcap".
494 # Also check for various additional libraries that libpcap might
497 AC_CHECK_LIB(pcap, pcap_open_live,
500 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library])
502 ac_wireshark_extras_found=no
504 for extras in "-lcfg -lodm" "-lpfring"
506 AC_MSG_CHECKING([for pcap_open_live in -lpcap with $extras])
507 LIBS="-lpcap $extras"
509 # XXX - can't we use AC_CHECK_LIB here?
516 pcap_open_live(NULL, 0, 0, 0, NULL);
519 ac_wireshark_extras_found=yes
521 PCAP_LIBS="-lpcap $extras"
522 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library])
527 if test x$ac_wireshark_extras_found = xyes
532 if test x$ac_wireshark_extras_found = xno
534 AC_MSG_ERROR([Can't link with library libpcap.])
537 ], $SOCKET_LIBS $NSL_LIBS)
542 # Check whether various variables and functions are defined by
546 LIBS="$PCAP_LIBS $SOCKET_LIBS $NSL_LIBS $LIBS"
547 AC_CHECK_FUNCS(pcap_open_dead pcap_freecode)
549 # pcap_breakloop may be present in the library but not declared
550 # in the pcap.h header file. If it's not declared in the header
551 # file, attempts to use it will get warnings, and, if we're
552 # building with warnings treated as errors, that warning will
553 # cause compilation to fail.
555 # We are therefore first testing whether the function is present
556 # and then, if we're compiling with warnings as errors, testing
557 # whether it is usable. It is usable if it compiles without
558 # a -Wimplicit warning (the "compile with warnings as errors"
559 # option requires GCC). If it is not usable, we fail and tell
560 # the user that the pcap.h header needs to be updated.
562 # Ceteris paribus, this should only happen with Mac OS X 10.3[.x] which
563 # can have an up-to-date pcap library without the corresponding pcap
566 # However, it might also happen on some others OSes with some erroneous
567 # system manipulations where multiple versions of libpcap might co-exist
568 # e.g. hand made symbolic link from libpcap.so -> libpcap.so.0.8 but
569 # having the pcap header version 0.7.
571 AC_MSG_CHECKING([whether pcap_breakloop is present])
572 ac_CFLAGS_saved="$CFLAGS"
573 AC_WIRESHARK_PCAP_BREAKLOOP_TRY_LINK
574 if test "x$ws_breakloop_compiled" = "xyes"; then
576 AC_DEFINE(HAVE_PCAP_BREAKLOOP, 1, [Define if pcap_breakloop is known])
577 if test "x$with_warnings_as_errors" = "xyes"; then
578 AC_MSG_CHECKING([whether pcap_breakloop is usable])
579 CFLAGS="$CFLAGS -Werror -Wimplicit"
580 AC_WIRESHARK_PCAP_BREAKLOOP_TRY_LINK
581 if test "x$ws_breakloop_compiled" = "xyes"; then
586 [Your pcap library is more recent than your pcap header.
587 As you are building with compiler warnings treated as errors, Wireshark
588 won't be able to use functions not declared in that header.
589 If you wish to build with compiler warnings treated as errors, You should
590 install a newer version of the header file.])
592 CFLAGS="$ac_CFLAGS_saved"
599 # Later versions of Mac OS X 10.3[.x] ship a pcap.h that
600 # doesn't define pcap_if_t but ship an 0.8[.x] libpcap,
601 # so the library has "pcap_findalldevs()", but pcap.h
602 # doesn't define "pcap_if_t" so you can't actually *use*
603 # "pcap_findalldevs()".
605 # That even appears to be true of systems shipped with
606 # 10.3.4, so it doesn't appear only to be a case of
607 # Software Update not updating header files.
609 # (You can work around this by installing the 0.8 header
612 AC_CACHE_CHECK([whether pcap_findalldevs is present and usable],
613 [ac_cv_func_pcap_findalldevs],
622 pcap_if_t *devpointer;
625 pcap_findalldevs(&devpointer, errbuf);
630 ac_cv_func_pcap_findalldevs=yes
633 ac_cv_func_pcap_findalldevs=no
637 # Don't check for other new routines that showed up after
638 # "pcap_findalldevs()" if we don't have a usable
639 # "pcap_findalldevs()", so we don't end up using them if the
640 # "pcap.h" is crufty and old and doesn't declare them.
642 if test $ac_cv_func_pcap_findalldevs = "yes" ; then
643 AC_DEFINE(HAVE_PCAP_FINDALLDEVS, 1,
644 [Define to 1 if you have the `pcap_findalldevs' function and a pcap.h that declares pcap_if_t.])
645 AC_CHECK_FUNCS(pcap_datalink_val_to_name pcap_datalink_name_to_val)
646 AC_CHECK_FUNCS(pcap_datalink_val_to_description)
647 AC_CHECK_FUNCS(pcap_list_datalinks pcap_set_datalink pcap_lib_version)
648 AC_CHECK_FUNCS(pcap_get_selectable_fd pcap_free_datalinks)
649 AC_CHECK_FUNCS(pcap_create bpf_image pcap_set_tstamp_precision)
654 AC_DEFUN([AC_WIRESHARK_PCAP_REMOTE_CHECK],
657 LIBS="$PCAP_LIBS $SOCKET_LIBS $NSL_LIBS $LIBS"
658 AC_DEFINE(HAVE_REMOTE, 1, [Define to 1 to enable remote
659 capturing feature in WinPcap library])
660 AC_CHECK_FUNCS(pcap_open)
661 if test $ac_cv_func_pcap_open = "yes" ; then
662 AC_DEFINE(HAVE_PCAP_REMOTE, 1,
663 [Define to 1 if you have WinPcap remote capturing support and prefer to use these new API features.])
665 AC_CHECK_FUNCS(pcap_setsampling)
670 # AC_WIRESHARK_ZLIB_CHECK
672 AC_DEFUN([AC_WIRESHARK_ZLIB_CHECK],
674 if test "x$zlib_dir" != "x"
677 # The user specified a directory in which zlib resides,
678 # so add the "include" subdirectory of that directory to
679 # the include file search path and the "lib" subdirectory
680 # of that directory to the library search path.
682 # XXX - if there's also a zlib in a directory that's
683 # already in CPPFLAGS or LDFLAGS, this won't make us find
684 # the version in the specified directory, as the compiler
685 # and/or linker will search that other directory before it
686 # searches the specified directory.
688 wireshark_save_CPPFLAGS="$CPPFLAGS"
689 CPPFLAGS="$CPPFLAGS -I$zlib_dir/include"
690 wireshark_save_LIBS="$LIBS"
691 AC_WIRESHARK_ADD_DASH_L(LIBS, $zlib_dir/lib)
695 # Make sure we have "zlib.h". If we don't, it means we probably
696 # don't have zlib, so don't use it.
698 AC_CHECK_HEADER(zlib.h,,
700 if test "x$zlib_dir" != "x"
703 # The user used "--with-zlib=" to specify a directory
704 # containing zlib, but we didn't find the header file
705 # there; that either means they didn't specify the
706 # right directory or are confused about whether zlib
707 # is, in fact, installed. Report the error and give up.
709 AC_MSG_ERROR([zlib header not found in directory specified in --with-zlib])
711 if test "x$want_zlib" = "xyes"
714 # The user tried to force us to use the library, but we
715 # couldn't find the header file; report an error.
717 AC_MSG_ERROR(Header file zlib.h not found.)
720 # We couldn't find the header file; don't use the
721 # library, as it's probably not present.
728 if test "x$want_zlib" != "xno"
731 # Well, we at least have the zlib header file.
732 # We link with zlib to support uncompression of
733 # gzipped network traffic, e.g. in an HTTP request
736 if test "x$zlib_dir" != "x"
739 # Put the "-L" flags for zlib at the beginning
743 AC_WIRESHARK_ADD_DASH_L(LIBS, $zlib_dir/lib)
744 LIBS="$LIBS -lz $wireshark_save_LIBS"
748 AC_DEFINE(HAVE_LIBZ, 1, [Define to use libz library])
751 # Check for "inflatePrime()" in zlib, which we need
752 # in order to read compressed capture files.
754 AC_CHECK_FUNCS(inflatePrime)
756 if test "x$ac_cv_func_inflatePrime" = "xyes" ; then
758 # Now check for "inflatePrime()" in zlib when
759 # linking with the linker flags for GTK+
760 # applications; people often grab XFree86 source
761 # and build and install it on their systems,
762 # and they appear sometimes to misconfigure
763 # XFree86 so that, even on systems with zlib,
764 # it assumes there is no zlib, so the XFree86
765 # build process builds and installs its
766 # own zlib in the X11 library directory.
768 # The zlib in at least some versions of XFree86
769 # is an older version that may lack "inflatePrime()",
770 # and that's the zlib with which Wireshark gets
771 # linked, so the build of Wireshark fails.
773 AC_MSG_CHECKING([for inflatePrime missing when linking with X11])
774 AC_TRY_LINK_FUNC(inflatePrime, AC_MSG_RESULT(no),
777 AC_MSG_ERROR(old zlib found when linking with X11 - get rid of old zlib.)
782 # Restore the versions of CPPFLAGS and LIBS before
783 # we added the "-with-zlib=" directory, as we didn't
784 # actually find zlib there.
786 CPPFLAGS="$wireshark_save_CPPFLAGS"
787 LIBS="$wireshark_save_LIBS"
793 # AC_WIRESHARK_LIBLUA_CHECK
795 # Sets $have_lua to yes or no.
796 # If it's yes, it also sets $LUA_CFLAGS and $LUA_LIBS.
797 AC_DEFUN([AC_WIRESHARK_LIBLUA_CHECK],[
799 if test "x$want_lua_dir" = "x"
801 # The user didn't tell us where to find Lua. Let's go look for it.
803 # First, try the standard (pkg-config) way.
804 PKG_CHECK_MODULES(LUA, lua, [have_lua=yes], [true])
806 # Unfortunately Lua's pkg-config file isn't standardly named.
807 # Apparently Debian, in particular, allows installation of multiple
808 # versions of Lua at the same time (thus each version has its own
810 for ver in 5.2 -5.2 5.1 -5.1 5.0 -5.0
812 if test "x$have_lua" = "xyes"
817 PKG_CHECK_MODULES(LUA, lua$ver, [have_lua=yes], [true])
822 if test "x$have_lua" != "xyes"
824 # We don't have pkg-config or the user specified the path to
825 # Lua (in $want_lua_dir).
826 # Let's look for the header file.
828 AC_MSG_CHECKING(for the location of lua.h)
829 if test "x$want_lua_dir" = "x"
831 # The user didn't tell us where to look so we'll look in some
832 # standard locations.
833 want_lua_dir="/usr /usr/local $prefix"
835 for dir in $want_lua_dir
837 if test -r "$dir/include/lua.h"
839 header_dir="$dir/include"
844 for ver in 5.2 52 5.1 51 5.0 50
846 if test -r "$dir/include/lua$ver/lua.h"
848 header_dir="$dir/include/lua$ver"
855 if test "x$header_dir" = "x"
858 AC_MSG_RESULT(not found)
860 AC_MSG_RESULT($header_dir)
862 AC_MSG_CHECKING(the Lua version)
863 lua_ver=`$AWK AS_ESCAPE('/LUA_VERSION_NUM/ { print $NF; }' $header_dir/lua.h | sed 's/0/./')`
864 AC_MSG_RESULT($lua_ver)
866 wireshark_save_CPPFLAGS="$CPPFLAGS"
867 CPPFLAGS="$CPPFLAGS -I$header_dir"
868 AC_CHECK_HEADERS(lua.h lualib.h lauxlib.h, ,
871 # Restore our CPPFLAGS
872 CPPFLAGS="$wireshark_save_CPPFLAGS"
876 if test "x$have_lua" = "x"
878 # Restore our CPPFLAGS and set LUA_CFLAGS
879 CPPFLAGS="$wireshark_save_CPPFLAGS"
880 LUA_CFLAGS="-I$header_dir"
882 # We have the header files and they work. Now let's check if we
883 # have the library and it works.
885 # XXX - if there's also a liblua in a directory that's
886 # already in CPPFLAGS or LDFLAGS, this won't make us find
887 # the version in the specified directory, as the compiler
888 # and/or linker will search that other directory before it
889 # searches the specified directory.
892 wireshark_save_LIBS="$LIBS"
893 LIBS="$LIBS -L$lua_dir/lib"
894 AC_SEARCH_LIBS(luaL_openlibs, [lua-${lua_ver} lua${lua_ver} lua],
896 LUA_LIBS="-L$lua_dir/lib $ac_cv_search_luaL_openlibs -lm"
897 LIBS="$wireshark_save_LIBS"
900 LIBS="$wireshark_save_LIBS"
910 # AC_WIRESHARK_LIBPORTAUDIO_CHECK
912 AC_DEFUN([AC_WIRESHARK_LIBPORTAUDIO_CHECK],[
914 if test "x$portaudio_dir" != "x"
917 # The user specified a directory in which libportaudio
918 # resides, so add the "include" subdirectory of that directory to
919 # the include file search path and the "lib" subdirectory
920 # of that directory to the library search path.
922 # XXX - if there's also a libportaudio in a directory that's
923 # already in CPPFLAGS or LDFLAGS, this won't make us find
924 # the version in the specified directory, as the compiler
925 # and/or linker will search that other directory before it
926 # searches the specified directory.
928 wireshark_save_CPPFLAGS="$CPPFLAGS"
929 CPPFLAGS="$CPPFLAGS -I$portaudio_dir/include"
930 wireshark_save_LIBS="$LIBS"
931 LIBS="$LIBS -L$portaudio_dir/lib -lportaudio"
932 wireshark_save_LDFLAGS="$LDFLAGS"
933 LDFLAGS="$LDFLAGS -L$portaudio_dir/lib"
936 # The user specified no directory in which libportaudio resides,
937 # so just add "-lportaudio" to the used libs.
939 wireshark_save_CPPFLAGS="$CPPFLAGS"
940 wireshark_save_LDFLAGS="$LDFLAGS"
941 wireshark_save_LIBS="$LIBS"
942 LIBS="$LIBS -lportaudio"
946 # Make sure we have "portaudio.h". If we don't, it means we probably
947 # don't have libportaudio, so don't use it.
949 AC_CHECK_HEADERS(portaudio.h,,
951 if test "x$portaudio_dir" != "x"
954 # The user used "--with-portaudio=" to specify a directory
955 # containing libportaudio, but we didn't find the header file
956 # there; that either means they didn't specify the
957 # right directory or are confused about whether libportaudio
958 # is, in fact, installed. Report the error and give up.
960 AC_MSG_ERROR([libportaudio header not found in directory specified in --with-portaudio])
962 CPPFLAGS="$wireshark_save_CPPFLAGS"
963 LDFLAGS="$wireshark_save_LDFLAGS"
964 LIBS="$wireshark_save_LIBS"
966 if test "x$want_portaudio" = "xyes"
969 # The user tried to force us to use the library, but we
970 # couldn't find the header file; report an error.
972 AC_MSG_ERROR(Header file portaudio.h not found.)
975 # We couldn't find the header file; don't use the
976 # library, as it's probably not present.
984 # Check whether we have the right version of portaudio
986 if test "x$want_portaudio" != "xno"
988 AC_CHECK_TYPE(PortAudioStream,
989 AC_DEFINE(PORTAUDIO_API_1, 1, [Define if we are using version of of the Portaudio library API]),
991 [#include <portaudio.h>])
994 if test "x$want_portaudio" != "xno"
997 # Well, we at least have the portaudio header file.
999 # let's check if the libs are there
1002 AC_CHECK_LIB(portaudio, Pa_Initialize,
1004 if test "x$portaudio_dir" != "x"
1007 # Put the "-I" and "-L" flags for portaudio
1008 # into PORTAUDIO_INCLUDES and PORTAUDIO_LIBS,
1011 PORTAUDIO_LIBS="-L$portaudio_dir/lib -lportaudio"
1012 PORTAUDIO_INCLUDES="-I$portaudio_dir/include"
1014 PORTAUDIO_LIBS="-lportaudio"
1015 PORTAUDIO_INCLUDES=""
1017 AC_DEFINE(HAVE_LIBPORTAUDIO, 1, [Define to use libportaudio library])
1021 # Restore the versions of CPPFLAGS, LDFLAGS, and
1022 # LIBS before we added the "--with-portaudio="
1023 # directory, as we didn't actually find portaudio
1026 CPPFLAGS="$wireshark_save_CPPFLAGS"
1027 LDFLAGS="$wireshark_save_LDFLAGS"
1028 LIBS="$wireshark_save_LIBS"
1030 # User requested --with-portaudio but it isn't available
1031 if test "x$want_portaudio" = "xyes"
1033 AC_MSG_ERROR(Linking with libportaudio failed.)
1038 CPPFLAGS="$wireshark_save_CPPFLAGS"
1039 LDFLAGS="$wireshark_save_LDFLAGS"
1040 LIBS="$wireshark_save_LIBS"
1041 AC_SUBST(PORTAUDIO_LIBS)
1042 AC_SUBST(PORTAUDIO_INCLUDES)
1048 # AC_WIRESHARK_RPM_CHECK
1049 # Looks for the rpm program, and checks to see if we can redefine "_topdir".
1051 AC_DEFUN([AC_WIRESHARK_RPM_CHECK],
1053 AC_CHECK_PROG(ac_cv_wireshark_have_rpm, rpm, "yes", "no")
1054 if test "x$ac_cv_wireshark_have_rpm" = "xyes"; then
1055 rpm --define '_topdir /tmp' > /dev/null 2>&1
1056 AC_MSG_CHECKING(to see if we can redefine _topdir)
1057 if test $? -eq 0 ; then
1061 AC_MSG_RESULT(no. You'll have to build packages manually.)
1068 # AC_WIRESHARK_GNU_SED_CHECK
1069 # Checks if GNU sed is the first sed in PATH.
1071 AC_DEFUN([AC_WIRESHARK_GNU_SED_CHECK],
1073 AC_MSG_CHECKING(for GNU sed as first sed in PATH)
1074 if ( sh -c "sed --version" </dev/null 2> /dev/null | grep "GNU sed" 2>&1 > /dev/null ) ; then
1084 # AC_WIRESHARK_C_ARES_CHECK
1086 AC_DEFUN([AC_WIRESHARK_C_ARES_CHECK],
1088 want_c_ares=defaultyes
1090 if test "x$want_c_ares" = "xdefaultyes"; then
1092 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
1094 if test -d "$withval"; then
1095 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1100 if test "x$want_c_ares" = "xyes"; then
1101 AC_CHECK_LIB(cares, ares_init,
1104 AC_DEFINE(HAVE_C_ARES, 1, [Define to use c-ares library])
1105 have_good_c_ares=yes
1106 ],, $SOCKET_LIBS $NSL_LIBS
1109 AC_MSG_RESULT(not required)
1115 # AC_WIRESHARK_ADNS_CHECK
1117 AC_DEFUN([AC_WIRESHARK_ADNS_CHECK],
1119 want_adns=defaultyes
1121 if test "x$want_adns" = "xdefaultyes"; then
1123 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
1125 if test -d "$withval"; then
1126 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1131 if test "x$want_adns" = "xyes"; then
1132 AC_CHECK_LIB(adns, adns_init,
1135 AC_DEFINE(HAVE_GNU_ADNS, 1, [Define to use GNU ADNS library])
1137 ],, $SOCKET_LIBS $NSL_LIBS
1140 AC_MSG_RESULT(not required)
1146 # AC_WIRESHARK_LIBCAP_CHECK
1148 AC_DEFUN([AC_WIRESHARK_LIBCAP_CHECK],
1150 want_libcap=defaultyes
1152 if test "x$want_libcap" = "xdefaultyes"; then
1154 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
1156 if test -d "$withval"; then
1157 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1162 if test "x$want_libcap" = "xyes"; then
1163 AC_CHECK_LIB(cap, cap_set_flag,
1166 AC_DEFINE(HAVE_LIBCAP, 1, [Define to use the libcap library])
1167 have_good_libcap=yes
1171 AC_MSG_RESULT(not required)
1177 # AC_WIRESHARK_KRB5_CHECK
1179 AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
1181 wireshark_save_CPPFLAGS="$CPPFLAGS"
1182 if test "x$krb5_dir" != "x"
1185 # The user specified a directory in which kerberos resides,
1186 # so add the "include" subdirectory of that directory to
1187 # the include file search path and the "lib" subdirectory
1188 # of that directory to the library search path.
1190 # XXX - if there's also a kerberos in a directory that's
1191 # already in CPPFLAGS or LDFLAGS, this won't make us find
1192 # the version in the specified directory, as the compiler
1193 # and/or linker will search that other directory before it
1194 # searches the specified directory.
1196 CPPFLAGS="$CPPFLAGS -I$krb5_dir/include"
1197 ac_heimdal_version=`grep heimdal $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*heimdal.*$/HEIMDAL/'`
1198 # MIT Kerberos moved krb5.h to krb5/krb5.h starting with release 1.5
1199 ac_mit_version_olddir=`grep 'Massachusetts' $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*Massachusetts.*$/MIT/'`
1200 ac_mit_version_newdir=`grep 'Massachusetts' $krb5_dir/include/krb5/krb5.h | head -n 1 | sed 's/^.*Massachusetts.*$/MIT/'`
1201 ac_krb5_version="$ac_heimdal_version$ac_mit_version_olddir$ac_mit_version_newdir"
1202 if test "x$ac_krb5_version" = "xHEIMDAL"
1204 KRB5_LIBS="-L$krb5_dir/lib -lkrb5 -lasn1 $SSL_LIBS -lroken -lcrypt"
1206 KRB5_LIBS="-L$krb5_dir/lib -lkrb5 -lk5crypto -lcom_err"
1208 if test "x$ac_krb5_version" = "xMIT"
1210 AC_DEFINE(HAVE_MIT_KERBEROS, 1, [Define to use MIT kerberos])
1213 AC_PATH_PROG(KRB5_CONFIG, krb5-config)
1214 if test -x "$KRB5_CONFIG"
1216 KRB5_FLAGS=`"$KRB5_CONFIG" --cflags`
1217 KRB5_LIBS=`"$KRB5_CONFIG" --libs`
1218 CPPFLAGS="$CPPFLAGS $KRB5_FLAGS"
1220 # If -lcrypto is in KRB5_FLAGS, we require it to build
1221 # with Heimdal/MIT. We don't want to built with it by
1222 # default, due to annoying license incompatibilities
1223 # between the OpenSSL license and the GPL, so:
1225 # if SSL_LIBS is set to a non-empty string, we
1226 # remove -lcrypto from KRB5_LIBS and replace
1229 # if SSL_LIBS is not set to a non-empty string
1230 # we fail with an appropriate error message.
1232 case "$KRB5_LIBS" in
1234 if test ! -z "$SSL_LIBS"
1236 KRB5_LIBS=`echo $KRB5_LIBS | sed 's/-lcrypto//'`
1237 KRB5_LIBS="$KRB5_LIBS $SSL_LIBS"
1239 AC_MSG_ERROR([Kerberos library requires -lcrypto, so you must specify --with-ssl])
1243 ac_krb5_version=`"$KRB5_CONFIG" --version | head -n 1 | sed -e 's/^.*heimdal.*$/HEIMDAL/' -e 's/^Kerberos .*$/MIT/' -e 's/^Solaris Kerberos .*$/MIT/'`
1248 # Make sure we have "krb5.h". If we don't, it means we probably
1249 # don't have kerberos, so don't use it.
1251 AC_CHECK_HEADER(krb5.h,,
1253 if test "x$krb5_dir" != "x"
1256 # The user used "--with-krb5=" to specify a directory
1257 # containing kerberos, but we didn't find the header file
1258 # there; that either means they didn't specify the
1259 # right directory or are confused about whether kerberos
1260 # is, in fact, installed. Report the error and give up.
1262 AC_MSG_ERROR([kerberos header not found in directory specified in --with-krb5])
1264 if test "x$want_krb5" = "xyes"
1267 # The user tried to force us to use the library, but we
1268 # couldn't find the header file; report an error.
1270 AC_MSG_ERROR(Header file krb5.h not found.)
1273 # We couldn't find the header file; don't use the
1274 # library, as it's probably not present.
1277 AC_MSG_RESULT(No Heimdal or MIT header found - disabling dissection for some kerberos data in packet decoding)
1282 if test "x$want_krb5" != "xno"
1285 # Well, we at least have the krb5 header file.
1286 # Check whether this is Heimdal or MIT.
1288 AC_MSG_CHECKING(whether the Kerberos library is Heimdal or MIT)
1289 if test "x$ac_krb5_version" = "xHEIMDAL" -o "x$ac_krb5_version" = "xMIT"
1293 # Check whether we have krb5_kt_resolve - and whether
1294 # we need to link with -lresolv when linking with
1295 # the Kerberos library.
1297 AC_MSG_RESULT($ac_krb5_version)
1298 wireshark_save_LIBS="$LIBS"
1299 found_krb5_kt_resolve=no
1300 for extras in "" "-lresolv"
1302 LIBS="$KRB5_LIBS $extras"
1303 if test -z "$extras"
1305 AC_MSG_CHECKING([whether $ac_krb5_version includes krb5_kt_resolve])
1307 AC_MSG_CHECKING([whether $ac_krb5_version includes krb5_kt_resolve (linking with $extras)])
1317 # We found "krb5_kt_resolve()", and required
1318 # the libraries in extras as well.
1322 AC_DEFINE(HAVE_KERBEROS, 1, [Define to use kerberos])
1323 if test "x$ac_krb5_version" = "xHEIMDAL"
1325 AC_DEFINE(HAVE_HEIMDAL_KERBEROS, 1, [Define to use heimdal kerberos])
1326 elif test "x$ac_krb5_version" = "xMIT"
1328 AC_DEFINE(HAVE_MIT_KERBEROS, 1, [Define to use MIT kerberos])
1330 found_krb5_kt_resolve=yes
1337 if test "$found_krb5_kt_resolve" = no
1340 # We didn't find "krb5_kt_resolve()" in the
1341 # Kerberos library, even when we tried linking
1342 # with -lresolv; we can't link with kerberos.
1344 if test "x$want_krb5" = "xyes"
1347 # The user tried to force us to use the library,
1348 # but we can't do so; report an error.
1350 AC_MSG_ERROR(Usable $ac_krb5_version not found)
1353 # Restore the versions of CPPFLAGS from before we
1354 # added the flags for Kerberos.
1356 AC_MSG_RESULT(Usable $ac_krb5_version not found - disabling dissection for some kerberos data in packet decoding)
1357 CPPFLAGS="$wireshark_save_CPPFLAGS"
1363 # We can link with Kerberos; see whether krb5.h
1364 # defines KEYTYPE_ARCFOUR_56 (where "defines" means
1365 # "as a #define or as an enum member).
1367 AC_MSG_CHECKING([whether krb5.h defines KEYTYPE_ARCFOUR_56])
1377 printf("%u\n", KEYTYPE_ARCFOUR_56);
1383 AC_DEFINE(HAVE_KEYTYPE_ARCFOUR_56, 1, [Define if krb5.h defines KEYTYPE_ARCFOUR_56])
1389 LIBS="$wireshark_save_LIBS"
1392 # It's not Heimdal or MIT.
1395 if test "x$want_krb5" = "xyes"
1398 # The user tried to force us to use the library,
1399 # but we can't do so; report an error.
1401 AC_MSG_ERROR(Kerberos not found)
1404 # Restore the versions of CPPFLAGS from before we
1405 # added the flags for Kerberos.
1407 AC_MSG_RESULT(Kerberos not found - disabling dissection for some kerberos data in packet decoding)
1408 CPPFLAGS="$wireshark_save_CPPFLAGS"
1415 # The user asked us not to use Kerberos, or they didn't
1416 # say whether they wanted us to use it but we found
1419 # Restore the versions of CPPFLAGS from before we added
1420 # the flags for Kerberos.
1422 CPPFLAGS="$wireshark_save_CPPFLAGS"
1430 # AC_WIRESHARK_GEOIP_CHECK
1432 AC_DEFUN([AC_WIRESHARK_GEOIP_CHECK],
1434 want_geoip=defaultyes
1436 if test "x$want_geoip" = "xdefaultyes"; then
1438 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
1440 if test -d "$withval"; then
1441 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1446 if test "x$want_geoip" = "xyes"; then
1447 AC_CHECK_LIB(GeoIP, GeoIP_new,
1450 AC_DEFINE(HAVE_GEOIP, 1, [Define to use GeoIP library])
1454 if test "x$have_good_geoip" = "xyes"; then
1455 AC_CHECK_LIB(GeoIP, GeoIP_country_name_by_ipnum_v6,
1457 AC_DEFINE(HAVE_GEOIP_V6, 1, [Define if GeoIP supports IPv6 (GeoIP 1.4.5 and later)])
1462 AC_MSG_RESULT(not required)
1466 #AC_WIRESHARK_LDFLAGS_CHECK
1468 # $1 : ldflag(s) to test
1470 # We attempt to compile and link a test program with the specified linker
1471 # flag. The defined flag is added to LDFLAGS only if the link succeeds.
1473 AC_DEFUN([AC_WIRESHARK_LDFLAGS_CHECK],
1475 AC_MSG_CHECKING(whether we can add $LD_OPTION to LDFLAGS)
1476 LDFLAGS_saved="$LDFLAGS"
1477 LDFLAGS="$LDFLAGS $LD_OPTION"
1480 AC_LANG_SOURCE([[main() { return; }]])
1487 LDFLAGS="$LDFLAGS_saved"
1492 dnl Check whether, if you pass an unknown warning option to the
1493 dnl compiler, it fails or just prints a warning message and succeeds.
1494 dnl Set ac_wireshark_unknown_warning_option_error to the appropriate flag
1495 dnl to force an error if it would otherwise just print a warning message
1498 AC_DEFUN([AC_WIRESHARK_CHECK_UNKNOWN_WARNING_OPTION_ERROR],
1500 AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option])
1501 save_CFLAGS="$CFLAGS"
1502 CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
1507 AC_MSG_RESULT([no, adding -Werror=unknown-warning-option])
1509 # We're assuming this is clang, where
1510 # -Werror=unknown-warning-option is the appropriate
1511 # option to force the compiler to fail.
1513 ac_wireshark_unknown_warning_option_error="-Werror=unknown-warning-option"
1516 AC_MSG_RESULT([yes])
1518 CFLAGS="$save_CFLAGS"
1522 dnl Check whether, if you pass a valid-for-C-but-not-C++ option to the
1523 dnl compiler, it fails or just prints a warning message and succeeds.
1524 dnl Set ac_wireshark_non_cxx_warning_option_error to the appropriate flag
1525 dnl to force an error if it would otherwise just print a warning message
1528 AC_DEFUN([AC_WIRESHARK_CHECK_NON_CXX_WARNING_OPTION_ERROR],
1530 AC_MSG_CHECKING([whether the compiler fails when given an warning option not supported for C++])
1532 # Some C+ compilers warn about -Wmissing-prototypes, and some warn
1533 # about -Wmissing-declarations. Check both.
1536 save_CXXFLAGS="$CXXFLAGS"
1537 for flag in -Wmissing-prototypes -Wmissing-declarations; do
1538 CXXFLAGS="$save_CXXFLAGS $flag"
1544 # We're assuming this is g++, where -Werror is the
1545 # appropriate option to force the compiler to fail.
1546 # Check whether it fails with -Werror.
1548 # NOTE: it's important to put -Werror *before*
1549 # the flag, otherwise, when it sees the flag,
1550 # it doesn't yet know that warnings should be
1551 # treated as errors, and doesn't treat the
1552 # "that's C-only" warning as an error.
1554 CXXFLAGS="$save_CXXFLAGS -Werror $flag"
1560 # No, so this option is actually OK
1561 # with our C++ compiler.
1563 # (We need an empty command here to
1564 # prevent some versions of autoconf
1565 # from generating a script with an
1566 # empty "then" clause for an if statement.)
1572 # Yes, so we need -Werror for the tests.
1574 ac_wireshark_non_cxx_warning_option_error="-Werror"
1579 CXXFLAGS="$save_CXXFLAGS"
1581 if test x$ac_wireshark_non_cxx_warning_option_error = x; then
1582 AC_MSG_RESULT([yes])
1584 AC_MSG_RESULT([no, adding -Werror])
1589 # AC_WIRESHARK_COMPILER_FLAGS_CHECK
1591 # $1 : flags to test
1592 # $2 : if supplied, C for C-only flags, CXX for C++-only flags
1593 # $3 : if supplied, a program to try to compile with the flag
1594 # and, if the compile fails when -Werror is turned on,
1595 # we don't add the flag - used for warning flags that
1596 # issue incorrect or non-useful warnings with some
1598 # $4 : must be supplied if $3 is supplied - a message describing
1599 # for what the test program is testing
1601 # The macro first determines if the compiler supports GCC-style flags.
1602 # Then it attempts to compile with the defined cflags. The defined
1603 # flags are added to CFLAGS only if the compilation succeeds.
1605 # We do this because not all such options are necessarily supported by
1606 # the version of the particular compiler we're using.
1608 AC_DEFUN([AC_WIRESHARK_COMPILER_FLAGS_CHECK],
1610 can_add_to_cflags=""
1611 can_add_to_cxxflags=""
1612 if test "x$ac_supports_gcc_flags" = "xyes" ; then
1613 if test "$2" != CXX ; then
1615 # Not C++-only; if this can be added to the C compiler flags, add them.
1617 # If the option begins with "-W", add
1618 # $ac_wireshark_unknown_warning_option_error to make sure that
1619 # we'll get an error if it's an unknown warning option; not all
1620 # compilers treat unknown warning options as errors (I'm looking at
1623 # If the option begins with "-f" or "-m", add -Werror to make sure
1624 # that we'll get an error if we get "argument unused during compilation"
1625 # warnings, as those will either cause a failure for files compiled
1626 # with -Werror or annoying noise for files compiled without it.
1627 # (Yeah, you, clang.)
1629 AC_MSG_CHECKING(whether we can add $GCC_OPTION to CFLAGS)
1630 CFLAGS_saved="$CFLAGS"
1631 if expr "x$GCC_OPTION" : "x-W.*" >/dev/null
1633 CFLAGS="$CFLAGS $ac_wireshark_unknown_warning_option_error $GCC_OPTION"
1634 elif expr "x$GCC_OPTION" : "x-f.*" >/dev/null
1636 CFLAGS="$CFLAGS -Werror $GCC_OPTION"
1637 elif expr "x$GCC_OPTION" : "x-m.*" >/dev/null
1639 CFLAGS="$CFLAGS -Werror $GCC_OPTION"
1641 CFLAGS="$CFLAGS $GCC_OPTION"
1645 AC_LANG_SOURCE([[int foo;]])
1649 can_add_to_cflags=yes
1651 # OK, do we have a test program? If so, check
1652 # whether it fails with this option and -Werror,
1653 # and, if so, don't include it.
1655 # We test arg 4 here because arg 3 is a program which
1656 # could contain quotes (breaking the comparison).
1658 if test "x$4" != "x" ; then
1659 CFLAGS="$CFLAGS -Werror"
1660 AC_MSG_CHECKING(whether $GCC_OPTION $4)
1662 [AC_LANG_SOURCE($3)],
1666 # Remove "force an error for a warning" options, if we
1667 # added them, by setting CFLAGS to the saved value plus
1668 # just the new option.
1670 CFLAGS="$CFLAGS_saved $GCC_OPTION"
1672 # Add it to the flags we use when building build tools.
1674 CFLAGS_FOR_BUILD="$CFLAGS_FOR_BUILD $GCC_OPTION"
1678 CFLAGS="$CFLAGS_saved"
1682 # Remove "force an error for a warning" options, if we
1683 # added them, by setting CFLAGS to the saved value plus
1684 # just the new option.
1686 CFLAGS="$CFLAGS_saved $GCC_OPTION"
1688 # Add it to the flags we use when building build tools.
1690 CFLAGS_FOR_BUILD="$CFLAGS_FOR_BUILD $GCC_OPTION"
1695 can_add_to_cflags=no
1696 CFLAGS="$CFLAGS_saved"
1699 if test "$2" != C ; then
1701 # Not C-only; if this can be added to the C++ compiler flags, add them.
1703 # If the option begins with "-W", add
1704 # $ac_wireshark_unknown_warning_option_error, as per the above, and
1705 # also add $ac_wireshark_non_cxx_warning_option_error, because at
1706 # lease some versions of g++ whine about -Wmissing-prototypes, the
1707 # fact that at least one of those versions refuses to warn about
1708 # function declarations without an earlier declaration nonwithstanding;
1709 # perhaps there's a reason not to warn about that with C++ even though
1710 # warning about it can be a Good Idea with C, but it's not obvious to
1713 # If the option begins with "-f" or "-m", add -Werror to make sure
1714 # that we'll get an error if we get "argument unused during compilation"
1715 # warnings, as those will either cause a failure for files compiled
1716 # with -Werror or annoying noise for files compiled without it.
1717 # (Yeah, you, clang++.)
1719 AC_MSG_CHECKING(whether we can add $GCC_OPTION to CXXFLAGS)
1720 CXXFLAGS_saved="$CXXFLAGS"
1721 if expr "x$GCC_OPTION" : "x-W.*" >/dev/null
1723 CXXFLAGS="$CXXFLAGS $ac_wireshark_unknown_warning_option_error $ac_wireshark_non_cxx_warning_option_error $GCC_OPTION"
1724 elif expr "x$GCC_OPTION" : "x-f.*" >/dev/null
1726 CXXFLAGS="$CXXFLAGS -Werror $GCC_OPTION"
1727 elif expr "x$GCC_OPTION" : "x-m.*" >/dev/null
1729 CXXFLAGS="$CXXFLAGS -Werror $GCC_OPTION"
1731 CXXFLAGS="$CXXFLAGS $GCC_OPTION"
1736 AC_LANG_SOURCE([[int foo;]])
1740 can_add_to_cxxflags=yes
1742 # OK, do we have a test program? If so, check
1743 # whether it fails with this option and -Werror,
1744 # and, if so, don't include it.
1746 # We test arg 4 here because arg 3 is a program which
1747 # could contain quotes (breaking the comparison).
1749 if test "x$4" != "x" ; then
1750 CXXFLAGS="$CXXFLAGS -Werror"
1751 AC_MSG_CHECKING(whether $GCC_OPTION $4)
1753 [AC_LANG_SOURCE($3)],
1757 # Remove "force an error for a warning" options, if we
1758 # added them, by setting CXXFLAGS to the saved value plus
1759 # just the new option.
1761 CXXFLAGS="$CXXFLAGS_saved $GCC_OPTION"
1765 CXXFLAGS="$CXXFLAGS_saved"
1769 # Remove "force an error for a warning" options, if we
1770 # added them, by setting CXXFLAGS to the saved value plus
1771 # just the new option.
1773 CXXFLAGS="$CXXFLAGS_saved $GCC_OPTION"
1778 can_add_to_cxxflags=no
1779 CXXFLAGS="$CXXFLAGS_saved"
1783 if test "(" "$can_add_to_cflags" = "yes" -a "$can_add_to_cxxflags" = "no" ")" \
1784 -o "(" "$can_add_to_cflags" = "no" -a "$can_add_to_cxxflags" = "yes" ")"
1787 # Confusingly, some C++ compilers like -Wmissing-prototypes but
1788 # don't like -Wmissing-declarations and others like
1789 # -Wmissing-declarations but don't like -Wmissing-prototypes,
1790 # the fact that the corresponding C compiler likes both. Don't
1793 if test "(" x$GCC_OPTION != x-Wmissing-prototypes ")" \
1794 -a "(" x$GCC_OPTION != x-Wmissing-declarations ")"
1796 AC_MSG_WARN([$CC and $CXX appear to be a mismatched pair])
1802 # AC_WIRESHARK_GCC_FORTIFY_SOURCE_CHECK
1804 # Checks if '-D_FORTIFY_SOURCE=...' is OK to use in CPPFLAGS.
1805 # Use '-D_FORTIFY_SOURCE=...' in CPPFLAGS only if the GCC 'optimization level' is > 0.
1806 # The use of '-D_FORTIFY_SOURCE=...' will cause a warning with at least some versions
1807 # of glibc if the GCC "optimization level" is 0 (default or -O or -O0)
1808 # when using GCC to compile a source file which references the macro definition.
1810 # See: http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
1811 # See: http://sourceware.org/bugzilla/show_bug.cgi?id=13979
1813 # We'll use '-D_FORTIFY_SOURCE=2' only if there's no warning; Among other things this means
1814 # that the use of '-D_FORTIFY_SOURCE=2' with '-Werror' and '-O0' won't cause
1815 # the compiler to stop on error.
1816 # Assumption: CFLAGS already contains whatever optimization option including none) is
1820 AC_DEFUN([AC_WIRESHARK_GCC_FORTIFY_SOURCE_CHECK],
1822 if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
1823 AC_MSG_CHECKING([whether -D_FORTIFY_SOURCE=... can be used (without generating a warning)])
1824 CFLAGS_saved="$CFLAGS"
1825 CPPFLAGS_saved="$CPPFLAGS"
1826 CFLAGS="$CFLAGS -Werror"
1827 CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
1836 # (CPPFLAGS contains _D_FORTIFY_SOURCE=2)
1841 # Remove -D_FORTIFY_SOURCE=2
1842 CPPFLAGS="$CPPFLAGS_saved"
1844 CFLAGS="$CFLAGS_saved"
1849 # AC_WIRESHARK_OSX_INTEGRATION_CHECK
1851 # Checks for the presence of OS X integration functions in the GTK+ framework
1852 # or as a separate library.
1854 # GTK+ for MAC OS X now lives on www.gtk.org at:
1856 # http://www.gtk.org/download/macos.php
1858 # Details on building with GTK-OSX are available at:
1860 # http://live.gnome.org/GTK%2B/OSX/Building
1862 # The GTK-OSX library has been renamed to gtkmacintegration.
1863 # It was previously named igemacintegration.
1865 # http://live.gnome.org/GTK%2B/OSX/Integration
1866 # for the old Carbon-based integration functions
1868 AC_DEFUN([AC_WIRESHARK_OSX_INTEGRATION_CHECK],
1870 ac_save_CFLAGS="$CFLAGS"
1871 ac_save_LIBS="$LIBS"
1872 CFLAGS="$CFLAGS $GTK_CFLAGS"
1873 LIBS="$GTK_LIBS $LIBS"
1876 # Check for the new integration functions in a -lgtkmacintegration
1879 AC_CHECK_LIB(gtkmacintegration, gtkosx_application_set_menu_bar,
1881 AC_DEFINE(HAVE_GTKOSXAPPLICATION, 1,
1882 [Define to 1 if -lgtkmacintegration includes the GtkOSXApplication Integration functions.])
1884 # We don't want gtk stuff in LIBS (which is reset below) so
1885 # manually set GTK_LIBS (which is more appropriate)
1886 GTK_LIBS="$GTK_LIBS -lgtkmacintegration"
1889 if test x$have_ige_mac = x
1892 # Not found - check for the old integration functions in
1893 # the Gtk framework.
1895 AC_CHECK_LIB(Gtk, gtk_mac_menu_set_menu_bar,
1897 AC_DEFINE(HAVE_IGE_MAC_INTEGRATION, 1,
1898 [Define to 1 if the the Gtk+ framework or a separate library includes the Imendio IGE Mac OS X Integration functions.])
1900 # We don't want gtk stuff in LIBS (which is reset below) so
1901 # manually set GTK_LIBS (which is more appropriate)
1902 GTK_LIBS="$GTK_LIBS -lGtk"
1906 if test x$have_ige_mac = x
1909 # Not found - check for the old integration functions in
1910 # a -lgtkmacintegration library.
1912 AC_CHECK_LIB(gtkmacintegration, gtk_mac_menu_set_menu_bar,
1914 AC_DEFINE(HAVE_IGE_MAC_INTEGRATION, 1,
1915 [Define to 1 if the the Gtk+ framework or a separate library includes the Imendio IGE Mac OS X Integration functions.])
1917 # We don't want gtk stuff in LIBS (which is reset below) so
1918 # manually set GTK_LIBS (which is more appropriate)
1919 GTK_LIBS="$GTK_LIBS -lgtkmacintegration"
1922 CFLAGS="$ac_save_CFLAGS"
1923 LIBS="$ac_save_LIBS"
1926 # Based on AM_PATH_GTK in gtk-2.0.m4.
1928 dnl AC_WIRESHARK_QT_MODULE_CHECK([MODULE, MINIMUM-VERSION, [ACTION-IF-FOUND,
1929 dnl [ACTION-IF-NOT-FOUND]]])
1930 dnl Test for a particular Qt module and add the flags and libraries
1931 dnl for it to Qt_CFLAGS and Qt_LIBS.
1933 AC_DEFUN([AC_WIRESHARK_QT_MODULE_CHECK],
1936 # Version of the module we're checking for.
1939 min_qt_version=ifelse([$2], ,4.0.0,$2)
1942 # Prior to Qt 5, modules were named QtXXX.
1943 # In Qt 5, they're named Qt5XXX.
1945 # Try the Qt 5 version first.
1946 # (And be prepared to add Qt6 at some point....)
1948 for modprefix in Qt5 Qt
1950 pkg_config_module="${modprefix}$1"
1951 AC_MSG_CHECKING(for $pkg_config_module - version >= $min_qt_version)
1952 if $PKG_CONFIG --atleast-version $min_qt_version $pkg_config_module; then
1953 mod_version=`$PKG_CONFIG --modversion $pkg_config_module`
1954 AC_MSG_RESULT(yes (version $mod_version))
1955 Qt_CFLAGS="$Qt_CFLAGS `$PKG_CONFIG --cflags $pkg_config_module`"
1956 Qt_LIBS="$Qt_LIBS `$PKG_CONFIG --libs $pkg_config_module`"
1964 if test "x$found_$1" = "xyes"; then
1965 # Run Action-If-Found
1966 ifelse([$3], , :, [$3])
1968 # Run Action-If-Not-Found
1969 ifelse([$4], , :, [$4])
1973 dnl AC_WIRESHARK_QT_CHECK([MINIMUM-VERSION, [ACTION-IF-FOUND,
1974 dnl [ACTION-IF-NOT-FOUND]]])
1975 dnl Test for Qt and define Qt_CFLAGS and Qt_LIBS.
1977 AC_DEFUN([AC_WIRESHARK_QT_CHECK],
1981 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
1983 if test x$PKG_CONFIG != xno ; then
1984 if pkg-config --atleast-pkgconfig-version 0.7 ; then
1987 echo *** pkg-config too old; version 0.7 or better required.
1995 if test x"$no_qt" = x ; then
1997 # OK, we have an adequate version of pkg-config.
1999 # Check for the Core module; if we don't have that,
2002 AC_WIRESHARK_QT_MODULE_CHECK(Core, $1, , [no_qt=yes])
2005 if test x"$no_qt" = x ; then
2007 # We need the Gui module as well.
2009 AC_WIRESHARK_QT_MODULE_CHECK(Gui, $1, , [no_qt=yes])
2012 if test x"$no_qt" = x ; then
2014 # Qt 5.0 appears to move the widgets out of Qt GUI
2015 # to Qt Widgets; look for the Widgets module, but
2016 # don't fail if we don't have it.
2018 AC_WIRESHARK_QT_MODULE_CHECK(Widgets, $1)
2021 # Qt 5.0 also appears to move the printing support into
2022 # the Qt PrintSupport module.
2024 AC_WIRESHARK_QT_MODULE_CHECK(PrintSupport, $1)
2027 # Qt 5.0 added multimedia widgets in the Qt
2028 # MultimediaWidgets module.
2030 AC_WIRESHARK_QT_MODULE_CHECK(MultimediaWidgets, $1,
2031 AC_DEFINE(QT_MULTIMEDIAWIDGETS_LIB, 1, [Define if we have QtMultimediaWidgets]))
2034 # While we're at it, look for QtMacExtras. (Presumably
2035 # if we're not building for OS X, it won't be present.)
2037 # XXX - is there anything in QtX11Extras or QtWinExtras
2038 # that we should be using?
2040 AC_WIRESHARK_QT_MODULE_CHECK(MacExtras, $1,
2041 AC_DEFINE(QT_MACEXTRAS_LIB, 1, [Define if we have QtMacExtras]))
2045 # Run Action-If-Found
2046 ifelse([$2], , :, [$2])
2048 # Run Action-If-Not-Found
2049 ifelse([$3], , :, [$3])