HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / acinclude.m4
blobbf5575592150d585d4ea4de32f9ad58b9662bd74
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.
54 # AC_WIRESHARK_ADD_DASH_L
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.
60 # XXX - IRIX, and other OSes, may require some flag equivalent to
61 # "-R" here.
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
73 # AC_WIRESHARK_TIMEZONE_ABBREV
76 AC_DEFUN([AC_WIRESHARK_TIMEZONE_ABBREV],
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
108 # AC_WIRESHARK_STRUCT_ST_FLAGS
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.
117 dnl ### Checks for structure members
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])
130 # AC_WIRESHARK_STRUCT_SA_LEN
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.
139 dnl ### Checks for structure members
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])
153 # AC_WIRESHARK_IPV6_STACK
155 # By Jun-ichiro "itojun" Hagino, <itojun@iijlab.net>
157 AC_DEFUN([AC_WIRESHARK_IPV6_STACK],
159         v6type=unknown
160         v6lib=none
162         AC_MSG_CHECKING([ipv6 stack type])
163         for i in v6d toshiba kame inria zeta linux linux-glibc solaris; do
164                 case $i in
165                 v6d)
166                         AC_EGREP_CPP(yes, [
167 #include </usr/local/v6/include/sys/types.h>
168 #ifdef __V6D__
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
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__
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
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
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
227 #endif
228 #endif],
229                         [v6type=$i; v6lib=inet6; CPPFLAGS="-DINET6 $CPPFLAGS"])
230                         ;;
231                 solaris)
232                         if test "`uname -s`" = "SunOS"; then
233                                 v6type=$i
234                                 v6lib=inet6
235                                 [CPPFLAGS="-DINET6 $CPPFLAGS"]
236                         fi
237                         ;;
238                 esac
239                 if test "$v6type" != "unknown"; then
240                         break
241                 fi
242         done
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"])
259 # AC_WIRESHARK_GETHOSTBY_LIB_CHECK
261 # Checks whether we need "-lnsl" to get "gethostby*()", which we use
262 # in "resolv.c".
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.
268 AC_DEFUN([AC_WIRESHARK_GETHOSTBY_LIB_CHECK],
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)
282 # AC_WIRESHARK_SOCKET_LIB_CHECK
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).
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.
293 # We use "connect" because that's what AC_PATH_XTRA did.
295 AC_DEFUN([AC_WIRESHARK_SOCKET_LIB_CHECK],
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)
311 # AC_WIRESHARK_BREAKLOOP_TRY_LINK
313 AC_DEFUN([AC_WIRESHARK_PCAP_BREAKLOOP_TRY_LINK],
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   ])
339 # AC_WIRESHARK_PCAP_CHECK
341 AC_DEFUN([AC_WIRESHARK_PCAP_CHECK],
343         if test -z "$pcap_dir"
344         then
345           # Pcap header checks
346           # XXX need to set a var AC_CHECK_HEADER(pcap.h,,)
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)
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
365             "-L "*)
366               #
367               # Space after -L.  Pretend pcap-config doesn't exist.
368               #
369               AC_MSG_RESULT(yes)
370               PCAP_CONFIG=""
371               ;;
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
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
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?]]))
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)
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 libpcap 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
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];
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"
623 AC_DEFUN([AC_WIRESHARK_PCAP_REMOTE_CHECK],
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"
641 # AC_WIRESHARK_ZLIB_CHECK
643 AC_DEFUN([AC_WIRESHARK_ZLIB_CHECK],
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
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           ])
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])
721                 #
722                 # Check for "inflatePrime()" in zlib, which we need
723                 # in order to read compressed capture files.
724                 #
725                 AC_CHECK_FUNCS(inflatePrime)
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
764 # AC_WIRESHARK_LIBLUA_CHECK
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"
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                 # we try to find out the lua version by looking at pathnames
801                 # and we just add "-llua -lliblua" to the used libs.
802                 #
803                 AC_MSG_CHECKING(Lua version)
804                 for i in 5.0 5.1 5.2
805                 do
806                         [[ -d "/usr/include/lua$i" ]] && lua_ver=$i
807                 done
808                 AC_MSG_RESULT(Lua ${lua_ver})
809                 wireshark_save_CPPFLAGS="$CPPFLAGS"
810                 wireshark_save_LDFLAGS="$LDFLAGS"
811                 wireshark_save_LIBS="$LIBS"
812                 LIBS="$LIBS -llua -lm"
813         fi
815         #
816         # Make sure we have "lua.h", "lualib.h" and "lauxlib.h".  If we don't, it means we probably
817         # don't have liblua, so don't use it.
818         #
819         AC_CHECK_HEADERS(lua.h lualib.h lauxlib.h,,
820         [
821                 AC_CHECK_HEADERS(lua${lua_ver}/lua.h lua${lua_ver}/lualib.h lua${lua_ver}/lauxlib.h,
822                 [
823                         if test "x$lua_dir" != "x"
824                         then
825                                 LUA_INCLUDES="-I$lua_dir/include/lua${lua_ver}"
826                         else
827                                 #
828                                 # The user didn't specify a directory in which liblua resides;
829                                 # we must look for the headers in a "lua${lua_ver}" subdirectory of
830                                 # "/usr/include", "/usr/local/include", or "$prefix/include"
831                                 # as some systems apparently put the headers in a "lua${lua_ver}"
832                                 # subdirectory.
833                                 AC_MSG_CHECKING(for extraneous lua header directories)
834                                 found_lua_dir=""
835                                 lua_dir_list="/usr/include/lua${lua_ver} $prefix/include/lua${lua_ver}"
836                                 if test "x$ac_cv_enable_usr_local" = "xyes"
837                                 then
838                                         lua_dir_list="$lua_dir_list /usr/local/include/lua${lua_ver}"
839                                 fi
840                                 for lua_dir_ent in $lua_dir_list
841                                 do
842                                         if test -d $lua_dir_ent
843                                         then
844                                                 LUA_INCLUDES="-I$lua_dir_ent"
845                                                 found_lua_dir="$lua_dir_ent"
846                                                 break
847                                         fi
848                                 done
850                                 if test "x$found_lua_dir" != "x"
851                                 then
852                                         AC_MSG_RESULT(found -- $found_lua_dir)
853                                 else
854                                         AC_MSG_RESULT(not found)
855                                         #
856                                         # Restore the versions of CPPFLAGS,
857                                         # LDFLAGS, and LIBS before we added the
858                                         # "--with-lua=" directory, as we didn't
859                                         # actually find lua there.
860                                         #
861                                         CPPFLAGS="$wireshark_save_CPPFLAGS"
862                                         LDFLAGS="$wireshark_save_LDFLAGS"
863                                         LIBS="$wireshark_save_LIBS"
864                                         LUA_LIBS=""
865                                         if test "x$want_lua" = "xyes"
866                                         then
867                                                 # we found lua${lua_ver}/lua.h, but we don't know which include dir contains it
868                                                 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.)
869                                         else
870                                                 #
871                                                 # We couldn't find the header file; don't use the
872                                                 # library, as it's probably not present.
873                                                 #
874                                                 want_lua=no
875                                         fi
876                                 fi
877                         fi
878                 ],
879                 [
880                         #
881                         # Restore the versions of CPPFLAGS, LDFLAGS,
882                         # and LIBS before we added the "--with-lua="
883                         # directory, as we didn't actually find lua
884                         # there.
885                         #
886                         CPPFLAGS="$wireshark_save_CPPFLAGS"
887                         LDFLAGS="$wireshark_save_LDFLAGS"
888                         LIBS="$wireshark_save_LIBS"
889                         LUA_LIBS=""
890                         if test "x$lua_dir" != "x"
891                         then
892                                 #
893                                 # The user used "--with-lua=" to specify a directory
894                                 # containing liblua, but we didn't find the header file
895                                 # there; that either means they didn't specify the
896                                 # right directory or are confused about whether liblua
897                                 # is, in fact, installed.  Report the error and give up.
898                                 #
899                                 AC_MSG_ERROR([liblua header not found in directory specified in --with-lua])
900                         else
901                                 if test "x$want_lua" = "xyes"
902                                 then
903                                         #
904                                         # The user tried to force us to use the library, but we
905                                         # couldn't find the header file; report an error.
906                                         #
907                                         AC_MSG_ERROR(Header file lua.h not found.)
908                                 else
909                                         #
910                                         # We couldn't find the header file; don't use the
911                                         # library, as it's probably not present.
912                                         #
913                                         want_lua=no
914                                 fi
915                         fi
916                 ])
917         ])
919         if test "x$want_lua" != "xno"
920         then
921                 #
922                 # Well, we at least have the lua header file.
923                 #
924                 # let's check if the libs are there
925                 #
927                 # At least on Suse 9.3 systems, liblualib needs linking
928                 # against libm.
929                 LIBS="$LIBS $LUA_LIBS -lm"
931                 AC_CHECK_LIB(lua, luaL_openlibs,
932                 [
933                         #
934                         #  Lua found
935                         #
936                         if test "x$lua_dir" != "x"
937                         then
938                                 #
939                                 # Put the "-I" and "-L" flags for lua into
940                                 # LUA_INCLUDES and LUA_LIBS, respectively.
941                                 #
942                                 LUA_LIBS="-L$lua_dir/lib -llua -lm"
943                                 LUA_INCLUDES="-I$lua_dir/include"
944                         else
945                                 LUA_LIBS="-llua -lm"
946                                 LUA_INCLUDES=""
947                         fi
948                         AC_DEFINE(HAVE_LUA, 1, [Define to use Lua])
949                         want_lua=yes
951                 ],[
952                         #
953                         # We could not find the libs, maybe we have version number in the lib name
954                         #
956                         LIBS="$wireshark_save_LIBS -llua${lua_ver} -lm"
958                         AC_CHECK_LIB(lua${lua_ver}, luaL_openlibs,
959                         [
960                             #
961                             #  Lua found
962                             #
963                             LUA_LIBS=" -llua${lua_ver} -lm"
964                             AC_DEFINE(HAVE_LUA, 1, [Define to use Lua])
965                             want_lua=yes
966                         ],[
967                                 #
968                                 # Restore the versions of CPPFLAGS, LDFLAGS,
969                                 # and LIBS before we added the "--with-lua="
970                                 # directory, as we didn't actually find lua
971                                 # there.
972                                 #
973                                 CPPFLAGS="$wireshark_save_CPPFLAGS"
974                                 LDFLAGS="$wireshark_save_LDFLAGS"
975                                 LIBS="$wireshark_save_LIBS"
976                                 LUA_LIBS=""
977                                 # User requested --with-lua but it isn't available
978                                 if test "x$want_lua" = "xyes"
979                                 then
980                                         AC_MSG_ERROR(Linking with liblua failed.)
981                                 fi
982                                 want_lua=no
983                         ])
984                 ])
986         CPPFLAGS="$wireshark_save_CPPFLAGS"
987         LDFLAGS="$wireshark_save_LDFLAGS"
988         LIBS="$wireshark_save_LIBS"
989         AC_SUBST(LUA_LIBS)
990         AC_SUBST(LUA_INCLUDES)
992         fi
996 # AC_WIRESHARK_LIBPORTAUDIO_CHECK
998 AC_DEFUN([AC_WIRESHARK_LIBPORTAUDIO_CHECK],[
1000         if test "x$portaudio_dir" != "x"
1001         then
1002                 #
1003                 # The user specified a directory in which libportaudio
1004                 # resides, so add the "include" subdirectory of that directory to
1005                 # the include file search path and the "lib" subdirectory
1006                 # of that directory to the library search path.
1007                 #
1008                 # XXX - if there's also a libportaudio in a directory that's
1009                 # already in CPPFLAGS or LDFLAGS, this won't make us find
1010                 # the version in the specified directory, as the compiler
1011                 # and/or linker will search that other directory before it
1012                 # searches the specified directory.
1013                 #
1014                 wireshark_save_CPPFLAGS="$CPPFLAGS"
1015                 CPPFLAGS="$CPPFLAGS -I$portaudio_dir/include"
1016                 wireshark_save_LIBS="$LIBS"
1017                 LIBS="$LIBS -L$portaudio_dir/lib -lportaudio"
1018                 wireshark_save_LDFLAGS="$LDFLAGS"
1019                 LDFLAGS="$LDFLAGS -L$portaudio_dir/lib"
1020         else
1021                 #
1022                 # The user specified no directory in which libportaudio resides,
1023                 # so just add "-lportaudio" to the used libs.
1024                 #
1025                 wireshark_save_CPPFLAGS="$CPPFLAGS"
1026                 wireshark_save_LDFLAGS="$LDFLAGS"
1027                 wireshark_save_LIBS="$LIBS"
1028                 LIBS="$LIBS -lportaudio"
1029         fi
1031         #
1032         # Make sure we have "portaudio.h".  If we don't, it means we probably
1033         # don't have libportaudio, so don't use it.
1034         #
1035         AC_CHECK_HEADERS(portaudio.h,,
1036         [
1037                 if test "x$portaudio_dir" != "x"
1038                 then
1039                         #
1040                         # The user used "--with-portaudio=" to specify a directory
1041                         # containing libportaudio, but we didn't find the header file
1042                         # there; that either means they didn't specify the
1043                         # right directory or are confused about whether libportaudio
1044                         # is, in fact, installed.  Report the error and give up.
1045                         #
1046                         AC_MSG_ERROR([libportaudio header not found in directory specified in --with-portaudio])
1047                 else
1048                         CPPFLAGS="$wireshark_save_CPPFLAGS"
1049                         LDFLAGS="$wireshark_save_LDFLAGS"
1050                         LIBS="$wireshark_save_LIBS"
1051                         PORTAUDIO_LIBS=""
1052                         if test "x$want_portaudio" = "xyes"
1053                         then
1054                                 #
1055                                 # The user tried to force us to use the library, but we
1056                                 # couldn't find the header file; report an error.
1057                                 #
1058                                 AC_MSG_ERROR(Header file portaudio.h not found.)
1059                         else
1060                                 #
1061                                 # We couldn't find the header file; don't use the
1062                                 # library, as it's probably not present.
1063                                 #
1064                                 want_portaudio=no
1065                         fi
1066                 fi
1067         ])
1069         #
1070         # Check whether we have the right version of portaudio
1071         #
1072         if test "x$want_portaudio" != "xno"
1073         then
1074                 AC_CHECK_TYPE(PortAudioStream,
1075                 AC_DEFINE(PORTAUDIO_API_1, 1, [Define if we are using version of of the Portaudio library API]),
1076                 ,
1077                 [#include <portaudio.h>])
1078         fi
1080         if test "x$want_portaudio" != "xno"
1081         then
1082                 #
1083                 # Well, we at least have the portaudio header file.
1084                 #
1085                 # let's check if the libs are there
1086                 #
1088                 AC_CHECK_LIB(portaudio, Pa_Initialize,
1089                 [
1090                         if test "x$portaudio_dir" != "x"
1091                         then
1092                                 #
1093                                 # Put the "-I" and "-L" flags for portaudio
1094                                 # into PORTAUDIO_INCLUDES and PORTAUDIO_LIBS,
1095                                 # respectively.
1096                                 #
1097                                 PORTAUDIO_LIBS="-L$portaudio_dir/lib -lportaudio"
1098                                 PORTAUDIO_INCLUDES="-I$portaudio_dir/include"
1099                         else
1100                                 PORTAUDIO_LIBS="-lportaudio"
1101                                 PORTAUDIO_INCLUDES=""
1102                         fi
1103                         AC_DEFINE(HAVE_LIBPORTAUDIO, 1, [Define to use libportaudio library])
1104                         want_portaudio=yes
1105                 ],[
1106                         #
1107                         # Restore the versions of CPPFLAGS, LDFLAGS, and
1108                         # LIBS before we added the "--with-portaudio="
1109                         # directory, as we didn't actually find portaudio
1110                         # there.
1111                         #
1112                         CPPFLAGS="$wireshark_save_CPPFLAGS"
1113                         LDFLAGS="$wireshark_save_LDFLAGS"
1114                         LIBS="$wireshark_save_LIBS"
1115                         PORTAUDIO_LIBS=""
1116                         # User requested --with-portaudio but it isn't available
1117                         if test "x$want_portaudio" = "xyes"
1118                         then
1119                                 AC_MSG_ERROR(Linking with libportaudio failed.)
1120                         fi
1121                         want_portaudio=no
1122                 ])
1124         CPPFLAGS="$wireshark_save_CPPFLAGS"
1125         LDFLAGS="$wireshark_save_LDFLAGS"
1126         LIBS="$wireshark_save_LIBS"
1127         AC_SUBST(PORTAUDIO_LIBS)
1128         AC_SUBST(PORTAUDIO_INCLUDES)
1130         fi
1134 # AC_WIRESHARK_RPM_CHECK
1135 # Looks for the rpm program, and checks to see if we can redefine "_topdir".
1137 AC_DEFUN([AC_WIRESHARK_RPM_CHECK],
1139         AC_CHECK_PROG(ac_cv_wireshark_have_rpm, rpm, "yes", "no")
1140         if test "x$ac_cv_wireshark_have_rpm" = "xyes"; then
1141                 rpm --define '_topdir /tmp' > /dev/null 2>&1
1142                 AC_MSG_CHECKING(to see if we can redefine _topdir)
1143                 if test $? -eq 0 ; then
1144                         AC_MSG_RESULT(yes)
1145                         HAVE_RPM=yes
1146                 else
1147                         AC_MSG_RESULT(no.  You'll have to build packages manually.)
1148                         HAVE_RPM=no
1149                 fi
1150         fi
1154 # AC_WIRESHARK_GNU_SED_CHECK
1155 # Checks if GNU sed is the first sed in PATH.
1157 AC_DEFUN([AC_WIRESHARK_GNU_SED_CHECK],
1159         AC_MSG_CHECKING(for GNU sed as first sed in PATH)
1160         if  ( sh -c "sed --version" </dev/null 2> /dev/null | grep "GNU sed" 2>&1 > /dev/null ) ;  then
1161                 AC_MSG_RESULT(yes)
1162                 HAVE_GNU_SED=yes
1163         else
1164                 AC_MSG_RESULT(no)
1165                 HAVE_GNU_SED=no
1166         fi
1170 # AC_WIRESHARK_C_ARES_CHECK
1172 AC_DEFUN([AC_WIRESHARK_C_ARES_CHECK],
1174         want_c_ares=defaultyes
1176         if test "x$want_c_ares" = "xdefaultyes"; then
1177                 want_c_ares=yes
1178                 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
1179                         withval=/usr/local
1180                         if test -d "$withval"; then
1181                                 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1182                         fi
1183                 fi
1184         fi
1186         if test "x$want_c_ares" = "xyes"; then
1187                 AC_CHECK_LIB(cares, ares_init,
1188                   [
1189                     C_ARES_LIBS=-lcares
1190                 AC_DEFINE(HAVE_C_ARES, 1, [Define to use c-ares library])
1191                 have_good_c_ares=yes
1192                   ],, $SOCKET_LIBS $NSL_LIBS
1193                 )
1194         else
1195                 AC_MSG_RESULT(not required)
1196         fi
1201 # AC_WIRESHARK_ADNS_CHECK
1203 AC_DEFUN([AC_WIRESHARK_ADNS_CHECK],
1205         want_adns=defaultyes
1207         if test "x$want_adns" = "xdefaultyes"; then
1208                 want_adns=yes
1209                 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
1210                         withval=/usr/local
1211                         if test -d "$withval"; then
1212                                 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1213                         fi
1214                 fi
1215         fi
1217         if test "x$want_adns" = "xyes"; then
1218                 AC_CHECK_LIB(adns, adns_init,
1219                   [
1220                     ADNS_LIBS=-ladns
1221                 AC_DEFINE(HAVE_GNU_ADNS, 1, [Define to use GNU ADNS library])
1222                 have_good_adns=yes
1223                   ],, $SOCKET_LIBS $NSL_LIBS
1224                 )
1225         else
1226                 AC_MSG_RESULT(not required)
1227         fi
1232 # AC_WIRESHARK_LIBCAP_CHECK
1234 AC_DEFUN([AC_WIRESHARK_LIBCAP_CHECK],
1236         want_libcap=defaultyes
1238         if test "x$want_libcap" = "xdefaultyes"; then
1239                 want_libcap=yes
1240                 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
1241                         withval=/usr/local
1242                         if test -d "$withval"; then
1243                                 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1244                         fi
1245                 fi
1246         fi
1248         if test "x$want_libcap" = "xyes"; then
1249                 AC_CHECK_LIB(cap, cap_set_flag,
1250                   [
1251                     LIBCAP_LIBS=-lcap
1252                 AC_DEFINE(HAVE_LIBCAP, 1, [Define to use the libcap library])
1253                 have_good_libcap=yes
1254                   ],,
1255                 )
1256         else
1257                 AC_MSG_RESULT(not required)
1258         fi
1263 # AC_WIRESHARK_KRB5_CHECK
1265 AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
1267         wireshark_save_CPPFLAGS="$CPPFLAGS"
1268         if test "x$krb5_dir" != "x"
1269         then
1270           #
1271           # The user specified a directory in which kerberos resides,
1272           # so add the "include" subdirectory of that directory to
1273           # the include file search path and the "lib" subdirectory
1274           # of that directory to the library search path.
1275           #
1276           # XXX - if there's also a kerberos in a directory that's
1277           # already in CPPFLAGS or LDFLAGS, this won't make us find
1278           # the version in the specified directory, as the compiler
1279           # and/or linker will search that other directory before it
1280           # searches the specified directory.
1281           #
1282           CPPFLAGS="$CPPFLAGS -I$krb5_dir/include"
1283           ac_heimdal_version=`grep heimdal $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*heimdal.*$/HEIMDAL/'`
1284           # MIT Kerberos moved krb5.h to krb5/krb5.h starting with release 1.5
1285           ac_mit_version_olddir=`grep 'Massachusetts Institute of Technology' $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*Massachusetts Institute of Technology.*$/MIT/'`
1286           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/'`
1287           ac_krb5_version="$ac_heimdal_version$ac_mit_version_olddir$ac_mit_version_newdir"
1288           if test "x$ac_krb5_version" = "xHEIMDAL"
1289           then
1290               KRB5_LIBS="-L$krb5_dir/lib -lkrb5 -lasn1 $SSL_LIBS -lroken -lcrypt"
1291           else
1292               KRB5_LIBS="-L$krb5_dir/lib -lkrb5 -lk5crypto -lcom_err"
1293           fi
1294           if test "x$ac_krb5_version" = "xMIT"
1295           then
1296             AC_DEFINE(HAVE_MIT_KERBEROS, 1, [Define to use MIT kerberos])
1297           fi
1298         else
1299           AC_PATH_PROG(KRB5_CONFIG, krb5-config)
1300           if test -x "$KRB5_CONFIG"
1301           then
1302             KRB5_FLAGS=`"$KRB5_CONFIG" --cflags`
1303             KRB5_LIBS=`"$KRB5_CONFIG" --libs`
1304             CPPFLAGS="$CPPFLAGS $KRB5_FLAGS"
1305             #
1306             # If -lcrypto is in KRB5_FLAGS, we require it to build
1307             # with Heimdal/MIT.  We don't want to built with it by
1308             # default, due to annoying license incompatibilities
1309             # between the OpenSSL license and the GPL, so:
1310             #
1311             #   if SSL_LIBS is set to a non-empty string, we
1312             #   remove -lcrypto from KRB5_LIBS and replace
1313             #   it with SSL_LIBS;
1314             #
1315             #   if SSL_LIBS is not set to a non-empty string
1316             #   we fail with an appropriate error message.
1317             #
1318             case "$KRB5_LIBS" in
1319             *-lcrypto*)
1320                 if test ! -z "$SSL_LIBS"
1321                 then
1322                     KRB5_LIBS=`echo $KRB5_LIBS | sed 's/-lcrypto//'`
1323                     KRB5_LIBS="$KRB5_LIBS $SSL_LIBS"
1324                 else
1325                     AC_MSG_ERROR([Kerberos library requires -lcrypto but --with-ssl not specified])
1326                 fi
1327                 ;;
1328             esac
1329             ac_krb5_version=`"$KRB5_CONFIG" --version | head -n 1 | sed -e 's/^.*heimdal.*$/HEIMDAL/' -e 's/^Kerberos .*$/MIT/' -e 's/^Solaris Kerberos .*$/MIT/'`
1330           fi
1331         fi
1333         #
1334         # Make sure we have "krb5.h".  If we don't, it means we probably
1335         # don't have kerberos, so don't use it.
1336         #
1337         AC_CHECK_HEADER(krb5.h,,
1338           [
1339             if test "x$krb5_dir" != "x"
1340             then
1341               #
1342               # The user used "--with-krb5=" to specify a directory
1343               # containing kerberos, but we didn't find the header file
1344               # there; that either means they didn't specify the
1345               # right directory or are confused about whether kerberos
1346               # is, in fact, installed.  Report the error and give up.
1347               #
1348               AC_MSG_ERROR([kerberos header not found in directory specified in --with-krb5])
1349             else
1350               if test "x$want_krb5" = "xyes"
1351               then
1352                 #
1353                 # The user tried to force us to use the library, but we
1354                 # couldn't find the header file; report an error.
1355                 #
1356                 AC_MSG_ERROR(Header file krb5.h not found.)
1357               else
1358                 #
1359                 # We couldn't find the header file; don't use the
1360                 # library, as it's probably not present.
1361                 #
1362                 want_krb5=no
1363                 AC_MSG_RESULT(No Heimdal or MIT header found - disabling dissection for some kerberos data in packet decoding)
1364               fi
1365             fi
1366           ])
1368         if test "x$want_krb5" != "xno"
1369         then
1370             #
1371             # Well, we at least have the krb5 header file.
1372             # Check whether this is Heimdal or MIT.
1373             #
1374             AC_MSG_CHECKING(whether the Kerberos library is Heimdal or MIT)
1375             if test "x$ac_krb5_version" = "xHEIMDAL" -o "x$ac_krb5_version" = "xMIT"
1376             then
1377                 #
1378                 # Yes.
1379                 # Check whether we have krb5_kt_resolve - and whether
1380                 # we need to link with -lresolv when linking with
1381                 # the Kerberos library.
1382                 #
1383                 AC_MSG_RESULT($ac_krb5_version)
1384                 wireshark_save_LIBS="$LIBS"
1385                 found_krb5_kt_resolve=no
1386                 for extras in "" "-lresolv"
1387                 do
1388                     LIBS="$KRB5_LIBS $extras"
1389                     if test -z "$extras"
1390                     then
1391                         AC_MSG_CHECKING([whether $ac_krb5_version includes krb5_kt_resolve])
1392                     else
1393                         AC_MSG_CHECKING([whether $ac_krb5_version includes krb5_kt_resolve (linking with $extras)])
1394                     fi
1395                     AC_TRY_LINK(
1396                         [
1397                         ],
1398                         [
1399                             krb5_kt_resolve();
1400                         ],
1401                         [
1402                             #
1403                             # We found "krb5_kt_resolve()", and required
1404                             # the libraries in extras as well.
1405                             #
1406                             AC_MSG_RESULT(yes)
1407                             KRB5_LIBS="$LIBS"
1408                             AC_DEFINE(HAVE_KERBEROS, 1, [Define to use kerberos])
1409                             if test "x$ac_krb5_version" = "xHEIMDAL"
1410                             then
1411                                 AC_DEFINE(HAVE_HEIMDAL_KERBEROS, 1, [Define to use heimdal kerberos])
1412                             elif test "x$ac_krb5_version" = "xMIT"
1413                             then
1414                                 AC_DEFINE(HAVE_MIT_KERBEROS, 1, [Define to use MIT kerberos])
1415                             fi
1416                             found_krb5_kt_resolve=yes
1417                             break
1418                         ],
1419                         [
1420                             AC_MSG_RESULT(no)
1421                         ])
1422                 done
1423                 if test "$found_krb5_kt_resolve" = no
1424                 then
1425                     #
1426                     # We didn't find "krb5_kt_resolve()" in the
1427                     # Kerberos library, even when we tried linking
1428                     # with -lresolv; we can't link with kerberos.
1429                     #
1430                     if test "x$want_krb5" = "xyes"
1431                     then
1432                         #
1433                         # The user tried to force us to use the library,
1434                         # but we can't do so; report an error.
1435                         #
1436                         AC_MSG_ERROR(Usable $ac_krb5_version not found)
1437                     else
1438                         #
1439                         # Restore the versions of CPPFLAGS from before we
1440                         # added the flags for Kerberos.
1441                         #
1442                         AC_MSG_RESULT(Usable $ac_krb5_version not found - disabling dissection for some kerberos data in packet decoding)
1443                         CPPFLAGS="$wireshark_save_CPPFLAGS"
1444                         KRB5_LIBS=""
1445                         want_krb5=no
1446                     fi
1447                 else
1448                     #
1449                     # We can link with Kerberos; see whether krb5.h
1450                     # defines KEYTYPE_ARCFOUR_56 (where "defines" means
1451                     # "as a #define or as an enum member).
1452                     #
1453                     AC_MSG_CHECKING([whether krb5.h defines KEYTYPE_ARCFOUR_56])
1454                     AC_COMPILE_IFELSE(
1455                       [
1456                         AC_LANG_SOURCE(
1457                           [[
1458                             #include <krb5.h>
1459                             #include <stdio.h>
1461                             main()
1462                             {
1463                               printf("%u\n", KEYTYPE_ARCFOUR_56);
1464                             }
1465                           ]])
1466                       ],
1467                       [
1468                         AC_MSG_RESULT(yes)
1469                         AC_DEFINE(HAVE_KEYTYPE_ARCFOUR_56, 1, [Define if krb5.h defines KEYTYPE_ARCFOUR_56])
1470                       ],
1471                       [
1472                         AC_MSG_RESULT(no)
1473                       ])
1474                 fi
1475                 LIBS="$wireshark_save_LIBS"
1476             else
1477                 #
1478                 # It's not Heimdal or MIT.
1479                 #
1480                 AC_MSG_RESULT(no)
1481                 if test "x$want_krb5" = "xyes"
1482                 then
1483                     #
1484                     # The user tried to force us to use the library,
1485                     # but we can't do so; report an error.
1486                     #
1487                     AC_MSG_ERROR(Kerberos not found)
1488                 else
1489                     #
1490                     # Restore the versions of CPPFLAGS from before we
1491                     # added the flags for Kerberos.
1492                     #
1493                     AC_MSG_RESULT(Kerberos not found - disabling dissection for some kerberos data in packet decoding)
1494                     CPPFLAGS="$wireshark_save_CPPFLAGS"
1495                     KRB5_LIBS=""
1496                     want_krb5=no
1497                 fi
1498             fi
1499         else
1500             #
1501             # The user asked us not to use Kerberos, or they didn't
1502             # say whether they wanted us to use it but we found
1503             # that we couldn't.
1504             #
1505             # Restore the versions of CPPFLAGS from before we added
1506             # the flags for Kerberos.
1507             #
1508             CPPFLAGS="$wireshark_save_CPPFLAGS"
1509             KRB5_LIBS=""
1510             want_krb5=no
1511         fi
1512         AC_SUBST(KRB5_LIBS)
1516 # AC_WIRESHARK_GEOIP_CHECK
1518 AC_DEFUN([AC_WIRESHARK_GEOIP_CHECK],
1520         want_geoip=defaultyes
1522         if test "x$want_geoip" = "xdefaultyes"; then
1523                 want_geoip=yes
1524                 if test "x$ac_cv_enable_usr_local" = "xyes" ; then
1525                         withval=/usr/local
1526                         if test -d "$withval"; then
1527                                 AC_WIRESHARK_ADD_DASH_L(LDFLAGS, ${withval}/lib)
1528                         fi
1529                 fi
1530         fi
1532         if test "x$want_geoip" = "xyes"; then
1533                 AC_CHECK_LIB(GeoIP, GeoIP_new,
1534                   [
1535                     GEOIP_LIBS=-lGeoIP
1536                 AC_DEFINE(HAVE_GEOIP, 1, [Define to use GeoIP library])
1537                 have_good_geoip=yes
1538                   ],,
1539                 )
1540                 if test "x$have_good_geoip" = "xyes"; then
1541                         AC_CHECK_LIB(GeoIP, GeoIP_country_name_by_ipnum_v6,
1542                           [
1543                                 AC_DEFINE(HAVE_GEOIP_V6, 1, [Define if GeoIP supports IPv6 (GeoIP 1.4.5 and later)])
1544                           ],,
1545                         )
1546                 fi
1547         else
1548                 AC_MSG_RESULT(not required)
1549         fi
1552 #AC_WIRESHARK_LDFLAGS_CHECK
1554 # $1 : ldflag(s) to test
1556 # The macro first determines if the compiler supports "-Wl,{option}" to
1557 # pass options through to the linker. Then it attempts to compile with
1558 # the defined ldflags. The defined flags are added to LDFLAGS only if
1559 # the compilation succeeds.
1561 AC_DEFUN([AC_WIRESHARK_LDFLAGS_CHECK],
1562 [GCC_OPTION="$1"
1563 AC_MSG_CHECKING(whether we can add $GCC_OPTION to LDFLAGS)
1564 if test "x$ac_supports_W_linker_passthrough" = "xyes"; then
1565   LDFLAGS_saved="$LDFLAGS"
1566   LDFLAGS="$LDFLAGS $GCC_OPTION"
1567   AC_LINK_IFELSE([
1568     AC_LANG_SOURCE([[
1569                 main() { return; }
1570                   ]])],
1571                   [
1572                     AC_MSG_RESULT(yes)
1573                   ],
1574                   [
1575                     AC_MSG_RESULT(no)
1576                     LDFLAGS="$LDFLAGS_saved"
1577                   ])
1578 else
1579   AC_MSG_RESULT(no)
1584 dnl Check whether, if you pass an unknown warning option to the
1585 dnl compiler, it fails or just prints a warning message and succeeds.
1586 dnl Set ac_wireshark_unknown_warning_option_error to the appropriate flag
1587 dnl to force an error if it would otherwise just print a warning message
1588 dnl and succeed.
1590 AC_DEFUN([AC_WIRESHARK_CHECK_UNKNOWN_WARNING_OPTION_ERROR],
1591     [
1592         AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option])
1593         save_CFLAGS="$CFLAGS"
1594         CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
1595         AC_TRY_COMPILE(
1596             [],
1597             [return 0],
1598             [
1599                 AC_MSG_RESULT([no, adding -Werror=unknown-warning-option])
1600                 #
1601                 # We're assuming this is clang, where
1602                 # -Werror=unknown-warning-option is the appropriate
1603                 # option to force the compiler to fail.
1604                 # 
1605                 ac_wireshark_unknown_warning_option_error="-Werror=unknown-warning-option"
1606             ],
1607             [
1608                 AC_MSG_RESULT([yes])
1609             ])
1610         CFLAGS="$save_CFLAGS"
1611     ])
1614 # AC_WIRESHARK_COMPILER_FLAGS_CHECK
1616 # $1 : flags to test
1617 # $2 : if supplied, C for C-only flags, CXX for C++-only flags
1618 # $3 : if supplied, a program to try to compile with the flag
1619 #      and, if the compile fails when -Werror is turned on,
1620 #      we don't add the flag - used for warning flags that
1621 #      issue incorrect or non-useful warnings with some
1622 #      compiler versions
1623 # $4 : must be supplied if $3 is supplied - a message describing
1624 #      for what the test program is testing
1626 # The macro first determines if the compiler supports GCC-style flags.
1627 # Then it attempts to compile with the defined cflags.  The defined
1628 # flags are added to CFLAGS only if the compilation succeeds.
1630 # We do this because not all such options are necessarily supported by
1631 # the version of the particular compiler we're using.
1633 AC_DEFUN([AC_WIRESHARK_COMPILER_FLAGS_CHECK],
1634 [GCC_OPTION="$1"
1635 can_add_to_cflags=""
1636 can_add_to_cxxflags=""
1637 if test "x$ac_supports_gcc_flags" = "xyes" ; then
1638   if test "$2" != CXX ; then
1639     #
1640     # Not C++-only; if this can be added to the C compiler flags, add them.
1641     #
1642     # If the option begins with "-W", add
1643     # $ac_wireshark_unknown_warning_option_error to make sure that
1644     # we'll get an error if it's an unknown warning option; not all
1645     # compilers treat unknown warning options as errors (I'm looking at
1646     # you, clang).
1647     #
1648     # If the option begins with "-f", add -Werror to make sure that
1649     # we'll get an error if we get "argument unused during compilation"
1650     # warnings, as those will either cause a failure for files compiled
1651     # with -Werror or annoying noise for files compiled without it.
1652     # (Yeah, you, clang.)
1653     #
1654     AC_MSG_CHECKING(whether we can add $GCC_OPTION to CFLAGS)
1655     CFLAGS_saved="$CFLAGS"
1656     if expr "x$GCC_OPTION" : "x-W.*" >/dev/null
1657     then
1658       CFLAGS="$CFLAGS $ac_wireshark_unknown_warning_option_error $GCC_OPTION"
1659     elif expr "x$GCC_OPTION" : "x-f.*" >/dev/null
1660     then
1661       CFLAGS="$CFLAGS -Werror $GCC_OPTION"
1662     fi
1663     AC_COMPILE_IFELSE(
1664       [
1665         AC_LANG_SOURCE([[int foo;]])
1666       ],
1667       [
1668         AC_MSG_RESULT(yes)
1669         can_add_to_cflags=yes
1670         #
1671         # OK, do we have a test program?  If so, check
1672         # whether it fails with this option and -Werror,
1673         # and, if so, don't include it.
1674         #
1675         # We test arg 4 here because arg 3 is a program which
1676         # could contain quotes (breaking the comparison).
1677         #
1678         if test "x$4" != "x" ; then
1679           CFLAGS="$CFLAGS -Werror"
1680           AC_MSG_CHECKING(whether $GCC_OPTION $4)
1681           AC_COMPILE_IFELSE(
1682             [AC_LANG_SOURCE($3)],
1683             [
1684               AC_MSG_RESULT(no)
1685               #
1686               # Remove "force an error for a warning" options, if we
1687               # added them, by setting CFLAGS to the saved value plus
1688               # just the new option.
1689               #
1690               CFLAGS="$CFLAGS_saved $GCC_OPTION"
1691               #
1692               # Add it to the flags we use when building build tools.
1693               #
1694               CFLAGS_FOR_BUILD="$CFLAGS_FOR_BUILD $GCC_OPTION"
1695             ],
1696             [
1697               AC_MSG_RESULT(yes)
1698               CFLAGS="$CFLAGS_saved"
1699             ])
1700         else
1701           #
1702           # Remove "force an error for a warning" options, if we
1703           # added them, by setting CFLAGS to the saved value plus
1704           # just the new option.
1705           #
1706           CFLAGS="$CFLAGS_saved $GCC_OPTION"
1707           #
1708           # Add it to the flags we use when building build tools.
1709           #
1710           CFLAGS_FOR_BUILD="$CFLAGS_FOR_BUILD $GCC_OPTION"
1711         fi
1712       ],
1713       [
1714         AC_MSG_RESULT(no)
1715         can_add_to_cflags=no
1716         CFLAGS="$CFLAGS_saved"
1717       ])
1718   fi
1719   if test "$2" != C ; then
1720     #
1721     # Not C-only; if this can be added to the C++ compiler flags, add them.
1722     #
1723     AC_MSG_CHECKING(whether we can add $GCC_OPTION to CXXFLAGS)
1724     CXXFLAGS_saved="$CXXFLAGS"
1725     if expr "x$GCC_OPTION" : "x-W.*" >/dev/null
1726     then
1727       CXXFLAGS="$CXXFLAGS $ac_wireshark_unknown_warning_option_error $GCC_OPTION"
1728     elif expr "x$GCC_OPTION" : "x-f.*" >/dev/null
1729     then
1730       CXXFLAGS="$CXXFLAGS -Werror $GCC_OPTION"
1731     fi
1732     AC_LANG_PUSH([C++])
1733     AC_COMPILE_IFELSE(
1734       [
1735         AC_LANG_SOURCE([[int foo;]])
1736       ],
1737       [
1738         AC_MSG_RESULT(yes)
1739         can_add_to_cxxflags=yes
1740         #
1741         # OK, do we have a test program?  If so, check
1742         # whether it fails with this option and -Werror,
1743         # and, if so, don't include it.
1744         #
1745         # We test arg 4 here because arg 3 is a program which
1746         # could contain quotes (breaking the comparison).
1747         #
1748         if test "x$4" != "x" ; then
1749           CXXFLAGS="$CXXFLAGS -Werror"
1750           AC_MSG_CHECKING(whether $GCC_OPTION $4)
1751           AC_COMPILE_IFELSE(
1752             [AC_LANG_SOURCE($3)],
1753             [
1754               AC_MSG_RESULT(no)
1755               #
1756               # Remove "force an error for a warning" options, if we
1757               # added them, by setting CXXFLAGS to the saved value plus
1758               # just the new option.
1759               #
1760               CXXFLAGS="$CXXFLAGS_saved $GCC_OPTION"
1761             ],
1762             [
1763               AC_MSG_RESULT(yes)
1764               CXXFLAGS="$CXXFLAGS_saved"
1765             ])
1766         else
1767           #
1768           # Remove "force an error for a warning" options, if we
1769           # added them, by setting CXXFLAGS to the saved value plus
1770           # just the new option.
1771           #
1772           CXXFLAGS="$CXXFLAGS_saved $GCC_OPTION"
1773         fi
1774       ],
1775       [
1776         AC_MSG_RESULT(no)
1777         can_add_to_cxxflags=no
1778         CXXFLAGS="$CXXFLAGS_saved"
1779       ])
1780     AC_LANG_POP([C++])
1781   fi
1782   if test "(" "$can_add_to_cflags" = "yes" -a "$can_add_to_cxxflags" = "no" ")" \
1783        -o "(" "$can_add_to_cflags" = "no" -a "$can_add_to_cxxflags" = "yes" ")"
1784   then
1785     AC_MSG_WARN([$CC and $CXX appear to be a mismatched pair])
1786   fi
1787 else
1788   AC_MSG_RESULT(no)
1792 # AC_WIRESHARK_GCC_FORTIFY_SOURCE_CHECK
1794 # Checks if '-D_FORTIFY_SOURCE=...' is OK to use in CPPFLAGS.
1795 #  Use '-D_FORTIFY_SOURCE=...' in CPPFLAGS only if the GCC 'optimization level' is > 0.
1796 #  The use of '-D_FORTIFY_SOURCE=...' will cause a warning with at least some versions
1797 #    of glibc if the  GCC "optimization level" is 0 (default or -O or -O0)
1798 #    when using GCC to compile a source file which references the macro definition.
1800 # See: http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
1801 # See: http://sourceware.org/bugzilla/show_bug.cgi?id=13979
1803 #   We'll use '-D_FORTIFY_SOURCE=2' only if there's no warning; Among other things this means
1804 #    that the  use of '-D_FORTIFY_SOURCE=2' with '-Werror' and '-O0' won't cause
1805 #    the compiler to stop on error.
1806 #   Assumption: CFLAGS already contains whatever optimization option including none) is
1807 #    to be used.
1810 AC_DEFUN([AC_WIRESHARK_GCC_FORTIFY_SOURCE_CHECK],
1812 if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
1813   AC_MSG_CHECKING([whether -D_FORTIFY_SOURCE=... can be used (without generating a warning)])
1814   CFLAGS_saved="$CFLAGS"
1815   CPPFLAGS_saved="$CPPFLAGS"
1816   CFLAGS="$CFLAGS -Werror"
1817   CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
1818   AC_COMPILE_IFELSE([
1819     AC_LANG_SOURCE([[
1820                   #include <stdio.h>
1821                       int foo;
1822                   ]])],
1823                   [
1824                     AC_MSG_RESULT(yes)
1825                     #
1826                     # (CPPFLAGS contains _D_FORTIFY_SOURCE=2)
1827                     #
1828                   ],
1829                   [
1830                     AC_MSG_RESULT(no)
1831                     # Remove -D_FORTIFY_SOURCE=2
1832                     CPPFLAGS="$CPPFLAGS_saved"
1833                   ])
1834   CFLAGS="$CFLAGS_saved"
1839 # AC_WIRESHARK_OSX_INTEGRATION_CHECK
1841 # Checks for the presence of OS X integration functions in the GTK+ framework
1842 # or as a separate library.
1844 # GTK+ for MAC OS X now lives on www.gtk.org at:
1846 #   http://www.gtk.org/download/macos.php
1848 # Details on building with GTK-OSX are available at:
1850 #   http://live.gnome.org/GTK%2B/OSX/Building
1852 # The GTK-OSX library has been renamed to gtkmacintegration.
1853 # It was previously named igemacintegration.
1855 # http://live.gnome.org/GTK%2B/OSX/Integration
1856 #    for the old Carbon-based integration functions
1858 AC_DEFUN([AC_WIRESHARK_OSX_INTEGRATION_CHECK],
1860         ac_save_CFLAGS="$CFLAGS"
1861         ac_save_LIBS="$LIBS"
1862         CFLAGS="$CFLAGS $GTK_CFLAGS"
1863         LIBS="$GTK_LIBS $LIBS"
1865         #
1866         # Check for the new integration functions in a -lgtkmacintegration
1867         # library.
1868         #
1869         AC_CHECK_LIB(gtkmacintegration, gtkosx_application_set_menu_bar,
1870         [
1871                 AC_DEFINE(HAVE_GTKOSXAPPLICATION, 1,
1872                         [Define to 1 if -lgtkmacintegration includes the GtkOSXApplication Integration functions.])
1873                 have_ige_mac=yes
1874                 # We don't want gtk stuff in LIBS (which is reset below) so
1875                 # manually set GTK_LIBS (which is more appropriate)
1876                 GTK_LIBS="$GTK_LIBS -lgtkmacintegration"
1877         ])
1879         if test x$have_ige_mac = x
1880         then
1881                 #
1882                 # Not found - check for the old integration functions in
1883                 # the Gtk framework.
1884                 #
1885                 AC_CHECK_LIB(Gtk, gtk_mac_menu_set_menu_bar,
1886                 [
1887                         AC_DEFINE(HAVE_IGE_MAC_INTEGRATION, 1,
1888                                 [Define to 1 if the the Gtk+ framework or a separate library includes the Imendio IGE Mac OS X Integration functions.])
1889                         have_ige_mac=yes
1890                         # We don't want gtk stuff in LIBS (which is reset below) so
1891                         # manually set GTK_LIBS (which is more appropriate)
1892                         GTK_LIBS="$GTK_LIBS -lGtk"
1893                 ])
1894         fi
1896         if test x$have_ige_mac = x
1897         then
1898                 #
1899                 # Not found - check for the old integration functions in
1900                 # a -lgtkmacintegration library.
1901                 #
1902                 AC_CHECK_LIB(gtkmacintegration, gtk_mac_menu_set_menu_bar,
1903                 [
1904                         AC_DEFINE(HAVE_IGE_MAC_INTEGRATION, 1,
1905                                 [Define to 1 if the the Gtk+ framework or a separate library includes the Imendio IGE Mac OS X Integration functions.])
1906                         have_ige_mac=yes
1907                         # We don't want gtk stuff in LIBS (which is reset below) so
1908                         # manually set GTK_LIBS (which is more appropriate)
1909                         GTK_LIBS="$GTK_LIBS -lgtkmacintegration"
1910                 ])
1911         fi
1912         CFLAGS="$ac_save_CFLAGS"
1913         LIBS="$ac_save_LIBS"
1916 # Based on AM_PATH_GTK in gtk-2.0.m4.
1918 dnl AC_WIRESHARK_QT_MODULE_CHECK([MODULE, MINIMUM-VERSION, [ACTION-IF-FOUND,
1919 dnl     [ACTION-IF-NOT-FOUND]]])
1920 dnl Test for a particular Qt module and add the flags and libraries
1921 dnl for it to Qt_CFLAGS and Qt_LIBS.
1923 AC_DEFUN([AC_WIRESHARK_QT_MODULE_CHECK],
1925         #
1926         # Version of the module we're checking for.
1927         # Default to 4.0.0.
1928         #
1929         min_qt_version=ifelse([$2], ,4.0.0,$2)
1931         #
1932         # Prior to Qt 5, modules were named QtXXX.
1933         # In Qt 5, they're named Qt5XXX.
1934         #
1935         # Try the Qt 5 version first.
1936         # (And be prepared to add Qt6 at some point....)
1937         #
1938         for modprefix in Qt5 Qt
1939         do
1940                 pkg_config_module="${modprefix}$1"
1941                 AC_MSG_CHECKING(for $pkg_config_module - version >= $min_qt_version)
1942                 if $PKG_CONFIG --atleast-version $min_qt_version $pkg_config_module; then
1943                         mod_version=`$PKG_CONFIG --modversion $pkg_config_module`
1944                         AC_MSG_RESULT(yes (version $mod_version))
1945                         Qt_CFLAGS="$Qt_CFLAGS `$PKG_CONFIG --cflags $pkg_config_module`"
1946                         Qt_LIBS="$Qt_LIBS `$PKG_CONFIG --libs $pkg_config_module`"
1947                         found_$1=yes
1948                         break
1949                 else
1950                         AC_MSG_RESULT(no)
1951                 fi
1952         done
1954         if test "x$found_$1" = "xyes"; then
1955                 # Run Action-If-Found
1956                 ifelse([$3], , :, [$3])
1957         else
1958                 # Run Action-If-Not-Found
1959                 ifelse([$4], , :, [$4])
1960         fi
1963 dnl AC_WIRESHARK_QT_CHECK([MINIMUM-VERSION, [ACTION-IF-FOUND,
1964 dnl     [ACTION-IF-NOT-FOUND]]])
1965 dnl Test for Qt and define Qt_CFLAGS and Qt_LIBS.
1967 AC_DEFUN([AC_WIRESHARK_QT_CHECK],
1969         no_qt=""
1971         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
1973         if test x$PKG_CONFIG != xno ; then
1974                 if pkg-config --atleast-pkgconfig-version 0.7 ; then
1975                         :
1976                 else
1977                         echo *** pkg-config too old; version 0.7 or better required.
1978                         no_qt=yes
1979                         PKG_CONFIG=no
1980                 fi
1981         else
1982                 no_qt=yes
1983         fi
1985         if test x"$no_qt" = x ; then
1986                 #
1987                 # OK, we have an adequate version of pkg-config.
1988                 #
1989                 # Check for the Core module; if we don't have that,
1990                 # we don't have Qt.
1991                 #
1992                 AC_WIRESHARK_QT_MODULE_CHECK(Core, $1, , [no_qt=yes])
1993         fi
1995         if test x"$no_qt" = x ; then
1996                 #
1997                 # We need the Gui module as well.
1998                 #
1999                 AC_WIRESHARK_QT_MODULE_CHECK(Gui, $1, , [no_qt=yes])
2000         fi
2002         if test x"$no_qt" = x ; then
2003                 #
2004                 # Qt 5.0 appears to move the widgets out of Qt GUI
2005                 # to Qt Widgets; look for the Widgets module, but
2006                 # don't fail if we don't have it.
2007                 #
2008                 AC_WIRESHARK_QT_MODULE_CHECK(Widgets, $1)
2010                 #
2011                 # Qt 5.0 also appears to move the printing support into
2012                 # the Qt PrintSupport module.
2013                 #
2014                 AC_WIRESHARK_QT_MODULE_CHECK(PrintSupport, $1)
2016                 #
2017                 # While we're at it, look for QtMacExtras.  (Presumably
2018                 # if we're not building for OS X, it won't be present.)
2019                 #
2020                 # XXX - is there anything in QtX11Extras or QtWinExtras
2021                 # that we should be using?
2022                 #
2023                 AC_WIRESHARK_QT_MODULE_CHECK(MacExtras, $1,
2024                         AC_DEFINE(QT_MACEXTRAS_LIB, 1, [Define if we have QtMacExtras]))
2026                 AC_SUBST(Qt_LIBS)
2028                 # Run Action-If-Found
2029                 ifelse([$2], , :, [$2])
2030         else
2031                 # Run Action-If-Not-Found
2032                 ifelse([$3], , :, [$3])
2033         fi
2038 # AC_WIRESHARK_PYTHON_CHECK
2040 # Check whether python devel package is present
2042 AC_DEFUN([AC_WIRESHARK_PYTHON_CHECK],
2043   [
2044     #
2045     # Checking whether we have a python devel environment available
2046     #
2047 #  AC_CACHE_CHECK([checking python devel package], ac_cv_wireshark_python_devel,
2048 #    [
2049     AC_CHECK_PROG([ac_ws_python_config], python-config, "yes", "no")
2050     if test "x$ac_ws_python_config" = "xno"; then
2051       ac_cv_wireshark_python_devel=no
2052         if test "x$want_python" = "xyes"
2053         then
2054             #
2055             # The user tried to force us to use Python, but we
2056             # couldn't find the python-config tool; report an error.
2057             #
2058             AC_MSG_ERROR("python-config not found")
2059         fi
2060         #
2061         # Set want_python to no, so we report that we aren't using
2062         # the Python interpreter.
2063         #
2064         want_python=no
2065     else
2066       AC_MSG_CHECKING([python devel])
2067       ac_save_ws_cflags=$CFLAGS
2068       ac_save_ws_libs=$LIBS
2069       CFLAGS=$(python-config --includes)
2070       LIBS=$(python-config --ldflags)
2071       AC_COMPILE_IFELSE(
2072         [
2073           AC_LANG_PROGRAM(
2074             [[#include <Python.h>]],
2075             [[Py_Initialiaze();]]
2076           )
2077         ],
2078         [
2079           #
2080           # Compilation successful, we have python devel available
2081           #
2082           ac_cv_wireshark_python_devel=yes
2083           PY_LIBS=$LIBS
2084           PY_CFLAGS=$CFLAGS
2085           AC_SUBST(PY_LIBS)
2086           AC_SUBST(PY_CFLAGS)
2087           CFLAGS="$ac_save_ws_cflags"
2088           LIBS="$ac_save_ws_libs"
2089           AC_DEFINE(HAVE_PYTHON, 1, [Define if python devel package available])
2090           AC_MSG_RESULT([yes])
2091         ],
2092         [
2093           #
2094           # Compilation unsuccessful, python devel not available
2095           #
2096           ac_cv_wireshark_python_devel=no
2097           CFLAGS=$ac_save_ws_cflags
2098           LIBS=$ac_save_ws_libs
2099           if test "x$want_python" = "xyes"
2100           then
2101             #
2102             # The user tried to force us to use Python, but we
2103             # couldn't compile the test program; report an error.
2104             #
2105             AC_MSG_ERROR("Python test program failed compilation")
2106           fi
2107           AC_MSG_RESULT([no])
2108           #
2109           # Set want_python to no, so we report that we aren't using
2110           # the Python interpreter.
2111           #
2112           want_python=no
2113         ])
2114     fi
2115 #    ])
2119 # AC_WIRESHARK_CLANG_CHECK
2121 # Check if either our C or C++ compiler is Clang
2123 AC_DEFUN([AC_WIRESHARK_CLANG_CHECK], [
2125   AC_MSG_CHECKING(if $CC is Clang)
2126   AC_COMPILE_IFELSE([
2127     AC_LANG_SOURCE([[
2128 #ifndef __clang__
2129 CC is not __clang__
2130 #endif
2131     ]])],
2132     [
2133       CC_IS_CLANG='yes'
2134       CFLAGS="$CFLAGS -Qunused-arguments"
2135     ],
2136     CC_IS_CLANG='no'
2137     )
2138   AC_MSG_RESULT("$CC_IS_CLANG")
2140   AC_MSG_CHECKING(if $CXX is Clang)
2141   AC_LANG_PUSH([C++])
2142   AC_COMPILE_IFELSE([
2143     AC_LANG_SOURCE([[
2144 #ifndef __clang__
2145 CXX is not __clang__
2146 #endif
2147     ]])],
2148     [
2149       CXX_IS_CLANG='yes'
2150       CXXFLAGS="$CXXFLAGS -Qunused-arguments"
2151     ],
2152     CXX_IS_CLANG='no'
2153     )
2154   AC_LANG_POP([C++])
2155   AC_MSG_RESULT("$CXX_IS_CLANG")