aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/configure.in
blob: 0f978d8fbd865979c94a5c8d1242d0cbc50727fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# $Id$
#
AC_INIT(wtap.c)

AC_PREREQ(2.52)

AC_CANONICAL_HOST
AC_CANONICAL_TARGET

AM_INIT_AUTOMAKE(libwtap.a, 0.0.0)
AM_CONFIG_HEADER(config.h)

AM_DISABLE_STATIC

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_YACC
AM_PROG_LEX
AC_PROG_LIBTOOL
AC_PATH_PROG(LEX, flex)

AC_SUBST(FLEX_PATH)

#
# If we're running gcc, add '-Wall -W -Wcast-qual' to CFLAGS, and add
# '-D_U_="__attribute__((unused))"' as well, so we can use _U_ to
# flag unused function arguments and not get warnings about them.
# If "--with-extra-gcc-checks" was specified, add some additional
# warning checks.
#
# Otherwise, add '-D_U_=""', so that _U_ used to flag an unused function
# argument will compile with non-GCC compilers.
#
AC_ARG_WITH(extra-gcc-checks,
[  --with-extra-gcc-checks Do additional -W checks in GCC.  [default=no]],
[
	if test $withval != no
	then
		wireshark_extra_gcc_flags=" -Wcast-qual -Wcast-align -Wbad-function-cast -pedantic -Wmissing-declarations -Wwrite-strings"
	fi
],)
AC_MSG_CHECKING(to see if we can add '-Wall -W$wireshark_extra_gcc_flags' to CFLAGS)
if test x$GCC != x ; then
  CFLAGS="-D_U_=\"__attribute__((unused))\" -Wall -W $wireshark_extra_gcc_flags $CFLAGS"
  AC_MSG_RESULT(yes)
else
  CFLAGS="-D_U_=\"\" $CFLAGS"
  AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(to see if we can add '-Wdeclaration-after-statement' to CFLAGS)
if test x$GCC == xyes ; then
  # some versions of GCC support this directive
  rm -rf conftest*
  echo "int foo;" >>conftest.c
  if $CC -c -o conftest.o conftest.c -Wdeclaration-after-statement > /dev/null 2>&1 ; then
    CFLAGS="$CFLAGS -Wdeclaration-after-statement"
    AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no)
  fi
else
  # non-gcc compilers do not support this directive
  AC_MSG_RESULT(no)
fi
rm -rf conftest*

AC_MSG_CHECKING(to see if we can add '-Wno-pointer-sign' to CFLAGS)
if test x$GCC == xyes ; then
  # some versions of GCC support this directive
  rm -rf conftest*
  echo "int foo;" >>conftest.c
  if $CC -c -o conftest.o conftest.c -Wno-pointer-sign > /dev/null 2>&1 ; then
    CFLAGS="$CFLAGS -Wno-pointer-sign"
    AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no)
  fi
else
  # non-gcc compilers do not support this directive
  AC_MSG_RESULT(no)
fi
rm -rf conftest*

AC_ARG_WITH(warnings-as-errors,
[  --with-warnings-as-errors Treat warnings as errors (if using gcc). [default=no]],
[  
  if test "x$GCC" != "x"; then
    if test "x$withval" != "xno"; then
      with_warnings_as_errors="yes"
    fi
  else
    with_warnings_as_errors="no"
  fi
],)
AM_CONDITIONAL(HAVE_WARNINGS_AS_ERRORS, test "x$with_warnings_as_errors" = "xyes")

#
# Add any platform-specific compiler flags needed.
#
AC_MSG_CHECKING(for platform-specific compiler flags)
if test "x$GCC" = x
then
	#
	# Not GCC - assume it's the vendor's compiler.
	#
	case "$host_os" in
	hpux*)
		#
		# HP's ANSI C compiler; flags suggested by Jost Martin.
		# "-Ae" for ANSI C plus extensions such as "long long".
		# "+O2", for optimization.  XXX - works with "-g"?
		#
		CFLAGS="-Ae +O2 $CFLAGS"
		AC_MSG_RESULT(HP ANSI C compiler - added -Ae +O2)
		;;
	darwin*)
		#
		# It may be called "cc", but it's really a GCC derivative
		# with a problematic special precompiler and precompiled
		# headers; turn off the special precompiler, as some
		# apparently-legal code won't compile with its precompiled
		# headers.
		#
		CFLAGS="-no-cpp-precomp $CFLAGS"
		AC_MSG_RESULT(Apple GCC - added -no-cpp-precomp)
		;;
	*)
		AC_MSG_RESULT(none needed)
		;;
	esac
