Have AC_WIRESHARK_GCC_CFLAGS_CHECK take an optional second flag to
[metze/wireshark/wip.git] / configure.in
1 # $Id$
2 #
3 AC_PREREQ(2.60)
4
5 AC_INIT(wireshark, 1.7.1)
6
7 dnl Check for CPU / vendor / OS
8 dnl The user is encouraged to use either `AC_CANONICAL_BUILD', or
9 dnl `AC_CANONICAL_HOST', or `AC_CANONICAL_TARGET', depending on the
10 dnl needs.  Using `AC_CANONICAL_TARGET' is enough to run the two other
11 dnl macros.
12 dnl
13 dnl As nothing in the Wireshark is itself a build tool (we are not,
14 dnl for example, a compiler that generates machine code), we probably
15 dnl don't need AC_CANONICAL_TARGET, so, in theory, we should be able
16 dnl to use AC_CANONICAL_BUILD and AC_CANONICAL_HOST - or perhaps just
17 dnl AC_CANONICAL_HOST - instead.  Note that we do have tools, such as
18 dnl lemon, that need to be built for the build machine, not for the
19 dnl host machine, so we might need both.
20 dnl
21 dnl This has to be done *after* AC_INIT, otherwise autogen.sh fails.
22
23 dnl AC_CANONICAL_BUILD
24 dnl AC_CANONICAL_HOST
25 AC_CANONICAL_TARGET
26
27 AM_INIT_AUTOMAKE([1.9 tar-ustar dist-bzip2 no-dist-gzip])
28
29 AM_DISABLE_STATIC
30
31 dnl Checks for programs.
32 AC_PROG_CC
33 AM_PROG_CC_C_O
34 AC_PROG_CXX
35 AC_PROG_CPP
36 dnl Work around libtool bug (fixed in the version 1.5a?)
37 AC_DEFUN([AC_PROVIDE_AC_LIBTOOL_DLOPEN], )
38 AC_LIBTOOL_DLOPEN
39 AC_PROG_LIBTOOL
40 AC_PATH_PROG(PERL, perl)
41 #
42 # XXX - should autogen.sh check for YACC/Bison and Flex?  A user building
43 # from a distribution tarball shouldn't have to have YACC/Bison or Flex,
44 # as the tarball should contain the results of running YACC/Bison on .y
45 # files and running Flex on .l files, but a user building from SVN
46 # will have to run YACC/Bison and Flex to process those files.
47 #
48 # On the other hand, what about users who use a distribution tarball to
49 # do development?  They *shouldn't* - that's what the SVN repository is
50 # for - but they might.  They'd get errors if they modify a .y or .l
51 # file and try to do a build - but the error should tell them that they
52 # need to get YACC/Bison and/or Flex.
53 #
54 # Then again, getting them shouldn't be too big of a burden.
55 #
56 # XXX - is the same true of pod2man and pod2html, or are they needed
57 # even when building from a distribution tarball?
58 #
59 #
60 AC_PROG_YACC
61 AC_PATH_PROG(YACCDUMMY, $YACC)
62 if test "x$YACCDUMMY" = x
63 then
64         AC_MSG_ERROR(I couldn't find yacc (or bison or ...); make sure it's installed and in your path)
65 fi
66 AM_PROG_LEX
67 AC_PATH_PROG(LEX, flex)
68 if test "x$LEX" = x
69 then
70         AC_MSG_ERROR(I couldn't find flex; make sure it's installed and in your path)
71 fi
72 AC_PATH_PROG(POD2MAN, pod2man)
73 if test "x$POD2MAN" = x
74 then
75         #
76         # The alternative is not to build the man pages....
77         #
78         AC_MSG_ERROR(I couldn't find pod2man; make sure it's installed and in your path)
79 fi
80 AC_PATH_PROG(POD2HTML, pod2html)
81 if test "x$POD2HTML" = x
82 then
83         #
84         # The alternative is not to build the HTML man pages....
85         #
86         AC_MSG_ERROR(I couldn't find pod2html; make sure it's installed and in your path)
87 fi
88
89 #
90 # XXX - this looks for various HTML viewers on the host, not the target;
91 # we really want to know what's available on the target, for cross-builds.
92 # That would probably require us to, at run time, look for xdg-open and,
93 # if we don't find it, look for mozilla, htmlview, etc.
94 #
95 AC_PATH_PROG(HTML_VIEWER, xdg-open)
96 if test "x$HTML_VIEWER" != x
97 then
98         #
99         # XXX - the HTML_VIEWER shell variable is the full path of xdg-open.
100         # Define some variable to be that, so we just run that?
101         #
102         AC_DEFINE(HAVE_XDG_OPEN, 1, [Define if we have xdg-open])
103
104         #
105         # XXX - we have to define HTML_VIEWER for the prefs.c code that
106         # sets the default value of the Web browser preference, even
107         # though that preference won't be offered.
108         #
109         AC_DEFINE_UNQUOTED(HTML_VIEWER, "xdg-open", [HTML viewer, e.g. mozilla])
110 else
111         AC_PATH_PROG(HTML_VIEWER, htmlview)
112         if test "x$HTML_VIEWER" = x
113         then
114                 AC_DEFINE_UNQUOTED(HTML_VIEWER, "mozilla", [HTML viewer, e.g. mozilla])
115         else
116                 AC_DEFINE_UNQUOTED(HTML_VIEWER, "htmlview", [HTML viewer, e.g. mozilla])
117         fi
118 fi
119
120 AC_PATH_PROG(PYTHON, python)
121
122 AC_SUBST(PERL)
123 AC_SUBST(LEX)
124 AC_SUBST(POD2MAN)
125 AC_SUBST(POD2HTML)
126 AC_SUBST(PYTHON)
127 AC_SUBST(XSLTPROC)
128 AC_SUBST(XMLLINT)
129
130 #
131 # Set "ac_supports_gcc_flags" if the compiler is known to support GCC-style
132 # flags such as -pedantic, -W warning flags and -f feature flags.  Currently,
133 # we assume GCC and clang do; other compilers should be added here.
134 #
135 # This is done to avoid getting tripped up by compilers that support
136 # those flags but give them a different meaning.
137 #
138 if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
139         ac_supports_gcc_flags=yes
140 fi
141
142 #
143 # Set "ac_supports_W_linker_passthrough" if the compiler is known to
144 # support "-Wl,{options}" to pass options through to the linker.
145 # Currently, we assume GCC, xlc, and clang do; other compilers should
146 # be added here.
147 #
148 if test "x$GCC" = "xyes" -o "x$CC" = "xxlc" -o "x$CC" = "xclang" ; then
149         ac_supports_W_linker_passthrough=yes
150 fi
151
152 #
153 # Set "ac_supports_attribute_unused" if the compiler is known to
154 # support "__attribute__(unused)".
155 # Currently, we assume GCC and clang do; other compilers should
156 # be added here.
157 #
158 # XXX - do this with a compiler test?
159 #
160 if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
161         ac_supports_W_linker_passthrough=yes
162 fi
163
164 if test "x$CC_FOR_BUILD" = x
165 then
166        CC_FOR_BUILD=$CC
167 fi
168 AC_SUBST(CC_FOR_BUILD)
169
170 # Check for doxygen
171 AC_PATH_PROG(DOXYGEN, doxygen)
172 AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, "yes", "no")
173 AM_CONDITIONAL(HAVE_DOXYGEN, test x$HAVE_DOXYGEN = xyes)
174
175 #
176 # Try to arrange for large file support.
177 #
178 AC_SYS_LARGEFILE
179
180 # GnuTLS
181 tls_message="no"
182 AC_ARG_WITH([gnutls],
183   AC_HELP_STRING( [--with-gnutls=@<:@yes/no@:>@],
184                   [use GnuTLS library @<:@default=yes@:>@]),
185   with_gnutls="$withval", with_gnutls="yes")
186 if test "x$with_gnutls" = "xyes"; then
187   PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 1.2.0],
188         [
189                 echo "GnuTLS found, enabling SSL decryption"
190                 AC_DEFINE(HAVE_LIBGNUTLS, 1, [Define to use GnuTLS library])
191                 tls_message="yes"
192         ]
193         , [
194                 echo "GnuTLS not found, disabling SSL decryption"
195                 tls_message="no"
196         ]
197   )
198 fi
199
200 # libgrypt
201 gcrypt_message="no"
202 AC_ARG_WITH([gcrypt],
203   AC_HELP_STRING( [--with-gcrypt=@<:@yes/no@:>@],
204                   [use gcrypt library @<:@default=yes@:>@]),
205   with_gcrypt="$withval", with_gcrypt="yes")
206 if test "x$with_gcrypt" = "xyes"; then
207   AM_PATH_LIBGCRYPT(1.1.92,
208         [
209                 echo "libgcrypt found, enabling ipsec decryption"
210                 AC_DEFINE(HAVE_LIBGCRYPT, 1, [Define to use libgcrypt])
211                 gcrypt_message="yes"
212         ]
213         , [
214                 if test x$libgcrypt_config_prefix != x ; then
215                         AC_MSG_ERROR([[libgcrypt not found; install libgcrypt-devel package for your system]])
216                 else
217                         echo "libgcrypt not found, disabling ipsec decryption"
218                         gcrypt_message="no"
219                 fi
220         ]
221   )
222 fi
223
224 AC_ARG_WITH([gtk3],
225   AC_HELP_STRING( [--with-gtk3=@<:@yes/no@:>@],
226                   [use GTK+ 3.0 instead of 2.0 @<:@default=no@:>@]),
227   with_gtk3="$withval", with_gtk3="no")
228
229
230 # libsmi
231 # FIXME: currently the path argument to with-libsmi is being ignored
232 AX_LIBSMI
233
234 # Check for xsltproc
235 AC_PATH_PROG(XSLTPROC, xsltproc)
236 AC_CHECK_PROG(HAVE_XSLTPROC, xsltproc, "yes", "no")
237 AM_CONDITIONAL(HAVE_XSLTPROC, test x$HAVE_XSLTPROC = xyes)
238
239 # Check for xmllint
240 AC_PATH_PROG(XMLLINT, xmllint)
241 AC_CHECK_PROG(HAVE_XMLLINT, xmllint, "yes", "no")
242 AM_CONDITIONAL(HAVE_XMLLINT, test x$HAVE_XMLLINT = xyes)
243
244 # Check for fop (translate .fo to e.g. pdf)
245 AC_PATH_PROG(FOP, fop)
246 AC_CHECK_PROG(HAVE_FOP, fop, "yes", "no")
247 AM_CONDITIONAL(HAVE_FOP, test x$HAVE_FOP = xyes)
248
249 #
250 # Look for something to convert HTML to text (for docbook/)
251 #
252 AC_PATH_PROG(ELINKS, elinks)
253 AC_CHECK_PROG(HAVE_ELINKS, elinks, "yes", "no")
254 AM_CONDITIONAL(HAVE_ELINKS, test x$HAVE_ELINKS = xyes)
255
256 ## links: Fails as used in docbook/Makefile.am
257 ## (Rather than fixing things we'll just disable the use of links).
258 ##AC_PATH_PROG(LINKS, links)
259 ##AC_CHECK_PROG(HAVE_LINKS, links, "yes", "no")
260 ##AM_CONDITIONAL(HAVE_LINKS, test x$HAVE_LINKS = xyes)
261
262 AC_PATH_PROG(LYNX, lynx)
263 AC_CHECK_PROG(HAVE_LYNX, lynx, "yes", "no")
264 AM_CONDITIONAL(HAVE_LYNX, test x$HAVE_LYNX = xyes)
265
266
267 # Check for hhc (html help compiler)
268 AC_PATH_PROG(HHC, hhc.exe)
269 AC_CHECK_PROG(HAVE_HHC, hhc.exe, "yes", "no")
270 AM_CONDITIONAL(HAVE_HHC, test x$HAVE_HHC = xyes)
271
272 # Check for packaging utilities
273 # For now, we check to see if the various packaging utilites are in our
274 # path.  I'm too lazy to write code to go hunt for them.  -  Gerald
275
276 # SVR4/Solaris
277 AC_CHECK_PROG(HAVE_PKGPROTO, pkgproto, "yes", "no")
278 AC_CHECK_PROG(HAVE_PKGMK, pkgmk, "yes", "no")
279 AC_CHECK_PROG(HAVE_PKGTRANS, pkgtrans, "yes", "no")
280
281 if test x$HAVE_PKGPROTO = xyes -a x$HAVE_PKGMK = xyes \
282      -a x$HAVE_PKGTRANS = xyes ; then
283   HAVE_SVR4_PACKAGING=yes
284 else
285   HAVE_SVR4_PACKAGING=no
286 fi
287 AC_SUBST(HAVE_SVR4_PACKAGING)
288
289 # RPM
290 AC_WIRESHARK_RPM_CHECK
291 AC_SUBST(HAVE_RPM)
292
293 # Debian
294 AC_CHECK_PROG(HAVE_DPKG_BUILDPACKAGE, dpkg-buildpackage, "yes", "no")
295
296 # Mac OS X
297 AC_CHECK_PROG(HAVE_XCODEBUILD, xcodebuild, "yes", "no")
298 AC_CHECK_PROG(HAVE_HDIUTIL, hdiutil, "yes", "no")
299 AC_CHECK_PROG(HAVE_BLESS, bless, "yes", "no")
300
301 if test x$HAVE_XCODEBUILD = xyes -a x$HAVE_HDIUTIL = xyes \
302      -a x$HAVE_BLESS = xyes ; then
303   HAVE_OSX_PACKAGING=yes
304 else
305   HAVE_OSX_PACKAGING=no
306 fi
307 AC_SUBST(HAVE_OSX_PACKAGING)
308
309 #
310 # Try to add some additional gcc checks to CFLAGS
311 #
312 AC_ARG_ENABLE(extra-gcc-checks,
313   AC_HELP_STRING( [--enable-extra-gcc-checks],
314                   [do additional -W checks in GCC @<:@default=no@:>@]),
315 [
316         wireshark_extra_gcc_flags=$enableval
317         if test $enableval != no
318         then
319                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-pedantic)
320                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Woverflow)
321                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wlogical-op)
322                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-overlength-strings)
323 #               AC_WIRESHARK_GCC_CFLAGS_CHECK(-fstrict-overflow -Wstrict-overflow=4)
324 #               AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wunreachable-code)
325 #               AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wunsafe-loop-optimizations)
326                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-long-long)
327                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wbad-function-cast, C)
328                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wcast-qual)
329                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Waddress)
330                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Warray-bounds)
331                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wattributes)
332                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wdiv-by-zero)
333                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wignored-qualifiers)
334                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wpragmas)
335                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wredundant-decls)
336                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wvla)
337                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wc++-compat, C)
338                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wjump-misses-init, C)
339                 #
340                 # epan/dissectors/packet-ncp2222.inc blocks this one
341                 # for now.
342                 #
343                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wwrite-strings)
344                 #
345                 # GLib blocks this for now.
346                 #
347                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wstrict-prototypes)
348                 #
349                 # All the registration functions block these for now.
350                 #
351                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wmissing-prototypes)
352                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wmissing-declarations)
353                 #
354                 # epan/dissectors/packet-afs.c blocks this one for now.
355                 #
356                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wshadow)
357                 #
358                 # More cleanup needed for this on LP64.
359                 #
360                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wshorten-64-to-32)
361         fi
362 ],)
363 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wall -W) # -W is now known as -Wextra
364 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wextra) # -W is now known as -Wextra
365 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wdeclaration-after-statement, C)
366 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wendif-labels)
367 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wpointer-arith)
368 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-pointer-sign, C)
369 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Warray-bounds)
370 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wcast-align)
371 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wformat-security)
372 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wold-style-definition, C)
373 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-error=unused-but-set-variable)    ##  for now
374 #
375 # Use the faster pre gcc 4.5 floating point precision if available;
376 # clang doesn't error out on -f options that it doesn't know about,
377 # it just warns and ignores them, so this check doesn't cause us
378 # to omit -fexcess-precision=fast, which produces a pile of
379 # annoying warnings.
380 #
381 if test "x$CC" != "xclang" ; then
382 AC_WIRESHARK_GCC_CFLAGS_CHECK(-fexcess-precision=fast)
383 fi
384
385 AC_WIRESHARK_LDFLAGS_CHECK([-Wl,--as-needed])
386 ###AC_WIRESHARK_LDFLAGS_CHECK([-Wl,-M])
387 ###AC_WIRESHARK_LDFLAGS_CHECK([-Wl,--cref])
388 # AC_WIRESHARK_LDFLAGS_CHECK([-flto])
389 # AC_WIRESHARK_LDFLAGS_CHECK([-fwhopr])
390 # AC_WIRESHARK_LDFLAGS_CHECK([-fwhole-program])
391
392 #
393 # If we're running GCC or clang, add '-D_U_="__attribute__((unused))"' to
394 # CFLAGS as well, so we can use _U_ to flag unused function arguments and
395 # not get warnings about them. Otherwise, add '-D_U_=""', so that _U_ used
396 # to flag an unused function argument will compile with non-GCC, non-clang
397 # compilers.
398 #
399 # XXX - other compilers?
400 #
401 if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
402   CFLAGS="-D_U_=\"__attribute__((unused))\" $CFLAGS"
403 else
404   CFLAGS="-D_U_=\"\" $CFLAGS"
405 fi
406
407 # If we're running GCC or CLang, always use FORTIFY_SOURCE=2
408 # See: http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
409 # Note: FORTIFY_SOURCE is only effective for gcc -O2 (and -O1 ?)
410 if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
411   CFLAGS="-D_FORTIFY_SOURCE=2 $CFLAGS"
412 fi
413
414 #
415 # If the compiler supports GCC-style flags, enable a barrier "stop on
416 # warning".
417 # This barrier is set for a very large part of the code. However, it is
418 # typically not set for "generated" code  (flex, ans2wrs, idl2wrs, ...)
419 #
420 warnings_as_errors_default="yes"
421 AC_MSG_CHECKING(whether we should treat compiler warnings as errors)
422 AC_ARG_ENABLE(warnings-as-errors,
423   AC_HELP_STRING( [--enable-warnings-as-errors],
424                   [treat warnings as errors (only for GCC or clang) @<:@default=yes@:>@]),
425 [
426   if test "x$ac_supports_gcc_flags" = "xyes" -a "x$enableval" = "xyes" -a "x$wireshark_extra_gcc_flags" != "xyes"; then
427     with_warnings_as_errors="yes"
428     AC_MSG_RESULT(yes)
429   else
430     with_warnings_as_errors="no"
431     AC_MSG_RESULT(no)
432   fi
433 ],
434   if test "x$ac_supports_gcc_flags" = "xyes" -a "x$wireshark_extra_gcc_flags" = "x" -a "x$warnings_as_errors_default" = "xyes"; then
435     with_warnings_as_errors="yes"
436     AC_MSG_RESULT(yes)
437   else
438     with_warnings_as_errors="no"
439     AC_MSG_RESULT(no)
440   fi
441 )
442 AM_CONDITIONAL(HAVE_WARNINGS_AS_ERRORS, test "x$with_warnings_as_errors" = "xyes")
443
444 #
445 # Add any platform-specific compiler flags needed.
446 #
447 AC_MSG_CHECKING(for platform-specific compiler flags)
448 if test "x$GCC" = "xyes" ; then
449         #
450         # GCC - do any platform-specific tweaking necessary.
451         #
452         case "$host_os" in
453         solaris*)
454                 # the X11 headers don't automatically include prototype info
455                 # and a lot don't include the return type
456                 CFLAGS="$CFLAGS -Wno-return-type -DFUNCPROTO=15"
457                 AC_MSG_RESULT(GCC on Solaris - added -Wno-return-type -DFUNCPROTO=15)
458                 ;;
459         darwin*)
460                 #
461                 # See comments above about Apple's lovely C compiler.
462                 #
463                 # NOTE: to AC_PROG_CC, "GCC" means "any compiler that
464                 # defines __GNUC__"; clang defines __GNUC__, so that
465                 # means we think clang is GCC.
466                 #
467                 # clang whines about -no-cpp-precomp being unused
468                 # so we check whether this is really clang, and
469                 # only add -no-cpp-precomp if it's not.
470                 #
471                 if test "x$CC" != "xclang" ; then
472                         CFLAGS="-no-cpp-precomp $CFLAGS"
473                         AC_MSG_RESULT(Apple GCC - added -no-cpp-precomp)
474                 else
475                         #
476                         # Clang, clang, clang went the trolley....
477                         #
478                         AC_MSG_RESULT(none needed)
479                 fi
480                 ;;
481         *)
482                 AC_MSG_RESULT(none needed)
483                 ;;
484         esac
485 else
486         #
487         # Not GCC - assume it's the vendor's compiler.
488         #
489         case "$host_os" in
490         hpux*)
491                 #
492                 # HP's ANSI C compiler; flags suggested by Jost Martin.
493                 # "-Ae" for ANSI C plus extensions such as "long long".
494                 # "+O2", for optimization.  XXX - works with "-g"?
495                 #
496                 CFLAGS="-Ae +O2 $CFLAGS"
497                 AC_MSG_RESULT(HP ANSI C compiler - added -Ae +O2)
498                 ;;
499         darwin*)
500                 #
501                 # It may be called "cc", but it's really a GCC derivative
502                 # with a problematic special precompiler and precompiled
503                 # headers; turn off the special precompiler, as some
504                 # apparently-legal code won't compile with its precompiled
505                 # headers.
506                 #
507                 # On the other hand, if it's called "clang", it's not a
508                 # GCC derivative, and it whines if you pass it
509                 # -no-cpp-precomp.
510                 #
511                 # XXX - is there any version of autoconf we support
512                 # where it uses another way to decide if the compiler
513                 # is GCC or not?
514                 #
515                 if test "x$CC" != "xclang" ; then
516                         CFLAGS="-no-cpp-precomp $CFLAGS"
517                         AC_MSG_RESULT(Apple CC - added -no-cpp-precomp)
518                 else
519                         #
520                         # Clang, clang, clang went the trolley....
521                         #
522                         AC_MSG_RESULT(none needed)
523                 fi
524                 ;;
525         *)
526                 AC_MSG_RESULT(none needed)
527                 ;;
528         esac
529 fi
530
531 #
532 # Add any platform-specific linker flags needed.
533 #
534 AC_MSG_CHECKING(for platform-specific linker flags)
535 case "$host_os" in
536 darwin*)
537         #
538         # Add -Wl,-single_module to the LDFLAGS used with shared
539         # libraries, to fix some error that show up in some cases;
540         # some Apple documentation recommends it for most shared
541         # libraries.
542         #
543         LDFLAGS_SHAREDLIB="-Wl,-single_module"
544         #
545         # Add -Wl,-search_paths_first to make sure that if we search
546         # directories A and B, in that order, for a given library, a
547         # non-shared version in directory A, rather than a shared
548         # version in directory B, is chosen (so we can use
549         # --with-pcap=/usr/local to force all programs to be linked
550         # with a static version installed in /usr/local/lib rather than
551         # the system version in /usr/lib).
552         #
553         LDFLAGS="-Wl,-search_paths_first $LDFLAGS"
554         AC_MSG_RESULT([Apple linker - added -Wl,-single_module and -Wl,-search_paths_first])
555         ;;
556 cygwin*)
557         #
558         # Shared libraries in cygwin/Win32 must never contain
559         # undefined symbols.
560         #
561         LDFLAGS="$LDFLAGS -no-undefined"
562         AC_MSG_RESULT(CygWin GNU ld - added -no-undefined)
563         ;;
564 *)
565         AC_MSG_RESULT(none needed)
566         ;;
567 esac
568 AC_SUBST(LDFLAGS_SHAREDLIB)
569
570 # Control silent compiling
571 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
572
573 #
574 # On OS X, if we find the headers for Core Foundation, Launch Services,
575 # and Core Services, add -framework options to link with Application
576 # Services (of which Launch Services is a subframework), Core Foundation
577 # (required by the Launch Services APIs), and Core Services, so we can
578 # use them to launch a Web browser from the Help menu and to use
579 # Gestalt() to get the Mac OS X version number.
580 #
581 case "$host_os" in
582
583 darwin*)
584         AC_MSG_CHECKING([whether we can build with Core Foundation, Launch Services, and Core Services])
585         ac_save_LIBS="$LIBS"
586         ac_coreservices_frameworks="-framework CoreServices"
587         ac_launchservices_frameworks="-framework ApplicationServices -framework CoreFoundation $ac_coreservices_frameworks"
588         LIBS="$LIBS $ac_launchservices_frameworks $ac_coreservices_frameworks"
589         AC_TRY_LINK(
590            [
591 #       include <CoreFoundation/CFBase.h>
592 #       include <CoreFoundation/CFString.h>
593 #       include <CoreFoundation/CFURL.h>
594 #       include <ApplicationServices/ApplicationServices.h>
595 #       include <CoreServices/CoreServices.h>
596            ],
597            [
598         CFStringRef url_CFString;
599         CFURLRef url_CFURL;
600         OSStatus status;
601         long os_version;
602
603         url_CFString = CFStringCreateWithCString(NULL, "", kCFStringEncodingASCII);
604         url_CFURL = CFURLCreateWithString(NULL, url_CFString, NULL);
605         status = LSOpenCFURLRef(url_CFURL, NULL);
606
607         Gestalt(gestaltSystemVersion, &os_version);
608            ],
609            ac_cv_can_use_osx_frameworks=yes,
610            ac_cv_can_use_osx_frameworks=no,
611            [echo $ac_n "cross compiling; assumed OK... $ac_c"])
612         if test "$ac_cv_can_use_osx_frameworks" = yes ; then
613                 AC_DEFINE(HAVE_OS_X_FRAMEWORKS, 1, [Define to 1 if you have OS X frameworks])
614                 CORESERVICES_FRAMEWORKS="$ac_coreservices_frameworks"
615                 LAUNCHSERVICES_FRAMEWORKS="$ac_launchservices_frameworks"
616                 AC_MSG_RESULT(yes)
617         else
618                 AC_MSG_RESULT(no)
619         fi
620         LIBS="$ac_save_LIBS"
621         ;;
622 esac
623 AC_SUBST(CORESERVICES_FRAMEWORKS)
624 AC_SUBST(LAUNCHSERVICES_FRAMEWORKS)
625
626 #
627 # If using $prefix we add "$prefix/include" to the include search path
628 # and "$prefix/lib" to the library search path.
629 #
630 if test "x$prefix" != "x" ; then
631         AC_MSG_CHECKING(whether to use $prefix for headers and libraries)
632         if test -d $prefix/include ; then
633                 AC_MSG_RESULT(yes)
634                 #
635                 # Arrange that we search for header files in "$prefix/include", as
636                 # various packages we use may have been installed under "$prefix/include".
637                 #
638                 CFLAGS="$CFLAGS -I$prefix/include"
639                 CPPFLAGS="$CPPFLAGS -I$prefix/include"
640
641                 #
642                 # Arrange that we search for libraries in "$prefix/lib".
643                 #
644                 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, $prefix/lib)
645         else
646                 AC_MSG_RESULT(no)
647         fi
648 fi
649
650 dnl Look in /usr/local for header files and libraries ?
651 dnl XXX FIXME don't include /usr/local if it is already in the system
652 dnl search path as this causes gcc 3.2 on Linux to complain about a change
653 dnl of the system search order for includes
654 AC_ARG_ENABLE(usr-local,
655   AC_HELP_STRING( [--enable-usr-local],
656                   [look for headers and libs in /usr/local tree @<:@default=yes@:>@]),
657     ac_cv_enable_usr_local=$enableval,ac_cv_enable_usr_local=yes)
658
659 AC_MSG_CHECKING(whether to use /usr/local for headers and libraries)
660 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
661         if test -d "/usr/local"; then
662                 AC_MSG_RESULT(yes)
663                 #
664                 # Arrange that we search for header files in the source directory
665                 # and in its "wiretap" subdirectory, as well as in "/usr/local/include",
666                 # as various packages we use ("libpcap", "zlib", "adns")
667                 # may have been installed under "/usr/local/include".
668                 #
669                 CFLAGS="$CFLAGS -I/usr/local/include"
670                 CPPFLAGS="$CPPFLAGS -I/usr/local/include"
671
672                 #
673                 # Arrange that we search for libraries in "/usr/local/lib".
674                 #
675                 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, /usr/local/lib)
676         else
677                 AC_MSG_RESULT(no)
678         fi
679 else
680         AC_MSG_RESULT(no)
681 fi
682
683 #
684 # If we're running Solaris, and LD_LIBRARY_PATH is defined, add it as a
685 # link directory.
686 #
687 case "$host_os" in
688   solaris*)
689     AC_MSG_CHECKING(for LD_LIBRARY_PATH, since you appear to be running Solaris)
690     if test x$LD_LIBRARY_PATH != x ; then
691       LIBS="$LIBS -R$LD_LIBRARY_PATH"
692       AC_MSG_RESULT(yes -- added LD_LIBRARY_PATH to run-time linker path)
693     else
694       AC_MSG_RESULT(no -- this may be a problem in a few seconds)
695     fi
696   ;;
697 esac
698
699 #
700 # Check for versions of "sed" inadequate to handle, in libtool, a list
701 # of object files as large as the list in Wireshark.
702 #
703 # On Solaris, we check for "/bin/sed", "/usr/bin/sed", and "/usr/ucb/sed",
704 # as both "/usr/bin/sed" (which is also "/bin/sed", as "/bin" is just a
705 # symlink to "/usr/bin", but people may have "/bin" before "/usr/bin" in
706 # their search path) and "/usr/ucb/sed" are inadequate; "/usr/xpg4/bin/sed"
707 # is the only "sed" that comes with Solaris that can handle Wireshark.
708 #
709 # Add any checks here that are necessary for other OSes.
710 #
711 AC_WIRESHARK_GNU_SED_CHECK
712 if test "$HAVE_GNU_SED" = no ; then
713         case "$host_os" in
714         solaris*)
715                 AC_MSG_CHECKING(whether one of /usr/bin/sed or /bin/sed or /usr/ucb/sed will be used)
716                 case `which sed` in
717                         /bin/sed|/usr/bin/sed|/usr/ucb/sed)
718                         AC_MSG_RESULT(yes)
719                         AC_MSG_ERROR([change your path to search /usr/xpg4/bin or directory containing GNU sed before /usr/bin (and /bin and /usr/ucb)])
720                         ;;
721
722                         *)
723                         AC_MSG_RESULT(no)
724                         ;;
725                 esac
726                 ;;
727
728         *)
729                 :
730                 ;;
731         esac
732 fi
733
734 # Enable/disable wireshark
735
736 AC_ARG_ENABLE(wireshark,
737   AC_HELP_STRING( [--enable-wireshark],
738                   [build GTK+-based Wireshark @<:@default=yes, if GTK+ available@:>@]),
739     enable_wireshark=$enableval,enable_wireshark=yes)
740
741 AC_ARG_ENABLE(packet-editor,
742   AC_HELP_STRING( [--enable-packet-editor],
743                   [add support for packet editor in Wireshark @<:@default=no@:>@]),
744     enable_packet_editor=$enableval,enable_packet_editor=no)
745 if test x$enable_packet_editor = xyes; then
746         AC_DEFINE(WANT_PACKET_EDITOR, 1, [Support for packet editor])
747 fi
748
749 AC_ARG_ENABLE(profile-build,
750   AC_HELP_STRING( [--enable-profile-build],
751                   [build profile-ready binaries @<:@default=no@:>@]),
752     enable_profile_build=$enableval,enable_profile_build=no)
753 AM_CONDITIONAL(USE_PROFILE_BUILD, test x$enable_profile_build = xyes)
754 AC_MSG_CHECKING(if profile builds must be generated)
755 if test "x$enable_profile_build" = "xyes" ; then
756         if test "x$GCC" = "xyes" -o "x$CLANG" = "xyes" ; then
757                 AC_MSG_RESULT(yes)
758                 CFLAGS=" -pg $CFLAGS"
759         else
760                 AC_MSG_RESULT(no)
761                 echo "Building profile binaries currently only supported for GCC and clang."
762         fi
763 else
764         AC_MSG_RESULT(no)
765 fi
766
767 # Create DATAFILE_DIR #define for config.h
768 datafiledir=$datadir/wireshark
769 datafiledir=`(
770     test "x$prefix" = xNONE && prefix=$ac_default_prefix
771     test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
772     # Ugly hack, but I don't see how this problem can be solved
773     # properly that DATAFILE_DIR had a value starting with
774     # "${prefix}/" instead of e.g. "/usr/local/"
775     eval eval echo "$datafiledir"
776 )`
777 AC_DEFINE_UNQUOTED(DATAFILE_DIR,"$datafiledir", [Directory for data])
778
779 # Create DOC_DIR #define for config.h
780 docdir=`(
781     test "x$prefix" = xNONE && prefix=$ac_default_prefix
782     test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
783     # Ugly hack, but I don't see how this problem can be solved
784     # properly that DOC_DIR had a value starting with
785     # "${prefix}/" instead of e.g. "/usr/local/"
786     eval eval echo "$docdir"
787 )`
788 AC_DEFINE_UNQUOTED(DOC_DIR, "$docdir", [Directory for docs])
789
790 # GTK checks; we require GTK+ 2.12 or later.
791 # We don't add $GLIB_LIBS to LIBS, because we don't want to force all
792 # programs to be built with GTK+.
793 #
794 if test "x$enable_wireshark" = "xyes"; then
795         if test "x$with_gtk3" = "xyes"; then
796                 AM_PATH_GTK_3_0(3.0.0,
797                 [
798                         CFLAGS="$CFLAGS $GTK_CFLAGS"
799                         CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
800                         have_gtk=yes
801                         AC_DEFINE(HAVE_GTK, 1,
802                             [Define to 1 if compiling with GTK])
803                 ], have_gtk=no)
804
805         else
806                 AM_PATH_GTK_2_0(2.12.0,
807                 [
808                         CFLAGS="$CFLAGS $GTK_CFLAGS"
809                         CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
810                         have_gtk=yes
811                         AC_DEFINE(HAVE_GTK, 1,
812                             [Define to 1 if compiling with GTK])
813                 ], have_gtk=no)
814         fi
815 else
816         have_gtk=no
817 fi
818
819 # GLib checks; we require GLib 2.14 or later, and require gmodule
820 # support, as we need that for dynamically loading plugins.
821 # If we found GTK+, this doesn't add GLIB_CFLAGS to CFLAGS, because
822 # AM_PATH_GTK will add GTK_CFLAGS to CFLAGS, and GTK_CFLAGS is a
823 # superset of GLIB_CFLAGS.  If we didn't find GTK+, it does add
824 # GLIB_CFLAGS to CFLAGS.
825 # However, this means that both @GLIB_LIBS@ and @GTK_LIBS@ will be
826 # set when generating the Makefile, so we can make programs that require
827 # only GLib link with @GLIB_LIBS@ and make programs that require GTK+
828 # link with @GTK_LIBS@ (which includes @GLIB_LIBS@).
829 # We don't add $GLIB_LIBS to LIBS, because we don't want to force all
830 # programs to be built with GLib.
831 #
832 if test "$have_gtk" = "no" ; then
833         #
834         # We don't have GTK+.
835         # If they didn't explicitly say "--disable-wireshark", fail (so
836         # that, unless they explicitly indicated that they don't want
837         # Wireshark, we stop so they know they won't be getting
838         # Wireshark unless they fix the GTK+ problem).
839         #
840         if test "x$enable_wireshark" = "xyes"; then
841                 if test "x$with_gtk3" = "xyes"; then
842                         AC_MSG_ERROR([GTK+ 3.0 or later isn't available, so Wireshark can't be compiled])
843                 else
844                         AC_MSG_ERROR([GTK+ 2.12 or later isn't available, so Wireshark can't be compiled])
845                 fi
846         fi
847         wireshark_bin=""
848         wireshark_man=""
849         # Use GLIB_CFLAGS
850         AM_PATH_GLIB_2_0(2.14.0,
851         [
852                 CFLAGS="$CFLAGS $GLIB_CFLAGS"
853                 CXXFLAGS="$CXXFLAGS $GLIB_CFLAGS"
854         ], AC_MSG_ERROR(GLib 2.14 or later distribution not found.), gthread gmodule)
855 else
856         #
857         # We have GTK+, and thus will be building Wireshark unless the
858         # user explicitly disabled it.
859         #
860         wireshark_bin="wireshark\$(EXEEXT)"
861         wireshark_man="wireshark.1"
862         wireshark_SUBDIRS="codecs ui/gtk"
863         # Don't use GLIB_CFLAGS
864         AM_PATH_GLIB_2_0(2.14.0, , AC_MSG_ERROR(GLib 2.14 or later distribution not found.), gthread gmodule)
865
866         CFLAGS="-DGTK_DISABLE_SINGLE_INCLUDES $CFLAGS"
867         ## Define GTK_DISABLE_DEPRECATED only if GTK lt 3.2
868         ## GTK 3.2 deprecates GtkVBox & GtkHBox which are currently used extensively by Wireshark.
869         if test $gtk_config_major_version -eq 2 -o $gtk_config_minor_version -lt 2; then
870                 CFLAGS="-DGTK_DISABLE_DEPRECATED $CFLAGS"
871         fi
872         # CFLAGS="-DGDK_DISABLE_DEPRECATED $CFLAGS"
873         if test $gtk_config_major_version -eq 2 -a $gtk_config_minor_version -ge 20; then
874                 # Enable GSEAL when building with GTK > 2.20 and < 3.0
875                 # (Versions prior to 2.22 lacked some necessary accessors.)
876                 CFLAGS="-DGSEAL_ENABLE $CFLAGS"
877         fi
878 fi
879
880 # Error out if a glib header other than a "top level" header
881 #  (glib.h, glib-object.h, gio.h) or certain other headers( e.g.,gmodule.h)
882 #  is used.
883 CFLAGS="-DG_DISABLE_SINGLE_INCLUDES $CFLAGS"
884
885 # Error out on the usage of deprecated glib functions
886 CFLAGS="-DG_DISABLE_DEPRECATED $CFLAGS"
887
888 #
889 # Check whether GLib modules are supported, to determine whether we
890 # can support plugins.
891 #
892 AC_MSG_CHECKING(whether GLib supports loadable modules)
893 ac_save_CFLAGS="$CFLAGS"
894 ac_save_LIBS="$LIBS"
895 CFLAGS="$CFLAGS $GLIB_CFLAGS"
896 LIBS="$GLIB_LIBS $LIBS"
897 AC_TRY_RUN([
898 #include <glib.h>
899 #include <gmodule.h>
900 #include <stdio.h>
901 #include <stdlib.h>
902
903 int
904 main ()
905 {
906   if (g_module_supported())
907     return 0;   /* success */
908   else
909     return 1;   /* failure */
910 }
911 ], ac_cv_glib_supports_modules=yes, ac_cv_glib_supports_modules=no,
912    [echo $ac_n "cross compiling; assumed OK... $ac_c"
913     ac_cv_glib_supports_modules=yes])
914 CFLAGS="$ac_save_CFLAGS"
915 LIBS="$ac_save_LIBS"
916 if test "$ac_cv_glib_supports_modules" = yes ; then
917   AC_MSG_RESULT(yes)
918   have_plugins=yes
919 else
920   AC_MSG_RESULT(no)
921   have_plugins=no
922 fi
923
924 #
925 # If we have <dlfcn.h>, check whether we can use dladdr to find a
926 # filename (hopefully, a full pathname, but no guarantees) for
927 # the executable.
928 #
929 if test "$ac_cv_header_dlfcn_h" = "yes"
930 then
931         AC_MSG_CHECKING(whether dladdr can be used to find the pathname of an executable)
932         ac_save_CFLAGS="$CFLAGS"
933         ac_save_LIBS="$LIBS"
934         CFLAGS="$CFLAGS $GLIB_CFLAGS"
935         LIBS="$GLIB_LIBS $LIBS"
936         AC_TRY_RUN([
937 #define _GNU_SOURCE     /* required on Linux, sigh */
938 #include <dlfcn.h>
939
940 int
941 main(void)
942 {
943         Dl_info info;
944
945         if (!dladdr((void *)main, &info))
946                 return 1;       /* failure */
947         return 0;               /* assume success */
948 }
949 ], ac_cv_dladdr_finds_executable_path=yes, ac_cv_dladdr_finds_executable_path=no,
950    [echo $ac_n "cross compiling; assumed OK... $ac_c"
951     ac_cv_dladdr_finds_executable_path=yes])
952         CFLAGS="$ac_save_CFLAGS"
953         LIBS="$ac_save_LIBS"
954         if test x$ac_cv_dladdr_finds_executable_path = xyes
955         then
956                 AC_DEFINE(DLADDR_FINDS_EXECUTABLE_PATH, 1, [Define if dladdr can be used to find the path of the executable])
957         fi
958         AC_MSG_RESULT($ac_cv_dladdr_finds_executable_path)
959 fi
960
961 if test "x$have_gtk" = "xyes"
962 then
963     #
964     # We have GTK+; do we want the OS X integration functions and,
965     # if so, do we have them and, if so, which versions do we have,
966     # the old Carbon-based ones or the new Cocoa-based ones?
967     #
968     AC_MSG_CHECKING(whether to use OS X integration functions)
969
970     AC_ARG_WITH(osx-integration,
971       AC_HELP_STRING( [--with-osx-integration],
972                       [use OS X integration functions @<:@default=yes, if available@:>@]),
973     [
974         if test $withval = no
975         then
976             want_osx_integration=no
977         else
978             want_osx_integration=yes
979         fi
980     ],[
981         want_osx_integration=yes
982     ])
983     if test "x$want_osx_integration" = "xno"; then
984         AC_MSG_RESULT(no)
985     else
986         AC_MSG_RESULT(yes)
987         AC_WIRESHARK_OSX_INTEGRATION_CHECK
988     fi
989 fi
990
991 AC_SUBST(wireshark_bin)
992 AC_SUBST(wireshark_man)
993
994
995 # Enable/disable tshark
996
997 AC_ARG_ENABLE(tshark,
998   AC_HELP_STRING( [--enable-tshark],
999                   [build TShark @<:@default=yes@:>@]),
1000     tshark=$enableval,enable_tshark=yes)
1001
1002 if test "x$enable_tshark" = "xyes" ; then
1003         tshark_bin="tshark\$(EXEEXT)"
1004         tshark_man="tshark.1"
1005         wiresharkfilter_man="wireshark-filter.4"
1006 else
1007         tshark_bin=""
1008         tshark_man=""
1009 fi
1010 AC_SUBST(tshark_bin)
1011 AC_SUBST(tshark_man)
1012 AC_SUBST(wiresharkfilter_man)
1013
1014
1015
1016 # Enable/disable editcap
1017
1018 AC_ARG_ENABLE(editcap,
1019   AC_HELP_STRING( [--enable-editcap],
1020                   [build editcap @<:@default=yes@:>@]),
1021     enable_editcap=$enableval,enable_editcap=yes)
1022
1023 if test "x$enable_editcap" = "xyes" ; then
1024         editcap_bin="editcap\$(EXEEXT)"
1025         editcap_man="editcap.1"
1026 else
1027         editcap_bin=""
1028         editcap_man=""
1029 fi
1030 AC_SUBST(editcap_bin)
1031 AC_SUBST(editcap_man)
1032
1033 # Enabling/disabling of dumpcap is done later (after we know if we have PCAP
1034 # or not)
1035
1036 # Enable/disable capinfos
1037
1038 AC_ARG_ENABLE(capinfos,
1039   AC_HELP_STRING( [--enable-capinfos],
1040                   [build capinfos @<:@default=yes@:>@]),
1041     enable_capinfos=$enableval,enable_capinfos=yes)
1042
1043 if test "x$enable_capinfos" = "xyes" ; then
1044         capinfos_bin="capinfos\$(EXEEXT)"
1045         capinfos_man="capinfos.1"
1046 else
1047         capinfos_bin=""
1048         capinfos_man=""
1049 fi
1050 AC_SUBST(capinfos_bin)
1051 AC_SUBST(capinfos_man)
1052
1053
1054 # Enable/disable mergecap
1055
1056 AC_ARG_ENABLE(mergecap,
1057   AC_HELP_STRING( [--enable-mergecap],
1058                   [build mergecap @<:@default=yes@:>@]),
1059     enable_mergecap=$enableval,enable_mergecap=yes)
1060
1061 if test "x$enable_mergecap" = "xyes" ; then
1062         mergecap_bin="mergecap\$(EXEEXT)"
1063         mergecap_man="mergecap.1"
1064 else
1065         mergecap_bin=""
1066         mergecap_man=""
1067 fi
1068 AC_SUBST(mergecap_bin)
1069 AC_SUBST(mergecap_man)
1070
1071
1072 # Enable/disable text2pcap
1073
1074 AC_ARG_ENABLE(text2pcap,
1075   AC_HELP_STRING( [--enable-text2pcap],
1076                   [build text2pcap @<:@default=yes@:>@]),
1077     text2pcap=$enableval,enable_text2pcap=yes)
1078
1079 if test "x$enable_text2pcap" = "xyes" ; then
1080         text2pcap_bin="text2pcap\$(EXEEXT)"
1081         text2pcap_man="text2pcap.1"
1082 else
1083         text2pcap_bin=""
1084         text2pcap_man=""
1085 fi
1086 AC_SUBST(text2pcap_bin)
1087 AC_SUBST(text2pcap_man)
1088
1089
1090 # Enable/disable dftest
1091
1092 AC_ARG_ENABLE(dftest,
1093   AC_HELP_STRING( [--enable-dftest],
1094                   [build dftest @<:@default=yes@:>@]),
1095     enable_dftest=$enableval,enable_dftest=yes)
1096
1097 if test "x$enable_dftest" = "xyes" ; then
1098         dftest_bin="dftest\$(EXEEXT)"
1099         dftest_man="dftest.1"
1100 else
1101         dftest_bin=""
1102         dftest_man=""
1103 fi
1104 AC_SUBST(dftest_bin)
1105 AC_SUBST(dftest_man)
1106
1107
1108 # Enable/disable randpkt
1109
1110 AC_ARG_ENABLE(randpkt,
1111   AC_HELP_STRING( [--enable-randpkt],
1112                   [build randpkt @<:@default=yes@:>@]),
1113     enable_randpkt=$enableval,enable_randpkt=yes)
1114
1115 if test "x$enable_randpkt" = "xyes" ; then
1116         randpkt_bin="randpkt\$(EXEEXT)"
1117         randpkt_man="randpkt.1"
1118 else
1119         randpkt_bin=""
1120         randpkt_man=""
1121 fi
1122 AC_SUBST(randpkt_bin)
1123 AC_SUBST(randpkt_man)
1124
1125
1126
1127 dnl Checks for "gethostbyname()" - and "-lnsl", if we need it to get
1128 dnl "gethostbyname()".
1129 AC_WIRESHARK_GETHOSTBY_LIB_CHECK
1130
1131 dnl Checks for "connect()", used as a proxy for "socket()" - and
1132 dnl "-lsocket", if we need it to get "connect()".
1133 AC_WIRESHARK_SOCKET_LIB_CHECK
1134
1135 dnl pcap check
1136 AC_MSG_CHECKING(whether to use libpcap for packet capture)
1137
1138 AC_ARG_WITH(pcap,
1139   AC_HELP_STRING( [--with-pcap@<:@=DIR@:>@],
1140                   [use libpcap for packet capturing @<:@default=yes@:>@]),
1141 [
1142         if test $withval = no
1143         then
1144                 want_pcap=no
1145         elif test $withval = yes
1146         then
1147                 want_pcap=yes
1148         else
1149                 want_pcap=yes
1150                 pcap_dir=$withval
1151         fi
1152 ],[
1153         want_pcap=yes
1154         pcap_dir=
1155 ])
1156 if test "x$want_pcap" = "xno" ; then
1157         AC_MSG_RESULT(no)
1158 else
1159         AC_MSG_RESULT(yes)
1160         AC_WIRESHARK_PCAP_CHECK
1161 fi
1162
1163 # Enable/disable dumpcap
1164
1165 dnl dumpcap check
1166 AC_MSG_CHECKING(whether to build dumpcap)
1167
1168 AC_ARG_ENABLE(dumpcap,
1169   AC_HELP_STRING( [--enable-dumpcap],
1170                   [build dumpcap @<:@default=yes@:>@]),
1171     enable_dumpcap=$enableval,enable_dumpcap=yes)
1172
1173 if test "x$enable_dumpcap" = "xyes" ; then
1174         if test "x$want_pcap" = "xno" ; then
1175                 enable_dumpcap=no
1176                 AC_MSG_RESULT(pcap not available - disabling dumpcap)
1177         else
1178                 AC_MSG_RESULT(yes)
1179         fi
1180 else
1181         AC_MSG_RESULT(no)
1182 fi
1183
1184 if test "x$enable_dumpcap" = "xyes" ; then
1185         dumpcap_bin="dumpcap\$(EXEEXT)"
1186         dumpcap_man="dumpcap.1"
1187 else
1188         dumpcap_bin=""
1189         dumpcap_man=""
1190 fi
1191 AC_SUBST(dumpcap_bin)
1192 AC_SUBST(dumpcap_man)
1193
1194 # Enable/disable rawshark
1195
1196 dnl rawshark check
1197 AC_MSG_CHECKING(whether to build rawshark)
1198
1199 AC_ARG_ENABLE(rawshark,
1200   AC_HELP_STRING( [--enable-rawshark],
1201                   [build rawshark @<:@default=yes@:>@]),
1202     rawshark=$enableval,enable_rawshark=yes)
1203
1204 if test "x$enable_rawshark" = "xyes" ; then
1205         if test "x$want_pcap" = "xno" ; then
1206                 enable_rawshark=no
1207                 AC_MSG_RESULT(pcap not available - disabling rawshark)
1208         else
1209                 AC_MSG_RESULT(yes)
1210         fi
1211 else
1212         AC_MSG_RESULT(no)
1213 fi
1214
1215 if test "x$enable_rawshark" = "xyes" ; then
1216         rawshark_bin="rawshark\$(EXEEXT)"
1217         rawshark_man="rawshark.1"
1218 else
1219         rawshark_bin=""
1220         rawshark_man=""
1221 fi
1222 AC_SUBST(rawshark_bin)
1223 AC_SUBST(rawshark_man)
1224
1225 dnl Use pcap-ng by default
1226 AC_ARG_ENABLE(pcap-ng-default,
1227   AC_HELP_STRING( [--enable-pcap-ng-default],
1228                   [use the pcap-ng file format by default instead of pcap @<:@default=yes@:>@]),
1229     enable_pcap_ng_default=$enableval,enable_pcap_ng_default=yes)
1230 if test x$enable_pcap_ng_default = xyes; then
1231         AC_DEFINE(PCAP_NG_DEFAULT, 1, [Support for pcap-ng])
1232 fi
1233
1234 dnl pcap remote check
1235 AC_MSG_CHECKING(whether to use libpcap remote capturing feature)
1236
1237 AC_ARG_WITH(pcap-remote,
1238     AC_HELP_STRING([--with-pcap-remote],
1239                    [use libpcap remote capturing (requires libpcap)]),
1240 [
1241     if test $withval = no
1242     then
1243         want_pcap_remote=no
1244     else
1245         want_pcap_remote=yes
1246     fi
1247 ],[
1248     want_pcap_remote=no
1249 ])
1250 if test "x$want_pcap_remote" = "xno" -o "x$want_pcap" = "xno" ; then
1251     AC_MSG_RESULT(no)
1252 else
1253     AC_MSG_RESULT(yes)
1254     AC_WIRESHARK_PCAP_REMOTE_CHECK
1255 fi
1256
1257 dnl zlib check
1258 AC_MSG_CHECKING(whether to use zlib for gzip compression and decompression)
1259
1260 AC_ARG_WITH(zlib,
1261   AC_HELP_STRING([--with-zlib@<:@=DIR@:>@],
1262                  [use zlib (located in directory DIR, if supplied) for gzip compression and decompression @<:@default=yes, if available@:>@]),
1263 [
1264         if test "x$withval" = "xno"
1265         then
1266                 want_zlib=no
1267         elif test "x$withval" = "xyes"
1268         then
1269                 want_zlib=yes
1270         else
1271                 want_zlib=yes
1272                 zlib_dir="$withval"
1273         fi
1274 ],[
1275         #
1276         # Use zlib if it's present, otherwise don't.
1277         #
1278         want_zlib=ifavailable
1279         zlib_dir=
1280 ])
1281 if test "x$want_zlib" = "xno" ; then
1282         AC_MSG_RESULT(no)
1283 else
1284         AC_MSG_RESULT(yes)
1285         AC_WIRESHARK_ZLIB_CHECK
1286         if test "x$want_zlib" = "xno" ; then
1287                 AC_MSG_RESULT(zlib not found - disabling gzip compression and decompression)
1288         else
1289                 if test "x$ac_cv_func_inflatePrime" = "xno" ; then
1290                         AC_MSG_RESULT(inflatePrime not found in zlib - disabling gzipped capture file support)
1291                 fi
1292         fi
1293 fi
1294
1295 dnl Lua check
1296 AC_MSG_CHECKING(whether to use liblua for the Lua scripting plugin)
1297
1298 AC_ARG_WITH(lua,
1299   AC_HELP_STRING( [--with-lua@<:@=DIR@:>@],
1300                   [use liblua (located in directory DIR, if supplied) for the Lua scripting plugin @<:@default=yes, if available@:>@]),
1301 [
1302         if test $withval = no
1303         then
1304                 want_lua=no
1305         elif test $withval = yes
1306         then
1307                 want_lua=yes
1308         else
1309                 want_lua=yes
1310                 lua_dir=$withval
1311         fi
1312 ],[
1313         #
1314         # Use liblua by default
1315         #
1316         want_lua=ifavailable
1317         lua_dir=
1318 ])
1319 if test "x$want_lua" = "xno" ; then
1320         AC_MSG_RESULT(no)
1321 else
1322         AC_MSG_RESULT(yes)
1323         AC_WIRESHARK_LIBLUA_CHECK
1324         if test "x$want_lua" = "xno" ; then
1325                 AC_MSG_RESULT(liblua not found - disabling support for the lua scripting plugin)
1326         fi
1327 fi
1328 AM_CONDITIONAL(HAVE_LIBLUA, test x$want_lua = xyes)
1329
1330
1331 dnl portaudio check
1332 AC_MSG_CHECKING(whether to use libportaudio for the rtp_player)
1333
1334 AC_ARG_WITH(portaudio,
1335   AC_HELP_STRING( [--with-portaudio@<:@=DIR@:>@],
1336                   [use libportaudio (located in directory DIR, if supplied) for the rtp_player @<:@default=yes, if available@:>@]),
1337 [
1338         if test $withval = no
1339         then
1340                 want_portaudio=no
1341         elif test $withval = yes
1342         then
1343                 want_portaudio=yes
1344         else
1345                 want_portaudio=yes
1346                 portaudio_dir=$withval
1347         fi
1348 ],[
1349         #
1350         # Use libportaudio by default
1351         #
1352         want_portaudio=ifavailable
1353         portaudio_dir=
1354 ])
1355 if test "x$want_portaudio" = "xno" ; then
1356         AC_MSG_RESULT(no)
1357 else
1358         AC_MSG_RESULT(yes)
1359         AC_WIRESHARK_LIBPORTAUDIO_CHECK
1360         if test "x$want_portaudio" = "xno" ; then
1361                 AC_MSG_RESULT(libportaudio not found - disabling support for the rtp_player)
1362         fi
1363 fi
1364 AM_CONDITIONAL(HAVE_LIBPORTAUDIO, test x$want_portaudio = xyes)
1365
1366
1367 dnl ipv6 check
1368 AC_ARG_ENABLE(ipv6,
1369   AC_HELP_STRING( [--enable-ipv6],
1370                   [use IPv6 name resolution, if available @<:@default=yes@:>@]),
1371     enable_ipv6=$enableval,enable_ipv6=yes)
1372
1373 AC_MSG_CHECKING(whether to enable ipv6 name resolution if available)
1374 if test "x$enable_ipv6" = "xno" ; then
1375         AC_MSG_RESULT(no)
1376 else
1377         AC_MSG_RESULT(yes)
1378         AC_WIRESHARK_IPV6_STACK
1379 fi
1380
1381
1382 dnl Check if dumpcap should be installed with filesystem capabilities
1383 AC_PATH_PROG(SETCAP, setcap)
1384 AC_ARG_ENABLE(setcap-install,
1385   AC_HELP_STRING( [--enable-setcap-install],
1386                   [install dumpcap with cap_net_admin and cap_net_raw @<:@default=no@:>@]),
1387     enable_setcap_install=$enableval,enable_setcap_install=no)
1388
1389 AC_MSG_CHECKING(whether to install dumpcap with cap_net_admin and cap_net_raw capabilities)
1390 if test "x$enable_setcap_install" = "xno" ; then
1391         AC_MSG_RESULT(no)
1392 else
1393         if test "x$SETCAP" = "x" ; then
1394                 AC_MSG_RESULT(no. Setcap not found)
1395         elif test "x$enable_dumpcap" = "xno" ; then
1396                 AC_MSG_ERROR(Setcap install works only with dumpcap but dumpcap is disabled)
1397         else
1398                 AC_MSG_RESULT(yes)
1399         fi
1400 fi
1401
1402 AM_CONDITIONAL(SETCAP_INSTALL, test x$enable_setcap_install = xyes)
1403
1404 dnl Check if dumpcap should be installed setuid
1405 AC_ARG_ENABLE(setuid-install,
1406   AC_HELP_STRING( [--enable-setuid-install],
1407                   [install dumpcap as setuid @<:@default=no@:>@]),
1408     enable_setuid_install=$enableval,enable_setuid_install=no)
1409
1410 AC_MSG_CHECKING(whether to install dumpcap setuid)
1411 if test "x$enable_setuid_install" = "xno" ; then
1412         AC_MSG_RESULT(no)
1413 else
1414         if test "x$enable_setcap_install" = "xyes" ; then
1415                 enable_setuid_install=no
1416                 AC_MSG_RESULT(no; using setcap instead)
1417         elif test "x$enable_dumpcap" = "xno" ; then
1418                 AC_MSG_ERROR(Setuid install works only with dumpcap but dumpcap is disabled)
1419         else
1420                 AC_MSG_RESULT(yes)
1421         fi
1422 fi
1423
1424 AM_CONDITIONAL(SETUID_INSTALL, test x$enable_setuid_install = xyes)
1425 AC_CHECK_FUNCS(setresuid setresgid)
1426
1427 dnl ...but our Network Operations group is named "no"!
1428 DUMPCAP_GROUP=''
1429 AC_ARG_WITH(dumpcap-group,
1430   AC_HELP_STRING( [--with-dumpcap-group=GROUP],
1431                   [restrict dumpcap to GROUP]),
1432 [
1433   if test "x$withval" = "xyes"; then
1434       AC_MSG_ERROR([No dumpcap group specified.])
1435   elif test "x$withval" != "xno"; then
1436       if test "x$enable_dumpcap" = "xno" ; then
1437           AC_MSG_ERROR(dumpcap group install works only with dumpcap but dumpcap is disabled)
1438       fi
1439       AC_MSG_RESULT($withval)
1440       DUMPCAP_GROUP="$withval"
1441   fi
1442 ])
1443 AC_SUBST(DUMPCAP_GROUP)
1444 AM_CONDITIONAL(HAVE_DUMPCAP_GROUP, test x$DUMPCAP_GROUP != x)
1445
1446 dnl libcap (not libpcap) check
1447 LIBCAP_LIBS=''
1448 AC_MSG_CHECKING(whether to use the libcap capabilities library)
1449
1450 AC_ARG_WITH(libcap,
1451   AC_HELP_STRING( [--with-libcap@<:@=DIR@:>@],
1452                   [use libcap (located in directory DIR, if supplied) for POSIX.1e capabilities management @<:@default=yes, if present@:>@]),
1453 [
1454 if   test "x$withval" = "xno";  then
1455         want_libcap=no
1456 elif test "x$withval" = "xyes"; then
1457         want_libcap=yes
1458 elif test -d "$withval"; then
1459         want_libcap=yes
1460         AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1461 fi
1462 ])
1463 if test "x$with_libcap" = "xno" ; then
1464         AC_MSG_RESULT(no)
1465 else
1466         AC_MSG_RESULT(yes)
1467         AC_WIRESHARK_LIBCAP_CHECK
1468 fi
1469 AC_SUBST(LIBCAP_LIBS)
1470
1471 dnl Checks for header files.
1472 AC_CHECK_HEADERS(direct.h dirent.h fcntl.h grp.h inttypes.h netdb.h pwd.h stdarg.h stddef.h unistd.h)
1473 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)
1474 AC_CHECK_HEADERS(netinet/in.h)
1475 AC_CHECK_HEADERS(arpa/inet.h arpa/nameser.h)
1476
1477 dnl SSL Check
1478 SSL_LIBS=''
1479 AC_MSG_CHECKING(whether to use SSL library)
1480
1481 AC_ARG_WITH(ssl,
1482   AC_HELP_STRING( [--with-ssl@<:@=DIR@:>@],
1483                   [use SSL crypto library (located in directory DIR, if supplied) @<:@default=no@:>@]),
1484 [
1485 if test "x$withval" = "xno";  then
1486         want_ssl=no
1487 elif test "x$withval" = "xyes"; then
1488         want_ssl=yes
1489 elif test -d "$withval"; then
1490         want_ssl=yes
1491         AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1492 fi
1493 ],[
1494         want_ssl=no
1495 ])
1496 if test "x$want_ssl" = "xyes"; then
1497         AC_MSG_RESULT(yes)
1498         AC_CHECK_LIB(crypto,EVP_md5,
1499             [
1500                 SSL_LIBS=-lcrypto
1501             ],
1502             [
1503                 AC_MSG_ERROR([SSL crypto library was requested, but is not available])
1504             ])
1505 else
1506         AC_MSG_RESULT(no)
1507 fi
1508 AC_SUBST(SSL_LIBS)
1509
1510 dnl kerberos check
1511 AC_MSG_CHECKING(whether to use Kerberos library)
1512
1513 AC_ARG_WITH(krb5,
1514   AC_HELP_STRING( [--with-krb5@<:@=DIR@:>@],
1515                   [use Kerberos library (located in directory DIR, if supplied) to use in Kerberos dissection @<:@default=yes@:>@]),
1516 [
1517         if test $withval = no
1518         then
1519                 want_krb5=no
1520         elif test $withval = yes
1521         then
1522                 want_krb5=yes
1523         else
1524                 want_krb5=yes
1525                 krb5_dir=$withval
1526         fi
1527 ],[
1528         #
1529         # Use Kerberos library if available, otherwise don't.
1530         #
1531         want_krb5=ifavailable
1532         krb5_dir=
1533 ])
1534 if test "x$want_krb5" = "xno" ; then
1535         AC_MSG_RESULT(no)
1536 else
1537         AC_MSG_RESULT(yes)
1538         AC_WIRESHARK_KRB5_CHECK
1539 fi
1540
1541
1542 dnl c-ares Check
1543 C_ARES_LIBS=''
1544 AC_MSG_CHECKING(whether to use the c-ares library if available)
1545
1546 AC_ARG_WITH(c-ares,
1547   AC_HELP_STRING( [--with-c-ares@<:@=DIR@:>@],
1548                   [use c-ares (located in directory DIR, if supplied) - supersedes --with-adns @<:@default=yes, if present@:>@]),
1549 [
1550 if   test "x$withval" = "xno";  then
1551         want_c_ares=no
1552 elif test "x$withval" = "xyes"; then
1553         want_c_ares=yes
1554 elif test -d "$withval"; then
1555         want_c_ares=yes
1556         AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1557 fi
1558 ])
1559 if test "x$want_c_ares" = "xno" ; then
1560         AC_MSG_RESULT(no)
1561 else
1562         AC_MSG_RESULT(yes)
1563         AC_WIRESHARK_C_ARES_CHECK
1564 fi
1565 AC_SUBST(C_ARES_LIBS)
1566
1567 dnl ADNS Check
1568 ADNS_LIBS=''
1569 AC_MSG_CHECKING(whether to use the GNU ADNS library if available)
1570
1571 AC_ARG_WITH(adns,
1572   AC_HELP_STRING( [--with-adns@<:@=DIR@:>@],
1573                   [use GNU ADNS (located in directory DIR, if supplied) @<:@default=yes, if present@:>@]),
1574 [
1575 if   test "x$withval" = "xno";  then
1576         want_adns=no
1577 elif test "x$withval" = "xyes"; then
1578         want_adns=yes
1579 elif test -d "$withval"; then
1580         want_adns=yes
1581         AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1582 fi
1583 ])
1584 if test "x$want_adns" = "xno" -o "x$have_good_c_ares" = "xyes" ; then
1585         AC_MSG_RESULT(no)
1586 else
1587         AC_MSG_RESULT(yes)
1588         AC_WIRESHARK_ADNS_CHECK
1589 fi
1590 AC_SUBST(ADNS_LIBS)
1591
1592 dnl GEOIP Check
1593 GEOIP_LIBS=''
1594 AC_MSG_CHECKING(whether to use the GeoIP IP address mapping library if available)
1595
1596 AC_ARG_WITH(geoip,
1597   AC_HELP_STRING( [--with-geoip@<:@=DIR@:>@],
1598                   [use GeoIP (located in directory DIR, if supplied) @<:@default=yes, if present@:>@]),
1599 [
1600 if   test "x$withval" = "xno";  then
1601         want_geoip=no
1602 elif test "x$withval" = "xyes"; then
1603         want_geoip=yes
1604 elif test -d "$withval"; then
1605         want_geoip=yes
1606         AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1607 fi
1608 ])
1609 if test "x$want_geoip" = "xno"; then
1610         AC_MSG_RESULT(no)
1611 else
1612         AC_MSG_RESULT(yes)
1613         AC_WIRESHARK_GEOIP_CHECK
1614 fi
1615 AC_SUBST(GEOIP_LIBS)
1616
1617 dnl Python devel Check
1618 AC_MSG_CHECKING(whether to use the Python interpreter for scripting)
1619
1620 AC_ARG_WITH(python,
1621     AC_HELP_STRING( [--with-python@<:@=DIR@:>@],
1622                     [use Python interpreter (installed in DIR, if supplied) @<:@default=no@:>@ (EXPERIMENTAL)]),
1623 [
1624         pythondir='${libdir}/wireshark/python/${VERSION}'
1625         if test "x$withval" = "xno"
1626         then
1627                 want_python=no
1628         elif test "x$withval" = "xyes"
1629         then
1630                 want_python=yes
1631         else
1632                 want_python=yes
1633                 pythondir="$withval"
1634         fi
1635 ],[
1636         # By default (user didn't explicitly enable Python), don't enable
1637         # Python support.
1638         #
1639         want_python=no
1640         #pythondir='${libdir}/wireshark/python/${VERSION}'
1641 ])
1642 if test "x$want_python" = "xno" ; then
1643         AC_MSG_RESULT(no)
1644 else
1645         AC_MSG_RESULT(yes)
1646         AC_WIRESHARK_PYTHON_CHECK
1647 fi
1648 AM_CONDITIONAL(HAVE_LIBPY, test x$want_python != xno)
1649 AC_SUBST(pythondir)
1650
1651 #
1652 # Define WS_VAR_IMPORT appropriately for declarations of external
1653 # variables exported from dynamically-linked libraries.
1654 #
1655 AC_DEFINE(WS_VAR_IMPORT, extern, [Define as the string to precede external variable declarations in dynamically-linked libraries])
1656
1657 #
1658 # Define WS_MSVC_NORETURN appropriately for declarations of routines that
1659 # never return (just like Charlie on the MTA).
1660 #
1661 # Note that MSVC++ expects __declspec(noreturn) to precede the function
1662 # name and GCC, as far as I know, expects __attribute__((noreturn)) to
1663 # follow the function name, so we need two different flavors of
1664 # noreturn tag.
1665 #
1666 AC_DEFINE(WS_MSVC_NORETURN,, [Define as the string to precede declarations of routines that never return])
1667
1668 AC_ARG_ENABLE(airpcap,
1669   AC_HELP_STRING( [--enable-airpcap],
1670                   [use AirPcap in Wireshark @<:@default=no@:>@]),
1671   enable_airpcap=$enableval
1672   if test x$enable_airpcap != xno; then
1673         AC_DEFINE(HAVE_AIRPCAP, 1, [Enable AirPcap])
1674   fi
1675 )
1676
1677 dnl Checks for typedefs, structures, and compiler characteristics.
1678 # AC_C_CONST
1679
1680 # Check how we can get the time zone abbreviation
1681 AC_WIRESHARK_TIMEZONE_ABBREV
1682
1683 # We need to know whether "struct sockaddr" has an "sa_len" member
1684 # for get_interface_list().
1685
1686 AC_WIRESHARK_STRUCT_SA_LEN
1687
1688 # We must know our byte order
1689 AC_C_BIGENDIAN
1690
1691 # Checks whether "-traditional" is needed when using "ioctl".
1692 # XXX - do we need this?
1693 AC_PROG_GCC_TRADITIONAL
1694
1695 GETOPT_LO=""
1696 AC_CHECK_FUNC(getopt,
1697   [GETOPT_LO=""
1698    AC_DEFINE(HAVE_GETOPT, 1, [Define to 1 if you have the getopt function.])
1699   ],
1700   GETOPT_LO="wsgetopt.lo"
1701 )
1702 if test "$ac_cv_func_getopt" = no ; then
1703   GETOPT_LO="wsgetopt.lo"
1704 fi
1705 AM_CONDITIONAL(NEED_GETOPT_LO, test "x$ac_cv_func_getopt" = "xno")
1706 AC_SUBST(GETOPT_LO)
1707
1708 AC_CHECK_FUNC(strncasecmp, STRNCASECMP_LO="",
1709   STRNCASECMP_LO="strncasecmp.lo")
1710 if test "$ac_cv_func_strncasecmp" = no ; then
1711   STRNCASECMP_LO="strncasecmp.lo"
1712 fi
1713 AM_CONDITIONAL(NEED_STRNCASECMP_LO, test "x$ac_cv_func_strncasecmp" = "xno")
1714 AC_SUBST(STRNCASECMP_LO)
1715
1716 AC_CHECK_FUNCS(mkstemp mkdtemp)
1717
1718 AC_SEARCH_LIBS(inet_aton, [socket nsl], have_inet_aton=yes,
1719     have_inet_aton=no)
1720 if test "$have_inet_aton" = no; then
1721   INET_ATON_LO="inet_aton.lo"
1722   AC_DEFINE(NEED_INET_ATON_H, 1, [Define if inet/aton.h needs to be included])
1723 else
1724   INET_ATON_LO=""
1725 fi
1726 AM_CONDITIONAL(NEED_INET_ATON_LO, test "x$have_inet_aton" = "xno")
1727 AC_SUBST(INET_ATON_LO)
1728
1729 AC_SEARCH_LIBS(inet_pton, [socket nsl], [
1730   dnl check for pre-BIND82 inet_pton() bug.
1731   AC_MSG_CHECKING(for broken inet_pton)
1732   AC_TRY_RUN([#include <sys/types.h>
1733 #include <sys/socket.h>
1734 #include <netinet/in.h>
1735 #include <arpa/inet.h>
1736 int main()
1737 {
1738 #ifdef AF_INET6
1739   char buf[16];
1740   /* this should return 0 (error) */
1741   return inet_pton(AF_INET6, "0:1:2:3:4:5:6:7:", buf);
1742 #else
1743   return 1;
1744 #endif
1745 }], [AC_MSG_RESULT(ok);
1746 have_inet_pton=yes], [AC_MSG_RESULT(broken);
1747 have_inet_pton=no], [AC_MSG_RESULT(cross compiling, assume it is broken);
1748 have_inet_pton=no])],
1749 have_inet_pton=no)
1750 if test "$have_inet_pton" = no; then
1751   INET_PTON_LO="inet_pton.lo"
1752 else
1753   INET_PTON_LO=""
1754 fi
1755 AM_CONDITIONAL(NEED_INET_PTON_LO, test "x$have_inet_pton" = "xno")
1756 AC_SUBST(INET_PTON_LO)
1757
1758 AC_SEARCH_LIBS(inet_ntop, [socket nsl], [
1759   AC_MSG_CHECKING([for inet_ntop prototype])
1760   AC_TRY_COMPILE([#include <stdio.h>
1761 #include <sys/types.h>
1762 #include <sys/socket.h>
1763 #include <netinet/in.h>
1764 #include <arpa/inet.h>
1765
1766 extern const char *inet_ntop(int, const void *, char *, size_t);],, [
1767     AC_MSG_RESULT(yes)
1768     AC_DEFINE(HAVE_INET_NTOP_PROTO, 1,
1769     [Define if inet_ntop() prototype exists])], [
1770     AC_TRY_COMPILE([#include <stdio.h>
1771 #include <sys/types.h>
1772 #include <sys/socket.h>
1773 #include <netinet/in.h>
1774 #include <arpa/inet.h>
1775
1776 extern const char *inet_ntop(int, const void *, char *, socklen_t);],, [
1777       AC_MSG_RESULT(yes)
1778       AC_DEFINE(HAVE_INET_NTOP_PROTO, 1,
1779       [Define if inet_ntop() prototype exists])], [
1780       AC_MSG_RESULT(no)])])
1781   INET_NTOP_LO=""], [
1782   INET_NTOP_LO="inet_ntop.lo"
1783   AC_DEFINE(NEED_INET_V6DEFS_H, 1,
1784   [Define if inet/v6defs.h needs to be included])])
1785 AM_CONDITIONAL(NEED_INET_NTOP_LO, test "x$INET_NTOP_LO" != "x")
1786 AC_SUBST(INET_NTOP_LO)
1787
1788 AC_CHECK_FUNC(strptime, STRPTIME_LO="",
1789   [STRPTIME_LO="strptime.lo"
1790    AC_DEFINE(NEED_STRPTIME_H, 1, [Define if strptime.h needs to be included])
1791 ])
1792 if test "$ac_cv_func_strptime" = no ; then
1793   STRPTIME_LO="strptime.lo"
1794 fi
1795 AC_SUBST(STRPTIME_C)
1796 AM_CONDITIONAL(NEED_STRPTIME_LO, test "x$ac_cv_func_strptime" = "no")
1797 AC_SUBST(STRPTIME_LO)
1798
1799 AC_CHECK_FUNCS(getprotobynumber gethostbyname2)
1800 AC_CHECK_FUNCS(issetugid)
1801 AC_CHECK_FUNCS(mmap mprotect sysconf)
1802 AC_CHECK_FUNCS(strtoll)
1803
1804 dnl blank for now, but will be used in future
1805 AC_SUBST(wireshark_SUBDIRS)
1806
1807 dnl
1808 dnl check whether plugins should be enabled and, if they should be,
1809 dnl check for plugins directory - stolen from Amanda's configure.in
1810 dnl
1811 dnl we don't wish to expand ${libdir} yet
1812 plugindir='${libdir}/wireshark/plugins/${VERSION}'
1813 AC_ARG_WITH(plugins,
1814   AC_HELP_STRING( [--with-plugins@<:@=DIR@:>@],
1815                   [support plugins (installed in DIR, if supplied) @<:@default=yes, if possible@:>@]),
1816 [
1817   if test "x$withval" = "xno"; then
1818     have_plugins=no
1819   elif test "x$have_plugins" = "xno"; then
1820       AC_MSG_ERROR([GLib on this platform doesn't support loadable modules, so you can't enable plugins.])
1821   elif test "x$withval" != "xyes"; then
1822       plugindir="$withval"
1823   fi
1824 ])
1825 AM_CONDITIONAL(HAVE_PLUGINS, test "x$have_plugins" = "xyes")
1826 if test x$have_plugins = xyes
1827 then
1828   AC_DEFINE(HAVE_PLUGINS, 1, [Define if plugins are enabled])
1829 fi
1830 AC_SUBST(plugindir)
1831 CPPFLAGS="$CPPFLAGS '-DPLUGIN_DIR=\"\$(plugindir)\"'"
1832
1833 #
1834 # The plugin dissectors reside in ./plugins/PROTO/
1835 #
1836 PLUGIN_LIBS=""
1837 AC_SUBST(PLUGIN_LIBS)
1838
1839 dnl libtool defs
1840 #
1841 # Yes, AM_PROG_LIBTOOL is redundant with newer version(s) of some tool(s)
1842 # (autoconf?  automake?  libtool?) - with the newer version(s), it's
1843 # just an alias for AC_PROG_LIBTOOL, which is called earlier.
1844 #
1845 # With older version(s) of those tool(s), however, it's not just an
1846 # alias, and the configure scripts don't work without it.
1847 #
1848 AM_PROG_LIBTOOL
1849 AC_SUBST(LIBTOOL_DEPS)
1850
1851 AM_CONDITIONAL(ENABLE_STATIC, test x$enable_static = xyes)
1852 if test x$enable_static = xyes -a x$have_plugins = xyes
1853 then
1854   AC_DEFINE(ENABLE_STATIC, 1, [Link plugins statically into Wireshark])
1855 fi
1856 AC_SUBST(ENABLE_STATIC)
1857
1858 dnl Save the cacheable configure results to config.cache before recursing
1859 AC_CACHE_SAVE
1860
1861 sinclude(plugins/Custom.m4) dnl
1862 ifdef(_CUSTOM_AC_OUTPUT_,, define(_CUSTOM_AC_OUTPUT_, )) dnl
1863
1864 sinclude(asn1/Custom.m4) dnl
1865 ifdef(_CUSTOM_ASN1_AC_OUTPUT_,, define(_CUSTOM_ASN1_AC_OUTPUT_, )) dnl
1866
1867 AM_CONFIG_HEADER(config.h)
1868 AC_OUTPUT(
1869   Makefile
1870   doxygen.cfg
1871   asn1/Makefile
1872   _CUSTOM_ASN1_AC_OUTPUT_
1873   asn1/acp133/Makefile
1874   asn1/acse/Makefile
1875   asn1/ansi_map/Makefile
1876   asn1/ansi_tcap/Makefile
1877   asn1/c1222/Makefile
1878   asn1/camel/Makefile
1879   asn1/cdt/Makefile
1880   asn1/charging_ase/Makefile
1881   asn1/cmip/Makefile
1882   asn1/cmp/Makefile
1883   asn1/crmf/Makefile
1884   asn1/cms/Makefile
1885   asn1/credssp/Makefile
1886   asn1/dap/Makefile
1887   asn1/disp/Makefile
1888   asn1/dop/Makefile
1889   asn1/dsp/Makefile
1890   asn1/ess/Makefile
1891   asn1/ftam/Makefile
1892   asn1/gnm/Makefile
1893   asn1/goose/Makefile
1894   asn1/gprscdr/Makefile
1895   asn1/gsm_map/Makefile
1896   asn1/h225/Makefile
1897   asn1/h235/Makefile
1898   asn1/h245/Makefile
1899   asn1/h248/Makefile
1900   asn1/h282/Makefile
1901   asn1/h283/Makefile
1902   asn1/h323/Makefile
1903   asn1/h450/Makefile
1904   asn1/h450-ros/Makefile
1905   asn1/h460/Makefile
1906   asn1/h501/Makefile
1907   asn1/HI2Operations/Makefile
1908   asn1/hnbap/Makefile
1909   asn1/idmp/Makefile
1910   asn1/inap/Makefile
1911   asn1/kerberos/Makefile
1912   asn1/lcsap/Makefile
1913   asn1/ldap/Makefile
1914   asn1/logotypecertextn/Makefile
1915   asn1/lpp/Makefile
1916   asn1/lppa/Makefile
1917   asn1/lte-rrc/Makefile
1918   asn1/m3ap/Makefile
1919   asn1/mms/Makefile
1920   asn1/mpeg-audio/Makefile
1921   asn1/mpeg-pes/Makefile
1922   asn1/nbap/Makefile
1923   asn1/ns_cert_exts/Makefile
1924   asn1/ocsp/Makefile
1925   asn1/p1/Makefile
1926   asn1/p22/Makefile
1927   asn1/p7/Makefile
1928   asn1/p772/Makefile
1929   asn1/pcap/Makefile
1930   asn1/pkcs1/Makefile
1931   asn1/pkcs12/Makefile
1932   asn1/pkinit/Makefile
1933   asn1/pkixac/Makefile
1934   asn1/pkix1explicit/Makefile
1935   asn1/pkix1implicit/Makefile
1936   asn1/pkixproxy/Makefile
1937   asn1/pkixqualified/Makefile
1938   asn1/pkixtsp/Makefile
1939   asn1/pres/Makefile
1940   asn1/q932/Makefile
1941   asn1/q932-ros/Makefile
1942   asn1/qsig/Makefile
1943   asn1/ranap/Makefile
1944   asn1/rnsap/Makefile
1945   asn1/ros/Makefile
1946   asn1/rrc/Makefile
1947   asn1/rrlp/Makefile
1948   asn1/rtse/Makefile
1949   asn1/rua/Makefile
1950   asn1/s1ap/Makefile
1951   asn1/sabp/Makefile
1952   asn1/sbc-ap/Makefile
1953   asn1/smrse/Makefile
1954   asn1/snmp/Makefile
1955   asn1/spnego/Makefile
1956   asn1/sv/Makefile
1957   asn1/t124/Makefile
1958   asn1/t125/Makefile
1959   asn1/t38/Makefile
1960   asn1/tcap/Makefile
1961   asn1/tetra/Makefile
1962   asn1/ulp/Makefile
1963   asn1/wlancertextn/Makefile
1964   asn1/x2ap/Makefile
1965   asn1/x509af/Makefile
1966   asn1/x509ce/Makefile
1967   asn1/x509if/Makefile
1968   asn1/x509sat/Makefile
1969   asn1/x721/Makefile
1970   doc/Makefile
1971   docbook/Makefile
1972   epan/Makefile
1973   epan/crypt/Makefile
1974   epan/doxygen.cfg
1975   epan/dfilter/Makefile
1976   epan/dissectors/Makefile
1977   epan/dissectors/dcerpc/Makefile
1978   epan/dissectors/pidl/Makefile
1979   epan/ftypes/Makefile
1980   epan/wslua/Makefile
1981   epan/wspython/Makefile
1982   codecs/Makefile
1983   ui/Makefile
1984   ui/doxygen.cfg
1985   ui/gtk/Makefile
1986   ui/gtk/doxygen.cfg
1987   ui/cli/Makefile
1988   help/Makefile
1989   packaging/Makefile
1990   packaging/macosx/Info.plist
1991   packaging/macosx/Makefile
1992   packaging/nsis/Makefile
1993   packaging/rpm/Makefile
1994   packaging/rpm/SPECS/Makefile
1995   packaging/rpm/SPECS/wireshark.spec
1996   packaging/svr4/Makefile
1997   packaging/svr4/checkinstall
1998   packaging/svr4/pkginfo
1999   plugins/Makefile
2000   plugins/asn1/Makefile
2001   plugins/docsis/Makefile
2002   plugins/ethercat/Makefile
2003   plugins/giop/Makefile
2004   plugins/gryphon/Makefile
2005   plugins/irda/Makefile
2006   plugins/m2m/Makefile
2007   plugins/mate/Makefile
2008   plugins/opcua/Makefile
2009   plugins/profinet/Makefile
2010   plugins/stats_tree/Makefile
2011   plugins/unistim/Makefile
2012   plugins/wimax/Makefile
2013   plugins/wimaxasncp/Makefile
2014   tools/Makefile
2015   tools/lemon/Makefile
2016   wiretap/Makefile
2017   wsutil/Makefile
2018   _CUSTOM_AC_OUTPUT_
2019   ,)
2020 dnl AC_CONFIG_FILES([tools/setuid-root.pl], [chmod +x tools/setuid-root.pl])
2021
2022
2023 # Pretty messages
2024
2025 if test "x$have_gtk" = "xyes"; then
2026         if test "x$with_gtk3" = "xyes"; then
2027                 gui_lib_message=" (with GTK+ 3"
2028         else
2029                 gui_lib_message=" (with GTK+ 2"
2030         fi
2031         if test "x$have_ige_mac" = "xyes"; then
2032                 gui_lib_message="$gui_lib_message and Mac OS X integration)"
2033         else
2034                 gui_lib_message="$gui_lib_message)"
2035         fi
2036 fi
2037
2038 if test "x$enable_setcap_install" = "xyes" ; then
2039         setcap_message="yes"
2040 else
2041         setcap_message="no"
2042 fi
2043
2044 if test "x$enable_setuid_install" = "xyes" ; then
2045         setuid_message="yes"
2046 else
2047         setuid_message="no"
2048 fi
2049
2050 if test "x$DUMPCAP_GROUP" = "x" ; then
2051         dumpcap_group_message="(none)"
2052 else
2053         dumpcap_group_message="$DUMPCAP_GROUP"
2054 fi
2055
2056 if test "x$want_zlib" = "xno" ; then
2057         zlib_message="no"
2058 else
2059         zlib_message="yes"
2060 fi
2061
2062 if test "x$want_lua" = "xyes" ; then
2063         lua_message="yes"
2064 else
2065         lua_message="no"
2066 fi
2067
2068 if test "x$want_python" = "xno"; then
2069         python_message="no"
2070 else
2071         python_message="yes"
2072 fi
2073
2074 if test "x$want_portaudio" = "xyes" ; then
2075         portaudio_message="yes"
2076 else
2077         portaudio_message="no"
2078 fi
2079
2080 if test "x$want_ssl" = "xno" ; then
2081         ssl_message="no"
2082 else
2083         ssl_message="yes"
2084 fi
2085
2086 if test "x$want_krb5" = "xno" ; then
2087         krb5_message="no"
2088 else
2089         krb5_message="yes ($ac_krb5_version)"
2090 fi
2091
2092 if test "x$have_good_c_ares" = "xyes" ; then
2093         c_ares_message="yes"
2094 else
2095         c_ares_message="no"
2096 fi
2097
2098 if test "x$have_good_adns" = "xyes" ; then
2099         adns_message="yes"
2100 else
2101         if test "x$have_good_c_ares" = "xyes" ; then
2102                 adns_message="no (using c-ares instead)"
2103         else
2104                 adns_message="no"
2105         fi
2106 fi
2107
2108 if test "x$have_good_libcap" = "xyes" ; then
2109         libcap_message="yes"
2110 else
2111         libcap_message="no"
2112 fi
2113
2114 if test "x$have_good_geoip" = "xyes" ; then
2115         geoip_message="yes"
2116 else
2117         geoip_message="no"
2118 fi
2119
2120 echo ""
2121 echo "The Wireshark package has been configured with the following options."
2122 echo "                    Build wireshark : $enable_wireshark""$gui_lib_message"
2123 echo "                       Build tshark : $enable_tshark"
2124 echo "                     Build capinfos : $enable_capinfos"
2125 echo "                      Build editcap : $enable_editcap"
2126 echo "                      Build dumpcap : $enable_dumpcap"
2127 echo "                     Build mergecap : $enable_mergecap"
2128 echo "                    Build text2pcap : $enable_text2pcap"
2129 echo "                      Build randpkt : $enable_randpkt"
2130 echo "                       Build dftest : $enable_dftest"
2131 echo "                     Build rawshark : $enable_rawshark"
2132 echo ""
2133 echo "   Save files as pcap-ng by default : $enable_pcap_ng_default"
2134 echo "  Install dumpcap with capabilities : $setcap_message"
2135 echo "             Install dumpcap setuid : $setuid_message"
2136 echo "                  Use dumpcap group : $dumpcap_group_message"
2137 echo "                        Use plugins : $have_plugins"
2138 echo "                    Use Lua library : $lua_message"
2139 echo "                 Use Python binding : $python_message"
2140 echo "                   Build rtp_player : $portaudio_message"
2141 echo "             Build profile binaries : $enable_profile_build"
2142 echo "                   Use pcap library : $want_pcap"
2143 echo "                   Use zlib library : $zlib_message"
2144 echo "               Use kerberos library : $krb5_message"
2145 echo "                 Use c-ares library : $c_ares_message"
2146 echo "               Use GNU ADNS library : $adns_message"
2147 echo "                Use SMI MIB library : $libsmi_message"
2148 echo "             Use GNU crypto library : $gcrypt_message"
2149 echo "             Use SSL crypto library : $ssl_message"
2150 echo "           Use IPv6 name resolution : $enable_ipv6"
2151 echo "                 Use gnutls library : $tls_message"
2152 echo "     Use POSIX capabilities library : $libcap_message"
2153 echo "                  Use GeoIP library : $geoip_message"