[Diameter] Add a couple of command codes from IANA.
[metze/wireshark/wip.git] / configure.ac
1 #
2 # Autoconf script for Wireshark
3 #
4
5 #
6 # Define variables for the components of the Wireshark version number.
7 #
8 m4_define([version_major], [2])
9 m4_define([version_minor], [5])
10 m4_define([version_micro], [0])
11 dnl Updated by make-version.pl
12 m4_define([version_extra], [])
13 m4_define([version_micro_extra], m4_join([], version_micro, version_extra))
14
15 AC_INIT(Wireshark, [version_major.version_minor.version_micro_extra], http://bugs.wireshark.org/, , http://www.wireshark.org/)
16 CONFIG_ARGS="$*"
17 AC_SUBST(CONFIG_ARGS)
18
19 # Minimum autoconf version we require.
20 AC_PREREQ(2.64)
21 # Variable expansion doesn't work in AC_PREREQ()
22 AC_MIN_VERSION=2.64
23 AC_SUBST(AC_MIN_VERSION)
24
25 dnl Make sure to keep ACLOCAL_AMFLAGS in Makefile.am and AC_CONFIG_MACRO_DIRS
26 dnl in configure.ac in sync, otherwise there will be an error running autogen.sh.
27 m4_ifdef([AC_CONFIG_MACRO_DIRS],[AC_CONFIG_MACRO_DIRS([m4])])
28
29 dnl Check for CPU / vendor / OS
30 dnl The user is encouraged to use either `AC_CANONICAL_BUILD', or
31 dnl `AC_CANONICAL_HOST', or `AC_CANONICAL_TARGET', depending on the
32 dnl needs.  Using `AC_CANONICAL_TARGET' is enough to run the two other
33 dnl macros.
34 dnl
35 dnl As nothing in the Wireshark is itself a build tool (we are not,
36 dnl for example, a compiler that generates machine code), we probably
37 dnl don't need AC_CANONICAL_TARGET, so, in theory, we should be able
38 dnl to use AC_CANONICAL_BUILD and AC_CANONICAL_HOST - or perhaps just
39 dnl AC_CANONICAL_HOST - instead.  Note that we do have tools, such as
40 dnl lemon, that need to be built for the build machine, not for the
41 dnl host machine, so we might need both.
42 dnl
43 dnl This has to be done *after* AC_INIT, otherwise autogen.sh fails.
44
45 dnl AC_CANONICAL_BUILD
46 dnl AC_CANONICAL_HOST
47 AC_CANONICAL_TARGET
48
49 AM_INIT_AUTOMAKE([1.11 tar-ustar dist-xz no-dist-gzip subdir-objects])
50
51 # Enable silent builds by default. Verbose builds can be enabled with "./configure
52 # --enable-silent-rules ..." or "make V=1 ..."
53 AM_SILENT_RULES([yes])
54
55 # Make Wireshark's version available in config.h
56 AC_DEFINE(VERSION_MAJOR, version_major, [Wireshark's major version])
57 AC_DEFINE(VERSION_MINOR, version_minor, [Wireshark's minor version])
58 AC_DEFINE(VERSION_MICRO, version_micro, [Wireshark's micro version])
59
60 AC_DEFINE_UNQUOTED(VERSION_FLAVOR,
61         ["${WIRESHARK_VERSION_FLAVOR:-"Development Build"}"], [Wireshark's package flavor])
62
63 LT_PREREQ([2.2.2])
64 LT_INIT([disable-static dlopen])
65 AC_SUBST([LIBTOOL_DEPS])
66
67 AC_CONFIG_LIBOBJ_DIR([wsutil])
68
69 #
70 # Checks for programs used in the main build process.
71 #
72 # See doc/README.developer for allowed C99 features
73 #
74 AC_PROG_CC_C99
75 if test "$ac_cv_prog_cc_c99" = "no"
76 then
77         AC_MSG_ERROR([The C compiler does not support C99])
78 fi
79 AC_PROG_CPP
80
81 AC_PROG_CXX
82 if test ! -z "$CXX"; then
83         #
84         # OK, we found something AC_LANG_CXX thinks is a C++ compiler,
85         # but is it one?
86         #
87         # Some UN*Xes have, by default, a case-insensitive file
88         # system, and AC_PROG_CXX looks for, among other things,
89         # "CC" as a C++ compiler, and, if you have a case-insensitive
90         # file system and a C compiler named "cc" (both true, by
91         # default, on macOS), AC_PROG_CXX may end up thinking it's
92         # the C++ compiler.
93         #
94         # So we check by feeding the purported C++ compiler a
95         # program using C++ features (iostream).
96         #
97         AC_MSG_CHECKING(whether $CXX is a C++ compiler)
98         AC_LANG_PUSH([C++])
99         AC_LINK_IFELSE([AC_LANG_PROGRAM(
100         [
101 #include <iostream>
102         ],
103         [
104         std::cout << "Hello World! ";
105         return 0;
106         ])],
107                 [AC_MSG_RESULT(yes)],
108                 [
109                         AC_MSG_RESULT(no)
110                         CXX=""
111                 ])
112         AC_LANG_POP([C++])
113 fi
114
115 # Qt 5.7 or later requires C++11
116 AS_IF([test -n "$CXX"],
117         [AX_CXX_COMPILE_STDCXX([11], [noext], [optional])])
118
119 # Set CC_FOR_BUILD (the *local* gcc to use for building e.g. lemon)
120 if test "x$cross_compiling" = xno -a -z "$CC_FOR_BUILD"; then
121         CC_FOR_BUILD="$CC"
122 fi
123 AX_PROG_CC_FOR_BUILD
124
125 #
126 # Check for versions of "sed" inadequate to handle, in libtool, a list
127 # of object files as large as the list in Wireshark.
128 #
129 AC_PROG_SED
130
131 AC_PROG_LN_S
132 AC_PROG_MKDIR_P
133
134 AC_PATH_PROG(PERL, perl)
135
136 # Check for Python.
137 AC_PATH_PROGS(PYTHON, python python3)
138 if test ! -z "$PYTHON"; then
139         #
140         # OK, we found Python; is it Python 2.5 or later?
141         # Note: we don't use named components for sys.version_info to get
142         # the major version number, as named components for version_info
143         # were apparently introduced in Python 2.7.
144         #
145         AC_MSG_CHECKING([whether $PYTHON is Python 2.5 or later])
146         python_major_version=`$PYTHON -c 'import sys; print (sys.version_info[[0]])'`
147         python_minor_version=`$PYTHON -c 'import sys; print (sys.version_info[[1]])'`
148         if test "$python_major_version" -eq 2 -a "$python_minor_version" -lt 5 ; then
149                 AC_MSG_RESULT(no)
150                 AC_MSG_WARN([Building with Python $python_major_version.$python_minor_version may not work])
151         else
152                 AC_MSG_RESULT(yes)
153         fi
154 else
155         AC_MSG_ERROR(I couldn't find python; make sure it's installed and in your path)
156 fi
157
158 dnl
159 dnl Check for yacc/lex. Distribution tarballs include generated source,
160 dnl in which case these tools are not a mandatory requirement to build.
161 dnl
162 AC_PROG_YACC
163 AS_IF([test "x$YACC" = xyacc], [AS_UNSET(YACC)])
164 AS_IF([test -z "$YACC" -a ! -f $srcdir/wiretap/ascend.c],
165         [AC_MSG_ERROR([I couldn't find bison or byacc; make sure it's installed and in your path])])
166 AM_MISSING_PROG(YACC, bison)
167 AC_PROG_LEX
168 AS_IF([test "x$LEX" != xflex], [AS_UNSET(LEX)])
169 AS_IF([test -z "$LEX" -a ! -f $srcdir/wiretap/ascend_scanner.c],
170         [AC_MSG_ERROR([I couldn't find flex; make sure it's installed and in your path])])
171 AM_MISSING_PROG(LEX, flex)
172
173 AC_PATH_PROG(POD2MAN, pod2man)
174 if test "x$POD2MAN" = x
175 then
176         #
177         # The alternative is not to build the man pages....
178         #
179         AC_MSG_ERROR(I couldn't find pod2man; make sure it's installed and in your path)
180 fi
181 AC_PATH_PROG(POD2HTML, pod2html)
182 if test "x$POD2HTML" = x
183 then
184         #
185         # The alternative is not to build the HTML man pages....
186         #
187         AC_MSG_ERROR(I couldn't find pod2html; make sure it's installed and in your path)
188 fi
189
190 #
191 # Set "ac_supports_gcc_flags" if the compiler is known to support GCC-style
192 # flags such as -pedantic, -W warning flags and -f feature flags.  Currently,
193 # we assume GCC and clang do; other compilers should be added here.
194 #
195 # This is done to avoid getting tripped up by compilers that support
196 # those flags but give them a different meaning.
197 #
198 if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
199         ac_supports_gcc_flags=yes
200 fi
201
202 # Check for doxygen
203 AC_PATH_PROG(DOXYGEN, doxygen)
204 AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, "yes", "no")
205 AM_CONDITIONAL(HAVE_DOXYGEN, test x$HAVE_DOXYGEN = xyes)
206
207 #
208 # Check for pkg-config and set PKG_CONFIG accordingly.
209 #
210 # This is referenced via AC_REQUIRE([PKG_PROG_PKG_CONFIG] in some macros
211 # like PKG_CHECK_MODULES. If the first call to such a macro is under an
212 # "if" statement, it's safer to call PKG_PROG_PKG_CONFIG directly, see
213 # the comments in acolocal.m4
214 #
215 # We want version 0.7 or better.  (XXX - explain why. Is that just
216 # because our Qt tests were originally based on AM_PATH_GTK, and *it*
217 # requires 0.7 or better?)
218 #
219 PKG_PROG_PKG_CONFIG(0.7)
220 if test -z "$PKG_CONFIG"; then
221         AC_MSG_ERROR(I couldn't find pkg-config; make sure it's installed and in your path)
222 fi
223
224 #
225 # Add configure argument to select macOS deployment target.
226 #
227 AC_WIRESHARK_OSX_DEPLOY_TARGET
228
229 #
230 # Try to arrange for large file support.
231 #
232 AC_SYS_LARGEFILE
233
234 #
235 # Check if we need to link with libm
236 #
237 AC_SEARCH_LIBS([cos], [m])
238
239 #
240 # Check for C99 math functions.
241 #
242 AC_CHECK_FUNCS([floorl lrint])
243
244 #
245 # Check if we need to link with -lnsl and -lsocket
246 #
247 AX_LIB_SOCKET_NSL
248
249 #
250 # GUI toolkit options
251 #
252 AC_ARG_WITH([qt],
253   AC_HELP_STRING( [--with-qt=@<:@yes/no/4/5@:>@],
254                   [use Qt @<:@default=yes, if available@:>@]),
255   with_qt="$withval", with_qt="unspecified")
256
257 AC_ARG_WITH([gtk],
258   AC_HELP_STRING( [--with-gtk=@<:@yes/no/2/3@:>@],
259         [use GTK+ @<:@default=no@:>@]),
260         AS_CASE([$withval],
261           [yes], [with_gtk="3 2 fail"],
262           [no],  [with_gtk="no"],
263           [3],   [with_gtk="3 fail3"],
264           [2],   [with_gtk="2 fail2"],
265           [AC_MSG_ERROR([--with-gtk must be one of yes/no/2/3])]),
266         with_gtk="no")
267
268 # GnuTLS
269 # Version 3.0 switched from LGPLv2.1+ to LGPLv3+, then switched back to
270 # LGPLv2.1+ in version 3.1.10.
271 # GnuTLS depends on GMP which switched from LGPLv2.1+ to LGPLv3+ in
272 # version 4.2.2, the switched to LGPLv3+ / GPLv2+ in version 6.0.0.
273
274 tls_message="no"
275 want_gnutls="if_available"
276 AC_ARG_WITH([gnutls],
277   AC_HELP_STRING( [--with-gnutls=@<:@yes/no@:>@],
278                   [use GnuTLS library @<:@default=yes, if available@:>@]),
279   [ with_gnutls="$withval"; want_gnutls="yes" ], with_gnutls="yes")
280
281 if test "x$with_gnutls" = "xyes"; then
282   have_license_compatible_gnutls="no"
283   PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 3.1.10 ],
284     [ have_license_compatible_gnutls="yes" ], [ echo "GnuTLS >= 3.1.10 not found " ]
285   )
286
287   if test "x$have_license_compatible_gnutls" != "xyes"; then
288     PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.12.0 gnutls < 3],
289       [ have_license_compatible_gnutls="yes" ] , [ echo "GnuTLS >= 2.12.0, < 3.0 not found " ]
290     )
291   fi
292
293   if test "x$have_license_compatible_gnutls" != "xyes"; then
294     if test "x$want_gnutls" = "xyes"; then
295       AC_MSG_ERROR([GnuTLS crypto library was requested, but is not available])
296     else
297       AS_ECHO(["GnuTLS with compatible license not found, disabling SSL decryption"])
298     fi
299   else
300     AC_DEFINE(HAVE_LIBGNUTLS, 1, [Define to use GnuTLS library])
301     tls_message="yes"
302   fi
303 fi
304
305 # libgrypt (for decryption, MAC, etc. functionality).
306 AM_PATH_LIBGCRYPT(1.4.2, [ ] , [
307   AC_MSG_ERROR([[libgcrypt not found; install libgcrypt-devel package for your system]])
308 ])
309
310 AC_ARG_WITH(libnl,
311   AC_HELP_STRING([--with-libnl@<:@=VERSION@:>@],
312                  [use libnl (force version VERSION, if supplied) @<:@default: yes, if available@:>@]),
313 [
314         if test "x$withval" = "xno"
315         then
316                 want_libnl=no
317         elif test "x$withval" = "xyes"
318         then
319                 want_libnl=yes
320                 libnl_version=any
321         elif test "x$withval" = "x1"
322         then
323                 want_libnl=yes
324                 libnl_version=1
325         elif test "x$withval" = "x2"
326         then
327                 want_libnl=yes
328                 libnl_version=2
329         elif test "x$withval" = "x3"
330         then
331                 want_libnl=yes
332                 libnl_version=3
333         else
334                 AC_MSG_ERROR(["$withval" is not a valid argument to --with-libnl])
335         fi
336 ],[
337         #
338         # Use libnl if it's present, otherwise don't.
339         #
340         want_libnl=ifavailable
341         libnl_version=any
342 ])
343 #
344 # Libnl is Linux-specific.
345 #
346 libnl_message="no"
347 case "$host_os" in
348 linux*)
349         AC_MSG_CHECKING(whether to use libnl for various network interface purposes)
350
351         if test x$want_libnl = "xno"; then
352                 AC_MSG_RESULT(no)
353         else
354                 AC_MSG_RESULT(yes)
355                 #
356                 # Test for specific libnl versions only if no version
357                 # was specified by the user or if the version in question
358                 # was requested by the user.
359                 #
360                 if test x$libnl_version = "xany" -o x$libnl_version = "x3"; then
361                         PKG_CHECK_EXISTS([libnl-3.0 libnl-route-3.0 libnl-genl-3.0], [have_libnl3=yes], [have_libnl3=no])
362                 fi
363                 if test x$libnl_version = "xany" -o x$libnl_version = "x2"; then
364                         PKG_CHECK_EXISTS([libnl-2.0], [have_libnl2=yes], [have_libnl2=no])
365                 fi
366                 if test x$libnl_version = "xany" -o x$libnl_version = "x1"; then
367                         PKG_CHECK_EXISTS([libnl-1], [have_libnl1=yes], [have_libnl1=no])
368                 fi
369                 if (test "${have_libnl3}" = "yes"); then
370                         PKG_WIRESHARK_CHECK_SYSTEM_MODULES([LIBNL], [libnl-3.0 libnl-route-3.0 libnl-genl-3.0])
371                         AC_DEFINE(HAVE_LIBNL, 1, [Enable libnl support])
372                         AC_DEFINE(HAVE_LIBNL3, 1, [libnl version 3])
373                         libnl_message="yes (v3)"
374                 elif (test "${have_libnl2}" = "yes"); then
375                         PKG_WIRESHARK_CHECK_SYSTEM_MODULES([LIBNL], [libnl-2.0])
376                         AC_DEFINE(HAVE_LIBNL, 1, [Enable libnl support])
377                         AC_DEFINE(HAVE_LIBNL2, 1, [libnl version 2])
378                         libnl_message="yes (v2)"
379                 elif (test "${have_libnl1}" = "yes"); then
380                         PKG_WIRESHARK_CHECK_SYSTEM_MODULES([LIBNL], [libnl-1])
381                         AC_DEFINE(HAVE_LIBNL, 1, [Enable libnl support])
382                         AC_DEFINE(HAVE_LIBNL1, 1, [libnl version 1])
383                         libnl_message="yes (v1)"
384                 else
385                         if test x$want_libnl = "xyes"; then
386                                 case "$libnl_version" in
387
388                                 any)
389                                         AC_MSG_ERROR("I couldn't find libnl even though you manually enabled it.")
390                                         ;;
391
392                                 *)
393                                         AC_MSG_ERROR("I couldn't find libnl version $libnl_version even though you manually enabled it.")
394                                         ;;
395                                 esac
396                         fi
397                 fi
398         fi
399
400         AC_MSG_CHECKING([if nl80211.h is new enough])
401           AC_TRY_COMPILE([#include <linux/nl80211.h>],
402             [int x = NL80211_FREQUENCY_ATTR_MAX_TX_POWER;
403              x |= NL80211_ATTR_SUPPORTED_IFTYPES;
404              x |= NL80211_ATTR_SUPPORTED_COMMANDS;
405              x |= NL80211_ATTR_WIPHY_FREQ;
406              x |= NL80211_CHAN_NO_HT;
407              (void)x;],
408             [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_NL80211, 1, [nl80211.h is new enough])],
409             [AC_MSG_RESULT(no)])
410
411         AC_MSG_CHECKING([for NL80211_SET_CHANNEL])
412           AC_TRY_COMPILE([#include <linux/nl80211.h>],
413             [enum nl80211_commands x = NL80211_CMD_SET_CHANNEL;],
414             [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_NL80211_CMD_SET_CHANNEL, 1, [SET_CHANNEL is supported])],
415             [AC_MSG_RESULT(no)])
416
417         AC_MSG_CHECKING([for NL80211_SPLIT_WIPHY_DUMP])
418           AC_TRY_COMPILE([#include <linux/nl80211.h>],
419             [enum nl80211_protocol_features x = NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP;],
420             [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_NL80211_SPLIT_WIPHY_DUMP, 1, [SPLIT_WIPHY_DUMP is supported])],
421             [AC_MSG_RESULT(no)])
422
423         AC_MSG_CHECKING([for NL80211_VHT_CAPABILITY])
424           AC_TRY_COMPILE([#include <linux/nl80211.h>],
425             [enum nl80211_attrs x = NL80211_ATTR_VHT_CAPABILITY;],
426             [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_NL80211_VHT_CAPABILITY, 1, [VHT_CAPABILITY is supported])],
427             [AC_MSG_RESULT(no)])
428         ;;
429
430 *)
431         if test x$want_libnl != "xno" -a x$want_libnl != "xifavailable"; then
432                 AC_MSG_WARN([libnl is Linux-specific, ignoring --with-libnl])
433         fi
434 esac
435
436 # libsmi
437 # FIXME: currently the path argument to with-libsmi is being ignored
438 AX_LIBSMI
439
440 #
441 # Check for programs used when building DocBook documentation.
442 #
443 AC_CHECK_PROGS(XSLTPROC, xsltproc, xsltproc)
444 AC_CHECK_PROGS(A2X, a2x, a2x)
445 AC_CHECK_PROGS(FOP, fop, fop)
446
447 # HTML to text processor
448 AC_MSG_CHECKING([for an HTML to text processor])
449 AS_IF([w3m -version >&AS_MESSAGE_LOG_FD 2>&1], [have_a2x_text=w3m],
450         [lynx -version >&AS_MESSAGE_LOG_FD 2>&1], [have_a2x_text=lynx],
451         [have_a2x_text=no])
452 AC_MSG_RESULT([$have_a2x_text])
453 AM_CONDITIONAL(HAVE_A2X_TEXT, [test "x$have_a2x_text" != xno])
454 AS_IF([test $have_a2x_text = lynx], [A2X_LYNX="--lynx"])
455 AC_SUBST(A2X_LYNX)
456
457 # Check for packaging utilities
458 # For now, we check to see if the various packaging utilites are in our
459 # path.  I'm too lazy to write code to go hunt for them.  -  Gerald
460
461 #
462 # Source packages.
463 # (Lets you install the desktop files.)
464 #
465 AC_PATH_PROG(DESKTOP_FILE_INSTALL, desktop-file-install)
466
467 # SVR4/Solaris
468 AC_CHECK_PROG(HAVE_PKGPROTO, pkgproto, "yes", "no")
469 AC_CHECK_PROG(HAVE_PKGMK, pkgmk, "yes", "no")
470 AC_CHECK_PROG(HAVE_PKGTRANS, pkgtrans, "yes", "no")
471
472 if test x$HAVE_PKGPROTO = xyes -a x$HAVE_PKGMK = xyes \
473      -a x$HAVE_PKGTRANS = xyes ; then
474   HAVE_SVR4_PACKAGING=yes
475 else
476   HAVE_SVR4_PACKAGING=no
477 fi
478 AC_SUBST(HAVE_SVR4_PACKAGING)
479
480 # RPM
481 #
482 # Looks for the rpmbuild program, and checks to see if we can redefine "_topdir".
483 #
484 AC_CHECK_PROGS(RPMBUILD, [rpmbuild], [false])
485 if test "x$RPMBUILD" != "xfalse" ; then
486         AC_MSG_CHECKING([to see if we can redefine _topdir])
487         rpm --define '_topdir /tmp' > /dev/null 2>&1
488         if test $? -eq 0 ; then
489                 AC_MSG_RESULT(yes)
490                 have_rpm=yes
491         else
492                 AC_MSG_RESULT([no, you'll have to build packages manually])
493                 have_rpm=no
494         fi
495 fi
496 AM_CONDITIONAL(HAVE_RPM, [test "x$have_rpm" = xyes])
497
498 # Debian
499 AC_CHECK_PROG(HAVE_DPKG_BUILDPACKAGE, dpkg-buildpackage, "yes", "no")
500
501 # macOS
502 AC_CHECK_PROG(HAVE_XCODEBUILD, xcodebuild, "yes", "no")
503 AC_CHECK_PROG(HAVE_HDIUTIL, hdiutil, "yes", "no")
504 AC_CHECK_PROG(HAVE_BLESS, bless, "yes", "no")
505
506 if test x$HAVE_XCODEBUILD = xyes -a x$HAVE_HDIUTIL = xyes \
507      -a x$HAVE_BLESS = xyes ; then
508   HAVE_OSX_PACKAGING=yes
509 else
510   HAVE_OSX_PACKAGING=no
511 fi
512 AC_SUBST(HAVE_OSX_PACKAGING)
513
514 #
515 # Use this as a proxy for "is this macOS" (just in case somebody actually
516 # built and installed Darwin as an OS, perhaps with some X11-based GUI,
517 # don't look for Darwin).
518 #
519 AC_CHECK_PROG(have_sw_vers, sw_vers, "yes", "no")
520 AM_CONDITIONAL(NOT_MACOS, test "x$have_sw_vers" = "xno")
521
522 # Shellcheck
523 AC_CHECK_PROG(HAVE_SHELLCHECK, shellcheck, "yes", "no")
524 AM_CONDITIONAL(HAVE_SHELLCHECK, test x$HAVE_SHELLCHECK = xyes)
525
526 #
527 # Check compiler vendor. For GCC this will be 'gnu' and for Clang 'clang'.
528 #
529 AX_COMPILER_VENDOR
530 if test "x$CXX" != "x" ; then
531         AC_LANG_PUSH(C++)
532         AX_COMPILER_VENDOR
533         AC_LANG_POP
534 fi
535
536 #
537 # Some compilers have to be told to fail when passed an unknown -W flag;
538 # make sure we do that.
539 #
540 AC_WIRESHARK_CHECK_UNKNOWN_WARNING_OPTION_ERROR
541
542 #
543 # Some C++ compilers have to be told to fail when passed a -W flag that
544 # they don't think should apply to C++; make sure we do that.
545 #
546 AC_WIRESHARK_CHECK_NON_CXX_WARNING_OPTION_ERROR
547
548 #
549 # The following are for C and C++
550 #
551 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wall)
552 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wextra)
553 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wendif-labels)
554 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wpointer-arith)
555 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wformat-security)
556 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-fwrapv)
557 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-fno-strict-overflow)
558 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-fno-delete-null-pointer-checks)
559 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wvla)
560 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Waddress)
561 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wattributes)
562 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wdiv-by-zero)
563 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wignored-qualifiers)
564 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wpragmas)
565 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wno-overlength-strings)
566 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wno-long-long)
567 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wheader-guard)
568
569 #
570 # The following are C only, not C++
571 #
572 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wc++-compat, C)
573 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wunused-const-variable, C)
574
575 #
576 # XXX - OK for C++?
577 #
578 # Make sure -Wshadow doesn't complain about variables in function and
579 # function pointer declarations shadowing other variables; if not, don't
580 # turn it on, as some versions of GCC (including the one in at least
581 # some Xcode versions that came with Mac OS X 10.5) complain about
582 # that.
583 #
584 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wshadow, C,
585   [
586 extern int bar(int a);
587 extern int foo(int);
588
589 int
590 foo(int a)
591 {
592         int (*fptr)(int a) = bar;
593
594         return fptr(a) * 2;
595 }
596   ],
597   [warns about variables in function declarations shadowing other variables])
598
599 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wno-pointer-sign, C)
600 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wold-style-definition, C)
601 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wstrict-prototypes, C)
602
603 # Unfortunately some versions of gcc generate logical-op warnings when strchr()
604 # is given a constant string.
605 # gcc versions 4.3.2 and 4.4.5 are known to have the problem.
606 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wlogical-op, C,
607   [
608 #include <string.h>
609
610 int foo(const char *, int);
611 int bar(void);
612
613 int
614 foo(const char *sep, int c)
615 {
616         if (strchr (sep, c) != NULL)
617                 return 1;
618         else
619                 return 0;
620 }
621
622 int
623 bar(void)
624 {
625         return foo("<", 'a');
626 }
627   ],
628   [generates warnings from strchr()])
629
630 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wjump-misses-init, C)
631 # The Qt headers generate a ton of shortening errors on 64-bit systems
632 # so only enable this for C for now.
633 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wshorten-64-to-32, C)
634
635 #
636 # Implicit function declarations are an error in C++ and most
637 # likely a programming error in C. Turn -Wimplicit-int and
638 # -Wimplicit-function-declaration into an error by default.
639 #
640 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Werror=implicit, C)
641
642 # Clang only. Avoid "argument unused during compilation" warnings
643 # (for example, when getting the -gsplit-dwarf option or
644 # when combining -fwrapv with -fno-strict-overflow)
645 if test x"$ax_cv_c_compiler_vendor" = xclang; then
646         AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Qunused-arguments, C)
647 fi
648 if test x"$ax_cv_cxx_compiler_vendor" = xclang; then
649         AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Qunused-arguments, CXX)
650 fi
651
652 #
653 # Use the faster pre gcc 4.5 floating point precision if available.
654 #
655 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-fexcess-precision=fast)
656
657 #
658 # Try to have the compiler default to hiding symbols, so that only
659 # symbols explicitly exported with WS_DLL_PUBLIC will be visible
660 # outside (shared) libraries; that way, more UN*X builds will catch
661 # failures to export symbols, rather than having that fail only on
662 # Windows.
663 #
664 # GCC and GCC-compatible compilers
665 #
666 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-fvisibility=hidden)
667 if test "x$can_add_to_cflags" = "xno"
668 then
669         #
670         # Sun^WOracle C.
671         #
672         AC_WIRESHARK_COMPILER_FLAGS_CHECK(-xldscope=hidden)
673         if test "x$can_add_to_cflags" = "xno"
674         then
675                 # TODO add other ways of hiding symbols
676                 AC_MSG_WARN(Compiler will export all symbols from shared libraries)
677         fi
678 fi
679
680 #
681 # Try to add some additional checks to CFLAGS.
682 # These are not enabled by default, because the warnings they produce
683 # are very hard or impossible to eliminate.
684 #
685 AC_ARG_ENABLE(extra-compiler-warnings,
686   AC_HELP_STRING( [--enable-extra-compiler-warnings],
687                   [do additional compiler warnings @<:@default=no@:>@]),
688 [
689         wireshark_extra_flags=$enableval
690         if test $enableval != no
691         then
692                 #
693                 # The following are for C and C++
694                 #
695                 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wpedantic)
696                 #
697                 # As we use variadic macros, we don't want warnings
698                 # about them, even with -Wpedantic.
699                 #
700                 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wno-variadic-macros)
701                 #
702                 # Various code blocks this one.
703                 #
704                 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Woverflow)
705                 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-fstrict-overflow -Wstrict-overflow=4)
706                 #
707                 # Due to various places where APIs we don't control
708                 # require us to cast away constness, we can probably
709                 # never enable this one with -Werror.
710                 #
711                 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wcast-qual)
712                 #
713                 # Some generated ASN.1 dissectors block this one;
714                 # multiple function declarations for the same
715                 # function are being generated.
716                 #
717                 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wredundant-decls)
718                 #
719                 # Some loops are safe, but it's hard to convince the
720                 # compiler of that.
721                 #
722                 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wunsafe-loop-optimizations)
723                 #
724                 # All the registration functions block these for now.
725                 #
726                 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wmissing-prototypes)
727                 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wmissing-declarations)
728                 #
729                 # A bunch of "that might not work on SPARC" code blocks
730                 # this one for now.
731                 #
732                 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wcast-align)
733                 #
734                 # Works only with Clang
735                 #
736                 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wunreachable-code)
737                 #
738                 # Works only with Clang but generates a lot of warnings
739                 # (about glib library not using Doxygen)
740                 #
741                 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wdocumentation)
742
743                 #
744                 # The following are C only, not C++
745                 #
746                 # Due to various places where APIs we don't control
747                 # require us to cast away constness, we can probably
748                 # never enable this one with -Werror.
749                 #
750                 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wbad-function-cast, C)
751
752                 # Works only with GCC 7
753                 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-Wduplicated-branches)
754
755         fi
756 ])
757
758 # Try to add ASAN address analyze.
759 # Only needed for analyse
760 #
761 AC_ARG_ENABLE(asan,
762   AC_HELP_STRING( [--enable-asan],
763                   [Enable AddressSanitizer (ASAN) for debugging (degrades performance)@<:@default=no@:>@]),
764 [
765         #
766         # With Clang >= 3.5 Leak detection is enable by default
767         # and no yet all leak is fixed...
768         # use ASAN_OPTIONS=detect_leaks=0 to disable detect_leaks
769         #
770         # XXX shouldn't this also be added to LDFLAGS?
771         AC_WIRESHARK_COMPILER_FLAGS_CHECK(-fsanitize=address)
772
773         # Disable ASAN for build-time tools, e.g. lemon
774         WS_CFLAGS_saved="$WS_CFLAGS"
775         WS_LDFLAGS_saved="$WS_LDFLAGS"
776         AC_WIRESHARK_COMPILER_FLAGS_CHECK(-fno-sanitize=all, C)
777         if test "x$can_add_to_cflags" = "xyes"
778         then
779                 NO_SANITIZE_CFLAGS="-fno-sanitize=all"
780                 NO_SANITIZE_LDFLAGS="-fno-sanitize=all"
781         fi
782         WS_CFLAGS="$WS_CFLAGS_saved"
783         WS_LDFLAGS="$WS_LDFLAGS_saved"
784
785 ])
786 AC_SUBST(NO_SANITIZE_CFLAGS)
787 AC_SUBST(NO_SANITIZE_LDFLAGS)
788
789 # Try to enable UndefinedBehaviorSanitizer.
790 #
791 AC_ARG_ENABLE(ubsan,
792   AC_HELP_STRING( [--enable-ubsan],
793                   [Enable UndefinedBehaviorSanitizer (UBSan) for debugging@<:@default=no@:>@]),
794 [
795         #
796         # Available since Clang >= 3.3 and GCC >= 4.9
797         #
798         # XXX shouldn't this also be added to LDFLAGS?
799         AC_WIRESHARK_COMPILER_FLAGS_CHECK(-fsanitize=undefined)
800
801 ])
802
803 # Add check hf conflict..
804 #
805 AC_ARG_ENABLE(checkhf-conflict,
806   AC_HELP_STRING( [--enable-checkhf-conflict],
807                   [Enable hf conflict check for debugging (start-up may be slower)@<:@default=no@:>@]),
808 [
809         AC_DEFINE(ENABLE_CHECK_FILTER, 1, [Enable hf conflict check])
810 ])
811
812 AC_WIRESHARK_LDFLAGS_CHECK([-Wl,--as-needed])
813 ###AC_WIRESHARK_LDFLAGS_CHECK([-Wl,-M])
814 ###AC_WIRESHARK_LDFLAGS_CHECK([-Wl,--cref])
815 # AC_WIRESHARK_LDFLAGS_CHECK([-flto])
816 # AC_WIRESHARK_LDFLAGS_CHECK([-fwhopr])
817 # AC_WIRESHARK_LDFLAGS_CHECK([-fwhole-program])
818
819 #
820 # Put -fPIE in PIE_CFLAGS and -pie in PIE_LDFLAGS if we can use them,
821 # so that we can build dumpcap PIE - it may run with elevated
822 # privileges, and using PIE means the OS can run it at random locations
823 # in the address space to make attacks more difficult.
824 #
825
826 WS_CFLAGS_saved="$WS_CFLAGS"
827 WS_LDFLAGS_saved="$WS_LDFLAGS"
828 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-fPIE, C)
829 if test "x$can_add_to_cflags" = "xyes"
830 then
831         AC_WIRESHARK_LDFLAGS_CHECK([-fPIE -pie])
832         if test "x$can_add_to_ldflags" = "xyes"
833         then
834                 # We can use PIE
835                 PIE_CFLAGS="-fPIE"
836                 PIE_LDFLAGS="-pie"
837         fi
838 fi
839 WS_CFLAGS="$WS_CFLAGS_saved"
840 WS_LDFLAGS="$WS_LDFLAGS_saved"
841 AC_SUBST(PIE_CFLAGS)
842 AC_SUBST(PIE_LDFLAGS)
843
844 WS_CFLAGS_saved="$WS_CFLAGS"
845 AC_WIRESHARK_COMPILER_FLAGS_CHECK(-msse4.2, C)
846 if test "x$can_add_to_cflags" = "xyes"
847 then
848         #
849         # The compiler supports -msse4.2; use that to enable SSE 4.2.
850         #
851         # We only want to apply -msse4.2 to
852         # wsutil/ws_mempbrk_sse42.c, as the SSE4.2 code there
853         # is run only if the hardware supports it, but other
854         # code would do no such checks.
855         #
856         ac_sse4_2_flag=-msse4.2
857 else
858         #
859         # Try -xarch=sse4_2; that's the flag for Sun's compiler.
860         #
861         AC_WIRESHARK_COMPILER_FLAGS_CHECK(-xarch=sse4_2, C)
862         if test "x$can_add_to_cflags" = "xyes"
863         then
864                 #
865                 # The compiler supports -xarch=sse4_2; use that to
866                 # enable SSE 4.2.
867                 ac_sse4_2_flag=-xarch=sse4_2
868         fi
869 fi
870 WS_CFLAGS="$WS_CFLAGS_saved"
871
872 if test "x$ac_sse4_2_flag" != x; then
873         #
874         # OK, we have a compiler flag to enable SSE 4.2.
875         #
876         # Make sure we have the necessary headers for the SSE4.2 intrinsics
877         # and that we can use them.
878         #
879         # First, check whether we have emmintrin.h and can use it
880         # *without* the SSE 4.2 flag.
881         #
882         AC_MSG_CHECKING([whether there is emmintrin.h header and we can use it])
883         AC_TRY_COMPILE(
884                 [#include <emmintrin.h>],
885                 [return 0;],
886                 [
887                         emmintrin_h_works=yes
888                         AC_MSG_RESULT([yes])
889                 ],
890                 [
891                         emmintrin_h_works=no
892                         AC_MSG_RESULT([no])
893                 ]
894         )
895
896         #
897         # OK, if that works, see whether we have nmmintrin.h and
898         # can use it *with* the SSE 4.2 flag.
899         #
900         if test "x$emmintrin_h_works" = "xyes"; then
901                 #
902                 # Add the SSE4.2 flags to the beginning of CFLAGS,
903                 # in case the user explicitly specified -mno-sse4.2
904                 # (or in case Gentoo's build tools did so); if they
905                 # did so, we only want this to work if we can use
906                 # the #pragma to override that for ws_mempbrk_sse42.c,
907                 # and putting it at the beginning means that the
908                 # CFLAGS setting in the environment will come later
909                 # and override it.
910                 #
911                 AC_MSG_CHECKING([whether there is nmmintrin.h header and we can use it])
912                 saved_CFLAGS="$CFLAGS"
913                 CFLAGS="$ac_sse4_2_flag $WS_CFLAGS $CFLAGS"
914                 AC_TRY_COMPILE(
915                         [#include <nmmintrin.h>],
916                         [return 0;],
917                         [
918                                 have_sse42=yes
919                                 AC_DEFINE(HAVE_SSE4_2, 1, [Support SSSE4.2 (Streaming SIMD Extensions 4.2) instructions])
920                                 CFLAGS_SSE42="$ac_sse4_2_flag"
921                                 AC_MSG_RESULT([yes])
922                         ],
923                         [
924                                 have_sse42=no
925                                 AC_MSG_RESULT([no])
926                         ]
927                 )
928                 CFLAGS="$saved_CFLAGS"
929         else
930                 have_sse42=no
931         fi
932 else
933         have_sse42=no
934 fi
935 dnl build libwsutil_sse42 only if there is SSE4.2
936 AM_CONDITIONAL(SSE42_SUPPORTED, test "x$have_sse42" = "xyes")
937 AC_SUBST(CFLAGS_SSE42)
938
939 #
940 # If we're running GCC or clang define _U_ to be "__attribute__((unused))"
941 # so we can use _U_ to flag unused function parameters and not get warnings
942 # about them. Otherwise, define _U_ to be an empty string so that _U_ used
943 # to flag an unused function parameters will compile with other compilers.
944 #
945 # XXX - similar hints for other compilers?
946 #
947 if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
948   AC_DEFINE(_U_, __attribute__((unused)), [Hint to the compiler that a function parameters is not used])
949   AC_DEFINE(WS_NORETURN, __attribute((noreturn)), [Hint to the compiler that a function never returns])
950 else
951   AC_DEFINE(_U_, , [Hint to the compiler that a function parameters is not used])
952   AC_DEFINE(WS_NORETURN, , [Hint to the compiler that a function never returns])
953 fi
954
955 # If we're running GCC or CLang, use FORTIFY_SOURCE=2
956 #  (only if the GCC 'optimization level' > 0).
957 #
958 # See: http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
959 # See: http://sourceware.org/bugzilla/show_bug.cgi?id=13979
960 #
961 # Note: FORTIFY_SOURCE is only effective for gcc optimization level > 0 (-O1, etc)
962 AC_WIRESHARK_GCC_FORTIFY_SOURCE_CHECK
963
964 #
965 # If the compiler supports GCC-style flags, enable a barrier "stop on
966 # warning".
967 # This barrier is set for a very large part of the code. However, it is
968 # typically not set for "generated" code  (flex, ans2wrs, idl2wrs, ...)
969 #
970 warnings_as_errors_default="yes"
971 AC_MSG_CHECKING(whether we should treat compiler warnings as errors)
972 AC_ARG_ENABLE(warnings-as-errors,
973   AC_HELP_STRING( [--enable-warnings-as-errors],
974                   [treat warnings as errors (only for GCC or clang) @<:@default=yes, unless extra compiler warnings are enabled@:>@]),
975 [
976   if test "x$ac_supports_gcc_flags" = "xyes" -a "x$enableval" = "xyes"; then
977     with_warnings_as_errors="yes"
978     AC_MSG_RESULT(yes)
979   else
980     with_warnings_as_errors="no"
981     AC_MSG_RESULT(no)
982   fi
983 ],
984 [
985   if test "x$ac_supports_gcc_flags" = "xyes" -a "x$wireshark_extra_flags" = "x" -a "x$warnings_as_errors_default" = "xyes"; then
986     with_warnings_as_errors="yes"
987     AC_MSG_RESULT(yes)
988   else
989     with_warnings_as_errors="no"
990     AC_MSG_RESULT(no)
991   fi
992 ])
993
994 AS_IF([test "x$with_warnings_as_errors" = "xyes"], [WERROR="-Werror"], [WERROR=""])
995 AC_SUBST(WERROR)
996 AM_CONDITIONAL(HAVE_WARNINGS_AS_ERRORS, [test "x$with_warnings_as_errors" = "xyes"])
997
998 #
999 # Add any platform-specific compiler flags needed.
1000 #
1001 AC_MSG_CHECKING(for platform-specific compiler flags)
1002 if test "x$GCC" = "xyes" ; then
1003         #
1004         # GCC - do any platform-specific tweaking necessary.
1005         #
1006         case "$host_os" in
1007         solaris*)
1008                 # the X11 headers don't automatically include prototype info
1009                 # and a lot don't include the return type
1010                 WS_CPPFLAGS="$WS_CPPFLAGS -DFUNCPROTO=15"
1011                 WS_CFLAGS="$WS_CFLAGS -Wno-return-type"
1012                 WS_CXXFLAGS="$WS_CXXFLAGS -Wno-return-type"
1013                 AC_MSG_RESULT(GCC on Solaris - added -Wno-return-type -DFUNCPROTO=15)
1014                 ;;
1015         *)
1016                 AC_MSG_RESULT(none needed)
1017                 ;;
1018         esac
1019 else
1020         #
1021         # Not GCC - assume it's the vendor's compiler.
1022         #
1023         case "$host_os" in
1024         hpux*)
1025                 #
1026                 # AC_PROG_CC_STDC should already have added whatever
1027                 # flags are necessary for ISO C - C99 if available,
1028                 # otherwise C89 - with extensions.
1029                 #
1030                 # Add +O2, for optimization, as suggested by Jost Martin.
1031                 # XXX - works with "-g"?
1032                 #
1033                 # +O2 is supported both by the C and C++ compiler.
1034                 #
1035                 WS_CFLAGS="+O2 $WS_CFLAGS"
1036                 if test "$CC" = "$CC_FOR_BUILD"; then
1037                         #
1038                         # We're building the build tools with the same
1039                         # compiler as the one with which we're building
1040                         # Wireshark, so add the flags to the flags for
1041                         # that compiler as well.
1042                         #
1043                         CFLAGS_FOR_BUILD="-Ae +O2 $CFLAGS"
1044                 fi
1045                 WS_CXXFLAGS="+O2 $WS_CXXFLAGS"
1046                 AC_MSG_RESULT(HP C/C++ compiler - added +O2)
1047                 ;;
1048         solaris*)
1049                 #
1050                 # Crank up the warning level.
1051                 #
1052                 WS_CFLAGS="$WS_CFLAGS -v"
1053                 WS_CXXFLAGS="$WS_CXXFLAGS +w2"
1054                 ;;
1055         *)
1056                 AC_MSG_RESULT(none needed)
1057                 ;;
1058         esac
1059 fi
1060
1061 #
1062 # Add any platform-specific linker flags needed.
1063 #
1064 AC_MSG_CHECKING(for platform-specific linker flags)
1065 case "$host_os" in
1066 aix*)
1067         #
1068         # If this is GCC or Clang, Add -Wl,-bbigtoc for big libraries.
1069         # XXX - what if we're using xlc?  Is that necessary?  The
1070         # xlc 7.0 manual says "Specifying -qpic=large has the same
1071         # effect as passing -bbigtoc to ld"; do we need to tell xlc,
1072         # when it's compiling, to generate different code for a large
1073         # TOC, or is that just a linker flag?  For that matter, do we
1074         # have to tell GCC or Clang to generate different code for a
1075         # large TOC?
1076         #
1077         if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
1078                 LDFLAGS_BIGSHAREDLIB="-Wl,-bbigtoc"
1079                 AC_MSG_RESULT([AIX linker with GCC or Clang - added -Wl,-bbigtoc to large shared library linker flags and -Wl,-headerpad_max_install_names -Wl,-search_paths_first and -Wl,-headerpad_max_install_names to all linker flags])
1080         fi
1081         ;;
1082 darwin*)
1083         #
1084         # Add -Wl,-single_module to the LDFLAGS used with shared
1085         # libraries, to fix some error that show up in some cases;
1086         # some Apple documentation recommends it for most shared
1087         # libraries.
1088         #
1089         LDFLAGS_SHAREDLIB="-Wl,-single_module"
1090         #
1091         # Add -Wl,-headerpad_max_install_names to the LDFLAGS, as
1092         # code-signing issues is running out of padding space.
1093         #
1094         # Add -Wl,-search_paths_first to make sure that if we search
1095         # directories A and B, in that order, for a given library, a
1096         # non-shared version in directory A, rather than a shared
1097         # version in directory B, is chosen (so we can use
1098         # --with-pcap=/usr/local to force all programs to be linked
1099         # with a static version installed in /usr/local/lib rather than
1100         # the system version in /usr/lib).
1101         #
1102         WS_LDFLAGS="-Wl,-headerpad_max_install_names -Wl,-search_paths_first $WS_LDFLAGS"
1103         AC_MSG_RESULT([Apple linker - added -Wl,-single_module to shared library linker flags and -Wl,-headerpad_max_install_names -Wl,-search_paths_first and -Wl,-headerpad_max_install_names to all linker flags])
1104         ;;
1105 cygwin*)
1106         #
1107         # Shared libraries in cygwin/Win32 must never contain
1108         # undefined symbols.
1109         #
1110         WS_LDFLAGS="$WS_LDFLAGS -no-undefined"
1111         AC_MSG_RESULT(Cygwin GNU ld - added -no-undefined)
1112         ;;
1113 *)
1114         AC_MSG_RESULT(none needed)
1115         ;;
1116 esac
1117 AC_SUBST(LDFLAGS_BIGSHAREDLIB)
1118 AC_SUBST(LDFLAGS_SHAREDLIB)
1119
1120 #
1121 # On "Darwin", which we assume to mean "macOS" rather than "iOS" or
1122 # "just Darwin" (as we don't currently support iOS, and as I don't
1123 # think you can build and run "just Darwin" as an OS for PCs), we
1124 # arrange to build some programs with Application Services so they
1125 # can launch Web browsers and Finder windows, arrange to build some
1126 # programs with System Configuration so they can get "friendly names"
1127 # and other information about interfaces, and build any programs that
1128 # use either of those frameworks or that report version information
1129 # with Core Foundation as the frameworks in question use it and as we
1130 # get version information from plists and thus need Core Foundation
1131 # to process those plists.
1132 #
1133 have_macos_frameworks=no
1134 case "$host_os" in
1135 darwin*)
1136         have_macos_frameworks=yes
1137         AC_DEFINE(HAVE_MACOS_FRAMEWORKS, 1, [Define to 1 if you have macOS frameworks])
1138         APPLICATIONSERVICES_FRAMEWORKS="-framework ApplicationServices"
1139         SYSTEMCONFIGURATION_FRAMEWORKS="-framework SystemConfiguration"
1140         COREFOUNDATION_FRAMEWORKS="-framework CoreFoundation"
1141
1142         #
1143         # OK, so we have the macOS frameworks; do they include
1144         # CFPropertyListCreateWithStream, or do we have
1145         # to fall back on CFPropertyListCreateFromStream?
1146         # (They only differ in the error return, which we
1147         # don't care about.  And, no, we shouldn't just
1148         # use CFPropertyListCreateFromStream, because it's
1149         # deprecated in newer releases.)
1150         #
1151         ac_save_LIBS="$LIBS"
1152         LIBS="$LIBS $COREFOUNDATION_FRAMEWORKS"
1153         AC_CHECK_FUNCS(CFPropertyListCreateWithStream)
1154         LIBS="$ac_save_LIBS"
1155         ;;
1156 esac
1157 AC_SUBST(APPLICATIONSERVICES_FRAMEWORKS)
1158 AC_SUBST(SYSTEMCONFIGURATION_FRAMEWORKS)
1159 AC_SUBST(COREFOUNDATION_FRAMEWORKS)
1160 AM_CONDITIONAL(HAVE_MACOS_FRAMEWORKS, [test "x$have_macos_frameworks" = "xyes"])
1161
1162 #
1163 # If we're running Solaris, and LD_LIBRARY_PATH is defined, add it as a
1164 # link directory.
1165 #
1166 case "$host_os" in
1167   solaris*)
1168     AC_MSG_CHECKING(for LD_LIBRARY_PATH, since you appear to be running Solaris)
1169     if test x$LD_LIBRARY_PATH != x ; then
1170       LIBS="$LIBS -R$LD_LIBRARY_PATH"
1171       AC_MSG_RESULT(yes -- added LD_LIBRARY_PATH to run-time linker path)
1172     else
1173       AC_MSG_RESULT(no -- this may be a problem in a few seconds)
1174     fi
1175   ;;
1176 esac
1177
1178 # Enable/disable wireshark
1179 AC_ARG_ENABLE(wireshark,
1180   AC_HELP_STRING( [--enable-wireshark],
1181                   [build the Wireshark GUI (with Gtk+, Qt, or both) @<:@default=yes@:>@]),
1182     enable_wireshark=$enableval,enable_wireshark=yes)
1183 AM_CONDITIONAL(BUILDING_WIRESHARK, test x$enable_wireshark = xyes)
1184
1185 AC_ARG_ENABLE(packet-editor,
1186   AC_HELP_STRING( [--enable-packet-editor],
1187                   [add support for packet editor in Wireshark @<:@default=yes@:>@]),
1188     enable_packet_editor=$enableval,enable_packet_editor=yes)
1189 if test x$enable_packet_editor = xyes; then
1190         AC_DEFINE(WANT_PACKET_EDITOR, 1, [Support for packet editor])
1191 fi
1192
1193 AC_ARG_ENABLE(profile-build,
1194   AC_HELP_STRING( [--enable-profile-build],
1195                   [build profile-ready binaries @<:@default=no@:>@]),
1196     enable_profile_build=$enableval,enable_profile_build=no)
1197 AM_CONDITIONAL(USE_PROFILE_BUILD, test x$enable_profile_build = xyes)
1198 AC_MSG_CHECKING(if profile builds must be generated)
1199 if test "x$enable_profile_build" = "xyes" ; then
1200         if test "x$GCC" = "xyes" -o "x$CLANG" = "xyes" ; then
1201                 AC_MSG_RESULT(yes)
1202                 WS_CFLAGS="-pg $WS_CFLAGS"
1203                 WS_CXXFLAGS="-pg $WS_CXXFLAGS"
1204         else
1205                 AC_MSG_RESULT(no)
1206                 echo "Building profile binaries currently only supported for GCC and clang."
1207         fi
1208 else
1209         AC_MSG_RESULT(no)
1210 fi
1211
1212 GLIB_MIN_VERSION=2.22.0
1213 AC_SUBST(GLIB_MIN_VERSION)
1214 # GLib checks; we require GLib $GLIB_MIN_VERSION or later, and require gmodule
1215 # support, as we need that for dynamically loading plugins.
1216 #
1217 # Release dates for GLib versions:
1218 # 2.14.0: 03 Aug 2007
1219 # 2.16.0: 10 Mar 2008
1220 # 2.18.0: 02 Sep 2008
1221 # 2.20.0: 13 Mar 2009
1222 # 2.22.0: 22 Sep 2009
1223 # 2.24.0: 28 Mar 2010
1224 # 2.26.0: 27 Sep 2010
1225 # 2.28.0: 08 Feb 2011
1226 # 2.30.0: 27 Sep 2011
1227 # 2.32.0: 24 Mar 2012
1228 # 2.34.0: 24 Sep 2012
1229 # 2.36.0: 25 Mar 2013
1230 # 2.38.0: 23 Sep 2013
1231 # 2.40.0: 24 Mar 2014
1232 # 2.42.0: 22 Sep 2014
1233 # 2.44.0: 23 Mar 2014
1234 # 2.46.0: 25 Sep 2015
1235
1236 PKG_WIRESHARK_CHECK_SYSTEM_MODULES([GLIB],
1237         [glib-2.0 >= $GLIB_MIN_VERSION gthread-2.0 >= $GLIB_MIN_VERSION gmodule-2.0 >= $GLIB_MIN_VERSION],
1238         [GLIB_VERSION=`$PKG_CONFIG --modversion glib-2.0`],
1239         [AC_MSG_ERROR([GLib $GLIB_MIN_VERSION or later not found.])])
1240
1241 # Error out if a glib header other than a "top level" header
1242 #  (glib.h, glib-object.h, gio.h) or certain other headers( e.g.,gmodule.h)
1243 #  is used.
1244 AX_APPEND_FLAG([-DG_DISABLE_SINGLE_INCLUDES], [GLIB_CONFIG])
1245
1246 # Error out on the usage of deprecated glib functions
1247 AX_APPEND_FLAG([-DG_DISABLE_DEPRECATED], [GLIB_CONFIG])
1248
1249 GLIB_CFLAGS="$GLIB_CONFIG $GLIB_CFLAGS"
1250 AC_SUBST(GLIB_CFLAGS)
1251 AC_SUBST(GLIB_LIBS)
1252
1253 GTK2_MIN_VERSION=2.12.0
1254 AC_SUBST(GTK2_MIN_VERSION)
1255 GTK3_MIN_VERSION=3.0.0
1256 AC_SUBST(GTK3_MIN_VERSION)
1257 QT_MIN_VERSION=4.8.0
1258 AC_SUBST(QT_MIN_VERSION)
1259 # GTK+ and Qt checks; we require GTK+ $GTK2_MIN_VERSION or later or
1260 # GTK3_MIN_VERSION or later or Qt $QT_MIN_VERSION or later.
1261 #
1262 # We only do those if we're going to be building Wireshark;
1263 # otherwise, we don't have any GUI to build, so we don't use
1264 # GTK+ or Qt.
1265 #
1266 # We don't add $GTK_LIBS or $Qt_LIBS to LIBS, because we don't want to
1267 # force all programs to be built with GTK+ or Qt.
1268 #
1269 # For a list of library versions and their support across different platforms,
1270 # see https://wiki.wireshark.org/Development/Support_library_version_tracking
1271
1272 have_qt=no
1273 have_gtk=no
1274 if test "x$enable_wireshark" = "xyes"; then
1275         if test "x$with_qt" != "xno"; then
1276                 #
1277                 # Qt was specified; make sure we have a C++ compiler.
1278                 #
1279                 if test -z "$CXX"; then
1280                         AC_MSG_ERROR(Need a working C++ compiler to build Wireshark with Qt)
1281                 fi
1282
1283                 #
1284                 # Now make sure we have Qt and, if so, add the flags
1285                 # for it to CFLAGS and CXXFLAGS.
1286                 #
1287                 AC_WIRESHARK_QT_CHECK($QT_MIN_VERSION, "$with_qt",
1288                 [
1289                         AC_SUBST(Qt_CFLAGS)
1290                         AC_SUBST(Qt_LIBS)
1291                         have_qt=yes
1292                         GUI_CONFIGURE_FLAGS="$GUI_CONFIGURE_FLAGS --with-qt"
1293
1294                         #
1295                         # We're building with Qt, so we need the Qt build
1296                         # tools in order to build the Wireshark GUI.
1297                         # We've found a particular major version of Qt,
1298                         # and we want that version's build tools; for
1299                         # example, the Qt 4 version of uic produces files
1300                         # that include Qt headers with paths that work
1301                         # with Qt 4 but not Qt 5, so we can't use the
1302                         # Qt 4 version of uic if we're building with Qt 5.
1303                         AC_WIRESHARK_QT_TOOL_CHECK(UIC, uic, "$qt_version")
1304                         AC_SUBST(UIC)
1305                         AC_WIRESHARK_QT_TOOL_CHECK(MOC, moc, "$qt_version")
1306                         AC_SUBST(MOC)
1307                         AC_WIRESHARK_QT_TOOL_CHECK(RCC, rcc, "$qt_version")
1308                         AC_SUBST(RCC)
1309                         AC_WIRESHARK_QT_TOOL_CHECK_LRELEASE("$qt_version")
1310                         AC_SUBST(LRELEASE)
1311
1312                         #
1313                         # On Darwin, make sure we're using Qt5 or later.
1314                         # If so, find where the Qt frameworks are located
1315                         # and add that to the rpath, just in case this is
1316                         # Qt 5.5 or later and the frameworks have an
1317                         # install name that begins with @rpath and aren't
1318                         # installed in a frameworks directory that's
1319                         # searched by default.
1320                         #
1321                         case "$host_os" in
1322                         darwin*)
1323                                 if test $qt_version -le 4
1324                                 then
1325                                         AC_MSG_ERROR([macOS builds should use Qt5])
1326                                 else
1327                                         Qt_LDFLAGS="-Wl,-rpath,"`$PKG_CONFIG --libs Qt${qt_version}Core | sed -e 's/-F//' -e 's/ -framework.*//'`
1328                                 fi
1329                                 ;;
1330                         esac
1331                         AC_SUBST(Qt_LDFLAGS)
1332
1333                         if test -z "${MOC_OPTIONS+1}"
1334                         then
1335                                 # Squelch moc verbose "nothing to do" output
1336                                 if test $QT_VERSION_MAJOR -eq 5
1337                                 then
1338                                         MOC_OPTIONS="-nn"
1339                                 elif test $QT_VERSION_MAJOR -eq 4 -a $QT_VERSION_MINOR -ge 8
1340                                 then
1341                                         MOC_OPTIONS="-nn"
1342                                 fi
1343                         fi
1344                         AC_SUBST(MOC_OPTIONS)
1345                 ],
1346                 [
1347                         case "$with_qt" in
1348
1349                         unspecified)
1350                                 #
1351                                 # They didn't explicitly ask for Qt,
1352                                 # so just don't build with it.
1353                                 #
1354                                 ;;
1355
1356                         yes)
1357                                 AC_MSG_ERROR([Qt is not available])
1358                                 ;;
1359
1360                         4)
1361                                 AC_MSG_ERROR([Qt 4 is not available])
1362                                 ;;
1363
1364                         5)
1365                                 AC_MSG_ERROR([Qt 5 is not available])
1366                                 ;;
1367                         esac
1368                 ])
1369         fi
1370
1371         for want_gtk_version in $with_gtk; do
1372                 AS_CASE([$want_gtk_version],
1373                   [3], [PKG_WIRESHARK_CHECK_SYSTEM_MODULES([GTK],
1374                         [gtk+-3.0 >= $GTK3_MIN_VERSION glib-2.0 >= $GLIB_MIN_VERSION gthread-2.0 >= $GLIB_MIN_VERSION gmodule-2.0 >= $GLIB_MIN_VERSION],
1375                         [
1376                           have_gtk=yes
1377                           GTK_VERSION=`$PKG_CONFIG --modversion gtk+-3.0`
1378                           GUI_CONFIGURE_FLAGS="$GUI_CONFIGURE_FLAGS --with-gtk=3"
1379                         ],
1380                         [
1381                           :
1382                         ])],
1383                   [2], [PKG_WIRESHARK_CHECK_SYSTEM_MODULES([GTK],
1384                         [gtk+-2.0 >= $GTK2_MIN_VERSION glib-2.0 >= $GLIB_MIN_VERSION gthread-2.0 >= $GLIB_MIN_VERSION gmodule-2.0 >= $GLIB_MIN_VERSION],
1385                         [
1386                           have_gtk=yes
1387                           GTK_VERSION=`$PKG_CONFIG --modversion gtk+-2.0`
1388                           GUI_CONFIGURE_FLAGS="$GUI_CONFIGURE_FLAGS --with-gtk=2"
1389                         ],
1390                         [
1391                           :
1392                         ])],
1393                   [fail3], [AC_MSG_ERROR([GTK+ 3 was requested but is not available])],
1394                   [fail2], [AC_MSG_ERROR([GTK+ 2 was requested but is not available])],
1395                   [fail],  [AC_MSG_ERROR([GTK+ was requested but is not available])])
1396
1397                 AS_IF([test "x$have_gtk" = xyes], [break])
1398         done
1399
1400         if test "$have_gtk" = "yes" ; then
1401                 # If we have GTK then add flags for it.
1402                 #
1403                 # GLib flags first
1404                 #
1405                 GTK_CONFIG="$GLIB_CONFIG"
1406
1407                 gtk_major_version=`echo $GTK_VERSION | cut -d. -f1`
1408                 gtk_minor_version=`echo $GTK_VERSION | cut -d. -f2`
1409
1410                 AX_APPEND_FLAG([-DGDK_DISABLE_DEPRECATED], [GTK_CONFIG])
1411                 if test \( $gtk_major_version -eq 3 -a $gtk_minor_version -ge 10 \) ; then
1412                         ## Allow use of deprecated & disable deprecated warnings if Gtk >= 3.10;
1413                         ##  The deprecations in Gtk 3.10 will not be fixed ...
1414                         AX_APPEND_FLAG([-DGDK_DISABLE_DEPRECATION_WARNINGS], [GTK_CONFIG])
1415                 else
1416                         AX_APPEND_FLAG([-DGTK_DISABLE_DEPRECATED], [GTK_CONFIG])
1417                 fi
1418                 AX_APPEND_FLAG([-DGTK_DISABLE_SINGLE_INCLUDES], [GTK_CONFIG])
1419                 if test ! \( $gtk_major_version -eq 2 -a $gtk_minor_version -lt 20 \) ; then
1420                         # Enable GSEAL when building with GTK > 2.20
1421                         # (Versions prior to 2.22 lacked some necessary accessors.)
1422                         AX_APPEND_FLAG([-DGSEAL_ENABLE], [GTK_CONFIG])
1423                 fi
1424
1425                 GTK_CFLAGS="$GTK_CONFIG $GTK_CFLAGS"
1426         fi
1427 fi
1428
1429 AC_SUBST(GTK_CFLAGS)
1430 AC_SUBST(GTK_LIBS)
1431 AC_SUBST(GUI_CONFIGURE_FLAGS)
1432
1433 # Check for GTK GUI support for GResource pixbufs
1434 have_gresource_pixbuf=no
1435 if test "x$have_gtk" = "xyes"; then
1436         AC_MSG_CHECKING(whether GDK-Pixbuf can load data using GResource)
1437         PKG_CHECK_EXISTS([gio-2.0 >= 2.32 gdk-pixbuf-2.0 >= 2.26],
1438           [
1439            AC_MSG_RESULT(yes)
1440            AC_DEFINE(HAVE_GDK_GRESOURCE, 1, [Defined if GResource is supported])
1441            have_gresource_pixbuf=yes
1442           ],
1443           [AC_MSG_RESULT(no)])
1444 fi
1445 AM_CONDITIONAL(HAVE_GRESOURCE_PIXBUF, test "x$have_gresource_pixbuf" = "xyes")
1446
1447 if test "$have_gtk" = "yes" -a "$have_qt" = "yes" ; then
1448         # We have both GTK and Qt and thus will be building both wireshark
1449         # and wireshark-gtk.
1450
1451         wireshark_bin="wireshark\$(EXEEXT) wireshark-gtk\$(EXEEXT)"
1452         wireshark_man="wireshark.1"
1453         wireshark_SUBDIRS="ui/qt ui/gtk"
1454 elif test "$have_gtk" = "no" -a "$have_qt" = "yes" ; then
1455         # We don't have GTK+ but we have Qt.
1456
1457         wireshark_bin="wireshark\$(EXEEXT)"
1458         wireshark_man="wireshark.1"
1459         wireshark_SUBDIRS="ui/qt"
1460 elif test "$have_gtk" = "yes" -a "$have_qt" = "no" ; then
1461         # We have GTK+ but not Qt.
1462
1463         wireshark_bin="wireshark-gtk\$(EXEEXT)"
1464         wireshark_man="wireshark.1"
1465         wireshark_SUBDIRS="ui/gtk"
1466         OSX_APP_FLAGS="$OSX_APP_FLAGS -gtk"
1467         OSX_DMG_FLAGS="-gtk"
1468 elif test "$have_gtk" = "no" -a "$have_qt" = "no" ; then
1469         # We have neither GTK+ nor Qt.
1470         #
1471         # If they didn't explicitly say "--disable-wireshark",
1472         # fail (so that, unless they explicitly indicated that
1473         # they don't want Wireshark, we stop so they know they
1474         # won't be getting Wireshark unless they fix the GTK+/Qt
1475         # problem).
1476         #
1477         if test "x$enable_wireshark" = "xyes"; then
1478                 if test "$with_qt" != "no" -a "$with_gtk" != "no" ; then
1479                         AC_MSG_ERROR([Neither Qt nor GTK+ are available, so Wireshark can't be compiled])
1480                 elif test "$with_qt" != "no" -a "$with_gtk" = "no" ; then
1481                         AC_MSG_ERROR([Qt is not available and GTK+ was not requested, so Wireshark can't be compiled])
1482                 elif test "$with_qt" = "no" -a "$with_gtk" != "no" ; then
1483                         AC_MSG_ERROR([Qt was not requested and GTK+ is not available, so Wireshark can't be compiled])
1484                 elif test "$with_qt" = "no" -a "$with_gtk" = "no" ; then
1485                         AC_MSG_ERROR([Neither Qt nor GTK+ were requested, so Wireshark can't be compiled])
1486                 fi
1487         fi
1488         wireshark_bin=""
1489         wireshark_man=""
1490         wireshark_SUBDIRS=""
1491 fi
1492
1493 #
1494 # Check whether GLib modules are supported, to determine whether we
1495 # can support plugins.
1496 #
1497
1498 AC_CACHE_CHECK([whether GLib supports loadable modules],
1499                [ac_cv_glib_supports_modules], [
1500 ac_save_CFLAGS="$CFLAGS"
1501 ac_save_LIBS="$LIBS"
1502 CFLAGS="$WS_CFLAGS $GLIB_CFLAGS $CFLAGS"
1503 LIBS="$LIBS $GLIB_LIBS"
1504 AC_TRY_RUN([
1505 #include <glib.h>
1506 #include <gmodule.h>
1507 #include <stdio.h>
1508 #include <stdlib.h>
1509
1510 int
1511 main ()
1512 {
1513   if (g_module_supported())
1514     return 0;   /* success */
1515   else
1516     return 1;   /* failure */
1517 }
1518 ], ac_cv_glib_supports_modules=yes, ac_cv_glib_supports_modules=no,
1519    [echo $ac_n "cross compiling; assumed OK... $ac_c"
1520     ac_cv_glib_supports_modules=yes])
1521 CFLAGS="$ac_save_CFLAGS"
1522 LIBS="$ac_save_LIBS"
1523 ])
1524 if test "$ac_cv_glib_supports_modules" = yes ; then
1525   have_plugins=yes
1526 else
1527   have_plugins=no
1528 fi
1529
1530 #
1531 # If we have <dlfcn.h>, check whether we have dladdr.
1532 #
1533 if test "$ac_cv_header_dlfcn_h" = "yes"
1534 then
1535         #
1536         # Use GLib compiler flags and linker flags; GLib's gmodule
1537         # stuff uses the dl APIs if available, so it might know
1538         # what flags are needed.
1539         #
1540         ac_save_CFLAGS="$CFLAGS"
1541         ac_save_LIBS="$LIBS"
1542         CFLAGS="$WS_CFLAGS $GLIB_CFLAGS $CFLAGS"
1543         LIBS="$LIBS $GLIB_LIBS"
1544         AC_CHECK_FUNCS(dladdr)
1545         if test x$ac_cv_func_dladdr = xno
1546         then
1547                 #
1548                 # OK, try it with -ldl, in case you need that to get
1549                 # dladdr().  For some reason, on Linux, that's not
1550                 # part of the GLib flags; perhaps GLib itself is
1551                 # linked with libdl, so that you can link with
1552                 # Glib and it'll pull libdl in itself.
1553                 #
1554                 LIBS="$LIBS -ldl"
1555                 AC_CHECK_FUNCS(dladdr)
1556         fi
1557         CFLAGS="$ac_save_CFLAGS"
1558         LIBS="$ac_save_LIBS"
1559 fi
1560
1561 #
1562 # Check whether GLib's printf supports thousands grouping. (This might
1563 # be different from the system's printf since GLib can optionally use
1564 # its own printf implementation.)
1565 #
1566 AC_CACHE_CHECK([whether GLib supports POSIX/XSI thousands grouping],
1567                [ac_cv_glib_supports_printf_grouping], [
1568 ac_save_CFLAGS="$CFLAGS"
1569 ac_save_LIBS="$LIBS"
1570 CFLAGS="$WS_CFLAGS $GLIB_CFLAGS $CFLAGS"
1571 LIBS="$LIBS $GLIB_LIBS"
1572 AC_TRY_RUN([
1573 #include <glib.h>
1574 #include <locale.h>
1575 #include <stdio.h>
1576 #include <string.h>
1577
1578 int
1579 main ()
1580 {
1581   gchar *str;
1582   setlocale(LC_ALL, "en_US.UTF-8");
1583   str = g_strdup_printf("%'u", 123456);
1584   return (strcmp (str, "123,456") != 0);
1585 }
1586 ], ac_cv_glib_supports_printf_grouping=yes, ac_cv_glib_supports_printf_grouping=no,
1587    [echo $ac_n "cross compiling; playing it safe... $ac_c"
1588     ac_cv_glib_supports_printf_grouping=no])
1589 CFLAGS="$ac_save_CFLAGS"
1590 LIBS="$ac_save_LIBS"
1591 ])
1592 if test "$ac_cv_glib_supports_printf_grouping" = yes ; then
1593   AC_DEFINE(HAVE_GLIB_PRINTF_GROUPING, 1, [Define if GLib's printf functions support thousands grouping.])
1594 fi
1595
1596 if test "x$have_gtk" = "xyes"
1597 then
1598     #
1599     # We have GTK+; do we want the macOS integration functions and,
1600     # if so, do we have them and, if so, which versions do we have,
1601     # the old Carbon-based ones or the new Cocoa-based ones?
1602     #
1603     AC_MSG_CHECKING(whether to use macOS integration functions)
1604
1605     AC_ARG_WITH(osx-integration,
1606       AC_HELP_STRING( [--with-osx-integration],
1607                       [use macOS integration functions @<:@default=yes, if available@:>@]),
1608     [
1609         if test $withval = no
1610         then
1611             want_osx_integration=no
1612         else
1613             want_osx_integration=yes
1614         fi
1615     ],[
1616         want_osx_integration=yes
1617     ])
1618     if test "x$want_osx_integration" = "xno"; then
1619         AC_MSG_RESULT(no)
1620     else
1621         AC_MSG_RESULT(yes)
1622         AC_WIRESHARK_OSX_INTEGRATION_CHECK
1623     fi
1624 fi
1625
1626 AC_SUBST(wireshark_bin)
1627 AC_SUBST(wireshark_man)
1628 AC_SUBST(wireshark_SUBDIRS)
1629 AM_CONDITIONAL(HAVE_Qt, test "$have_qt" = "yes")
1630 AM_CONDITIONAL(HAVE_GTK, test "$have_gtk" = "yes")
1631 AC_SUBST(OSX_APP_FLAGS)
1632 AC_SUBST(OSX_DMG_FLAGS)
1633
1634 # Enable/disable tshark
1635 AC_ARG_ENABLE(tshark,
1636   AC_HELP_STRING( [--enable-tshark],
1637                   [build tshark @<:@default=yes@:>@]),
1638     tshark=$enableval,enable_tshark=yes)
1639
1640 if test "x$enable_tshark" = "xyes" ; then
1641         tshark_bin="tshark\$(EXEEXT)"
1642         tshark_man="tshark.1"
1643         wiresharkfilter_man="wireshark-filter.4"
1644 else
1645         tshark_bin=""
1646         tshark_man=""
1647 fi
1648 AC_SUBST(tshark_bin)
1649 AC_SUBST(tshark_man)
1650
1651 # Enable/disable editcap
1652
1653 AC_ARG_ENABLE(editcap,
1654   AC_HELP_STRING( [--enable-editcap],
1655                   [build editcap @<:@default=yes@:>@]),
1656     enable_editcap=$enableval,enable_editcap=yes)
1657
1658 if test "x$enable_editcap" = "xyes" ; then
1659         editcap_bin="editcap\$(EXEEXT)"
1660         editcap_man="editcap.1"
1661 else
1662         editcap_bin=""
1663         editcap_man=""
1664 fi
1665 AC_SUBST(editcap_bin)
1666 AC_SUBST(editcap_man)
1667
1668
1669 # Enabling/disabling of dumpcap is done later (after we know if we have PCAP
1670 # or not)
1671
1672 # Enable/disable capinfos
1673
1674 AC_ARG_ENABLE(capinfos,
1675   AC_HELP_STRING( [--enable-capinfos],
1676                   [build capinfos @<:@default=yes@:>@]),
1677     enable_capinfos=$enableval,enable_capinfos=yes)
1678
1679 if test "x$enable_capinfos" = "xyes" ; then
1680         capinfos_bin="capinfos\$(EXEEXT)"
1681         capinfos_man="capinfos.1"
1682 else
1683         capinfos_bin=""
1684         capinfos_man=""
1685 fi
1686 AC_SUBST(capinfos_bin)
1687 AC_SUBST(capinfos_man)
1688
1689 # Enable/disable captype
1690
1691 AC_ARG_ENABLE(captype,
1692   AC_HELP_STRING( [--enable-captype],
1693                   [build captype @<:@default=yes@:>@]),
1694     enable_captype=$enableval,enable_captype=yes)
1695
1696 if test "x$enable_captype" = "xyes" ; then
1697         captype_bin="captype\$(EXEEXT)"
1698         captype_man="captype.1"
1699 else
1700         captype_bin=""
1701         captype_man=""
1702 fi
1703 AC_SUBST(captype_bin)
1704 AC_SUBST(captype_man)
1705
1706 # Enable/disable mergecap
1707
1708 AC_ARG_ENABLE(mergecap,
1709   AC_HELP_STRING( [--enable-mergecap],
1710                   [build mergecap @<:@default=yes@:>@]),
1711     enable_mergecap=$enableval,enable_mergecap=yes)
1712
1713 if test "x$enable_mergecap" = "xyes" ; then
1714         mergecap_bin="mergecap\$(EXEEXT)"
1715         mergecap_man="mergecap.1"
1716 else
1717         mergecap_bin=""
1718         mergecap_man=""
1719 fi
1720 AC_SUBST(mergecap_bin)
1721 AC_SUBST(mergecap_man)
1722
1723 # Enable/disable reordercap
1724
1725 AC_ARG_ENABLE(reordercap,
1726   AC_HELP_STRING( [--enable-reordercap],
1727                   [build reordercap @<:@default=yes@:>@]),
1728     enable_reordercap=$enableval,enable_reordercap=yes)
1729
1730 if test "x$enable_reordercap" = "xyes" ; then
1731         reordercap_bin="reordercap\$(EXEEXT)"
1732         reordercap_man="reordercap.1"
1733 else
1734         reordercap_bin=""
1735         reordercap_man=""
1736 fi
1737 AC_SUBST(reordercap_bin)
1738 AC_SUBST(reordercap_man)
1739
1740 # Enable/disable text2pcap
1741
1742 AC_ARG_ENABLE(text2pcap,
1743   AC_HELP_STRING( [--enable-text2pcap],
1744                   [build text2pcap @<:@default=yes@:>@]),
1745     text2pcap=$enableval,enable_text2pcap=yes)
1746
1747 if test "x$enable_text2pcap" = "xyes" ; then
1748         text2pcap_bin="text2pcap\$(EXEEXT)"
1749         text2pcap_man="text2pcap.1"
1750 else
1751         text2pcap_bin=""
1752         text2pcap_man=""
1753 fi
1754 AC_SUBST(text2pcap_bin)
1755 AC_SUBST(text2pcap_man)
1756
1757 # Enable/disable dftest
1758
1759 AC_ARG_ENABLE(dftest,
1760   AC_HELP_STRING( [--enable-dftest],
1761                   [build dftest @<:@default=yes@:>@]),
1762     enable_dftest=$enableval,enable_dftest=yes)
1763
1764 if test "x$enable_dftest" = "xyes" ; then
1765         dftest_bin="dftest\$(EXEEXT)"
1766         dftest_man="dftest.1"
1767 else
1768         dftest_bin=""
1769         dftest_man=""
1770 fi
1771 AC_SUBST(dftest_bin)
1772 AC_SUBST(dftest_man)
1773
1774 # Enable/disable randpkt
1775
1776 AC_ARG_ENABLE(randpkt,
1777   AC_HELP_STRING( [--enable-randpkt],
1778                   [build randpkt @<:@default=yes@:>@]),
1779     enable_randpkt=$enableval,enable_randpkt=yes)
1780
1781 if test "x$enable_randpkt" = "xyes" ; then
1782         randpkt_bin="randpkt\$(EXEEXT)"
1783         randpkt_man="randpkt.1"
1784 else
1785         randpkt_bin=""
1786         randpkt_man=""
1787 fi
1788 AC_SUBST(randpkt_bin)
1789 AC_SUBST(randpkt_man)
1790
1791 AC_SUBST(wiresharkfilter_man)
1792
1793 dnl pcap check
1794 AC_MSG_CHECKING(whether to use libpcap for packet capture)
1795
1796 AC_ARG_WITH(pcap,
1797   AC_HELP_STRING( [--with-pcap@<:@=DIR@:>@],
1798                   [use libpcap for packet capturing @<:@default=yes@:>@]),
1799 [
1800         if test $withval = no
1801         then
1802                 want_pcap=no
1803         elif test $withval = yes
1804         then
1805                 want_pcap=yes
1806         else
1807                 want_pcap=yes
1808                 pcap_dir=$withval
1809         fi
1810 ],[
1811         want_pcap=yes
1812         pcap_dir=
1813 ])
1814 if test "x$want_pcap" = "xno" ; then
1815         AC_MSG_RESULT(no)
1816 else
1817         AC_MSG_RESULT(yes)
1818         AC_WIRESHARK_PCAP_CHECK
1819 fi
1820
1821 dnl dumpcap check
1822 AC_MSG_CHECKING(whether to build dumpcap)
1823
1824 AC_ARG_ENABLE(dumpcap,
1825   AC_HELP_STRING( [--enable-dumpcap],
1826                   [build dumpcap @<:@default=yes@:>@]),
1827     enable_dumpcap=$enableval,enable_dumpcap=yes)
1828
1829 if test "x$enable_dumpcap" = "xyes" ; then
1830         if test "x$want_pcap" = "xno" ; then
1831                 enable_dumpcap=no
1832                 AC_MSG_RESULT(pcap not available - disabling dumpcap)
1833         else
1834                 AC_MSG_RESULT(yes)
1835         fi
1836 else
1837         AC_MSG_RESULT(no)
1838 fi
1839
1840 if test "x$enable_dumpcap" = "xyes" ; then
1841         dumpcap_bin="dumpcap\$(EXEEXT)"
1842         dumpcap_man="dumpcap.1"
1843 else
1844         dumpcap_bin=""
1845         dumpcap_man=""
1846 fi
1847 AC_SUBST(dumpcap_bin)
1848 AC_SUBST(dumpcap_man)
1849
1850 # Enable/disable rawshark
1851
1852 dnl rawshark check
1853 AC_MSG_CHECKING(whether to build rawshark)
1854
1855 AC_ARG_ENABLE(rawshark,
1856   AC_HELP_STRING( [--enable-rawshark],
1857                   [build rawshark @<:@default=yes@:>@]),
1858     rawshark=$enableval,enable_rawshark=yes)
1859
1860 if test "x$enable_rawshark" = "xyes" ; then
1861         if test "x$want_pcap" = "xno" ; then
1862                 enable_rawshark=no
1863                 AC_MSG_RESULT(pcap not available - disabling rawshark)
1864         else
1865                 AC_MSG_RESULT(yes)
1866         fi
1867 else
1868         AC_MSG_RESULT(no)
1869 fi
1870
1871 if test "x$enable_rawshark" = "xyes" ; then
1872         rawshark_bin="rawshark\$(EXEEXT)"
1873         rawshark_man="rawshark.1"
1874 else
1875         rawshark_bin=""
1876         rawshark_man=""
1877 fi
1878 AC_SUBST(rawshark_bin)
1879 AC_SUBST(rawshark_man)
1880
1881 # Enable/disable sharkd
1882 AC_ARG_ENABLE(sharkd,
1883   AC_HELP_STRING( [--enable-sharkd],
1884                   [build sharkd @<:@default=yes@:>@]),
1885     sharkd=$enableval,enable_sharkd=yes)
1886
1887 if test "x$enable_sharkd" = "xyes" ; then
1888         sharkd_bin="sharkd\$(EXEEXT)"
1889 else
1890         sharkd_bin=""
1891 fi
1892 AC_SUBST(sharkd_bin)
1893
1894 # Enable/disable tfshark
1895 AC_ARG_ENABLE(tfshark,
1896   AC_HELP_STRING( [--enable-tfshark],
1897                   [build tfshark (Experimental) @<:@default=no@:>@]),
1898     tfshark=$enableval,enable_tfshark=no)
1899
1900 if test "x$enable_tfshark" = "xyes" ; then
1901         tfshark_bin="tfshark\$(EXEEXT)"
1902         tfshark_man="tfshark.1"
1903         wiresharkfilter_man="wireshark-filter.4"
1904 else
1905         tfshark_bin=""
1906         tfshark_man=""
1907 fi
1908 AC_SUBST(tfshark_bin)
1909 AC_SUBST(tfshark_man)
1910
1911
1912 dnl Use pcap-ng by default
1913 AC_ARG_ENABLE(pcap-ng-default,
1914   AC_HELP_STRING( [--enable-pcap-ng-default],
1915                   [use the pcap-ng file format by default instead of pcap @<:@default=yes@:>@]),
1916     enable_pcap_ng_default=$enableval,enable_pcap_ng_default=yes)
1917 if test x$enable_pcap_ng_default = xyes; then
1918         AC_DEFINE(PCAP_NG_DEFAULT, 1, [Support for pcap-ng])
1919 fi
1920
1921 dnl pcap remote check
1922 AC_MSG_CHECKING(whether to use libpcap remote capturing feature)
1923
1924 AC_ARG_WITH(pcap-remote,
1925     AC_HELP_STRING([--with-pcap-remote],
1926                    [use libpcap remote capturing (requires libpcap)]),
1927 [
1928     if test $withval = no
1929     then
1930         want_pcap_remote=no
1931     else
1932         want_pcap_remote=yes
1933     fi
1934 ],[
1935     want_pcap_remote=no
1936 ])
1937 if test "x$want_pcap_remote" = "xno" -o "x$want_pcap" = "xno" ; then
1938     AC_MSG_RESULT(no)
1939 else
1940     AC_MSG_RESULT(yes)
1941     AC_WIRESHARK_PCAP_REMOTE_CHECK
1942 fi
1943
1944 dnl zlib check
1945 AC_MSG_CHECKING(whether to use zlib for gzip compression and decompression)
1946
1947 AC_ARG_WITH(zlib,
1948   AC_HELP_STRING([--with-zlib@<:@=DIR@:>@],
1949                  [use zlib (located in directory DIR, if supplied) for gzip compression and decompression @<:@default=yes, if available@:>@]),
1950 [
1951         if test "x$withval" = "xno"
1952         then
1953                 want_zlib=no
1954         elif test "x$withval" = "xyes"
1955         then
1956                 want_zlib=yes
1957         else
1958                 want_zlib=yes
1959                 zlib_dir="$withval"
1960         fi
1961 ],[
1962         #
1963         # Use zlib if it's present, otherwise don't.
1964         #
1965         want_zlib=ifavailable
1966         zlib_dir=
1967 ])
1968 if test "x$want_zlib" = "xno" ; then
1969         AC_MSG_RESULT(no)
1970 else
1971         AC_MSG_RESULT(yes)
1972         AC_WIRESHARK_ZLIB_CHECK
1973         if test "x$want_zlib" = "xno" ; then
1974                 AC_MSG_RESULT(zlib not found - disabling gzip compression and decompression)
1975         else
1976                 if test "x$ac_cv_func_inflatePrime" = "xno" ; then
1977                         AC_MSG_RESULT(inflatePrime not found in zlib - disabling gzipped capture file support)
1978                 fi
1979         fi
1980 fi
1981
1982 dnl lz4 check
1983 LZ4_LIBS=''
1984 AC_MSG_CHECKING(whether to use lz4 compression and decompression)
1985
1986 AC_ARG_WITH(lz4,
1987   AC_HELP_STRING([--with-lz4@<:@=DIR@:>@],
1988                  [use lz4 (located in directory DIR, if supplied) for lz4 compression and decompression @<:@default=yes, if available@:>@]),
1989 [
1990         if test "x$withval" = "xno"
1991         then
1992                 want_lz4=no
1993         elif test "x$withval" = "xyes"
1994         then
1995                 want_lz4=yes
1996         else
1997                 want_lz4=yes
1998                 lz4_dir="$withval"
1999         fi
2000 ],[
2001         #
2002         # Use lz4 if it's present, otherwise don't.
2003         #
2004         want_lz4=ifavailable
2005         lz4_dir=
2006 ])
2007 have_lz4=no
2008 if test "x$want_lz4" = "xno" ; then
2009         AC_MSG_RESULT(no)
2010 else
2011         AC_MSG_RESULT(yes)
2012         AC_WIRESHARK_LZ4_CHECK
2013         if test "x$want_lz4" = "xno" ; then
2014                 AC_MSG_RESULT(lz4 not found - disabling lz4 compression and decompression)
2015         else
2016                 if test "x$ac_cv_func_LZ4_decompress_safe" = "xno" ; then
2017                         AC_MSG_RESULT(LZ4_decompress_safe not found in lz4 - disabling cql lz4 decompression)
2018                 else
2019                         have_lz4=yes
2020                 fi
2021         fi
2022 fi
2023 AC_SUBST(LZ4_LIBS)
2024
2025 dnl snappy check
2026 SNAPPY_LIBS=''
2027 AC_MSG_CHECKING(whether to use snappy compression and decompression)
2028
2029 AC_ARG_WITH(snappy,
2030   AC_HELP_STRING([--with-snappy@<:@=DIR@:>@],
2031                  [use snappy (located in directory DIR, if supplied) for snappy compression and decompression @<:@default=yes, if available@:>@]),
2032 [
2033         if test "x$withval" = "xno"
2034         then
2035                 want_snappy=no
2036         elif test "x$withval" = "xyes"
2037         then
2038                 want_snappy=yes
2039         else
2040                 want_snappy=yes
2041                 snappy_dir="$withval"
2042         fi
2043 ],[
2044         #
2045         # Use snappy if it's present, otherwise don't.
2046         #
2047         want_snappy=ifavailable
2048         snappy_dir=
2049 ])
2050 have_snappy=no
2051 if test "x$want_snappy" = "xno" ; then
2052         AC_MSG_RESULT(no)
2053 else
2054         AC_MSG_RESULT(yes)
2055         AC_WIRESHARK_SNAPPY_CHECK
2056         if test "x$want_snappy" = "xno" ; then
2057                 AC_MSG_RESULT(snappy not found - disabling snappy compression and decompression)
2058         else
2059                 if test "x$ac_cv_func_snappy_uncompress" = "xno" ; then
2060                         AC_MSG_RESULT(snappy_uncompress not found in snappy - disabling cql snappy decompression)
2061                 else
2062                         have_snappy=yes
2063                 fi
2064         fi
2065 fi
2066 AC_SUBST(SNAPPY_LIBS)
2067
2068 dnl Lua check
2069 AC_ARG_WITH(lua,
2070   AC_HELP_STRING( [--with-lua@<:@=DIR@:>@],
2071                   [use liblua (located in directory DIR, if supplied) for the Lua scripting plugin @<:@default=yes, if available@:>@]),
2072 [
2073         if test $withval = no
2074         then
2075                 want_lua=no
2076         elif test $withval = yes
2077         then
2078                 want_lua=yes
2079         else
2080                 want_lua=yes
2081                 want_lua_dir=$withval
2082         fi
2083 ],[
2084         # By default use Lua if we can find it
2085         want_lua=ifavailable
2086         lua_dir=
2087 ])
2088 if test "x$want_lua" != "xno" ; then
2089         AC_WIRESHARK_LIBLUA_CHECK
2090
2091         if test "x$want_lua" = "xyes" -a "x$have_lua" = "xno"
2092         then
2093                 AC_MSG_ERROR([Lua support was requested, but is not available])
2094         fi
2095 fi
2096 if test "x$have_lua" = "xyes"
2097 then
2098         AC_DEFINE(HAVE_LUA, 1, [Define to use Lua])
2099 fi
2100 AM_CONDITIONAL(HAVE_LIBLUA, test x$have_lua = xyes)
2101 AC_SUBST(LUA_LIBS)
2102 AC_SUBST(LUA_CFLAGS)
2103
2104
2105 dnl portaudio check
2106 AC_MSG_CHECKING(whether to use libportaudio for the GTK+ RTP player)
2107
2108 AC_ARG_WITH(portaudio,
2109   AC_HELP_STRING( [--with-portaudio@<:@=DIR@:>@],
2110                   [use libportaudio (located in directory DIR, if supplied) for the GTK+ RTP player @<:@default=yes, if available@:>@]),
2111 [
2112         if test $withval = no
2113         then
2114                 want_portaudio=no
2115         elif test $withval = yes
2116         then
2117                 want_portaudio=yes
2118         else
2119                 want_portaudio=yes
2120                 portaudio_dir=$withval
2121         fi
2122 ],[
2123         #
2124         # Use libportaudio by default
2125         #
2126         want_portaudio=ifavailable
2127         portaudio_dir=
2128 ])
2129 if test "x$want_portaudio" = "xno" ; then
2130         AC_MSG_RESULT(no)
2131 else
2132         AC_MSG_RESULT(yes)
2133         AC_WIRESHARK_LIBPORTAUDIO_CHECK
2134         if test "x$want_portaudio" = "xno" ; then
2135                 AC_MSG_RESULT(libportaudio not found - disabling support for the GTK+ RTP player)
2136         fi
2137 fi
2138 AM_CONDITIONAL(HAVE_LIBPORTAUDIO, test x$want_portaudio = xyes)
2139
2140
2141 dnl Check if dumpcap should be installed with filesystem capabilities
2142 AC_PATH_PROG(SETCAP, setcap)
2143 AC_ARG_ENABLE(setcap-install,
2144   AC_HELP_STRING( [--enable-setcap-install],
2145                   [install dumpcap with cap_net_admin and cap_net_raw @<:@default=no@:>@]),
2146     enable_setcap_install=$enableval,enable_setcap_install=no)
2147
2148 AC_MSG_CHECKING(whether to install dumpcap with cap_net_admin and cap_net_raw capabilities)
2149 if test "x$enable_setcap_install" = "xno" ; then
2150         AC_MSG_RESULT(no)
2151 else
2152         if test "x$SETCAP" = "x" ; then
2153                 AC_MSG_RESULT(setcap not found)
2154                 AC_MSG_ERROR([Setcap install was requested, but setcap was not found])
2155         elif test "x$enable_dumpcap" = "xno" ; then
2156                 AC_MSG_RESULT(dumpcap disabled)
2157                 AC_MSG_ERROR([Setcap install works only with dumpcap, but dumpcap is disabled])
2158         else
2159                 AC_MSG_RESULT(yes)
2160         fi
2161 fi
2162
2163 AM_CONDITIONAL(SETCAP_INSTALL, test x$enable_setcap_install = xyes)
2164
2165 dnl Check if dumpcap should be installed setuid
2166 AC_ARG_ENABLE(setuid-install,
2167   AC_HELP_STRING( [--enable-setuid-install],
2168                   [install dumpcap as setuid @<:@default=no@:>@]),
2169     enable_setuid_install=$enableval,enable_setuid_install=no)
2170
2171 AC_MSG_CHECKING(whether to install dumpcap setuid)
2172 if test "x$enable_setuid_install" = "xno" ; then
2173         AC_MSG_RESULT(no)
2174 else
2175         if test "x$enable_setcap_install" = "xyes" ; then
2176                 enable_setuid_install=no
2177                 AC_MSG_RESULT(setcap and setuid both selected)
2178                 AC_MSG_ERROR(You must choose one of setcap install and setuid install)
2179         elif test "x$enable_dumpcap" = "xno" ; then
2180                 AC_MSG_RESULT(dumpcap disabled)
2181                 AC_MSG_ERROR([Setuid install works only with dumpcap, but dumpcap is disabled])
2182         else
2183                 AC_MSG_RESULT(yes)
2184         fi
2185 fi
2186
2187 AM_CONDITIONAL(SETUID_INSTALL, test x$enable_setuid_install = xyes)
2188 AC_CHECK_FUNCS(setresuid setresgid)
2189
2190 dnl ...but our Network Operations group is named "no"!
2191 DUMPCAP_GROUP=''
2192 AC_ARG_WITH(dumpcap-group,
2193   AC_HELP_STRING( [--with-dumpcap-group=GROUP],
2194                   [restrict dumpcap to GROUP]),
2195 [
2196   if test "x$withval" = "xyes"; then
2197       AC_MSG_ERROR([No dumpcap group specified.])
2198   elif test "x$withval" != "xno"; then
2199       if test "x$enable_dumpcap" = "xno" ; then
2200           AC_MSG_ERROR(dumpcap group install works only with dumpcap but dumpcap is disabled)
2201       fi
2202       AC_MSG_RESULT($withval)
2203       DUMPCAP_GROUP="$withval"
2204   fi
2205 ])
2206 AC_SUBST(DUMPCAP_GROUP)
2207 AM_CONDITIONAL(HAVE_DUMPCAP_GROUP, test x$DUMPCAP_GROUP != x)
2208
2209 dnl libcap (not libpcap) check
2210 LIBCAP_LIBS=''
2211 AC_MSG_CHECKING(whether to use the libcap capabilities library)
2212
2213 AC_ARG_WITH(libcap,
2214   AC_HELP_STRING( [--with-libcap@<:@=DIR@:>@],
2215                   [use libcap (located in directory DIR, if supplied) for POSIX.1e capabilities management @<:@default=yes, if present@:>@]),
2216 [
2217 if   test "x$withval" = "xno";  then
2218         want_libcap=no
2219 elif test "x$withval" = "xyes"; then
2220         want_libcap=yes
2221 elif test -d "$withval"; then
2222         want_libcap=yes
2223         AC_WIRESHARK_ADD_DASH_L(WS_LDFLAGS, ${withval}/lib)
2224 fi
2225 ])
2226 if test "x$with_libcap" = "xno" ; then
2227         AC_MSG_RESULT(no)
2228 else
2229         AC_MSG_RESULT(yes)
2230         AC_WIRESHARK_LIBCAP_CHECK
2231 fi
2232 AC_SUBST(LIBCAP_LIBS)
2233
2234 dnl Checks for header files.
2235 dnl Some of these may not be needed: http://hacks.owlfolio.org/header-survey/
2236 dnl Note, however, that, whilst this script is generally run only on UN*Xes:
2237 dnl
2238 dnl     1) we also support building on and for Windows and not all of those
2239 dnl        headers are present on Windows, so the code has to check a
2240 dnl        #define *anyway* to determine whether to include the header
2241 dnl        file
2242 dnl
2243 dnl and
2244 dnl
2245 dnl     2) this might also be run on Windows with a sufficiently UNIXy
2246 dnl        environment such as Cygwin (although Wireshark should be built
2247 dnl        natively rather than using Cygwin).
2248 dnl
2249 AC_CHECK_HEADERS(fcntl.h getopt.h grp.h inttypes.h netdb.h pwd.h unistd.h)
2250 AC_CHECK_HEADERS(sys/ioctl.h sys/param.h sys/socket.h sys/sockio.h sys/stat.h sys/time.h sys/types.h sys/utsname.h sys/wait.h)
2251 AC_CHECK_HEADERS(netinet/in.h)
2252 AC_CHECK_HEADERS(arpa/inet.h arpa/nameser.h)
2253 AC_CHECK_HEADERS(ifaddrs.h)
2254
2255 #
2256 # On Linux, check for some additional headers, which we need as a
2257 # workaround for a bonding driver bug and for libpcap's current lack
2258 # of its own workaround for that bug.
2259 #
2260 case "$host_os" in
2261 linux*)
2262         AC_CHECK_HEADERS(linux/sockios.h linux/if_bonding.h,,,[#include <sys/socket.h>])
2263         ;;
2264 esac
2265
2266 dnl SSL Check
2267 SSL_LIBS=''
2268 AC_MSG_CHECKING(whether to use SSL library)
2269
2270 AC_ARG_WITH(ssl,
2271   AC_HELP_STRING( [--with-ssl@<:@=DIR@:>@],
2272                   [use SSL crypto library (located in directory DIR, if supplied) @<:@default=no@:>@]),
2273 [
2274 if test "x$withval" = "xno";  then
2275         want_ssl=no
2276 elif test "x$withval" = "xyes"; then
2277         want_ssl=yes
2278 elif test -d "$withval"; then
2279         want_ssl=yes
2280         AC_WIRESHARK_ADD_DASH_L(WS_LDFLAGS, ${withval}/lib)
2281 fi
2282 ],[
2283         want_ssl=no
2284 ])
2285 if test "x$want_ssl" = "xyes"; then
2286         AC_MSG_RESULT(yes)
2287         AC_CHECK_LIB(crypto,EVP_md5,
2288             [
2289                 SSL_LIBS=-lcrypto
2290             ],
2291             [
2292                 AC_MSG_ERROR([SSL crypto library was requested, but is not available])
2293             ])
2294 else
2295         AC_MSG_RESULT(no)
2296 fi
2297 AC_SUBST(SSL_LIBS)
2298
2299 dnl kerberos check
2300 AC_MSG_CHECKING(whether to use Kerberos library)
2301
2302 AC_ARG_WITH(krb5,
2303   AC_HELP_STRING( [--with-krb5@<:@=DIR@:>@],
2304                   [use Kerberos library (located in directory DIR, if supplied) to use in Kerberos dissection @<:@default=yes@:>@]),
2305 [
2306         if test $withval = no
2307         then
2308                 want_krb5=no
2309         elif test $withval = yes
2310         then
2311                 want_krb5=yes
2312         else
2313                 want_krb5=yes
2314                 krb5_dir=$withval
2315         fi
2316 ],[
2317         #
2318         # Use Kerberos library if available, otherwise don't.
2319         #
2320         want_krb5=ifavailable
2321         krb5_dir=
2322 ])
2323 if test "x$want_krb5" = "xno" ; then
2324         AC_MSG_RESULT(no)
2325 else
2326         AC_MSG_RESULT(yes)
2327         AC_WIRESHARK_KRB5_CHECK
2328 fi
2329
2330
2331 dnl c-ares Check
2332 C_ARES_LIBS=''
2333 AC_MSG_CHECKING(whether to use the c-ares library if available)
2334
2335 AC_ARG_WITH(c-ares,
2336   AC_HELP_STRING( [--with-c-ares@<:@=DIR@:>@],
2337                   [use c-ares (located in directory DIR, if supplied) @<:@default=yes, if present@:>@]),
2338 [
2339 if   test "x$withval" = "xno";  then
2340         want_c_ares=no
2341 elif test "x$withval" = "xyes"; then
2342         want_c_ares=yes
2343 elif test -d "$withval"; then
2344         want_c_ares=yes
2345         AC_WIRESHARK_ADD_DASH_L(WS_LDFLAGS, ${withval}/lib)
2346 fi
2347 ])
2348 if test "x$want_c_ares" = "xno" ; then
2349         AC_MSG_RESULT(no)
2350 else
2351         AC_MSG_RESULT(yes)
2352         AC_WIRESHARK_C_ARES_CHECK
2353 fi
2354 AC_SUBST(C_ARES_LIBS)
2355
2356 dnl GEOIP Check
2357 GEOIP_LIBS=''
2358 AC_MSG_CHECKING(whether to use the GeoIP IP address mapping library if available)
2359
2360 AC_ARG_WITH(geoip,
2361   AC_HELP_STRING( [--with-geoip@<:@=DIR@:>@],
2362                   [use GeoIP (located in directory DIR, if supplied) @<:@default=yes, if present@:>@]),
2363 [
2364 if   test "x$withval" = "xno";  then
2365         want_geoip=no
2366 elif test "x$withval" = "xyes"; then
2367         want_geoip=yes
2368 elif test -d "$withval"; then
2369         want_geoip=yes
2370         AC_WIRESHARK_ADD_DASH_L(WS_LDFLAGS, ${withval}/lib)
2371 fi
2372 ])
2373 if test "x$want_geoip" = "xno"; then
2374         AC_MSG_RESULT(no)
2375 else
2376         AC_MSG_RESULT(yes)
2377         AC_WIRESHARK_GEOIP_CHECK
2378 fi
2379 AC_SUBST(GEOIP_LIBS)
2380
2381 dnl LIBSSH Check
2382 LIBSSH=''
2383 AC_MSG_CHECKING(whether to use the libssh library if available)
2384
2385 AC_ARG_WITH(ssh,
2386   AC_HELP_STRING( [--with-libssh@<:@=DIR@:>@],
2387                   [use libssh (located in directory DIR, if supplied) @<:@default=yes, if present@:>@]),
2388 [
2389 if   test "x$withval" = "xno";  then
2390         want_libssh=no
2391 elif test "x$withval" = "xyes"; then
2392         want_libssh=yes
2393 elif test -d "$withval"; then
2394         want_libssh=yes
2395         AC_WIRESHARK_ADD_DASH_L(WS_LDFLAGS, ${withval}/lib)
2396 fi
2397 ])
2398 if test "x$want_libssh" = "xno"; then
2399         AC_MSG_RESULT(no)
2400 else
2401         AC_MSG_RESULT(yes)
2402         AC_WIRESHARK_LIBSSH_CHECK
2403 fi
2404 AC_SUBST(LIBSSH_LIBS)
2405
2406 dnl nghttp2 Check
2407 NGHTTP2_LIBS=''
2408 AC_MSG_CHECKING(whether to use the nghttp2 HPACK library if available)
2409
2410 AC_ARG_WITH(nghttp2,
2411   AC_HELP_STRING( [--with-nghttp2@<:@=DIR@:>@],
2412                   [use nghttp2 (located in directory DIR, if supplied) @<:@default=yes, if present@:>@]),
2413 [
2414 if   test "x$withval" = "xno";  then
2415         want_nghttp2=no
2416 elif test "x$withval" = "xyes"; then
2417         want_nghttp2=yes
2418 elif test -d "$withval"; then
2419         want_nghttp2=yes
2420         AC_WIRESHARK_ADD_DASH_L(WS_LDFLAGS, ${withval}/lib)
2421 fi
2422 ])
2423 if test "x$want_nghttp2" = "xno"; then
2424         AC_MSG_RESULT(no)
2425 else
2426         AC_MSG_RESULT(yes)
2427         AC_WIRESHARK_NGHTTP2_CHECK
2428 fi
2429 AC_SUBST(NGHTTP2_LIBS)
2430
2431 dnl Checks for typedefs, structures, and compiler characteristics.
2432 # AC_C_CONST
2433
2434 # Check how we can get the time zone abbreviation
2435 AC_STRUCT_TIMEZONE
2436
2437 # We need to know whether "struct stat" has an "st_flags" member
2438 # for file_user_immutable().
2439
2440 AC_CHECK_MEMBERS([struct stat.st_flags])
2441
2442 # We need to know whether "struct stat" has an "st_birthtime" member
2443 # or an "__st_birthtime" member for the file set dialog.
2444
2445 AC_CHECK_MEMBERS([struct stat.st_birthtime])
2446 AC_CHECK_MEMBERS([struct stat.__st_birthtime])
2447
2448 # We need to know whether "struct sockaddr" has an "sa_len" member
2449 # for get_interface_list().
2450
2451 AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,
2452                  [#ifdef HAVE_SYS_TYPES_H
2453                   #include <sys/types.h>
2454                   #endif
2455                   #ifdef HAVE_SYS_SOCKET_H
2456                   #include <sys/socket.h>
2457                   #endif])
2458
2459 # We must know our byte order
2460 AC_C_BIGENDIAN
2461
2462 # Checks whether "-traditional" is needed when using "ioctl".
2463 # XXX - do we need this?
2464 AC_PROG_GCC_TRADITIONAL
2465
2466 AC_REPLACE_FUNCS(getopt_long)
2467 dnl
2468 dnl Do we have optreset?
2469 dnl
2470 if test "x$ac_cv_func_getopt_long" = xyes; then
2471   AC_CACHE_CHECK([whether optreset is defined], ac_cv_have_optreset,
2472     AC_LINK_IFELSE([AC_LANG_SOURCE([[extern int optreset;return optreset;]])],
2473         ac_cv_have_optreset=yes, ac_cv_have_optreset=no))
2474   if test "$ac_cv_have_optreset" = yes ; then
2475     AC_DEFINE(HAVE_OPTRESET, 1, [Define to 1 if you have the optreset variable])
2476   fi
2477 fi
2478
2479 AC_REPLACE_FUNCS(inet_aton)
2480
2481 AC_CHECK_FUNC(inet_pton, [
2482   dnl check for pre-BIND82 inet_pton() bug.
2483   AC_MSG_CHECKING(for broken inet_pton)
2484   AC_TRY_RUN([#include <sys/types.h>
2485 #include <sys/socket.h>
2486 #include <netinet/in.h>
2487 #include <arpa/inet.h>
2488 int main()
2489 {
2490 #ifdef AF_INET6
2491   char buf[16];
2492   /* this should return 0 (error) */
2493   return inet_pton(AF_INET6, "0:1:2:3:4:5:6:7:", buf);
2494 #else
2495   return 1;
2496 #endif
2497 }], [AC_MSG_RESULT(ok);
2498 have_inet_pton=yes], [AC_MSG_RESULT(broken);
2499 have_inet_pton=no], [AC_MSG_RESULT([cross compiling, assume it is broken]);
2500 have_inet_pton=no])],
2501 have_inet_pton=no)
2502 if test "$have_inet_pton" = no; then
2503   AC_LIBOBJ(inet_pton)
2504 else
2505   AC_DEFINE(HAVE_INET_PTON, 1, [Define to 1 if you have the `inet_pton' function.])
2506 fi
2507
2508 AC_REPLACE_FUNCS(inet_ntop)
2509 AC_REPLACE_FUNCS(strptime)
2510 AC_REPLACE_FUNCS(popcount)
2511
2512 AC_CHECK_FUNCS(mkstemps mkdtemp)
2513 AC_CHECK_FUNCS(getprotobynumber)
2514 AC_CHECK_FUNCS(issetugid)
2515 AC_CHECK_FUNCS(sysconf)
2516 AC_CHECK_FUNCS(getifaddrs)
2517 AC_CHECK_FUNC(getexecname)
2518
2519 #
2520 # Check for SpeexDSP (http://www.speex.org)
2521 #
2522 AS_IF([test "x$have_qt_multimedia_lib" = xyes],
2523         [PKG_CHECK_MODULES(SPEEXDSP, speexdsp, [have_speexdsp=yes], [have_speexdsp=no])])
2524 AS_IF([test "x$have_speexdsp" = xyes],
2525         [AC_DEFINE(HAVE_SPEEXDSP, 1, [Define to 1 if you have SpeexDSP])])
2526 AM_CONDITIONAL(HAVE_SPEEXDSP, [test "x$have_speexdsp" = "xyes"])
2527
2528 # Check Bluetooth SBC codec for RTP Player
2529 # git://git.kernel.org/pub/scm/bluetooth/sbc.git
2530 AC_ARG_WITH([sbc],
2531   AC_HELP_STRING( [--with-sbc=@<:@yes/no@:>@],
2532                   [use SBC codec to play Bluetooth A2DP stream @<:@default=yes, if available@:>@]),
2533   with_sbc="$withval"; want_sbc="yes", with_sbc="yes")
2534
2535 PKG_CHECK_MODULES(SBC, sbc >= 1.0, [have_sbc=yes], [have_sbc=no])
2536 if test "x$with_sbc" != "xno"; then
2537     if (test "${have_sbc}" = "yes"); then
2538         AC_DEFINE(HAVE_SBC, 1, [Define to support playing SBC by standalone BlueZ SBC library])
2539     elif test "x$want_sbc" = "xyes"; then
2540         # Error out if the user explicitly requested the sbc library
2541         AC_MSG_ERROR([SBC codec library was requested, but is not available])
2542     fi
2543 else
2544     have_sbc=no
2545 fi
2546 AM_CONDITIONAL(HAVE_SBC, test "x$have_sbc" = "xyes")
2547
2548 #`
2549 # Check SpanDSP library for RTP Player
2550 # http://www.soft-switch.org/
2551 AC_ARG_WITH([spandsp],
2552   AC_HELP_STRING( [--with-spandsp=@<:@yes/no@:>@],
2553                  [use SpanDSP to play G.722/G.726 codecs @<:@default=yes, if available@:>@]),
2554   with_spandsp="$withval"; want_spandsp="yes", with_spandsp="yes")
2555
2556 PKG_CHECK_MODULES(SPANDSP, spandsp, [have_spandsp=yes], [have_spandsp=no])
2557 if test "x$with_spandsp" != "xno"; then
2558     if (test "${have_spandsp}" = "yes"); then
2559         AC_DEFINE(HAVE_SPANDSP, 1, [Define if you have the SpanDSP library])
2560     elif test "x$want_spandsp" = "xyes"; then
2561         # Error out if the user explicitly requested the SpanDSP library
2562         AC_MSG_ERROR([SpanDSP library was requested, but is not available])
2563     fi
2564 else
2565     have_spandsp=no
2566 fi
2567 AM_CONDITIONAL(HAVE_SPANDSP, test "x$have_spandsp" = "xyes")
2568
2569 #`
2570 # Libxml2 check
2571 AC_ARG_WITH(libxml2,
2572   AC_HELP_STRING([--with-libxml2=@<:@yes/no@:>@],
2573                  [Libxml2 is a XML C parser, which can be used for handling XML configuration in dissectors @<:@default=yes, if available@:>@]),
2574   with_libxml2="$withval"; want_libxml2="yes", with_libxml2="yes")
2575
2576 PKG_CHECK_MODULES(LIBXML2, libxml-2.0, [have_libxml2=yes], [have_libxml2=no])
2577 if test "x$with_libxml2" != "xno"; then
2578     if (test "${have_libxml2}" = "yes"); then
2579         AC_DEFINE(HAVE_LIBXML2, 1, [Define if you have libxml2])
2580     elif test "x$want_libxml2" = "xyes"; then
2581         # Error out if the user explicitly requested libxml2
2582         AC_MSG_ERROR([Libxml2 was requested, but is not available])
2583     fi
2584 else
2585     have_libxml2=no
2586 fi
2587 AM_CONDITIONAL(HAVE_LIBXML2, test "x$have_libxml2" = "xyes")
2588
2589
2590 dnl
2591 dnl check whether plugins should be enabled and, if they should be,
2592 dnl check for plugins directory - stolen from Amanda's configure.ac
2593 dnl
2594 dnl we don't wish to expand ${libdir} yet
2595 plugindir="\${libdir}/wireshark/plugins/${VERSION}"
2596 AC_ARG_WITH(plugins,
2597   AC_HELP_STRING( [--with-plugins@<:@=DIR@:>@],
2598                   [support plugins (installed in DIR, if supplied) @<:@default=yes, if possible@:>@]),
2599 [
2600   if test "x$withval" = "xno"; then
2601     have_plugins=no
2602   elif test "x$have_plugins" = "xno"; then
2603       AC_MSG_ERROR([GLib on this platform doesn't support loadable modules, so you can't enable plugins.])
2604   elif test "x$withval" != "xyes"; then
2605       plugindir="$withval"
2606   fi
2607 ])
2608 AM_CONDITIONAL(HAVE_PLUGINS, test "x$have_plugins" = "xyes")
2609 if test x$have_plugins = xyes
2610 then
2611   plugins_dir="plugins"
2612   AC_DEFINE(HAVE_PLUGINS, 1, [Define if plugins are enabled])
2613 else
2614   plugins_dir=""
2615 fi
2616 AC_SUBST(plugins_dir)
2617 AC_SUBST(plugindir)
2618
2619 #
2620 # The plugin dissectors reside in ./plugins/PROTO/
2621 #
2622 PLUGIN_LIBS=""
2623 AC_SUBST(PLUGIN_LIBS)
2624
2625 dnl
2626 dnl check whether extcap programs should be enabled and, if they should be,
2627 dnl check for extcap directory - stolen from Amanda's configure.ac
2628 dnl
2629 dnl we don't wish to expand ${libdir} yet
2630 extcapdir="\${libdir}/wireshark/extcap"
2631 AC_ARG_WITH(extcap,
2632   AC_HELP_STRING( [--with-extcap@<:@=DIR@:>@],
2633                   [use extcap for external capture sources (installed in DIR, if supplied) @<:@default=yes, if possible@:>@]),
2634 [
2635   if test "x$withval" = "xno"; then
2636       have_extcap=no
2637   elif test "x$withval" = "xyes"; then
2638       have_extcap=yes
2639   elif test "x$withval" != "xyes"; then
2640       have_extcap=yes
2641       extcapdir ="$withval"
2642   fi
2643 ],[
2644     have_extcap=yes
2645 ])
2646 AM_CONDITIONAL(HAVE_EXTCAP, test "x$have_extcap" = "xyes")
2647 if test "x$have_extcap" = "xyes"
2648 then
2649   AC_DEFINE(HAVE_EXTCAP, 1, [Define if external capture sources should be enabled])
2650   extcap_subdir="extcap"
2651   extcap_man="extcap.4"
2652 fi
2653 AC_SUBST(extcap_subdir)
2654 AC_SUBST(extcap_man)
2655 AC_SUBST(extcapdir)
2656
2657 dnl androiddump check
2658 AC_MSG_CHECKING(whether to build androiddump)
2659
2660 AC_ARG_ENABLE(androiddump,
2661   AC_HELP_STRING( [--enable-androiddump],
2662                   [build androiddump @<:@default=yes@:>@]),
2663     androiddump=$enableval,enable_androiddump=yes)
2664
2665 if test "x$have_extcap" != xyes; then
2666         AC_MSG_RESULT([no, extcap disabled])
2667         enable_androiddump=no
2668 elif test "x$enable_androiddump" = "xyes" ; then
2669         AC_MSG_RESULT(yes)
2670 else
2671         AC_MSG_RESULT(no)
2672 fi
2673
2674 AC_ARG_ENABLE(androiddump_use_libpcap,
2675   AC_HELP_STRING( [--enable-androiddump-use-libpcap],
2676                   [build androiddump using libpcap @<:@default=no@:>@]),
2677     androiddump_use_libpcap=$enableval,enable_androiddump_use_libpcap=no)
2678
2679 if test "x$enable_androiddump" = "xyes" -a "x$enable_androiddump_use_libpcap" = "xyes" ; then
2680         AC_DEFINE(ANDROIDDUMP_USE_LIBPCAP, 1, [Androiddump will use Libpcap])
2681 fi
2682
2683 if test "x$enable_androiddump" = "xyes" ; then
2684         androiddump_bin="androiddump\$(EXEEXT)"
2685         androiddump_man="androiddump.1"
2686 else
2687         androiddump_bin=""
2688         androiddump_man=""
2689 fi
2690 AC_SUBST(androiddump_bin)
2691 AC_SUBST(androiddump_man)
2692
2693 dnl sshdump check
2694 AC_MSG_CHECKING(whether to build sshdump)
2695
2696 AC_ARG_ENABLE(sshdump,
2697         AC_HELP_STRING( [--enable-sshdump],
2698                 [build sshdump @<:@default=yes@:>@]),
2699         [],[enable_sshdump=yes])
2700
2701 if test "x$have_extcap" != xyes; then
2702         AC_MSG_RESULT([no, extcap disabled])
2703         enable_sshdump=no
2704 elif test "x$have_libssh_pointsix" != xyes; then
2705         AC_MSG_RESULT([no, libssh >= 0.6.0 not available])
2706         enable_sshdump=no
2707 elif test "x$enable_sshdump" = "xyes" ; then
2708         AC_MSG_RESULT(yes)
2709 else
2710         AC_MSG_RESULT(no)
2711 fi
2712
2713 if test "x$enable_sshdump" = "xyes" ; then
2714         sshdump_bin="sshdump\$(EXEEXT)"
2715         sshdump_man="sshdump.1"
2716 else
2717         sshdump_bin=""
2718         sshdump_man=""
2719 fi
2720 AC_SUBST(sshdump_bin)
2721 AC_SUBST(sshdump_man)
2722
2723 dnl ciscodump check
2724 AC_MSG_CHECKING(whether to build ciscodump)
2725
2726 AC_ARG_ENABLE(ciscodump,
2727         AC_HELP_STRING( [--enable-ciscodump],
2728                 [build ciscodump @<:@default=yes@:>@]),
2729         [],[enable_ciscodump=yes])
2730
2731 if test "x$have_extcap" != xyes; then
2732         AC_MSG_RESULT([no, extcap disabled])
2733         enable_ciscodump=no
2734 elif test "x$have_libssh_pointsix" != xyes; then
2735         AC_MSG_RESULT([no, libssh >= 0.6.0 not available])
2736         enable_ciscodump=no
2737 elif test "x$enable_ciscodump" = "xyes" ; then
2738         AC_MSG_RESULT(yes)
2739 else
2740         AC_MSG_RESULT(no)
2741 fi
2742
2743 if test "x$enable_ciscodump" = "xyes" ; then
2744         ciscodump_bin="ciscodump\$(EXEEXT)"
2745         ciscodump_man="ciscodump.1"
2746 else
2747         ciscodump_bin=""
2748         ciscodump_man=""
2749 fi
2750 AC_SUBST(ciscodump_bin)
2751 AC_SUBST(ciscodump_man)
2752
2753 dnl randpktdump check
2754 AC_MSG_CHECKING(whether to build randpktdump)
2755
2756 AC_ARG_ENABLE(randpktdump,
2757         AC_HELP_STRING( [--enable-randpktdump],
2758                 [build randpktdump @<:@default=yes@:>@]),
2759         randpktdump=$enableval,enable_randpktdump=yes)
2760
2761 if test "x$have_extcap" != xyes; then
2762         AC_MSG_RESULT([no, extcap disabled])
2763         enable_randpktdump=no
2764 elif test "x$enable_randpktdump" = "xyes" ; then
2765         AC_MSG_RESULT(yes)
2766 else
2767         AC_MSG_RESULT(no)
2768 fi
2769
2770 if test "x$enable_randpktdump" = "xyes" ; then
2771         randpktdump_bin="randpktdump\$(EXEEXT)"
2772         randpktdump_man="randpktdump.1"
2773 else
2774         randpktdump_bin=""
2775         randpktdump_man=""
2776 fi
2777 AC_SUBST(randpktdump_bin)
2778 AC_SUBST(randpktdump_man)
2779
2780 dnl udpdump check
2781 AC_MSG_CHECKING(whether to build udpdump)
2782
2783 AC_ARG_ENABLE(udpdump,
2784         AC_HELP_STRING( [--enable-udpdump],
2785                 [build udpdump @<:@default=yes@:>@]),
2786         [],[enable_udpdump=yes])
2787
2788 if test "x$have_extcap" != xyes; then
2789         AC_MSG_RESULT([no, extcap disabled])
2790         enable_udpdump=no
2791 elif test "x$enable_udpdump" = "xyes" ; then
2792         AC_MSG_RESULT(yes)
2793 else
2794         AC_MSG_RESULT(no)
2795 fi
2796
2797 if test "x$enable_udpdump" = "xyes" ; then
2798         udpdump_bin="udpdump\$(EXEEXT)"
2799         udpdump_man="udpdump.1"
2800 else
2801         udpdump_bin=""
2802         udpdump_man=""
2803 fi
2804 AC_SUBST(udpdump_bin)
2805 AC_SUBST(udpdump_man)
2806
2807 AM_CONDITIONAL(ENABLE_STATIC, test x$enable_static = xyes)
2808 if test x$enable_static = xyes -a x$have_plugins = xyes
2809 then
2810   AC_DEFINE(ENABLE_STATIC, 1, [Link plugins statically into Wireshark])
2811 fi
2812 AC_SUBST(ENABLE_STATIC)
2813
2814 # Gather which GUI we're building for rpmbuild
2815 if test "x$have_gtk" = "xyes"; then
2816         if test "x$gtk_major_version" = "x3"; then
2817                 RPMBUILD_WITH_ARGS="--with gtk3 --without gtk2"
2818         else
2819                 RPMBUILD_WITH_ARGS="--without gtk3 --with gtk2"
2820         fi
2821 else
2822         RPMBUILD_WITH_ARGS="--without gtk2 --without gtk3"
2823 fi
2824 if test "x$have_qt" = "xyes" ; then
2825         if test "$qt_version" -eq "5"; then
2826                 RPMBUILD_WITH_ARGS="$RPMBUILD_WITH_ARGS --with qt5"
2827         else
2828                 RPMBUILD_WITH_ARGS="$RPMBUILD_WITH_ARGS --with qt"
2829         fi
2830 else
2831         RPMBUILD_WITH_ARGS="$RPMBUILD_WITH_ARGS --without qt --without qt5"
2832 fi
2833 if test "x$have_lua" = "xyes" ; then
2834         RPMBUILD_WITH_ARGS="$RPMBUILD_WITH_ARGS --with lua"
2835 else
2836         RPMBUILD_WITH_ARGS="$RPMBUILD_WITH_ARGS --without lua"
2837 fi
2838 AC_SUBST(RPMBUILD_WITH_ARGS)
2839 AC_SUBST(RPM_VERSION, version_major.version_minor.version_micro)
2840
2841 AC_SUBST(WS_CPPFLAGS)
2842 AC_SUBST(WS_CFLAGS)
2843 AC_SUBST(WS_CXXFLAGS)
2844 AC_SUBST(WS_LDFLAGS)
2845
2846 AC_SUBST(WS_CFLAGS_FOR_BUILD)
2847
2848 AH_BOTTOM([#include <ws_diag_control.h>])
2849
2850 dnl Save the cacheable configure results to config.cache before recursing
2851 AC_CACHE_SAVE
2852
2853 sinclude(plugins/Custom.m4) dnl
2854 ifdef(_CUSTOM_AC_OUTPUT_,, define(_CUSTOM_AC_OUTPUT_, )) dnl
2855
2856 sinclude(epan/dissectors/asn1/Custom.m4) dnl
2857 ifdef(_CUSTOM_ASN1_AC_OUTPUT_,, define(_CUSTOM_ASN1_AC_OUTPUT_, )) dnl
2858
2859 AC_CONFIG_HEADERS([config.h])
2860
2861 AC_CONFIG_FILES(
2862   Makefile
2863   doxygen.cfg
2864   epan/dissectors/asn1/Makefile
2865   wireshark.pc
2866   _CUSTOM_ASN1_AC_OUTPUT_
2867   epan/dissectors/asn1/acp133/Makefile
2868   epan/dissectors/asn1/acse/Makefile
2869   epan/dissectors/asn1/ansi_map/Makefile
2870   epan/dissectors/asn1/ansi_tcap/Makefile
2871   epan/dissectors/asn1/atn-cm/Makefile
2872   epan/dissectors/asn1/atn-cpdlc/Makefile
2873   epan/dissectors/asn1/atn-ulcs/Makefile
2874   epan/dissectors/asn1/c1222/Makefile
2875   epan/dissectors/asn1/camel/Makefile
2876   epan/dissectors/asn1/cdt/Makefile
2877   epan/dissectors/asn1/charging_ase/Makefile
2878   epan/dissectors/asn1/cmip/Makefile
2879   epan/dissectors/asn1/cmp/Makefile
2880   epan/dissectors/asn1/crmf/Makefile
2881   epan/dissectors/asn1/cms/Makefile
2882   epan/dissectors/asn1/credssp/Makefile
2883   epan/dissectors/asn1/dap/Makefile
2884   epan/dissectors/asn1/disp/Makefile
2885   epan/dissectors/asn1/dop/Makefile
2886   epan/dissectors/asn1/dsp/Makefile
2887   epan/dissectors/asn1/ess/Makefile
2888   epan/dissectors/asn1/ftam/Makefile
2889   epan/dissectors/asn1/goose/Makefile
2890   epan/dissectors/asn1/gprscdr/Makefile
2891   epan/dissectors/asn1/gsm_map/Makefile
2892   epan/dissectors/asn1/h225/Makefile
2893   epan/dissectors/asn1/h235/Makefile
2894   epan/dissectors/asn1/h245/Makefile
2895   epan/dissectors/asn1/h248/Makefile
2896   epan/dissectors/asn1/h282/Makefile
2897   epan/dissectors/asn1/h283/Makefile
2898   epan/dissectors/asn1/h323/Makefile
2899   epan/dissectors/asn1/h450/Makefile
2900   epan/dissectors/asn1/h450-ros/Makefile
2901   epan/dissectors/asn1/h460/Makefile
2902   epan/dissectors/asn1/h501/Makefile
2903   epan/dissectors/asn1/HI2Operations/Makefile
2904   epan/dissectors/asn1/hnbap/Makefile
2905   epan/dissectors/asn1/idmp/Makefile
2906   epan/dissectors/asn1/ilp/Makefile
2907   epan/dissectors/asn1/inap/Makefile
2908   epan/dissectors/asn1/isdn-sup/Makefile
2909   epan/dissectors/asn1/kerberos/Makefile
2910   epan/dissectors/asn1/lcsap/Makefile
2911   epan/dissectors/asn1/ldap/Makefile
2912   epan/dissectors/asn1/logotypecertextn/Makefile
2913   epan/dissectors/asn1/lpp/Makefile
2914   epan/dissectors/asn1/lppa/Makefile
2915   epan/dissectors/asn1/lppe/Makefile
2916   epan/dissectors/asn1/lte-rrc/Makefile
2917   epan/dissectors/asn1/m2ap/Makefile
2918   epan/dissectors/asn1/m3ap/Makefile
2919   epan/dissectors/asn1/mms/Makefile
2920   epan/dissectors/asn1/mpeg-audio/Makefile
2921   epan/dissectors/asn1/mpeg-pes/Makefile
2922   epan/dissectors/asn1/mudurl/Makefile
2923   epan/dissectors/asn1/nbap/Makefile
2924   epan/dissectors/asn1/ns_cert_exts/Makefile
2925   epan/dissectors/asn1/novell_pkis/Makefile
2926   epan/dissectors/asn1/ocsp/Makefile
2927   epan/dissectors/asn1/p1/Makefile
2928   epan/dissectors/asn1/p22/Makefile
2929   epan/dissectors/asn1/p7/Makefile
2930   epan/dissectors/asn1/p772/Makefile
2931   epan/dissectors/asn1/pcap/Makefile
2932   epan/dissectors/asn1/pkcs1/Makefile
2933   epan/dissectors/asn1/pkcs12/Makefile
2934   epan/dissectors/asn1/pkinit/Makefile
2935   epan/dissectors/asn1/pkixac/Makefile
2936   epan/dissectors/asn1/pkix1explicit/Makefile
2937   epan/dissectors/asn1/pkix1implicit/Makefile
2938   epan/dissectors/asn1/pkixproxy/Makefile
2939   epan/dissectors/asn1/pkixqualified/Makefile
2940   epan/dissectors/asn1/pkixtsp/Makefile
2941   epan/dissectors/asn1/pres/Makefile
2942   epan/dissectors/asn1/q932/Makefile
2943   epan/dissectors/asn1/q932-ros/Makefile
2944   epan/dissectors/asn1/qsig/Makefile
2945   epan/dissectors/asn1/ranap/Makefile
2946   epan/dissectors/asn1/rnsap/Makefile
2947   epan/dissectors/asn1/ros/Makefile
2948   epan/dissectors/asn1/rrc/Makefile
2949   epan/dissectors/asn1/rrlp/Makefile
2950   epan/dissectors/asn1/rtse/Makefile
2951   epan/dissectors/asn1/rua/Makefile
2952   epan/dissectors/asn1/s1ap/Makefile
2953   epan/dissectors/asn1/sabp/Makefile
2954   epan/dissectors/asn1/sbc-ap/Makefile
2955   epan/dissectors/asn1/smrse/Makefile
2956   epan/dissectors/asn1/snmp/Makefile
2957   epan/dissectors/asn1/spnego/Makefile
2958   epan/dissectors/asn1/sv/Makefile
2959   epan/dissectors/asn1/t124/Makefile
2960   epan/dissectors/asn1/t125/Makefile
2961   epan/dissectors/asn1/t38/Makefile
2962   epan/dissectors/asn1/tcap/Makefile
2963   epan/dissectors/asn1/tetra/Makefile
2964   epan/dissectors/asn1/ulp/Makefile
2965   epan/dissectors/asn1/wlancertextn/Makefile
2966   epan/dissectors/asn1/x2ap/Makefile
2967   epan/dissectors/asn1/x509af/Makefile
2968   epan/dissectors/asn1/x509ce/Makefile
2969   epan/dissectors/asn1/x509if/Makefile
2970   epan/dissectors/asn1/x509sat/Makefile
2971   epan/dissectors/asn1/x721/Makefile
2972   capchild/Makefile
2973   capchild/doxygen.cfg
2974   caputils/Makefile
2975   caputils/doxygen.cfg
2976   doc/Makefile
2977   docbook/Makefile
2978   epan/Makefile
2979   epan/compress/Makefile
2980   epan/crypt/Makefile
2981   epan/doxygen.cfg
2982   epan/dfilter/Makefile
2983   epan/dissectors/Makefile
2984   epan/dissectors/dcerpc/Makefile
2985   epan/ftypes/Makefile
2986   epan/wmem/Makefile
2987   epan/wslua/Makefile
2988   extcap/Makefile
2989   codecs/Makefile
2990   ui/Makefile
2991   ui/doxygen.cfg
2992   ui/gtk/Makefile
2993   ui/gtk/doxygen.cfg
2994   ui/cli/Makefile
2995   ui/qt/Makefile
2996   ui/qt/doxygen.cfg
2997   help/Makefile
2998   packaging/Makefile
2999   packaging/macosx/Info.plist
3000   packaging/macosx/Makefile
3001   packaging/macosx/osx-dmg.sh
3002   packaging/macosx/Wireshark_package.pmdoc/index.xml
3003   packaging/nsis/Makefile
3004   packaging/rpm/Makefile
3005   packaging/rpm/SPECS/Makefile
3006   packaging/rpm/SPECS/wireshark.spec
3007   packaging/svr4/Makefile
3008   packaging/svr4/checkinstall
3009   packaging/svr4/pkginfo
3010   packaging/wix/Makefile
3011   plugins/Makefile
3012   plugins/docsis/Makefile
3013   plugins/easy_codec/Makefile
3014   plugins/ethercat/Makefile
3015   plugins/gryphon/Makefile
3016   plugins/irda/Makefile
3017   plugins/m2m/Makefile
3018   plugins/mate/Makefile
3019   plugins/opcua/Makefile
3020   plugins/profinet/Makefile
3021   plugins/stats_tree/Makefile
3022   plugins/transum/Makefile
3023   plugins/unistim/Makefile
3024   plugins/wimax/Makefile
3025   plugins/wimaxasncp/Makefile
3026   plugins/wimaxmacphy/Makefile
3027   randpkt_core/doxygen.cfg
3028   randpkt_core/Makefile
3029   tools/Makefile
3030   tools/lemon/Makefile
3031   wiretap/Makefile
3032   writecap/Makefile
3033   writecap/doxygen.cfg
3034   wsutil/Makefile
3035   _CUSTOM_AC_OUTPUT_
3036 )
3037
3038 AC_OUTPUT
3039
3040
3041 # Pretty messages
3042
3043 if test "x$have_gtk" = "xyes"; then
3044         gtk_lib_message=" (with GTK+ v$GTK_VERSION"
3045         if test "x$have_ige_mac" = "xyes"; then
3046                 gtk_lib_message="$gtk_lib_message and macOS integration)"
3047         else
3048                 gtk_lib_message="$gtk_lib_message)"
3049         fi
3050 fi
3051
3052 if test "x$have_qt" = "xyes" ; then
3053         enable_wireshark_qt="yes"
3054         qt_lib_message=" (with Qt$qt_version v$QT_VERSION)"
3055 else
3056         enable_wireshark_qt="no"
3057 fi
3058
3059 if test "x$enable_setcap_install" = "xyes" ; then
3060         setcap_message="yes"
3061 else
3062         setcap_message="no"
3063 fi
3064
3065 if test "x$enable_setuid_install" = "xyes" ; then
3066         setuid_message="yes"
3067 else
3068         setuid_message="no"
3069 fi
3070
3071 if test "x$DUMPCAP_GROUP" = "x" ; then
3072         dumpcap_group_message="(none)"
3073 else
3074         dumpcap_group_message="$DUMPCAP_GROUP"
3075 fi
3076
3077 if test "x$want_zlib" = "xno" ; then
3078         zlib_message="no"
3079 else
3080         zlib_message="yes"
3081 fi
3082
3083 if test "x$have_lua" = "xyes" ; then
3084         lua_message="yes"
3085 else
3086         lua_message="no"
3087 fi
3088
3089 if test "x$have_qt_multimedia_lib" = "xyes" ; then
3090         qt_multimedia_message="yes"
3091 else
3092         qt_multimedia_message="no"
3093 fi
3094
3095 if test "x$want_portaudio" = "xyes" ; then
3096         portaudio_message="yes"
3097 else
3098         portaudio_message="no"
3099 fi
3100
3101 if test "x$want_ssl" = "xno" ; then
3102         ssl_message="no"
3103 else
3104         ssl_message="yes"
3105 fi
3106
3107 if test "x$want_krb5" = "xno" ; then
3108         krb5_message="no"
3109 else
3110         krb5_message="yes ($ac_krb5_version)"
3111 fi
3112
3113 if test "x$have_good_c_ares" = "xyes" ; then
3114         c_ares_message="yes"
3115 else
3116         c_ares_message="no (name resolution will be disabled)"
3117 fi
3118
3119 if test "x$have_good_libcap" = "xyes" ; then
3120         libcap_message="yes"
3121 else
3122         libcap_message="no"
3123 fi
3124
3125 if test "x$have_good_geoip" = "xyes" ; then
3126         geoip_message="yes"
3127 else
3128         geoip_message="no"
3129 fi
3130
3131 if test "x$have_good_libssh" = "xyes" ; then
3132         libssh_message="yes"
3133 else
3134         libssh_message="no"
3135 fi
3136
3137 if test "x$have_ssh_userauth_agent" = "xyes" ; then
3138         ssh_userauth_agent_message="yes"
3139 else
3140         ssh_userauth_agent_message="no"
3141 fi
3142
3143 if test "x$have_good_nghttp2" = "xyes" ; then
3144         nghttp2_message="yes"
3145 else
3146         nghttp2_message="no"
3147 fi
3148
3149 echo ""
3150 echo "  CPPFLAGS: $WS_CPPFLAGS $CPPFLAGS"
3151 echo ""
3152 echo "  CFLAGS: $WS_CFLAGS $CFLAGS"
3153 echo ""
3154 echo "  CXXFLAGS: $WS_CXXFLAGS $CXXFLAGS"
3155 echo ""
3156 echo "  LDFLAGS: $WS_LDFLAGS $LDFLAGS"
3157 echo ""
3158 echo "  LIBS: $LIBS"
3159
3160 echo ""
3161 echo "The Wireshark package has been configured with the following options:"
3162 echo "                       GLib version : v$GLIB_VERSION"
3163 echo "                    Build wireshark : $enable_wireshark_qt$qt_lib_message"
3164 echo "                Build wireshark-gtk : $have_gtk""$gtk_lib_message"
3165 echo "                       Build tshark : $enable_tshark"
3166 echo "                      Build tfshark : $enable_tfshark"
3167 echo "                     Build capinfos : $enable_capinfos"
3168 echo "                      Build captype : $enable_captype"
3169 echo "                      Build editcap : $enable_editcap"
3170 echo "                      Build dumpcap : $enable_dumpcap"
3171 echo "                     Build mergecap : $enable_mergecap"
3172 echo "                   Build reordercap : $enable_reordercap"
3173 echo "                    Build text2pcap : $enable_text2pcap"
3174 echo "                      Build randpkt : $enable_randpkt"
3175 echo "                       Build dftest : $enable_dftest"
3176 echo "                     Build rawshark : $enable_rawshark"
3177 echo "                       Build sharkd : $enable_sharkd"
3178 echo "                  Build androiddump : $enable_androiddump"
3179 echo "                      Build sshdump : $enable_sshdump"
3180 echo "                    Build ciscodump : $enable_ciscodump"
3181 echo "                  Build randpktdump : $enable_randpktdump"
3182 echo "                      Build udpdump : $enable_udpdump"
3183 echo ""
3184 echo "   Save files as pcap-ng by default : $enable_pcap_ng_default"
3185 echo "  Install dumpcap with capabilities : $setcap_message"
3186 echo "             Install dumpcap setuid : $setuid_message"
3187 echo "                  Use dumpcap group : $dumpcap_group_message"
3188 echo "                        Use plugins : $have_plugins"
3189 echo "       Use external capture sources : $have_extcap"
3190 echo "                    Use Lua library : $lua_message"
3191 echo "                Build Qt RTP player : $qt_multimedia_message"
3192 echo "              Build GTK+ RTP player : $portaudio_message"
3193 echo "             Build profile binaries : $enable_profile_build"
3194 echo "                   Use pcap library : $want_pcap"
3195 echo "                   Use zlib library : $zlib_message"
3196 echo "               Use kerberos library : $krb5_message"
3197 echo "                 Use c-ares library : $c_ares_message"
3198 echo "                Use SMI MIB library : $libsmi_message"
3199 echo "             Use GNU gcrypt library : yes"
3200 echo "             Use SSL crypto library : $ssl_message"
3201 echo "                 Use GnuTLS library : $tls_message"
3202 echo "     Use POSIX capabilities library : $libcap_message"
3203 echo "                  Use GeoIP library : $geoip_message"
3204 echo "                 Use libssh library : $libssh_message"
3205 echo "            Have ssh_userauth_agent : $ssh_userauth_agent_message"
3206 echo "                     Use nl library : $libnl_message"
3207 echo "              Use SBC codec library : $have_sbc"
3208 echo "                Use SpanDSP library : $have_spandsp"
3209 echo "                Use libxml2 library : $have_libxml2"
3210 echo "                Use nghttp2 library : $nghttp2_message"
3211 echo "                    Use LZ4 library : $have_lz4"
3212 echo "                 Use Snappy library : $have_snappy"
3213 #echo "       Use GDK-Pixbuf with GResource: $have_gresource_pixbuf"