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