else
	case "$host_os" in
	darwin*)
		#
		# See comments above about Apple's lovely C compiler.
		#
		CFLAGS="-no-cpp-precomp $CFLAGS"
		AC_MSG_RESULT(Apple GCC - added -no-cpp-precomp)
		;;
	*)
	AC_MSG_RESULT(none needed)
	;;
	esac
fi


#
# Add any platform-specific linker flags needed.
#
AC_MSG_CHECKING(for platform-specific linker flags)
case "$host_os" in
darwin*)
	#
	# Add -Wl,-single_module to the LDFLAGS used with shared
	# libraries, to fix some error that show up in some cases;
	# some Apple documentation recommends it for most shared
	# libraries.
	#
	LDFLAGS_SHAREDLIB="-Wl,-single_module"
	#
	# Add -Wl,-search_paths_first to make sure that if we search
	# directories A and B, in that order, for a given library, a
	# non-shared version in directory A, rather than a shared
	# version in directory B, is chosen (so we can use
	# --with-pcap=/usr/local to force all programs to be linked
	# with a static version installed in /usr/local/lib rather than
	# the system version in /usr/lib).
	#
	LDFLAGS="-Wl,-search_paths_first $LDFLAGS"
	AC_MSG_RESULT([Apple linker - added -Wl,-single_module and -Wl,-search_paths_first])
	;;
cygwin*)
	#
	# Shared libraries in cygwin/Win32 must never contain
	# undefined symbols.
	#
	LDFLAGS="$LDFLAGS -no-undefined"
	AC_MSG_RESULT(CygWin GNU ld - added -no-undefined)
	;;
*)
	AC_MSG_RESULT(none needed)
	;;
esac
AC_SUBST(LDFLAGS_SHAREDLIB)

AC_ARG_ENABLE(profile-build,
[  --enable-profile-build  build profile-ready binaries.  [default=no]],enable_profile_build=$enableval,enable_profile_build=no)
AM_CONDITIONAL(USE_PROFILE_BUILD, test x$enable_profile_build = xyes)
AC_MSG_CHECKING(if profile builds must be generated)
if test "x$enable_profile_build" = "xyes" ; then
	if test -n "$GCC" ; then
		AC_MSG_RESULT(yes)
		CFLAGS=" -pg $CFLAGS"
	else
		AC_MSG_RESULT(no)
		echo "Building profile binaries currently only supported for GCC."
	fi
else
	AC_MSG_RESULT(no)
fi
	
AC_ARG_ENABLE(gtk2,
[  --disable-gtk2           build Glib1/Gtk1+-based wireshark/tshark.  [default=no]],enable_gtk2=$enableval,enable_gtk2=yes)

if test "x$enable_gtk2" = "xyes" ; then
	AM_PATH_GLIB_2_0(2.0.0, CFLAGS="$CFLAGS $GLIB_CFLAGS" LIBS="$LIBS $GLIB_LIBS", , gmodule)
else
	AM_PATH_GLIB(1.2.0, CFLAGS="$CFLAGS $GLIB_CFLAGS" LIBS="$LIBS $GLIB_LIBS", , gmodule)
fi

dnl Look in /usr/local for header files and libraries ?
AC_ARG_ENABLE(usr-local,
[  --enable-usr-local      look for headers and libs in /usr/local tree.  [default=yes]],enable_usr_local=$enableval,enable_usr_local=yes)

