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 SPDX-License-Identifier: GPL-2.0-or-later
7 dnl As a special exception, the Free Software Foundation gives unlimited
8 dnl permission to copy, distribute and modify the configure scripts that
9 dnl are the output of Autoconf. You need not follow the terms of the GNU
10 dnl General Public License when using or distributing such scripts, even
11 dnl though portions of the text of Autoconf appear in them. The GNU
12 dnl General Public License (GPL) does govern all other use of the material
13 dnl that constitutes the Autoconf program.
15 dnl Certain portions of the Autoconf source text are designed to be copied
16 dnl (in certain cases, depending on the input) into the output of
17 dnl Autoconf. We call these the "data" portions. The rest of the Autoconf
18 dnl source text consists of comments plus executable code that decides which
19 dnl of the data portions to output in any given case. We call these
20 dnl comments and executable code the "non-data" portions. Autoconf never
21 dnl copies any of the non-data portions into its output.
23 dnl This special exception to the GPL applies to versions of Autoconf
24 dnl released by the Free Software Foundation. When you make and
25 dnl distribute a modified version of Autoconf, you may extend this special
26 dnl exception to the GPL to apply to your modified version as well, *unless*
27 dnl your modified version has the potential to copy into its output some
28 dnl of the text that was the non-data portion of the version that you started
29 dnl with. (In other words, unless your change moves or copies text from
30 dnl the non-data portions to the data portions.) If your modification has
31 dnl such potential, you must delete any notice of this special exception
32 dnl to the GPL from your modified version.
34 dnl Written by David MacKenzie, with help from
35 dnl Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
36 dnl Roland McGrath, Noah Friedman, david d zuhn, and many others.
39 # AC_WIRESHARK_ADD_DASH_L
41 # Add to the variable specified as the first argument a "-L" flag for the
42 # directory specified as the second argument, and, on Solaris, add a
43 # "-R" flag for it as well.
45 # XXX - IRIX, and other OSes, may require some flag equivalent to
48 AC_DEFUN([AC_WIRESHARK_ADD_DASH_L],
49 [AX_APPEND_FLAG(-L$2, $1)
52 AX_APPEND_FLAG(-R$2, $1)
58 # AC_WIRESHARK_PUSH_FLAGS
60 # Push our flags to CFLAGS/etc.
62 AC_DEFUN([AC_WIRESHARK_PUSH_FLAGS],
64 ac_ws_CPPLAGS_saved="$CPPFLAGS"
65 ac_ws_CFLAGS_saved="$CFLAGS"
66 ac_ws_CXXFLAGS_saved="$CXXFLAGS"
67 ac_ws_LDFLAGS_saved="$LDFLAGS"
68 CPPFLAGS="$WS_CPPFLAGS $CPPFLAGS"
69 CFLAGS="$WS_CFLAGS $CFLAGS"
70 CXXFLAGS="$WS_CXXFLAGS $CXXFLAGS"
71 LDFLAGS="$WS_LDFLAGS $LDFLAGS"
75 # AC_WIRESHARK_POP_FLAGS
77 # Restore user build flags.
79 AC_DEFUN([AC_WIRESHARK_POP_FLAGS],
81 CPPFLAGS="$ac_ws_CPPLAGS_saved"
82 CFLAGS="$ac_ws_CFLAGS_saved"
83 CXXFLAGS="$ac_ws_CXXFLAGS_saved"
84 LDFLAGS="$ac_ws_LDFLAGS_saved"
89 # AC_WIRESHARK_BREAKLOOP_TRY_LINK
91 AC_DEFUN([AC_WIRESHARK_PCAP_BREAKLOOP_TRY_LINK],
107 ws_breakloop_compiled=yes
110 ws_breakloop_compiled=no
117 # AC_WIRESHARK_PCAP_CHECK
119 AC_DEFUN([AC_WIRESHARK_PCAP_CHECK],
121 AC_WIRESHARK_PUSH_FLAGS
122 ws_ac_save_LIBS="$LIBS"
124 if test -z "$pcap_dir"
127 # XXX need to set a var AC_CHECK_HEADER(pcap.h,,)
130 # The user didn't specify a directory in which libpcap resides.
131 # First, look for a pcap-config script.
133 AC_PATH_TOOL(PCAP_CONFIG, pcap-config)
135 if test -n "$PCAP_CONFIG" ; then
139 # Now check whether it's the libpcap 1.0 version, which
140 # put a space after "-L" - on some platforms, that doesn't
143 AC_MSG_CHECKING(for broken pcap-config)
144 case "`\"$PCAP_CONFIG\" --libs`" in
148 # Space after -L. Pretend pcap-config doesn't exist.
162 if test -n "$PCAP_CONFIG" ; then
164 # Found it, and it's usable; use it to get the include flags
167 PCAP_CFLAGS="`\"$PCAP_CONFIG\" --cflags`"
169 # We have pcap-config; we assume that means we have libpcap
170 # installed and that pcap-config will tell us whatever
171 # libraries libpcap needs.
173 if test x$enable_static = xyes; then
174 PCAP_LIBS="`\"$PCAP_CONFIG\" --libs --static`"
176 PCAP_LIBS="`\"$PCAP_CONFIG\" --libs`"
180 # Didn't find it; we have to look for libpcap ourselves.
181 # We assume that the current library search path will work,
182 # but we may have to look for the header in a "pcap"
183 # subdirectory of "/usr/include" or "/usr/local/include",
184 # as some systems apparently put "pcap.h" in a "pcap"
185 # subdirectory without also providing a "pcap.h" in the top-level
186 # include directory, and we also check "$prefix/include" - and
187 # "$prefix/include/pcap", in case $prefix is set to
188 # "/usr/include" or "/usr/local/include".
193 AC_MSG_CHECKING(for extraneous pcap header directories)
195 pcap_dir_list="/usr/local/include/pcap /usr/include/pcap $prefix/include/pcap $prefix/include"
196 for pcap_dir in $pcap_dir_list
198 if test -d $pcap_dir ; then
199 if test x$pcap_dir != x/usr/include -a x$pcap_dir != x/usr/local/include ; then
200 PCAP_CFLAGS="-I$pcap_dir"
202 found_pcap_dir=" $found_pcap_dir -I$pcap_dir"
207 if test "$found_pcap_dir" != "" ; then
208 AC_MSG_RESULT(found --$found_pcap_dir added to CFLAGS)
210 AC_MSG_RESULT(not found)
215 # The user specified a directory in which libpcap resides,
216 # so add the "include" subdirectory of that directory to
217 # the include file search path and the "lib" subdirectory
218 # of that directory to the library search path.
220 # XXX - if there's also a libpcap in a directory that's
221 # already in CPPFLAGS or LDFLAGS, this won't make us find
222 # the version in the specified directory, as the compiler
223 # and/or linker will search that other directory before it
224 # searches the specified directory.
226 PCAP_CFLAGS="-I$pcap_dir/include"
228 # XXX - This doesn't use AC_WIRESHARK_ADD_DASH_L
230 PCAP_LIBS="-L$pcap_dir/lib -lpcap"
233 CFLAGS="$PCAP_CFLAGS $CFLAGS"
234 LIBS="$PCAP_LIBS $LIBS"
237 AC_CHECK_HEADER(pcap.h,
239 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library])
242 AC_MSG_ERROR([[Header file pcap.h not found; if you installed libpcap
243 from source, did you also do \"make install-incl\", and if you installed a
244 binary package of libpcap, is there also a developer's package of libpcap,
245 and did you also install that package?]])
249 # Check to see if we find "pcap_open_live" in "-lpcap".
250 # Also check for various additional libraries that libpcap might
253 AC_CHECK_LIB(pcap, pcap_open_live,
257 ac_wireshark_extras_found=no
259 for extras in "-lcfg -lodm" "-lpfring"
261 AC_MSG_CHECKING([for pcap_open_live in -lpcap with $extras])
262 LIBS="-lpcap $extras $ac_save_LIBS"
264 # XXX - can't we use AC_CHECK_LIB here?
271 pcap_open_live(NULL, 0, 0, 0, NULL);
274 ac_wireshark_extras_found=yes
276 PCAP_LIBS="$PCAP_LIBS $extras"
281 if test x$ac_wireshark_extras_found = xyes
286 if test x$ac_wireshark_extras_found = xno
288 AC_MSG_ERROR([Can't link with library libpcap.])
292 AC_SUBST(PCAP_CFLAGS)
296 # Check whether various variables and functions are defined by
299 AC_CHECK_FUNCS(pcap_open_dead pcap_freecode)
300 AC_CHECK_FUNCS(pcap_open)
301 if test $ac_cv_func_pcap_open = "yes" ; then
302 AC_DEFINE(HAVE_PCAP_REMOTE, 1,
303 [Define to 1 if you have libpcap/WinPcap remote capturing support])
306 # XXX - this *should* be checked for independently of checking
307 # for pcap_open(), as you might have pcap_setsampling() without
308 # remote capture support.
310 # However, 1) the sampling options are treated as remote options
311 # in the GUI and and 2) having pcap_setsampling() doesn't mean
312 # you have sampling support. libpcap needs a way to indicate
313 # whether a given device supports sampling, and the GUI should
314 # be changed to decouple them.
316 # (Actually, libpcap needs a general mechanism to offer options
317 # for particular devices, and Wireshark needs to use that
318 # mechanism. The former is a work in progress.)
320 # (Note: another work in progress is support for remote
321 # capturing using pcap_create()/pcap_activate(), which we
322 # also need to support once it's available.)
324 AC_CHECK_FUNCS(pcap_setsampling)
328 # pcap_breakloop may be present in the library but not declared
329 # in the pcap.h header file. If it's not declared in the header
330 # file, attempts to use it will get warnings, and, if we're
331 # building with warnings treated as errors, that warning will
332 # cause compilation to fail.
334 # We are therefore first testing whether the function is present
335 # and then, if we're compiling with warnings as errors, testing
336 # whether it is usable. It is usable if it compiles without
337 # a -Wimplicit warning (the "compile with warnings as errors"
338 # option requires GCC). If it is not usable, we fail and tell
339 # the user that the pcap.h header needs to be updated.
341 # Ceteris paribus, this should only happen with Mac OS X 10.3[.x] which
342 # can have an up-to-date pcap library without the corresponding pcap
345 # However, it might also happen on some others OSes with some erroneous
346 # system manipulations where multiple versions of libpcap might co-exist
347 # e.g. hand made symbolic link from libpcap.so -> libpcap.so.0.8 but
348 # having the pcap header version 0.7.
350 AC_MSG_CHECKING([whether pcap_breakloop is present])
351 ac_CFLAGS_saved="$CFLAGS"
352 AC_WIRESHARK_PCAP_BREAKLOOP_TRY_LINK
353 if test "x$ws_breakloop_compiled" = "xyes"; then
355 AC_DEFINE(HAVE_PCAP_BREAKLOOP, 1, [Define if pcap_breakloop is known])
356 if test "x$with_warnings_as_errors" = "xyes"; then
357 AC_MSG_CHECKING([whether pcap_breakloop is usable])
358 CFLAGS="$CFLAGS -Werror -Wimplicit"
359 AC_WIRESHARK_PCAP_BREAKLOOP_TRY_LINK
360 if test "x$ws_breakloop_compiled" = "xyes"; then
365 [Your pcap library is more recent than your pcap header.
366 As you are building with compiler warnings treated as errors, Wireshark
367 won't be able to use functions not declared in that header.
368 If you wish to build with compiler warnings treated as errors, You should
369 install a newer version of the header file.])
371 CFLAGS="$ac_CFLAGS_saved"
378 # Later versions of Mac OS X 10.3[.x] ship a pcap.h that
379 # doesn't define pcap_if_t but ship an 0.8[.x] libpcap,
380 # so the library has "pcap_findalldevs()", but pcap.h
381 # doesn't define "pcap_if_t" so you can't actually *use*
382 # "pcap_findalldevs()".
384 # That even appears to be true of systems shipped with
385 # 10.3.4, so it doesn't appear only to be a case of
386 # Software Update not updating header files.
388 # (You can work around this by installing the 0.8 header
391 AC_CACHE_CHECK([whether pcap_findalldevs is present and usable],
392 [ac_cv_func_pcap_findalldevs],
401 pcap_if_t *devpointer;
404 pcap_findalldevs(&devpointer, errbuf);
409 ac_cv_func_pcap_findalldevs=yes
412 ac_cv_func_pcap_findalldevs=no
416 # Don't check for other new routines that showed up after
417 # "pcap_findalldevs()" if we don't have a usable
418 # "pcap_findalldevs()", so we don't end up using them if the
419 # "pcap.h" is crufty and old and doesn't declare them.
421 if test $ac_cv_func_pcap_findalldevs = "yes" ; then
422 AC_DEFINE(HAVE_PCAP_FINDALLDEVS, 1,
423 [Define to 1 if you have the `pcap_findalldevs' function and a pcap.h that declares pcap_if_t.])
424 AC_CHECK_FUNCS(pcap_datalink_val_to_name pcap_datalink_name_to_val)
425 AC_CHECK_FUNCS(pcap_datalink_val_to_description)
426 AC_CHECK_FUNCS(pcap_list_datalinks pcap_set_datalink pcap_lib_version)
427 AC_CHECK_FUNCS(pcap_get_selectable_fd pcap_free_datalinks)
428 AC_CHECK_FUNC(pcap_create,
430 AC_DEFINE(HAVE_PCAP_CREATE, 1,
431 [Define to 1 if you have the `pcap_create' function.])
432 AC_DEFINE(CAN_SET_CAPTURE_BUFFER_SIZE, 1,
433 [Define to 1 if the capture buffer size can be set.])
435 AC_CHECK_FUNCS(bpf_image pcap_set_tstamp_precision pcap_set_tstamp_type)
438 AC_WIRESHARK_POP_FLAGS
439 LIBS="$ws_ac_save_LIBS"
443 # AC_WIRESHARK_ZLIB_CHECK
445 AC_DEFUN([AC_WIRESHARK_ZLIB_CHECK],
447 AC_WIRESHARK_PUSH_FLAGS
449 if test "x$zlib_dir" != "x"
452 # The user specified a directory in which zlib resides,
453 # so add the "include" subdirectory of that directory to
454 # the include file search path and the "lib" subdirectory
455 # of that directory to the library search path.
457 # XXX - if there's also a zlib in a directory that's
458 # already in CPPFLAGS or LDFLAGS, this won't make us find
459 # the version in the specified directory, as the compiler
460 # and/or linker will search that other directory before it
461 # searches the specified directory.
463 CPPFLAGS="$CPPFLAGS -I$zlib_dir/include"
464 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, $zlib_dir/lib)
468 # Make sure we have "zlib.h". If we don't, it means we probably
469 # don't have zlib, so don't use it.
471 AC_CHECK_HEADER(zlib.h,,
473 if test "x$zlib_dir" != "x"
476 # The user used "--with-zlib=" to specify a directory
477 # containing zlib, but we didn't find the header file
478 # there; that either means they didn't specify the
479 # right directory or are confused about whether zlib
480 # is, in fact, installed. Report the error and give up.
482 AC_MSG_ERROR([zlib header not found in directory specified in --with-zlib])
484 if test "x$want_zlib" = "xyes"
487 # The user tried to force us to use the library, but we
488 # couldn't find the header file; report an error.
490 AC_MSG_ERROR(Header file zlib.h not found.)
493 # We couldn't find the header file; don't use the
494 # library, as it's probably not present.
501 if test "x$want_zlib" != "xno"
504 # Well, we at least have the zlib header file.
506 # We link with zlib to support uncompression of
507 # gzipped network traffic, e.g. in an HTTP request
510 # Check for inflate() in zlib, to make sure the
511 # zlib library is usable. For example, on at
512 # least some versions of Fedora, if you have a
513 # 64-bit machine, have both the 32-bit and 64-bit
514 # versions of the run-time zlib package installed,
515 # and have only the *32-bit* version of the zlib
516 # development package installed, it'll find the
517 # header, and think it can use zlib, and will use
518 # it in subsequent tests, but it'll try and link
519 # 64-bit test programs with the 32-bit library,
520 # causing those tests to falsely fail. Hilarity
523 if test "x$zlib_dir" != "x"
525 WS_CPPFLAGS="$WS_CPPFLAGS -I$zlib_dir/include"
526 AC_WIRESHARK_ADD_DASH_L(WS_LDFLAGS, $zlib_dir/lib)
528 AC_DEFINE(HAVE_ZLIB, 1, [Define to use zlib library])
530 # Check for "inflate()" in zlib to make sure we can
533 AC_CHECK_LIB(z, inflate,,
534 AC_MSG_ERROR([zlib.h found but linking with -lz failed to find inflate(); do you have the right developer package installed (32-bit vs. 64-bit)?]))
537 # Check for "inflatePrime()" in zlib, which we need
538 # in order to read compressed capture files.
540 AC_CHECK_FUNCS(inflatePrime)
542 if test "x$ac_cv_func_inflatePrime" = "xyes" ; then
544 # Now check for "inflatePrime()" in zlib when
545 # linking with the linker flags for GTK+
546 # applications; people often grab XFree86 source
547 # and build and install it on their systems,
548 # and they appear sometimes to misconfigure
549 # XFree86 so that, even on systems with zlib,
550 # it assumes there is no zlib, so the XFree86
551 # build process builds and installs its
552 # own zlib in the X11 library directory.
554 # The zlib in at least some versions of XFree86
555 # is an older version that may lack "inflatePrime()",
556 # and that's the zlib with which Wireshark gets
557 # linked, so the build of Wireshark fails.
559 AC_MSG_CHECKING([for inflatePrime missing when linking with X11])
560 AC_TRY_LINK_FUNC(inflatePrime, AC_MSG_RESULT(no),
563 AC_MSG_ERROR(old zlib found when linking with X11 - get rid of old zlib.)
568 AC_WIRESHARK_POP_FLAGS
572 # AC_WIRESHARK_LIBLUA_CHECK
574 # Sets $have_lua to yes or no.
575 # If it's yes, it also sets $LUA_CFLAGS and $LUA_LIBS.
576 AC_DEFUN([AC_WIRESHARK_LIBLUA_CHECK],[
578 AC_WIRESHARK_PUSH_FLAGS
580 if test "x$want_lua_dir" = "x"
582 # The user didn't tell us where to find Lua. Let's go look for it.
584 # First, try the standard (pkg-config) way.
585 # Unfortunately Lua's pkg-config file isn't standardly named.
586 # Some distributions allow installation of multiple versions of
587 # Lua at the same time. On such systems each version has its
590 # We use a for loop instead of giving all the package names to
591 # PKG_CHECK_MODULES because doing the latter doesn't appear to
592 # work reliably (some package names are not searched for).
593 for pkg in "lua < 5.3" lua5.2 lua-5.2 lua52 lua5.1 lua-5.1 lua51 lua5.0 lua-5.0 lua50
595 AC_MSG_CHECKING(if you have $pkg)
596 PKG_CHECK_EXISTS($pkg,
605 if test "x$have_lua" = "xyes"
607 PKG_WIRESHARK_CHECK_SYSTEM_MODULES(LUA, $pkg)
608 CPPFLAGS="$LUA_CFLAGS $CPPFLAGS"
609 AC_CHECK_HEADERS(lua.h lualib.h lauxlib.h)
615 if test "x$have_lua" != "xyes"
617 # We don't have pkg-config or the user specified the path to
618 # Lua (in $want_lua_dir).
619 # Let's look for the header file.
621 AC_MSG_CHECKING(for the location of lua.h)
622 if test "x$want_lua_dir" = "x"
624 # The user didn't tell us where to look so we'll look in some
625 # standard locations.
626 want_lua_dir="/usr/local /usr $prefix"
628 for dir in $want_lua_dir
630 if test -r "$dir/include/lua.h"
632 header_dir="$dir/include"
637 for ver in 5.2 52 5.1 51 5.0 50
639 if test -r "$dir/include/lua$ver/lua.h"
641 header_dir="$dir/include/lua$ver"
648 if test "x$header_dir" = "x"
651 AC_MSG_RESULT(not found)
653 AC_MSG_RESULT($header_dir)
655 AC_MSG_CHECKING(the Lua version)
656 lua_ver=`$AWK AS_ESCAPE('/LUA_VERSION_NUM/ { print $NF; }' $header_dir/lua.h | sed 's/0/./')`
658 if test "x$lua_ver" = "x5.3"
660 # Wireshark doesn't compile with Lua 5.3 today
661 AC_MSG_RESULT($lua_ver - disabling Lua support)
664 AC_MSG_RESULT($lua_ver)
666 CPPFLAGS="$CPPFLAGS -I$header_dir"
667 AC_CHECK_HEADERS(lua.h lualib.h lauxlib.h, ,
673 if test "x$have_lua" = "x"
676 LUA_CFLAGS="-I$header_dir"
678 # We have the header files and they work. Now let's check if we
679 # have the library and it works.
681 # XXX - if there's also a liblua in a directory that's
682 # already in CPPFLAGS or LDFLAGS, this won't make us find
683 # the version in the specified directory, as the compiler
684 # and/or linker will search that other directory before it
685 # searches the specified directory.
688 LDFLAGS="-L$lua_dir/lib $LDFLAGS"
689 AC_SEARCH_LIBS(luaL_openlibs, [lua-${lua_ver} lua${lua_ver} lua],
691 LUA_LIBS="-L$lua_dir/lib $ac_cv_search_luaL_openlibs -lm"
694 # Try again with -ldl
696 # Tell autoconf we don't want to use the cached result
697 unset ac_cv_search_luaL_openlibs
699 AC_SEARCH_LIBS(luaL_openlibs, [lua-${lua_ver} lua${lua_ver} lua],
701 LUA_LIBS="-L$lua_dir/lib $ac_cv_search_luaL_openlibs -lm -ldl"
711 AC_WIRESHARK_POP_FLAGS
715 # AC_WIRESHARK_C_ARES_CHECK
717 AC_DEFUN([AC_WIRESHARK_C_ARES_CHECK],
719 want_c_ares=defaultyes
721 if test "x$want_c_ares" = "xdefaultyes"; then
725 if test "x$want_c_ares" = "xyes"; then
726 AC_CHECK_LIB(cares, ares_init,
729 # Make sure we have c-ares 1.5 or later; we don't
730 # support the older API.
732 AC_MSG_CHECKING([whether we have c-ares 1.5 or later])
736 #include <ares_version.h>
739 #if ((ARES_VERSION_MAJOR < 1) || \
740 (1 == ARES_VERSION_MAJOR == 1 && ARES_VERSION_MINOR < 5))
749 AC_DEFINE(HAVE_C_ARES, 1, [Define to use c-ares library])
754 AC_MSG_ERROR([Pre-1.5 versions of c-ares aren't supported])
758 AC_MSG_RESULT(not required)
764 # AC_WIRESHARK_LIBCAP_CHECK
766 AC_DEFUN([AC_WIRESHARK_LIBCAP_CHECK],
768 want_libcap=defaultyes
770 if test "x$want_libcap" = "xdefaultyes"; then
774 if test "x$want_libcap" = "xyes"; then
775 AC_CHECK_LIB(cap, cap_set_flag,
778 AC_DEFINE(HAVE_LIBCAP, 1, [Define to use the libcap library])
783 AC_MSG_RESULT(not required)
789 # AC_WIRESHARK_KRB5_CHECK
791 AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
793 AC_WIRESHARK_PUSH_FLAGS
794 wireshark_save_LIBS="$LIBS"
796 if test "x$krb5_dir" != "x"
799 # The user specified a directory in which kerberos resides,
800 # so add the "include" subdirectory of that directory to
801 # the include file search path and the "lib" subdirectory
802 # of that directory to the library search path.
804 # XXX - if there's also a kerberos in a directory that's
805 # already in CPPFLAGS or LDFLAGS, this won't make us find
806 # the version in the specified directory, as the compiler
807 # and/or linker will search that other directory before it
808 # searches the specified directory.
810 KRB5_CFLAGS="-I$krb5_dir/include"
811 ac_heimdal_version=`grep heimdal $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*heimdal.*$/HEIMDAL/'`
812 # MIT Kerberos moved krb5.h to krb5/krb5.h starting with release 1.5
813 ac_mit_version_olddir=`grep 'Massachusetts' $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*Massachusetts.*$/MIT/'`
814 ac_mit_version_newdir=`grep 'Massachusetts' $krb5_dir/include/krb5/krb5.h | head -n 1 | sed 's/^.*Massachusetts.*$/MIT/'`
815 ac_krb5_version="$ac_heimdal_version$ac_mit_version_olddir$ac_mit_version_newdir"
816 if test "x$ac_krb5_version" = "xHEIMDAL"
818 KRB5_LIBS="-L$krb5_dir/lib -lkrb5 -lasn1 -lcrypto -lroken -lcrypt"
820 KRB5_LIBS="-L$krb5_dir/lib -lkrb5 -lk5crypto -lcom_err"
822 if test "x$ac_krb5_version" = "xMIT"
824 AC_DEFINE(HAVE_MIT_KERBEROS, 1, [Define to use MIT kerberos])
827 AC_PATH_TOOL(KRB5_CONFIG, krb5-config)
828 if test -x "$KRB5_CONFIG"
830 KRB5_CFLAGS=`"$KRB5_CONFIG" --cflags`
831 KRB5_LIBS=`"$KRB5_CONFIG" --libs`
832 ac_krb5_version=`"$KRB5_CONFIG" --version | head -n 1 | sed -e 's/^.*heimdal.*$/HEIMDAL/' -e 's/^Kerberos .*$/MIT/' -e 's/^Solaris Kerberos .*$/MIT/'`
836 # If -lcrypto is in KRB5_LIBS, we require it to build
837 # with Heimdal/MIT. We don't want to built with it by
838 # default, due to annoying license incompatibilities
839 # between the OpenSSL license and the GPL.
843 if test "x$with_krb5_crypto_openssl" != "xyes"
845 AC_MSG_ERROR([Kerberos library requires -lcrypto, so you must specify --with-krb5-crypto-openssl])
850 CPPFLAGS="$CPPFLAGS $KRB5_CFLAGS"
853 # Make sure we have "krb5.h". If we don't, it means we probably
854 # don't have kerberos, so don't use it.
856 AC_CHECK_HEADER(krb5.h,,
858 if test "x$krb5_dir" != "x"
861 # The user used "--with-krb5=" to specify a directory
862 # containing kerberos, but we didn't find the header file
863 # there; that either means they didn't specify the
864 # right directory or are confused about whether kerberos
865 # is, in fact, installed. Report the error and give up.
867 AC_MSG_ERROR([kerberos header not found in directory specified in --with-krb5])
869 if test "x$want_krb5" = "xyes"
872 # The user tried to force us to use the library, but we
873 # couldn't find the header file; report an error.
875 AC_MSG_ERROR(Header file krb5.h not found.)
878 # We couldn't find the header file; don't use the
879 # library, as it's probably not present.
884 AC_MSG_RESULT(No Heimdal or MIT header found - disabling dissection for some kerberos data in packet decoding)
889 if test "x$want_krb5" != "xno"
892 # Well, we at least have the krb5 header file.
893 # Check whether this is Heimdal or MIT.
895 AC_MSG_CHECKING(whether the Kerberos library is Heimdal or MIT)
896 if test "x$ac_krb5_version" = "xHEIMDAL" -o "x$ac_krb5_version" = "xMIT"
900 # Check whether we have krb5_kt_resolve - and whether
901 # we need to link with -lresolv when linking with
902 # the Kerberos library.
904 AC_MSG_RESULT($ac_krb5_version)
905 found_krb5_kt_resolve=no
906 for extras in "" "-lresolv"
908 LIBS="$KRB5_LIBS $extras $wireshark_save_LIBS"
911 AC_MSG_CHECKING([whether $ac_krb5_version includes krb5_kt_resolve])
913 AC_MSG_CHECKING([whether $ac_krb5_version includes krb5_kt_resolve (linking with $extras)])
920 krb5_kt_resolve(0, 0, 0);
924 # We found "krb5_kt_resolve()".
927 if test -n "$extras"; then
928 KRB5_LIBS="$KRB5_LIBS $extras"
930 AC_DEFINE(HAVE_KERBEROS, 1, [Define to use kerberos])
931 if test "x$ac_krb5_version" = "xHEIMDAL"
933 AC_DEFINE(HAVE_HEIMDAL_KERBEROS, 1, [Define to use heimdal kerberos])
934 elif test "x$ac_krb5_version" = "xMIT"
936 AC_DEFINE(HAVE_MIT_KERBEROS, 1, [Define to use MIT kerberos])
938 found_krb5_kt_resolve=yes
945 if test "$found_krb5_kt_resolve" = no
948 # We didn't find "krb5_kt_resolve()" in the
949 # Kerberos library, even when we tried linking
950 # with -lresolv; we can't link with kerberos.
952 if test "x$want_krb5" = "xyes"
955 # The user tried to force us to use the library,
956 # but we can't do so; report an error.
958 AC_MSG_ERROR(Usable $ac_krb5_version not found)
963 AC_MSG_RESULT(Usable $ac_krb5_version not found - disabling dissection for some kerberos data in packet decoding)
970 # We can link with Kerberos; see whether krb5.h
971 # defines KEYTYPE_ARCFOUR_56 (where "defines" means
972 # "as a #define or as an enum member).
974 AC_MSG_CHECKING([whether krb5.h defines KEYTYPE_ARCFOUR_56])
984 printf("%u\n", KEYTYPE_ARCFOUR_56);
990 AC_DEFINE(HAVE_KEYTYPE_ARCFOUR_56, 1, [Define if krb5.h defines KEYTYPE_ARCFOUR_56])
998 # It's not Heimdal or MIT.
1001 if test "x$want_krb5" = "xyes"
1004 # The user tried to force us to use the library,
1005 # but we can't do so; report an error.
1007 AC_MSG_ERROR(Kerberos not found)
1012 AC_MSG_RESULT(Kerberos not found - disabling dissection for some kerberos data in packet decoding)
1020 # The user asked us not to use Kerberos, or they didn't
1021 # say whether they wanted us to use it but we found
1028 AC_SUBST(KRB5_CFLAGS)
1031 LIBS="$wireshark_save_LIBS"
1032 AC_WIRESHARK_POP_FLAGS
1036 # AC_WIRESHARK_MAXMINDDB_CHECK
1038 AC_DEFUN([AC_WIRESHARK_MAXMINDDB_CHECK],
1040 want_maxminddb=defaultyes
1042 if test "x$want_maxminddb" = "xdefaultyes"; then
1046 if test "x$want_maxminddb" = "xyes"; then
1047 AC_CHECK_LIB(maxminddb, MMDB_open,
1049 MAXMINDDB_LIBS=-lmaxminddb
1050 AC_DEFINE(HAVE_MAXMINDDB, 1, [Define to use MaxMind DB library])
1051 have_good_maxminddb=yes
1055 AC_MSG_RESULT(not required)
1060 # AC_WIRESHARK_LIBSSH_CHECK
1062 AC_DEFUN([AC_WIRESHARK_LIBSSH_CHECK],
1064 want_libssh=defaultyes
1066 if test "x$want_libssh" = "xdefaultyes"; then
1070 if test "x$want_libssh" = "xyes"; then
1071 AC_CHECK_LIB(ssh, ssh_new,
1074 AC_DEFINE(HAVE_LIBSSH, 1, [Define to use libssh library])
1075 have_good_libssh=yes
1078 AC_MSG_CHECKING([whether libssh >= 0.6.0 for sshdump, ciscodump])
1079 PKG_CHECK_EXISTS([libssh >= 0.6.0],
1082 AC_DEFINE(HAVE_LIBSSH_POINTSIX, 1, [Defined if libssh >= 0.6.0])
1083 have_libssh_pointsix=yes
1087 if test "x$have_libssh_pointsix" = "xyes"; then
1088 # ssh_userauth_agent exists only >= 0.6.0, but not on Windows
1089 # so check explicitly
1090 AC_CHECK_LIB(ssh, ssh_userauth_agent,
1092 AC_DEFINE(HAVE_SSH_USERAUTH_AGENT, 1, [Libssh library has ssh_userauth_agent])
1093 have_ssh_userauth_agent=yes
1098 AC_MSG_RESULT(not required)
1103 # AC_WIRESHARK_NGHTTP2_CHECK
1105 AC_DEFUN([AC_WIRESHARK_NGHTTP2_CHECK],
1107 want_nghttp2=defaultyes
1109 if test "x$want_nghttp2" = "xdefaultyes"; then
1113 if test "x$want_nghttp2" = "xyes"; then
1114 AC_CHECK_LIB(nghttp2, nghttp2_hd_inflate_new,
1116 AC_CHECK_HEADERS(nghttp2/nghttp2.h,
1118 NGHTTP2_LIBS=-lnghttp2
1119 AC_DEFINE(HAVE_NGHTTP2, 1, [Define to use nghttp2 library])
1120 have_good_nghttp2=yes
1126 AC_MSG_RESULT(not required)
1130 #AC_WIRESHARK_LDFLAGS_CHECK
1132 # $1 : ldflag(s) to test
1134 # We attempt to compile and link a test program with the specified linker
1135 # flag. The defined flag is added to LDFLAGS only if the link succeeds.
1137 AC_DEFUN([AC_WIRESHARK_LDFLAGS_CHECK],
1139 AC_MSG_CHECKING(whether we can add $LD_OPTION to LDFLAGS)
1140 AC_WIRESHARK_PUSH_FLAGS
1141 LDFLAGS="$LDFLAGS $LD_OPTION"
1142 can_add_to_ldflags=""
1145 AC_LANG_SOURCE([[int main() { return 0; }]])
1149 AX_APPEND_FLAG([$LD_OPTION], [WS_LDFLAGS])
1150 can_add_to_ldflags=yes
1154 can_add_to_ldflags=no
1156 AC_WIRESHARK_POP_FLAGS
1160 dnl Check whether, if you pass an unknown warning option to the
1161 dnl compiler, it fails or just prints a warning message and succeeds.
1162 dnl Set ac_wireshark_unknown_warning_option_error to the appropriate flag
1163 dnl to force an error if it would otherwise just print a warning message
1166 AC_DEFUN([AC_WIRESHARK_CHECK_UNKNOWN_WARNING_OPTION_ERROR],
1168 AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option])
1169 AC_WIRESHARK_PUSH_FLAGS
1170 CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
1175 AC_MSG_RESULT([no, adding -Werror=unknown-warning-option])
1177 # We're assuming this is clang, where
1178 # -Werror=unknown-warning-option is the appropriate
1179 # option to force the compiler to fail.
1181 ac_wireshark_unknown_warning_option_error="-Werror=unknown-warning-option"
1184 AC_MSG_RESULT([yes])
1186 AC_WIRESHARK_POP_FLAGS
1190 dnl Check whether, if you pass a valid-for-C-but-not-C++ option to the
1191 dnl compiler, it fails or just prints a warning message and succeeds.
1192 dnl Set ac_wireshark_non_cxx_warning_option_error to the appropriate flag
1193 dnl to force an error if it would otherwise just print a warning message
1196 AC_DEFUN([AC_WIRESHARK_CHECK_NON_CXX_WARNING_OPTION_ERROR],
1198 AC_MSG_CHECKING([whether the compiler fails when given an warning option not supported for C++])
1200 # Some C+ compilers warn about -Wmissing-prototypes, and some warn
1201 # about -Wmissing-declarations. Check both.
1204 AC_WIRESHARK_PUSH_FLAGS
1205 save_CXXFLAGS="$CXXFLAGS"
1206 for flag in -Wmissing-prototypes -Wmissing-declarations; do
1207 CXXFLAGS="$save_CXXFLAGS $flag"
1213 # We're assuming this is g++, where -Werror is the
1214 # appropriate option to force the compiler to fail.
1215 # Check whether it fails with -Werror.
1217 # NOTE: it's important to put -Werror *before*
1218 # the flag, otherwise, when it sees the flag,
1219 # it doesn't yet know that warnings should be
1220 # treated as errors, and doesn't treat the
1221 # "that's C-only" warning as an error.
1223 CXXFLAGS="$save_CXXFLAGS -Werror $flag"
1229 # No, so this option is actually OK
1230 # with our C++ compiler.
1232 # (We need an empty command here to
1233 # prevent some versions of autoconf
1234 # from generating a script with an
1235 # empty "then" clause for an if statement.)
1241 # Yes, so we need -Werror for the tests.
1243 ac_wireshark_non_cxx_warning_option_error="-Werror"
1248 AC_WIRESHARK_POP_FLAGS
1250 if test x$ac_wireshark_non_cxx_warning_option_error = x; then
1251 AC_MSG_RESULT([yes])
1253 AC_MSG_RESULT([no, adding -Werror])
1258 # AC_WIRESHARK_COMPILER_FLAGS_CHECK
1260 # $1 : flags to test
1261 # $2 : if supplied, C for C-only flags, CXX for C++-only flags
1262 # $3 : if supplied, a program to try to compile with the flag
1263 # and, if the compile fails when -Werror is turned on,
1264 # we don't add the flag - used for warning flags that
1265 # issue incorrect or non-useful warnings with some
1267 # $4 : must be supplied if $3 is supplied - a message describing
1268 # for what the test program is testing
1270 # The macro first determines if the compiler supports GCC-style flags.
1271 # Then it attempts to compile with the defined cflags. The defined
1272 # flags are added to WS_CHECKED_CFLAGS only if the compilation succeeds.
1273 # CFLAGS remains unchanged. can_add_to_cflags is set to "no" when the
1274 # flag is checked but unavailable. (Like-wise for CXXFLAGS.)
1276 # We do this because not all such options are necessarily supported by
1277 # the version of the particular compiler we're using.
1279 AC_DEFUN([AC_WIRESHARK_COMPILER_FLAGS_CHECK],
1281 can_add_to_cflags=""
1282 can_add_to_cxxflags=""
1283 if test "x$ac_supports_gcc_flags" = "xyes" ; then
1284 if test "$2" != CXX ; then
1286 # Not C++-only; if this can be added to the C compiler flags, add them.
1288 # If the option begins with "-W", add
1289 # $ac_wireshark_unknown_warning_option_error to make sure that
1290 # we'll get an error if it's an unknown warning option; not all
1291 # compilers treat unknown warning options as errors (I'm looking at
1294 # If the option begins with "-f" or "-m", add -Werror to make sure
1295 # that we'll get an error if we get "argument unused during compilation"
1296 # warnings, as those will either cause a failure for files compiled
1297 # with -Werror or annoying noise for files compiled without it.
1298 # (Yeah, you, clang.)
1300 AC_MSG_CHECKING(whether we can add $GCC_OPTION to CFLAGS)
1301 AC_WIRESHARK_PUSH_FLAGS
1302 if expr "x$GCC_OPTION" : "x-W.*" >/dev/null
1304 CFLAGS="$CFLAGS $ac_wireshark_unknown_warning_option_error $GCC_OPTION"
1305 elif expr "x$GCC_OPTION" : "x-f.*" >/dev/null
1307 CFLAGS="$CFLAGS -Werror $GCC_OPTION"
1308 elif expr "x$GCC_OPTION" : "x-m.*" >/dev/null
1310 CFLAGS="$CFLAGS -Werror $GCC_OPTION"
1312 CFLAGS="$CFLAGS $GCC_OPTION"
1316 AC_LANG_SOURCE([[int foo;]])
1320 can_add_to_cflags=yes
1322 # OK, do we have a test program? If so, check
1323 # whether it fails with this option and -Werror,
1324 # and, if so, don't include it.
1326 # We test arg 4 here because arg 3 is a program which
1327 # could contain quotes (breaking the comparison).
1329 if test "x$4" != "x" ; then
1330 CFLAGS="$CFLAGS -Werror"
1331 AC_MSG_CHECKING(whether $GCC_OPTION $4)
1333 [AC_LANG_SOURCE($3)],
1337 # Remove "force an error for a warning" options, if we
1338 # added them, by setting CFLAGS to the saved value plus
1339 # just the new option.
1341 AX_APPEND_FLAG([$GCC_OPTION], [WS_CFLAGS])
1342 if test "$CC" = "$CC_FOR_BUILD"; then
1344 # We're building the build tools with the same compiler
1345 # with which we're building Wireshark, so add the flags
1346 # to the flags for that compiler as well.
1348 AX_APPEND_FLAG([$GCC_OPTION], [WS_CFLAGS_FOR_BUILD])
1356 # Remove "force an error for a warning" options, if we
1357 # added them, by setting CFLAGS to the saved value plus
1358 # just the new option.
1360 AX_APPEND_FLAG([$GCC_OPTION], [WS_CFLAGS])
1361 if test "$CC" = "$CC_FOR_BUILD"; then
1363 # We're building the build tools with the same compiler
1364 # with which we're building Wireshark, so add the flags
1365 # to the flags for that compiler as well.
1367 AX_APPEND_FLAG([$GCC_OPTION], [WS_CFLAGS_FOR_BUILD])
1373 can_add_to_cflags=no
1375 AC_WIRESHARK_POP_FLAGS
1378 # Did we find a C++ compiler?
1380 if test "x$CXX" != "x" ; then
1382 # Yes. Is this option only for the C compiler?
1384 if test "$2" != C ; then
1386 # Not C-only; if this option can be added to the C++ compiler
1389 # If the option begins with "-W", add
1390 # $ac_wireshark_unknown_warning_option_error, as per the above, and
1391 # also add $ac_wireshark_non_cxx_warning_option_error, because at
1392 # lease some versions of g++ whine about -Wmissing-prototypes, the
1393 # fact that at least one of those versions refuses to warn about
1394 # function declarations without an earlier declaration nonwithstanding;
1395 # perhaps there's a reason not to warn about that with C++ even though
1396 # warning about it can be a Good Idea with C, but it's not obvious to
1399 # If the option begins with "-f" or "-m", add -Werror to make sure
1400 # that we'll get an error if we get "argument unused during compilation"
1401 # warnings, as those will either cause a failure for files compiled
1402 # with -Werror or annoying noise for files compiled without it.
1403 # (Yeah, you, clang++.)
1405 AC_MSG_CHECKING(whether we can add $GCC_OPTION to CXXFLAGS)
1406 AC_WIRESHARK_PUSH_FLAGS
1407 if expr "x$GCC_OPTION" : "x-W.*" >/dev/null
1409 CXXFLAGS="$CXXFLAGS $ac_wireshark_unknown_warning_option_error $ac_wireshark_non_cxx_warning_option_error $GCC_OPTION"
1410 elif expr "x$GCC_OPTION" : "x-f.*" >/dev/null
1412 CXXFLAGS="$CXXFLAGS -Werror $GCC_OPTION"
1413 elif expr "x$GCC_OPTION" : "x-m.*" >/dev/null
1415 CXXFLAGS="$CXXFLAGS -Werror $GCC_OPTION"
1417 CXXFLAGS="$CXXFLAGS $GCC_OPTION"
1422 AC_LANG_SOURCE([[int foo;]])
1426 can_add_to_cxxflags=yes
1428 # OK, do we have a test program? If so, check
1429 # whether it fails with this option and -Werror,
1430 # and, if so, don't include it.
1432 # We test arg 4 here because arg 3 is a program which
1433 # could contain quotes (breaking the comparison).
1435 if test "x$4" != "x" ; then
1436 CXXFLAGS="$CXXFLAGS -Werror"
1437 AC_MSG_CHECKING(whether $GCC_OPTION $4)
1439 [AC_LANG_SOURCE($3)],
1443 # Remove "force an error for a warning" options, if we
1444 # added them, by setting CXXFLAGS to the saved value plus
1445 # just the new option.
1447 AX_APPEND_FLAG([$GCC_OPTION], [WS_CXXFLAGS])
1454 # Remove "force an error for a warning" options, if we
1455 # added them, by setting CXXFLAGS to the saved value plus
1456 # just the new option.
1458 AX_APPEND_FLAG([$GCC_OPTION], [WS_CXXFLAGS])
1463 can_add_to_cxxflags=no
1465 AC_WIRESHARK_POP_FLAGS
1468 if test "(" "$can_add_to_cflags" = "yes" -a "$can_add_to_cxxflags" = "no" ")" \
1469 -o "(" "$can_add_to_cflags" = "no" -a "$can_add_to_cxxflags" = "yes" ")"
1472 # Confusingly, some C++ compilers like -Wmissing-prototypes but
1473 # don't like -Wmissing-declarations and others like
1474 # -Wmissing-declarations but don't like -Wmissing-prototypes,
1475 # the fact that the corresponding C compiler likes both. Don't
1478 if test "(" x$GCC_OPTION != x-Wmissing-prototypes ")" \
1479 -a "(" x$GCC_OPTION != x-Wmissing-declarations ")"
1481 AC_MSG_WARN([$CC and $CXX appear to be a mismatched pair])
1488 # AC_WIRESHARK_GCC_FORTIFY_SOURCE_CHECK
1490 # Checks if '-D_FORTIFY_SOURCE=...' is OK to use in CPPFLAGS.
1491 # Use '-D_FORTIFY_SOURCE=...' in CPPFLAGS only if the GCC 'optimization level' is > 0.
1492 # The use of '-D_FORTIFY_SOURCE=...' will cause a warning with at least some versions
1493 # of glibc if the GCC "optimization level" is 0 (default or -O or -O0)
1494 # when using GCC to compile a source file which references the macro definition.
1496 # See: http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
1497 # See: http://sourceware.org/bugzilla/show_bug.cgi?id=13979
1499 # We'll use '-D_FORTIFY_SOURCE=2' only if there's no warning; Among other things this means
1500 # that the use of '-D_FORTIFY_SOURCE=2' with '-Werror' and '-O0' won't cause
1501 # the compiler to stop on error.
1502 # Assumption: CFLAGS already contains whatever optimization option including none) is
1506 AC_DEFUN([AC_WIRESHARK_GCC_FORTIFY_SOURCE_CHECK],
1508 if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
1509 AC_MSG_CHECKING([whether -D_FORTIFY_SOURCE=2 can be used (without generating a warning)])
1510 AC_WIRESHARK_PUSH_FLAGS
1511 CFLAGS="$CFLAGS -Werror"
1512 CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
1520 AX_APPEND_FLAG([-D_FORTIFY_SOURCE=2], [WS_CPPFLAGS])
1525 AC_WIRESHARK_POP_FLAGS
1530 # AC_WIRESHARK_GCC_SYSTEM_INCLUDE
1532 # Replace -I include flag for -isystem in FLAGS argument
1534 AC_DEFUN([AC_WIRESHARK_GCC_SYSTEM_INCLUDE],
1536 if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
1538 | sed -e 's/ *-I *\// -isystem\//g' -e 's/^ *//'`
1543 # PKG_WIRESHARK_CHECK_SYSTEM_MODULES
1545 AC_DEFUN([PKG_WIRESHARK_CHECK_SYSTEM_MODULES],
1547 PKG_CHECK_MODULES($@)
1548 AC_WIRESHARK_GCC_SYSTEM_INCLUDE($1_CFLAGS)
1551 # Based on AM_PATH_GTK in gtk-2.0.m4.
1553 dnl AC_WIRESHARK_QT_MODULE_CHECK_WITH_QT_VERSION([MODULE, MINIMUM-VERSION,
1554 dnl REQUESTED-MAJOR_VERSION, [ACTION-IF-FOUND, [ACTION-IF-NOT-FOUND]]])
1555 dnl Test for a particular Qt module, for a particular Qt major version,
1556 dnl and, if we find it add the flags and libraries for it to Qt_CFLAGS
1559 AC_DEFUN([AC_WIRESHARK_QT_MODULE_CHECK_WITH_QT_VERSION],
1569 # Version of the module we're checking for.
1572 min_qt_version=5.2.0
1576 AC_MSG_ERROR([Qt version $3 is not a known Qt version])
1580 pkg_config_module="${modprefix}$1"
1581 AC_MSG_CHECKING(for $pkg_config_module - version >= $min_qt_version)
1582 if $PKG_CONFIG --atleast-version $min_qt_version $pkg_config_module; then
1583 mod_version=`$PKG_CONFIG --modversion $pkg_config_module`
1584 AC_MSG_RESULT(yes (version $mod_version))
1585 mod_cflags=`$PKG_CONFIG --cflags $pkg_config_module`
1586 AC_WIRESHARK_GCC_SYSTEM_INCLUDE(mod_cflags)
1587 Qt_CFLAGS="$Qt_CFLAGS $mod_cflags"
1588 Qt_LIBS="$Qt_LIBS `$PKG_CONFIG --libs $pkg_config_module`"
1589 # Run Action-If-Found
1590 ifelse([$4], , :, [$4])
1593 # Run Action-If-Not-Found
1594 ifelse([$5], , :, [$5])
1598 dnl AC_WIRESHARK_QT_MODULE_CHECK([MODULE, MINIMUM-VERSION,
1599 dnl REQUESTED-MAJOR_VERSION, [ACTION-IF-FOUND, [ACTION-IF-NOT-FOUND]]])
1600 dnl Test for a particular Qt module and add the flags and libraries
1601 dnl for it to Qt_CFLAGS and Qt_LIBS.
1603 AC_DEFUN([AC_WIRESHARK_QT_MODULE_CHECK],
1606 # Prior to Qt 5, modules were named QtXXX.
1607 # In Qt 5, they're named Qt5XXX.
1608 # This will need to change to handle future major Qt releases.
1614 # Check for all versions of Qt we support.
1615 # Try the Qt 5 version first.
1621 AC_MSG_ERROR([$3 is not a known Qt option])
1625 for version in $versions
1627 AC_WIRESHARK_QT_MODULE_CHECK_WITH_QT_VERSION($1, $2,
1628 $version, [foundit=yes], [foundit=no])
1629 if test "x$foundit" = "xyes"; then
1634 if test "x$foundit" = "xyes"; then
1635 # Remember which version of Qt we found
1637 # Run Action-If-Found
1638 ifelse([$4], , :, [$4])
1640 # Run Action-If-Not-Found
1641 ifelse([$5], , :, [$5])
1645 AC_DEFUN([AC_WIRESHARK_QT_ADD_PIC_IF_NEEDED],
1648 AC_WIRESHARK_PUSH_FLAGS
1649 CPPFLAGS="$CPPFLAGS $Qt_CFLAGS"
1650 AC_MSG_CHECKING([whether Qt works without -fPIC])
1652 [AC_LANG_SOURCE([[#include <QtCore>]])],
1653 [AC_MSG_RESULT(yes)],
1656 AC_MSG_CHECKING([whether Qt works with -fPIC])
1657 CPPFLAGS="$CPPFLAGS -fPIC"
1659 [AC_LANG_SOURCE([[#include <QtCore>]])],
1662 Qt_CFLAGS="$Qt_CFLAGS -fPIC"
1666 AC_MSG_ERROR(Couldn't compile Qt without -fPIC nor with -fPIC)
1669 AC_WIRESHARK_POP_FLAGS
1673 dnl AC_WIRESHARK_QT_CHECK([MINIMUM-VERSION, REQUESTED-MAJOR_VERSION,
1674 dnl [ACTION-IF-FOUND, [ACTION-IF-NOT-FOUND]]])
1675 dnl Test for Qt and define Qt_CFLAGS and Qt_LIBS.
1677 AC_DEFUN([AC_WIRESHARK_QT_CHECK],
1679 qt_version_to_check="$2"
1682 # Check for the Core module; if we don't have that,
1683 # we don't have Qt. If we *do* have it, we know what
1684 # version it is, so only check for that version of
1687 AC_WIRESHARK_QT_MODULE_CHECK(Core, $1, $qt_version_to_check,
1689 qt_version_to_check=$qt_version
1690 QT_VERSION=$mod_version
1691 QT_VERSION_MAJOR=`echo "$QT_VERSION" | cut -f1 -d.`
1692 QT_VERSION_MINOR=`echo "$QT_VERSION" | cut -f2 -d.`
1693 QT_VERSION_MICRO=`echo "$QT_VERSION" | cut -f3 -d.`
1695 # Qt 5.7 and later requires C++11
1696 AS_IF([test $QT_VERSION_MAJOR -eq 5 -a $QT_VERSION_MINOR -ge 7],
1697 [AS_IF([test "$HAVE_CXX11" -eq 0], [AC_MSG_ERROR([Qt 5.7 and later requires C++11])])])
1702 if test x"$no_qt" = x ; then
1704 # We need the Gui module as well.
1706 AC_WIRESHARK_QT_MODULE_CHECK(Gui, $1, $qt_version_to_check, ,
1710 if test x"$no_qt" = x ; then
1712 # Qt 5.0 appears to move the widgets out of Qt GUI
1713 # to Qt Widgets; look for the Widgets module, but
1714 # don't fail if we don't have it.
1716 AC_WIRESHARK_QT_MODULE_CHECK(Widgets, $1, $qt_version_to_check)
1719 # Qt 5.0 also appears to move the printing support into
1720 # the Qt PrintSupport module.
1722 AC_WIRESHARK_QT_MODULE_CHECK(PrintSupport, $1, $qt_version_to_check)
1725 # Qt 5.0 added multimedia in the Qt
1726 # Multimedia module.
1728 have_qt_multimedia_lib=no
1729 AC_WIRESHARK_QT_MODULE_CHECK(Multimedia, $1, $qt_version_to_check,
1730 have_qt_multimedia_lib=yes
1731 AC_DEFINE(QT_MULTIMEDIA_LIB, 1, [Define if we have QtMultimedia]))
1734 # While we're at it, look for QtMacExtras. (Presumably
1735 # if we're not building for macOS, it won't be present.)
1737 # XXX - is there anything in QtX11Extras or QtWinExtras
1738 # that we should be using?
1740 AC_WIRESHARK_QT_MODULE_CHECK(MacExtras, $1, $qt_version_to_check,
1741 AC_DEFINE(QT_MACEXTRAS_LIB, 1, [Define if we have QtMacExtras]))
1743 AC_WIRESHARK_QT_ADD_PIC_IF_NEEDED
1745 # Run Action-If-Found
1746 ifelse([$3], , :, [$3])
1748 # Run Action-If-Not-Found
1749 ifelse([$4], , :, [$4])
1754 dnl AC_WIRESHARK_QT_TOOL_CHECK([TOOLPATHVAR, TOOL, REQUESTED-MAJOR_VERSION])
1755 dnl Test for a particular Qt tool for some specific version of Qt
1757 AC_DEFUN([AC_WIRESHARK_QT_TOOL_CHECK],
1760 # At least in some versions of Debian/Ubuntu, and perhaps
1761 # other OSes, the Qt build tools are just links to a
1762 # program called "qtchooser", and even if you want to
1763 # build with Qt 5, running the tool might give you the
1764 # Qt 4 version of the tool unless you run the tool with
1767 # So we look for qtchooser and, if we find it, use the
1768 # -qt={version} argument, otherwise we look for particular
1769 # tool versions using tool name suffixes.
1771 AC_PATH_PROG(QTCHOOSER, qtchooser)
1772 if test ! -z "$QTCHOOSER"; then
1774 # We found qtchooser; we assume that means that
1775 # the tool is linked to qtchooser, so that we
1776 # can run it with the -qt={version} flag to get
1777 # the appropriate version of the tool.
1779 AC_PATH_PROG($1, $2)
1780 if test "x$$1" = x; then
1782 # We can't build Qt Wireshark without that
1785 AC_MSG_ERROR(I couldn't find $2; make sure it's installed and in your path)
1789 # Add the -qt={version} argument to it.
1791 $1="$$1 -qt=$qt_version"
1794 # Annoyingly, on some Linux distros (e.g. Debian)
1795 # the Qt 5 tools have no suffix and the Qt 4 tools
1796 # have suffix -qt4. On other distros (e.g. openSUSE)
1797 # the Qt 5 tools have suffix -qt5 and the Qt 4 tools
1800 # So we check for the tool first with the -qtN suffix
1801 # and then with no suffix.
1803 AC_PATH_PROGS($1, [$2-qt$qt_version $2])
1804 if test "x$$1" = x; then
1806 # We can't build Qt Wireshark without that
1809 AC_MSG_ERROR(I couldn't find $2-qt$qt_version or $2; make sure it's installed and in your path)
1814 AC_DEFUN([AC_WIRESHARK_QT_TOOL_CHECK_LRELEASE],
1816 AC_WIRESHARK_QT_TOOL_CHECK(LRELEASE, lrelease, $2)
1817 AC_MSG_CHECKING(whether lrelease -version works)
1818 lrelease_version=`$LRELEASE -version 2>&AS_MESSAGE_LOG_FD`
1819 AS_IF([test $? -ne 0],
1822 AC_MSG_ERROR([$LRELEASE -version returned non-zero exit status])
1824 AC_MSG_RESULT([ok, $lrelease_version])
1828 # AC_WIRESHARK_LZ4_CHECK
1830 AC_DEFUN([AC_WIRESHARK_LZ4_CHECK],
1832 AC_WIRESHARK_PUSH_FLAGS
1834 if test "x$lz4_dir" != "x"
1837 # The user specified a directory in which lz4 resides,
1838 # so add the "include" subdirectory of that directory to
1839 # the include file search path and the "lib" subdirectory
1840 # of that directory to the library search path.
1842 # XXX - if there's also a lz4 in a directory that's
1843 # already in CPPFLAGS or LDFLAGS, this won't make us find
1844 # the version in the specified directory, as the compiler
1845 # and/or linker will search that other directory before it
1846 # searches the specified directory.
1848 LZ4_CFLAGS="-I$lz4_dir/include"
1852 # Make sure we have "lz4.h". If we don't, it means we probably
1853 # don't have lz4, so don't use it.
1855 AC_CHECK_HEADER(lz4.h,,
1857 if test "x$lz4_dir" != "x"
1860 # The user used "--with-lz4=" to specify a directory
1861 # containing lz4, but we didn't find the header file
1862 # there; that either means they didn't specify the
1863 # right directory or are confused about whether lz4
1864 # is, in fact, installed. Report the error and give up.
1866 AC_MSG_ERROR([lz4 header not found in directory specified in --with-lz4])
1868 if test "x$want_lz4" = "xyes"
1871 # The user tried to force us to use the library, but we
1872 # couldn't find the header file; report an error.
1874 AC_MSG_ERROR(Header file lz4.h not found.)
1877 # We couldn't find the header file; don't use the
1878 # library, as it's probably not present.
1885 if test "x$want_lz4" != "xno"
1888 # Well, we at least have the lz4 header file.
1889 # We link with lz4 to support uncompression of
1893 ac_save_LIBS="$LIBS"
1894 LIBS="$LZ4_LIBS $LIBS"
1895 AC_DEFINE(HAVE_LZ4, 1, [Define to use lz4 library])
1897 # Check for "LZ4_decompress_safe()" in lz4, which we need
1898 # in order to read compressed capture files.
1900 AC_CHECK_FUNCS(LZ4_decompress_safe)
1902 # Check for (optional) lz4frame.h
1904 AC_CHECK_HEADERS(lz4frame.h)
1905 LIBS="$ac_save_LIBS"
1908 AC_WIRESHARK_POP_FLAGS
1912 # AC_WIRESHARK_SNAPPY_CHECK
1914 AC_DEFUN([AC_WIRESHARK_SNAPPY_CHECK],
1916 AC_WIRESHARK_PUSH_FLAGS
1918 if test "x$snappy_dir" != "x"
1921 # The user specified a directory in which snappy resides,
1922 # so add the "include" subdirectory of that directory to
1923 # the include file search path and the "lib" subdirectory
1924 # of that directory to the library search path.
1926 # XXX - if there's also a snappy in a directory that's
1927 # already in CPPFLAGS or LDFLAGS, this won't make us find
1928 # the version in the specified directory, as the compiler
1929 # and/or linker will search that other directory before it
1930 # searches the specified directory.
1932 SNAPPY_CFLAGS="-I$snappy_dir/include"
1936 # Make sure we have "snappy-c.h". If we don't, it means we probably
1937 # don't have snappy, so don't use it.
1939 AC_CHECK_HEADER(snappy-c.h,,
1941 if test "x$snappy_dir" != "x"
1944 # The user used "--with-snappy=" to specify a directory
1945 # containing snappy, but we didn't find the header file
1946 # there; that either means they didn't specify the
1947 # right directory or are confused about whether snappy
1948 # is, in fact, installed. Report the error and give up.
1950 AC_MSG_ERROR([snappy-c.header not found in directory specified in --with-snappy])
1952 if test "x$want_snappy" = "xyes"
1955 # The user tried to force us to use the library, but we
1956 # couldn't find the header file; report an error.
1958 AC_MSG_ERROR(Header file snappy-c.h not found.)
1961 # We couldn't find the header file; don't use the
1962 # library, as it's probably not present.
1969 if test "x$want_snappy" != "xno"
1972 # Well, we at least have the snappy-c.header file.
1973 # We link with snappy to support uncompression of
1974 # compressed CQL traffic.
1976 SNAPPY_LIBS=-lsnappy
1977 ac_save_LIBS="$LIBS"
1978 LIBS="$SNAPPY_LIBS $LIBS"
1979 AC_DEFINE(HAVE_SNAPPY, 1, [Define to use snappy library])
1981 # Check for "snappy_uncompress()" in snappy, which we need
1982 # in order to read compressed capture files.
1984 AC_CHECK_FUNCS(snappy_uncompress)
1985 LIBS="$ac_save_LIBS"
1988 AC_WIRESHARK_POP_FLAGS
1992 # AC_WIRESHARK_BCG729_CHECK
1994 AC_DEFUN([AC_WIRESHARK_BCG729_CHECK],
1996 want_bcg729=defaultyes
1998 if test "x$want_bcg729" = "xdefaultyes"; then
2002 if test "x$want_bcg729" = "xyes"; then
2003 AC_CHECK_LIB(bcg729, bcg729Decoder,
2005 AC_CHECK_HEADERS(bcg729/decoder.h,
2007 BCG729_LIBS=-lbcg729
2008 AC_DEFINE(HAVE_BCG729, 1, [Define to use bcg729 library])
2009 have_good_bcg729=yes
2015 AC_MSG_RESULT(not required)