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