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.
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 $prefix/include /usr/local/include/pcap
49 if test -d $pcap_dir ; then
50 if test x$pcap_dir != x/usr/include; then
51 CFLAGS="$CFLAGS -I$pcap_dir"
52 CPPFLAGS="$CPPFLAGS -I$pcap_dir"
54 found_pcap_dir=" $found_pcap_dir -I$pcap_dir"
59 if test "$found_pcap_dir" != "" ; then
60 AC_MSG_RESULT(found --$found_pcap_dir added to CFLAGS)
62 AC_MSG_RESULT(not found)
66 # The user specified a directory in which libpcap resides,
67 # so add the "include" subdirectory of that directory to
68 # the include file search path.
70 # XXX - if there's also a libpcap in a directory that's
71 # already in CFLAGS or CPPFLAGS, this won't make us find
72 # the version in the specified directory, as the compiler
73 # will search that other directory before it searches the
74 # specified directory.
76 CFLAGS="$CFLAGS -I$pcap_dir/include"
77 CPPFLAGS="$CPPFLAGS -I$pcap_dir/include"
81 AC_CHECK_HEADERS(pcap.h)
85 # AC_WIRETAP_ZLIB_CHECK
87 AC_DEFUN([AC_WIRETAP_ZLIB_CHECK],
89 if test "x$zlib_dir" != "x"
92 # The user specified a directory in which zlib resides,
93 # so add the "include" subdirectory of that directory to
94 # the include file search path and the "lib" subdirectory
95 # of that directory to the library search path.
97 # XXX - if there's also a zlib in a directory that's
98 # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
99 # make us find the version in the specified directory,
100 # as the compiler and/or linker will search that other
101 # directory before it searches the specified directory.
103 wiretap_save_CFLAGS="$CFLAGS"
104 CFLAGS="$CFLAGS -I$zlib_dir/include"
105 wiretap_save_CPPFLAGS="$CPPFLAGS"
106 CPPFLAGS="$CPPFLAGS -I$zlib_dir/include"
107 wiretap_save_LIBS="$LIBS"
108 AC_WIRETAP_ADD_DASH_L(LIBS, $zlib_dir/lib)
112 # Make sure we have "zlib.h". If we don't, it means we probably
113 # don't have zlib, so don't use it.
115 AC_CHECK_HEADER(zlib.h,,
117 if test "x$zlib_dir" != "x"
120 # The user used "--with-zlib=" to specify a directory
121 # containing zlib, but we didn't find the header file
122 # there; that either means they didn't specify the
123 # right directory or are confused about whether zlib
124 # is, in fact, installed. Report the error and give up.
126 AC_MSG_ERROR([zlib header not found in directory specified in --with-zlib])
128 if test "x$want_zlib" = "xyes"
131 # The user tried to force us to use the library, but we
132 # couldn't find the header file; report an error.
134 AC_MSG_ERROR(Header file zlib.h not found.)
137 # We couldn't find the header file; don't use the
138 # library, as it's probably not present.
145 if test "x$want_zlib" != "xno"
148 # Well, we at least have the zlib header file.
150 # Check for "gzgets()" in zlib, because we need it, but
151 # some older versions of zlib don't have it. It appears
152 # from the zlib ChangeLog that any released version of zlib
153 # with "gzgets()" should have the other routines we
154 # depend on, such as "gzseek()", "gztell()", and "zError()".
156 # Another reason why we require "gzgets()" is that
157 # some versions of zlib that didn't have it, such
158 # as 1.0.8, had a bug in "gzseek()" that meant that it
159 # doesn't work correctly on uncompressed files; this
160 # means we cannot use version 1.0.8. (Unfortunately,
161 # that's the version that comes with recent X11 source,
162 # and many people who install XFree86 on their Slackware
163 # boxes don't realize that they should configure it to
164 # use the native zlib rather than building and installing
165 # the crappy old version that comes with XFree86.)
167 # I.e., we can't just avoid using "gzgets()", as
168 # versions of zlib without "gzgets()" are likely to have
169 # a broken "gzseek()".
171 AC_CHECK_LIB(z, gzgets,
173 if test "x$zlib_dir" != "x"
176 # Put the "-I" and "-L" flags for zlib at
177 # the beginning of CFLAGS, CPPFLAGS, and
181 AC_WIRETAP_ADD_DASH_L(LIBS, $zlib_dir/lib)
182 LIBS="$LIBS -lz $wiretap_save_LIBS"
186 AC_DEFINE(HAVE_LIBZ, 1, [Define to use libz library])
188 if test "x$zlib_dir" != "x"
191 # Restore the versions of CFLAGS, CPPFLAGS,
192 # and LIBS before we added the "-with-zlib="
193 # directory, as we didn't actually find
194 # zlib there, or didn't find a zlib that
195 # contains gzgets there.
197 CFLAGS="$wiretap_save_CFLAGS"
198 CPPFLAGS="$wiretap_save_CPPFLAGS"
199 LIBS="$wiretap_save_LIBS"
205 if test "x$want_zlib" != "xno"
208 # Well, we at least have the zlib header file and a zlib
211 # Now check for "gzgets()" in zlib when linking with the
212 # linker flags for GTK+ applications; people often grab
213 # XFree86 source and build and install it on their systems,
214 # and they appear sometimes to misconfigure XFree86 so that,
215 # even on systems with zlib, it assumes there is no zlib,
216 # so the XFree86 build process builds and installs its
217 # own zlib in the X11 library directory.
219 # The XFree86 zlib is an older version that lacks
220 # "gzgets()", and that's the zlib with which Ethereal
221 # gets linked, so the build of Ethereal fails.
223 ac_save_CFLAGS="$CFLAGS"
225 CFLAGS="$CFLAGS $GTK_CFLAGS"
226 LIBS="$GTK_LIBS -lz $LIBS"
227 AC_MSG_CHECKING([for gzgets missing when linking with X11])
228 AC_TRY_LINK_FUNC(gzgets, AC_MSG_RESULT(no),
231 AC_MSG_ERROR(old zlib found when linking with X11 - get rid of old zlib.)
233 CFLAGS="$ac_save_CFLAGS"