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