1 dnl Macros that test for specific features.
2 dnl This file is part of the Autoconf packaging for Ethereal.
3 dnl Copyright (C) 1998-2000 by Gerald Combs.
5 dnl $Id: acinclude.m4,v 1.14 2002/04/08 01:34:39 guy Exp $
9 # AC_WIRETAP_ADD_DASH_L
11 # Add to the variable specified as the first argument a "-L" flag for the
12 # directory specified as the second argument, and, on Solaris, add a
13 # "-R" flag for it as well.
15 # XXX - IRIX, and other OSes, may require some flag equivalent to
18 AC_DEFUN(AC_WIRETAP_ADD_DASH_L,
28 # AC_WIRETAP_PCAP_CHECK
30 AC_DEFUN(AC_WIRETAP_PCAP_CHECK,
32 if test -z "$pcap_dir"
35 # The user didn't specify a directory in which libpcap resides;
36 # we assume that the current library search path will work,
37 # but we may have to look for the header in a "pcap"
38 # subdirectory of "/usr/include" or "/usr/local/include",
39 # as some systems apparently put "pcap.h" in a "pcap"
40 # subdirectory, and we also check "$prefix/include".
42 # XXX - should we just add "$prefix/include" to the include
45 AC_MSG_CHECKING(for extraneous pcap header directories)
47 for pcap_dir in /usr/include/pcap /usr/local/include/pcap $prefix/include
49 if test -d $pcap_dir ; then
50 CFLAGS="$CFLAGS -I$pcap_dir"
51 CPPFLAGS="$CPPFLAGS -I$pcap_dir"
52 found_pcap_dir=" $found_pcap_dir -I$pcap_dir"
56 if test "$found_pcap_dir" != "" ; then
57 AC_MSG_RESULT(found --$found_pcap_dir added to CFLAGS)
59 AC_MSG_RESULT(not found)
63 # The user specified a directory in which libpcap resides,
64 # so add the "include" subdirectory of that directory to
65 # the include file search path.
67 # XXX - if there's also a libpcap in a directory that's
68 # already in CFLAGS or CPPFLAGS, this won't make us find
69 # the version in the specified directory, as the compiler
70 # will search that other directory before it searches the
71 # specified directory.
73 CFLAGS="$CFLAGS -I$pcap_dir/include"
74 CPPFLAGS="$CPPFLAGS -I$pcap_dir/include"
78 AC_CHECK_HEADERS(pcap.h)
82 # AC_WIRETAP_ZLIB_CHECK
84 AC_DEFUN(AC_WIRETAP_ZLIB_CHECK,
86 if test "x$zlib_dir" != "x"
89 # The user specified a directory in which zlib resides,
90 # so add the "include" subdirectory of that directory to
91 # the include file search path and the "lib" subdirectory
92 # of that directory to the library search path.
94 # XXX - if there's also a zlib in a directory that's
95 # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
96 # make us find the version in the specified directory,
97 # as the compiler and/or linker will search that other
98 # directory before it searches the specified directory.
100 wiretap_save_CFLAGS="$CFLAGS"
101 CFLAGS="$CFLAGS -I$zlib_dir/include"
102 wiretap_save_CPPLAGS="$CPPLAGS"
103 CPPFLAGS="$CPPFLAGS -I$zlib_dir/include"
104 wiretap_save_LIBS="$LIBS"
105 AC_WIRETAP_ADD_DASH_L(LIBS, $zlib_dir/lib)
109 # Make sure we have "zlib.h". If we don't, it means we probably
110 # don't have zlib, so don't use it.
112 AC_CHECK_HEADER(zlib.h,,
114 if test "x$zlib_dir" != "x"
117 # The user used "--with-zlib=" to specify a directory
118 # containing zlib, but we didn't find the header file
119 # there; that either means they didn't specify the
120 # right directory or are confused about whether zlib
121 # is, in fact, installed. Report the error and give up.
123 AC_MSG_ERROR([zlib header not found in directory specified in --with-zlib])
125 if test "x$want_zlib" = "xyes"
128 # The user tried to force us to use the library, but we
129 # couldn't find the header file; report an error.
131 AC_MSG_ERROR(Header file zlib.h not found.)
134 # We couldn't find the header file; don't use the
135 # library, as it's probably not present.
142 if test "x$want_zlib" != "xno"
145 # Well, we at least have the zlib header file.
147 # Check for "gzgets()" in zlib, because we need it, but
148 # some older versions of zlib don't have it. It appears
149 # from the zlib ChangeLog that any released version of zlib
150 # with "gzgets()" should have the other routines we
151 # depend on, such as "gzseek()", "gztell()", and "zError()".
153 # Another reason why we require "gzgets()" is that
154 # some versions of zlib that didn't have it, such
155 # as 1.0.8, had a bug in "gzseek()" that meant that it
156 # doesn't work correctly on uncompressed files; this
157 # means we cannot use version 1.0.8. (Unfortunately,
158 # that's the version that comes with recent X11 source,
159 # and many people who install XFree86 on their Slackware
160 # boxes don't realize that they should configure it to
161 # use the native zlib rather than building and installing
162 # the crappy old version that comes with XFree86.)
164 # I.e., we can't just avoid using "gzgets()", as
165 # versions of zlib without "gzgets()" are likely to have
166 # a broken "gzseek()".
168 AC_CHECK_LIB(z, gzgets,
170 if test "x$zlib_dir" != "x"
173 # Put the "-I" and "-L" flags for zlib at
174 # the beginning of CFLAGS, CPPFLAGS, and
178 AC_WIRETAP_ADD_DASH_L(LIBS, $zlib_dir/lib)
179 LIBS="$LIBS -lz $wiretap_save_LIBS"
185 if test "x$zlib_dir" != "x"
188 # Restore the versions of CFLAGS, CPPFLAGS,
189 # and LIBS before we added the "-with-zlib="
190 # directory, as we didn't actually find
191 # zlib there, or didn't find a zlib that
192 # contains gzgets there.
194 CFLAGS="$wiretap_save_CFLAGS"
195 CPPFLAGS="$wiretap_save_CPPLAGS"
196 LIBS="$wiretap_save_LIBS"
202 if test "x$want_zlib" != "xno"
205 # Well, we at least have the zlib header file and a zlib
208 # Now check for "gzgets()" in zlib when linking with the
209 # linker flags for GTK+ applications; people often grab
210 # XFree86 source and build and install it on their systems,
211 # and they appear sometimes to misconfigure XFree86 so that,
212 # even on systems with zlib, it assumes there is no zlib,
213 # so the XFree86 build process builds and installs its
214 # own zlib in the X11 library directory.
216 # The XFree86 zlib is an older version that lacks
217 # "gzgets()", and that's the zlib with which Ethereal
218 # gets linked, so the build of Ethereal fails.
220 ac_save_CFLAGS="$CFLAGS"
222 CFLAGS="$CFLAGS $GTK_CFLAGS"
223 LIBS="$GTK_LIBS -lz $LIBS"
224 AC_MSG_CHECKING([for gzgets missing when linking with X11])
225 AC_TRY_LINK_FUNC(gzgets, AC_MSG_RESULT(no),
228 AC_MSG_ERROR(old zlib found when linking with X11 - get rid of old zlib.)
230 CFLAGS="$ac_save_CFLAGS"