Ethereal -> Wireshark
[obnox/wireshark/wip.git] / wiretap / configure.in
1 # $Id$
2 #
3 AC_INIT(wtap.c)
4
5 AC_PREREQ(2.52)
6
7 AC_CANONICAL_HOST
8 AC_CANONICAL_TARGET
9
10 AM_INIT_AUTOMAKE(libwtap.a, 0.0.0)
11 AM_CONFIG_HEADER(config.h)
12
13 AM_DISABLE_STATIC
14
15 dnl Checks for programs.
16 AC_PROG_CC
17 AC_PROG_CPP
18 AC_PROG_YACC
19 AM_PROG_LEX
20 AC_PROG_LIBTOOL
21 AC_PATH_PROG(LEX, flex)
22
23 AC_SUBST(FLEX_PATH)
24
25 #
26 # If we're running gcc, add '-Wall -W -Wcast-qual' to CFLAGS, and add
27 # '-D_U_="__attribute__((unused))"' as well, so we can use _U_ to
28 # flag unused function arguments and not get warnings about them.
29 # If "--with-extra-gcc-checks" was specified, add "-Wcast-align"
30 # as well.  (Add more checks here in the future?)
31 #
32 # Otherwise, add '-D_U_=""', so that _U_ used to flag an unused function
33 # argument will compile with non-GCC compilers.
34 #
35 AC_ARG_WITH(extra-gcc-checks,
36 [  --with-extra-gcc-checks Do additional -W checks in GCC.  [default=no]],
37 [
38         if test $withval != no
39         then
40                 wireshark_extra_gcc_flags=" -Wcast-qual -Wcast-align -Wbad-function-cast -pedantic -Wmissing-declarations -Wwrite-strings"
41         fi
42 ],)
43 AC_MSG_CHECKING(to see if we can add '-Wall -W -Wcast-qual $wireshark_extra_gcc_flags' to CFLAGS)
44 if test x$GCC != x ; then
45   CFLAGS="-D_U_=\"__attribute__((unused))\" -Wall -W $wireshark_extra_gcc_flags $CFLAGS"
46   AC_MSG_RESULT(yes)
47 else
48   CFLAGS="-D_U_=\"\" $CFLAGS"
49   AC_MSG_RESULT(no)
50 fi
51
52 #
53 # Add any platform-specific compiler flags needed.
54 #
55 AC_MSG_CHECKING(for platform-specific compiler flags)
56 if test "x$GCC" = x
57 then
58         #
59         # Not GCC - assume it's the vendor's compiler.
60         #
61         case "$host_os" in
62         hpux*)
63                 #
64                 # HP's ANSI C compiler; flags suggested by Jost Martin.
65                 # "-Ae" for ANSI C plus extensions such as "long long".
66                 # "+O2", for optimization.  XXX - works with "-g"?
67                 #
68                 CFLAGS="-Ae +O2 $CFLAGS"
69                 AC_MSG_RESULT(HP ANSI C compiler - added -Ae +O2)
70                 ;;
71         darwin*)
72                 #
73                 # It may be called "cc", but it's really a GCC derivative
74                 # with a problematic special precompiler and precompiled
75                 # headers; turn off the special precompiler, as some
76                 # apparently-legal code won't compile with its precompiled
77                 # headers.
78                 #
79                 CFLAGS="-no-cpp-precomp $CFLAGS"
80                 AC_MSG_RESULT(Apple GCC - added -no-cpp-precomp)
81                 ;;
82         *)
83                 AC_MSG_RESULT(none needed)
84                 ;;
85         esac
86 else
87         case "$host_os" in
88         darwin*)
89                 #
90                 # See comments above about Apple's lovely C compiler.
91                 #
92                 CFLAGS="-no-cpp-precomp $CFLAGS"
93                 AC_MSG_RESULT(Apple GCC - added -no-cpp-precomp)
94                 ;;
95         cygwin*)
96                 #
97                 # Shared libraries in cygwin/Win32 must never contain
98                 # undefined symbols.
99                 #
100                 LDFLAGS="$LDFLAGS -no-undefined"
101                 AC_MSG_RESULT(CygWin GCC - added -no-undefined to LDFLAGS)
102                 ;;
103         *)
104         AC_MSG_RESULT(none needed)
105         ;;
106         esac
107 fi
108
109 AC_ARG_ENABLE(profile-build,
110 [  --enable-profile-build  build profile-ready binaries.  [default=no]],enable_profile_build=$enableval,enable_profile_build=no)
111 AM_CONDITIONAL(USE_PROFILE_BUILD, test x$enable_profile_build = xyes)
112 AC_MSG_CHECKING(if profile builds must be generated)
113 if test "x$enable_profile_build" = "xyes" ; then
114         if test -n "$GCC" ; then
115                 AC_MSG_RESULT(yes)
116                 CFLAGS=" -pg $CFLAGS"
117         else
118                 AC_MSG_RESULT(no)
119                 echo "Building profile binaries currently only supported for GCC."
120         fi
121 else
122         AC_MSG_RESULT(no)
123 fi
124         
125 AC_ARG_ENABLE(gtk2,
126 [  --disable-gtk2           build Glib1/Gtk1+-based wireshark/tshark.  [default=no]],enable_gtk2=$enableval,enable_gtk2=yes)
127
128 if test "x$enable_gtk2" = "xyes" ; then
129         AM_PATH_GLIB_2_0(2.0.0, CFLAGS="$CFLAGS $GLIB_CFLAGS" LIBS="$LIBS $GLIB_LIBS", , gmodule)
130 else
131         AM_PATH_GLIB(1.2.0, CFLAGS="$CFLAGS $GLIB_CFLAGS" LIBS="$LIBS $GLIB_LIBS", , gmodule)
132 fi
133
134 dnl Look in /usr/local for header files and libraries ?
135 AC_ARG_ENABLE(usr-local,
136 [  --enable-usr-local      look for headers and libs in /usr/local tree.  [default=yes]],enable_usr_local=$enableval,enable_usr_local=yes)
137
138 AC_MSG_CHECKING(whether to use /usr/local for headers and libraries)
139 if test "x$enable_usr_local" = "xyes" ; then
140         AC_MSG_RESULT(yes)
141         #
142         # Arrange that we search for header files in "/usr/local/include",
143         # as various packages we use ("libpcap", "zlib") may have been installed
144         # under "/usr/local/include".
145         #
146         # We do this after checking for GLib, so that "-I/usr/local/include"
147         # comes after any "-I" flags added by "AM_PATH_GLIB"; if the user has
148         # installed a pre-1.2.9 version of GLib, it'd probably go under
149         # "/usr/local", and if they then install 1.2.9 or later without
150         # uninstalling the pre-1.2.9 version, 1.2.9's header files won't be
151         # in "/usr/local/include" (they're put in a separate directory so that
152         # GLib 1.2[.x] and 1.3[.x]/2.x can coexist), and if we search
153         # "/usr/local/include" before searching the directory "AM_PATH_GLIB"
154         # specifies, we may pick up headers from the older version.
155         #
156         CFLAGS="$CFLAGS -I/usr/local/include"
157         CPPFLAGS="$CPPFLAGS -I/usr/local/include"
158
159         #
160         # Arrange that we search for libraries in "/usr/local/lib", as we'll
161         # be testing whether zlib has gzgets, and we need to be able to find
162         # zlib even if it's in "/usr/local/lib".
163         #
164         # We do this after checking for GLib; see above.
165         #
166         LDFLAGS="$LDFLAGS -L/usr/local/lib"
167 else
168         AC_MSG_RESULT(no)
169 fi
170
171 dnl Checks for header files
172 AC_HEADER_STDC
173 AC_CHECK_HEADERS(sys/time.h netinet/in.h unistd.h fcntl.h sys/stat.h sys/types.h)
174
175 # We must know our byte order
176 AC_C_BIGENDIAN
177
178 #
179 # Does GLib define G_GINT64_MODIFIER?
180 #
181 AC_MSG_CHECKING([[whether glib.h defines the G_GINT64_MODIFIER macro]])
182 AC_COMPILE_IFELSE(
183   [
184     AC_LANG_SOURCE(
185       [[
186         #include <glib.h>
187         #if GTK_MAJOR_VERSION >= 2
188         #include <glib/gprintf.h>
189         #endif
190         #include <stdio.h>
191
192         main()
193         {
194           char strbuf[16+1];
195           g_snprintf(strbuf, sizeof strbuf, "%" G_GINT64_MODIFIER "x\n", (gint64)1);
196         }
197       ]])
198   ],
199   [
200     AC_MSG_RESULT(yes)
201   ],
202   [
203     AC_MSG_RESULT(no)
204     AC_WIRETAP_CHECK_64BIT_FORMAT(ll,
205       [
206         AC_WIRETAP_CHECK_64BIT_FORMAT(L,
207           [
208             AC_WIRETAP_CHECK_64BIT_FORMAT(q,
209               [
210                 AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer])
211               ])
212           ])
213       ])
214   ])
215
216 #
217 # Look for libpcap, so we can include <pcap.h> in libpcap.c if it's
218 # found.
219 #
220 # "--with-pcap" is merely done to allow the user to specify a directory
221 # in which to look for <pcap.h> (and so that specifying it to the
222 # top-level Wireshark configure script specifies it to the Wiretap
223 # configure script as well); we search for it regardless of whether
224 # "--without-pcap" was specified, as Wiretap isn't linked with it and
225 # there's no benefit to not looking for the header.
226 #
227 AC_ARG_WITH(pcap,
228 [  --with-pcap=DIR         libpcap is located in directory DIR.],
229 [
230         if test $withval != yes -a $withval != no
231         then
232                 pcap_dir=$withval
233         fi
234 ],[
235         pcap_dir=
236 ])
237 AC_WIRETAP_PCAP_CHECK
238
239 dnl zlib check
240 AC_MSG_CHECKING(whether to use zlib for reading compressed capture files)
241
242 AC_ARG_WITH(zlib,
243 [  --with-zlib[=DIR]       use zlib (located in directory DIR, if supplied) to read compressed data.  [default=yes, if present]],
244 [
245         if test $withval = no
246         then
247                 want_zlib=no
248         elif test $withval = yes
249         then
250                 want_zlib=yes
251         else
252                 want_zlib=yes
253                 zlib_dir=$withval
254         fi
255 ],[
256         #
257         # Use zlib if it's present, otherwise don't.
258         #
259         want_zlib=ifpresent
260         zlib_dir=
261 ])
262 if test "x$want_zlib" = "xno" ; then
263         AC_MSG_RESULT(no)
264 else
265         AC_MSG_RESULT(yes)
266         AC_WIRETAP_ZLIB_CHECK
267         if test "x$want_zlib" = "xno" ; then
268                 AC_MSG_RESULT(zlib not found - disabling compressed capture file support)
269         fi
270 fi
271
272 AC_OUTPUT(Makefile)