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