Don't add compressed-file-reading support unless "gzopen()" *and*
[obnox/wireshark/wip.git] / acinclude.m4
1 dnl Macros that test for specific features.
2 dnl This file is part of Autoconf.
3 dnl Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
4 dnl
5 dnl This program is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 2, or (at your option)
8 dnl any later version.
9 dnl
10 dnl This program is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 dnl GNU General Public License for more details.
14 dnl
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with this program; if not, write to the Free Software
17 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 dnl 02111-1307, USA.
19 dnl
20 dnl As a special exception, the Free Software Foundation gives unlimited
21 dnl permission to copy, distribute and modify the configure scripts that
22 dnl are the output of Autoconf.  You need not follow the terms of the GNU
23 dnl General Public License when using or distributing such scripts, even
24 dnl though portions of the text of Autoconf appear in them.  The GNU
25 dnl General Public License (GPL) does govern all other use of the material
26 dnl that constitutes the Autoconf program.
27 dnl
28 dnl Certain portions of the Autoconf source text are designed to be copied
29 dnl (in certain cases, depending on the input) into the output of
30 dnl Autoconf.  We call these the "data" portions.  The rest of the Autoconf
31 dnl source text consists of comments plus executable code that decides which
32 dnl of the data portions to output in any given case.  We call these
33 dnl comments and executable code the "non-data" portions.  Autoconf never
34 dnl copies any of the non-data portions into its output.
35 dnl
36 dnl This special exception to the GPL applies to versions of Autoconf
37 dnl released by the Free Software Foundation.  When you make and
38 dnl distribute a modified version of Autoconf, you may extend this special
39 dnl exception to the GPL to apply to your modified version as well, *unless*
40 dnl your modified version has the potential to copy into its output some
41 dnl of the text that was the non-data portion of the version that you started
42 dnl with.  (In other words, unless your change moves or copies text from
43 dnl the non-data portions to the data portions.)  If your modification has
44 dnl such potential, you must delete any notice of this special exception
45 dnl to the GPL from your modified version.
46 dnl
47 dnl Written by David MacKenzie, with help from
48 dnl Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
49 dnl Roland McGrath, Noah Friedman, david d zuhn, and many others.
50
51 #
52 # AC_ETHEREAL_STRUCT_SA_LEN
53 #
54 dnl AC_STRUCT_ST_BLKSIZE extracted from the file in qustion,
55 dnl "acspecific.m4" in GNU Autoconf 2.12, and turned into
56 dnl AC_ETHEREAL_STRUCT_SA_LEN, which checks if "struct sockaddr"
57 dnl has the 4.4BSD "sa_len" member, and defines HAVE_SA_LEN; that's
58 dnl what's in this file.
59 dnl Done by Guy Harris <guy@alum.mit.edu> on 1998-11-14. 
60
61 dnl ### Checks for structure members
62
63 AC_DEFUN(AC_ETHEREAL_STRUCT_SA_LEN,
64 [AC_CACHE_CHECK([for sa_len in struct sockaddr], ac_cv_ethereal_struct_sa_len,
65 [AC_TRY_COMPILE([#include <sys/types.h>
66 #include <sys/socket.h>], [struct sockaddr s; s.sa_len;],
67 ac_cv_ethereal_struct_sa_len=yes, ac_cv_ethereal_struct_sa_len=no)])
68 if test $ac_cv_ethereal_struct_sa_len = yes; then
69   AC_DEFINE(HAVE_SA_LEN)
70 fi
71 ])
72
73
74 #
75 # AC_ETHEREAL_IPV6_STACK
76 #
77 # By Jun-ichiro "itojun" Hagino, <itojun@iijlab.net>
78
79 AC_DEFUN(AC_ETHEREAL_IPV6_STACK,
80 [
81         v6type=unknown
82         v6lib=none
83
84         AC_MSG_CHECKING([ipv6 stack type])
85         for i in v6d toshiba kame inria zeta linux; do
86                 case $i in
87                 v6d)
88                         AC_EGREP_CPP(yes, [dnl
89 #include </usr/local/v6/include/sys/types.h>
90 #ifdef __V6D__
91 yes
92 #endif],
93                                 [v6type=$i; v6lib=v6;
94                                 v6libdir=/usr/local/v6/lib;
95                                 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
96                         ;;
97                 toshiba)
98                         AC_EGREP_CPP(yes, [dnl
99 #include <sys/param.h>
100 #ifdef _TOSHIBA_INET6
101 yes
102 #endif],
103                                 [v6type=$i; v6lib=inet6;
104                                 v6libdir=/usr/local/v6/lib;
105                                 CFLAGS="-DINET6 $CFLAGS"])
106                         ;;
107                 kame)
108                         AC_EGREP_CPP(yes, [dnl
109 #include <netinet/in.h>
110 #ifdef __KAME__
111 yes
112 #endif],
113                                 [v6type=$i; v6lib=inet6;
114                                 v6libdir=/usr/local/v6/lib;
115                                 CFLAGS="-DINET6 $CFLAGS"])
116                         ;;
117                 inria)
118                         AC_EGREP_CPP(yes, [dnl
119 #include <netinet/in.h>
120 #ifdef IPV6_INRIA_VERSION
121 yes
122 #endif],
123                                 [v6type=$i; CFLAGS="-DINET6 $CFLAGS"])
124                         ;;
125                 zeta)
126                         AC_EGREP_CPP(yes, [dnl
127 #include <sys/param.h>
128 #ifdef _ZETA_MINAMI_INET6
129 yes
130 #endif],
131                                 [v6type=$i; v6lib=inet6;
132                                 v6libdir=/usr/local/v6/lib;
133                                 CFLAGS="-DINET6 $CFLAGS"])
134                         ;;
135                 linux)
136                         if test -d /usr/inet6; then
137                                 v6type=$i
138                                 v6lib=inet6
139                                 v6libdir=/usr/inet6
140                                 CFLAGS="-DINET6 $CFLAGS"
141                         fi
142                         ;;
143                 esac
144                 if test "$v6type" != "unknown"; then
145                         break
146                 fi
147         done
148
149         if test "$v6lib" != "none"; then
150                 for dir in $v6libdir /usr/local/v6/lib /usr/local/lib; do
151                         if test -d $dir -a -f $dir/lib$v6lib.a; then
152                                 LIBS="-L$dir $LIBS -l$v6lib"
153                                 break
154                         fi
155                 done
156                 enable_ipv6="yes"
157         else
158                 enable_ipv6="no"
159         fi
160         AC_MSG_RESULT(["$v6type, $v6lib"])
161 ])
162
163 #
164 # AC_ETHEREAL_PCAP_CHECK
165 #
166 AC_DEFUN(AC_ETHEREAL_PCAP_CHECK,
167 [
168         # Evidently, some systems have pcap.h, etc. in */include/pcap
169         AC_MSG_CHECKING(for extraneous pcap header directories)
170         found_pcap_dir=""
171         for pcap_dir in /usr/include/pcap /usr/local/include/pcap $prefix/include
172         do
173           if test -d $pcap_dir ; then
174             LIBS="$LIBS -L$pcap_dir"
175             CFLAGS="$CFLAGS -I$pcap_dir"
176             CPPFLAGS="$CPPFLAGS -I$pcap_dir"
177             found_pcap_dir=" $found_pcap_dir -L$pcap_dir"
178           fi
179         done
180
181         if test "$found_pcap_dir" != "" ; then
182           AC_MSG_RESULT(found --$found_pcap_dir added to LIBS and CFLAGS)
183         else
184           AC_MSG_RESULT(not found)
185         fi
186
187         # Pcap checks
188         AC_CHECK_HEADER(net/bpf.h,,
189             AC_MSG_ERROR([[Header file net/bpf.h not found; if you installed libpcap from source, did you also do \"make install-incl\"?]]))
190         AC_CHECK_HEADER(pcap.h,, AC_MSG_ERROR(Header file pcap.h not found.))
191         AC_CHECK_LIB(pcap, pcap_open_offline,, AC_MSG_ERROR(Library libpcap not found.))
192 ])
193
194 #
195 # AC_ETHEREAL_ZLIB_CHECK
196 #
197 AC_DEFUN(AC_ETHEREAL_ZLIB_CHECK,
198 [
199         AC_CHECK_HEADER(zlib.h,,enable_zlib=no)
200         AC_CHECK_LIB(z, gzopen,,enable_zlib=no)
201         AC_CHECK_LIB(z, gzseek,,enable_zlib=no)
202         AC_CHECK_LIB(z, gztell,,enable_zlib=no)
203         AC_CHECK_LIB(z, gzgets,,enable_zlib=no)
204         AC_CHECK_LIB(z, zError,,enable_zlib=no)
205 ])
206
207 #
208 # AC_ETHEREAL_UCDSNMP_CHECK
209 #
210 AC_DEFUN(AC_ETHEREAL_UCDSNMP_CHECK,
211 [
212         want_ucdsnmp=yes
213
214         AC_ARG_WITH(ucdsnmp,
215         [  --with-ucdsnmp=DIR      use UCD SNMP client library, located in directory DIR.], [
216         if test $withval = no
217         then
218                 want_ucdsnmp=no
219         else
220                 want_ucdsnmp=yes
221                 ucdsnmp_user_dir=$withval
222         fi
223         ])
224
225         if test $want_ucdsnmp = yes
226         then
227                 ucdsnmpdir=""
228
229                 for d in $ucdsnmp_user_dir $prefix
230                 do
231                         AC_MSG_CHECKING($d)
232
233                         if test x$d != x/usr/local && test -f $d/include/ucd-snmp/snmp.h
234                         then
235                                 AC_MSG_RESULT(found ucd-snmp in $d)
236                                 ucdsnmpdir=$d
237                                 break
238                         fi
239                 done
240
241                 if test x$ucdsnmpdir != x
242                 then
243                         AC_MSG_RESULT(added $d to paths)
244                         CFLAGS="$CFLAGS -I${ucdsnmpdir}/include"
245                         CPPFLAGS="$CPPFLAGS -I${ucdsnmpdir}/include"
246                         LIBS="$LIBS -L${ucdsnmpdir}/lib"
247                 fi
248         fi
249 ])