Fix for bug 848. Make a scrollable window when more than 10 interfaces are listed.
[obnox/wireshark/wip.git] / wiretap / acinclude.m4
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.
4 dnl
5 dnl $Id$
6 dnl
7
8 #
9 # AC_WIRETAP_ADD_DASH_L
10 #
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.
14 #
15 # XXX - IRIX, and other OSes, may require some flag equivalent to
16 # "-R" here.
17 #
18 AC_DEFUN([AC_WIRETAP_ADD_DASH_L],
19 [$1="$$1 -L$2"
20 case "$host_os" in
21   solaris*)
22     $1="$$1 -R$2"
23   ;;
24 esac
25 ])
26
27 #
28 # AC_WIRETAP_PCAP_CHECK
29 #
30 AC_DEFUN([AC_WIRETAP_PCAP_CHECK],
31 [
32         if test -z "$pcap_dir"
33         then
34           #
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".
41           #
42           # XXX - should we just add "$prefix/include" to the include
43           # search path?
44           #
45           AC_MSG_CHECKING(for extraneous pcap header directories)
46           found_pcap_dir=""
47           for pcap_dir in /usr/include/pcap $prefix/include /usr/local/include/pcap
48           do
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"
53               fi
54               found_pcap_dir=" $found_pcap_dir -I$pcap_dir"
55               break
56             fi
57           done
58
59           if test "$found_pcap_dir" != "" ; then
60             AC_MSG_RESULT(found --$found_pcap_dir added to CFLAGS)
61           else
62             AC_MSG_RESULT(not found)
63           fi
64         else
65           #
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.
69           #
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.
75           #
76           CFLAGS="$CFLAGS -I$pcap_dir/include"
77           CPPFLAGS="$CPPFLAGS -I$pcap_dir/include"
78         fi
79
80         # Pcap header check
81         AC_CHECK_HEADERS(pcap.h)
82 ])
83
84 #
85 # AC_WIRETAP_ZLIB_CHECK
86 #
87 AC_DEFUN([AC_WIRETAP_ZLIB_CHECK],
88 [
89         if test "x$zlib_dir" != "x"
90         then
91           #
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.
96           #
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.
102           #
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)
109         fi
110
111         #
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.
114         #
115         AC_CHECK_HEADER(zlib.h,,
116           [
117             if test "x$zlib_dir" != "x"
118             then
119               #
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.
125               #
126               AC_MSG_ERROR([zlib header not found in directory specified in --with-zlib])
127             else
128               if test "x$want_zlib" = "xyes"
129               then
130                 #
131                 # The user tried to force us to use the library, but we
132                 # couldn't find the header file; report an error.
133                 #
134                 AC_MSG_ERROR(Header file zlib.h not found.)
135               else
136                 #
137                 # We couldn't find the header file; don't use the
138                 # library, as it's probably not present.
139                 #
140                 want_zlib=no
141               fi
142             fi
143           ])
144
145         if test "x$want_zlib" != "xno"
146         then
147                 #
148                 # Well, we at least have the zlib header file.
149                 #
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()".
155                 #
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.)
166                 #
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()".
170                 #
171                 AC_CHECK_LIB(z, gzgets,
172                 [
173                         if test "x$zlib_dir" != "x"
174                         then
175                                 #
176                                 # Put the "-I" and "-L" flags for zlib at
177                                 # the beginning of CFLAGS, CPPFLAGS, and
178                                 # LIBS.
179                                 #
180                                 LIBS=""
181                                 AC_WIRETAP_ADD_DASH_L(LIBS, $zlib_dir/lib)
182                                 LIBS="$LIBS -lz $wiretap_save_LIBS"
183                         else
184                                 LIBS="-lz $LIBS"
185                         fi
186                         AC_DEFINE(HAVE_LIBZ, 1, [Define to use libz library])
187                 ],[
188                         if test "x$zlib_dir" != "x"
189                         then
190                                 #
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.
196                                 #
197                                 CFLAGS="$wiretap_save_CFLAGS"
198                                 CPPFLAGS="$wiretap_save_CPPFLAGS"
199                                 LIBS="$wiretap_save_LIBS"
200                         fi
201                         want_zlib=no
202                 ])
203         fi
204
205         if test "x$want_zlib" != "xno"
206         then
207                 #
208                 # Well, we at least have the zlib header file and a zlib
209                 # with "gzgets()".
210                 #
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.
218                 #
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.
222                 #
223                 ac_save_CFLAGS="$CFLAGS"
224                 ac_save_LIBS="$LIBS"
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),
229                   [
230                     AC_MSG_RESULT(yes)
231                     AC_MSG_ERROR(old zlib found when linking with X11 - get rid of old zlib.)
232                   ])
233                 CFLAGS="$ac_save_CFLAGS"
234                 LIBS="$ac_save_LIBS"
235         fi
236 ])