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