Put -D and -I flags into CPPFLAGS rather than into CFLAGS; that should
[metze/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                                 CPPFLAGS="-I/usr/local/v6/include $CPPFLAGS"])
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                                 CPPFLAGS="-DINET6 $CPPFLAGS"])
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                                 CPPFLAGS="-DINET6 $CPPFLAGS"])
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; CPPFLAGS="-DINET6 $CPPFLAGS"])
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                                 CPPFLAGS="-DINET6 $CPPFLAGS"])
190                         ;;
191                 linux)
192                         if test -d /usr/inet6; then
193                                 v6type=$i
194                                 v6lib=inet6
195                                 v6libdir=/usr/inet6
196                                 CPPFLAGS="-DINET6 $CPPFLAGS"
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; CPPFLAGS="-DINET6 $CPPFLAGS"])
208                         ;;
209                 solaris8)
210                         if test "`uname -s`" = "SunOS" && test "`uname -r`" = "5.8"; then
211                                 v6type=$i
212                                 v6lib=inet6
213                                 [CPPFLAGS="-DINET6 -DSOLARIS8_INET6 $CPPFLAGS"]
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             CPPFLAGS="$CPPFLAGS `\"$PCAP_CONFIG\" --cflags`"
365           else
366             #
367             # Didn't find it; we have to look for libpcap ourselves.
368             # We assume that the current library search path will work,
369             # but we may have to look for the header in a "pcap"
370             # subdirectory of "/usr/include" or "/usr/local/include",
371             # as some systems apparently put "pcap.h" in a "pcap"
372             # subdirectory, and we also check "$prefix/include" - and
373             # "$prefix/include/pcap", in case $prefix is set to
374             # "/usr/include" or "/usr/local/include".
375             #
376             # XXX - should we just add "$prefix/include" to the include
377             # search path and "$prefix/lib" to the library search path?
378             #
379             AC_MSG_CHECKING(for extraneous pcap header directories)
380             found_pcap_dir=""
381             pcap_dir_list="/usr/include/pcap $prefix/include/pcap $prefix/include"
382             if test "x$ac_cv_enable_usr_local" = "xyes" ; then
383               pcap_dir_list="$pcap_dir_list /usr/local/include/pcap"
384             fi
385             for pcap_dir in $pcap_dir_list
386             do
387               if test -d $pcap_dir ; then
388                 if test x$pcap_dir != x/usr/include -a x$pcap_dir != x/usr/local/include ; then
389                     CPPFLAGS="$CPPFLAGS -I$pcap_dir"
390                 fi
391                 found_pcap_dir=" $found_pcap_dir -I$pcap_dir"
392                 break
393               fi
394             done
395
396             if test "$found_pcap_dir" != "" ; then
397               AC_MSG_RESULT(found --$found_pcap_dir added to CFLAGS)
398             else
399               AC_MSG_RESULT(not found)
400             fi
401           fi
402         else
403           #
404           # The user specified a directory in which libpcap resides,
405           # so add the "include" subdirectory of that directory to
406           # the include file search path and the "lib" subdirectory
407           # of that directory to the library search path.
408           #
409           # XXX - if there's also a libpcap in a directory that's
410           # already in CPPFLAGS or LDFLAGS, this won't make us find
411           # the version in the specified directory, as the compiler
412           # and/or linker will search that other directory before it
413           # searches the specified directory.
414           #
415           CPPFLAGS="$CPPFLAGS -I$pcap_dir/include"
416           AC_WIRESHARK_ADD_DASH_L(LDFLAGS, $pcap_dir/lib)
417         fi
418
419         # Pcap header check
420         AC_CHECK_HEADER(pcap.h,,
421             AC_MSG_ERROR([[Header file pcap.h not found; if you installed libpcap
422 from source, did you also do \"make install-incl\", and if you installed a
423 binary package of libpcap, is there also a developer's package of libpcap,
424 and did you also install that package?]]))
425
426         if test -n "$PCAP_CONFIG" ; then
427           #
428           # We have pcap-config; we assume that means we have libpcap
429           # installed and that pcap-config will tell us whatever
430           # libraries libpcap needs.
431           #
432           if test x$enable_static = xyes; then
433             PCAP_LIBS="`\"$PCAP_CONFIG\" --libs --static`"
434           else
435             PCAP_LIBS="`\"$PCAP_CONFIG\" --libs`"
436           fi
437           AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library])
438         else
439           #
440           # Check to see if we find "pcap_open_live" in "-lpcap".
441           # Also check for various additional libraries that libpcap might
442           # require.
443           #
444           AC_CHECK_LIB(pcap, pcap_open_live,
445             [
446               PCAP_LIBS=-lpcap
447               AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library])
448             ], [
449               ac_wireshark_extras_found=no
450               ac_save_LIBS="$LIBS"
451               for extras in "-lcfg -lodm" "-lpfring"
452               do
453                 AC_MSG_CHECKING([for pcap_open_live in -lpcap with $extras])
454                 LIBS="-lpcap $extras"
455                 #
456                 # XXX - can't we use AC_CHECK_LIB here?
457                 #
458                 AC_TRY_LINK(
459                     [
460 #       include <pcap.h>
461                     ],
462                     [
463         pcap_open_live(NULL, 0, 0, 0, NULL);
464                     ],
465                     [
466                         ac_wireshark_extras_found=yes
467                         AC_MSG_RESULT([yes])
468                         PCAP_LIBS="-lpcap $extras"
469                         AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library])
470                     ],
471                     [
472                         AC_MSG_RESULT([no])
473                     ])
474                 if test x$ac_wireshark_extras_found = xyes
475                 then
476                     break
477                 fi
478               done
479               if test x$ac_wireshark_extras_found = xno
480               then
481                 AC_MSG_ERROR([Can't link with library libpcap.])
482               fi
483               LIBS=$ac_save_LIBS
484             ], $SOCKET_LIBS $NSL_LIBS)
485         fi
486         AC_SUBST(PCAP_LIBS)
487
488         #
489         # Check whether various variables and functions are defined by
490         # libpcap.
491         #
492         ac_save_LIBS="$LIBS"
493         LIBS="$PCAP_LIBS $SOCKET_LIBS $NSL_LIBS $LIBS"
494         AC_CHECK_FUNCS(pcap_open_dead pcap_freecode)
495         #
496         # pcap_breakloop may be present in the library but not declared
497         # in the pcap.h header file.  If it's not declared in the header
498         # file, attempts to use it will get warnings, and, if we're
499         # building with warnings treated as errors, that warning will
500         # cause compilation to fail.
501         #
502         # We are therefore first testing whether the function is present
503         # and then, if we're compiling with warnings as errors, testing
504         # whether it is usable.  It is usable if it compiles without
505         # a -Wimplicit warning (the "compile with warnings as errors"
506         # option requires GCC). If it is not usable, we fail and tell
507         # the user that the pcap.h header needs to be updated.
508         #
509         # Ceteris paribus, this should only happen with Mac OS X 10.3[.x] which
510         # can have an up-to-date pcap library without the corresponding pcap
511         # header.
512         #
513         # However, it might also happen on some others OSes with some erroneous
514         # system manipulations where multiple versions of libcap might co-exist
515         # e.g. hand made symbolic link from libpcap.so -> libpcap.so.0.8 but
516         # having the pcap header version 0.7.
517         #
518         AC_MSG_CHECKING([whether pcap_breakloop is present])
519         ac_CFLAGS_saved="$CFLAGS"
520         AC_WIRESHARK_PCAP_BREAKLOOP_TRY_LINK
521         if test "x$ws_breakloop_compiled" = "xyes"; then
522           AC_MSG_RESULT(yes)
523           AC_DEFINE(HAVE_PCAP_BREAKLOOP, 1, [Define if pcap_breakloop is known])
524           if test "x$with_warnings_as_errors" = "xyes"; then
525             AC_MSG_CHECKING([whether pcap_breakloop is usable])
526             CFLAGS="$CFLAGS -Werror -Wimplicit"
527             AC_WIRESHARK_PCAP_BREAKLOOP_TRY_LINK
528             if test "x$ws_breakloop_compiled" = "xyes"; then
529               AC_MSG_RESULT(yes)
530             else
531               AC_MSG_RESULT(no)
532               AC_MSG_ERROR(
533 [Your pcap library is more recent than your pcap header.
534 As you are building with compiler warnings treated as errors, Wireshark
535 won't be able to use functions not declared in that header.
536 If you wish to build with compiler warnings treated as errors, You should
537 install a newer version of the header file.])
538             fi
539             CFLAGS="$ac_CFLAGS_saved"
540           fi
541         else
542           AC_MSG_RESULT(no)
543         fi
544
545         #
546         # Later versions of Mac OS X 10.3[.x] ship a pcap.h that
547         # doesn't define pcap_if_t but ship an 0.8[.x] libpcap,
548         # so the library has "pcap_findalldevs()", but pcap.h
549         # doesn't define "pcap_if_t" so you can't actually *use*
550         # "pcap_findalldevs()".
551         #
552         # That even appears to be true of systems shipped with
553         # 10.3.4, so it doesn't appear only to be a case of
554         # Software Update not updating header files.
555         #
556         # (You can work around this by installing the 0.8 header
557         # files.)
558         #
559         AC_CACHE_CHECK([whether pcap_findalldevs is present and usable],
560           [ac_cv_func_pcap_findalldevs],
561           [
562             AC_LINK_IFELSE(
563               [
564                 AC_LANG_SOURCE(
565                   [[
566                     #include <pcap.h>
567                     main()
568                     {
569                       pcap_if_t *devpointer;
570                       char errbuf[1];
571
572                       pcap_findalldevs(&devpointer, errbuf);
573                     }
574                   ]])
575               ],
576               [
577                 ac_cv_func_pcap_findalldevs=yes
578               ],
579               [
580                 ac_cv_func_pcap_findalldevs=no
581               ])
582           ])
583         #
584         # Don't check for other new routines that showed up after
585         # "pcap_findalldevs()" if we don't have a usable
586         # "pcap_findalldevs()", so we don't end up using them if the
587         # "pcap.h" is crufty and old and doesn't declare them.
588         #
589         if test $ac_cv_func_pcap_findalldevs = "yes" ; then
590           AC_DEFINE(HAVE_PCAP_FINDALLDEVS, 1,
591            [Define to 1 if you have the `pcap_findalldevs' function and a pcap.h that declares pcap_if_t.])
592           AC_CHECK_FUNCS(pcap_datalink_val_to_name pcap_datalink_name_to_val)
593           AC_CHECK_FUNCS(pcap_datalink_val_to_description)
594           AC_CHECK_FUNCS(pcap_list_datalinks pcap_set_datalink pcap_lib_version)
595           AC_CHECK_FUNCS(pcap_get_selectable_fd pcap_free_datalinks)
596           AC_CHECK_FUNCS(pcap_create bpf_image)
597         fi
598         LIBS="$ac_save_LIBS"
599 ])
600
601 AC_DEFUN([AC_WIRESHARK_PCAP_REMOTE_CHECK],
602 [
603     ac_save_LIBS="$LIBS"
604     LIBS="$PCAP_LIBS $SOCKET_LIBS $NSL_LIBS $LIBS"
605     AC_DEFINE(HAVE_REMOTE, 1, [Define to 1 to enable remote
606               capturing feature in WinPcap library])
607     AC_CHECK_FUNCS(pcap_open pcap_findalldevs_ex pcap_createsrcstr)
608     if test $ac_cv_func_pcap_open = "yes" -a \
609             $ac_cv_func_pcap_findalldevs_ex = "yes" -a \
610             $ac_cv_func_pcap_createsrcstr = "yes" ; then
611         AC_DEFINE(HAVE_PCAP_REMOTE, 1,
612             [Define to 1 if you have WinPcap remote capturing support and prefer to use these new API features.])
613     fi
614     AC_CHECK_FUNCS(pcap_setsampling)
615     LIBS="$ac_save_LIBS"
616 ])
617
618 #
619 # AC_WIRESHARK_ZLIB_CHECK
620 #
621 AC_DEFUN([AC_WIRESHARK_ZLIB_CHECK],
622 [
623         if test "x$zlib_dir" != "x"
624         then
625           #
626           # The user specified a directory in which zlib resides,
627           # so add the "include" subdirectory of that directory to
628           # the include file search path and the "lib" subdirectory
629           # of that directory to the library search path.
630           #
631           # XXX - if there's also a zlib in a directory that's
632           # already in CPPFLAGS or LDFLAGS, this won't make us find
633           # the version in the specified directory, as the compiler
634           # and/or linker will search that other directory before it
635           # searches the specified directory.
636           #
637           wireshark_save_CPPFLAGS="$CPPFLAGS"
638           CPPFLAGS="$CPPFLAGS -I$zlib_dir/include"
639           wireshark_save_LIBS="$LIBS"
640           AC_WIRESHARK_ADD_DASH_L(LIBS, $zlib_dir/lib)
641         fi
642
643         #
644         # Make sure we have "zlib.h".  If we don't, it means we probably
645         # don't have zlib, so don't use it.
646         #
647         AC_CHECK_HEADER(zlib.h,,
648           [
649             if test "x$zlib_dir" != "x"
650             then
651               #
652               # The user used "--with-zlib=" to specify a directory
653               # containing zlib, but we didn't find the header file
654               # there; that either means they didn't specify the
655               # right directory or are confused about whether zlib
656               # is, in fact, installed.  Report the error and give up.
657               #
658               AC_MSG_ERROR([zlib header not found in directory specified in --with-zlib])
659             else
660               if test "x$want_zlib" = "xyes"
661               then
662                 #
663                 # The user tried to force us to use the library, but we
664                 # couldn't find the header file; report an error.
665                 #
666                 AC_MSG_ERROR(Header file zlib.h not found.)
667               else
668                 #
669                 # We couldn't find the header file; don't use the
670                 # library, as it's probably not present.
671                 #
672                 want_zlib=no
673               fi
674             fi
675           ])
676
677         if test "x$want_zlib" != "xno"
678         then
679                 #
680                 # Well, we at least have the zlib header file.
681                 # We link with zlib to support uncompression of
682                 # gzipped network traffic, e.g. in an HTTP request
683                 # or response body.
684                 #
685                 if test "x$zlib_dir" != "x"
686                 then
687                         #
688                         # Put the "-L" flags for zlib at the beginning
689                         # of LIBS.
690                         #
691                         LIBS=""
692                         AC_WIRESHARK_ADD_DASH_L(LIBS, $zlib_dir/lib)
693                         LIBS="$LIBS -lz $wireshark_save_LIBS"
694                 else
695                         LIBS="-lz $LIBS"
696                 fi
697                 AC_DEFINE(HAVE_LIBZ, 1, [Define to use libz library])
698
699                 #
700                 # Check for "inflatePrime()" in zlib, which we need
701                 # in order to read compressed capture files.
702                 #
703                 AC_CHECK_FUNCS(inflatePrime)
704
705                 if test "x$ac_cv_func_inflatePrime" = "xyes" ; then
706                         #
707                         # Now check for "inflatePrime()" in zlib when
708                         # linking with the linker flags for GTK+
709                         # applications; people often grab XFree86 source
710                         # and build and install it on their systems,
711                         # and they appear sometimes to misconfigure
712                         # XFree86 so that, even on systems with zlib,
713                         # it assumes there is no zlib, so the XFree86
714                         # build process builds and installs its
715                         # own zlib in the X11 library directory.
716                         #
717                         # The zlib in at least some versions of XFree86
718                         # is an older version that may lack "inflatePrime()",
719                         # and that's the zlib with which Wireshark gets
720                         # linked, so the build of Wireshark fails.
721                         #
722                         AC_MSG_CHECKING([for inflatePrime missing when linking with X11])
723                         AC_TRY_LINK_FUNC(inflatePrime, AC_MSG_RESULT(no),
724                           [
725                             AC_MSG_RESULT(yes)
726                             AC_MSG_ERROR(old zlib found when linking with X11 - get rid of old zlib.)
727                           ])
728                 fi
729         else
730                 #
731                 # Restore the versions of CPPFLAGS and LIBS before
732                 # we added the "-with-zlib=" directory, as we didn't
733                 # actually find zlib there.
734                 #
735                 CPPFLAGS="$wireshark_save_CPPFLAGS"
736                 LIBS="$wireshark_save_LIBS"
737                 want_zlib=no
738         fi
739 ])
740
741 #
742 # AC_WIRESHARK_LIBLUA_CHECK
743 #
744 AC_DEFUN([AC_WIRESHARK_LIBLUA_CHECK],[
745
746         if test "x$lua_dir" != "x"
747         then
748                 #
749                 # The user specified a directory in which liblua resides,
750                 # so add the "include" subdirectory of that directory to
751                 # the include file search path and the "lib" subdirectory
752                 # of that directory to the library search path.
753                 #
754                 # XXX - if there's also a liblua in a directory that's
755                 # already in CPPFLAGS or LDFLAGS, this won't make us find
756                 # the version in the specified directory, as the compiler
757                 # and/or linker will search that other directory before it
758                 # searches the specified directory.
759                 #
760                 wireshark_save_CPPFLAGS="$CPPFLAGS"
761                 CPPFLAGS="$CPPFLAGS -I$lua_dir/include"
762                 wireshark_save_LIBS="$LIBS"
763                 LIBS="$LIBS -L$lua_dir/lib -llua -lm"
764                 wireshark_save_LDFLAGS="$LDFLAGS"
765                 LDFLAGS="$LDFLAGS -L$lua_dir/lib"
766         else
767                 #
768                 # The user specified no directory in which liblua resides,
769                 # so just add "-llua -lliblua" to the used libs.
770                 #
771                 wireshark_save_CPPFLAGS="$CPPFLAGS"
772                 wireshark_save_LDFLAGS="$LDFLAGS"
773                 wireshark_save_LIBS="$LIBS"
774                 LIBS="$LIBS -llua -lm"
775         fi
776
777         #
778         # Make sure we have "lua.h", "lualib.h" and "lauxlib.h".  If we don't, it means we probably
779         # don't have liblua, so don't use it.
780         #
781         AC_CHECK_HEADERS(lua.h lualib.h lauxlib.h,,
782         [
783                 AC_CHECK_HEADERS(lua5.1/lua.h lua5.1/lualib.h lua5.1/lauxlib.h,
784                 [
785                         if test "x$lua_dir" != "x"
786                         then
787                                 LUA_INCLUDES="-I$lua_dir/include/lua5.1"
788                         else
789                                 #
790                                 # The user didn't specify a directory in which liblua resides;
791                                 # we must look for the headers in a "lua5.1" subdirectory of
792                                 # "/usr/include", "/usr/local/include", or "$prefix/include"
793                                 # as some systems apparently put the headers in a "lua5.1"
794                                 # subdirectory.
795                                 AC_MSG_CHECKING(for extraneous lua header directories)
796                                 found_lua_dir=""
797                                 lua_dir_list="/usr/include/lua5.1 $prefix/include/lua5.1"
798                                 if test "x$ac_cv_enable_usr_local" = "xyes"
799                                 then
800                                         lua_dir_list="$lua_dir_list /usr/local/include/lua5.1"
801                                 fi
802                                 for lua_dir_ent in $lua_dir_list
803                                 do
804                                         if test -d $lua_dir_ent
805                                         then
806                                                 LUA_INCLUDES="-I$lua_dir_ent"
807                                                 found_lua_dir="$lua_dir_ent"
808                                                 break
809                                         fi
810                                 done
811
812                                 if test "x$found_lua_dir" != "x"
813                                 then
814                                         AC_MSG_RESULT(found -- $found_lua_dir)
815                                 else
816                                         AC_MSG_RESULT(not found)
817                                         #
818                                         # Restore the versions of CPPFLAGS,
819                                         # LDFLAGS, and LIBS before we added the
820                                         # "--with-lua=" directory, as we didn't
821                                         # actually find lua there.
822                                         #
823                                         CPPFLAGS="$wireshark_save_CPPFLAGS"
824                                         LDFLAGS="$wireshark_save_LDFLAGS"
825                                         LIBS="$wireshark_save_LIBS"
826                                         LUA_LIBS=""
827                                         if test "x$want_lua" = "xyes"
828                                         then
829                                                 # we found lua5.1/lua.h, but we don't know which include dir contains it
830                                                 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.)
831                                         else
832                                                 #
833                                                 # We couldn't find the header file; don't use the
834                                                 # library, as it's probably not present.
835                                                 #
836                                                 want_lua=no
837                                         fi
838                                 fi
839                         fi
840                 ],
841                 [
842                         #
843                         # Restore the versions of CPPFLAGS, LDFLAGS,
844                         # and LIBS before we added the "--with-lua="
845                         # directory, as we didn't actually find lua
846                         # there.
847                         #
848                         CPPFLAGS="$wireshark_save_CPPFLAGS"
849                         LDFLAGS="$wireshark_save_LDFLAGS"
850                         LIBS="$wireshark_save_LIBS"
851                         LUA_LIBS=""
852                         if test "x$lua_dir" != "x"
853                         then
854                                 #
855                                 # The user used "--with-lua=" to specify a directory
856                                 # containing liblua, but we didn't find the header file
857                                 # there; that either means they didn't specify the
858                                 # right directory or are confused about whether liblua
859                                 # is, in fact, installed.  Report the error and give up.
860                                 #
861                                 AC_MSG_ERROR([liblua header not found in directory specified in --with-lua])
862                         else
863                                 if test "x$want_lua" = "xyes"
864                                 then
865                                         #
866                                         # The user tried to force us to use the library, but we
867                                         # couldn't find the header file; report an error.
868                                         #
869                                         AC_MSG_ERROR(Header file lua.h not found.)
870                                 else
871                                         #
872                                         # We couldn't find the header file; don't use the
873                                         # library, as it's probably not present.
874                                         #
875                                         want_lua=no
876                                 fi
877                         fi
878                 ])
879         ])
880
881         if test "x$want_lua" != "xno"
882         then
883                 #
884                 # Well, we at least have the lua header file.
885                 #
886                 # let's check if the libs are there
887                 #
888
889                 # At least on Suse 9.3 systems, liblualib needs linking
890                 # against libm.
891                 LIBS="$LIBS $LUA_LIBS -lm"
892
893                 AC_CHECK_LIB(lua, luaL_register,
894                 [
895                     #
896                     #  Lua 5.1 found
897                     #
898                         if test "x$lua_dir" != "x"
899                         then
900                                 #
901                                 # Put the "-I" and "-L" flags for lua at
902                                 # the beginning of CFLAGS, CPPFLAGS,
903                                 # LDFLAGS, and LIBS.
904                                 #
905                                 LUA_LIBS="-L$lua_dir/lib -llua -lm"
906                                 LUA_INCLUDES="-I$lua_dir/include"
907                         else
908                                 LUA_LIBS="-llua -lm"
909                                 LUA_INCLUDES=""
910                         fi
911                         AC_DEFINE(HAVE_LUA_5_1, 1, [Define to use Lua 5.1])
912                         want_lua=yes
913
914                 ],[
915                         #
916                         # We could not find the libs, maybe we have version number in the lib name
917                         #
918
919                         LIBS="$wireshark_save_LIBS -llua5.1 -lm"
920
921                         AC_CHECK_LIB(lua5.1, luaL_register,
922                         [
923                             #
924                             #  Lua 5.1 found
925                             #
926                             LUA_LIBS=" -llua5.1 -lm"
927                             AC_DEFINE(HAVE_LUA_5_1, 1, [Define to use Lua 5.1])
928                             want_lua=yes
929                         ],[
930                                 #
931                                 # Restore the versions of CPPFLAGS, LDFLAGS,
932                                 # and LIBS before we added the "--with-lua="
933                                 # directory, as we didn't actually find lua
934                                 # there.
935                                 #
936                                 CPPFLAGS="$wireshark_save_CPPFLAGS"
937                                 LDFLAGS="$wireshark_save_LDFLAGS"
938                                 LIBS="$wireshark_save_LIBS"
939                                 LUA_LIBS=""
940                                 # User requested --with-lua but it isn't available
941                                 if test "x$want_lua" = "xyes"
942                                 then
943                                         AC_MSG_ERROR(Linking with liblua failed.)
944                                 fi
945                                 want_lua=no
946                         ])
947                 ])
948
949         CPPFLAGS="$wireshark_save_CPPFLAGS"
950         LDFLAGS="$wireshark_save_LDFLAGS"
951         LIBS="$wireshark_save_LIBS"
952         AC_SUBST(LUA_LIBS)
953         AC_SUBST(LUA_INCLUDES)
954
955         fi
956 ])
957
958 #
959 # AC_WIRESHARK_LIBPORTAUDIO_CHECK
960 #
961 AC_DEFUN([AC_WIRESHARK_LIBPORTAUDIO_CHECK],[
962
963         if test "x$portaudio_dir" != "x"
964         then
965                 #
966                 # The user specified a directory in which libportaudio
967                 # resides, so add the "include" subdirectory of that directory to
968                 # the include file search path and the "lib" subdirectory
969                 # of that directory to the library search path.
970                 #
971                 # XXX - if there's also a libportaudio in a directory that's
972                 # already in CPPFLAGS or LDFLAGS, this won't make us find
973                 # the version in the specified directory, as the compiler
974                 # and/or linker will search that other directory before it
975                 # searches the specified directory.
976                 #
977                 wireshark_save_CPPFLAGS="$CPPFLAGS"
978                 CPPFLAGS="$CPPFLAGS -I$portaudio_dir/include"
979                 wireshark_save_LIBS="$LIBS"
980                 LIBS="$LIBS -L$portaudio_dir/lib -lportaudio"
981                 wireshark_save_LDFLAGS="$LDFLAGS"
982                 LDFLAGS="$LDFLAGS -L$portaudio_dir/lib"
983         else
984                 #
985                 # The user specified no directory in which libportaudio resides,
986                 # so just add "-lportaudio" to the used libs.
987                 #
988                 wireshark_save_CPPFLAGS="$CPPFLAGS"
989                 wireshark_save_LDFLAGS="$LDFLAGS"
990                 wireshark_save_LIBS="$LIBS"
991                 LIBS="$LIBS -lportaudio"
992         fi
993
994         #
995         # Make sure we have "portaudio.h".  If we don't, it means we probably
996         # don't have libportaudio, so don't use it.
997         #
998         AC_CHECK_HEADERS(portaudio.h,,
999         [
1000                 if test "x$portaudio_dir" != "x"
1001                 then
1002                         #
1003                         # The user used "--with-portaudio=" to specify a directory
1004                         # containing libportaudio, but we didn't find the header file
1005                         # there; that either means they didn't specify the
1006                         # right directory or are confused about whether libportaudio
1007                         # is, in fact, installed.  Report the error and give up.
1008                         #
1009                         AC_MSG_ERROR([libportaudio header not found in directory specified in --with-portaudio])
1010                 else
1011                         CPPFLAGS="$wireshark_save_CPPFLAGS"
1012                         LDFLAGS="$wireshark_save_LDFLAGS"
1013                         LIBS="$wireshark_save_LIBS"
1014                         PORTAUDIO_LIBS=""
1015                         if test "x$want_portaudio" = "xyes"
1016                         then
1017                                 #
1018                                 # The user tried to force us to use the library, but we
1019                                 # couldn't find the header file; report an error.
1020                                 #
1021                                 AC_MSG_ERROR(Header file portaudio.h not found.)
1022                         else
1023                                 #
1024                                 # We couldn't find the header file; don't use the
1025                                 # library, as it's probably not present.
1026                                 #
1027                                 want_portaudio=no
1028                         fi
1029                 fi
1030         ])
1031
1032         #
1033         # Check whether we have the right version of portaudio
1034         #
1035         if test "x$want_portaudio" != "xno"
1036         then
1037                 AC_CHECK_TYPE(PortAudioStream,
1038                 AC_DEFINE(PORTAUDIO_API_1, 1, [Define if we are using version of of the Portaudio library API]),
1039                 ,
1040                 [#include <portaudio.h>])
1041         fi
1042
1043         if test "x$want_portaudio" != "xno"
1044         then
1045                 #
1046                 # Well, we at least have the portaudio header file.
1047                 #
1048                 # let's check if the libs are there
1049                 #
1050
1051                 AC_CHECK_LIB(portaudio, Pa_Initialize,
1052                 [
1053                         if test "x$portaudio_dir" != "x"
1054                         then
1055                                 #
1056                                 # Put the "-I" and "-L" flags for portaudio at
1057                                 # the beginning of CFLAGS, CPPFLAGS,
1058                                 # LDFLAGS, and LIBS.
1059                                 #
1060                                 PORTAUDIO_LIBS="-L$portaudio_dir/lib -lportaudio"
1061                                 PORTAUDIO_INCLUDES="-I$portaudio_dir/include"
1062                         else
1063                                 PORTAUDIO_LIBS="-lportaudio"
1064                                 PORTAUDIO_INCLUDES=""
1065                         fi
1066                         AC_DEFINE(HAVE_LIBPORTAUDIO, 1, [Define to use libportaudio library])
1067                         want_portaudio=yes
1068                 ],[
1069                         #
1070                         # Restore the versions of CPPFLAGS, LDFLAGS, and
1071                         # LIBS before we added the "--with-portaudio="
1072                         # directory, as we didn't actually find portaudio
1073                         # there.
1074                         #
1075                         CPPFLAGS="$wireshark_save_CPPFLAGS"
1076                         LDFLAGS="$wireshark_save_LDFLAGS"
1077                         LIBS="$wireshark_save_LIBS"
1078                         PORTAUDIO_LIBS=""
1079                         # User requested --with-portaudio but it isn't available
1080                         if test "x$want_portaudio" = "xyes"
1081                         then
1082                                 AC_MSG_ERROR(Linking with libportaudio failed.)
1083                         fi
1084                         want_portaudio=no
1085                 ])
1086
1087         CPPFLAGS="$wireshark_save_CPPFLAGS"
1088         LDFLAGS="$wireshark_save_LDFLAGS"
1089         LIBS="$wireshark_save_LIBS"
1090         AC_SUBST(PORTAUDIO_LIBS)
1091         AC_SUBST(PORTAUDIO_INCLUDES)
1092
1093         fi
1094 ])
1095
1096 #
1097 # AC_WIRESHARK_RPM_CHECK
1098 # Looks for the rpm program, and checks to see if we can redefine "_topdir".
1099 #
1100 AC_DEFUN([AC_WIRESHARK_RPM_CHECK],
1101 [
1102         AC_CHECK_PROG(ac_cv_wireshark_have_rpm, rpm, "yes", "no")
1103         if test "x$ac_cv_wireshark_have_rpm" = "xyes"; then
1104                 rpm --define '_topdir /tmp' > /dev/null 2>&1
1105                 AC_MSG_CHECKING(to see if we can redefine _topdir)
1106                 if test $? -eq 0 ; then
1107                         AC_MSG_RESULT(yes)
1108                         HAVE_RPM=yes
1109                 else
1110                         AC_MSG_RESULT(no.  You'll have to build packages manually.)
1111                         HAVE_RPM=no
1112                 fi
1113         fi
1114 ])
1115
1116 #
1117 # AC_WIRESHARK_GNU_SED_CHECK
1118 # Checks if GNU sed is the first sed in PATH.
1119 #
1120 AC_DEFUN([AC_WIRESHARK_GNU_SED_CHECK],
1121 [
1122         AC_MSG_CHECKING(for GNU sed as first sed in PATH)
1123         if  ( sh -c "sed --version" </dev/null 2> /dev/null | grep "GNU sed" 2>&1 > /dev/null ) ;  then
1124                 AC_MSG_RESULT(yes)
1125                 HAVE_GNU_SED=yes
1126         else
1127                 AC_MSG_RESULT(no)
1128                 HAVE_GNU_SED=no
1129         fi
1130 ])
1131
1132 #
1133 # AC_WIRESHARK_C_ARES_CHECK
1134 #
1135 AC_DEFUN([AC_WIRESHARK_C_ARES_CHECK],
1136 [
1137         want_c_ares=defaultyes
1138
1139         if test "x$want_c_ares" = "xdefaultyes"; then
1140                 want_c_ares=yes
1141                 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
1142                         withval=/usr/local
1143                         if test -d "$withval"; then
1144                                 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1145                         fi
1146                 fi
1147         fi
1148
1149         if test "x$want_c_ares" = "xyes"; then
1150                 AC_CHECK_LIB(cares, ares_init,
1151                   [
1152                     C_ARES_LIBS=-lcares
1153                 AC_DEFINE(HAVE_C_ARES, 1, [Define to use c-ares library])
1154                 have_good_c_ares=yes
1155                   ],, $SOCKET_LIBS $NSL_LIBS
1156                 )
1157         else
1158                 AC_MSG_RESULT(not required)
1159         fi
1160 ])
1161
1162
1163 #
1164 # AC_WIRESHARK_ADNS_CHECK
1165 #
1166 AC_DEFUN([AC_WIRESHARK_ADNS_CHECK],
1167 [
1168         want_adns=defaultyes
1169
1170         if test "x$want_adns" = "xdefaultyes"; then
1171                 want_adns=yes
1172                 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
1173                         withval=/usr/local
1174                         if test -d "$withval"; then
1175                                 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1176                         fi
1177                 fi
1178         fi
1179
1180         if test "x$want_adns" = "xyes"; then
1181                 AC_CHECK_LIB(adns, adns_init,
1182                   [
1183                     ADNS_LIBS=-ladns
1184                 AC_DEFINE(HAVE_GNU_ADNS, 1, [Define to use GNU ADNS library])
1185                 have_good_adns=yes
1186                   ],, $SOCKET_LIBS $NSL_LIBS
1187                 )
1188         else
1189                 AC_MSG_RESULT(not required)
1190         fi
1191 ])
1192
1193
1194 #
1195 # AC_WIRESHARK_LIBCAP_CHECK
1196 #
1197 AC_DEFUN([AC_WIRESHARK_LIBCAP_CHECK],
1198 [
1199         want_libcap=defaultyes
1200
1201         if test "x$want_libcap" = "xdefaultyes"; then
1202                 want_libcap=yes
1203                 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
1204                         withval=/usr/local
1205                         if test -d "$withval"; then
1206                                 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1207                         fi
1208                 fi
1209         fi
1210
1211         if test "x$want_libcap" = "xyes"; then
1212                 AC_CHECK_LIB(cap, cap_set_flag,
1213                   [
1214                     LIBCAP_LIBS=-lcap
1215                 AC_DEFINE(HAVE_LIBCAP, 1, [Define to use the libcap library])
1216                 have_good_libcap=yes
1217                   ],,
1218                 )
1219         else
1220                 AC_MSG_RESULT(not required)
1221         fi
1222 ])
1223
1224
1225 #
1226 # AC_WIRESHARK_KRB5_CHECK
1227 #
1228 AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
1229 [
1230         wireshark_save_CPPFLAGS="$CPPFLAGS"
1231         if test "x$krb5_dir" != "x"
1232         then
1233           #
1234           # The user specified a directory in which kerberos resides,
1235           # so add the "include" subdirectory of that directory to
1236           # the include file search path and the "lib" subdirectory
1237           # of that directory to the library search path.
1238           #
1239           # XXX - if there's also a kerberos in a directory that's
1240           # already in CPPFLAGS or LDFLAGS, this won't make us find
1241           # the version in the specified directory, as the compiler
1242           # and/or linker will search that other directory before it
1243           # searches the specified directory.
1244           #
1245           CPPFLAGS="$CPPFLAGS -I$krb5_dir/include"
1246           ac_heimdal_version=`grep heimdal $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*heimdal.*$/HEIMDAL/'`
1247           # MIT Kerberos moved krb5.h to krb5/krb5.h starting with release 1.5
1248           ac_mit_version_olddir=`grep 'Massachusetts Institute of Technology' $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*Massachusetts Institute of Technology.*$/MIT/'`
1249           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/'`
1250           ac_krb5_version="$ac_heimdal_version$ac_mit_version_olddir$ac_mit_version_newdir"
1251           if test "x$ac_krb5_version" = "xHEIMDAL"
1252           then
1253               KRB5_LIBS="-L$krb5_dir/lib -lkrb5 -lasn1 $SSL_LIBS -lroken -lcrypt"
1254           else
1255               KRB5_LIBS="-L$krb5_dir/lib -lkrb5 -lk5crypto -lcom_err"
1256           fi
1257           if test "x$ac_krb5_version" = "xMIT"
1258           then
1259             AC_DEFINE(HAVE_MIT_KERBEROS, 1, [Define to use MIT kerberos])
1260           fi
1261         else
1262           AC_PATH_PROG(KRB5_CONFIG, krb5-config)
1263           if test -x "$KRB5_CONFIG"
1264           then
1265             KRB5_FLAGS=`"$KRB5_CONFIG" --cflags`
1266             KRB5_LIBS=`"$KRB5_CONFIG" --libs`
1267             CPPFLAGS="$CPPFLAGS $KRB5_FLAGS"
1268             #
1269             # If -lcrypto is in KRB5_FLAGS, we require it to build
1270             # with Heimdal/MIT.  We don't want to built with it by
1271             # default, due to annoying license incompatibilities
1272             # between the OpenSSL license and the GPL, so:
1273             #
1274             #   if SSL_LIBS is set to a non-empty string, we
1275             #   remove -lcrypto from KRB5_LIBS and replace
1276             #   it with SSL_LIBS;
1277             #
1278             #   if SSL_LIBS is not set to a non-empty string
1279             #   we fail with an appropriate error message.
1280             #
1281             case "$KRB5_LIBS" in
1282             *-lcrypto*)
1283                 if test ! -z "$SSL_LIBS"
1284                 then
1285                     KRB5_LIBS=`echo $KRB5_LIBS | sed 's/-lcrypto//'`
1286                     KRB5_LIBS="$KRB5_LIBS $SSL_LIBS"
1287                 else
1288                     AC_MSG_ERROR([Kerberos library requires -lcrypto but --with-ssl not specified])
1289                 fi
1290                 ;;
1291             esac
1292             ac_krb5_version=`"$KRB5_CONFIG" --version | head -n 1 | sed -e 's/^.*heimdal.*$/HEIMDAL/' -e 's/^Kerberos .*$/MIT/' -e 's/^Solaris Kerberos .*$/MIT/'`
1293           fi
1294         fi
1295
1296         #
1297         # Make sure we have "krb5.h".  If we don't, it means we probably
1298         # don't have kerberos, so don't use it.
1299         #
1300         AC_CHECK_HEADER(krb5.h,,
1301           [
1302             if test "x$krb5_dir" != "x"
1303             then
1304               #
1305               # The user used "--with-krb5=" to specify a directory
1306               # containing kerberos, but we didn't find the header file
1307               # there; that either means they didn't specify the
1308               # right directory or are confused about whether kerberos
1309               # is, in fact, installed.  Report the error and give up.
1310               #
1311               AC_MSG_ERROR([kerberos header not found in directory specified in --with-krb5])
1312             else
1313               if test "x$want_krb5" = "xyes"
1314               then
1315                 #
1316                 # The user tried to force us to use the library, but we
1317                 # couldn't find the header file; report an error.
1318                 #
1319                 AC_MSG_ERROR(Header file krb5.h not found.)
1320               else
1321                 #
1322                 # We couldn't find the header file; don't use the
1323                 # library, as it's probably not present.
1324                 #
1325                 want_krb5=no
1326                 AC_MSG_RESULT(No Heimdal or MIT header found - disabling dissection for some kerberos data in packet decoding)
1327               fi
1328             fi
1329           ])
1330
1331         if test "x$want_krb5" != "xno"
1332         then
1333             #
1334             # Well, we at least have the krb5 header file.
1335             # Check whether this is Heimdal or MIT.
1336             #
1337             AC_MSG_CHECKING(whether the Kerberos library is Heimdal or MIT)
1338             if test "x$ac_krb5_version" = "xHEIMDAL" -o "x$ac_krb5_version" = "xMIT"
1339             then
1340                 #
1341                 # Yes.
1342                 # Check whether we have krb5_kt_resolve - and whether
1343                 # we need to link with -lresolv when linking with
1344                 # the Kerberos library.
1345                 #
1346                 AC_MSG_RESULT($ac_krb5_version)
1347                 wireshark_save_LIBS="$LIBS"
1348                 found_krb5_kt_resolve=no
1349                 for extras in "" "-lresolv"
1350                 do
1351                     LIBS="$KRB5_LIBS $extras"
1352                     if test -z "$extras"
1353                     then
1354                         AC_MSG_CHECKING([whether $ac_krb5_version includes krb5_kt_resolve])
1355                     else
1356                         AC_MSG_CHECKING([whether $ac_krb5_version includes krb5_kt_resolve (linking with $extras)])
1357                     fi
1358                     AC_TRY_LINK(
1359                         [
1360                         ],
1361                         [
1362                             krb5_kt_resolve();
1363                         ],
1364                         [
1365                             #
1366                             # We found "krb5_kt_resolve()", and required
1367                             # the libraries in extras as well.
1368                             #
1369                             AC_MSG_RESULT(yes)
1370                             KRB5_LIBS="$LIBS"
1371                             AC_DEFINE(HAVE_KERBEROS, 1, [Define to use kerberos])
1372                             if test "x$ac_krb5_version" = "xHEIMDAL"
1373                             then
1374                                 AC_DEFINE(HAVE_HEIMDAL_KERBEROS, 1, [Define to use heimdal kerberos])
1375                             elif test "x$ac_krb5_version" = "xMIT"
1376                             then
1377                                 AC_DEFINE(HAVE_MIT_KERBEROS, 1, [Define to use MIT kerberos])
1378                             fi
1379                             found_krb5_kt_resolve=yes
1380                             break
1381                         ],
1382                         [
1383                             AC_MSG_RESULT(no)
1384                         ])
1385                 done
1386                 if test "$found_krb5_kt_resolve" = no
1387                 then
1388                     #
1389                     # We didn't find "krb5_kt_resolve()" in the
1390                     # Kerberos library, even when we tried linking
1391                     # with -lresolv; we can't link with kerberos.
1392                     #
1393                     if test "x$want_krb5" = "xyes"
1394                     then
1395                         #
1396                         # The user tried to force us to use the library,
1397                         # but we can't do so; report an error.
1398                         #
1399                         AC_MSG_ERROR(Usable $ac_krb5_version not found)
1400                     else
1401                         #
1402                         # Restore the versions of CPPFLAGS from before we
1403                         # added the flags for Kerberos.
1404                         #
1405                         AC_MSG_RESULT(Usable $ac_krb5_version not found - disabling dissection for some kerberos data in packet decoding)
1406                         CPPFLAGS="$wireshark_save_CPPFLAGS"
1407                         KRB5_LIBS=""
1408                         want_krb5=no
1409                     fi
1410                 else
1411                     #
1412                     # We can link with Kerberos; see whether krb5.h
1413                     # defines KEYTYPE_ARCFOUR_56 (where "defines" means
1414                     # "as a #define or as an enum member).
1415                     #
1416                     AC_MSG_CHECKING([whether krb5.h defines KEYTYPE_ARCFOUR_56])
1417                     AC_COMPILE_IFELSE(
1418                       [
1419                         AC_LANG_SOURCE(
1420                           [[
1421                             #include <krb5.h>
1422                             #include <stdio.h>
1423
1424                             main()
1425                             {
1426                               printf("%u\n", KEYTYPE_ARCFOUR_56);
1427                             }
1428                           ]])
1429                       ],
1430                       [
1431                         AC_MSG_RESULT(yes)
1432                         AC_DEFINE(HAVE_KEYTYPE_ARCFOUR_56, 1, [Define if krb5.h defines KEYTYPE_ARCFOUR_56])
1433                       ],
1434                       [
1435                         AC_MSG_RESULT(no)
1436                       ])
1437                 fi
1438                 LIBS="$wireshark_save_LIBS"
1439             else
1440                 #
1441                 # It's not Heimdal or MIT.
1442                 #
1443                 AC_MSG_RESULT(no)
1444                 if test "x$want_krb5" = "xyes"
1445                 then
1446                     #
1447                     # The user tried to force us to use the library,
1448                     # but we can't do so; report an error.
1449                     #
1450                     AC_MSG_ERROR(Kerberos not found)
1451                 else
1452                     #
1453                     # Restore the versions of CPPFLAGS from before we
1454                     # added the flags for Kerberos.
1455                     #
1456                     AC_MSG_RESULT(Kerberos not found - disabling dissection for some kerberos data in packet decoding)
1457                     CPPFLAGS="$wireshark_save_CPPFLAGS"
1458                     KRB5_LIBS=""
1459                     want_krb5=no
1460                 fi
1461             fi
1462         else
1463             #
1464             # The user asked us not to use Kerberos, or they didn't
1465             # say whether they wanted us to use it but we found
1466             # that we couldn't.
1467             #
1468             # Restore the versions of CPPFLAGS from before we added
1469             # the flags for Kerberos.
1470             #
1471             CPPFLAGS="$wireshark_save_CPPFLAGS"
1472             KRB5_LIBS=""
1473             want_krb5=no
1474         fi
1475         AC_SUBST(KRB5_LIBS)
1476 ])
1477
1478 #
1479 # AC_WIRESHARK_GEOIP_CHECK
1480 #
1481 AC_DEFUN([AC_WIRESHARK_GEOIP_CHECK],
1482 [
1483         want_geoip=defaultyes
1484
1485         if test "x$want_geoip" = "xdefaultyes"; then
1486                 want_geoip=yes
1487                 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
1488                         withval=/usr/local
1489                         if test -d "$withval"; then
1490                                 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1491                         fi
1492                 fi
1493         fi
1494
1495         if test "x$want_geoip" = "xyes"; then
1496                 AC_CHECK_LIB(GeoIP, GeoIP_new,
1497                   [
1498                     GEOIP_LIBS=-lGeoIP
1499                 AC_DEFINE(HAVE_GEOIP, 1, [Define to use GeoIP library])
1500                 have_good_geoip=yes
1501                   ],,
1502                 )
1503                 if test "x$have_good_geoip" = "xyes"; then
1504                         AC_CHECK_LIB(GeoIP, GeoIP_country_name_by_ipnum_v6,
1505                           [
1506                                 AC_DEFINE(HAVE_GEOIP_V6, 1, [Define if GeoIP supports IPv6 (GeoIP 1.4.5 and later)])
1507                           ],,
1508                         )
1509                 fi
1510         else
1511                 AC_MSG_RESULT(not required)
1512         fi
1513 ])
1514
1515 #AC_WIRESHARK_LDFLAGS_CHECK
1516 #
1517 # $1 : ldflag(s) to test
1518 #
1519 # The macro first determines if the compiler supports "-Wl,{option}" to
1520 # pass options through to the linker. Then it attempts to compile with
1521 # the defined ldflags. The defined flags are added to LDFLAGS only if
1522 # the compilation succeeds.
1523 #
1524 AC_DEFUN([AC_WIRESHARK_LDFLAGS_CHECK],
1525 [GCC_OPTION="$1"
1526 AC_MSG_CHECKING(whether we can add $GCC_OPTION to LDFLAGS)
1527 if test "x$ac_supports_W_linker_passthrough" = "xyes"; then
1528   LDFLAGS_saved="$LDFLAGS"
1529   LDFLAGS="$LDFLAGS $GCC_OPTION"
1530   AC_LINK_IFELSE([
1531     AC_LANG_SOURCE([[
1532                 main() { return; }
1533                   ]])],
1534                   [
1535                     AC_MSG_RESULT(yes)
1536                   ],
1537                   [
1538                     AC_MSG_RESULT(no)
1539                     LDFLAGS="$LDFLAGS_saved"
1540                   ])
1541 else
1542   AC_MSG_RESULT(no)
1543 fi
1544 ])
1545
1546 #
1547 # AC_WIRESHARK_GCC_CFLAGS_CHECK
1548 #
1549 # $1 : cflags to test
1550 # $2 : if supplied, C for C-only flags, CXX for C++-only flags
1551 #
1552 # The macro first determines if the compiler supports GCC-style flags.
1553 # Then it attempts to compile with the defined cflags.  The defined
1554 # flags are added to CFLAGS only if the compilation succeeds.
1555 #
1556 # We do this because not all such options are necessarily supported by
1557 # the version of the particular compiler we're using.
1558 #
1559 # NOTE: clang, by default, only warns about unknown -W options.
1560 # If we're using clang, we turn on -Werror=unknown-warning-option
1561 # so that it fails if we pass it a -W option it doesn't know about
1562 # but doesn't fail for any other warning that the test program might
1563 # produce.
1564 #
1565 AC_DEFUN([AC_WIRESHARK_GCC_CFLAGS_CHECK],
1566 [GCC_OPTION="$1"
1567 case "$2" in
1568 C)
1569   AC_MSG_CHECKING(whether we can add $GCC_OPTION to CFLAGS)
1570   ;;
1571
1572 CXX)
1573   AC_MSG_CHECKING(whether we can add $GCC_OPTION to CXXFLAGS)
1574   ;;
1575
1576 *)
1577   AC_MSG_CHECKING(whether we can add $GCC_OPTION to CFLAGS and CXXFLAGS)
1578   ;;
1579 esac
1580
1581 if test "x$ac_supports_gcc_flags" = "xyes" ; then
1582   if test "$2" != CXX ; then
1583     #
1584     # Not C++-only; if this can be added to the C compiler flags, add them.
1585     #
1586     CFLAGS_saved="$CFLAGS"
1587     CFLAGS="$CFLAGS $GCC_OPTION"
1588     if test "x$CC" = "xclang" ; then
1589       #
1590       # Force clang to fail on an unknown warning option; by default,
1591       # it whines but doesn't fail, so we add unknown options and,
1592       # as a result, get a lot of that whining when we compile.
1593       #
1594       CFLAGS="$CFLAGS -Werror=unknown-warning-option"
1595     fi
1596     AC_COMPILE_IFELSE([
1597       AC_LANG_SOURCE([[
1598                         int foo;
1599                     ]])],
1600                     [
1601                       AC_MSG_RESULT(yes)
1602                       #
1603                       # Remove -Werror=unknown-warning-option, if we
1604                       # added it, by setting CFLAGS to the saved value
1605                       # plus just the new option.
1606                       #
1607                       CFLAGS="$CFLAGS_saved $GCC_OPTION"
1608                       if test "$2" != C ; then
1609                         #
1610                         # Add it to the C++ flags as well.
1611                         #
1612                         CXXFLAGS="$CXXFLAGS $GCC_OPTION"
1613                       fi
1614                     ],
1615                     [
1616                       AC_MSG_RESULT(no)
1617                       CFLAGS="$CFLAGS_saved"
1618                     ])
1619   else
1620     #
1621     # C++-only; if this can be added to the C++ compiler flags, add them.
1622     #
1623     CXXFLAGS_saved="$CXXFLAGS"
1624     CXXFLAGS="$CXXFLAGS $GCC_OPTION"
1625     if test "x$CC" = "xclang" ; then
1626       CXXFLAGS="$CXXFLAGS -Werror=unknown-warning-option"
1627     fi
1628     AC_LANG_PUSH([C++])
1629     AC_COMPILE_IFELSE([
1630       AC_LANG_SOURCE([[
1631                         int foo;
1632                     ]])],
1633                     [
1634                       AC_MSG_RESULT(yes)
1635                     ],
1636                     [
1637                       AC_MSG_RESULT(no)
1638                       CXXFLAGS="$CXXFLAGS_saved"
1639                     ])
1640     AC_LANG_POP([C++])
1641   fi
1642 else
1643   AC_MSG_RESULT(no)
1644 fi
1645 ])
1646
1647 #
1648 # AC_WIRESHARK_OSX_INTEGRATION_CHECK
1649 #
1650 # Checks for the presence of OS X integration functions in the GTK+ framework
1651 # or as a separate library.
1652 #
1653 # http://sourceforge.net/apps/trac/gtk-osx/wiki/Integrate
1654 #
1655 # http://live.gnome.org/GTK%2B/OSX/Integration
1656 #    for the old Carbon-based integration functions
1657 #
1658 # http://gtk-osx.sourceforge.net/ige-mac-integration/
1659 #    for the new Cocoa-based integration functions
1660 #
1661 AC_DEFUN([AC_WIRESHARK_OSX_INTEGRATION_CHECK],
1662 [
1663         ac_save_CFLAGS="$CFLAGS"
1664         ac_save_LIBS="$LIBS"
1665         CFLAGS="$CFLAGS $GTK_CFLAGS"
1666         LIBS="$GTK_LIBS $LIBS"
1667
1668         #
1669         # Check for the new integration functions in a -ligemacintegration
1670         # library.
1671         #
1672         AC_CHECK_LIB(igemacintegration, gtk_osxapplication_set_menu_bar,
1673         [
1674                 AC_DEFINE(HAVE_GTKOSXAPPLICATION, 1,
1675                         [Define to 1 if -ligemacintegration includes the GtkOSXApplication Integration functions.])
1676                 have_ige_mac=yes
1677                 # We don't want gtk stuff in LIBS (which is reset below) so
1678                 # manually set GTK_LIBS (which is more appropriate)
1679                 GTK_LIBS="$GTK_LIBS -ligemacintegration"
1680         ])
1681
1682         if test x$have_ige_mac = x
1683         then
1684                 #
1685                 # Not found - check for the old integration functions in
1686                 # the Gtk framework.
1687                 #
1688                 AC_CHECK_LIB(Gtk, ige_mac_menu_set_menu_bar,
1689                 [
1690                         AC_DEFINE(HAVE_IGE_MAC_INTEGRATION, 1,
1691                                 [Define to 1 if the the Gtk+ framework or a separate library includes the Imendio IGE Mac OS X Integration functions.])
1692                         have_ige_mac=yes
1693                         # We don't want gtk stuff in LIBS (which is reset below) so
1694                         # manually set GTK_LIBS (which is more appropriate)
1695                         GTK_LIBS="$GTK_LIBS -lGtk"
1696                 ])
1697         fi
1698
1699         if test x$have_ige_mac = x
1700         then
1701                 #
1702                 # Not found - check for the old integration functions in
1703                 # a -ligemacintegration library.
1704                 #
1705                 AC_CHECK_LIB(igemacintegration, ige_mac_menu_set_menu_bar,
1706                 [
1707                         AC_DEFINE(HAVE_IGE_MAC_INTEGRATION, 1,
1708                                 [Define to 1 if the the Gtk+ framework or a separate library includes the Imendio IGE Mac OS X Integration functions.])
1709                         have_ige_mac=yes
1710                         # We don't want gtk stuff in LIBS (which is reset below) so
1711                         # manually set GTK_LIBS (which is more appropriate)
1712                         GTK_LIBS="$GTK_LIBS -ligemacintegration"
1713                 ])
1714         fi
1715         CFLAGS="$ac_save_CFLAGS"
1716         LIBS="$ac_save_LIBS"
1717 ])
1718
1719 #
1720 # AC_WIRESHARK_PYTHON_CHECK
1721 #
1722 # Check whether python devel package is present
1723 #
1724 AC_DEFUN([AC_WIRESHARK_PYTHON_CHECK],
1725   [
1726     #
1727     # Checking whether we have a python devel environment available
1728     #
1729 #  AC_CACHE_CHECK([checking python devel package], ac_cv_wireshark_python_devel,
1730 #    [
1731     AC_CHECK_PROG([ac_ws_python_config], python-config, "yes", "no")
1732     if test "x$ac_ws_python_config" = "xno"; then
1733       ac_cv_wireshark_python_devel=no
1734         if test "x$want_python" = "xyes"
1735         then
1736             #
1737             # The user tried to force us to use Python, but we
1738             # couldn't find the python-config tool; report an error.
1739             #
1740             AC_MSG_ERROR("python-config not found")
1741         fi
1742         #
1743         # Set want_python to no, so we report that we aren't using
1744         # the Python interpreter.
1745         #
1746         want_python=no
1747     else
1748       AC_MSG_CHECKING([python devel])
1749       ac_save_ws_cflags=$CFLAGS
1750       ac_save_ws_libs=$LIBS
1751       CFLAGS=$(python-config --includes)
1752       LIBS=$(python-config --ldflags)
1753       AC_COMPILE_IFELSE(
1754         [
1755           AC_LANG_PROGRAM(
1756             [[#include <Python.h>]],
1757             [[Py_Initialiaze();]]
1758           )
1759         ],
1760         [
1761           #
1762           # Compilation successful, we have python devel available
1763           #
1764           ac_cv_wireshark_python_devel=yes
1765           PY_LIBS=$LIBS
1766           PY_CFLAGS=$CFLAGS
1767           AC_SUBST(PY_LIBS)
1768           AC_SUBST(PY_CFLAGS)
1769           CFLAGS="$ac_save_ws_cflags"
1770           LIBS="$ac_save_ws_libs"
1771           AC_DEFINE(HAVE_PYTHON, 1, [Define if python devel package available])
1772           AC_MSG_RESULT([yes])
1773         ],
1774         [
1775           #
1776           # Compilation unsuccessful, python devel not available
1777           #
1778           ac_cv_wireshark_python_devel=no
1779           CFLAGS=$ac_save_ws_cflags
1780           LIBS=$ac_save_ws_libs
1781           if test "x$want_python" = "xyes"
1782           then
1783             #
1784             # The user tried to force us to use Python, but we
1785             # couldn't compile the test program; report an error.
1786             #
1787             AC_MSG_ERROR("Python test program failed compilation")
1788           fi
1789           AC_MSG_RESULT([no])
1790           #
1791           # Set want_python to no, so we report that we aren't using
1792           # the Python interpreter.
1793           #
1794           want_python=no
1795         ])
1796     fi
1797 #    ])
1798 ])