AC_MSG_CHECKING(whether to use /usr/local for headers and libraries)
if test "x$enable_usr_local" = "xyes" ; then
	AC_MSG_RESULT(yes)
	#
	# Arrange that we search for header files in "/usr/local/include",
	# as various packages we use ("libpcap", "zlib") may have been installed
	# under "/usr/local/include".
	#
	# We do this after checking for GLib, so that "-I/usr/local/include"
	# comes after any "-I" flags added by "AM_PATH_GLIB"; if the user has
	# installed a pre-1.2.9 version of GLib, it'd probably go under
	# "/usr/local", and if they then install 1.2.9 or later without
	# uninstalling the pre-1.2.9 version, 1.2.9's header files won't be
	# in "/usr/local/include" (they're put in a separate directory so that
	# GLib 1.2[.x] and 1.3[.x]/2.x can coexist), and if we search
	# "/usr/local/include" before searching the directory "AM_PATH_GLIB"
	# specifies, we may pick up headers from the older version.
	#
	CFLAGS="$CFLAGS -I/usr/local/include"
	CPPFLAGS="$CPPFLAGS -I/usr/local/include"

	#
	# Arrange that we search for libraries in "/usr/local/lib", as we'll
	# be testing whether zlib has gzgets, and we need to be able to find
	# zlib even if it's in "/usr/local/lib".
	#
	# We do this after checking for GLib; see above.
	#
	LDFLAGS="$LDFLAGS -L/usr/local/lib"
else
	AC_MSG_RESULT(no)
fi

dnl Checks for header files
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/time.h netinet/in.h unistd.h fcntl.h sys/stat.h sys/types.h)

#
# Define WS_VAR_IMPORT appropriately for declarations of external
# variables exported from dynamically-linked libraries.
#
AC_DEFINE(WS_VAR_IMPORT, extern, [Define as the string to precede external variable declarations in dynamically-linked libraries])

# We must know our byte order
AC_C_BIGENDIAN

#
# Does GLib define G_GINT64_MODIFIER?
#
AC_MSG_CHECKING([[whether glib.h defines the G_GINT64_MODIFIER macro]])
AC_COMPILE_IFELSE(
  [
    AC_LANG_SOURCE(
      [[
	#include <glib.h>
	#if GTK_MAJOR_VERSION >= 2
	#include <glib/gprintf.h>
	#endif
	#include <stdio.h>

	main()
	{
	  char strbuf[16+1];
	  g_snprintf(strbuf, sizeof strbuf, "%" G_GINT64_MODIFIER "x\n", (gint64)1);
	}
      ]])
  ],
  [
    AC_MSG_RESULT(yes)
  ],
  [
    AC_MSG_RESULT(no)
    AC_WIRETAP_CHECK_64BIT_FORMAT(ll,
      [
	AC_WIRETAP_CHECK_64BIT_FORMAT(L,
	  [
	    AC_WIRETAP_CHECK_64BIT_FORMAT(q,
	      [
		AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer])
	      ])
	  ])
      ])
  ])

#
# Look for libpcap, so we can include <pcap.h> in libpcap.c if it's
# found.
#
# "--with-pcap" is merely done to allow the user to specify a directory
# in which to look for <pcap.h> (and so that specifying it to the
# top-level Wireshark configure script specifies it to the Wiretap
# configure script as well); we search for it regardless of whether
# "--without-pcap" was specified, as Wiretap isn't linked with it and
# there's no benefit to not looking for the header.
#
AC_ARG_WITH(pcap,
[  --with-pcap=DIR         libpcap is located in directory DIR.],
[
	if test $withval != yes -a $withval != no
	then
		pcap_dir=$withval
	fi
],[
	pcap_dir=
])
AC_WIRETAP_PCAP_CHECK

dnl zlib check
AC_MSG_CHECKING(whether to use zlib for reading compressed capture files)

AC_ARG_WITH(zlib,
[  --with-zlib[=DIR]       use zlib (located in directory DIR, if supplied) to read compressed data.  [default=yes, if present]],
[
	if test $withval = no
	then
		want_zlib=no
	elif test $withval = yes
	then
		want_zlib=yes
	else
		want_zlib=yes
		zlib_dir=$withval
	fi
],[
	#
	# Use zlib if it's present, otherwise don't.
	#
	want_zlib=ifpresent
	zlib_dir=
])
if test "x$want_zlib" = "xno" ; then
	AC_MSG_RESULT(no)
else
	AC_MSG_RESULT(yes)
	AC_WIRETAP_ZLIB_CHECK
	if test "x$want_zlib" = "xno" ; then
		AC_MSG_RESULT(zlib not found - disabling compressed capture file support)
	fi
fi

AC_OUTPUT(Makefile)