Back out the changes made earlier.
[metze/wireshark/wip.git] / wiretap / configure.in
1 # $Id: configure.in,v 1.47 2003/07/23 20:32:37 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(wtap.c)
13
14 AC_PREREQ(2.13)
15
16 AC_CANONICAL_HOST
17 AC_CANONICAL_TARGET
18
19 AM_INIT_AUTOMAKE(libwtap.a, 0.0.0)
20 AM_CONFIG_HEADER(config.h)
21
22 dnl Checks for programs.
23 AC_PROG_CC
24 AC_PROG_CPP
25 AC_PROG_YACC
26 AM_PROG_LEX
27 AC_PROG_LIBTOOL
28 AC_PATH_PROG(LEX, flex)
29
30 AC_SUBST(FLEX_PATH)
31
32 #
33 # If we're running gcc, add '-Wall -W -Wcast-qual' to CFLAGS, and add
34 # '-D_U_="__attribute__((unused))"' as well, so we can use _U_ to
35 # flag unused function arguments and not get warnings about them.
36 # If "--with-extra-gcc-checks" was specified, add "-Wcast-align"
37 # as well.  (Add more checks here in the future?)
38 #
39 # Otherwise, add '-D_U_=""', so that _U_ used to flag an unused function
40 # argument will compile with non-GCC compilers.
41 #
42 AC_ARG_WITH(extra-gcc-checks,
43 [  --with-extra-gcc-checks Do additional -W checks in GCC.  [default=no]],
44 [
45         if test $withval != no
46         then
47                 ethereal_extra_gcc_flags=" -Wcast-align"
48         fi
49 ],)
50 AC_MSG_CHECKING(to see if we can add '-Wall -W -Wcast-qual$ethereal_extra_gcc_flags' to CFLAGS)
51 if test x$GCC != x ; then
52   CFLAGS="-D_U_=\"__attribute__((unused))\" -Wall -W -Wcast-qual$ethereal_extra_gcc_flags $CFLAGS"
53   AC_MSG_RESULT(yes)
54 else
55   CFLAGS="-D_U_=\"\" $CFLAGS"
56   AC_MSG_RESULT(no)
57 fi
58
59 #
60 # Add any platform-specific compiler flags needed.
61 #
62 AC_MSG_CHECKING(for platform-specific compiler flags)
63 if test "x$GCC" = x
64 then
65         #
66         # Not GCC - assume it's the vendor's compiler.
67         #
68         case "$host_os" in
69         hpux*)
70                 #
71                 # HP's ANSI C compiler; flags suggested by Jost Martin.
72                 # "-Ae" for ANSI C plus extensions such as "long long".
73                 # "+O2", for optimization.  XXX - works with "-g"?
74                 #
75                 CFLAGS="-Ae +O2 $CFLAGS"
76                 AC_MSG_RESULT(HP ANSI C compiler - added -Ae +O2)
77                 ;;
78         darwin*)
79                 #
80                 # It may be called "cc", but it's really a GCC derivative
81                 # with a problematic special precompiler and precompiled
82                 # headers; turn off the special precompiler, as some
83                 # apparently-legal code won't compile with its precompiled
84                 # headers.
85                 #
86                 CFLAGS="-no-cpp-precomp $CFLAGS"
87                 AC_MSG_RESULT(Apple GCC - added -no-cpp-precomp)
88                 ;;
89         *)
90                 AC_MSG_RESULT(none needed)
91                 ;;
92         esac
93 else
94         case "$host_os" in
95         darwin*)
96                 #
97                 # See comments above about Apple's lovely C compiler.
98                 #
99                 CFLAGS="-no-cpp-precomp $CFLAGS"
100                 AC_MSG_RESULT(Apple GCC - added -no-cpp-precomp)
101                 ;;
102         *)
103         AC_MSG_RESULT(none needed)
104         ;;
105         esac
106 fi
107
108 AC_ARG_ENABLE(gtk2,
109 [  --enable-gtk2           build Glib2/Gtk2+-based (t)ethereal.  [default=no]],enable_gtk2=$enableval,enable_gtk2=no)
110
111 if test "x$enable_gtk2" = "xyes" ; then
112         AM_PATH_GLIB_2_0(2.0.0, CFLAGS="$CFLAGS $GLIB_CFLAGS" LIBS="$LIBS $GLIB_LIBS", , gmodule)
113 else
114         AM_PATH_GLIB(1.2.0, CFLAGS="$CFLAGS $GLIB_CFLAGS" LIBS="$LIBS $GLIB_LIBS", , gmodule)
115 fi
116
117 dnl Look in /usr/local for header files and libraries ?
118 AC_ARG_ENABLE(usr-local,
119 [  --enable-usr-local      look for headers and libs in /usr/local tree.  [default=yes]],enable_usr_local=$enableval,enable_usr_local=yes)
120
121 AC_MSG_CHECKING(whether to use /usr/local for headers and libraries)
122 if test "x$enable_usr_local" = "xyes" ; then
123         AC_MSG_RESULT(yes)
124         #
125         # Arrange that we search for header files in "/usr/local/include",
126         # as various packages we use ("libpcap", "zlib") may have been installed
127         # under "/usr/local/include".
128         #
129         # We do this after checking for GLib, so that "-I/usr/local/include"
130         # comes after any "-I" flags added by "AM_PATH_GLIB"; if the user has
131         # installed a pre-1.2.9 version of GLib, it'd probably go under
132         # "/usr/local", and if they then install 1.2.9 or later without
133         # uninstalling the pre-1.2.9 version, 1.2.9's header files won't be
134         # in "/usr/local/include" (they're put in a separate directory so that
135         # GLib 1.2[.x] and 1.3[.x]/2.x can coexist), and if we search
136         # "/usr/local/include" before searching the directory "AM_PATH_GLIB"
137         # specifies, we may pick up headers from the older version.
138         #
139         CFLAGS="$CFLAGS -I/usr/local/include"
140         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
141
142         #
143         # Arrange that we search for libraries in "/usr/local/lib", as we'll
144         # be testing whether zlib has gzgets, and we need to be able to find
145         # zlib even if it's in "/usr/local/lib".
146         #
147         # We do this after checking for GLib; see above.
148         #
149         LDFLAGS="$LDFLAGS -L/usr/local/lib"
150 else
151         AC_MSG_RESULT(no)
152 fi
153
154 dnl Checks for header files
155 AC_HEADER_STDC
156 AC_CHECK_HEADERS(sys/time.h netinet/in.h unistd.h fcntl.h sys/stat.h sys/types.h)
157
158 # We must know our byte order
159 AC_C_BIGENDIAN
160
161 #
162 # Look for libpcap, so we can include <pcap.h> in libpcap.c if it's
163 # found.
164 #
165 # "--with-pcap" is merely done to allow the user to specify a directory
166 # in which to look for <pcap.h> (and so that specifying it to the
167 # top-level Ethereal configure script specifies it to the Wiretap
168 # configure script as well); we search for it regardless of whether
169 # "--without-pcap" was specified, as Wiretap isn't linked with it and
170 # there's no benefit to not looking for the header.
171 #
172 AC_ARG_WITH(pcap,
173 [  --with-pcap=DIR      libpcap is located in directory DIR.],
174 [
175         if test $withval != yes -a $withval != no
176         then
177                 pcap_dir=$withval
178         fi
179 ],[
180         pcap_dir=
181 ])
182 AC_WIRETAP_PCAP_CHECK
183
184 dnl zlib check
185 AC_MSG_CHECKING(whether to use zlib for reading compressed capture files)
186
187 AC_ARG_WITH(zlib,
188 [  --with-zlib[=DIR]       use zlib (located in directory DIR, if supplied) to read compressed data.  [default=yes, if present]],
189 [
190         if test $withval = no
191         then
192                 want_zlib=no
193         elif test $withval = yes
194         then
195                 want_zlib=yes
196         else
197                 want_zlib=yes
198                 zlib_dir=$withval
199         fi
200 ],[
201         #
202         # Use zlib if it's present, otherwise don't.
203         #
204         want_zlib=ifpresent
205         zlib_dir=
206 ])
207 if test "x$want_zlib" = "xno" ; then
208         AC_MSG_RESULT(no)
209 else
210         AC_MSG_RESULT(yes)
211         AC_WIRETAP_ZLIB_CHECK
212         if test "x$want_zlib" = "xno" ; then
213                 AC_MSG_RESULT(zlib not found - disabling compressed capture file support)
214         fi
215 fi
216
217 AC_OUTPUT(Makefile)