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