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