The NetBSD zlib problem is probably the same as the FreeBSD and OpenBSD
[obnox/wireshark/wip.git] / configure.in
1 # $Id: configure.in,v 1.78 2000/01/16 00:13:24 guy Exp $
2 dnl
3 dnl Process this file with autoconf 2.13 or later to produce a
4 dnl configure script; 2.12 doesn't generate a "configure" script that
5 dnl defines SHELL, and "Makefile.in" has
6 dnl
7 dnl     SHELL = @SHELL@
8 dnl
9 dnl which requires it to be defined - and there may be other problems
10 dnl with pre-2.13 "autoconf" as well.
11 dnl
12 AC_INIT(etypes.h)
13
14 AC_PREREQ(2.13)
15
16 AM_INIT_AUTOMAKE(ethereal, 0.8.1)
17
18 dnl Check for CPU / vendor / OS
19 AC_CANONICAL_HOST
20
21 dnl Checks for programs.
22 AC_PROG_CC
23 AC_PROG_CPP
24 AC_PROG_RANLIB
25 AC_PROG_YACC
26 AM_PROG_LEX
27 AC_PATH_PROG(PERL_PATH, perl)
28 AC_PATH_PROG(LEX, flex)
29
30 AC_SUBST(PERL_PATH)
31 AC_SUBST(FLEX_PATH)
32
33
34 # If we're running gcc, add '-Wall' to CFLAGS.
35 AC_MSG_CHECKING(to see if we can add '-Wall' to CFLAGS)
36 if test x$GCC != x ; then
37   CFLAGS="-Wall $CFLAGS"
38   AC_MSG_RESULT(yes)
39 else
40   AC_MSG_RESULT(no)
41 fi
42
43 #
44 # Arrange that we search for header files in the source directory
45 # and in its "wiretap" subdirectory, as well as in "/usr/local/include",
46 # as various packages we use ("libpcap", "zlib", an SNMP library)
47 # may have been installed under "/usr/local/include".
48 #
49 CFLAGS="$CFLAGS -I\$(top_srcdir) -I\$(top_srcdir)/wiretap -I/usr/local/include"
50 CPPFLAGS="$CPPFLAGS -I\$(top_srcdir) -I\$(top_srcdir)/wiretap -I/usr/local/include"
51
52 #
53 # Arrange that we search for libraries in "/usr/local/lib".
54 #
55 AC_ETHEREAL_ADD_DASH_L(LIBS, /usr/local/lib)
56
57 # Create DATAFILE_DIR #define for config.h
58 DATAFILE_DIR=$sysconfdir
59 DATAFILE_DIR=`(
60     test "x$prefix" = xNONE && prefix=$ac_default_prefix
61     test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
62     eval echo "$DATAFILE_DIR"
63 )`
64 AC_DEFINE_UNQUOTED(DATAFILE_DIR,"$DATAFILE_DIR")
65 AC_SUBST(DATAFILE_DIR)
66
67 # If we're running Solaris, and LD_LIBRARY_PATH is defined, add it as a
68 # link directory.
69 case "$host_os" in
70   solaris*)
71     AC_MSG_CHECKING(for LD_LIBRARY_PATH, since you appear to be running Solaris)
72     if test x$LD_LIBRARY_PATH != x ; then
73       LIBS="$LIBS -R$LD_LIBRARY_PATH"
74       AC_MSG_RESULT(yes -- added LD_LIBRARY_PATH to run-time linker path)
75     else
76       AC_MSG_RESULT(no -- this may be a problem in a few seconds)
77     fi
78   ;;
79 esac
80
81 # GLib checks
82 # This doesn't add GLIB_CFLAGS to CFLAGS, because AM_PATH_GTK will add
83 # GTK_CFLAGS to CFLAGS, and GTK_CFLAGS is a superset of CFLAGS.
84 # However, this means that both @GLIB_LIBS@ and @GTK_LIBS@ will be
85 # set when generating the Makefile, so we can make programs that require
86 # only GLib link with @GLIB_LIBS@ and make programs that require GTK+
87 # link with @GTK_LIBS@ (which includes @GLIB_LIBS@).
88 # We don't add $GLIB_LIBS to LIBS, because we don't want to force all
89 # programs to be built with GLib.
90 #
91 AM_PATH_GLIB(1.2.0, , AC_MSG_ERROR(GLib distribution not found.), gmodule)
92
93 # GTK checks
94 # We don't add $GLIB_LIBS to LIBS, because we don't want to force all
95 # programs to be built with GTK+.
96 #
97 AM_PATH_GTK(1.2.0, CFLAGS="$CFLAGS $GTK_CFLAGS",
98                    AC_MSG_ERROR(GTK+ distribution not found.))
99
100 dnl Checks for "gethostbyname()" - and "-lnsl", if we need it to get
101 dnl "gethostbyname()".
102 AC_ETHEREAL_GETHOSTBY_LIB_CHECK
103
104 dnl Checks for "connect()", used as a proxy for "socket()" - and
105 dnl "-lsocket", if we need it to get "connect()".
106 AC_ETHEREAL_SOCKET_LIB_CHECK
107
108 dnl pcap check
109 AC_ARG_ENABLE(pcap,
110 [  --enable-pcap           use libpcap for packet capturing.  [default=yes]],,enable_pcap=yes)
111
112 AC_MSG_CHECKING(whether to use libpcap for packet capture)
113 if test "x$enable_pcap" = "xno" ; then
114         AC_MSG_RESULT(no)
115 else
116         AC_MSG_RESULT(yes)
117         AC_ETHEREAL_PCAP_CHECK
118 fi
119
120 dnl zlib check
121 AC_ARG_ENABLE(zlib,
122 [  --enable-zlib           use zlib to read compressed data.  [default=yes]],,enable_zlib=yes)
123
124 AC_MSG_CHECKING(whether to use zlib for reading compressed capture files)
125 if test "x$enable_zlib" = "xno" ; then
126         AC_MSG_RESULT(no)
127 else
128         AC_MSG_RESULT(yes)
129         AC_ETHEREAL_ZLIB_CHECK
130         if test "x$enable_zlib" = "xno" ; then
131                 AC_MSG_RESULT(zlib not found - disabling compressed capture file support)
132         fi
133 fi
134
135
136 dnl ipv6 check
137 AC_ARG_ENABLE(ipv6,
138 [  --enable-ipv6           use ipv6 name resolution, if available.  [default=yes]],,enable_ipv6=yes)
139
140 AC_MSG_CHECKING(whether to enable ipv6 name resolution if available)
141 if test "x$enable_ipv6" = "xno" ; then
142         AC_MSG_RESULT(no)
143 else
144         AC_MSG_RESULT(yes)
145         AC_ETHEREAL_IPV6_STACK
146 fi
147
148
149 dnl Checks for header files.
150 AC_HEADER_STDC
151 AC_CHECK_HEADERS(fcntl.h sys/ioctl.h sys/time.h unistd.h stdarg.h netdb.h dirent.h)
152 AC_CHECK_HEADERS(sys/stat.h sys/sockio.h sys/types.h sys/socket.h)
153 AC_CHECK_HEADERS(sys/wait.h sys/param.h)
154 AC_CHECK_HEADERS(netinet/in.h net/if.h)
155 AC_CHECK_HEADERS(stddef.h)
156 AC_CHECK_HEADERS(dlfcn.h)
157 AC_CHECK_HEADERS(arpa/inet.h arpa/nameser.h)
158
159 dnl SNMP Check
160 AC_ARG_ENABLE(snmp,
161 [  --enable-snmp           use SNMP library, if available.  [default=yes]],,enable_snmp=yes)
162
163 SNMP_LIBS=''
164 AC_MSG_CHECKING(whether to use SNMP library if available)
165 if test "x$enable_snmp" = "xno" ; then
166         AC_MSG_RESULT(no)
167 else
168         AC_MSG_RESULT(yes)
169         AC_ETHEREAL_UCDSNMP_CHECK
170         AC_CHECK_HEADERS(ucd-snmp/snmp.h ucd-snmp/version.h snmp/snmp.h snmp/version.h)
171
172         #
173         # This may require "-lkstat" on Solaris, sigh.
174         #
175         AC_CHECK_LIB(snmp, sprint_objid,
176           SNMP_LIBS=-lsnmp,
177           [
178             #
179             # Throw away the cached "we didn't find it" answer.
180             #
181             unset ac_cv_lib_snmp_sprint_objid
182             AC_CHECK_LIB(snmp, sprint_objid,
183               [
184                 #
185                 # Throw away the cached "we found it" answer, so that if
186                 # we rerun "configure", we don't just blow off this check
187                 # and blithely assume that we don't need "-lkstat".
188                 #
189                 # XXX - autoconf really needs a way to test for a given
190                 # routine in a given library *and* to test whether additional
191                 # "-L"/"-R"/whatever flags are needed *before* the "-l"
192                 # flag for the library and to test whether additional libraries
193                 # are needed after the library *and* to cache all that
194                 # information.
195                 #
196                 unset ac_cv_lib_snmp_sprint_objid
197                 SNMP_LIBS="-lsnmp -lkstat"
198               ],,$SOCKET_LIBS $NSL_LIBS -lkstat
199             )
200           ], $SOCKET_LIBS $NSL_LIBS
201         )
202         
203 fi
204 AC_SUBST(SNMP_LIBS)
205
206 dnl Checks for typedefs, structures, and compiler characteristics.
207 # AC_C_CONST
208
209 # We need to know whether "struct sockaddr" has an "sa_len" member
210 # for get_interface_list().
211
212 AC_ETHEREAL_STRUCT_SA_LEN
213
214 # We must know our byte order
215 AC_C_BIGENDIAN
216
217 # Checks whether "-traditional" is needed when using "ioctl".
218 # XXX - do we need this?
219 AC_PROG_GCC_TRADITIONAL
220
221 # If there's a system out there that has snprintf and _doesn't_ have vsnprintf,
222 # then this won't work.
223 SNPRINTF_C=""
224 SNPRINTF_O=""
225 AC_CHECK_FUNC(snprintf, SNPRINTF_O="",
226   SNPRINTF_O="snprintf.o" [AC_DEFINE(NEED_SNPRINTF_H)])
227 if test "$ac_cv_func_snprintf" = no ; then
228   SNPRINTF_C="snprintf.c"
229   SNPRINTF_O="snprintf.o"
230 fi
231 AC_SUBST(SNPRINTF_C)
232 AC_SUBST(SNPRINTF_O)
233
234 AC_CHECK_FUNC(strerror, STRERROR_O="",
235   STRERROR_O="strerror.o" [AC_DEFINE(NEED_STRERROR_H)])
236 if test "$ac_cv_func_strerror" = no ; then
237   STRERROR_C="strerror.c"
238   STRERROR_O="strerror.o"
239 fi
240 AC_SUBST(STRERROR_C)
241 AC_SUBST(STRERROR_O)
242
243 AC_CHECK_FUNC(strncasecmp, STRNCASECMP_O="",
244   STRNCASECMP_O="strncasecmp.o")
245 if test "$ac_cv_func_strncasecmp" = no ; then
246   STRNCASECMP_C="strncasecmp.c"
247   STRNCASECMP_O="strncasecmp.o"
248 fi
249 AC_SUBST(STRNCASECMP_C)
250 AC_SUBST(STRNCASECMP_O)
251
252 AC_CHECK_FUNC(mkstemp, MKSTEMP_O="",
253   MKSTEMP_O="mkstemp.o")
254 if test "$ac_cv_func_mkstemp" = no ; then
255   MKSTEMP_C="mkstemp.c"
256   MKSTEMP_O="mkstemp.o"
257   AC_DEFINE(NEED_MKSTEMP)
258 fi
259 AC_SUBST(MKSTEMP_C)
260 AC_SUBST(MKSTEMP_O)
261
262 AC_CHECK_FUNC(inet_aton, INET_ATON_O="",
263   INET_ATON_O="inet_aton.o")
264 if test "$ac_cv_func_inet_aton" = no ; then
265   INET_ATON_C="inet_aton.c"
266   INET_ATON_O="inet_aton.o"
267 fi
268 AC_SUBST(INET_ATON_C)
269 AC_SUBST(INET_ATON_O)
270
271 AC_CHECK_FUNC(inet_pton, [
272   dnl check for pre-BIND82 inet_pton() bug.
273   AC_MSG_CHECKING(for broken inet_pton)
274   AC_TRY_RUN([#include <sys/types.h>
275 #include <sys/socket.h>
276 #include <netinet/in.h>
277 #include <arpa/inet.h>
278 int main()
279 {
280 #ifdef AF_INET6
281   char buf[16];
282   /* this should return 0 (error) */
283   return inet_pton(AF_INET6, "0:1:2:3:4:5:6:7:", buf);
284 #else
285   return 1;
286 #endif
287 }], [AC_MSG_RESULT(ok);
288 have_inet_pton=yes], [AC_MSG_RESULT(broken);
289 have_inet_pton=no], [AC_MSG_RESULT(cross compiling, assume it is broken);
290 have_inet_pton=no])],
291 have_inet_pton=no)
292 if test "$have_inet_pton" = no; then
293   INET_PTON_C="inet_pton.c"
294   INET_PTON_O="inet_pton.o"
295 else
296   INET_PTON_C=""
297   INET_PTON_O=""
298 fi
299 AC_SUBST(INET_PTON_C)
300 AC_SUBST(INET_PTON_O)
301
302 AC_CHECK_FUNC(inet_ntop, INET_NTOP_O="",
303   INET_NTOP_O="inet_ntop.o")
304 if test "$ac_cv_func_inet_ntop" = no ; then
305   INET_NTOP_C="inet_ntop.c"
306   INET_NTOP_O="inet_ntop.o"
307   AC_DEFINE(NEED_INET_V6DEFS_H)
308 fi
309 AC_SUBST(INET_NTOP_C)
310 AC_SUBST(INET_NTOP_O)
311
312 AC_CHECK_FUNCS(getprotobynumber gethostbyname2)
313
314 dnl blank for now, but will be used in future
315 AC_SUBST(ethereal_SUBDIRS)
316
317 dnl check for plugins directory - stolen from Amanda's configure.in
318 AC_ARG_WITH(plugindir,
319   [  --with-plugindir=DIR   install plugins in DIR],
320   [
321   case "$withval" in
322   "" | y | ye | yes | n | no)
323     AC_MSG_ERROR([*** You must supply an argument to the --with-plugindir option.])
324   ;;
325   *) PLUGIN_DIR="$withval"
326   esac
327   ],
328   : ${PLUGIN_DIR=$libdir/ethereal/plugins/0.8}
329 )
330
331 PLUGIN_DIR=`(
332   test "x$prefix" = xNONE && prefix=$ac_default_prefix
333   test "x$exec_prefix" = xNONE && exec_prefix=${prefix}
334   eval echo "$PLUGIN_DIR"
335 )`
336 AC_DEFINE_UNQUOTED(PLUGIN_DIR,"$PLUGIN_DIR", [Plugin installation directory])
337 AC_SUBST(PLUGIN_DIR)
338
339 dnl libtool defs
340 AC_LIBTOOL_DLOPEN
341 AM_PROG_LIBTOOL
342 AC_SUBST(LIBTOOL_DEPS)
343
344 AM_CONFIG_HEADER(config.h)
345 AC_CONFIG_SUBDIRS(wiretap)
346 AC_OUTPUT(
347   Makefile
348   ethereal.spec
349   doc/Makefile
350   doc/dfilter2pod
351   gtk/Makefile
352   plugins/Makefile
353   plugins/gryphon/Makefile,
354         [chmod +x doc/dfilter2pod])