Update:
[obnox/wireshark/wip.git] / acinclude.m4
1 dnl Macros that test for specific features.
2 dnl This file is part of the Autoconf packaging for Wireshark.
3 dnl Copyright (C) 1998-2000 by Gerald Combs.
4 dnl
5 dnl $Id$
6 dnl
7 dnl This program is free software; you can redistribute it and/or modify
8 dnl it under the terms of the GNU General Public License as published by
9 dnl the Free Software Foundation; either version 2, or (at your option)
10 dnl any later version.
11 dnl
12 dnl This program is distributed in the hope that it will be useful,
13 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 dnl GNU General Public License for more details.
16 dnl
17 dnl You should have received a copy of the GNU General Public License
18 dnl along with this program; if not, write to the Free Software
19 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 dnl 02111-1307, USA.
21 dnl
22 dnl As a special exception, the Free Software Foundation gives unlimited
23 dnl permission to copy, distribute and modify the configure scripts that
24 dnl are the output of Autoconf.  You need not follow the terms of the GNU
25 dnl General Public License when using or distributing such scripts, even
26 dnl though portions of the text of Autoconf appear in them.  The GNU
27 dnl General Public License (GPL) does govern all other use of the material
28 dnl that constitutes the Autoconf program.
29 dnl
30 dnl Certain portions of the Autoconf source text are designed to be copied
31 dnl (in certain cases, depending on the input) into the output of
32 dnl Autoconf.  We call these the "data" portions.  The rest of the Autoconf
33 dnl source text consists of comments plus executable code that decides which
34 dnl of the data portions to output in any given case.  We call these
35 dnl comments and executable code the "non-data" portions.  Autoconf never
36 dnl copies any of the non-data portions into its output.
37 dnl
38 dnl This special exception to the GPL applies to versions of Autoconf
39 dnl released by the Free Software Foundation.  When you make and
40 dnl distribute a modified version of Autoconf, you may extend this special
41 dnl exception to the GPL to apply to your modified version as well, *unless*
42 dnl your modified version has the potential to copy into its output some
43 dnl of the text that was the non-data portion of the version that you started
44 dnl with.  (In other words, unless your change moves or copies text from
45 dnl the non-data portions to the data portions.)  If your modification has
46 dnl such potential, you must delete any notice of this special exception
47 dnl to the GPL from your modified version.
48 dnl
49 dnl Written by David MacKenzie, with help from
50 dnl Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
51 dnl Roland McGrath, Noah Friedman, david d zuhn, and many others.
52
53 #
54 # AC_WIRESHARK_ADD_DASH_L
55 #
56 # Add to the variable specified as the first argument a "-L" flag for the
57 # directory specified as the second argument, and, on Solaris, add a
58 # "-R" flag for it as well.
59 #
60 # XXX - IRIX, and other OSes, may require some flag equivalent to
61 # "-R" here.
62 #
63 AC_DEFUN([AC_WIRESHARK_ADD_DASH_L],
64 [$1="$$1 -L$2"
65 case "$host_os" in
66   solaris*)
67     $1="$$1 -R$2"
68   ;;
69 esac
70 ])
71
72 #
73 # AC_WIRESHARK_TIMEZONE_ABBREV
74 #
75
76 AC_DEFUN([AC_WIRESHARK_TIMEZONE_ABBREV],
77 [
78   AC_CACHE_CHECK([for tm_zone in struct tm],
79     ac_cv_wireshark_have_tm_zone,
80     [
81       AC_TRY_COMPILE(
82         [#include <time.h>],
83         [struct tm t; t.tm_zone;],
84         ac_cv_wireshark_have_tm_zone=yes,
85         ac_cv_wireshark_have_tm_zone=no)
86     ])
87   if test $ac_cv_wireshark_have_tm_zone = yes; then
88     AC_DEFINE(HAVE_TM_ZONE, 1, [Define if tm_zone field exists in struct tm])
89   else
90     AC_CACHE_CHECK([for tzname],
91       ac_cv_wireshark_have_tzname,
92       [
93         AC_TRY_LINK(
94 [#include <time.h>
95 #include <stdio.h>],
96           [printf("%s", tzname[0]);],
97           ac_cv_wireshark_have_tzname=yes,
98           ac_cv_wireshark_have_tzname=no)
99       ])
100     if test $ac_cv_wireshark_have_tzname = yes; then
101       AC_DEFINE(HAVE_TZNAME, 1, [Define if tzname array exists])
102     fi
103   fi
104 ])
105
106
107 #
108 # AC_WIRESHARK_STRUCT_SA_LEN
109 #
110 dnl AC_STRUCT_ST_BLKSIZE extracted from the file in question,
111 dnl "acspecific.m4" in GNU Autoconf 2.12, and turned into
112 dnl AC_WIRESHARK_STRUCT_SA_LEN, which checks if "struct sockaddr"
113 dnl has the 4.4BSD "sa_len" member, and defines HAVE_SA_LEN; that's
114 dnl what's in this file.
115 dnl Done by Guy Harris <guy@alum.mit.edu> on 1998-11-14.
116
117 dnl ### Checks for structure members
118
119 AC_DEFUN([AC_WIRESHARK_STRUCT_SA_LEN],
120 [AC_CACHE_CHECK([for sa_len in struct sockaddr], ac_cv_wireshark_struct_sa_len,
121 [AC_TRY_COMPILE([#include <sys/types.h>
122 #include <sys/socket.h>], [struct sockaddr s; s.sa_len;],
123 ac_cv_wireshark_struct_sa_len=yes, ac_cv_wireshark_struct_sa_len=no)])
124 if test $ac_cv_wireshark_struct_sa_len = yes; then
125   AC_DEFINE(HAVE_SA_LEN, 1, [Define if sa_len field exists in struct sockaddr])
126 fi
127 ])
128
129
130 #
131 # AC_WIRESHARK_IPV6_STACK
132 #
133 # By Jun-ichiro "itojun" Hagino, <itojun@iijlab.net>
134 #
135 AC_DEFUN([AC_WIRESHARK_IPV6_STACK],
136 [
137         v6type=unknown
138         v6lib=none
139
140         AC_MSG_CHECKING([ipv6 stack type])
141         for i in v6d toshiba kame inria zeta linux linux-glibc solaris8; do
142                 case $i in
143                 v6d)
144                         AC_EGREP_CPP(yes, [
145 #include </usr/local/v6/include/sys/types.h>
146 #ifdef __V6D__
147 yes
148 #endif],
149                                 [v6type=$i; v6lib=v6;
150                                 v6libdir=/usr/local/v6/lib;
151                                 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
152                         ;;
153                 toshiba)
154                         AC_EGREP_CPP(yes, [
155 #include <sys/param.h>
156 #ifdef _TOSHIBA_INET6
157 yes
158 #endif],
159                                 [v6type=$i; v6lib=inet6;
160                                 v6libdir=/usr/local/v6/lib;
161                                 CFLAGS="-DINET6 $CFLAGS"])
162                         ;;
163                 kame)
164                         AC_EGREP_CPP(yes, [
165 #include <netinet/in.h>
166 #ifdef __KAME__
167 yes
168 #endif],
169                                 [v6type=$i; v6lib=inet6;
170                                 v6libdir=/usr/local/v6/lib;
171                                 CFLAGS="-DINET6 $CFLAGS"])
172                         ;;
173                 inria)
174                         AC_EGREP_CPP(yes, [
175 #include <netinet/in.h>
176 #ifdef IPV6_INRIA_VERSION
177 yes
178 #endif],
179                                 [v6type=$i; CFLAGS="-DINET6 $CFLAGS"])
180                         ;;
181                 zeta)
182                         AC_EGREP_CPP(yes, [
183 #include <sys/param.h>
184 #ifdef _ZETA_MINAMI_INET6
185 yes
186 #endif],
187                                 [v6type=$i; v6lib=inet6;
188                                 v6libdir=/usr/local/v6/lib;
189                                 CFLAGS="-DINET6 $CFLAGS"])
190                         ;;
191                 linux)
192                         if test -d /usr/inet6; then
193                                 v6type=$i
194                                 v6lib=inet6
195                                 v6libdir=/usr/inet6
196                                 CFLAGS="-DINET6 $CFLAGS"
197                         fi
198                         ;;
199                 linux-glibc)
200                         AC_EGREP_CPP(yes, [
201 #include <features.h>
202 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
203 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || __GLIBC__ > 2
204 yes
205 #endif
206 #endif],
207                         [v6type=$i; v6lib=inet6; CFLAGS="-DINET6 $CFLAGS"])
208                         ;;
209                 solaris8)
210                         if test "`uname -s`" = "SunOS" && test "`uname -r`" = "5.8"; then
211                                 v6type=$i
212                                 v6lib=inet6
213                                 [CFLAGS="-DINET6 -DSOLARIS8_INET6 $CFLAGS"]
214                         fi
215                         ;;
216                 esac
217                 if test "$v6type" != "unknown"; then
218                         break
219                 fi
220         done
221
222         if test "$v6lib" != "none"; then
223                 for dir in $v6libdir /usr/local/v6/lib /usr/local/lib; do
224                         if test -d $dir -a -f $dir/lib$v6lib.a; then
225                                 LIBS="-L$dir $LIBS -l$v6lib"
226                                 break
227                         fi
228                 done
229                 enable_ipv6="yes"
230         else
231                 enable_ipv6="no"
232         fi
233         AC_MSG_RESULT(["$v6type, $v6lib"])
234 ])
235
236 #
237 # AC_WIRESHARK_GETHOSTBY_LIB_CHECK
238 #
239 # Checks whether we need "-lnsl" to get "gethostby*()", which we use
240 # in "resolv.c".
241 #
242 # Adapted from stuff in the AC_PATH_XTRA macro in "acspecific.m4" in
243 # GNU Autoconf 2.13; the comment came from there.
244 # Done by Guy Harris <guy@alum.mit.edu> on 2000-01-14.
245 #
246 AC_DEFUN([AC_WIRESHARK_GETHOSTBY_LIB_CHECK],
247 [
248     # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
249     # to get the SysV transport functions.
250     # chad@anasazi.com says the Pyramid MIS-ES running DC/OSx (SVR4)
251     # needs -lnsl.
252     # The nsl library prevents programs from opening the X display
253     # on Irix 5.2, according to dickey@clark.net.
254     AC_CHECK_FUNC(gethostbyname, ,
255         AC_CHECK_LIB(nsl, gethostbyname, NSL_LIBS="-lnsl"))
256     AC_SUBST(NSL_LIBS)
257 ])
258
259 #
260 # AC_WIRESHARK_SOCKET_LIB_CHECK
261 #
262 # Checks whether we need "-lsocket" to get "socket()", which is used
263 # by libpcap on some platforms - and, in effect, "gethostby*()" on
264 # most if not all platforms (so that it can use NIS or DNS or...
265 # to look up host names).
266 #
267 # Adapted from stuff in the AC_PATH_XTRA macro in "acspecific.m4" in
268 # GNU Autoconf 2.13; the comment came from there.
269 # Done by Guy Harris <guy@alum.mit.edu> on 2000-01-14.
270 #
271 # We use "connect" because that's what AC_PATH_XTRA did.
272 #
273 AC_DEFUN([AC_WIRESHARK_SOCKET_LIB_CHECK],
274 [
275     # lieder@skyler.mavd.honeywell.com says without -lsocket,
276     # socket/setsockopt and other routines are undefined under SCO ODT
277     # 2.0.  But -lsocket is broken on IRIX 5.2 (and is not necessary
278     # on later versions), says simon@lia.di.epfl.ch: it contains
279     # gethostby* variants that don't use the nameserver (or something).
280     # -lsocket must be given before -lnsl if both are needed.
281     # We assume that if connect needs -lnsl, so does gethostbyname.
282     AC_CHECK_FUNC(connect, ,
283       AC_CHECK_LIB(socket, connect, SOCKET_LIBS="-lsocket",
284                 AC_MSG_ERROR(Function 'socket' not found.), $NSL_LIBS))
285     AC_SUBST(SOCKET_LIBS)
286 ])
287
288 #
289 # AC_WIRESHARK_BREAKLOOP_TRY_LINK
290 #
291 AC_DEFUN([AC_WIRESHARK_PCAP_BREAKLOOP_TRY_LINK],
292 [
293   AC_LINK_IFELSE(
294   [
295       AC_LANG_SOURCE(
296       [[
297 #       include <pcap.h>
298         int main(void)
299         {
300           pcap_t  *pct = NULL;
301           pcap_breakloop(pct);
302           return 0;
303         }
304       ]])
305   ],
306   [
307     ws_breakloop_compiled=yes
308   ],
309   [
310     ws_breakloop_compiled=no
311   ])
312 ])
313
314
315
316 #
317 # AC_WIRESHARK_PCAP_CHECK
318 #
319 AC_DEFUN([AC_WIRESHARK_PCAP_CHECK],
320 [
321         if test -z "$pcap_dir"
322         then
323           # Pcap header checks
324           # XXX need to set a var AC_CHECK_HEADER(pcap.h,,)
325
326           #
327           # The user didn't specify a directory in which libpcap resides.
328           # First, look for a pcap-config script.
329           #
330           AC_PATH_PROG(PCAP_CONFIG, pcap-config)
331
332           if test -n "$PCAP_CONFIG" ; then
333             #
334             # Found it.
335             #
336             # Now check whether it's the libpcap 1.0 version, which
337             # put a space after "-L" - on some platforms, that doesn't
338             # work.
339             #
340             AC_MSG_CHECKING(for broken pcap-config)
341             case "`\"$PCAP_CONFIG\" --libs`" in
342
343             "-L "*)
344               #
345               # Space after -L.  Pretend pcap-config doesn't exist.
346               #
347               AC_MSG_RESULT(yes)
348               PCAP_CONFIG=""
349               ;;
350
351             *)
352               #
353               # No space after -L.
354               #
355               AC_MSG_RESULT(no)
356               ;;
357             esac
358           fi
359           if test -n "$PCAP_CONFIG" ; then
360             #
361             # Found it, and it's usable; use it to get the include flags
362             # for libpcap.
363             #
364             CFLAGS="$CFLAGS `\"$PCAP_CONFIG\" --cflags`"
365             CPPFLAGS="$CPPFLAGS `\"$PCAP_CONFIG\" --cflags`"
366           else
367             #
368             # Didn't find it; we have to look for libpcap ourselves.
369             # We assume that the current library search path will work,
370             # but we may have to look for the header in a "pcap"
371             # subdirectory of "/usr/include" or "/usr/local/include",
372             # as some systems apparently put "pcap.h" in a "pcap"
373             # subdirectory, and we also check "$prefix/include" - and
374             # "$prefix/include/pcap", in case $prefix is set to
375             # "/usr/include" or "/usr/local/include".
376             #
377             # XXX - should we just add "$prefix/include" to the include
378             # search path and "$prefix/lib" to the library search path?
379             #
380             AC_MSG_CHECKING(for extraneous pcap header directories)
381             found_pcap_dir=""
382             pcap_dir_list="/usr/include/pcap $prefix/include/pcap $prefix/include"
383             if test "x$ac_cv_enable_usr_local" = "xyes" ; then
384               pcap_dir_list="$pcap_dir_list /usr/local/include/pcap"
385             fi
386             for pcap_dir in $pcap_dir_list
387             do
388               if test -d $pcap_dir ; then
389                 if test x$pcap_dir != x/usr/include -a x$pcap_dir != x/usr/local/include ; then
390                     CFLAGS="$CFLAGS -I$pcap_dir"
391                     CPPFLAGS="$CPPFLAGS -I$pcap_dir"
392                 fi
393                 found_pcap_dir=" $found_pcap_dir -I$pcap_dir"
394                 break
395               fi
396             done
397
398             if test "$found_pcap_dir" != "" ; then
399               AC_MSG_RESULT(found --$found_pcap_dir added to CFLAGS)
400             else
401               AC_MSG_RESULT(not found)
402             fi
403           fi
404         else
405           #
406           # The user specified a directory in which libpcap resides,
407           # so add the "include" subdirectory of that directory to
408           # the include file search path and the "lib" subdirectory
409           # of that directory to the library search path.
410           #
411           # XXX - if there's also a libpcap in a directory that's
412           # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
413           # make us find the version in the specified directory,
414           # as the compiler and/or linker will search that other
415           # directory before it searches the specified directory.
416           #
417           CFLAGS="$CFLAGS -I$pcap_dir/include"
418           CPPFLAGS="$CPPFLAGS -I$pcap_dir/include"
419           AC_WIRESHARK_ADD_DASH_L(LDFLAGS, $pcap_dir/lib)
420         fi
421
422         # Pcap header check
423         AC_CHECK_HEADER(pcap.h,,
424             AC_MSG_ERROR([[Header file pcap.h not found; if you installed libpcap
425 from source, did you also do \"make install-incl\", and if you installed a
426 binary package of libpcap, is there also a developer's package of libpcap,
427 and did you also install that package?]]))
428
429         if test -n "$PCAP_CONFIG" ; then
430           #
431           # We have pcap-config; we assume that means we have libpcap
432           # installed and that pcap-config will tell us whatever
433           # libraries libpcap needs.
434           #
435           if test x$enable_static = xyes; then
436             PCAP_LIBS="`\"$PCAP_CONFIG\" --libs --static`"
437           else
438             PCAP_LIBS="`\"$PCAP_CONFIG\" --libs`"
439           fi
440           AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library])
441         else
442           #
443           # Check to see if we find "pcap_open_live" in "-lpcap".
444           # Also check for various additional libraries that libpcap might
445           # require.
446           #
447           AC_CHECK_LIB(pcap, pcap_open_live,
448             [
449               PCAP_LIBS=-lpcap
450               AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library])
451             ], [
452               ac_wireshark_extras_found=no
453               ac_save_LIBS="$LIBS"
454               for extras in "-lcfg -lodm" "-lpfring"
455               do
456                 AC_MSG_CHECKING([for pcap_open_live in -lpcap with $extras])
457                 LIBS="-lpcap $extras"
458                 #
459                 # XXX - can't we use AC_CHECK_LIB here?
460                 #
461                 AC_TRY_LINK(
462                     [
463 #       include <pcap.h>
464                     ],
465                     [
466         pcap_open_live(NULL, 0, 0, 0, NULL);
467                     ],
468                     [
469                         ac_wireshark_extras_found=yes
470                         AC_MSG_RESULT([yes])
471                         PCAP_LIBS="-lpcap $extras"
472                         AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library])
473                     ],
474                     [
475                         AC_MSG_RESULT([no])
476                     ])
477                 if test x$ac_wireshark_extras_found = xyes
478                 then
479                     break
480                 fi
481               done
482               if test x$ac_wireshark_extras_found = xno
483               then
484                 AC_MSG_ERROR([Can't link with library libpcap.])
485               fi
486               LIBS=$ac_save_LIBS
487             ], $SOCKET_LIBS $NSL_LIBS)
488         fi
489         AC_SUBST(PCAP_LIBS)
490
491         #
492         # Check whether various variables and functions are defined by
493         # libpcap.
494         #
495         ac_save_LIBS="$LIBS"
496         LIBS="$PCAP_LIBS $SOCKET_LIBS $NSL_LIBS $LIBS"
497         AC_CHECK_FUNCS(pcap_open_dead pcap_freecode)
498         #
499         # pcap_breakloop may be present in the library but not declared
500         # in the pcap.h header file.  If it's not declared in the header
501         # file, attempts to use it will get warnings, and, if we're
502         # building with warnings treated as errors, that warning will
503         # cause compilation to fail.
504         #
505         # We are therefore first testing whether the function is present
506         # and then, if we're compiling with warnings as errors, testing
507         # whether it is usable.  It is usable if it compiles without
508         # a -Wimplicit warning (the "compile with warnings as errors"
509         # option requires GCC). If it is not usable, we fail and tell
510         # the user that the pcap.h header needs to be updated.
511         #
512         # Ceteris paribus, this should only happen with Mac OS X 10.3[.x] which
513         # can have an up-to-date pcap library without the corresponding pcap
514         # header.
515         #
516         # However, it might also happen on some others OSes with some erroneous
517         # system manipulations where multiple versions of libcap might co-exist
518         # e.g. hand made symbolic link from libpcap.so -> libpcap.so.0.8 but
519         # having the pcap header version 0.7.
520         #
521         AC_MSG_CHECKING([whether pcap_breakloop is present])
522         ac_CFLAGS_saved="$CFLAGS"
523         AC_WIRESHARK_PCAP_BREAKLOOP_TRY_LINK
524         if test "x$ws_breakloop_compiled" = "xyes"; then
525           AC_MSG_RESULT(yes)
526           AC_DEFINE(HAVE_PCAP_BREAKLOOP, 1, [Define if pcap_breakloop is known])
527           if test "x$with_warnings_as_errors" = "xyes"; then
528             AC_MSG_CHECKING([whether pcap_breakloop is usable])
529             CFLAGS="$CFLAGS -Werror -Wimplicit"
530             AC_WIRESHARK_PCAP_BREAKLOOP_TRY_LINK
531             if test "x$ws_breakloop_compiled" = "xyes"; then
532               AC_MSG_RESULT(yes)
533             else
534               AC_MSG_RESULT(no)
535               AC_MSG_ERROR(
536 [Your pcap library is more recent than your pcap header.
537 As you are building with compiler warnings treated as errors, Wireshark
538 won't be able to use functions not declared in that header.
539 If you wish to build with compiler warnings treated as errors, You should
540 install a newer version of the header file.])
541             fi
542             CFLAGS="$ac_CFLAGS_saved"
543           fi
544         else
545           AC_MSG_RESULT(no)
546         fi
547
548         #
549         # Later versions of Mac OS X 10.3[.x] ship a pcap.h that
550         # doesn't define pcap_if_t but ship an 0.8[.x] libpcap,
551         # so the library has "pcap_findalldevs()", but pcap.h
552         # doesn't define "pcap_if_t" so you can't actually *use*
553         # "pcap_findalldevs()".
554         #
555         # That even appears to be true of systems shipped with
556         # 10.3.4, so it doesn't appear only to be a case of
557         # Software Update not updating header files.
558         #
559         # (You can work around this by installing the 0.8 header
560         # files.)
561         #
562         AC_CACHE_CHECK([whether pcap_findalldevs is present and usable],
563           [ac_cv_func_pcap_findalldevs],
564           [
565             AC_LINK_IFELSE(
566               [
567                 AC_LANG_SOURCE(
568                   [[
569                     #include <pcap.h>
570                     main()
571                     {
572                       pcap_if_t *devpointer;
573                       char errbuf[1];
574
575                       pcap_findalldevs(&devpointer, errbuf);
576                     }
577                   ]])
578               ],
579               [
580                 ac_cv_func_pcap_findalldevs=yes
581               ],
582               [
583                 ac_cv_func_pcap_findalldevs=no
584               ])
585           ])
586         #
587         # Don't check for other new routines that showed up after
588         # "pcap_findalldevs()" if we don't have a usable
589         # "pcap_findalldevs()", so we don't end up using them if the
590         # "pcap.h" is crufty and old and doesn't declare them.
591         #
592         if test $ac_cv_func_pcap_findalldevs = "yes" ; then
593           AC_DEFINE(HAVE_PCAP_FINDALLDEVS, 1,
594            [Define to 1 if you have the `pcap_findalldevs' function and a pcap.h that declares pcap_if_t.])
595           AC_CHECK_FUNCS(pcap_datalink_val_to_name pcap_datalink_name_to_val)
596           AC_CHECK_FUNCS(pcap_datalink_val_to_description)
597           AC_CHECK_FUNCS(pcap_list_datalinks pcap_set_datalink pcap_lib_version)
598           AC_CHECK_FUNCS(pcap_get_selectable_fd pcap_free_datalinks)
599           AC_CHECK_FUNCS(pcap_create bpf_image)
600         fi
601         LIBS="$ac_save_LIBS"
602 ])
603
604 AC_DEFUN([AC_WIRESHARK_PCAP_REMOTE_CHECK],
605 [
606     ac_save_LIBS="$LIBS"
607     LIBS="$PCAP_LIBS $SOCKET_LIBS $NSL_LIBS $LIBS"
608     AC_DEFINE(HAVE_REMOTE, 1, [Define to 1 to enable remote
609               capturing feature in WinPcap library])
610     AC_CHECK_FUNCS(pcap_open pcap_findalldevs_ex pcap_createsrcstr)
611     if test $ac_cv_func_pcap_open = "yes" -a \
612             $ac_cv_func_pcap_findalldevs_ex = "yes" -a \
613             $ac_cv_func_pcap_createsrcstr = "yes" ; then
614         AC_DEFINE(HAVE_PCAP_REMOTE, 1,
615             [Define to 1 if you have WinPcap remote capturing support and prefer to use these new API features.])
616     fi
617     AC_CHECK_FUNCS(pcap_setsampling)
618     LIBS="$ac_save_LIBS"
619 ])
620
621 #
622 # AC_WIRESHARK_ZLIB_CHECK
623 #
624 AC_DEFUN([AC_WIRESHARK_ZLIB_CHECK],
625 [
626         if test "x$zlib_dir" != "x"
627         then
628           #
629           # The user specified a directory in which zlib resides,
630           # so add the "include" subdirectory of that directory to
631           # the include file search path and the "lib" subdirectory
632           # of that directory to the library search path.
633           #
634           # XXX - if there's also a zlib in a directory that's
635           # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
636           # make us find the version in the specified directory,
637           # as the compiler and/or linker will search that other
638           # directory before it searches the specified directory.
639           #
640           wireshark_save_CFLAGS="$CFLAGS"
641           CFLAGS="$CFLAGS -I$zlib_dir/include"
642           wireshark_save_CPPFLAGS="$CPPFLAGS"
643           CPPFLAGS="$CPPFLAGS -I$zlib_dir/include"
644           wireshark_save_LIBS="$LIBS"
645           AC_WIRESHARK_ADD_DASH_L(LIBS, $zlib_dir/lib)
646         fi
647
648         #
649         # Make sure we have "zlib.h".  If we don't, it means we probably
650         # don't have zlib, so don't use it.
651         #
652         AC_CHECK_HEADER(zlib.h,,
653           [
654             if test "x$zlib_dir" != "x"
655             then
656               #
657               # The user used "--with-zlib=" to specify a directory
658               # containing zlib, but we didn't find the header file
659               # there; that either means they didn't specify the
660               # right directory or are confused about whether zlib
661               # is, in fact, installed.  Report the error and give up.
662               #
663               AC_MSG_ERROR([zlib header not found in directory specified in --with-zlib])
664             else
665               if test "x$want_zlib" = "xyes"
666               then
667                 #
668                 # The user tried to force us to use the library, but we
669                 # couldn't find the header file; report an error.
670                 #
671                 AC_MSG_ERROR(Header file zlib.h not found.)
672               else
673                 #
674                 # We couldn't find the header file; don't use the
675                 # library, as it's probably not present.
676                 #
677                 want_zlib=no
678               fi
679             fi
680           ])
681
682         if test "x$want_zlib" != "xno"
683         then
684                 #
685                 # Well, we at least have the zlib header file.
686                 # We link with zlib to support uncompression of
687                 # gzipped network traffic, e.g. in an HTTP request
688                 # or response body.
689                 #
690                 if test "x$zlib_dir" != "x"
691                 then
692                         #
693                         # Put the "-I" and "-L" flags for zlib at
694                         # the beginning of CFLAGS, CPPFLAGS, and
695                         # LIBS.
696                         #
697                         LIBS=""
698                         AC_WIRESHARK_ADD_DASH_L(LIBS, $zlib_dir/lib)
699                         LIBS="$LIBS -lz $wireshark_save_LIBS"
700                 else
701                         LIBS="-lz $LIBS"
702                 fi
703                 AC_DEFINE(HAVE_LIBZ, 1, [Define to use libz library])
704
705                 #
706                 # Check for "inflatePrime()" in zlib, which we need
707                 # in order to read compressed capture files.
708                 #
709                 AC_CHECK_FUNCS(inflatePrime)
710
711                 if test "x$ac_cv_func_inflatePrime" = "xyes" ; then
712                         #
713                         # Now check for "inflatePrime()" in zlib when
714                         # linking with the linker flags for GTK+
715                         # applications; people often grab XFree86 source
716                         # and build and install it on their systems,
717                         # and they appear sometimes to misconfigure
718                         # XFree86 so that, even on systems with zlib,
719                         # it assumes there is no zlib, so the XFree86
720                         # build process builds and installs its
721                         # own zlib in the X11 library directory.
722                         #
723                         # The zlib in at least some versions of XFree86
724                         # is an older version that may lack "inflatePrime()",
725                         # and that's the zlib with which Wireshark gets
726                         # linked, so the build of Wireshark fails.
727                         #
728                         AC_MSG_CHECKING([for inflatePrime missing when linking with X11])
729                         AC_TRY_LINK_FUNC(inflatePrime, AC_MSG_RESULT(no),
730                           [
731                             AC_MSG_RESULT(yes)
732                             AC_MSG_ERROR(old zlib found when linking with X11 - get rid of old zlib.)
733                           ])
734                 fi
735         else
736                 #
737                 # Restore the versions of CFLAGS, CPPFLAGS,
738                 # and LIBS before we added the "-with-zlib="
739                 # directory, as we didn't actually find
740                 # zlib there.
741                 #
742                 CFLAGS="$wireshark_save_CFLAGS"
743                 CPPFLAGS="$wireshark_save_CPPFLAGS"
744                 LIBS="$wireshark_save_LIBS"
745                 want_zlib=no
746         fi
747 ])
748
749 #
750 # AC_WIRESHARK_LIBLUA_CHECK
751 #
752 AC_DEFUN([AC_WIRESHARK_LIBLUA_CHECK],[
753
754         if test "x$lua_dir" != "x"
755         then
756                 #
757                 # The user specified a directory in which liblua resides,
758                 # so add the "include" subdirectory of that directory to
759                 # the include file search path and the "lib" subdirectory
760                 # of that directory to the library search path.
761                 #
762                 # XXX - if there's also a liblua in a directory that's
763                 # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
764                 # make us find the version in the specified directory,
765                 # as the compiler and/or linker will search that other
766                 # directory before it searches the specified directory.
767                 #
768                 wireshark_save_CFLAGS="$CFLAGS"
769                 CFLAGS="$CFLAGS -I$lua_dir/include"
770                 wireshark_save_CPPFLAGS="$CPPFLAGS"
771                 CPPFLAGS="$CPPFLAGS -I$lua_dir/include"
772                 wireshark_save_LIBS="$LIBS"
773                 LIBS="$LIBS -L$lua_dir/lib -llua -lm"
774                 wireshark_save_LDFLAGS="$LDFLAGS"
775                 LDFLAGS="$LDFLAGS -L$lua_dir/lib"
776         else
777                 #
778                 # The user specified no directory in which liblua resides,
779                 # so just add "-llua -lliblua" to the used libs.
780                 #
781                 wireshark_save_CFLAGS="$CFLAGS"
782                 wireshark_save_CPPFLAGS="$CPPFLAGS"
783                 wireshark_save_LDFLAGS="$LDFLAGS"
784                 wireshark_save_LIBS="$LIBS"
785                 LIBS="$LIBS -llua -lm"
786         fi
787
788         #
789         # Make sure we have "lua.h", "lualib.h" and "lauxlib.h".  If we don't, it means we probably
790         # don't have liblua, so don't use it.
791         #
792         AC_CHECK_HEADERS(lua.h lualib.h lauxlib.h,,
793         [
794                 AC_CHECK_HEADERS(lua5.1/lua.h lua5.1/lualib.h lua5.1/lauxlib.h,
795                 [
796                         if test "x$lua_dir" != "x"
797                         then
798                                 LUA_INCLUDES="-I$lua_dir/include/lua5.1"
799                         else
800                                 #
801                                 # The user didn't specify a directory in which liblua resides;
802                                 # we must look for the headers in a "lua5.1" subdirectory of
803                                 # "/usr/include", "/usr/local/include", or "$prefix/include"
804                                 # as some systems apparently put the headers in a "lua5.1"
805                                 # subdirectory.
806                                 AC_MSG_CHECKING(for extraneous lua header directories)
807                                 found_lua_dir=""
808                                 lua_dir_list="/usr/include/lua5.1 $prefix/include/lua5.1"
809                                 if test "x$ac_cv_enable_usr_local" = "xyes"
810                                 then
811                                         lua_dir_list="$lua_dir_list /usr/local/include/lua5.1"
812                                 fi
813                                 for lua_dir_ent in $lua_dir_list
814                                 do
815                                         if test -d $lua_dir_ent
816                                         then
817                                                 LUA_INCLUDES="-I$lua_dir_ent"
818                                                 found_lua_dir="$lua_dir_ent"
819                                                 break
820                                         fi
821                                 done
822
823                                 if test "x$found_lua_dir" != "x"
824                                 then
825                                         AC_MSG_RESULT(found -- $found_lua_dir)
826                                 else
827                                         AC_MSG_RESULT(not found)
828                                         #
829                                         # Restore the versions of CFLAGS, CPPFLAGS,
830                                         # LDFLAGS, and LIBS before we added the
831                                         # "--with-lua=" directory, as we didn't
832                                         # actually find lua there.
833                                         #
834                                         CFLAGS="$wireshark_save_CFLAGS"
835                                         CPPFLAGS="$wireshark_save_CPPFLAGS"
836                                         LDFLAGS="$wireshark_save_LDFLAGS"
837                                         LIBS="$wireshark_save_LIBS"
838                                         LUA_LIBS=""
839                                         if test "x$want_lua" = "xyes"
840                                         then
841                                                 # we found lua5.1/lua.h, but we don't know which include dir contains it
842                                                 AC_MSG_ERROR(Header file lua.h was found as lua5.1/lua.h but we can't locate the include directory. Please set the DIR for the --with-lua configure parameter.)
843                                         else
844                                                 #
845                                                 # We couldn't find the header file; don't use the
846                                                 # library, as it's probably not present.
847                                                 #
848                                                 want_lua=no
849                                         fi
850                                 fi
851                         fi
852                 ],
853                 [
854                         #
855                         # Restore the versions of CFLAGS, CPPFLAGS,
856                         # LDFLAGS, and LIBS before we added the
857                         # "--with-lua=" directory, as we didn't
858                         # actually find lua there.
859                         #
860                         CFLAGS="$wireshark_save_CFLAGS"
861                         CPPFLAGS="$wireshark_save_CPPFLAGS"
862                         LDFLAGS="$wireshark_save_LDFLAGS"
863                         LIBS="$wireshark_save_LIBS"
864                         LUA_LIBS=""
865                         if test "x$lua_dir" != "x"
866                         then
867                                 #
868                                 # The user used "--with-lua=" to specify a directory
869                                 # containing liblua, but we didn't find the header file
870                                 # there; that either means they didn't specify the
871                                 # right directory or are confused about whether liblua
872                                 # is, in fact, installed.  Report the error and give up.
873                                 #
874                                 AC_MSG_ERROR([liblua header not found in directory specified in --with-lua])
875                         else
876                                 if test "x$want_lua" = "xyes"
877                                 then
878                                         #
879                                         # The user tried to force us to use the library, but we
880                                         # couldn't find the header file; report an error.
881                                         #
882                                         AC_MSG_ERROR(Header file lua.h not found.)
883                                 else
884                                         #
885                                         # We couldn't find the header file; don't use the
886                                         # library, as it's probably not present.
887                                         #
888                                         want_lua=no
889                                 fi
890                         fi
891                 ])
892         ])
893
894         if test "x$want_lua" != "xno"
895         then
896                 #
897                 # Well, we at least have the lua header file.
898                 #
899                 # let's check if the libs are there
900                 #
901
902                 # At least on Suse 9.3 systems, liblualib needs linking
903                 # against libm.
904                 LIBS="$LIBS $LUA_LIBS -lm"
905
906                 AC_CHECK_LIB(lua, luaL_register,
907                 [
908                     #
909                     #  Lua 5.1 found
910                     #
911                         if test "x$lua_dir" != "x"
912                         then
913                                 #
914                                 # Put the "-I" and "-L" flags for lua at
915                                 # the beginning of CFLAGS, CPPFLAGS,
916                                 # LDFLAGS, and LIBS.
917                                 #
918                                 LUA_LIBS="-L$lua_dir/lib -llua -lm"
919                                 LUA_INCLUDES="-I$lua_dir/include"
920                         else
921                                 LUA_LIBS="-llua -lm"
922                                 LUA_INCLUDES=""
923                         fi
924                         AC_DEFINE(HAVE_LUA_5_1, 1, [Define to use Lua 5.1])
925                         want_lua=yes
926
927                 ],[
928                         #
929                         # We could not find the libs, maybe we have version number in the lib name
930                         #
931
932                         LIBS="$wireshark_save_LIBS -llua5.1 -lm"
933
934                         AC_CHECK_LIB(lua5.1, luaL_register,
935                         [
936                             #
937                             #  Lua 5.1 found
938                             #
939                             LUA_LIBS=" -llua5.1 -lm"
940                             AC_DEFINE(HAVE_LUA_5_1, 1, [Define to use Lua 5.1])
941                             want_lua=yes
942                         ],[
943                                 #
944                                 # Restore the versions of CFLAGS, CPPFLAGS,
945                                 # LDFLAGS, and LIBS before we added the
946                                 # "--with-lua=" directory, as we didn't
947                                 # actually find lua there.
948                                 #
949                                 CFLAGS="$wireshark_save_CFLAGS"
950                                 CPPFLAGS="$wireshark_save_CPPFLAGS"
951                                 LDFLAGS="$wireshark_save_LDFLAGS"
952                                 LIBS="$wireshark_save_LIBS"
953                                 LUA_LIBS=""
954                                 # User requested --with-lua but it isn't available
955                                 if test "x$want_lua" = "xyes"
956                                 then
957                                         AC_MSG_ERROR(Linking with liblua failed.)
958                                 fi
959                                 want_lua=no
960                         ])
961                 ])
962
963         CFLAGS="$wireshark_save_CFLAGS"
964         CPPFLAGS="$wireshark_save_CPPFLAGS"
965         LDFLAGS="$wireshark_save_LDFLAGS"
966         LIBS="$wireshark_save_LIBS"
967         AC_SUBST(LUA_LIBS)
968         AC_SUBST(LUA_INCLUDES)
969
970         fi
971 ])
972
973 #
974 # AC_WIRESHARK_LIBPORTAUDIO_CHECK
975 #
976 AC_DEFUN([AC_WIRESHARK_LIBPORTAUDIO_CHECK],[
977
978         if test "x$portaudio_dir" != "x"
979         then
980                 #
981                 # The user specified a directory in which libportaudio
982                 # resides, so add the "include" subdirectory of that directory to
983                 # the include file search path and the "lib" subdirectory
984                 # of that directory to the library search path.
985                 #
986                 # XXX - if there's also a libportaudio in a directory that's
987                 # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
988                 # make us find the version in the specified directory,
989                 # as the compiler and/or linker will search that other
990                 # directory before it searches the specified directory.
991                 #
992                 wireshark_save_CFLAGS="$CFLAGS"
993                 CFLAGS="$CFLAGS -I$portaudio_dir/include"
994                 wireshark_save_CPPFLAGS="$CPPFLAGS"
995                 CPPFLAGS="$CPPFLAGS -I$portaudio_dir/include"
996                 wireshark_save_LIBS="$LIBS"
997                 LIBS="$LIBS -L$portaudio_dir/lib -lportaudio"
998                 wireshark_save_LDFLAGS="$LDFLAGS"
999                 LDFLAGS="$LDFLAGS -L$portaudio_dir/lib"
1000         else
1001                 #
1002                 # The user specified no directory in which libportaudio resides,
1003                 # so just add "-lportaudio" to the used libs.
1004                 #
1005                 wireshark_save_CFLAGS="$CFLAGS"
1006                 wireshark_save_CPPFLAGS="$CPPFLAGS"
1007                 wireshark_save_LDFLAGS="$LDFLAGS"
1008                 wireshark_save_LIBS="$LIBS"
1009                 LIBS="$LIBS -lportaudio"
1010         fi
1011
1012         #
1013         # Make sure we have "portaudio.h".  If we don't, it means we probably
1014         # don't have libportaudio, so don't use it.
1015         #
1016         AC_CHECK_HEADERS(portaudio.h,,
1017         [
1018                 if test "x$portaudio_dir" != "x"
1019                 then
1020                         #
1021                         # The user used "--with-portaudio=" to specify a directory
1022                         # containing libportaudio, but we didn't find the header file
1023                         # there; that either means they didn't specify the
1024                         # right directory or are confused about whether libportaudio
1025                         # is, in fact, installed.  Report the error and give up.
1026                         #
1027                         AC_MSG_ERROR([libportaudio header not found in directory specified in --with-portaudio])
1028                 else
1029                         CFLAGS="$wireshark_save_CFLAGS"
1030                         CPPFLAGS="$wireshark_save_CPPFLAGS"
1031                         LDFLAGS="$wireshark_save_LDFLAGS"
1032                         LIBS="$wireshark_save_LIBS"
1033                         PORTAUDIO_LIBS=""
1034                         if test "x$want_portaudio" = "xyes"
1035                         then
1036                                 #
1037                                 # The user tried to force us to use the library, but we
1038                                 # couldn't find the header file; report an error.
1039                                 #
1040                                 AC_MSG_ERROR(Header file portaudio.h not found.)
1041                         else
1042                                 #
1043                                 # We couldn't find the header file; don't use the
1044                                 # library, as it's probably not present.
1045                                 #
1046                                 want_portaudio=no
1047                         fi
1048                 fi
1049         ])
1050
1051         #
1052         # Check whether we have the right version of portaudio
1053         #
1054         if test "x$want_portaudio" != "xno"
1055         then
1056                 AC_CHECK_TYPE(PortAudioStream,
1057                 AC_DEFINE(PORTAUDIO_API_1, 1, [Define if we are using version of of the Portaudio library API]),
1058                 ,
1059                 [#include <portaudio.h>])
1060         fi
1061
1062         if test "x$want_portaudio" != "xno"
1063         then
1064                 #
1065                 # Well, we at least have the portaudio header file.
1066                 #
1067                 # let's check if the libs are there
1068                 #
1069
1070                 AC_CHECK_LIB(portaudio, Pa_Initialize,
1071                 [
1072                         if test "x$portaudio_dir" != "x"
1073                         then
1074                                 #
1075                                 # Put the "-I" and "-L" flags for portaudio at
1076                                 # the beginning of CFLAGS, CPPFLAGS,
1077                                 # LDFLAGS, and LIBS.
1078                                 #
1079                                 PORTAUDIO_LIBS="-L$portaudio_dir/lib -lportaudio"
1080                                 PORTAUDIO_INCLUDES="-I$portaudio_dir/include"
1081                         else
1082                                 PORTAUDIO_LIBS="-lportaudio"
1083                                 PORTAUDIO_INCLUDES=""
1084                         fi
1085                         AC_DEFINE(HAVE_LIBPORTAUDIO, 1, [Define to use libportaudio library])
1086                         want_portaudio=yes
1087                 ],[
1088                         #
1089                         # Restore the versions of CFLAGS, CPPFLAGS,
1090                         # LDFLAGS, and LIBS before we added the
1091                         # "--with-portaudio=" directory, as we didn't
1092                         # actually find portaudio there.
1093                         #
1094                         CFLAGS="$wireshark_save_CFLAGS"
1095                         CPPFLAGS="$wireshark_save_CPPFLAGS"
1096                         LDFLAGS="$wireshark_save_LDFLAGS"
1097                         LIBS="$wireshark_save_LIBS"
1098                         PORTAUDIO_LIBS=""
1099                         # User requested --with-portaudio but it isn't available
1100                         if test "x$want_portaudio" = "xyes"
1101                         then
1102                                 AC_MSG_ERROR(Linking with libportaudio failed.)
1103                         fi
1104                         want_portaudio=no
1105                 ])
1106
1107         CFLAGS="$wireshark_save_CFLAGS"
1108         CPPFLAGS="$wireshark_save_CPPFLAGS"
1109         LDFLAGS="$wireshark_save_LDFLAGS"
1110         LIBS="$wireshark_save_LIBS"
1111         AC_SUBST(PORTAUDIO_LIBS)
1112         AC_SUBST(PORTAUDIO_INCLUDES)
1113
1114         fi
1115 ])
1116
1117 #
1118 # AC_WIRESHARK_RPM_CHECK
1119 # Looks for the rpm program, and checks to see if we can redefine "_topdir".
1120 #
1121 AC_DEFUN([AC_WIRESHARK_RPM_CHECK],
1122 [
1123         AC_CHECK_PROG(ac_cv_wireshark_have_rpm, rpm, "yes", "no")
1124         if test "x$ac_cv_wireshark_have_rpm" = "xyes"; then
1125                 rpm --define '_topdir /tmp' > /dev/null 2>&1
1126                 AC_MSG_CHECKING(to see if we can redefine _topdir)
1127                 if test $? -eq 0 ; then
1128                         AC_MSG_RESULT(yes)
1129                         HAVE_RPM=yes
1130                 else
1131                         AC_MSG_RESULT(no.  You'll have to build packages manually.)
1132                         HAVE_RPM=no
1133                 fi
1134         fi
1135 ])
1136
1137 #
1138 # AC_WIRESHARK_GNU_SED_CHECK
1139 # Checks if GNU sed is the first sed in PATH.
1140 #
1141 AC_DEFUN([AC_WIRESHARK_GNU_SED_CHECK],
1142 [
1143         AC_MSG_CHECKING(for GNU sed as first sed in PATH)
1144         if  ( sh -c "sed --version" </dev/null 2> /dev/null | grep "GNU sed" 2>&1 > /dev/null ) ;  then
1145                 AC_MSG_RESULT(yes)
1146                 HAVE_GNU_SED=yes
1147         else
1148                 AC_MSG_RESULT(no)
1149                 HAVE_GNU_SED=no
1150         fi
1151 ])
1152
1153 #
1154 # AC_WIRESHARK_C_ARES_CHECK
1155 #
1156 AC_DEFUN([AC_WIRESHARK_C_ARES_CHECK],
1157 [
1158         want_c_ares=defaultyes
1159
1160         if test "x$want_c_ares" = "xdefaultyes"; then
1161                 want_c_ares=yes
1162                 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
1163                         withval=/usr/local
1164                         if test -d "$withval"; then
1165                                 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1166                         fi
1167                 fi
1168         fi
1169
1170         if test "x$want_c_ares" = "xyes"; then
1171                 AC_CHECK_LIB(cares, ares_init,
1172                   [
1173                     C_ARES_LIBS=-lcares
1174                 AC_DEFINE(HAVE_C_ARES, 1, [Define to use c-ares library])
1175                 have_good_c_ares=yes
1176                   ],, $SOCKET_LIBS $NSL_LIBS
1177                 )
1178         else
1179                 AC_MSG_RESULT(not required)
1180         fi
1181 ])
1182
1183
1184 #
1185 # AC_WIRESHARK_ADNS_CHECK
1186 #
1187 AC_DEFUN([AC_WIRESHARK_ADNS_CHECK],
1188 [
1189         want_adns=defaultyes
1190
1191         if test "x$want_adns" = "xdefaultyes"; then
1192                 want_adns=yes
1193                 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
1194                         withval=/usr/local
1195                         if test -d "$withval"; then
1196                                 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1197                         fi
1198                 fi
1199         fi
1200
1201         if test "x$want_adns" = "xyes"; then
1202                 AC_CHECK_LIB(adns, adns_init,
1203                   [
1204                     ADNS_LIBS=-ladns
1205                 AC_DEFINE(HAVE_GNU_ADNS, 1, [Define to use GNU ADNS library])
1206                 have_good_adns=yes
1207                   ],, $SOCKET_LIBS $NSL_LIBS
1208                 )
1209         else
1210                 AC_MSG_RESULT(not required)
1211         fi
1212 ])
1213
1214
1215 #
1216 # AC_WIRESHARK_LIBCAP_CHECK
1217 #
1218 AC_DEFUN([AC_WIRESHARK_LIBCAP_CHECK],
1219 [
1220         want_libcap=defaultyes
1221
1222         if test "x$want_libcap" = "xdefaultyes"; then
1223                 want_libcap=yes
1224                 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
1225                         withval=/usr/local
1226                         if test -d "$withval"; then
1227                                 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1228                         fi
1229                 fi
1230         fi
1231
1232         if test "x$want_libcap" = "xyes"; then
1233                 AC_CHECK_LIB(cap, cap_set_flag,
1234                   [
1235                     LIBCAP_LIBS=-lcap
1236                 AC_DEFINE(HAVE_LIBCAP, 1, [Define to use the libcap library])
1237                 have_good_libcap=yes
1238                   ],,
1239                 )
1240         else
1241                 AC_MSG_RESULT(not required)
1242         fi
1243 ])
1244
1245
1246 #
1247 # AC_WIRESHARK_KRB5_CHECK
1248 #
1249 AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
1250 [
1251         wireshark_save_CFLAGS="$CFLAGS"
1252         wireshark_save_CPPFLAGS="$CPPFLAGS"
1253         if test "x$krb5_dir" != "x"
1254         then
1255           #
1256           # The user specified a directory in which kerberos resides,
1257           # so add the "include" subdirectory of that directory to
1258           # the include file search path and the "lib" subdirectory
1259           # of that directory to the library search path.
1260           #
1261           # XXX - if there's also a kerberos in a directory that's
1262           # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
1263           # make us find the version in the specified directory,
1264           # as the compiler and/or linker will search that other
1265           # directory before it searches the specified directory.
1266           #
1267           CFLAGS="$CFLAGS -I$krb5_dir/include"
1268           CPPFLAGS="$CPPFLAGS -I$krb5_dir/include"
1269           ac_heimdal_version=`grep heimdal $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*heimdal.*$/HEIMDAL/'`
1270           # MIT Kerberos moved krb5.h to krb5/krb5.h starting with release 1.5
1271           ac_mit_version_olddir=`grep 'Massachusetts Institute of Technology' $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*Massachusetts Institute of Technology.*$/MIT/'`
1272           ac_mit_version_newdir=`grep 'Massachusetts Institute of Technology' $krb5_dir/include/krb5/krb5.h | head -n 1 | sed 's/^.*Massachusetts Institute of Technology.*$/MIT/'`
1273           ac_krb5_version="$ac_heimdal_version$ac_mit_version_olddir$ac_mit_version_newdir"
1274           if test "x$ac_krb5_version" = "xHEIMDAL"
1275           then
1276               KRB5_LIBS="-L$krb5_dir/lib -lkrb5 -lasn1 $SSL_LIBS -lroken -lcrypt"
1277           else
1278               KRB5_LIBS="-L$krb5_dir/lib -lkrb5 -lk5crypto -lcom_err"
1279           fi
1280           if test "x$ac_krb5_version" = "xMIT"
1281           then
1282             AC_DEFINE(HAVE_MIT_KERBEROS, 1, [Define to use MIT kerberos])
1283           fi
1284         else
1285           AC_PATH_PROG(KRB5_CONFIG, krb5-config)
1286           if test -x "$KRB5_CONFIG"
1287           then
1288             KRB5_FLAGS=`"$KRB5_CONFIG" --cflags`
1289             KRB5_LIBS=`"$KRB5_CONFIG" --libs`
1290             CFLAGS="$CFLAGS $KRB5_FLAGS"
1291             CPPFLAGS="$CPPFLAGS $KRB5_FLAGS"
1292             #
1293             # If -lcrypto is in KRB5_FLAGS, we require it to build
1294             # with Heimdal/MIT.  We don't want to built with it by
1295             # default, due to annoying license incompatibilities
1296             # between the OpenSSL license and the GPL, so:
1297             #
1298             #   if SSL_LIBS is set to a non-empty string, we
1299             #   remove -lcrypto from KRB5_LIBS and replace
1300             #   it with SSL_LIBS;
1301             #
1302             #   if SSL_LIBS is not set to a non-empty string
1303             #   we fail with an appropriate error message.
1304             #
1305             case "$KRB5_LIBS" in
1306             *-lcrypto*)
1307                 if test ! -z "$SSL_LIBS"
1308                 then
1309                     KRB5_LIBS=`echo $KRB5_LIBS | sed 's/-lcrypto//'`
1310                     KRB5_LIBS="$KRB5_LIBS $SSL_LIBS"
1311                 else
1312                     AC_MSG_ERROR([Kerberos library requires -lcrypto but --with-ssl not specified])
1313                 fi
1314                 ;;
1315             esac
1316             ac_krb5_version=`"$KRB5_CONFIG" --version | head -n 1 | sed -e 's/^.*heimdal.*$/HEIMDAL/' -e 's/^Kerberos .*$/MIT/' -e 's/^Solaris Kerberos .*$/MIT/'`
1317           fi
1318         fi
1319
1320         #
1321         # Make sure we have "krb5.h".  If we don't, it means we probably
1322         # don't have kerberos, so don't use it.
1323         #
1324         AC_CHECK_HEADER(krb5.h,,
1325           [
1326             if test "x$krb5_dir" != "x"
1327             then
1328               #
1329               # The user used "--with-krb5=" to specify a directory
1330               # containing kerberos, but we didn't find the header file
1331               # there; that either means they didn't specify the
1332               # right directory or are confused about whether kerberos
1333               # is, in fact, installed.  Report the error and give up.
1334               #
1335               AC_MSG_ERROR([kerberos header not found in directory specified in --with-krb5])
1336             else
1337               if test "x$want_krb5" = "xyes"
1338               then
1339                 #
1340                 # The user tried to force us to use the library, but we
1341                 # couldn't find the header file; report an error.
1342                 #
1343                 AC_MSG_ERROR(Header file krb5.h not found.)
1344               else
1345                 #
1346                 # We couldn't find the header file; don't use the
1347                 # library, as it's probably not present.
1348                 #
1349                 want_krb5=no
1350                 AC_MSG_RESULT(No Heimdal or MIT header found - disabling dissection for some kerberos data in packet decoding)
1351               fi
1352             fi
1353           ])
1354
1355         if test "x$want_krb5" != "xno"
1356         then
1357             #
1358             # Well, we at least have the krb5 header file.
1359             # Check whether this is Heimdal or MIT.
1360             #
1361             AC_MSG_CHECKING(whether the Kerberos library is Heimdal or MIT)
1362             if test "x$ac_krb5_version" = "xHEIMDAL" -o "x$ac_krb5_version" = "xMIT"
1363             then
1364                 #
1365                 # Yes.
1366                 # Check whether we have krb5_kt_resolve - and whether
1367                 # we need to link with -lresolv when linking with
1368                 # the Kerberos library.
1369                 #
1370                 AC_MSG_RESULT($ac_krb5_version)
1371                 wireshark_save_LIBS="$LIBS"
1372                 found_krb5_kt_resolve=no
1373                 for extras in "" "-lresolv"
1374                 do
1375                     LIBS="$KRB5_LIBS $extras"
1376                     if test -z "$extras"
1377                     then
1378                         AC_MSG_CHECKING([whether $ac_krb5_version includes krb5_kt_resolve])
1379                     else
1380                         AC_MSG_CHECKING([whether $ac_krb5_version includes krb5_kt_resolve (linking with $extras)])
1381                     fi
1382                     AC_TRY_LINK(
1383                         [
1384                         ],
1385                         [
1386                             krb5_kt_resolve();
1387                         ],
1388                         [
1389                             #
1390                             # We found "krb5_kt_resolve()", and required
1391                             # the libraries in extras as well.
1392                             #
1393                             AC_MSG_RESULT(yes)
1394                             KRB5_LIBS="$LIBS"
1395                             AC_DEFINE(HAVE_KERBEROS, 1, [Define to use kerberos])
1396                             if test "x$ac_krb5_version" = "xHEIMDAL"
1397                             then
1398                                 AC_DEFINE(HAVE_HEIMDAL_KERBEROS, 1, [Define to use heimdal kerberos])
1399                             elif test "x$ac_krb5_version" = "xMIT"
1400                             then
1401                                 AC_DEFINE(HAVE_MIT_KERBEROS, 1, [Define to use MIT kerberos])
1402                             fi
1403                             found_krb5_kt_resolve=yes
1404                             break
1405                         ],
1406                         [
1407                             AC_MSG_RESULT(no)
1408                         ])
1409                 done
1410                 if test "$found_krb5_kt_resolve" = no
1411                 then
1412                     #
1413                     # We didn't find "krb5_kt_resolve()" in the
1414                     # Kerberos library, even when we tried linking
1415                     # with -lresolv; we can't link with kerberos.
1416                     #
1417                     if test "x$want_krb5" = "xyes"
1418                     then
1419                         #
1420                         # The user tried to force us to use the library,
1421                         # but we can't do so; report an error.
1422                         #
1423                         AC_MSG_ERROR(Usable $ac_krb5_version not found)
1424                     else
1425                         #
1426                         # Restore the versions of CFLAGS and CPPFLAGS
1427                         # from before we added the flags for Kerberos.
1428                         #
1429                         AC_MSG_RESULT(Usable $ac_krb5_version not found - disabling dissection for some kerberos data in packet decoding)
1430                         CFLAGS="$wireshark_save_CFLAGS"
1431                         CPPFLAGS="$wireshark_save_CPPFLAGS"
1432                         KRB5_LIBS=""
1433                         want_krb5=no
1434                     fi
1435                 else
1436                     #
1437                     # We can link with Kerberos; see whether krb5.h
1438                     # defines KEYTYPE_ARCFOUR_56 (where "defines" means
1439                     # "as a #define or as an enum member).
1440                     #
1441                     AC_MSG_CHECKING([whether krb5.h defines KEYTYPE_ARCFOUR_56])
1442                     AC_COMPILE_IFELSE(
1443                       [
1444                         AC_LANG_SOURCE(
1445                           [[
1446                             #include <krb5.h>
1447                             #include <stdio.h>
1448
1449                             main()
1450                             {
1451                               printf("%u\n", KEYTYPE_ARCFOUR_56);
1452                             }
1453                           ]])
1454                       ],
1455                       [
1456                         AC_MSG_RESULT(yes)
1457                         AC_DEFINE(HAVE_KEYTYPE_ARCFOUR_56, 1, [Define if krb5.h defines KEYTYPE_ARCFOUR_56])
1458                       ],
1459                       [
1460                         AC_MSG_RESULT(no)
1461                       ])
1462                 fi
1463                 LIBS="$wireshark_save_LIBS"
1464             else
1465                 #
1466                 # It's not Heimdal or MIT.
1467                 #
1468                 AC_MSG_RESULT(no)
1469                 if test "x$want_krb5" = "xyes"
1470                 then
1471                     #
1472                     # The user tried to force us to use the library,
1473                     # but we can't do so; report an error.
1474                     #
1475                     AC_MSG_ERROR(Kerberos not found)
1476                 else
1477                     #
1478                     # Restore the versions of CFLAGS and CPPFLAGS
1479                     # from before we added the flags for Kerberos.
1480                     #
1481                     AC_MSG_RESULT(Kerberos not found - disabling dissection for some kerberos data in packet decoding)
1482                     CFLAGS="$wireshark_save_CFLAGS"
1483                     CPPFLAGS="$wireshark_save_CPPFLAGS"
1484                     KRB5_LIBS=""
1485                     want_krb5=no
1486                 fi
1487             fi
1488         else
1489             #
1490             # The user asked us not to use Kerberos, or they didn't
1491             # say whether they wanted us to use it but we found
1492             # that we couldn't.
1493             #
1494             # Restore the versions of CFLAGS and CPPFLAGS
1495             # from before we added the flags for Kerberos.
1496             #
1497             CFLAGS="$wireshark_save_CFLAGS"
1498             CPPFLAGS="$wireshark_save_CPPFLAGS"
1499             KRB5_LIBS=""
1500             want_krb5=no
1501         fi
1502         AC_SUBST(KRB5_LIBS)
1503 ])
1504
1505 #
1506 # AC_WIRESHARK_GEOIP_CHECK
1507 #
1508 AC_DEFUN([AC_WIRESHARK_GEOIP_CHECK],
1509 [
1510         want_geoip=defaultyes
1511
1512         if test "x$want_geoip" = "xdefaultyes"; then
1513                 want_geoip=yes
1514                 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
1515                         withval=/usr/local
1516                         if test -d "$withval"; then
1517                                 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1518                         fi
1519                 fi
1520         fi
1521
1522         if test "x$want_geoip" = "xyes"; then
1523                 AC_CHECK_LIB(GeoIP, GeoIP_new,
1524                   [
1525                     GEOIP_LIBS=-lGeoIP
1526                 AC_DEFINE(HAVE_GEOIP, 1, [Define to use GeoIP library])
1527                 have_good_geoip=yes
1528                   ],,
1529                 )
1530                 if test "x$have_good_geoip" = "xyes"; then
1531                         AC_CHECK_LIB(GeoIP, GeoIP_country_name_by_ipnum_v6,
1532                           [
1533                                 AC_DEFINE(HAVE_GEOIP_V6, 1, [Define if GeoIP supports IPv6 (GeoIP 1.4.5 and later)])
1534                           ],,
1535                         )
1536                 fi
1537         else
1538                 AC_MSG_RESULT(not required)
1539         fi
1540 ])
1541
1542 #AC_WIRESHARK_LDFLAGS_CHECK
1543 #
1544 # $1 : ldflag(s) to test
1545 #
1546 # The macro first determines if the compiler supports "-Wl,{option}" to
1547 # pass options through to the linker. Then it attempts to compile with
1548 # the defined ldflags. The defined flags are added to LDFLAGS only if
1549 # the compilation succeeds.
1550 #
1551 AC_DEFUN([AC_WIRESHARK_LDFLAGS_CHECK],
1552 [GCC_OPTION="$1"
1553 AC_MSG_CHECKING(whether we can add $GCC_OPTION to LDFLAGS)
1554 if test "x$ac_supports_W_linker_passthrough" = "xyes"; then
1555   LDFLAGS_saved="$LDFLAGS"
1556   LDFLAGS="$LDFLAGS $GCC_OPTION"
1557   AC_LINK_IFELSE([
1558     AC_LANG_SOURCE([[
1559                 main() { return; }
1560                   ]])],
1561                   [
1562                     AC_MSG_RESULT(yes)
1563                   ],
1564                   [
1565                     AC_MSG_RESULT(no)
1566                     LDFLAGS="$LDFLAGS_saved"
1567                   ])
1568 else
1569   AC_MSG_RESULT(no)
1570 fi
1571 ])
1572
1573 #
1574 # AC_WIRESHARK_GCC_CFLAGS_CHECK
1575 #
1576 # $1 : cflags to test
1577 #
1578 # The macro first determines if the compiler supports GCC-style flags.
1579 # Then it attempts to compile with the defined cflags.  The defined
1580 # flags are added to CFLAGS only if the compilation succeeds.
1581 #
1582 # We do this because not all such options are necessarily supported by
1583 # the version of the particular compiler we're using.
1584 #
1585 # NOTE: clang, by default, only warns about unknown -W options.
1586 # If we're using clang, we turn on -Werror=unknown-warning-option
1587 # so that it fails if we pass it a -W option it doesn't know about
1588 # but doesn't fail for any other warning that the test program might
1589 # produce.
1590 #
1591 AC_DEFUN([AC_WIRESHARK_GCC_CFLAGS_CHECK],
1592 [GCC_OPTION="$1"
1593 AC_MSG_CHECKING(whether we can add $GCC_OPTION to CFLAGS)
1594 if test "x$ac_supports_gcc_flags" = "xyes" ; then
1595   CFLAGS_saved="$CFLAGS"
1596   CFLAGS="$CFLAGS $GCC_OPTION"
1597   if test "x$CC" = "xclang" ; then
1598     CFLAGS="$CFLAGS -Werror=unknown-warning-option"
1599   fi
1600   AC_COMPILE_IFELSE([
1601     AC_LANG_SOURCE([[
1602                       int foo;
1603                   ]])],
1604                   [
1605                     AC_MSG_RESULT(yes)
1606                   ],
1607                   [
1608                     AC_MSG_RESULT(no)
1609                     CFLAGS="$CFLAGS_saved"
1610                   ])
1611 else
1612   AC_MSG_RESULT(no)
1613 fi
1614 ])
1615
1616 #
1617 # AC_WIRESHARK_OSX_INTEGRATION_CHECK
1618 #
1619 # Checks for the presence of OS X integration functions in the GTK+ framework
1620 # or as a separate library.
1621 #
1622 # http://sourceforge.net/apps/trac/gtk-osx/wiki/Integrate
1623 #
1624 # http://live.gnome.org/GTK%2B/OSX/Integration
1625 #    for the old Carbon-based integration functions
1626 #
1627 # http://gtk-osx.sourceforge.net/ige-mac-integration/
1628 #    for the new Cocoa-based integration functions
1629 #
1630 AC_DEFUN([AC_WIRESHARK_OSX_INTEGRATION_CHECK],
1631 [
1632         ac_save_CFLAGS="$CFLAGS"
1633         ac_save_LIBS="$LIBS"
1634         CFLAGS="$CFLAGS $GTK_CFLAGS"
1635         LIBS="$GTK_LIBS $LIBS"
1636
1637         #
1638         # Check for the new integration functions in a -ligemacintegration
1639         # library.
1640         #
1641         AC_CHECK_LIB(igemacintegration, gtk_osxapplication_set_menu_bar,
1642         [
1643                 AC_DEFINE(HAVE_GTKOSXAPPLICATION, 1,
1644                         [Define to 1 if -ligemacintegration includes the GtkOSXApplication Integration functions.])
1645                 have_ige_mac=yes
1646                 # We don't want gtk stuff in LIBS (which is reset below) so
1647                 # manually set GTK_LIBS (which is more appropriate)
1648                 GTK_LIBS="$GTK_LIBS -ligemacintegration"
1649         ])
1650
1651         if test x$have_ige_mac = x
1652         then
1653                 #
1654                 # Not found - check for the old integration functions in
1655                 # the Gtk framework.
1656                 #
1657                 AC_CHECK_LIB(Gtk, ige_mac_menu_set_menu_bar,
1658                 [
1659                         AC_DEFINE(HAVE_IGE_MAC_INTEGRATION, 1,
1660                                 [Define to 1 if the the Gtk+ framework or a separate library includes the Imendio IGE Mac OS X Integration functions.])
1661                         have_ige_mac=yes
1662                         # We don't want gtk stuff in LIBS (which is reset below) so
1663                         # manually set GTK_LIBS (which is more appropriate)
1664                         GTK_LIBS="$GTK_LIBS -lGtk"
1665                 ])
1666         fi
1667
1668         if test x$have_ige_mac = x
1669         then
1670                 #
1671                 # Not found - check for the old integration functions in
1672                 # a -ligemacintegration library.
1673                 #
1674                 AC_CHECK_LIB(igemacintegration, ige_mac_menu_set_menu_bar,
1675                 [
1676                         AC_DEFINE(HAVE_IGE_MAC_INTEGRATION, 1,
1677                                 [Define to 1 if the the Gtk+ framework or a separate library includes the Imendio IGE Mac OS X Integration functions.])
1678                         have_ige_mac=yes
1679                         # We don't want gtk stuff in LIBS (which is reset below) so
1680                         # manually set GTK_LIBS (which is more appropriate)
1681                         GTK_LIBS="$GTK_LIBS -ligemacintegration"
1682                 ])
1683         fi
1684         CFLAGS="$ac_save_CFLAGS"
1685         LIBS="$ac_save_LIBS"
1686 ])
1687
1688 #
1689 # AC_WIRESHARK_PYTHON_CHECK
1690 #
1691 # Check whether python devel package is present
1692 #
1693 AC_DEFUN([AC_WIRESHARK_PYTHON_CHECK],
1694   [
1695     #
1696     # Checking whether we have a python devel environment available
1697     #
1698 #  AC_CACHE_CHECK([checking python devel package], ac_cv_wireshark_python_devel,
1699 #    [
1700     AC_CHECK_PROG([ac_ws_python_config], python-config, "yes", "no")
1701     if test "x$ac_ws_python_config" = "xno"; then
1702       ac_cv_wireshark_python_devel=no
1703         if test "x$want_python" = "xyes"
1704         then
1705             #
1706             # The user tried to force us to use Python, but we
1707             # couldn't find the python-config tool; report an error.
1708             #
1709             AC_MSG_ERROR("python-config not found")
1710         fi
1711         #
1712         # Set want_python to no, so we report that we aren't using
1713         # the Python interpreter.
1714         #
1715         want_python=no
1716     else
1717       AC_MSG_CHECKING([python devel])
1718       ac_save_ws_cflags=$CFLAGS
1719       ac_save_ws_libs=$LIBS
1720       CFLAGS=$(python-config --includes)
1721       LIBS=$(python-config --ldflags)
1722       AC_COMPILE_IFELSE(
1723         [
1724           AC_LANG_PROGRAM(
1725             [[#include <Python.h>]],
1726             [[Py_Initialiaze();]]
1727           )
1728         ],
1729         [
1730           #
1731           # Compilation successful, we have python devel available
1732           #
1733           ac_cv_wireshark_python_devel=yes
1734           PY_LIBS=$LIBS
1735           PY_CFLAGS=$CFLAGS
1736           AC_SUBST(PY_LIBS)
1737           AC_SUBST(PY_CFLAGS)
1738           CFLAGS="$ac_save_ws_cflags"
1739           LIBS="$ac_save_ws_libs"
1740           AC_DEFINE(HAVE_PYTHON, 1, [Define if python devel package available])
1741           AC_MSG_RESULT([yes])
1742         ],
1743         [
1744           #
1745           # Compilation unsuccessful, python devel not available
1746           #
1747           ac_cv_wireshark_python_devel=no
1748           CFLAGS=$ac_save_ws_cflags
1749           LIBS=$ac_save_ws_libs
1750           if test "x$want_python" = "xyes"
1751           then
1752             #
1753             # The user tried to force us to use Python, but we
1754             # couldn't compile the test program; report an error.
1755             #
1756             AC_MSG_ERROR("Python test program failed compilation")
1757           fi
1758           AC_MSG_RESULT([no])
1759           #
1760           # Set want_python to no, so we report that we aren't using
1761           # the Python interpreter.
1762           #
1763           want_python=no
1764         ])
1765     fi
1766 #    ])
1767 ])