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