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