I think the intent, at least, is to allow people to build Wireshark from
[obnox/wireshark/wip.git] / configure.in
1 # $Id$
2 #
3 AC_INIT(cfile.h)
4
5 AC_PREREQ(2.52)
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
13 dnl AC_CANONICAL_HOST
14 dnl AC_CANONICAL_BUILD
15 AC_CANONICAL_TARGET
16
17 AM_INIT_AUTOMAKE(wireshark, 0.99.7)
18
19 AM_DISABLE_STATIC
20
21 dnl Checks for programs.
22 AC_PROG_CC
23 AC_PROG_CPP
24 dnl Work around libtool bug (fixed in the version 1.5a?)
25 AC_DEFUN([AC_PROVIDE_AC_LIBTOOL_DLOPEN], )
26 AC_LIBTOOL_DLOPEN
27 AC_PROG_LIBTOOL
28 AC_PROG_YACC
29 AM_PROG_LEX
30 AC_PATH_PROG(PERL, perl)
31 AC_PATH_PROG(POD2MAN, pod2man)
32 if test "x$POD2MAN" = x
33 then
34         #
35         # The alternative is not to build the man pages....
36         #
37         AC_MSG_ERROR(I couldn't find pod2man; make sure it's installed and in your path)
38 fi
39 AC_PATH_PROG(POD2HTML, pod2html)
40 if test "x$POD2HTML" = x
41 then
42         #
43         # The alternative is not to build the HTML man pages....
44         #
45         AC_MSG_ERROR(I couldn't find pod2html; make sure it's installed and in your path)
46 fi
47 AC_PATH_PROG(HTML_VIEWER, htmlview)
48 if test "x$HTML_VIEWER" = x
49 then
50         AC_DEFINE_UNQUOTED(HTML_VIEWER, "mozilla", [HTML viewer, e.g. mozilla])
51 else
52         AC_DEFINE_UNQUOTED(HTML_VIEWER, "htmlview", [HTML viewer, e.g. mozilla])
53 fi
54
55 AC_PATH_PROG(LEX, flex)
56 AC_PATH_PROG(PYTHON, python)
57
58 AC_SUBST(PERL)
59 AC_SUBST(POD2MAN)
60 AC_SUBST(POD2HTML)
61 AC_SUBST(LEX)
62 AC_SUBST(FLEX_PATH)
63 AC_SUBST(PYTHON)
64 AC_SUBST(XSLTPROC)
65 AC_SUBST(XMLLINT)
66
67 if test "x$CC_FOR_BUILD" = x
68 then
69        CC_FOR_BUILD=$CC
70 fi
71 AC_SUBST(CC_FOR_BUILD)
72
73 # Check for doxygen
74 AC_PATH_PROG(DOXYGEN, doxygen)
75 AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, "yes", "no")
76 AM_CONDITIONAL(HAVE_DOXYGEN, test x$HAVE_DOXYGEN = xyes)
77
78 # gnu tls
79 tls_message="no"
80 AC_ARG_WITH([gnutls],
81   AC_HELP_STRING( [--with-gnutls=@<:@yes/no@:>@],
82                   [use gnutls library @<:@default=yes@:>@]),
83   with_gnutls="$withval", with_gnutls="yes")
84 if test "x$with_gnutls" = "xyes"; then
85   AM_PATH_LIBGNUTLS(1.0.0,
86         [
87                 echo "gnuTLS found, enabling ssl decryption"
88                 AC_DEFINE(HAVE_LIBGNUTLS, 1, [Define to use gnutls library])
89                 tls_message="yes"
90         ]
91         , [
92                 if test x$libgnutls_config_prefix != x ; then
93                         AC_MSG_ERROR([[gnuTLS not found; install gnuTLS-devel package for your system]])
94                 else
95                         echo echo "gnuTLS not found, disabling ssl decryption"
96                         tls_message="no"
97                 fi
98         ]
99   )
100 fi
101
102 # libgrypt
103 gcrypt_message="no"
104 AC_ARG_WITH([gcrypt],
105   AC_HELP_STRING( [--with-gcrypt=@<:@yes/no@:>@],
106                   [use gcrypt library @<:@default=yes@:>@]),
107   with_gcrypt="$withval", with_gcrypt="yes")
108 if test "x$with_gcrypt" = "xyes"; then
109   AM_PATH_LIBGCRYPT(1.1.42,
110         [
111                 echo "libgcrypt found, enabling ipsec decryption"
112                 AC_DEFINE(HAVE_LIBGCRYPT, 1, [Define to use libgcrypt])
113                 gcrypt_message="yes"
114         ]
115         , [
116                 if test x$libgcrypt_config_prefix != x ; then
117                         AC_MSG_ERROR([[libgcrypt not found; install libgcrypt-devel package for your system]])
118                 else
119                         echo echo "libgcrypt not found, disabling ipsec decryption"
120                         gcrypt_message="no"
121                 fi
122         ]
123   )
124 fi
125
126 # Check for xsltproc
127 AC_PATH_PROG(XSLTPROC, xsltproc)
128 AC_CHECK_PROG(HAVE_XSLTPROC, xsltproc, "yes", "no")
129 AM_CONDITIONAL(HAVE_XSLTPROC, test x$HAVE_XSLTPROC = xyes)
130
131 # Check for xmllint
132 AC_PATH_PROG(XMLLINT, xmllint)
133 AC_CHECK_PROG(HAVE_XMLLINT, xmllint, "yes", "no")
134 AM_CONDITIONAL(HAVE_XMLLINT, test x$HAVE_XMLLINT = xyes)
135
136 # Check for fop (translate .fo to e.g. pdf)
137 AC_PATH_PROG(FOP, fop)
138 AC_CHECK_PROG(HAVE_FOP, fop, "yes", "no")
139 AM_CONDITIONAL(HAVE_FOP, test x$HAVE_FOP = xyes)
140
141 # Check for hhc (html help compiler)
142 AC_PATH_PROG(HHC, hhc.exe)
143 AC_CHECK_PROG(HAVE_HHC, hhc.exe, "yes", "no")
144 AM_CONDITIONAL(HAVE_HHC, test x$HAVE_HHC = xyes)
145
146 # Check for packaging utilities
147 # For now, we check to see if the various packaging utilites are in our
148 # path.  I'm too lazy to write code to go hunt for them.  -  Gerald
149 AC_CHECK_PROG(HAVE_PKGPROTO, pkgproto, "yes", "no")
150 AC_CHECK_PROG(HAVE_PKGMK, pkgmk, "yes", "no")
151 AC_CHECK_PROG(HAVE_PKGTRANS, pkgtrans, "yes", "no")
152
153 if test x$HAVE_PKGPROTO = xyes -a x$HAVE_PKGMK = xyes \
154      -a x$HAVE_PKGTRANS = xyes ; then
155   HAVE_SVR4_PACKAGING=yes
156 else
157   HAVE_SVR4_PACKAGING=no
158 fi
159 AC_SUBST(HAVE_SVR4_PACKAGING)
160
161 AC_WIRESHARK_RPM_CHECK
162 AC_SUBST(HAVE_RPM)
163
164 #
165 # Try to add some additional gcc checks to CFLAGS
166 #
167 AC_ARG_ENABLE(extra-gcc-checks,
168   AC_HELP_STRING( [--enable-extra-gcc-checks],
169                   [Do additional -W checks in GCC.  @<:@default=no@:>@]),
170 [
171         wireshark_extra_gcc_flags=$enableval
172         if test $enableval != no
173         then
174                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-pedantic)
175                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-long-long)
176                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wbad-function-cast)
177                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wcast-qual)
178                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wwrite-strings)
179                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wshorten-64-to-32)
180                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wstrict-prototypes)
181                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wmissing-declarations)
182                 #Temporarily put cast-align here waiting eradication of 'cast
183                 #increases required alignment of target type' on the Solaris
184                 #slave. 
185                 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wcast-align)
186         fi
187 ],)
188 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wall -W)
189 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wdeclaration-after-statement)
190 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wendif-labels)
191 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wpointer-arith)
192 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-pointer-sign)
193
194 #
195 # If we're running gcc add '-D_U_="__attribute__((unused))"' to CFLAGS as well,
196 # so we can use _U_ to flag unused function arguments and not get warnings
197 # about them. Otherwise, add '-D_U_=""', so that _U_ used to flag an unused
198 # function argument will compile with non-GCC compilers.
199 #
200 if test "x$GCC" = "xyes" ; then
201   CFLAGS="-D_U_=\"__attribute__((unused))\" $CFLAGS"
202 else
203   CFLAGS="-D_U_=\"\" $CFLAGS"
204 fi
205
206 #
207 # If we're running gcc, will enable a barrier "stop on warning". 
208 # This barrier is set for a very large part of the code. However, it is
209 # typically not set for "generated" code  (lex, ans2wrs, idl2wrs, ...)
210 #
211 AC_MSG_CHECKING(whether we should treat compiler warnings as errors)
212 AC_ARG_ENABLE(warnings-as-errors,
213   AC_HELP_STRING( [--enable-warnings-as-errors], 
214                   [Treat warnings as errors (only for gcc). @<:@default=yes@:>@]),
215 [
216   if test "x$GCC" = "xyes" -a "x$enableval" == "xyes" -a "x$wireshark_extra_gcc_flags" != "xyes"; then
217     with_warnings_as_errors="yes"
218     AC_MSG_RESULT(yes)
219   else
220     with_warnings_as_errors="no"
221     AC_MSG_RESULT(no)
222   fi
223 ],
224   if test "x$GCC" = "xyes" -a "x$wireshark_extra_gcc_flags" = "x"; then
225     with_warnings_as_errors="yes"
226     AC_MSG_RESULT(yes)
227   else
228     with_warnings_as_errors="no"
229     AC_MSG_RESULT(no)
230   fi
231 )
232 AM_CONDITIONAL(HAVE_WARNINGS_AS_ERRORS, test "x$with_warnings_as_errors" = "xyes")
233
234 #
235 # Add any platform-specific compiler flags needed.
236 #
237 AC_MSG_CHECKING(for platform-specific compiler flags)
238 if test "x$GCC" = "xyes" ; then
239         #
240         # GCC - do any platform-specific tweaking necessary.
241         #
242         case "$host_os" in
243         solaris*)
244                 # the X11 headers don't automatically include prototype info
245                 # and a lot don't include the return type
246                 CFLAGS="$CFLAGS -Wno-return-type -DFUNCPROTO=15"
247                 AC_MSG_RESULT(GCC on Solaris - added -Wno-return-type -DFUNCPROTO=15)
248                 ;;
249         darwin*)
250                 #
251                 # See comments above about Apple's lovely C compiler.
252                 #
253                 CFLAGS="-no-cpp-precomp $CFLAGS"
254                 AC_MSG_RESULT(Apple GCC - added -no-cpp-precomp)
255                 ;;
256         *)
257                 AC_MSG_RESULT(none needed)
258                 ;;
259         esac
260 else
261         #
262         # Not GCC - assume it's the vendor's compiler.
263         #
264         case "$host_os" in
265         hpux*)
266                 #
267                 # HP's ANSI C compiler; flags suggested by Jost Martin.
268                 # "-Ae" for ANSI C plus extensions such as "long long".
269                 # "+O2", for optimization.  XXX - works with "-g"?
270                 #
271                 CFLAGS="-Ae +O2 $CFLAGS"
272                 AC_MSG_RESULT(HP ANSI C compiler - added -Ae +O2)
273                 ;;
274         darwin*)
275                 #
276                 # It may be called "cc", but it's really a GCC derivative
277                 # with a problematic special precompiler and precompiled
278                 # headers; turn off the special precompiler, as some
279                 # apparently-legal code won't compile with its precompiled
280                 # headers.
281                 #
282                 CFLAGS="-no-cpp-precomp $CFLAGS"
283                 AC_MSG_RESULT(Apple GCC - added -no-cpp-precomp)
284                 ;;
285         *)
286                 AC_MSG_RESULT(none needed)
287                 ;;
288         esac
289 fi
290
291 #
292 # Add any platform-specific linker flags needed.
293 #
294 AC_MSG_CHECKING(for platform-specific linker flags)
295 case "$host_os" in
296 darwin*)
297         #
298         # Add -Wl,-single_module to the LDFLAGS used with shared
299         # libraries, to fix some error that show up in some cases;
300         # some Apple documentation recommends it for most shared
301         # libraries.
302         #
303         LDFLAGS_SHAREDLIB="-Wl,-single_module"
304         #
305         # Add -Wl,-search_paths_first to make sure that if we search
306         # directories A and B, in that order, for a given library, a
307         # non-shared version in directory A, rather than a shared
308         # version in directory B, is chosen (so we can use
309         # --with-pcap=/usr/local to force all programs to be linked
310         # with a static version installed in /usr/local/lib rather than
311         # the system version in /usr/lib).
312         #
313         LDFLAGS="-Wl,-search_paths_first $LDFLAGS"
314         AC_MSG_RESULT([Apple linker - added -Wl,-single_module and -Wl,-search_paths_first])
315         ;;
316 cygwin*)
317         #
318         # Shared libraries in cygwin/Win32 must never contain
319         # undefined symbols.
320         #
321         LDFLAGS="$LDFLAGS -no-undefined"
322         AC_MSG_RESULT(CygWin GNU ld - added -no-undefined)
323         ;;
324 *)
325         AC_MSG_RESULT(none needed)
326         ;;
327 esac
328 AC_SUBST(LDFLAGS_SHAREDLIB)
329
330 #
331 # On OS X, if we find the headers for Core Foundation and Launch Services,
332 # add -framework options to link with Application Services (of which
333 # Launch Services is a subframework) and Core Foundation (required by
334 # the Launch Services APIs), so we can use that to launch a Web browser
335 # from the Help menu.
336 #
337 # (Do those headers exist on pure Darwin?  If so, does the CoreFoundation
338 # *and* Launch Services code exist there, or are those headers just stubs?
339 # If the frameworks aren't present on Darwin, how *should* we check for
340 # their existence?)
341 #
342 case "$host_os" in
343
344 darwin*)
345         AC_MSG_CHECKING(whether we can build with Core Foundation and Launch Services)
346         ac_save_LIBS="$LIBS"
347         ac_frameworks="-framework ApplicationServices -framework CoreFoundation"
348         LIBS="$LIBS $ac_frameworks"
349         AC_TRY_LINK(
350            [
351 #       include <CoreFoundation/CFBase.h>
352 #       include <CoreFoundation/CFString.h>
353 #       include <CoreFoundation/CFURL.h>
354 #       include <ApplicationServices/ApplicationServices.h>
355            ],
356            [
357         CFStringRef url_CFString;
358         CFURLRef url_CFURL;
359         OSStatus status;
360
361         url_CFString = CFStringCreateWithCString(NULL, "", kCFStringEncodingASCII);
362         url_CFURL = CFURLCreateWithString(NULL, url_CFString, NULL);
363         status = LSOpenCFURLRef(url_CFURL, NULL);
364            ],
365            ac_cv_can_use_cf_and_ls=yes,
366            ac_cv_can_use_cf_and_ls=no,
367            [echo $ac_n "cross compiling; assumed OK... $ac_c"])
368         if test "$ac_cv_can_use_cf_and_ls" = yes ; then
369                 AC_DEFINE(HAVE_OS_X_FRAMEWORKS, 1, [Define to 1 if you have OS X frameworks])
370                 FRAMEWORKS="$ac_frameworks"
371                 AC_MSG_RESULT(yes)
372         else
373                 AC_MSG_RESULT(no)
374         fi
375         LIBS="$ac_save_LIBS"
376         ;;
377 esac
378 AC_SUBST(FRAMEWORKS)
379
380 dnl Look in /usr/local for header files and libraries ?
381 dnl XXX FIXME don't include /usr/local if it is already in the system
382 dnl search path as this causes gcc 3.2 on Linux to complain about a change
383 dnl of the system search order for includes
384 AC_ARG_ENABLE(usr-local,
385   AC_HELP_STRING( [--enable-usr-local],
386                   [look for headers and libs in /usr/local tree.  @<:@default=yes@:>@]),
387     ac_cv_enable_usr_local=$enableval,ac_cv_enable_usr_local=yes)
388
389 AC_MSG_CHECKING(whether to use /usr/local for headers and libraries)
390 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
391         AC_MSG_RESULT(yes)
392         #
393         # Arrange that we search for header files in the source directory
394         # and in its "wiretap" subdirectory, as well as in "/usr/local/include",
395         # as various packages we use ("libpcap", "zlib", an SNMP library)
396         # may have been installed under "/usr/local/include".
397         #
398         CFLAGS="$CFLAGS -I/usr/local/include"
399         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
400
401         #
402         # Arrange that we search for libraries in "/usr/local/lib".
403         #
404         AC_WIRESHARK_ADD_DASH_L(LDFLAGS, /usr/local/lib)
405 else
406         AC_MSG_RESULT(no)
407 fi
408
409 #
410 # If we're running Solaris, and LD_LIBRARY_PATH is defined, add it as a
411 # link directory.
412 #
413 case "$host_os" in
414   solaris*)
415     AC_MSG_CHECKING(for LD_LIBRARY_PATH, since you appear to be running Solaris)
416     if test x$LD_LIBRARY_PATH != x ; then
417       LIBS="$LIBS -R$LD_LIBRARY_PATH"
418       AC_MSG_RESULT(yes -- added LD_LIBRARY_PATH to run-time linker path)
419     else
420       AC_MSG_RESULT(no -- this may be a problem in a few seconds)
421     fi
422   ;;
423 esac
424
425 #
426 # Check for versions of "sed" inadequate to handle, in libtool, a list
427 # of object files as large as the list in Wireshark.
428 #
429 # On Solaris, we check for "/bin/sed", "/usr/bin/sed", and "/usr/ucb/sed",
430 # as both "/usr/bin/sed" (which is also "/bin/sed", as "/bin" is just a
431 # symlink to "/usr/bin", but people may have "/bin" before "/usr/bin" in
432 # their search path) and "/usr/ucb/sed" are inadequate; "/usr/xpg4/bin/sed"
433 # is the only "sed" that comes with Solaris that can handle Wireshark.
434 #
435 # Add any checks here that are necessary for other OSes.
436 #
437 AC_WIRESHARK_GNU_SED_CHECK
438 if test "$HAVE_GNU_SED" = no ; then
439         case "$host_os" in
440         solaris*)
441                 AC_MSG_CHECKING(whether one of /usr/bin/sed or /bin/sed or /usr/ucb/sed will be used)
442                 case `which sed` in
443                         /bin/sed|/usr/bin/sed|/usr/ucb/sed)
444                         AC_MSG_RESULT(yes)              
445                         AC_MSG_ERROR([change your path to search /usr/xpg4/bin or directory containing GNU sed before /usr/bin (and /bin and /usr/ucb)])
446                         ;;
447
448                         *)
449                         AC_MSG_RESULT(no)
450                         ;;
451                 esac
452                 ;;
453
454         *)
455                 :
456                 ;;
457         esac
458 fi
459
460 # Enable/disable tshark
461
462 AC_ARG_ENABLE(wireshark,
463   AC_HELP_STRING( [--enable-wireshark],
464                   [build GTK+-based wireshark.  @<:@default=yes, if GTK+ available@:>@]),
465     enable_wireshark=$enableval,enable_wireshark=yes)
466
467 AC_ARG_ENABLE(gtk2,
468   AC_HELP_STRING( [--disable-gtk2],
469                   [build Glib1/Gtk1+-based wireshark/tshark.  @<:@default=no@:>@]),
470     enable_gtk2=$enableval,enable_gtk2=yes)
471 AM_CONDITIONAL(USE_GTK2, test x$enable_gtk2 = xyes)
472
473 AC_ARG_ENABLE(threads,
474   AC_HELP_STRING( [--enable-threads],
475                   [use threads in wireshark.  @<:@default=no@:>@]),
476     enable_threads=$enableval,enable_threads=no)
477 AM_CONDITIONAL(USE_THREADS, test x$enable_threads = xyes)
478
479 AC_ARG_ENABLE(profile-build,
480   AC_HELP_STRING( [--enable-profile-build],
481                   [build profile-ready binaries.  @<:@default=no@:>@]),
482     enable_profile_build=$enableval,enable_profile_build=no)
483 AM_CONDITIONAL(USE_PROFILE_BUILD, test x$enable_profile_build = xyes)
484 AC_MSG_CHECKING(if profile builds must be generated)
485 if test "x$enable_profile_build" = "xyes" ; then
486         if test "x$GCC" = "xyes" ; then
487                 AC_MSG_RESULT(yes)
488                 CFLAGS=" -pg $CFLAGS"
489         else
490                 AC_MSG_RESULT(no)
491                 echo "Building profile binaries currently only supported for GCC."
492         fi
493 else
494         AC_MSG_RESULT(no)
495 fi
496
497 # Create DATAFILE_DIR #define for config.h
498 datafiledir=$datadir/wireshark
499 datafiledir=`(
500     test "x$prefix" = xNONE && prefix=$ac_default_prefix
501     test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
502     # Ugly hack, but I don't see how this problem can be solved
503     # properly that DATAFILE_DIR had a value starting with
504     # "${prefix}/" instead of e.g. "/usr/local/"
505     eval eval echo "$datafiledir"
506 )`
507 AC_DEFINE_UNQUOTED(DATAFILE_DIR,"$datafiledir", [Directory for data])
508
509 # GTK checks
510 # We don't add $GLIB_LIBS to LIBS, because we don't want to force all
511 # programs to be built with GTK+.
512 #
513 if test "x$enable_gtk2" = "xyes" -a "x$enable_wireshark" = "xyes"; then
514         GTK_OK=two
515         AM_PATH_GTK_2_0(2.0.0, CFLAGS="$CFLAGS $GTK_CFLAGS", GTK_OK=no, gthread)
516 elif test "x$enable_gtk2" != "xyes" -a "x$enable_wireshark" = "xyes"; then
517         GTK_OK=one
518         AM_PATH_GTK(1.2.0, CFLAGS="$CFLAGS $GTK_CFLAGS", GTK_OK=no )
519 else
520         GTK_OK=no
521 fi
522
523 # GLib checks
524 # This doesn't add GLIB_CFLAGS to CFLAGS, because AM_PATH_GTK will add
525 # GTK_CFLAGS to CFLAGS, and GTK_CFLAGS is a superset of CFLAGS.
526 # However, this means that both @GLIB_LIBS@ and @GTK_LIBS@ will be
527 # set when generating the Makefile, so we can make programs that require
528 # only GLib link with @GLIB_LIBS@ and make programs that require GTK+
529 # link with @GTK_LIBS@ (which includes @GLIB_LIBS@).
530 # We don't add $GLIB_LIBS to LIBS, because we don't want to force all
531 # programs to be built with GLib.
532 #
533 if test "$GTK_OK" = "no" ; then
534         #
535         # We don't have GTK+.
536         # If they didn't explicitly say "--disable-wireshark", fail (so
537         # that, unless they explicitly indicated that they don't want
538         # Wireshark, we stop so they know they won't be getting
539         # Wireshark unless they fix the GTK+ problem).
540         #
541         if test "x$enable_wireshark" = "xyes"; then
542                 AC_MSG_ERROR([GTK+ isn't available, so Wireshark can't be compiled])
543         fi
544         wireshark_bin=""
545         wireshark_man=""
546         # Honor GLIB_CFLAGS
547         if test "x$enable_gtk2" = "xyes" ; then
548                 AM_PATH_GLIB_2_0(2.0.0, CFLAGS="$CFLAGS $GLIB_CFLAGS", AC_MSG_ERROR(GLib2 distribution not found.), gmodule)
549         else
550                 AM_PATH_GLIB(1.2.0, CFLAGS="$CFLAGS $GLIB_CFLAGS", AC_MSG_ERROR(GLib distribution not found.), gmodule)
551         fi
552 else
553         wireshark_bin="wireshark\$(EXEEXT)"
554         wireshark_man="wireshark.1"
555         wireshark_SUBDIRS="codecs gtk"
556         # Honor GLIB_CFLAGS
557         if test "$GTK_OK" = "two" ; then
558                 AM_PATH_GLIB_2_0(2.0.0, , AC_MSG_ERROR(GLib distribution not found.), gmodule)
559         else
560                 AM_PATH_GLIB(1.2.0, , AC_MSG_ERROR(GLib distribution not found.), gmodule)
561         fi
562 fi
563
564 #
565 # Check whether GLib modules are supported, to determine whether we
566 # can support plugins.
567 #
568 AC_MSG_CHECKING(whether GLib supports loadable modules)
569 ac_save_CFLAGS="$CFLAGS"
570 ac_save_LIBS="$LIBS"
571 CFLAGS="$CFLAGS $GLIB_CFLAGS"
572 LIBS="$GLIB_LIBS $LIBS"
573 AC_TRY_RUN([
574 #include <glib.h>
575 #include <gmodule.h>
576 #include <stdio.h>
577 #include <stdlib.h>
578
579 int
580 main ()
581 {
582   if (g_module_supported())
583     return 0;   /* success */
584   else
585     return 1;   /* failure */
586 }
587 ], ac_cv_glib_supports_modules=yes, ac_cv_glib_supports_modules=no,
588    [echo $ac_n "cross compiling; assumed OK... $ac_c"
589     ac_cv_glib_supports_modules=yes])
590 CFLAGS="$ac_save_CFLAGS"
591 LIBS="$ac_save_LIBS"
592 if test "$ac_cv_glib_supports_modules" = yes ; then
593   AC_MSG_RESULT(yes)
594   have_plugins=yes
595 else
596   AC_MSG_RESULT(no)
597   have_plugins=no
598 fi
599
600 #
601 # We can't just check for <inttypes.h> - some systems have one that
602 # doesn't define all the PRI[doxu]64 macros.
603 #
604 AC_CHECK_HEADERS(inttypes.h,
605   [
606     #
607     # OK, we have inttypes.h, but does it define those macros?
608     #
609     AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]])
610     AC_COMPILE_IFELSE(
611       [
612         AC_LANG_SOURCE(
613           [[
614             #include <inttypes.h>
615             #include <glib.h>
616             #include <stdio.h>
617             #include <sys/types.h>
618
619             main()
620             {
621               printf("%" PRId64 "\n", (gint64)1);
622               printf("%" PRIo64 "\n", (guint64)1);
623               printf("%" PRIx64 "\n", (guint64)1);
624               printf("%" PRIX64 "\n", (guint64)1);
625               printf("%" PRIu64 "\n", (guint64)1);
626             }
627           ]])
628       ],
629       [
630         AC_MSG_RESULT(yes)
631         ac_wireshark_inttypes_h_defines_formats=yes
632       ],
633       [
634         AC_MSG_RESULT(no)
635         ac_wireshark_inttypes_h_defines_formats=no
636       ])
637   ],
638   [
639     #
640     # We don't have inttypes.h, so it obviously can't define those
641     # macros.
642     #
643     ac_wireshark_inttypes_h_defines_formats=no
644   ])
645 if test "$ac_wireshark_inttypes_h_defines_formats" = yes; then
646   AC_DEFINE(INTTYPES_H_DEFINES_FORMATS,,[Define if <inttypes.h> defines PRI[doxu]64 macros])
647 else
648   AC_WIRESHARK_CHECK_64BIT_FORMAT(ll,
649     [
650       AC_WIRESHARK_CHECK_64BIT_FORMAT(L,
651         [
652           AC_WIRESHARK_CHECK_64BIT_FORMAT(q,
653             [
654               AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer])
655             ])
656         ])
657     ])
658 fi
659
660 AC_SUBST(wireshark_bin)
661 AC_SUBST(wireshark_man)
662
663 rdps_bin="rdps\$(EXEEXT)"
664 AC_SUBST(rdps_bin)
665
666
667 # Enable/disable tshark
668
669 AC_ARG_ENABLE(tshark,
670   AC_HELP_STRING( [--enable-tshark],
671                   [build tshark.  @<:@default=yes@:>@]),
672     tshark=$enableval,enable_tshark=yes)
673
674 if test "x$enable_tshark" = "xyes" ; then
675         tshark_bin="tshark\$(EXEEXT)"
676         tshark_man="tshark.1"
677         wiresharkfilter_man="wireshark-filter.4"
678 else
679         tshark_bin=""
680         tshark_man=""
681 fi
682 AC_SUBST(tshark_bin)
683 AC_SUBST(tshark_man)
684 AC_SUBST(wiresharkfilter_man)
685
686
687
688 # Enable/disable editcap
689
690 AC_ARG_ENABLE(editcap,
691   AC_HELP_STRING( [--enable-editcap],
692                   [build editcap.  @<:@default=yes@:>@]),
693     enable_editcap=$enableval,enable_editcap=yes)
694
695 if test "x$enable_editcap" = "xyes" ; then
696         editcap_bin="editcap\$(EXEEXT)"
697         editcap_man="editcap.1"
698 else
699         editcap_bin=""
700         editcap_man=""
701 fi
702 AC_SUBST(editcap_bin)
703 AC_SUBST(editcap_man)
704
705
706 # Enable/disable dumpcap
707
708 AC_ARG_ENABLE(dumpcap,
709   AC_HELP_STRING( [--enable-dumpcap],
710                   [build dumpcap.  @<:@default=yes@:>@]),
711     enable_dumpcap=$enableval,enable_dumpcap=yes)
712
713 if test "x$enable_dumpcap" = "xyes" ; then
714         dumpcap_bin="dumpcap\$(EXEEXT)"
715         dumpcap_man="dumpcap.1"
716 else
717         dumpcap_bin=""
718         dumpcap_man=""
719 fi
720 AC_SUBST(dumpcap_bin)
721 AC_SUBST(dumpcap_man)
722
723
724 # Enable/disable capinfos
725
726 AC_ARG_ENABLE(capinfos,
727   AC_HELP_STRING( [--enable-capinfos],
728                   [build capinfos.  @<:@default=yes@:>@]),
729     enable_capinfos=$enableval,enable_capinfos=yes)
730
731 if test "x$enable_capinfos" = "xyes" ; then
732         capinfos_bin="capinfos\$(EXEEXT)"
733         capinfos_man="capinfos.1"
734 else
735         capinfos_bin=""
736         capinfos_man=""
737 fi
738 AC_SUBST(capinfos_bin)
739 AC_SUBST(capinfos_man)
740
741
742 # Enable/disable mergecap
743
744 AC_ARG_ENABLE(mergecap,
745   AC_HELP_STRING( [--enable-mergecap],
746                   [build mergecap.  @<:@default=yes@:>@]),
747     enable_mergecap=$enableval,enable_mergecap=yes)
748
749 if test "x$enable_mergecap" = "xyes" ; then
750         mergecap_bin="mergecap\$(EXEEXT)"
751         mergecap_man="mergecap.1"
752 else
753         mergecap_bin=""
754         mergecap_man=""
755 fi
756 AC_SUBST(mergecap_bin)
757 AC_SUBST(mergecap_man)
758
759
760 # Enable/disable text2pcap
761
762 AC_ARG_ENABLE(text2pcap,
763   AC_HELP_STRING( [--enable-text2pcap],
764                   [build text2pcap.  @<:@default=yes@:>@]),
765     text2pcap=$enableval,enable_text2pcap=yes)
766
767 if test "x$enable_text2pcap" = "xyes" ; then
768         text2pcap_bin="text2pcap\$(EXEEXT)"
769         text2pcap_man="text2pcap.1"
770 else
771         text2pcap_bin=""
772         text2pcap_man=""
773 fi
774 AC_SUBST(text2pcap_bin)
775 AC_SUBST(text2pcap_man)
776
777 # Enable/disable idl2wrs
778
779 AC_ARG_ENABLE(idl2wrs,
780   AC_HELP_STRING( [--enable-idl2wrs],
781                   [build idl2wrs.  @<:@default=yes@:>@]),
782     enable_idl2wrs=$enableval,enable_idl2wrs=yes)
783
784 if test "x$enable_idl2wrs" = "xyes" ; then
785         idl2wrs_bin="idl2wrs"
786         idl2wrs_man="idl2wrs.1"
787 else
788         idl2wrs_bin=""
789         idl2wrs_man=""
790 fi
791 AC_SUBST(idl2wrs_bin)
792 AC_SUBST(idl2wrs_man)
793
794
795 # Enable/disable dftest
796
797 AC_ARG_ENABLE(dftest,
798   AC_HELP_STRING( [--enable-dftest],
799                   [build dftest.  @<:@default=yes@:>@]),
800     enable_dftest=$enableval,enable_dftest=yes)
801
802 if test "x$enable_dftest" = "xyes" ; then
803         dftest_bin="dftest\$(EXEEXT)"
804 else
805         dftest_bin=""
806 fi
807 AC_SUBST(dftest_bin)
808
809
810 # Enable/disable randpkt
811
812 AC_ARG_ENABLE(randpkt,
813   AC_HELP_STRING( [--enable-randpkt],
814                   [build randpkt.  @<:@default=yes@:>@]),
815     enable_randpkt=$enableval,enable_randpkt=yes)
816
817 if test "x$enable_randpkt" = "xyes" ; then
818         randpkt_bin="randpkt\$(EXEEXT)"
819 else
820         randpkt_bin=""
821 fi
822 AC_SUBST(randpkt_bin)
823
824
825 dnl Checks for "gethostbyname()" - and "-lnsl", if we need it to get
826 dnl "gethostbyname()".
827 AC_WIRESHARK_GETHOSTBY_LIB_CHECK
828
829 dnl Checks for "connect()", used as a proxy for "socket()" - and
830 dnl "-lsocket", if we need it to get "connect()".
831 AC_WIRESHARK_SOCKET_LIB_CHECK
832
833 dnl pcap check
834 AC_MSG_CHECKING(whether to use libpcap for packet capture)
835
836 AC_ARG_WITH(pcap,
837   AC_HELP_STRING( [--with-pcap@<:@=DIR@:>@],
838                   [use libpcap for packet capturing.  @<:@default=yes@:>@]),
839 [
840         if test $withval = no
841         then
842                 want_pcap=no
843         elif test $withval = yes
844         then
845                 want_pcap=yes
846         else
847                 want_pcap=yes
848                 pcap_dir=$withval
849         fi
850 ],[
851         want_pcap=yes
852         pcap_dir=
853 ])
854 if test "x$want_pcap" = "xno" ; then
855         AC_MSG_RESULT(no)
856 else
857         AC_MSG_RESULT(yes)
858         AC_WIRESHARK_PCAP_CHECK
859 fi
860
861 dnl zlib check
862 AC_MSG_CHECKING(whether to use zlib for reading compressed capture files)
863
864 AC_ARG_WITH(zlib,
865   AC_HELP_STRING( [--with-zlib@<:@=DIR@:>@],
866                   [use zlib (located in directory DIR, if supplied) to read compressed data.  @<:@default=yes, if available@:>@]),
867 [
868         if test $withval = no
869         then
870                 want_zlib=no
871         elif test $withval = yes
872         then
873                 want_zlib=yes
874         else
875                 want_zlib=yes
876                 zlib_dir=$withval
877         fi
878 ],[
879         #
880         # Use zlib if it's present, otherwise don't.
881         #
882         want_zlib=ifavailable
883         zlib_dir=
884 ])
885 if test "x$want_zlib" = "xno" ; then
886         AC_MSG_RESULT(no)
887 else
888         AC_MSG_RESULT(yes)
889         AC_WIRESHARK_ZLIB_CHECK
890         if test "x$want_zlib" = "xno" ; then
891                 AC_MSG_RESULT(zlib not found - disabling compressed capture file support)
892         fi
893 fi
894
895
896 dnl pcre check
897 AC_MSG_CHECKING(whether to use libpcre for regular expressions in dfilters)
898
899 AC_ARG_WITH(pcre,
900   AC_HELP_STRING( [--with-pcre@<:@=DIR@:>@],
901                   [use libpcre (located in directory DIR, if supplied) to use in dfilter regular expressions.  @<:@default=yes, if available@:>@]),
902 [
903         if test $withval = no
904         then
905                 want_pcre=no
906         elif test $withval = yes
907         then
908                 want_pcre=yes
909         else
910                 want_pcre=yes
911                 pcre_dir=$withval
912         fi
913 ],[
914         #
915         # Use libpcre if it's present, otherwise don't.
916         #
917         want_pcre=ifavailable
918         pcre_dir=
919 ])
920 if test "x$want_pcre" = "xno" ; then
921         AC_MSG_RESULT(no)
922 else
923         AC_MSG_RESULT(yes)
924         AC_WIRESHARK_LIBPCRE_CHECK
925         if test "x$want_pcre" = "xno" ; then
926                 AC_MSG_RESULT(libpcre not found - disabling support for perl compatible regular expressions in dfilters)
927         fi
928 fi
929
930
931 dnl lua check
932 AC_MSG_CHECKING(whether to use liblua for the lua scripting plugin)
933
934 AC_ARG_WITH(lua,
935   AC_HELP_STRING( [--with-lua@<:@=DIR@:>@],
936                   [use liblua (located in directory DIR, if supplied) for the lua scripting plugin.  @<:@default=no@:>@]),
937 [
938         if test $withval = no
939         then
940                 want_lua=no
941         elif test $withval = yes
942         then
943                 want_lua=yes
944         else
945                 want_lua=yes
946                 lua_dir=$withval
947         fi
948 ],[
949         #
950         # Don't use liblua by default (it isn't ready yet)
951         #
952         want_lua=no
953         lua_dir=
954 ])
955 if test "x$want_lua" = "xno" ; then
956         AC_MSG_RESULT(no)
957 else
958         AC_MSG_RESULT(yes)
959         AC_WIRESHARK_LIBLUA_CHECK
960         if test "x$want_lua" = "xno" ; then
961                 AC_MSG_RESULT(liblua not found - disabling support for the lua scripting plugin)
962         fi
963 fi
964 AM_CONDITIONAL(HAVE_LIBLUA, test x$want_lua = xyes)
965
966
967 dnl portaudio check
968 AC_MSG_CHECKING(whether to use libportaudio for the rtp_player)
969
970 AC_ARG_WITH(portaudio,
971   AC_HELP_STRING( [--with-portaudio@<:@=DIR@:>@],
972                   [use libportaudio (located in directory DIR, if supplied) for the rtp_player.  @<:@default=yes, if available@:>@]),
973 [
974         if test $withval = no
975         then
976                 want_portaudio=no
977         elif test $withval = yes
978         then
979                 want_portaudio=yes
980         else
981                 want_portaudio=yes
982                 portaudio_dir=$withval
983         fi
984 ],[
985         #
986         # Use libportaudio by default
987         #
988         want_portaudio=ifavailable
989         portaudio_dir=
990 ])
991 if test "x$want_portaudio" = "xno" ; then
992         AC_MSG_RESULT(no)
993 else
994         AC_MSG_RESULT(yes)
995         AC_WIRESHARK_LIBPORTAUDIO_CHECK
996         if test "x$want_portaudio" = "xno" ; then
997                 AC_MSG_RESULT(libportaudio not found - disabling support for the rtp_player)
998         fi
999 fi
1000 AM_CONDITIONAL(HAVE_LIBPORTAUDIO, test x$want_portaudio = xyes)
1001
1002
1003 dnl ipv6 check
1004 AC_ARG_ENABLE(ipv6,
1005   AC_HELP_STRING( [--enable-ipv6],
1006                   [use ipv6 name resolution, if available.  @<:@default=yes@:>@]),
1007     enable_ipv6=$enableval,enable_ipv6=yes)
1008
1009 AC_MSG_CHECKING(whether to enable ipv6 name resolution if available)
1010 if test "x$enable_ipv6" = "xno" ; then
1011         AC_MSG_RESULT(no)
1012 else
1013         AC_MSG_RESULT(yes)
1014         AC_WIRESHARK_IPV6_STACK
1015 fi
1016
1017
1018 dnl Check if wireshark should be installed setuid
1019 AC_ARG_ENABLE(setuid-install,
1020   AC_HELP_STRING( [--enable-setuid-install],
1021                   [install wireshark as setuid. DANGEROUS!!! @<:@default=no@:>@]),
1022     enable_setuid_install=$enableval,enable_setuid_install=no)
1023
1024 AC_MSG_CHECKING(whether to install wireshark setuid)
1025 if test "x$enable_setuid_install" = "xno" ; then
1026         AC_MSG_RESULT(no)
1027 else
1028         if test "x$enable_dumpcap" = "xno" ; then
1029                 AC_MSG_ERROR(Setuid install works only with --enable-dumpcap, but dumpcap disabled)
1030         else
1031                 AC_MSG_RESULT(yes)
1032         fi
1033 fi
1034
1035 AM_CONDITIONAL(SETUID_INSTALL, test x$enable_setuid_install = xyes)
1036
1037 dnl Checks for header files.
1038 AC_HEADER_STDC
1039 AC_CHECK_HEADERS(direct.h dirent.h fcntl.h netdb.h stdarg.h stddef.h unistd.h)
1040 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)
1041 AC_CHECK_HEADERS(netinet/in.h)
1042 AC_CHECK_HEADERS(arpa/inet.h arpa/nameser.h)
1043
1044 dnl iconv check
1045 AM_ICONV
1046
1047 dnl SSL Check
1048 SSL_LIBS=''
1049 AC_MSG_CHECKING(whether to use SSL library)
1050
1051 AC_ARG_WITH(ssl,
1052   AC_HELP_STRING( [--with-ssl@<:@=DIR@:>@],
1053                   [use SSL crypto library (located in directory DIR, if supplied).   @<:@default=no@:>@]),
1054 [
1055 if test "x$withval" = "xno";  then
1056         want_ssl=no
1057 elif test "x$withval" = "xyes"; then
1058         want_ssl=yes
1059 elif test -d "$withval"; then
1060         want_ssl=yes
1061         AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1062 fi
1063 ],[
1064         want_ssl=no
1065 ])
1066 if test "x$want_ssl" = "xyes"; then
1067         AC_MSG_RESULT(yes)
1068         AC_CHECK_LIB(crypto,EVP_md5,
1069             [
1070                 SSL_LIBS=-lcrypto
1071             ],
1072             [
1073                 AC_MSG_ERROR([SSL crypto library was requested, but is not available])
1074             ])
1075 else
1076         AC_MSG_RESULT(no)
1077 fi
1078 AC_SUBST(SSL_LIBS)
1079
1080 dnl Net-SNMP Check
1081 SNMP_LIBS=''
1082
1083 AC_ARG_WITH(net-snmp,
1084   AC_HELP_STRING( [--with-net-snmp@<:@=PATH@:>@],
1085                   [use Net-SNMP library (with PATH as the location of the net-snmp-config shell script that comes with the net-snmp package, if supplied)  @<:@default=yes, if available@:>@]),
1086 [
1087         if test $withval = no
1088         then
1089                 want_netsnmp=no
1090         elif test $withval = yes
1091         then
1092                 want_netsnmp=yes
1093         else
1094                 want_netsnmp=yes
1095                 netsnmpconfig="$withval"
1096         fi
1097 ],[
1098         #
1099         # Set "want_netsnmp" to "ifavailable" to make the default "use it
1100         # if you find it, otherwise don't".
1101         #
1102         want_netsnmp=ifavailable
1103 ])
1104
1105 #
1106 # Try Net-SNMP
1107 #
1108 AC_MSG_CHECKING(whether to use Net-SNMP library)
1109 if test "x$want_netsnmp" = "xno" ; then
1110         AC_MSG_RESULT(no)
1111 else
1112         if test "x$want_netsnmp" = "xifavailable" ; then
1113                 AC_MSG_RESULT([yes, if available])
1114         else
1115                 AC_MSG_RESULT(yes)
1116         fi
1117         AC_WIRESHARK_NETSNMP_CHECK
1118 fi
1119
1120 if test "x$have_net_snmp" = "xyes"; then
1121         AC_DEFINE(HAVE_NET_SNMP, 1, [Define to 1 if Net-SNMP support is to be used])
1122 fi
1123
1124 AC_SUBST(SNMP_LIBS)
1125
1126
1127 dnl kerberos check
1128 AC_MSG_CHECKING(whether to use kerberos)
1129
1130 AC_ARG_WITH(krb5,
1131   AC_HELP_STRING( [--with-krb5@<:@=DIR@:>@],
1132                   [use kerberos (located in directory DIR, if supplied) to use in kerberos dissection  @<:@default=yes@:>@]),
1133 [
1134         if test $withval = no
1135         then
1136                 want_krb5=no
1137         elif test $withval = yes
1138         then
1139                 want_krb5=yes
1140         else
1141                 want_krb5=yes
1142                 krb5_dir=$withval
1143         fi
1144 ],[
1145         #
1146         # Use kerberos if specified, otherwise don't.
1147         #
1148         want_krb5=ifavailable
1149         krb5_dir=
1150 ])
1151 if test "x$want_krb5" = "xno" ; then
1152         AC_MSG_RESULT(no)
1153 else
1154         AC_MSG_RESULT(yes)
1155         AC_WIRESHARK_KRB5_CHECK
1156 fi
1157
1158
1159 dnl ADNS Check
1160 ADNS_LIBS=''
1161 AC_MSG_CHECKING(whether to use the GNU ADNS library if available)
1162
1163 AC_ARG_WITH(adns,
1164   AC_HELP_STRING( [--with-adns@<:@=DIR@:>@],
1165                   [use GNU ADNS (located in directory DIR, if supplied).   @<:@default=yes, if present@:>@]),
1166 [
1167 if   test "x$withval" = "xno";  then
1168         want_adns=no
1169 elif test "x$withval" = "xyes"; then
1170         want_adns=yes
1171 elif test -d "$withval"; then
1172         want_adns=yes
1173         AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1174 fi
1175 ])
1176 if test "x$with_adns" = "xno" ; then
1177         AC_MSG_RESULT(no)
1178 else
1179         AC_MSG_RESULT(yes)
1180         AC_WIRESHARK_ADNS_CHECK
1181 fi
1182 AC_SUBST(ADNS_LIBS)
1183
1184 #
1185 # Define WS_VAR_IMPORT appropriately for declarations of external
1186 # variables exported from dynamically-linked libraries.
1187 #
1188 AC_DEFINE(WS_VAR_IMPORT, extern, [Define as the string to precede external variable declarations in dynamically-linked libraries])
1189
1190 #
1191 # Define HAVE_AIRPDCAP
1192 # We'll want to remove this eventually.
1193 #
1194 AC_DEFINE(HAVE_AIRPDCAP, 1, [Enable AirPDcap (WPA/WPA2 decryption)])
1195
1196 dnl Checks for typedefs, structures, and compiler characteristics.
1197 # AC_C_CONST
1198
1199 # We need to know whether "struct sockaddr" has an "sa_len" member
1200 # for get_interface_list().
1201
1202 AC_WIRESHARK_STRUCT_SA_LEN
1203
1204 # We must know our byte order
1205 AC_C_BIGENDIAN
1206
1207 # Checks whether "-traditional" is needed when using "ioctl".
1208 # XXX - do we need this?
1209 AC_PROG_GCC_TRADITIONAL
1210
1211 #
1212 # Does GLib define G_GINT64_MODIFIER?
1213 #
1214 AC_MSG_CHECKING([[whether glib.h defines the G_GINT64_MODIFIER macro]])
1215 AC_COMPILE_IFELSE(
1216   [
1217     AC_LANG_SOURCE(
1218       [[
1219         #include <glib.h>
1220         #if GTK_MAJOR_VERSION >= 2
1221         #include <glib/gprintf.h>
1222         #endif
1223         #include <stdio.h>
1224
1225         main()
1226         {
1227           char strbuf[16+1];
1228           g_snprintf(strbuf, sizeof strbuf, "%" G_GINT64_MODIFIER "x\n", (gint64)1);
1229         }
1230       ]])
1231   ],
1232   [
1233     AC_MSG_RESULT(yes)
1234   ],
1235   [
1236     AC_MSG_RESULT(no)
1237     AC_WIRESHARK_CHECK_64BIT_FORMAT(l,
1238       [
1239       AC_WIRESHARK_CHECK_64BIT_FORMAT(ll,
1240         [
1241           AC_WIRESHARK_CHECK_64BIT_FORMAT(L,
1242             [
1243               AC_WIRESHARK_CHECK_64BIT_FORMAT(q,
1244                 [
1245                   AC_MSG_ERROR([neither %lx nor %llx nor %Lx nor %qx worked on a 64-bit integer])
1246                 ])
1247             ])
1248         ])
1249     ])
1250   ])
1251
1252 GETOPT_C=""
1253 GETOPT_O=""
1254 AC_CHECK_FUNC(getopt, GETOPT_O="",
1255   [GETOPT_O="getopt.o"
1256    AC_DEFINE(NEED_GETOPT_H, 1, [Define if getopt.h needs to be included])
1257 ])
1258 if test "$ac_cv_func_getopt" = no ; then
1259   GETOPT_C="getopt.c"
1260   GETOPT_O="getopt.o"
1261 fi
1262 AC_SUBST(GETOPT_C)
1263 AC_SUBST(GETOPT_O)
1264
1265 AC_CHECK_FUNC(strerror, STRERROR_O="",
1266   [STRERROR_O="strerror.o"
1267    AC_DEFINE(NEED_STRERROR_H, 1, [Define if strerror.h needs to be included])
1268 ])
1269 if test "$ac_cv_func_strerror" = no ; then
1270   STRERROR_C="strerror.c"
1271   STRERROR_O="strerror.o"
1272 fi
1273 AC_SUBST(STRERROR_C)
1274 AC_SUBST(STRERROR_O)
1275
1276 AC_CHECK_FUNC(strcasecmp, STRCASECMP_O="",
1277   STRCASECMP_O="strcasecmp.o")
1278 if test "$ac_cv_func_strcasecmp" = no ; then
1279   STRCASECMP_C="strcasecmp.c"
1280   STRCASECMP_O="strcasecmp.o"
1281 fi
1282 AC_SUBST(STRCASECMP_C)
1283 AC_SUBST(STRCASECMP_O)
1284
1285 AC_CHECK_FUNC(strncasecmp, STRNCASECMP_O="",
1286   STRNCASECMP_O="strncasecmp.o")
1287 if test "$ac_cv_func_strncasecmp" = no ; then
1288   STRNCASECMP_C="strncasecmp.c"
1289   STRNCASECMP_O="strncasecmp.o"
1290 fi
1291 AC_SUBST(STRNCASECMP_C)
1292 AC_SUBST(STRNCASECMP_O)
1293
1294 AC_CHECK_FUNC(mkstemp, MKSTEMP_O="",
1295   MKSTEMP_O="mkstemp.o")
1296 if test "$ac_cv_func_mkstemp" = no ; then
1297   MKSTEMP_C="mkstemp.c"
1298   MKSTEMP_O="mkstemp.o"
1299 fi
1300 AC_SUBST(MKSTEMP_C)
1301 AC_SUBST(MKSTEMP_O)
1302
1303 ac_save_LIBS="$LIBS"
1304 LIBS="$GLIB_LIBS $LIBS"
1305 G_ASCII_STRTOULL_C=""
1306 G_ASCII_STRTOULL_O=""
1307 G_ASCII_STRTOULL_LO=""
1308 AC_CHECK_FUNC(g_ascii_strtoull,
1309   [G_ASCII_STRTOULL_O=""
1310    G_ASCII_STRTOULL_LO=""],
1311   [G_ASCII_STRTOULL_O="g_ascii_strtoull.o"
1312    G_ASCII_STRTOULL_LO="g_ascii_strtoull.lo"
1313    AC_DEFINE(NEED_G_ASCII_STRTOULL_H, 1, [Define if g_ascii_strtoull.h needs to be included])
1314 ])
1315 LIBS="$ac_save_LIBS"
1316 if test "$ac_cv_func_g_ascii_strtoull" = no ; then
1317   G_ASCII_STRTOULL_C="g_ascii_strtoull.c"
1318   G_ASCII_STRTOULL_O="g_ascii_strtoull.o"
1319   G_ASCII_STRTOULL_LO="g_ascii_strtoull.lo"
1320 fi
1321 AC_SUBST(G_ASCII_STRTOULL_C)
1322 AC_SUBST(G_ASCII_STRTOULL_O)
1323 AC_SUBST(G_ASCII_STRTOULL_LO)
1324
1325 AC_CHECK_FUNC(inet_aton,
1326   [INET_ATON_O=""
1327    INET_ATON_LO=""],
1328   [INET_ATON_O="inet_aton.o"
1329    INET_ATON_LO="inet_aton.lo"
1330 ])
1331 if test "$ac_cv_func_inet_aton" = no ; then
1332   INET_ATON_C="inet_aton.c"
1333   INET_ATON_O="inet_aton.o"
1334   INET_ATON_LO="inet_aton.lo"
1335   AC_DEFINE(NEED_INET_ATON_H, 1, [Define if inet/aton.h needs to be included])
1336 fi
1337 AC_SUBST(INET_ATON_C)
1338 AC_SUBST(INET_ATON_O)
1339 AC_SUBST(INET_ATON_LO)
1340
1341 AC_SEARCH_LIBS(inet_pton, [socket nsl], [
1342   dnl check for pre-BIND82 inet_pton() bug.
1343   AC_MSG_CHECKING(for broken inet_pton)
1344   AC_TRY_RUN([#include <sys/types.h>
1345 #include <sys/socket.h>
1346 #include <netinet/in.h>
1347 #include <arpa/inet.h>
1348 int main()
1349 {
1350 #ifdef AF_INET6
1351   char buf[16];
1352   /* this should return 0 (error) */
1353   return inet_pton(AF_INET6, "0:1:2:3:4:5:6:7:", buf);
1354 #else
1355   return 1;
1356 #endif
1357 }], [AC_MSG_RESULT(ok);
1358 have_inet_pton=yes], [AC_MSG_RESULT(broken);
1359 have_inet_pton=no], [AC_MSG_RESULT(cross compiling, assume it is broken);
1360 have_inet_pton=no])],
1361 have_inet_pton=no)
1362 if test "$have_inet_pton" = no; then
1363   INET_PTON_C="inet_pton.c"
1364   INET_PTON_O="inet_pton.o"
1365   INET_PTON_LO="inet_pton.lo"
1366 else
1367   INET_PTON_C=""
1368   INET_PTON_O=""
1369   INET_PTON_LO=""
1370 fi
1371 AC_SUBST(INET_PTON_C)
1372 AC_SUBST(INET_PTON_O)
1373 AC_SUBST(INET_PTON_LO)
1374
1375 AC_SEARCH_LIBS(inet_ntop, [socket nsl], [
1376   AC_MSG_CHECKING([for inet_ntop prototype])
1377   AC_TRY_COMPILE([#include <stdio.h>
1378 #include <sys/types.h>
1379 #include <sys/socket.h>
1380 #include <netinet/in.h>
1381 #include <arpa/inet.h>
1382
1383 extern const char *inet_ntop(int, const void *, char *, size_t);],, [
1384     AC_MSG_RESULT(yes)
1385     AC_DEFINE(HAVE_INET_NTOP_PROTO, 1,
1386     [Define if inet_ntop() prototype exists])], [
1387     AC_TRY_COMPILE([#include <stdio.h>
1388 #include <sys/types.h>
1389 #include <sys/socket.h>
1390 #include <netinet/in.h>
1391 #include <arpa/inet.h>
1392
1393 extern const char *inet_ntop(int, const void *, char *, socklen_t);],, [
1394       AC_MSG_RESULT(yes)
1395       AC_DEFINE(HAVE_INET_NTOP_PROTO, 1,
1396       [Define if inet_ntop() prototype exists])], [
1397       AC_MSG_RESULT(no)])])
1398   INET_NTOP_O=""
1399   INET_NTOP_LO=""], [
1400   INET_NTOP_C="inet_ntop.c"
1401   INET_NTOP_O="inet_ntop.o"
1402   INET_NTOP_LO="inet_ntop.lo"
1403   AC_DEFINE(NEED_INET_V6DEFS_H, 1,
1404   [Define if inet/v6defs.h needs to be included])])
1405 AC_SUBST(INET_NTOP_C)
1406 AC_SUBST(INET_NTOP_O)
1407 AC_SUBST(INET_NTOP_LO)
1408
1409 AC_CHECK_FUNC(strptime, STRPTIME_O="",
1410   [STRPTIME_O="strptime.o"
1411    AC_DEFINE(NEED_STRPTIME_H, 1, [Define if strptime.h needs to be included])
1412 ])
1413 if test "$ac_cv_func_strptime" = no ; then
1414   STRPTIME_C="strptime.c"
1415   STRPTIME_O="strptime.o"
1416 fi
1417 AC_SUBST(STRPTIME_C)
1418 AC_SUBST(STRPTIME_O)
1419
1420 AC_CHECK_FUNCS(getprotobynumber gethostbyname2)
1421 AC_CHECK_FUNCS(issetugid)
1422 AC_CHECK_FUNCS(mmap mprotect sysconf)
1423
1424 dnl blank for now, but will be used in future
1425 AC_SUBST(wireshark_SUBDIRS)
1426
1427 dnl
1428 dnl check whether plugins should be enabled and, if they should be,
1429 dnl check for plugins directory - stolen from Amanda's configure.in
1430 dnl
1431 plugindir="$libdir/wireshark/plugins/$VERSION"
1432 AC_ARG_WITH(plugins,
1433   AC_HELP_STRING( [--with-plugins@<:@=DIR@:>@],
1434                   [support plugins (installed in DIR, if supplied).   @<:@default=yes, if possible@:>@]),
1435 [
1436   if test "x$withval" = "xno"; then
1437     have_plugins=no
1438   elif test "x$have_plugins" = "xno"; then
1439       AC_MSG_ERROR([GLib on this platform doesn't support loadable modules, so you can't enable plugins.])
1440       if test "x$withval" != "xyes"; then 
1441         plugindir="$withval"
1442       fi
1443   fi
1444 ])
1445 AM_CONDITIONAL(HAVE_PLUGINS, test "x$have_plugins" = "xyes")
1446 if test x$have_plugins = xyes
1447 then
1448   AC_DEFINE(HAVE_PLUGINS, 1, [Define if plugins are enabled])
1449   plugindir=`(
1450     test "x$prefix" = xNONE && prefix=$ac_default_prefix
1451     test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
1452     eval echo "$plugindir"
1453   )`
1454   AC_DEFINE_UNQUOTED(PLUGIN_DIR, "$plugindir", [Plugin installation directory])
1455 else
1456   AC_DEFINE(PLUGIN_DIR, NULL, [Plugin installation directory])
1457 fi
1458 AC_SUBST(plugindir)
1459
1460 #
1461 # The plugin dissectors reside in ./plugins/PROTO/
1462 #
1463 PLUGIN_LIBS="-L../../epan -lwireshark $GLIB_LIBS"
1464 AC_SUBST(PLUGIN_LIBS)
1465
1466 dnl libtool defs
1467 #
1468 # Yes, AM_PROG_LIBTOOL is redundant with newer version(s) of some tool(s)
1469 # (autoconf?  automake?  libtool?) - with the newer version(s), it's
1470 # just an alias for AC_PROG_LIBTOOL, which is called earlier.
1471 #
1472 # With older version(s) of those tool(s), however, it's not just an
1473 # alias, and the configure scripts don't work without it.
1474 #
1475 AM_PROG_LIBTOOL
1476 AC_SUBST(LIBTOOL_DEPS)
1477
1478 AM_CONDITIONAL(ENABLE_STATIC, test x$enable_static = xyes)
1479 if test x$enable_static = xyes -a x$have_plugins = xyes
1480 then
1481   AC_DEFINE(ENABLE_STATIC, 1, [Link plugins statically into Wireshark])
1482 fi
1483 AC_SUBST(ENABLE_STATIC)
1484
1485 dnl Save the cacheable configure results to config.cache before recursing
1486 AC_CACHE_SAVE
1487
1488 AM_CONFIG_HEADER(config.h)
1489 AC_CONFIG_SUBDIRS(wiretap)
1490 AC_OUTPUT(
1491   Makefile
1492   doxygen.cfg
1493   asn1/Makefile
1494   doc/Makefile
1495   epan/Makefile
1496   epan/crypt/Makefile
1497   epan/doxygen.cfg
1498   epan/dfilter/Makefile
1499   epan/dissectors/Makefile
1500   epan/ftypes/Makefile
1501   epan/wslua/Makefile
1502   codecs/Makefile
1503   gtk/Makefile
1504   gtk/doxygen.cfg
1505   help/Makefile
1506   packaging/Makefile
1507   packaging/nsis/Makefile
1508   packaging/rpm/Makefile
1509   packaging/rpm/SPECS/Makefile
1510   packaging/rpm/SPECS/wireshark.spec
1511   packaging/svr4/Makefile
1512   packaging/svr4/checkinstall
1513   packaging/svr4/pkginfo
1514   plugins/Makefile
1515   plugins/agentx/Makefile
1516   plugins/artnet/Makefile
1517   plugins/asn1/Makefile
1518   plugins/ciscosm/Makefile
1519   plugins/docsis/Makefile
1520   plugins/enttec/Makefile
1521   plugins/giop/Makefile
1522   plugins/gryphon/Makefile
1523   plugins/h223/Makefile
1524   plugins/irda/Makefile
1525   plugins/lwres/Makefile
1526   plugins/m2m/Makefile
1527   plugins/mate/Makefile
1528   plugins/mgcp/Makefile
1529   plugins/opcua/Makefile
1530   plugins/opsi/Makefile
1531   plugins/pcli/Makefile
1532   plugins/profinet/Makefile
1533   plugins/rlm/Makefile
1534   plugins/rtnet/Makefile
1535   plugins/rudp/Makefile
1536   plugins/sbus/Makefile
1537   plugins/stats_tree/Makefile
1538   plugins/v5ua/Makefile
1539   plugins/wimax/Makefile
1540   tools/Makefile
1541   tools/idl2wrs.sh
1542   tools/lemon/Makefile
1543   ,)
1544
1545
1546 # Pretty messages
1547
1548 if test "x$enable_setuid_install" = "xyes" ; then
1549         setuid_message="yes (DANGEROUS!!!)"
1550 else
1551         setuid_message="no"
1552 fi
1553
1554 if test "x$want_zlib" = "xno" ; then
1555         zlib_message="no"
1556 else
1557         zlib_message="yes"
1558 fi
1559
1560 if test "x$want_pcre" = "xno" ; then
1561         pcre_message="no"
1562 else
1563         pcre_message="yes"
1564 fi
1565
1566 if test "x$want_lua" = "xyes" -a "x$have_plugins" = "xyes" ; then
1567         lua_message="yes"
1568 else
1569         lua_message="no"
1570 fi
1571
1572 if test "x$want_portaudio" = "xyes" ; then
1573         portaudio_message="yes"
1574 else
1575         portaudio_message="no"
1576 fi
1577
1578 if test "x$want_ssl" = "xno" ; then
1579         ssl_message="no"
1580 else
1581         ssl_message="yes"
1582 fi
1583
1584 if test "x$want_krb5" = "xno" ; then
1585         krb5_message="no"
1586 else
1587         krb5_message="yes ($ac_krb5_version)"
1588 fi
1589
1590 if test "x$have_good_adns" = "xyes" ; then
1591         adns_message="yes"
1592 else
1593         adns_message="no"
1594 fi
1595
1596 if test "x$have_net_snmp" = "xyes" ; then
1597         snmp_libs_message="yes"
1598 else
1599         snmp_libs_message="no"
1600 fi
1601
1602 echo ""
1603 echo "The Wireshark package has been configured with the following options."
1604 echo "                    Build wireshark : $enable_wireshark"
1605 echo "                       Build tshark : $enable_tshark"
1606 echo "                     Build capinfos : $enable_capinfos"
1607 echo "                      Build editcap : $enable_editcap"
1608 echo "                      Build dumpcap : $enable_dumpcap"
1609 echo "                     Build mergecap : $enable_mergecap"
1610 echo "                    Build text2pcap : $enable_text2pcap"
1611 echo "                      Build idl2wrs : $enable_idl2wrs"
1612 echo "                      Build randpkt : $enable_randpkt"
1613 echo "                       Build dftest : $enable_dftest"
1614 echo ""
1615 echo "                     Install setuid : $setuid_message"
1616 echo "                        Use plugins : $have_plugins"
1617 echo "                   Build lua plugin : $lua_message"
1618 echo "                   Build rtp_player : $portaudio_message"
1619 echo "                Use GTK+ v2 library : $enable_gtk2"
1620 if test "x$enable_gtk2" = "xyes" ; then
1621 echo "                        Use threads : $enable_threads"
1622 echo "             Build profile binaries : $enable_profile_build"
1623 fi
1624 echo "                   Use pcap library : $want_pcap"
1625 echo "                   Use zlib library : $zlib_message"
1626 echo "                   Use pcre library : $pcre_message"
1627 echo "               Use kerberos library : $krb5_message"
1628 echo "               Use GNU ADNS library : $adns_message"
1629 echo "             Use GNU crypto library : $gcrypt_message"
1630 echo "             Use SSL crypto library : $ssl_message"
1631 echo "           Use IPv6 name resolution : $enable_ipv6"
1632 echo "               Use Net-SNMP library : $snmp_libs_message"
1633 echo "                 Use gnutls library : $tls_message"