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