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