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.
5 dnl This program is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 2, or (at your option)
10 dnl This program is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 dnl GNU General Public License for more details.
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with this program; if not, write to the Free Software
17 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 dnl As a special exception, the Free Software Foundation gives unlimited
21 dnl permission to copy, distribute and modify the configure scripts that
22 dnl are the output of Autoconf. You need not follow the terms of the GNU
23 dnl General Public License when using or distributing such scripts, even
24 dnl though portions of the text of Autoconf appear in them. The GNU
25 dnl General Public License (GPL) does govern all other use of the material
26 dnl that constitutes the Autoconf program.
28 dnl Certain portions of the Autoconf source text are designed to be copied
29 dnl (in certain cases, depending on the input) into the output of
30 dnl Autoconf. We call these the "data" portions. The rest of the Autoconf
31 dnl source text consists of comments plus executable code that decides which
32 dnl of the data portions to output in any given case. We call these
33 dnl comments and executable code the "non-data" portions. Autoconf never
34 dnl copies any of the non-data portions into its output.
36 dnl This special exception to the GPL applies to versions of Autoconf
37 dnl released by the Free Software Foundation. When you make and
38 dnl distribute a modified version of Autoconf, you may extend this special
39 dnl exception to the GPL to apply to your modified version as well, *unless*
40 dnl your modified version has the potential to copy into its output some
41 dnl of the text that was the non-data portion of the version that you started
42 dnl with. (In other words, unless your change moves or copies text from
43 dnl the non-data portions to the data portions.) If your modification has
44 dnl such potential, you must delete any notice of this special exception
45 dnl to the GPL from your modified version.
47 dnl Written by David MacKenzie, with help from
48 dnl Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
49 dnl Roland McGrath, Noah Friedman, david d zuhn, and many others.
52 # AC_WIRESHARK_ADD_DASH_L
54 # Add to the variable specified as the first argument a "-L" flag for the
55 # directory specified as the second argument, and, on Solaris, add a
56 # "-R" flag for it as well.
58 # XXX - IRIX, and other OSes, may require some flag equivalent to
61 AC_DEFUN([AC_WIRESHARK_ADD_DASH_L],
62 [AX_APPEND_FLAG(-L$2, $1)
65 AX_APPEND_FLAG(-R$2, $1)
71 # AC_WIRESHARK_PUSH_FLAGS
73 # Push our flags to CFLAGS/etc.
75 AC_DEFUN([AC_WIRESHARK_PUSH_FLAGS],
77 ac_ws_CPPLAGS_saved="$CPPFLAGS"
78 ac_ws_CFLAGS_saved="$CFLAGS"
79 ac_ws_CXXFLAGS_saved="$CXXFLAGS"
80 ac_ws_LDFLAGS_saved="$LDFLAGS"
81 CPPFLAGS="$WS_CPPFLAGS $CPPFLAGS"
82 CFLAGS="$WS_CFLAGS $CFLAGS"
83 CXXFLAGS="$WS_CXXFLAGS $CXXFLAGS"
84 LDFLAGS="$WS_LDFLAGS $LDFLAGS"
88 # AC_WIRESHARK_POP_FLAGS
90 # Restore user build flags.
92 AC_DEFUN([AC_WIRESHARK_POP_FLAGS],
94 CPPFLAGS="$ac_ws_CPPLAGS_saved"
95 CFLAGS="$ac_ws_CFLAGS_saved"
96 CXXFLAGS="$ac_ws_CXXFLAGS_saved"
97 LDFLAGS="$ac_ws_LDFLAGS_saved"
102 # AC_WIRESHARK_BREAKLOOP_TRY_LINK
104 AC_DEFUN([AC_WIRESHARK_PCAP_BREAKLOOP_TRY_LINK],
120 ws_breakloop_compiled=yes
123 ws_breakloop_compiled=no
130 # AC_WIRESHARK_PCAP_CHECK
132 AC_DEFUN([AC_WIRESHARK_PCAP_CHECK],
134 AC_WIRESHARK_PUSH_FLAGS
136 if test -z "$pcap_dir"
139 # XXX need to set a var AC_CHECK_HEADER(pcap.h,,)
142 # The user didn't specify a directory in which libpcap resides.
143 # First, look for a pcap-config script.
145 AC_PATH_TOOL(PCAP_CONFIG, pcap-config)
147 if test -n "$PCAP_CONFIG" ; then
151 # Now check whether it's the libpcap 1.0 version, which
152 # put a space after "-L" - on some platforms, that doesn't
155 AC_MSG_CHECKING(for broken pcap-config)
156 case "`\"$PCAP_CONFIG\" --libs`" in
160 # Space after -L. Pretend pcap-config doesn't exist.
174 if test -n "$PCAP_CONFIG" ; then
176 # Found it, and it's usable; use it to get the include flags
179 CPPFLAGS="$CPPFLAGS `\"$PCAP_CONFIG\" --cflags`"
182 # Didn't find it; we have to look for libpcap ourselves.
183 # We assume that the current library search path will work,
184 # but we may have to look for the header in a "pcap"
185 # subdirectory of "/usr/include" or "/usr/local/include",
186 # as some systems apparently put "pcap.h" in a "pcap"
187 # subdirectory, and we also check "$prefix/include" - and
188 # "$prefix/include/pcap", in case $prefix is set to
189 # "/usr/include" or "/usr/local/include".
191 # XXX - should we just add "$prefix/include" to the include
192 # search path and "$prefix/lib" to the library search path?
194 AC_MSG_CHECKING(for extraneous pcap header directories)
196 pcap_dir_list="/usr/local/include/pcap /usr/include/pcap $prefix/include/pcap $prefix/include"
197 for pcap_dir in $pcap_dir_list
199 if test -d $pcap_dir ; then
200 if test x$pcap_dir != x/usr/include -a x$pcap_dir != x/usr/local/include ; then
201 CPPFLAGS="$CPPFLAGS -I$pcap_dir"
203 found_pcap_dir=" $found_pcap_dir -I$pcap_dir"
208 if test "$found_pcap_dir" != "" ; then
209 AC_MSG_RESULT(found --$found_pcap_dir added to CFLAGS)
211 AC_MSG_RESULT(not found)
216 # The user specified a directory in which libpcap resides,
217 # so add the "include" subdirectory of that directory to
218 # the include file search path and the "lib" subdirectory
219 # of that directory to the library search path.
221 # XXX - if there's also a libpcap in a directory that's
222 # already in CPPFLAGS or LDFLAGS, this won't make us find
223 # the version in the specified directory, as the compiler
224 # and/or linker will search that other directory before it
225 # searches the specified directory.
227 CPPFLAGS="$CPPFLAGS -I$pcap_dir/include"
228 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, $pcap_dir/lib)
232 AC_CHECK_HEADER(pcap.h,,
233 AC_MSG_ERROR([[Header file pcap.h not found; if you installed libpcap
234 from source, did you also do \"make install-incl\", and if you installed a
235 binary package of libpcap, is there also a developer's package of libpcap,
236 and did you also install that package?]]))
238 if test -n "$PCAP_CONFIG" ; then
240 # We have pcap-config; we assume that means we have libpcap
241 # installed and that pcap-config will tell us whatever
242 # libraries libpcap needs.
244 if test x$enable_static = xyes; then
245 PCAP_LIBS="`\"$PCAP_CONFIG\" --libs --static`"
247 PCAP_LIBS="`\"$PCAP_CONFIG\" --libs`"
249 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library])
252 # Check to see if we find "pcap_open_live" in "-lpcap".
253 # Also check for various additional libraries that libpcap might
256 AC_CHECK_LIB(pcap, pcap_open_live,
259 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library])
261 ac_wireshark_extras_found=no
263 for extras in "-lcfg -lodm" "-lpfring"
265 AC_MSG_CHECKING([for pcap_open_live in -lpcap with $extras])
266 LIBS="-lpcap $extras $ac_save_LIBS"
268 # XXX - can't we use AC_CHECK_LIB here?
275 pcap_open_live(NULL, 0, 0, 0, NULL);
278 ac_wireshark_extras_found=yes
280 PCAP_LIBS="-lpcap $extras"
281 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library])
286 if test x$ac_wireshark_extras_found = xyes
291 if test x$ac_wireshark_extras_found = xno
293 AC_MSG_ERROR([Can't link with library libpcap.])
301 # Check whether various variables and functions are defined by
305 LIBS="$PCAP_LIBS $LIBS"
306 AC_CHECK_FUNCS(pcap_open_dead pcap_freecode)
308 # pcap_breakloop may be present in the library but not declared
309 # in the pcap.h header file. If it's not declared in the header
310 # file, attempts to use it will get warnings, and, if we're
311 # building with warnings treated as errors, that warning will
312 # cause compilation to fail.
314 # We are therefore first testing whether the function is present
315 # and then, if we're compiling with warnings as errors, testing
316 # whether it is usable. It is usable if it compiles without
317 # a -Wimplicit warning (the "compile with warnings as errors"
318 # option requires GCC). If it is not usable, we fail and tell
319 # the user that the pcap.h header needs to be updated.
321 # Ceteris paribus, this should only happen with Mac OS X 10.3[.x] which
322 # can have an up-to-date pcap library without the corresponding pcap
325 # However, it might also happen on some others OSes with some erroneous
326 # system manipulations where multiple versions of libpcap might co-exist
327 # e.g. hand made symbolic link from libpcap.so -> libpcap.so.0.8 but
328 # having the pcap header version 0.7.
330 AC_MSG_CHECKING([whether pcap_breakloop is present])
331 ac_CFLAGS_saved="$CFLAGS"
332 AC_WIRESHARK_PCAP_BREAKLOOP_TRY_LINK
333 if test "x$ws_breakloop_compiled" = "xyes"; then
335 AC_DEFINE(HAVE_PCAP_BREAKLOOP, 1, [Define if pcap_breakloop is known])
336 if test "x$with_warnings_as_errors" = "xyes"; then
337 AC_MSG_CHECKING([whether pcap_breakloop is usable])
338 CFLAGS="$CFLAGS -Werror -Wimplicit"
339 AC_WIRESHARK_PCAP_BREAKLOOP_TRY_LINK
340 if test "x$ws_breakloop_compiled" = "xyes"; then
345 [Your pcap library is more recent than your pcap header.
346 As you are building with compiler warnings treated as errors, Wireshark
347 won't be able to use functions not declared in that header.
348 If you wish to build with compiler warnings treated as errors, You should
349 install a newer version of the header file.])
351 CFLAGS="$ac_CFLAGS_saved"
358 # Later versions of Mac OS X 10.3[.x] ship a pcap.h that
359 # doesn't define pcap_if_t but ship an 0.8[.x] libpcap,
360 # so the library has "pcap_findalldevs()", but pcap.h
361 # doesn't define "pcap_if_t" so you can't actually *use*
362 # "pcap_findalldevs()".
364 # That even appears to be true of systems shipped with
365 # 10.3.4, so it doesn't appear only to be a case of
366 # Software Update not updating header files.
368 # (You can work around this by installing the 0.8 header
371 AC_CACHE_CHECK([whether pcap_findalldevs is present and usable],
372 [ac_cv_func_pcap_findalldevs],
381 pcap_if_t *devpointer;
384 pcap_findalldevs(&devpointer, errbuf);
389 ac_cv_func_pcap_findalldevs=yes
392 ac_cv_func_pcap_findalldevs=no
396 # Don't check for other new routines that showed up after
397 # "pcap_findalldevs()" if we don't have a usable
398 # "pcap_findalldevs()", so we don't end up using them if the
399 # "pcap.h" is crufty and old and doesn't declare them.
401 if test $ac_cv_func_pcap_findalldevs = "yes" ; then
402 AC_DEFINE(HAVE_PCAP_FINDALLDEVS, 1,
403 [Define to 1 if you have the `pcap_findalldevs' function and a pcap.h that declares pcap_if_t.])
404 AC_CHECK_FUNCS(pcap_datalink_val_to_name pcap_datalink_name_to_val)
405 AC_CHECK_FUNCS(pcap_datalink_val_to_description)
406 AC_CHECK_FUNCS(pcap_list_datalinks pcap_set_datalink pcap_lib_version)
407 AC_CHECK_FUNCS(pcap_get_selectable_fd pcap_free_datalinks)
408 AC_CHECK_FUNC(pcap_create,
410 AC_DEFINE(HAVE_PCAP_CREATE, 1,
411 [Define to 1 if you have the `pcap_create' function.])
412 AC_DEFINE(CAN_SET_CAPTURE_BUFFER_SIZE, 1,
413 [Define to 1 if the capture buffer size can be set.])
415 AC_CHECK_FUNCS(bpf_image pcap_set_tstamp_precision)
418 AC_WIRESHARK_POP_FLAGS
422 AC_DEFUN([AC_WIRESHARK_PCAP_REMOTE_CHECK],
425 LIBS="$PCAP_LIBS $LIBS"
426 AC_CHECK_FUNCS(pcap_open)
427 if test $ac_cv_func_pcap_open = "yes" ; then
428 AC_DEFINE(HAVE_PCAP_REMOTE, 1,
429 [Define to 1 if you have libpcap/WinPcap remote capturing support and prefer to use these new API features.])
431 AC_CHECK_FUNCS(pcap_setsampling)
436 # AC_WIRESHARK_ZLIB_CHECK
438 AC_DEFUN([AC_WIRESHARK_ZLIB_CHECK],
440 AC_WIRESHARK_PUSH_FLAGS
442 if test "x$zlib_dir" != "x"
445 # The user specified a directory in which zlib resides,
446 # so add the "include" subdirectory of that directory to
447 # the include file search path and the "lib" subdirectory
448 # of that directory to the library search path.
450 # XXX - if there's also a zlib in a directory that's
451 # already in CPPFLAGS or LDFLAGS, this won't make us find
452 # the version in the specified directory, as the compiler
453 # and/or linker will search that other directory before it
454 # searches the specified directory.
456 CPPFLAGS="$CPPFLAGS -I$zlib_dir/include"
457 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, $zlib_dir/lib)
461 # Make sure we have "zlib.h". If we don't, it means we probably
462 # don't have zlib, so don't use it.
464 AC_CHECK_HEADER(zlib.h,,
466 if test "x$zlib_dir" != "x"
469 # The user used "--with-zlib=" to specify a directory
470 # containing zlib, but we didn't find the header file
471 # there; that either means they didn't specify the
472 # right directory or are confused about whether zlib
473 # is, in fact, installed. Report the error and give up.
475 AC_MSG_ERROR([zlib header not found in directory specified in --with-zlib])
477 if test "x$want_zlib" = "xyes"
480 # The user tried to force us to use the library, but we
481 # couldn't find the header file; report an error.
483 AC_MSG_ERROR(Header file zlib.h not found.)
486 # We couldn't find the header file; don't use the
487 # library, as it's probably not present.
494 if test "x$want_zlib" != "xno"
497 # Well, we at least have the zlib header file.
498 # We link with zlib to support uncompression of
499 # gzipped network traffic, e.g. in an HTTP request
502 if test "x$zlib_dir" != "x"
504 WS_CPPFLAGS="$WS_CPPFLAGS -I$zlib_dir/include"
505 AC_WIRESHARK_ADD_DASH_L(WS_LDFLAGS, $zlib_dir/lib)
508 AC_DEFINE(HAVE_ZLIB, 1, [Define to use zlib library])
510 # Check for "inflatePrime()" in zlib, which we need
511 # in order to read compressed capture files.
513 AC_CHECK_FUNCS(inflatePrime)
515 if test "x$ac_cv_func_inflatePrime" = "xyes" ; then
517 # Now check for "inflatePrime()" in zlib when
518 # linking with the linker flags for GTK+
519 # applications; people often grab XFree86 source
520 # and build and install it on their systems,
521 # and they appear sometimes to misconfigure
522 # XFree86 so that, even on systems with zlib,
523 # it assumes there is no zlib, so the XFree86
524 # build process builds and installs its
525 # own zlib in the X11 library directory.
527 # The zlib in at least some versions of XFree86
528 # is an older version that may lack "inflatePrime()",
529 # and that's the zlib with which Wireshark gets
530 # linked, so the build of Wireshark fails.
532 AC_MSG_CHECKING([for inflatePrime missing when linking with X11])
533 AC_TRY_LINK_FUNC(inflatePrime, AC_MSG_RESULT(no),
536 AC_MSG_ERROR(old zlib found when linking with X11 - get rid of old zlib.)
541 AC_WIRESHARK_POP_FLAGS
545 # AC_WIRESHARK_LIBLUA_CHECK
547 # Sets $have_lua to yes or no.
548 # If it's yes, it also sets $LUA_CFLAGS and $LUA_LIBS.
549 AC_DEFUN([AC_WIRESHARK_LIBLUA_CHECK],[
551 AC_WIRESHARK_PUSH_FLAGS
553 if test "x$want_lua_dir" = "x"
555 # The user didn't tell us where to find Lua. Let's go look for it.
557 # First, try the standard (pkg-config) way.
558 # Unfortunately Lua's pkg-config file isn't standardly named.
559 # Some distributions allow installation of multiple versions of
560 # Lua at the same time. On such systems each version has its
563 # We use a for loop instead of giving all the package names to
564 # PKG_CHECK_MODULES because doing the latter doesn't appear to
565 # work reliably (some package names are not searched for).
566 for pkg in "lua < 5.3" lua5.2 lua-5.2 lua52 lua5.1 lua-5.1 lua51 lua5.0 lua-5.0 lua50
568 AC_MSG_CHECKING(if you have $pkg)
569 PKG_CHECK_EXISTS($pkg,
578 if test "x$have_lua" = "xyes"
580 PKG_WIRESHARK_CHECK_SYSTEM_MODULES(LUA, $pkg)
581 CPPFLAGS="$LUA_CFLAGS $CPPFLAGS"
582 AC_CHECK_HEADERS(lua.h lualib.h lauxlib.h)
588 if test "x$have_lua" != "xyes"
590 # We don't have pkg-config or the user specified the path to
591 # Lua (in $want_lua_dir).
592 # Let's look for the header file.
594 AC_MSG_CHECKING(for the location of lua.h)
595 if test "x$want_lua_dir" = "x"
597 # The user didn't tell us where to look so we'll look in some
598 # standard locations.
599 want_lua_dir="/usr/local /usr $prefix"
601 for dir in $want_lua_dir
603 if test -r "$dir/include/lua.h"
605 header_dir="$dir/include"
610 for ver in 5.2 52 5.1 51 5.0 50
612 if test -r "$dir/include/lua$ver/lua.h"
614 header_dir="$dir/include/lua$ver"
621 if test "x$header_dir" = "x"
624 AC_MSG_RESULT(not found)
626 AC_MSG_RESULT($header_dir)
628 AC_MSG_CHECKING(the Lua version)
629 lua_ver=`$AWK AS_ESCAPE('/LUA_VERSION_NUM/ { print $NF; }' $header_dir/lua.h | sed 's/0/./')`
631 if test "x$lua_ver" = "x5.3"
633 # Wireshark doesn't compile with Lua 5.3 today
634 AC_MSG_RESULT($lua_ver - disabling Lua support)
637 AC_MSG_RESULT($lua_ver)
639 CPPFLAGS="$CPPFLAGS -I$header_dir"
640 AC_CHECK_HEADERS(lua.h lualib.h lauxlib.h, ,
646 if test "x$have_lua" = "x"
649 LUA_CFLAGS="-I$header_dir"
651 # We have the header files and they work. Now let's check if we
652 # have the library and it works.
654 # XXX - if there's also a liblua in a directory that's
655 # already in CPPFLAGS or LDFLAGS, this won't make us find
656 # the version in the specified directory, as the compiler
657 # and/or linker will search that other directory before it
658 # searches the specified directory.
661 LDFLAGS="-L$lua_dir/lib $LDFLAGS"
662 AC_SEARCH_LIBS(luaL_openlibs, [lua-${lua_ver} lua${lua_ver} lua],
664 LUA_LIBS="-L$lua_dir/lib $ac_cv_search_luaL_openlibs -lm"
673 AC_WIRESHARK_POP_FLAGS
677 # AC_WIRESHARK_LIBPORTAUDIO_CHECK
679 AC_DEFUN([AC_WIRESHARK_LIBPORTAUDIO_CHECK],[
681 AC_WIRESHARK_PUSH_FLAGS
682 wireshark_save_LIBS="$LIBS"
684 if test "x$portaudio_dir" != "x"
687 # The user specified a directory in which libportaudio
688 # resides, so add the "include" subdirectory of that directory to
689 # the include file search path and the "lib" subdirectory
690 # of that directory to the library search path.
692 # XXX - if there's also a libportaudio in a directory that's
693 # already in CPPFLAGS or LDFLAGS, this won't make us find
694 # the version in the specified directory, as the compiler
695 # and/or linker will search that other directory before it
696 # searches the specified directory.
698 CPPFLAGS="$CPPFLAGS -I$portaudio_dir/include"
699 LDFLAGS="$LDFLAGS -L$portaudio_dir/lib"
701 LIBS="-lportaudio $LIBS"
704 # Make sure we have "portaudio.h". If we don't, it means we probably
705 # don't have libportaudio, so don't use it.
707 AC_CHECK_HEADERS(portaudio.h,,
709 if test "x$portaudio_dir" != "x"
712 # The user used "--with-portaudio=" to specify a directory
713 # containing libportaudio, but we didn't find the header file
714 # there; that either means they didn't specify the
715 # right directory or are confused about whether libportaudio
716 # is, in fact, installed. Report the error and give up.
718 AC_MSG_ERROR([libportaudio header not found in directory specified in --with-portaudio])
720 if test "x$want_portaudio" = "xyes"
723 # The user tried to force us to use the library, but we
724 # couldn't find the header file; report an error.
726 AC_MSG_ERROR(Header file portaudio.h not found.)
729 # We couldn't find the header file; don't use the
730 # library, as it's probably not present.
738 # Check whether we have the right version of portaudio
740 if test "x$want_portaudio" != "xno"
742 AC_CHECK_TYPE(PortAudioStream,
743 AC_DEFINE(PORTAUDIO_API_1, 1, [Define if we are using version of of the Portaudio library API]),
745 [#include <portaudio.h>])
748 if test "x$want_portaudio" != "xno"
751 # Well, we at least have the portaudio header file.
753 # let's check if the libs are there
756 PORTAUDIO_INCLUDES=""
758 AC_CHECK_LIB(portaudio, Pa_Initialize,
760 if test "x$portaudio_dir" != "x"
763 # Put the "-I" and "-L" flags for portaudio
764 # into PORTAUDIO_INCLUDES and PORTAUDIO_LIBS,
767 PORTAUDIO_LIBS="-L$portaudio_dir/lib -lportaudio"
768 PORTAUDIO_INCLUDES="-I$portaudio_dir/include"
770 PORTAUDIO_LIBS="-lportaudio"
772 AC_DEFINE(HAVE_LIBPORTAUDIO, 1, [Define to use libportaudio library])
775 # User requested --with-portaudio but it isn't available
776 if test "x$want_portaudio" = "xyes"
778 AC_MSG_ERROR(Linking with libportaudio failed.)
782 AC_SUBST(PORTAUDIO_LIBS)
783 AC_SUBST(PORTAUDIO_INCLUDES)
787 LIBS="$wireshark_save_LIBS"
788 AC_WIRESHARK_POP_FLAGS
793 # AC_WIRESHARK_C_ARES_CHECK
795 AC_DEFUN([AC_WIRESHARK_C_ARES_CHECK],
797 want_c_ares=defaultyes
799 if test "x$want_c_ares" = "xdefaultyes"; then
803 if test "x$want_c_ares" = "xyes"; then
804 AC_CHECK_LIB(cares, ares_init,
807 AC_DEFINE(HAVE_C_ARES, 1, [Define to use c-ares library])
811 AC_MSG_RESULT(not required)
817 # AC_WIRESHARK_LIBCAP_CHECK
819 AC_DEFUN([AC_WIRESHARK_LIBCAP_CHECK],
821 want_libcap=defaultyes
823 if test "x$want_libcap" = "xdefaultyes"; then
827 if test "x$want_libcap" = "xyes"; then
828 AC_CHECK_LIB(cap, cap_set_flag,
831 AC_DEFINE(HAVE_LIBCAP, 1, [Define to use the libcap library])
836 AC_MSG_RESULT(not required)
842 # AC_WIRESHARK_KRB5_CHECK
844 AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
846 AC_WIRESHARK_PUSH_FLAGS
847 wireshark_save_LIBS="$LIBS"
849 if test "x$krb5_dir" != "x"
852 # The user specified a directory in which kerberos resides,
853 # so add the "include" subdirectory of that directory to
854 # the include file search path and the "lib" subdirectory
855 # of that directory to the library search path.
857 # XXX - if there's also a kerberos in a directory that's
858 # already in CPPFLAGS or LDFLAGS, this won't make us find
859 # the version in the specified directory, as the compiler
860 # and/or linker will search that other directory before it
861 # searches the specified directory.
863 KRB5_CFLAGS="-I$krb5_dir/include"
864 ac_heimdal_version=`grep heimdal $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*heimdal.*$/HEIMDAL/'`
865 # MIT Kerberos moved krb5.h to krb5/krb5.h starting with release 1.5
866 ac_mit_version_olddir=`grep 'Massachusetts' $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*Massachusetts.*$/MIT/'`
867 ac_mit_version_newdir=`grep 'Massachusetts' $krb5_dir/include/krb5/krb5.h | head -n 1 | sed 's/^.*Massachusetts.*$/MIT/'`
868 ac_krb5_version="$ac_heimdal_version$ac_mit_version_olddir$ac_mit_version_newdir"
869 if test "x$ac_krb5_version" = "xHEIMDAL"
871 KRB5_LIBS="-L$krb5_dir/lib -lkrb5 -lasn1 $SSL_LIBS -lroken -lcrypt"
873 KRB5_LIBS="-L$krb5_dir/lib -lkrb5 -lk5crypto -lcom_err"
875 if test "x$ac_krb5_version" = "xMIT"
877 AC_DEFINE(HAVE_MIT_KERBEROS, 1, [Define to use MIT kerberos])
880 AC_PATH_TOOL(KRB5_CONFIG, krb5-config)
881 if test -x "$KRB5_CONFIG"
883 KRB5_CFLAGS=`"$KRB5_CONFIG" --cflags`
884 KRB5_LIBS=`"$KRB5_CONFIG" --libs`
886 # If -lcrypto is in KRB5_FLAGS, we require it to build
887 # with Heimdal/MIT. We don't want to built with it by
888 # default, due to annoying license incompatibilities
889 # between the OpenSSL license and the GPL, so:
891 # if SSL_LIBS is set to a non-empty string, we
892 # remove -lcrypto from KRB5_LIBS and replace
895 # if SSL_LIBS is not set to a non-empty string
896 # we fail with an appropriate error message.
900 if test ! -z "$SSL_LIBS"
902 KRB5_LIBS=`echo $KRB5_LIBS | sed 's/-lcrypto//'`
903 KRB5_LIBS="$KRB5_LIBS $SSL_LIBS"
905 AC_MSG_ERROR([Kerberos library requires -lcrypto, so you must specify --with-ssl])
909 ac_krb5_version=`"$KRB5_CONFIG" --version | head -n 1 | sed -e 's/^.*heimdal.*$/HEIMDAL/' -e 's/^Kerberos .*$/MIT/' -e 's/^Solaris Kerberos .*$/MIT/'`
913 CPPFLAGS="$CPPFLAGS $KRB5_CFLAGS"
916 # Make sure we have "krb5.h". If we don't, it means we probably
917 # don't have kerberos, so don't use it.
919 AC_CHECK_HEADER(krb5.h,,
921 if test "x$krb5_dir" != "x"
924 # The user used "--with-krb5=" to specify a directory
925 # containing kerberos, but we didn't find the header file
926 # there; that either means they didn't specify the
927 # right directory or are confused about whether kerberos
928 # is, in fact, installed. Report the error and give up.
930 AC_MSG_ERROR([kerberos header not found in directory specified in --with-krb5])
932 if test "x$want_krb5" = "xyes"
935 # The user tried to force us to use the library, but we
936 # couldn't find the header file; report an error.
938 AC_MSG_ERROR(Header file krb5.h not found.)
941 # We couldn't find the header file; don't use the
942 # library, as it's probably not present.
947 AC_MSG_RESULT(No Heimdal or MIT header found - disabling dissection for some kerberos data in packet decoding)
952 if test "x$want_krb5" != "xno"
955 # Well, we at least have the krb5 header file.
956 # Check whether this is Heimdal or MIT.
958 AC_MSG_CHECKING(whether the Kerberos library is Heimdal or MIT)
959 if test "x$ac_krb5_version" = "xHEIMDAL" -o "x$ac_krb5_version" = "xMIT"
963 # Check whether we have krb5_kt_resolve - and whether
964 # we need to link with -lresolv when linking with
965 # the Kerberos library.
967 AC_MSG_RESULT($ac_krb5_version)
968 found_krb5_kt_resolve=no
969 for extras in "" "-lresolv"
971 LIBS="$KRB5_LIBS $extras $wireshark_save_LIBS"
974 AC_MSG_CHECKING([whether $ac_krb5_version includes krb5_kt_resolve])
976 AC_MSG_CHECKING([whether $ac_krb5_version includes krb5_kt_resolve (linking with $extras)])
983 krb5_kt_resolve(0, 0, 0);
987 # We found "krb5_kt_resolve()".
990 if test -n "$extras"; then
991 KRB5_LIBS="$KRB5_LIBS $extras"
993 AC_DEFINE(HAVE_KERBEROS, 1, [Define to use kerberos])
994 if test "x$ac_krb5_version" = "xHEIMDAL"
996 AC_DEFINE(HAVE_HEIMDAL_KERBEROS, 1, [Define to use heimdal kerberos])
997 elif test "x$ac_krb5_version" = "xMIT"
999 AC_DEFINE(HAVE_MIT_KERBEROS, 1, [Define to use MIT kerberos])
1001 found_krb5_kt_resolve=yes
1008 if test "$found_krb5_kt_resolve" = no
1011 # We didn't find "krb5_kt_resolve()" in the
1012 # Kerberos library, even when we tried linking
1013 # with -lresolv; we can't link with kerberos.
1015 if test "x$want_krb5" = "xyes"
1018 # The user tried to force us to use the library,
1019 # but we can't do so; report an error.
1021 AC_MSG_ERROR(Usable $ac_krb5_version not found)
1026 AC_MSG_RESULT(Usable $ac_krb5_version not found - disabling dissection for some kerberos data in packet decoding)
1033 # We can link with Kerberos; see whether krb5.h
1034 # defines KEYTYPE_ARCFOUR_56 (where "defines" means
1035 # "as a #define or as an enum member).
1037 AC_MSG_CHECKING([whether krb5.h defines KEYTYPE_ARCFOUR_56])
1047 printf("%u\n", KEYTYPE_ARCFOUR_56);
1053 AC_DEFINE(HAVE_KEYTYPE_ARCFOUR_56, 1, [Define if krb5.h defines KEYTYPE_ARCFOUR_56])
1061 # It's not Heimdal or MIT.
1064 if test "x$want_krb5" = "xyes"
1067 # The user tried to force us to use the library,
1068 # but we can't do so; report an error.
1070 AC_MSG_ERROR(Kerberos not found)
1075 AC_MSG_RESULT(Kerberos not found - disabling dissection for some kerberos data in packet decoding)
1083 # The user asked us not to use Kerberos, or they didn't
1084 # say whether they wanted us to use it but we found
1091 AC_SUBST(KRB5_CFLAGS)
1094 LIBS="$wireshark_save_LIBS"
1095 AC_WIRESHARK_POP_FLAGS
1099 # AC_WIRESHARK_GEOIP_CHECK
1101 AC_DEFUN([AC_WIRESHARK_GEOIP_CHECK],
1103 want_geoip=defaultyes
1105 if test "x$want_geoip" = "xdefaultyes"; then
1109 if test "x$want_geoip" = "xyes"; then
1110 AC_CHECK_LIB(GeoIP, GeoIP_new,
1113 AC_DEFINE(HAVE_GEOIP, 1, [Define to use GeoIP library])
1117 if test "x$have_good_geoip" = "xyes"; then
1118 AC_CHECK_LIB(GeoIP, GeoIP_country_name_by_ipnum_v6,
1120 AC_DEFINE(HAVE_GEOIP_V6, 1, [Define if GeoIP supports IPv6 (GeoIP 1.4.5 and later)])
1123 AC_CHECK_LIB(GeoIP, GeoIP_free,
1125 AC_DEFINE(HAVE_GEOIP_FREE, 1, [Define if GeoIP has GeoIP_free (not available upstream with 1.6.10 or earlier)])
1130 AC_MSG_RESULT(not required)
1135 # AC_WIRESHARK_LIBSSH_CHECK
1137 AC_DEFUN([AC_WIRESHARK_LIBSSH_CHECK],
1139 want_libssh=defaultyes
1141 if test "x$want_libssh" = "xdefaultyes"; then
1145 if test "x$want_libssh" = "xyes"; then
1146 AC_CHECK_LIB(ssh, ssh_new,
1149 AC_DEFINE(HAVE_LIBSSH, 1, [Define to use libssh library])
1150 have_good_libssh=yes
1153 AC_MSG_CHECKING([whether libssh >= 0.6.0 for sshdump, ciscodump])
1154 PKG_CHECK_EXISTS([libssh >= 0.6.0],
1157 AC_DEFINE(HAVE_LIBSSH_POINTSIX, 1, [Defined if libssh >= 0.6.0])
1158 have_libssh_pointsix=yes
1162 if test "x$have_libssh_pointsix" = "xyes"; then
1163 # ssh_userauth_agent exists only >= 0.6.0, but not on Windows
1164 # so check explicitly
1165 AC_CHECK_LIB(ssh, ssh_userauth_agent,
1167 AC_DEFINE(HAVE_SSH_USERAUTH_AGENT, 1, [Libssh library has ssh_userauth_agent])
1168 have_ssh_userauth_agent=yes
1173 AC_MSG_RESULT(not required)
1178 # AC_WIRESHARK_NGHTTP2_CHECK
1180 AC_DEFUN([AC_WIRESHARK_NGHTTP2_CHECK],
1182 want_nghttp2=defaultyes
1184 if test "x$want_nghttp2" = "xdefaultyes"; then
1188 if test "x$want_nghttp2" = "xyes"; then
1189 AC_CHECK_LIB(nghttp2, nghttp2_hd_inflate_new,
1191 AC_CHECK_HEADERS(nghttp2/nghttp2.h,
1193 NGHTTP2_LIBS=-lnghttp2
1194 AC_DEFINE(HAVE_NGHTTP2, 1, [Define to use nghttp2 library])
1195 have_good_nghttp2=yes
1201 AC_MSG_RESULT(not required)
1205 #AC_WIRESHARK_LDFLAGS_CHECK
1207 # $1 : ldflag(s) to test
1209 # We attempt to compile and link a test program with the specified linker
1210 # flag. The defined flag is added to LDFLAGS only if the link succeeds.
1212 AC_DEFUN([AC_WIRESHARK_LDFLAGS_CHECK],
1214 AC_MSG_CHECKING(whether we can add $LD_OPTION to LDFLAGS)
1215 AC_WIRESHARK_PUSH_FLAGS
1216 LDFLAGS="$LDFLAGS $LD_OPTION"
1217 can_add_to_ldflags=""
1220 AC_LANG_SOURCE([[int main() { return 0; }]])
1224 AX_APPEND_FLAG([$LD_OPTION], [WS_LDFLAGS])
1225 can_add_to_ldflags=yes
1229 can_add_to_ldflags=no
1231 AC_WIRESHARK_POP_FLAGS
1235 dnl Check whether, if you pass an unknown warning option to the
1236 dnl compiler, it fails or just prints a warning message and succeeds.
1237 dnl Set ac_wireshark_unknown_warning_option_error to the appropriate flag
1238 dnl to force an error if it would otherwise just print a warning message
1241 AC_DEFUN([AC_WIRESHARK_CHECK_UNKNOWN_WARNING_OPTION_ERROR],
1243 AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option])
1244 AC_WIRESHARK_PUSH_FLAGS
1245 CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
1250 AC_MSG_RESULT([no, adding -Werror=unknown-warning-option])
1252 # We're assuming this is clang, where
1253 # -Werror=unknown-warning-option is the appropriate
1254 # option to force the compiler to fail.
1256 ac_wireshark_unknown_warning_option_error="-Werror=unknown-warning-option"
1259 AC_MSG_RESULT([yes])
1261 AC_WIRESHARK_POP_FLAGS
1265 dnl Check whether, if you pass a valid-for-C-but-not-C++ option to the
1266 dnl compiler, it fails or just prints a warning message and succeeds.
1267 dnl Set ac_wireshark_non_cxx_warning_option_error to the appropriate flag
1268 dnl to force an error if it would otherwise just print a warning message
1271 AC_DEFUN([AC_WIRESHARK_CHECK_NON_CXX_WARNING_OPTION_ERROR],
1273 AC_MSG_CHECKING([whether the compiler fails when given an warning option not supported for C++])
1275 # Some C+ compilers warn about -Wmissing-prototypes, and some warn
1276 # about -Wmissing-declarations. Check both.
1279 AC_WIRESHARK_PUSH_FLAGS
1280 save_CXXFLAGS="$CXXFLAGS"
1281 for flag in -Wmissing-prototypes -Wmissing-declarations; do
1282 CXXFLAGS="$save_CXXFLAGS $flag"
1288 # We're assuming this is g++, where -Werror is the
1289 # appropriate option to force the compiler to fail.
1290 # Check whether it fails with -Werror.
1292 # NOTE: it's important to put -Werror *before*
1293 # the flag, otherwise, when it sees the flag,
1294 # it doesn't yet know that warnings should be
1295 # treated as errors, and doesn't treat the
1296 # "that's C-only" warning as an error.
1298 CXXFLAGS="$save_CXXFLAGS -Werror $flag"
1304 # No, so this option is actually OK
1305 # with our C++ compiler.
1307 # (We need an empty command here to
1308 # prevent some versions of autoconf
1309 # from generating a script with an
1310 # empty "then" clause for an if statement.)
1316 # Yes, so we need -Werror for the tests.
1318 ac_wireshark_non_cxx_warning_option_error="-Werror"
1323 AC_WIRESHARK_POP_FLAGS
1325 if test x$ac_wireshark_non_cxx_warning_option_error = x; then
1326 AC_MSG_RESULT([yes])
1328 AC_MSG_RESULT([no, adding -Werror])
1333 # AC_WIRESHARK_COMPILER_FLAGS_CHECK
1335 # $1 : flags to test
1336 # $2 : if supplied, C for C-only flags, CXX for C++-only flags
1337 # $3 : if supplied, a program to try to compile with the flag
1338 # and, if the compile fails when -Werror is turned on,
1339 # we don't add the flag - used for warning flags that
1340 # issue incorrect or non-useful warnings with some
1342 # $4 : must be supplied if $3 is supplied - a message describing
1343 # for what the test program is testing
1345 # The macro first determines if the compiler supports GCC-style flags.
1346 # Then it attempts to compile with the defined cflags. The defined
1347 # flags are added to WS_CHECKED_CFLAGS only if the compilation succeeds.
1348 # CFLAGS remains unchanged. can_add_to_cflags is set to "no" when the
1349 # flag is checked but unavailable. (Like-wise for CXXFLAGS.)
1351 # We do this because not all such options are necessarily supported by
1352 # the version of the particular compiler we're using.
1354 AC_DEFUN([AC_WIRESHARK_COMPILER_FLAGS_CHECK],
1356 can_add_to_cflags=""
1357 can_add_to_cxxflags=""
1358 if test "x$ac_supports_gcc_flags" = "xyes" ; then
1359 if test "$2" != CXX ; then
1361 # Not C++-only; if this can be added to the C compiler flags, add them.
1363 # If the option begins with "-W", add
1364 # $ac_wireshark_unknown_warning_option_error to make sure that
1365 # we'll get an error if it's an unknown warning option; not all
1366 # compilers treat unknown warning options as errors (I'm looking at
1369 # If the option begins with "-f" or "-m", add -Werror to make sure
1370 # that we'll get an error if we get "argument unused during compilation"
1371 # warnings, as those will either cause a failure for files compiled
1372 # with -Werror or annoying noise for files compiled without it.
1373 # (Yeah, you, clang.)
1375 AC_MSG_CHECKING(whether we can add $GCC_OPTION to CFLAGS)
1376 AC_WIRESHARK_PUSH_FLAGS
1377 if expr "x$GCC_OPTION" : "x-W.*" >/dev/null
1379 CFLAGS="$CFLAGS $ac_wireshark_unknown_warning_option_error $GCC_OPTION"
1380 elif expr "x$GCC_OPTION" : "x-f.*" >/dev/null
1382 CFLAGS="$CFLAGS -Werror $GCC_OPTION"
1383 elif expr "x$GCC_OPTION" : "x-m.*" >/dev/null
1385 CFLAGS="$CFLAGS -Werror $GCC_OPTION"
1387 CFLAGS="$CFLAGS $GCC_OPTION"
1391 AC_LANG_SOURCE([[int foo;]])
1395 can_add_to_cflags=yes
1397 # OK, do we have a test program? If so, check
1398 # whether it fails with this option and -Werror,
1399 # and, if so, don't include it.
1401 # We test arg 4 here because arg 3 is a program which
1402 # could contain quotes (breaking the comparison).
1404 if test "x$4" != "x" ; then
1405 CFLAGS="$CFLAGS -Werror"
1406 AC_MSG_CHECKING(whether $GCC_OPTION $4)
1408 [AC_LANG_SOURCE($3)],
1412 # Remove "force an error for a warning" options, if we
1413 # added them, by setting CFLAGS to the saved value plus
1414 # just the new option.
1416 AX_APPEND_FLAG([$GCC_OPTION], [WS_CFLAGS])
1417 if test "$CC" = "$CC_FOR_BUILD"; then
1419 # We're building the build tools with the same compiler
1420 # with which we're building Wireshark, so add the flags
1421 # to the flags for that compiler as well.
1423 AX_APPEND_FLAG([$GCC_OPTION], [WS_CFLAGS_FOR_BUILD])
1431 # Remove "force an error for a warning" options, if we
1432 # added them, by setting CFLAGS to the saved value plus
1433 # just the new option.
1435 AX_APPEND_FLAG([$GCC_OPTION], [WS_CFLAGS])
1436 if test "$CC" = "$CC_FOR_BUILD"; then
1438 # We're building the build tools with the same compiler
1439 # with which we're building Wireshark, so add the flags
1440 # to the flags for that compiler as well.
1442 AX_APPEND_FLAG([$GCC_OPTION], [WS_CFLAGS_FOR_BUILD])
1448 can_add_to_cflags=no
1450 AC_WIRESHARK_POP_FLAGS
1453 # Did we find a C++ compiler?
1455 if test "x$CXX" != "x" ; then
1457 # Yes. Is this option only for the C compiler?
1459 if test "$2" != C ; then
1461 # Not C-only; if this option can be added to the C++ compiler
1464 # If the option begins with "-W", add
1465 # $ac_wireshark_unknown_warning_option_error, as per the above, and
1466 # also add $ac_wireshark_non_cxx_warning_option_error, because at
1467 # lease some versions of g++ whine about -Wmissing-prototypes, the
1468 # fact that at least one of those versions refuses to warn about
1469 # function declarations without an earlier declaration nonwithstanding;
1470 # perhaps there's a reason not to warn about that with C++ even though
1471 # warning about it can be a Good Idea with C, but it's not obvious to
1474 # If the option begins with "-f" or "-m", add -Werror to make sure
1475 # that we'll get an error if we get "argument unused during compilation"
1476 # warnings, as those will either cause a failure for files compiled
1477 # with -Werror or annoying noise for files compiled without it.
1478 # (Yeah, you, clang++.)
1480 AC_MSG_CHECKING(whether we can add $GCC_OPTION to CXXFLAGS)
1481 AC_WIRESHARK_PUSH_FLAGS
1482 if expr "x$GCC_OPTION" : "x-W.*" >/dev/null
1484 CXXFLAGS="$CXXFLAGS $ac_wireshark_unknown_warning_option_error $ac_wireshark_non_cxx_warning_option_error $GCC_OPTION"
1485 elif expr "x$GCC_OPTION" : "x-f.*" >/dev/null
1487 CXXFLAGS="$CXXFLAGS -Werror $GCC_OPTION"
1488 elif expr "x$GCC_OPTION" : "x-m.*" >/dev/null
1490 CXXFLAGS="$CXXFLAGS -Werror $GCC_OPTION"
1492 CXXFLAGS="$CXXFLAGS $GCC_OPTION"
1497 AC_LANG_SOURCE([[int foo;]])
1501 can_add_to_cxxflags=yes
1503 # OK, do we have a test program? If so, check
1504 # whether it fails with this option and -Werror,
1505 # and, if so, don't include it.
1507 # We test arg 4 here because arg 3 is a program which
1508 # could contain quotes (breaking the comparison).
1510 if test "x$4" != "x" ; then
1511 CXXFLAGS="$CXXFLAGS -Werror"
1512 AC_MSG_CHECKING(whether $GCC_OPTION $4)
1514 [AC_LANG_SOURCE($3)],
1518 # Remove "force an error for a warning" options, if we
1519 # added them, by setting CXXFLAGS to the saved value plus
1520 # just the new option.
1522 AX_APPEND_FLAG([$GCC_OPTION], [WS_CXXFLAGS])
1529 # Remove "force an error for a warning" options, if we
1530 # added them, by setting CXXFLAGS to the saved value plus
1531 # just the new option.
1533 AX_APPEND_FLAG([$GCC_OPTION], [WS_CXXFLAGS])
1538 can_add_to_cxxflags=no
1540 AC_WIRESHARK_POP_FLAGS
1543 if test "(" "$can_add_to_cflags" = "yes" -a "$can_add_to_cxxflags" = "no" ")" \
1544 -o "(" "$can_add_to_cflags" = "no" -a "$can_add_to_cxxflags" = "yes" ")"
1547 # Confusingly, some C++ compilers like -Wmissing-prototypes but
1548 # don't like -Wmissing-declarations and others like
1549 # -Wmissing-declarations but don't like -Wmissing-prototypes,
1550 # the fact that the corresponding C compiler likes both. Don't
1553 if test "(" x$GCC_OPTION != x-Wmissing-prototypes ")" \
1554 -a "(" x$GCC_OPTION != x-Wmissing-declarations ")"
1556 AC_MSG_WARN([$CC and $CXX appear to be a mismatched pair])
1563 # AC_WIRESHARK_GCC_FORTIFY_SOURCE_CHECK
1565 # Checks if '-D_FORTIFY_SOURCE=...' is OK to use in CPPFLAGS.
1566 # Use '-D_FORTIFY_SOURCE=...' in CPPFLAGS only if the GCC 'optimization level' is > 0.
1567 # The use of '-D_FORTIFY_SOURCE=...' will cause a warning with at least some versions
1568 # of glibc if the GCC "optimization level" is 0 (default or -O or -O0)
1569 # when using GCC to compile a source file which references the macro definition.
1571 # See: http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
1572 # See: http://sourceware.org/bugzilla/show_bug.cgi?id=13979
1574 # We'll use '-D_FORTIFY_SOURCE=2' only if there's no warning; Among other things this means
1575 # that the use of '-D_FORTIFY_SOURCE=2' with '-Werror' and '-O0' won't cause
1576 # the compiler to stop on error.
1577 # Assumption: CFLAGS already contains whatever optimization option including none) is
1581 AC_DEFUN([AC_WIRESHARK_GCC_FORTIFY_SOURCE_CHECK],
1583 if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
1584 AC_MSG_CHECKING([whether -D_FORTIFY_SOURCE=2 can be used (without generating a warning)])
1585 AC_WIRESHARK_PUSH_FLAGS
1586 CFLAGS="$CFLAGS -Werror"
1587 CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
1595 AX_APPEND_FLAG([-D_FORTIFY_SOURCE=2], [WS_CPPFLAGS])
1600 AC_WIRESHARK_POP_FLAGS
1605 # AC_WIRESHARK_GCC_SYSTEM_INCLUDE
1607 # Replace -I include flag for -isystem in FLAGS argument
1609 AC_DEFUN([AC_WIRESHARK_GCC_SYSTEM_INCLUDE],
1611 if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
1613 | sed -e 's/ *-I *\// -isystem\//g' -e 's/^ *//'`
1618 # PKG_WIRESHARK_CHECK_SYSTEM_MODULES
1620 AC_DEFUN([PKG_WIRESHARK_CHECK_SYSTEM_MODULES],
1622 PKG_CHECK_MODULES($@)
1623 AC_WIRESHARK_GCC_SYSTEM_INCLUDE($1_CFLAGS)
1626 # Based on AM_PATH_GTK in gtk-2.0.m4.
1628 dnl AC_WIRESHARK_QT_MODULE_CHECK_WITH_QT_VERSION([MODULE, MINIMUM-VERSION,
1629 dnl REQUESTED-MAJOR_VERSION, [ACTION-IF-FOUND, [ACTION-IF-NOT-FOUND]]])
1630 dnl Test for a particular Qt module, for a particular Qt major version,
1631 dnl and, if we find it add the flags and libraries for it to Qt_CFLAGS
1634 AC_DEFUN([AC_WIRESHARK_QT_MODULE_CHECK_WITH_QT_VERSION],
1644 # Version of the module we're checking for.
1647 min_qt_version=ifelse([$2], ,4.0.0,$2)
1656 # Version of the module we're checking for.
1659 min_qt_version=5.0.0
1663 AC_MSG_ERROR([Qt version $3 is not a known Qt version])
1667 pkg_config_module="${modprefix}$1"
1668 AC_MSG_CHECKING(for $pkg_config_module - version >= $min_qt_version)
1669 if $PKG_CONFIG --atleast-version $min_qt_version $pkg_config_module; then
1670 mod_version=`$PKG_CONFIG --modversion $pkg_config_module`
1671 AC_MSG_RESULT(yes (version $mod_version))
1672 mod_cflags=`$PKG_CONFIG --cflags $pkg_config_module`
1673 AC_WIRESHARK_GCC_SYSTEM_INCLUDE(mod_cflags)
1674 Qt_CFLAGS="$Qt_CFLAGS $mod_cflags"
1675 Qt_LIBS="$Qt_LIBS `$PKG_CONFIG --libs $pkg_config_module`"
1676 # Run Action-If-Found
1677 ifelse([$4], , :, [$4])
1680 # Run Action-If-Not-Found
1681 ifelse([$5], , :, [$5])
1685 dnl AC_WIRESHARK_QT_MODULE_CHECK([MODULE, MINIMUM-VERSION,
1686 dnl REQUESTED-MAJOR_VERSION, [ACTION-IF-FOUND, [ACTION-IF-NOT-FOUND]]])
1687 dnl Test for a particular Qt module and add the flags and libraries
1688 dnl for it to Qt_CFLAGS and Qt_LIBS.
1690 AC_DEFUN([AC_WIRESHARK_QT_MODULE_CHECK],
1693 # Prior to Qt 5, modules were named QtXXX.
1694 # In Qt 5, they're named Qt5XXX.
1695 # This will need to change to handle future major Qt releases.
1701 # Check for all versions of Qt we support.
1702 # Try the Qt 5 version first.
1722 AC_MSG_ERROR([Qt version $3 is not a known Qt version])
1726 for version in $versions
1728 AC_WIRESHARK_QT_MODULE_CHECK_WITH_QT_VERSION($1, $2,
1729 $version, [foundit=yes], [foundit=no])
1730 if test "x$foundit" = "xyes"; then
1735 if test "x$foundit" = "xyes"; then
1736 # Remember which version of Qt we found
1738 # Run Action-If-Found
1739 ifelse([$4], , :, [$4])
1741 # Run Action-If-Not-Found
1742 ifelse([$5], , :, [$5])
1746 AC_DEFUN([AC_WIRESHARK_QT_ADD_PIC_IF_NEEDED],
1749 AC_WIRESHARK_PUSH_FLAGS
1750 CPPFLAGS="$CPPFLAGS $Qt_CFLAGS"
1751 AC_MSG_CHECKING([whether Qt works without -fPIC])
1753 [AC_LANG_SOURCE([[#include <QtCore>]])],
1754 [AC_MSG_RESULT(yes)],
1757 AC_MSG_CHECKING([whether Qt works with -fPIC])
1758 CPPFLAGS="$CPPFLAGS -fPIC"
1760 [AC_LANG_SOURCE([[#include <QtCore>]])],
1763 Qt_CFLAGS="$Qt_CFLAGS -fPIC"
1767 AC_MSG_ERROR(Couldn't compile Qt without -fPIC nor with -fPIC)
1770 AC_WIRESHARK_POP_FLAGS
1774 dnl AC_WIRESHARK_QT_CHECK([MINIMUM-VERSION, REQUESTED-MAJOR_VERSION,
1775 dnl [ACTION-IF-FOUND, [ACTION-IF-NOT-FOUND]]])
1776 dnl Test for Qt and define Qt_CFLAGS and Qt_LIBS.
1778 AC_DEFUN([AC_WIRESHARK_QT_CHECK],
1780 qt_version_to_check="$2"
1783 # Check for the Core module; if we don't have that,
1784 # we don't have Qt. If we *do* have it, we know what
1785 # version it is, so only check for that version of
1788 AC_WIRESHARK_QT_MODULE_CHECK(Core, $1, $qt_version_to_check,
1790 qt_version_to_check=$qt_version
1791 QT_VERSION=$mod_version
1792 QT_VERSION_MAJOR=`echo "$QT_VERSION" | cut -f1 -d.`
1793 QT_VERSION_MINOR=`echo "$QT_VERSION" | cut -f2 -d.`
1794 QT_VERSION_MICRO=`echo "$QT_VERSION" | cut -f3 -d.`
1796 # Qt 5.7 and later requires C++11
1797 AS_IF([test $QT_VERSION_MAJOR -eq 5 -a $QT_VERSION_MINOR -ge 7],
1798 [AS_IF([test "$HAVE_CXX11" -eq 0], [AC_MSG_ERROR([Qt 5.7 and later requires C++11])])])
1803 if test x"$no_qt" = x ; then
1805 # We need the Gui module as well.
1807 AC_WIRESHARK_QT_MODULE_CHECK(Gui, $1, $qt_version_to_check, ,
1811 if test x"$no_qt" = x ; then
1813 # Qt 5.0 appears to move the widgets out of Qt GUI
1814 # to Qt Widgets; look for the Widgets module, but
1815 # don't fail if we don't have it.
1817 AC_WIRESHARK_QT_MODULE_CHECK(Widgets, $1, $qt_version_to_check)
1820 # Qt 5.0 also appears to move the printing support into
1821 # the Qt PrintSupport module.
1823 AC_WIRESHARK_QT_MODULE_CHECK(PrintSupport, $1, $qt_version_to_check)
1826 # Qt 5.0 added multimedia in the Qt
1827 # Multimedia module.
1829 have_qt_multimedia_lib=no
1830 AC_WIRESHARK_QT_MODULE_CHECK(Multimedia, $1, $qt_version_to_check,
1831 have_qt_multimedia_lib=yes
1832 AC_DEFINE(QT_MULTIMEDIA_LIB, 1, [Define if we have QtMultimedia]))
1835 # While we're at it, look for QtMacExtras. (Presumably
1836 # if we're not building for macOS, it won't be present.)
1838 # XXX - is there anything in QtX11Extras or QtWinExtras
1839 # that we should be using?
1841 AC_WIRESHARK_QT_MODULE_CHECK(MacExtras, $1, $qt_version_to_check,
1842 AC_DEFINE(QT_MACEXTRAS_LIB, 1, [Define if we have QtMacExtras]))
1844 AC_WIRESHARK_QT_ADD_PIC_IF_NEEDED
1846 # Run Action-If-Found
1847 ifelse([$3], , :, [$3])
1849 # Run Action-If-Not-Found
1850 ifelse([$4], , :, [$4])
1855 dnl AC_WIRESHARK_QT_TOOL_CHECK([TOOLPATHVAR, TOOL, REQUESTED-MAJOR_VERSION])
1856 dnl Test for a particular Qt tool for some specific version of Qt
1858 AC_DEFUN([AC_WIRESHARK_QT_TOOL_CHECK],
1861 # At least in some versions of Debian/Ubuntu, and perhaps
1862 # other OSes, the Qt build tools are just links to a
1863 # program called "qtchooser", and even if you want to
1864 # build with Qt 5, running the tool might give you the
1865 # Qt 4 version of the tool unless you run the tool with
1868 # So we look for qtchooser and, if we find it, use the
1869 # -qt={version} argument, otherwise we look for particular
1870 # tool versions using tool name suffixes.
1872 AC_PATH_PROG(QTCHOOSER, qtchooser)
1873 if test ! -z "$QTCHOOSER"; then
1875 # We found qtchooser; we assume that means that
1876 # the tool is linked to qtchooser, so that we
1877 # can run it with the -qt={version} flag to get
1878 # the appropriate version of the tool.
1880 AC_PATH_PROG($1, $2)
1881 if test "x$$1" = x; then
1883 # We can't build Qt Wireshark without that
1886 AC_MSG_ERROR(I couldn't find $2; make sure it's installed and in your path)
1890 # Add the -qt={version} argument to it.
1892 $1="$$1 -qt=$qt_version"
1895 # Annoyingly, on some Linux distros (e.g. Debian)
1896 # the Qt 5 tools have no suffix and the Qt 4 tools
1897 # have suffix -qt4. On other distros (e.g. openSUSE)
1898 # the Qt 5 tools have suffix -qt5 and the Qt 4 tools
1901 # So we check for the tool first with the -qtN suffix
1902 # and then with no suffix.
1904 AC_PATH_PROGS($1, [$2-qt$qt_version $2])
1905 if test "x$$1" = x; then
1907 # We can't build Qt Wireshark without that
1910 AC_MSG_ERROR(I couldn't find $2-qt$qt_version or $2; make sure it's installed and in your path)
1915 AC_DEFUN([AC_WIRESHARK_QT_TOOL_CHECK_LRELEASE],
1917 AC_WIRESHARK_QT_TOOL_CHECK(LRELEASE, lrelease, $2)
1918 AC_MSG_CHECKING(whether lrelease -version works)
1919 lrelease_version=`$LRELEASE -version 2>&AS_MESSAGE_LOG_FD`
1920 AS_IF([test $? -ne 0],
1923 AC_MSG_ERROR([$LRELEASE -version returned non-zero exit status])
1925 AC_MSG_RESULT([ok, $lrelease_version])
1929 # AC_WIRESHARK_LZ4_CHECK
1931 AC_DEFUN([AC_WIRESHARK_LZ4_CHECK],
1933 AC_WIRESHARK_PUSH_FLAGS
1935 if test "x$lz4_dir" != "x"
1938 # The user specified a directory in which lz4 resides,
1939 # so add the "include" subdirectory of that directory to
1940 # the include file search path and the "lib" subdirectory
1941 # of that directory to the library search path.
1943 # XXX - if there's also a lz4 in a directory that's
1944 # already in CPPFLAGS or LDFLAGS, this won't make us find
1945 # the version in the specified directory, as the compiler
1946 # and/or linker will search that other directory before it
1947 # searches the specified directory.
1949 LZ4_CFLAGS="-I$lz4_dir/include"
1953 # Make sure we have "lz4.h". If we don't, it means we probably
1954 # don't have lz4, so don't use it.
1956 AC_CHECK_HEADER(lz4.h,,
1958 if test "x$lz4_dir" != "x"
1961 # The user used "--with-lz4=" to specify a directory
1962 # containing lz4, but we didn't find the header file
1963 # there; that either means they didn't specify the
1964 # right directory or are confused about whether lz4
1965 # is, in fact, installed. Report the error and give up.
1967 AC_MSG_ERROR([lz4 header not found in directory specified in --with-lz4])
1969 if test "x$want_lz4" = "xyes"
1972 # The user tried to force us to use the library, but we
1973 # couldn't find the header file; report an error.
1975 AC_MSG_ERROR(Header file lz4.h not found.)
1978 # We couldn't find the header file; don't use the
1979 # library, as it's probably not present.
1986 if test "x$want_lz4" != "xno"
1989 # Well, we at least have the lz4 header file.
1990 # We link with lz4 to support uncompression of
1994 ac_save_LIBS="$LIBS"
1995 LIBS="$LZ4_LIBS $LIBS"
1996 AC_DEFINE(HAVE_LZ4, 1, [Define to use lz4 library])
1998 # Check for "LZ4_decompress_safe()" in lz4, which we need
1999 # in order to read compressed capture files.
2001 AC_CHECK_FUNCS(LZ4_decompress_safe)
2002 LIBS="$ac_save_LIBS"
2005 AC_WIRESHARK_POP_FLAGS
2009 # AC_WIRESHARK_SNAPPY_CHECK
2011 AC_DEFUN([AC_WIRESHARK_SNAPPY_CHECK],
2013 AC_WIRESHARK_PUSH_FLAGS
2015 if test "x$snappy_dir" != "x"
2018 # The user specified a directory in which snappy resides,
2019 # so add the "include" subdirectory of that directory to
2020 # the include file search path and the "lib" subdirectory
2021 # of that directory to the library search path.
2023 # XXX - if there's also a snappy in a directory that's
2024 # already in CPPFLAGS or LDFLAGS, this won't make us find
2025 # the version in the specified directory, as the compiler
2026 # and/or linker will search that other directory before it
2027 # searches the specified directory.
2029 SNAPPY_CFLAGS="-I$snappy_dir/include"
2033 # Make sure we have "snappy-c.h". If we don't, it means we probably
2034 # don't have snappy, so don't use it.
2036 AC_CHECK_HEADER(snappy-c.h,,
2038 if test "x$snappy_dir" != "x"
2041 # The user used "--with-snappy=" to specify a directory
2042 # containing snappy, but we didn't find the header file
2043 # there; that either means they didn't specify the
2044 # right directory or are confused about whether snappy
2045 # is, in fact, installed. Report the error and give up.
2047 AC_MSG_ERROR([snappy-c.header not found in directory specified in --with-snappy])
2049 if test "x$want_snappy" = "xyes"
2052 # The user tried to force us to use the library, but we
2053 # couldn't find the header file; report an error.
2055 AC_MSG_ERROR(Header file snappy-c.h not found.)
2058 # We couldn't find the header file; don't use the
2059 # library, as it's probably not present.
2066 if test "x$want_snappy" != "xno"
2069 # Well, we at least have the snappy-c.header file.
2070 # We link with snappy to support uncompression of
2071 # compressed CQL traffic.
2073 SNAPPY_LIBS=-lsnappy
2074 ac_save_LIBS="$LIBS"
2075 LIBS="$SNAPPY_LIBS $LIBS"
2076 AC_DEFINE(HAVE_SNAPPY, 1, [Define to use snappy library])
2078 # Check for "snappy_uncompress()" in snappy, which we need
2079 # in order to read compressed capture files.
2081 AC_CHECK_FUNCS(snappy_uncompress)
2082 LIBS="$ac_save_LIBS"
2085 AC_WIRESHARK_POP_FLAGS