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