More warining fixes: char -> const char
[obnox/wireshark/wip.git] / acinclude.m4
1 dnl Macros that test for specific features.
2 dnl This file is part of the Autoconf packaging for Ethereal.
3 dnl Copyright (C) 1998-2000 by Gerald Combs.
4 dnl
5 dnl $Id$
6 dnl
7 dnl This program is free software; you can redistribute it and/or modify
8 dnl it under the terms of the GNU General Public License as published by
9 dnl the Free Software Foundation; either version 2, or (at your option)
10 dnl any later version.
11 dnl
12 dnl This program is distributed in the hope that it will be useful,
13 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 dnl GNU General Public License for more details.
16 dnl
17 dnl You should have received a copy of the GNU General Public License
18 dnl along with this program; if not, write to the Free Software
19 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 dnl 02111-1307, USA.
21 dnl
22 dnl As a special exception, the Free Software Foundation gives unlimited
23 dnl permission to copy, distribute and modify the configure scripts that
24 dnl are the output of Autoconf.  You need not follow the terms of the GNU
25 dnl General Public License when using or distributing such scripts, even
26 dnl though portions of the text of Autoconf appear in them.  The GNU
27 dnl General Public License (GPL) does govern all other use of the material
28 dnl that constitutes the Autoconf program.
29 dnl
30 dnl Certain portions of the Autoconf source text are designed to be copied
31 dnl (in certain cases, depending on the input) into the output of
32 dnl Autoconf.  We call these the "data" portions.  The rest of the Autoconf
33 dnl source text consists of comments plus executable code that decides which
34 dnl of the data portions to output in any given case.  We call these
35 dnl comments and executable code the "non-data" portions.  Autoconf never
36 dnl copies any of the non-data portions into its output.
37 dnl
38 dnl This special exception to the GPL applies to versions of Autoconf
39 dnl released by the Free Software Foundation.  When you make and
40 dnl distribute a modified version of Autoconf, you may extend this special
41 dnl exception to the GPL to apply to your modified version as well, *unless*
42 dnl your modified version has the potential to copy into its output some
43 dnl of the text that was the non-data portion of the version that you started
44 dnl with.  (In other words, unless your change moves or copies text from
45 dnl the non-data portions to the data portions.)  If your modification has
46 dnl such potential, you must delete any notice of this special exception
47 dnl to the GPL from your modified version.
48 dnl
49 dnl Written by David MacKenzie, with help from
50 dnl Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
51 dnl Roland McGrath, Noah Friedman, david d zuhn, and many others.
52
53 #
54 # AC_ETHEREAL_ADD_DASH_L
55 #
56 # Add to the variable specified as the first argument a "-L" flag for the
57 # directory specified as the second argument, and, on Solaris, add a
58 # "-R" flag for it as well.
59 #
60 # XXX - IRIX, and other OSes, may require some flag equivalent to
61 # "-R" here.
62 #
63 AC_DEFUN([AC_ETHEREAL_ADD_DASH_L],
64 [$1="$$1 -L$2"
65 case "$host_os" in
66   solaris*)
67     $1="$$1 -R$2"
68   ;;
69 esac
70 ])
71
72
73 #
74 # AC_ETHEREAL_STRUCT_SA_LEN
75 #
76 dnl AC_STRUCT_ST_BLKSIZE extracted from the file in question,
77 dnl "acspecific.m4" in GNU Autoconf 2.12, and turned into
78 dnl AC_ETHEREAL_STRUCT_SA_LEN, which checks if "struct sockaddr"
79 dnl has the 4.4BSD "sa_len" member, and defines HAVE_SA_LEN; that's
80 dnl what's in this file.
81 dnl Done by Guy Harris <guy@alum.mit.edu> on 1998-11-14. 
82
83 dnl ### Checks for structure members
84
85 AC_DEFUN([AC_ETHEREAL_STRUCT_SA_LEN],
86 [AC_CACHE_CHECK([for sa_len in struct sockaddr], ac_cv_ethereal_struct_sa_len,
87 [AC_TRY_COMPILE([#include <sys/types.h>
88 #include <sys/socket.h>], [struct sockaddr s; s.sa_len;],
89 ac_cv_ethereal_struct_sa_len=yes, ac_cv_ethereal_struct_sa_len=no)])
90 if test $ac_cv_ethereal_struct_sa_len = yes; then
91   AC_DEFINE(HAVE_SA_LEN, 1, [Define if sa_len field exists in struct sockaddr])
92 fi
93 ])
94
95
96 dnl
97 dnl Check whether a given format can be used to print 64-bit integers
98 dnl
99 AC_DEFUN([AC_ETHEREAL_CHECK_64BIT_FORMAT],
100 [
101   AC_MSG_CHECKING([whether %$1x can be used to format 64-bit integers])
102   AC_RUN_IFELSE(
103     [
104       AC_LANG_SOURCE(
105         [[
106 #         ifdef HAVE_INTTYPES_H
107           #include <inttypes.h>
108 #         endif
109           #include <glibconfig.h>
110           #include <stdio.h>
111           #include <sys/types.h>
112
113           main()
114           {
115             guint64 t = 1;
116             char strbuf[16+1];
117             sprintf(strbuf, "%016$1x", t << 32);
118             if (strcmp(strbuf, "0000000100000000") == 0)
119               exit(0);
120             else
121               exit(1);
122           }
123         ]])
124     ],
125     [
126       AC_DEFINE(PRId64, "$1d", [Format for printing 64-bit signed decimal numbers])
127       AC_DEFINE(PRIo64, "$1o", [Format for printing 64-bit unsigned octal numbers])
128       AC_DEFINE(PRIx64, "$1x", [Format for printing 64-bit unsigned hexadecimal numbers])
129       AC_DEFINE(PRIu64, "$1u", [Format for printing 64-bit unsigned decimal numbers])
130       AC_MSG_RESULT(yes)
131     ],
132     [
133       AC_MSG_RESULT(no)
134       $2
135     ])
136 ])
137
138 #
139 # AC_ETHEREAL_IPV6_STACK
140 #
141 # By Jun-ichiro "itojun" Hagino, <itojun@iijlab.net>
142 #
143 AC_DEFUN([AC_ETHEREAL_IPV6_STACK],
144 [
145         v6type=unknown
146         v6lib=none
147
148         AC_MSG_CHECKING([ipv6 stack type])
149         for i in v6d toshiba kame inria zeta linux linux-glibc solaris8; do
150                 case $i in
151                 v6d)
152                         AC_EGREP_CPP(yes, [
153 #include </usr/local/v6/include/sys/types.h>
154 #ifdef __V6D__
155 yes
156 #endif],
157                                 [v6type=$i; v6lib=v6;
158                                 v6libdir=/usr/local/v6/lib;
159                                 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
160                         ;;
161                 toshiba)
162                         AC_EGREP_CPP(yes, [
163 #include <sys/param.h>
164 #ifdef _TOSHIBA_INET6
165 yes
166 #endif],
167                                 [v6type=$i; v6lib=inet6;
168                                 v6libdir=/usr/local/v6/lib;
169                                 CFLAGS="-DINET6 $CFLAGS"])
170                         ;;
171                 kame)
172                         AC_EGREP_CPP(yes, [
173 #include <netinet/in.h>
174 #ifdef __KAME__
175 yes
176 #endif],
177                                 [v6type=$i; v6lib=inet6;
178                                 v6libdir=/usr/local/v6/lib;
179                                 CFLAGS="-DINET6 $CFLAGS"])
180                         ;;
181                 inria)
182                         AC_EGREP_CPP(yes, [
183 #include <netinet/in.h>
184 #ifdef IPV6_INRIA_VERSION
185 yes
186 #endif],
187                                 [v6type=$i; CFLAGS="-DINET6 $CFLAGS"])
188                         ;;
189                 zeta)
190                         AC_EGREP_CPP(yes, [
191 #include <sys/param.h>
192 #ifdef _ZETA_MINAMI_INET6
193 yes
194 #endif],
195                                 [v6type=$i; v6lib=inet6;
196                                 v6libdir=/usr/local/v6/lib;
197                                 CFLAGS="-DINET6 $CFLAGS"])
198                         ;;
199                 linux)
200                         if test -d /usr/inet6; then
201                                 v6type=$i
202                                 v6lib=inet6
203                                 v6libdir=/usr/inet6
204                                 CFLAGS="-DINET6 $CFLAGS"
205                         fi
206                         ;;
207                 linux-glibc)
208                         AC_EGREP_CPP(yes, [
209 #include <features.h>
210 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
211 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || __GLIBC__ > 2
212 yes
213 #endif
214 #endif],
215                         [v6type=$i; v6lib=inet6; CFLAGS="-DINET6 $CFLAGS"])
216                         ;;
217                 solaris8)
218                         if test "`uname -s`" = "SunOS" && test "`uname -r`" = "5.8"; then
219                                 v6type=$i
220                                 v6lib=inet6
221                                 [CFLAGS="-DINET6 -DSOLARIS8_INET6 $CFLAGS"]
222                         fi
223                         ;; 
224                 esac
225                 if test "$v6type" != "unknown"; then
226                         break
227                 fi
228         done
229
230         if test "$v6lib" != "none"; then
231                 for dir in $v6libdir /usr/local/v6/lib /usr/local/lib; do
232                         if test -d $dir -a -f $dir/lib$v6lib.a; then
233                                 LIBS="-L$dir $LIBS -l$v6lib"
234                                 break
235                         fi
236                 done
237                 enable_ipv6="yes"
238         else
239                 enable_ipv6="no"
240         fi
241         AC_MSG_RESULT(["$v6type, $v6lib"])
242 ])
243
244 #
245 # AC_ETHEREAL_GETHOSTBY_LIB_CHECK
246 #
247 # Checks whether we need "-lnsl" to get "gethostby*()", which we use
248 # in "resolv.c".
249 #
250 # Adapted from stuff in the AC_PATH_XTRA macro in "acspecific.m4" in
251 # GNU Autoconf 2.13; the comment came from there.
252 # Done by Guy Harris <guy@alum.mit.edu> on 2000-01-14. 
253 #
254 AC_DEFUN([AC_ETHEREAL_GETHOSTBY_LIB_CHECK],
255 [
256     # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
257     # to get the SysV transport functions.
258     # chad@anasazi.com says the Pyramid MIS-ES running DC/OSx (SVR4)
259     # needs -lnsl.
260     # The nsl library prevents programs from opening the X display
261     # on Irix 5.2, according to dickey@clark.net.
262     AC_CHECK_FUNC(gethostbyname, ,
263         AC_CHECK_LIB(nsl, gethostbyname, NSL_LIBS="-lnsl"))
264     AC_SUBST(NSL_LIBS)
265 ])
266
267 #
268 # AC_ETHEREAL_SOCKET_LIB_CHECK
269 #
270 # Checks whether we need "-lsocket" to get "socket()", which is used
271 # by libpcap on some platforms - and, in effect, "gethostby*()" on
272 # most if not all platforms (so that it can use NIS or DNS or...
273 # to look up host names).
274 #
275 # Adapted from stuff in the AC_PATH_XTRA macro in "acspecific.m4" in
276 # GNU Autoconf 2.13; the comment came from there.
277 # Done by Guy Harris <guy@alum.mit.edu> on 2000-01-14. 
278 #
279 # We use "connect" because that's what AC_PATH_XTRA did.
280 #
281 AC_DEFUN([AC_ETHEREAL_SOCKET_LIB_CHECK],
282 [
283     # lieder@skyler.mavd.honeywell.com says without -lsocket,
284     # socket/setsockopt and other routines are undefined under SCO ODT
285     # 2.0.  But -lsocket is broken on IRIX 5.2 (and is not necessary
286     # on later versions), says simon@lia.di.epfl.ch: it contains
287     # gethostby* variants that don't use the nameserver (or something).
288     # -lsocket must be given before -lnsl if both are needed.
289     # We assume that if connect needs -lnsl, so does gethostbyname.
290     AC_CHECK_FUNC(connect, ,
291       AC_CHECK_LIB(socket, connect, SOCKET_LIBS="-lsocket",
292                 AC_MSG_ERROR(Function 'socket' not found.), $NSL_LIBS))
293     AC_SUBST(SOCKET_LIBS)
294 ])
295
296 #
297 # AC_ETHEREAL_PCAP_CHECK
298 #
299 AC_DEFUN([AC_ETHEREAL_PCAP_CHECK],
300 [
301         if test -z "$pcap_dir"
302         then
303           # Pcap header checks
304           # XXX need to set a var AC_CHECK_HEADER(pcap.h,,)
305
306           #
307           # The user didn't specify a directory in which libpcap resides;
308           # we assume that the current library search path will work,
309           # but we may have to look for the header in a "pcap"
310           # subdirectory of "/usr/include" or "/usr/local/include",
311           # as some systems apparently put "pcap.h" in a "pcap"
312           # subdirectory, and we also check "$prefix/include" - and
313           # "$prefix/include/pcap", in case $prefix is set to
314           # "/usr/include" or "/usr/local/include".
315           #
316           # XXX - should we just add "$prefix/include" to the include
317           # search path and "$prefix/lib" to the library search path?
318           #
319           AC_MSG_CHECKING(for extraneous pcap header directories)
320           found_pcap_dir=""
321           pcap_dir_list="/usr/include/pcap $prefix/include/pcap $prefix/include"
322           if test "x$ac_cv_enable_usr_local" = "xyes" ; then
323             pcap_dir_list="$pcap_dir_list /usr/local/include/pcap"
324           fi
325           for pcap_dir in $pcap_dir_list
326           do
327             if test -d $pcap_dir ; then
328                 if test x$pcap_dir != x/usr/include -a x$pcap_dir != x/usr/local/include ; then
329                     CFLAGS="$CFLAGS -I$pcap_dir"
330                     CPPFLAGS="$CPPFLAGS -I$pcap_dir"
331                 fi
332                 found_pcap_dir=" $found_pcap_dir -I$pcap_dir"
333                 break
334             fi
335           done
336
337           if test "$found_pcap_dir" != "" ; then
338             AC_MSG_RESULT(found --$found_pcap_dir added to CFLAGS)
339           else
340             AC_MSG_RESULT(not found)
341           fi
342         else
343           #
344           # The user specified a directory in which libpcap resides,
345           # so add the "include" subdirectory of that directory to
346           # the include file search path and the "lib" subdirectory
347           # of that directory to the library search path.
348           #
349           # XXX - if there's also a libpcap in a directory that's
350           # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
351           # make us find the version in the specified directory,
352           # as the compiler and/or linker will search that other
353           # directory before it searches the specified directory.
354           #
355           CFLAGS="$CFLAGS -I$pcap_dir/include"
356           CPPFLAGS="$CPPFLAGS -I$pcap_dir/include"
357           AC_ETHEREAL_ADD_DASH_L(LDFLAGS, $pcap_dir/lib)
358         fi
359
360         # Pcap header check
361         AC_CHECK_HEADER(pcap.h,, 
362             AC_MSG_ERROR([[Header file pcap.h not found; if you installed libpcap
363 from source, did you also do \"make install-incl\", and if you installed a
364 binary package of libpcap, is there also a developer's package of libpcap,
365 and did you also install that package?]]))
366
367         #
368         # Check to see if we find "pcap_open_live" in "-lpcap".
369         #
370         AC_CHECK_LIB(pcap, pcap_open_live,
371           [
372             PCAP_LIBS=-lpcap
373             AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library])
374           ], [
375             AC_MSG_CHECKING([for pcap_open_live in -lpcap -lcfg -lodm])
376             ac_save_LIBS="$LIBS"
377             LIBS="-lpcap -lcfg -lodm"
378             AC_TRY_LINK(
379                 [
380 #       include <pcap.h>
381                 ],
382                 [
383         pcap_open_live(NULL, 0, 0, 0, NULL);
384                 ],
385                 [
386                 AC_MSG_RESULT([yes])
387                 PCAP_LIBS="-lpcap -lcfg -lodm"
388                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to use libpcap library])
389                 ],
390                 [
391                 AC_MSG_RESULT([no])
392                 AC_MSG_ERROR([Library libpcap not found.])
393                 ])
394             LIBS=$ac_save_LIBS
395           ], $SOCKET_LIBS $NSL_LIBS)
396         AC_SUBST(PCAP_LIBS)
397
398         #
399         # Check whether various variables and functions are defined by
400         # libpcap.
401         #
402         ac_save_LIBS="$LIBS"
403         AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
404         LIBS="$PCAP_LIBS $SOCKET_LIBS $NSL_LIBS $LIBS"
405         AC_TRY_LINK(
406            [
407 #       include <stdio.h>
408         extern char *pcap_version;
409            ],
410            [
411         printf ("%s\n", pcap_version);
412            ],
413            ac_cv_pcap_version_defined=yes,
414            ac_cv_pcap_version_defined=no,
415            [echo $ac_n "cross compiling; assumed OK... $ac_c"])
416         if test "$ac_cv_pcap_version_defined" = yes ; then
417                 AC_MSG_RESULT(yes)
418                 AC_DEFINE(HAVE_PCAP_VERSION, 1, [Define if libpcap version is known])
419         else
420                 AC_MSG_RESULT(no)
421         fi
422         AC_CHECK_FUNCS(pcap_open_dead pcap_freecode)
423         #
424         # Later versions of Mac OS X 10.3[.x] ship a pcap.h that
425         # doesn't define pcap_if_t but ship an 0.8[.x] libpcap,
426         # so the library has "pcap_findalldevs()", but pcap.h
427         # doesn't define "pcap_if_t" so you can't actually *use*
428         # "pcap_findalldevs()".
429         #
430         # That even appears to be true of systems shipped with
431         # 10.3.4, so it doesn't appear only to be a case of
432         # Software Update not updating header files.
433         #
434         # (You can work around this by installing the 0.8 header
435         # files.)
436         #
437         AC_CACHE_CHECK([whether pcap_findalldevs is present and usable],
438           [ac_cv_func_pcap_findalldevs],
439           [
440             AC_LINK_IFELSE(
441               [
442                 AC_LANG_SOURCE(
443                   [[
444                     #include <pcap.h>
445                     main()
446                     {
447                       pcap_if_t *devpointer;
448                       char errbuf[1];
449
450                       pcap_findalldevs(&devpointer, errbuf);
451                     }
452                   ]])
453               ],
454               [
455                 ac_cv_func_pcap_findalldevs=yes
456               ],
457               [
458                 ac_cv_func_pcap_findalldevs=no
459               ])
460           ])
461         #
462         # Don't check for other new routines that showed up after
463         # "pcap_findalldevs()" if we don't have a usable
464         # "pcap_findalldevs()", so we don't end up using them if the
465         # "pcap.h" is crufty and old and doesn't declare them.
466         #
467         if test $ac_cv_func_pcap_findalldevs = "yes" ; then
468           AC_DEFINE(HAVE_PCAP_FINDALLDEVS, 1,
469            [Define to 1 if you have the `pcap_findalldevs' function and a pcap.h that declares pcap_if_t.])
470           AC_CHECK_FUNCS(pcap_datalink_val_to_name pcap_datalink_name_to_val)
471           AC_CHECK_FUNCS(pcap_list_datalinks pcap_set_datalink pcap_lib_version)
472           AC_CHECK_FUNCS(pcap_get_selectable_fd)
473         fi
474         LIBS="$ac_save_LIBS"
475 ])
476
477 #
478 # AC_ETHEREAL_ZLIB_CHECK
479 #
480 AC_DEFUN([AC_ETHEREAL_ZLIB_CHECK],
481 [
482         if test "x$zlib_dir" != "x"
483         then
484           #
485           # The user specified a directory in which zlib resides,
486           # so add the "include" subdirectory of that directory to
487           # the include file search path and the "lib" subdirectory
488           # of that directory to the library search path.
489           #
490           # XXX - if there's also a zlib in a directory that's
491           # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
492           # make us find the version in the specified directory,
493           # as the compiler and/or linker will search that other
494           # directory before it searches the specified directory.
495           #
496           ethereal_save_CFLAGS="$CFLAGS"
497           CFLAGS="$CFLAGS -I$zlib_dir/include"
498           ethereal_save_CPPFLAGS="$CPPFLAGS"
499           CPPFLAGS="$CPPFLAGS -I$zlib_dir/include"
500           ethereal_save_LIBS="$LIBS"
501           AC_ETHEREAL_ADD_DASH_L(LIBS, $zlib_dir/lib)
502         fi
503
504         #
505         # Make sure we have "zlib.h".  If we don't, it means we probably
506         # don't have zlib, so don't use it.
507         #
508         AC_CHECK_HEADER(zlib.h,,
509           [
510             if test "x$zlib_dir" != "x"
511             then
512               #
513               # The user used "--with-zlib=" to specify a directory
514               # containing zlib, but we didn't find the header file
515               # there; that either means they didn't specify the
516               # right directory or are confused about whether zlib
517               # is, in fact, installed.  Report the error and give up.
518               #
519               AC_MSG_ERROR([zlib header not found in directory specified in --with-zlib])
520             else
521               if test "x$want_zlib" = "xyes"
522               then
523                 #
524                 # The user tried to force us to use the library, but we
525                 # couldn't find the header file; report an error.
526                 #
527                 AC_MSG_ERROR(Header file zlib.h not found.)
528               else
529                 #
530                 # We couldn't find the header file; don't use the
531                 # library, as it's probably not present.
532                 #
533                 want_zlib=no
534               fi
535             fi
536           ])
537
538         if test "x$want_zlib" != "xno"
539         then
540                 #
541                 # Well, we at least have the zlib header file.
542                 #
543                 # Check for "gzgets()" in zlib, because we need it, but
544                 # some older versions of zlib don't have it.  It appears
545                 # from the zlib ChangeLog that any released version of zlib
546                 # with "gzgets()" should have the other routines we
547                 # depend on, such as "gzseek()", "gztell()", and "zError()".
548                 #
549                 # Another reason why we require "gzgets()" is that
550                 # some versions of zlib that didn't have it, such
551                 # as 1.0.8, had a bug in "gzseek()" that meant that it
552                 # doesn't work correctly on uncompressed files; this
553                 # means we cannot use version 1.0.8.  (Unfortunately,
554                 # that's the version that comes with recent X11 source,
555                 # and many people who install XFree86 on their Slackware
556                 # boxes don't realize that they should configure it to
557                 # use the native zlib rather than building and installing
558                 # the crappy old version that comes with XFree86.)
559                 #
560                 # I.e., we can't just avoid using "gzgets()", as
561                 # versions of zlib without "gzgets()" are likely to have
562                 # a broken "gzseek()".
563                 #
564                 AC_CHECK_LIB(z, gzgets,
565                 [
566                         if test "x$zlib_dir" != "x"
567                         then
568                                 #
569                                 # Put the "-I" and "-L" flags for zlib at
570                                 # the beginning of CFLAGS, CPPFLAGS, and
571                                 # LIBS.
572                                 #
573                                 LIBS=""
574                                 AC_ETHEREAL_ADD_DASH_L(LIBS, $zlib_dir/lib)
575                                 LIBS="$LIBS -lz $ethereal_save_LIBS"
576                         else
577                                 LIBS="-lz $LIBS"
578                         fi
579                         AC_DEFINE(HAVE_LIBZ, 1, [Define to use libz library])
580                 ],[
581                         if test "x$zlib_dir" != "x"
582                         then
583                                 #
584                                 # Restore the versions of CFLAGS, CPPFLAGS,
585                                 # and LIBS before we added the "-with-zlib="
586                                 # directory, as we didn't actually find
587                                 # zlib there, or didn't find a zlib that
588                                 # contains gzgets there.
589                                 #
590                                 CFLAGS="$ethereal_save_CFLAGS"
591                                 CPPFLAGS="$ethereal_save_CPPFLAGS"
592                                 LIBS="$ethereal_save_LIBS"
593                         fi
594                         want_zlib=no
595                 ])
596         fi
597
598         if test "x$want_zlib" != "xno"
599         then
600                 #
601                 # Well, we at least have the zlib header file and a zlib
602                 # with "gzgets()".
603                 #
604                 # Now check for "gzgets()" in zlib when linking with the
605                 # linker flags for GTK+ applications; people often grab
606                 # XFree86 source and build and install it on their systems,
607                 # and they appear sometimes to misconfigure XFree86 so that,
608                 # even on systems with zlib, it assumes there is no zlib,
609                 # so the XFree86 build process builds and installs its
610                 # own zlib in the X11 library directory.
611                 #
612                 # The XFree86 zlib is an older version that lacks
613                 # "gzgets()", and that's the zlib with which Ethereal
614                 # gets linked, so the build of Ethereal fails.
615                 #
616                 ac_save_CFLAGS="$CFLAGS"
617                 ac_save_LIBS="$LIBS"
618                 CFLAGS="$CFLAGS $GTK_CFLAGS"
619                 LIBS="$GTK_LIBS -lz $LIBS"
620                 AC_MSG_CHECKING([for gzgets missing when linking with X11])
621                 AC_TRY_LINK_FUNC(gzgets, AC_MSG_RESULT(no),
622                   [
623                     AC_MSG_RESULT(yes)
624                     AC_MSG_ERROR(old zlib found when linking with X11 - get rid of old zlib.)
625                   ])
626                 CFLAGS="$ac_save_CFLAGS"
627                 LIBS="$ac_save_LIBS"
628         fi
629 ])
630
631 #
632 # AC_ETHEREAL_LIBPCRE_CHECK
633 #
634 AC_DEFUN([AC_ETHEREAL_LIBPCRE_CHECK],
635 [
636         if test "x$pcre_dir" != "x"
637         then
638           #
639           # The user specified a directory in which libpcre resides,
640           # so add the "include" subdirectory of that directory to
641           # the include file search path and the "lib" subdirectory
642           # of that directory to the library search path.
643           #
644           # XXX - if there's also a libpcre in a directory that's
645           # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
646           # make us find the version in the specified directory,
647           # as the compiler and/or linker will search that other
648           # directory before it searches the specified directory.
649           #
650           ethereal_save_CFLAGS="$CFLAGS"
651           CFLAGS="$CFLAGS -I$pcre_dir/include"
652           ethereal_save_CPPFLAGS="$CPPFLAGS"
653           CPPFLAGS="$CPPFLAGS -I$pcre_dir/include"
654           ethereal_save_LIBS="$LIBS"
655           LIBS="$LIBS -lpcre"
656           ethereal_save_LDFLAGS="$LDFLAGS"
657           LDFLAGS="$LDFLAGS -L$pcre_dir/lib"
658         fi
659
660         #
661         # Make sure we have "pcre.h".  If we don't, it means we probably
662         # don't have libpcre, so don't use it.
663         #
664         AC_CHECK_HEADER(pcre.h,,
665           [
666             if test "x$pcre_dir" != "x"
667             then
668               #
669               # The user used "--with-pcre=" to specify a directory
670               # containing libpcre, but we didn't find the header file
671               # there; that either means they didn't specify the
672               # right directory or are confused about whether libpcre
673               # is, in fact, installed.  Report the error and give up.
674               #
675               AC_MSG_ERROR([libpcre header not found in directory specified in --with-pcre])
676             else
677               if test "x$want_pcre" = "xyes"
678               then
679                 #
680                 # The user tried to force us to use the library, but we
681                 # couldn't find the header file; report an error.
682                 #
683                 AC_MSG_ERROR(Header file pcre.h not found.)
684               else
685                 #
686                 # We couldn't find the header file; don't use the
687                 # library, as it's probably not present.
688                 #
689                 want_pcre=no
690               fi
691             fi
692           ])
693
694         if test "x$want_pcre" != "xno"
695         then
696                 #
697                 # Well, we at least have the pcre header file.
698                 #
699                 # We're only using standard functions from libpcre,
700                 # so we don't need to perform extra checks.
701                 #
702                 AC_CHECK_LIB(pcre, pcre_compile,
703                 [
704                         if test "x$pcre_dir" != "x"
705                         then
706                                 #
707                                 # Put the "-I" and "-L" flags for pcre at
708                                 # the beginning of CFLAGS, CPPFLAGS,
709                                 # LDFLAGS, and LIBS.
710                                 #
711                                 PCRE_LIBS="-L$pcre_dir/lib -lpcre $ethereal_save_LIBS"
712                         else
713                                 PCRE_LIBS="-lpcre"
714                         fi
715                         AC_DEFINE(HAVE_LIBPCRE, 1, [Define to use libpcre library])
716                 ],[
717                         if test "x$pcre_dir" != "x"
718                         then
719                                 #
720                                 # Restore the versions of CFLAGS, CPPFLAGS,
721                                 # LDFLAGS, and LIBS before we added the
722                                 # "--with-pcre=" directory, as we didn't
723                                 # actually find pcre there.
724                                 #
725                                 CFLAGS="$ethereal_save_CFLAGS"
726                                 CPPFLAGS="$ethereal_save_CPPFLAGS"
727                                 LDFLAGS="$ethereal_save_LDFLAGS"
728                                 LIBS="$ethereal_save_LIBS"
729                                 PCRE_LIBS=""
730                         fi
731                         want_pcre=no
732                 ])
733                 AC_SUBST(PCRE_LIBS)
734         fi
735 ])
736
737 #
738 # AC_ETHEREAL_NETSNMP_CHECK
739 #
740 AC_DEFUN([AC_ETHEREAL_NETSNMP_CHECK],
741 [
742         dnl get the net-snmp-config binary
743         if test "x$netsnmpconfig" = "x" ; then
744                 #
745                 # The user didn't specify where net-snmp-config is
746                 # located; search for it.
747                 #
748                 AC_PATH_PROG(NETSNMPCONFIG, net-snmp-config)
749         else
750                 NETSNMPCONFIG=$netsnmpconfig
751                 if test ! -x $NETSNMPCONFIG -o ! -f $NETSNMPCONFIG ; then
752                         NETSNMPCONFIG=$netsnmpconfig/bin/net-snmp-config
753                         if test ! -x $NETSNMPCONFIG -o ! -f $NETSNMPCONFIG ; then
754                                 AC_MSG_ERROR(Invalid net-snmp-config: $netsnmpconfig)
755                         fi
756                 fi
757         fi
758
759         #
760         # XXX - check whether $NETSNMPCONFIG is executable?
761         # if test "x$NETSNMPCONFIG" != "xno" -a "x$NETSNMPCONFIG" != "x" -a -x "$NETSNMPCONFIG" ; then
762         # We already did that if it was set; presumably AC_PATH_PROG
763         # will fail if it doesn't find an executable version.
764         #
765         if test "x$NETSNMPCONFIG" != "x" ; then
766                 dnl other choices for flags to use here: could also use
767                 dnl --prefix or --exec-prefix if you don't want the full list.
768
769                 #
770                 # Save the current settings of CFLAGS and CPPFLAGS, and add
771                 # the output of "$NETSNMPCONFIG --cflags" to it, so that when
772                 # searching for the Net-SNMP headers, we look in whatever
773                 # directory that output specifies.
774                 #
775                 ethereal_save_CFLAGS="$CFLAGS"
776                 ethereal_save_CPPFLAGS="$CPPFLAGS"
777                 CFLAGS="$CFLAGS `$NETSNMPCONFIG --cflags`"
778                 CPPFLAGS="$CPPFLAGS `$NETSNMPCONFIG --cflags`"
779
780                 AC_CHECK_HEADERS(net-snmp/net-snmp-config.h net-snmp/library/default_store.h)
781                 if test "x$ac_cv_header_net_snmp_net_snmp_config_h" = "xyes" -a "x$ac_cv_header_net_snmp_library_default_store_h" = "xyes" ; then
782                         SNMP_LIBS=`$NETSNMPCONFIG --libs`
783                         if echo "$SNMP_LIBS" | grep crypto >/dev/null  && test "x$SSL_LIBS" = "x"; then
784                                 if test "x$want_netsnmp" = "xyes" ; then
785                                         AC_MSG_ERROR(Net-SNMP requires openssl but ssl not enabled)
786                                 else
787                                         AC_MSG_RESULT(Net-SNMP requires openssl but ssl not enabled - disabling Net-SNMP)
788                                 fi
789                                 CFLAGS="$ethereal_save_CFLAGS"
790                                 CPPFLAGS="$ethereal_save_CPPFLAGS"
791                                 SNMP_LIBS=
792                         else
793                                 AC_DEFINE(HAVE_NET_SNMP, 1, [Define to enable support for Net-SNMP])
794                                 have_net_snmp="yes"
795                         fi
796                 else
797                         if test "x$want_netsnmp" = "xyes" ; then
798                                 AC_MSG_ERROR(Net-SNMP not found)
799                         else
800                                 #
801                                 # Restore the versions of CFLAGS and
802                                 # CPPFLAGS before we added the output
803                                 # of '$NETSNMPCONFIG --cflags", as we
804                                 # didn't actually find Net-SNMP there.
805                                 #
806                                 CFLAGS="$ethereal_save_CFLAGS"
807                                 CPPFLAGS="$ethereal_save_CPPFLAGS"
808                         fi
809                 fi
810         fi      
811 ])
812
813 #
814 # AC_ETHEREAL_UCDSNMP_CHECK
815 #
816 AC_DEFUN([AC_ETHEREAL_UCDSNMP_CHECK],
817 [
818         if test "x$ucdsnmp_dir" != "x"
819         then
820                 #
821                 # The user specified a directory in which UCD SNMP resides,
822                 # so add the "include" subdirectory of that directory to
823                 # the include file search path and the "lib" subdirectory
824                 # of that directory to the library search path.
825                 #
826                 # XXX - if there's also a libpcap in a directory that's
827                 # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
828                 # make us find the version in the specified directory,
829                 # as the compiler and/or linker will search that other
830                 # directory before it searches the specified directory.
831                 #
832                 CFLAGS="$CFLAGS -I$ucdsnmp_dir/include"
833                 CPPFLAGS="$CPPFLAGS -I$ucdsnmp_dir/include"
834                 AC_ETHEREAL_ADD_DASH_L(LDFLAGS, $ucdsnmp_dir/lib)
835         fi
836
837         #
838         # Check for one of the UCD SNMP header files we include,
839         # to see whether we have UCD SNMP installed.
840         #
841         AC_CHECK_HEADER(ucd-snmp/ucd-snmp-config.h,
842         [
843                 #
844                 # UCD SNMP or Net-SNMP might require various helper
845                 # libraries on various platforms, such as "-ldes425"
846                 # in "/usr/kerberos/lib" on some versions of Red
847                 # Hat Linux, or "-lkstat" on Solaris.
848                 #
849                 # It might also require "-lcrypto" on some platforms;
850                 # if the user didn't specify --with-ssl, we check
851                 # whether it would have made a difference and, if so,
852                 # we tell the user that they needed to request it.
853                 # (There are annoying licensing issues with it and
854                 # GPL'ed code, so we don't include it by default.)
855                 #
856                 # XXX - autoconf really needs a way to test for
857                 # a given routine in a given library *and* to test
858                 # whether additional "-L"/"-R"/whatever flags are
859                 # needed *before* the "-l" flag for the library
860                 # and to test whether additional libraries are
861                 # needed after the library *and* to cache all that
862                 # information.
863                 #
864                 ethereal_save_LIBS="$LIBS"
865                 found_sprint_realloc_objid=no
866                 for extras in "" "-L/usr/kerberos/lib -ldes425" "-lkstat"
867                 do
868                         LIBS="-lsnmp $extras $SOCKET_LIBS $NSL_LIBS $SSL_LIBS"
869                         if test -z "$extras"
870                         then
871                                 AC_MSG_CHECKING([whether UCD SNMP includes sprint_realloc_objid])
872                         else
873                                 AC_MSG_CHECKING([whether UCD SNMP includes sprint_realloc_objid (linking with $extras)])
874                         fi
875                         AC_TRY_LINK(
876                             [
877                             ],
878                             [
879                                 sprint_realloc_objid();
880                             ],
881                             [
882                                 #
883                                 # We found "sprint_realloc_objid()",
884                                 # and required the libraries in
885                                 # extras as well.
886                                 #
887                                 AC_MSG_RESULT(yes)
888                                 SNMP_LIBS="-lsnmp $extras"; break;
889                                 found_sprint_realloc_objid=yes
890                                 break
891                             ],
892                             [
893                                 #
894                                 # The link failed.  If they didn't ask
895                                 # for SSL, try linking with -lcrypto
896                                 # as well, and if *that* succeeds,
897                                 # tell them they'll need to specify
898                                 # --want-ssl.
899                                 #
900                                 AC_MSG_RESULT(no)
901                                 if test "x$want_ssl" = "xno"
902                                 then
903                                         LIBS="$LIBS -lcrypto"
904                                         AC_TRY_LINK(
905                                             [
906                                             ],
907                                             [
908                                                 sprint_realloc_objid();
909                                             ],
910                                             [
911                                                 #
912                                                 # It worked with -lcrypto; tell
913                                                 # them they'll need to specify
914                                                 # --with-ssl.
915                                                 #
916                                                 AC_MSG_ERROR([UCD SNMP requires -lcrypto but --with-ssl not specified])
917                                             ])
918                                 fi
919                             ])
920                 done
921                 LIBS="$ethereal_save_LIBS"
922
923                 #
924                 # If we didn't find "sprint_realloc_objid()", fail.
925                 # Either the user needs a newer version of UCD SNMP
926                 # with "sprint_realloc_objid()", or they may need to
927                 # specify "--with-ssl".
928                 #
929                 if test "$found_snmp_sprint_realloc_objid" = no; then
930                     AC_MSG_ERROR([UCD SNMP header files found, but sprint_realloc_objid not found in SNMP library.])
931                 fi
932
933                 #
934                 # We found it, so we have UCD SNMP.
935                 #
936                 AC_DEFINE(HAVE_UCD_SNMP, 1, [Define to enable support for UCD-SNMP])
937                 have_ucd_snmp="yes"
938         ],[
939                 #
940                 # No, we don't have it.
941                 # If the user explicitly asked for UCD SNMP, fail,
942                 # otherwise just don't use the UCD SNMP library.
943                 #
944                 if test "x$want_ucdsnmp" = "xyes" ; then
945                         AC_MSG_ERROR(Header file ucd-snmp/snmp.h not found.)
946                 fi
947         ])
948 ])
949
950 #
951 # AC_ETHEREAL_RPM_CHECK
952 # Looks for the rpm program, and checks to see if we can redefine "_topdir".
953 #
954 AC_DEFUN([AC_ETHEREAL_RPM_CHECK],
955 [
956         AC_CHECK_PROG(ac_cv_ethereal_have_rpm, rpm, "yes", "no")
957         if test "x$ac_cv_ethereal_have_rpm" = "xyes"; then
958                 rpm --define '_topdir /tmp' > /dev/null 2>&1
959                 AC_MSG_CHECKING(to see if we can redefine _topdir)
960                 if test $? -eq 0 ; then
961                         AC_MSG_RESULT(yes)
962                         HAVE_RPM=yes
963                 else
964                         AC_MSG_RESULT(no.  You'll have to build packages manually.)
965                         HAVE_RPM=no
966                 fi
967         fi
968 ])
969
970 #
971 # AC_ETHEREAL_GNU_SED_CHECK
972 # Checks if GNU sed is the first sed in PATH.
973 #
974 AC_DEFUN([AC_ETHEREAL_GNU_SED_CHECK],
975 [
976         AC_MSG_CHECKING(for GNU sed as first sed in PATH)
977         if  ( sh -c "sed --version" </dev/null 2> /dev/null | grep "GNU sed" 2>&1 > /dev/null ) ;  then
978                 AC_MSG_RESULT(yes)
979                 HAVE_GNU_SED=yes
980         else
981                 AC_MSG_RESULT(no)
982                 HAVE_GNU_SED=no
983         fi
984 ])
985
986 #
987 # AC_ETHEREAL_ADNS_CHECK
988 #
989 AC_DEFUN([AC_ETHEREAL_ADNS_CHECK],
990 [
991         want_adns=defaultyes
992
993         if test "x$want_adns" = "xdefaultyes"; then
994                 want_adns=yes
995                 withval=/usr/local
996                 if test -d "$withval"; then
997                         AC_ETHEREAL_ADD_DASH_L(LDFLAGS, ${withval}/lib)
998                 fi
999         fi
1000
1001         if test "x$want_adns" = "xyes"; then
1002                 AC_CHECK_LIB(adns, adns_init,
1003                   [
1004                     ADNS_LIBS=-ladns
1005                 AC_DEFINE(HAVE_GNU_ADNS, 1, [Define to use GNU ADNS library])
1006                 have_good_adns=yes
1007                   ],, $SOCKET_LIBS $NSL_LIBS
1008                 )
1009         else
1010                 AC_MSG_RESULT(not required)
1011         fi
1012 ])
1013
1014
1015 #
1016 # AC_ETHEREAL_KRB5_CHECK
1017 #
1018 AC_DEFUN([AC_ETHEREAL_KRB5_CHECK],
1019 [
1020         ethereal_save_CFLAGS="$CFLAGS"
1021         ethereal_save_CPPFLAGS="$CPPFLAGS"
1022         if test "x$krb5_dir" != "x"
1023         then
1024           #
1025           # The user specified a directory in which kerberos resides,
1026           # so add the "include" subdirectory of that directory to
1027           # the include file search path and the "lib" subdirectory
1028           # of that directory to the library search path.
1029           #
1030           # XXX - if there's also a kerberos in a directory that's
1031           # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
1032           # make us find the version in the specified directory,
1033           # as the compiler and/or linker will search that other
1034           # directory before it searches the specified directory.
1035           #
1036           CFLAGS="$CFLAGS -I$krb5_dir/include"
1037           CPPFLAGS="$CPPFLAGS -I$krb5_dir/include"
1038           ac_heimdal_version=`grep heimdal $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*heimdal.*$/HEIMDAL/'`
1039           ac_mit_version=`grep 'Massachusetts Institute of Technology' $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*Massachusetts Institute of Technology.*$/MIT/'`
1040           ac_krb5_version="$ac_heimdal_version$ac_mit_version"
1041           if test "x$ac_krb5_version" = "xHEIMDAL"
1042               KRB5_LIBS="-L$krb5_dir/lib -lkrb5 -lasn1 $SSL_LIBS -lroken -lcrypt"
1043           then
1044               KRB5_LIBS="-L$krb5_dir/lib -lkrb5 -lk5crypto -lcom_err"
1045           fi
1046           if test "x$ac_krb5_version" = "xMIT"
1047           then
1048             AC_DEFINE(HAVE_MIT_KERBEROS, 1, [Define to use MIT kerberos])
1049           fi
1050         else
1051           AC_PATH_PROG(KRB5_CONFIG, krb5-config) 
1052           if test -x "$KRB5_CONFIG"
1053           then
1054             KRB5_FLAGS=`"$KRB5_CONFIG" --cflags`
1055             KRB5_LIBS=`"$KRB5_CONFIG" --libs`
1056             CFLAGS="$CFLAGS $KRB5_FLAGS"
1057             CPPFLAGS="$CPPFLAGS $KRB5_FLAGS"
1058             #
1059             # If -lcrypto is in KRB5_FLAGS, we require it to build
1060             # with Heimdal/MIT.  We don't want to built with it by
1061             # default, due to annoying license incompatibilities
1062             # between the OpenSSL license and the GPL, so:
1063             #
1064             #   if SSL_LIBS is set to a non-empty string, we
1065             #   remove -lcrypto from KRB5_LIBS and replace
1066             #   it with SSL_LIBS;
1067             #
1068             #   if SSL_LIBS is not set to a non-empty string
1069             #   we fail with an appropriate error message.
1070             #
1071             case "$KRB5_LIBS" in
1072             *-lcrypto*)
1073                 if test ! -z "$SSL_LIBS"
1074                 then
1075                     KRB5_LIBS=`echo $KRB5_LIBS | sed 's/-lcrypto//'`
1076                     KRB5_LIBS="$KRB5_LIBS $SSL_LIBS"
1077                 else
1078                     AC_MSG_ERROR([Kerberos library requires -lcrypto but --with-ssl not specified])
1079                 fi
1080                 ;;
1081             esac
1082             ac_krb5_version=`"$KRB5_CONFIG" --version | head -n 1 | sed -e 's/^.*heimdal.*$/HEIMDAL/' -e 's/^Kerberos .*$/MIT/'`
1083           fi
1084         fi
1085
1086         #
1087         # Make sure we have "krb5.h".  If we don't, it means we probably
1088         # don't have kerberos, so don't use it.
1089         #
1090         AC_CHECK_HEADER(krb5.h,,
1091           [
1092             if test "x$krb5_dir" != "x"
1093             then
1094               #
1095               # The user used "--with-krb5=" to specify a directory
1096               # containing kerberos, but we didn't find the header file
1097               # there; that either means they didn't specify the
1098               # right directory or are confused about whether kerberos
1099               # is, in fact, installed.  Report the error and give up.
1100               #
1101               AC_MSG_ERROR([kerberos header not found in directory specified in --with-krb5])
1102             else
1103               if test "x$want_krb5" = "xyes"
1104               then
1105                 #
1106                 # The user tried to force us to use the library, but we
1107                 # couldn't find the header file; report an error.
1108                 #
1109                 AC_MSG_ERROR(Header file krb5.h not found.)
1110               else
1111                 #
1112                 # We couldn't find the header file; don't use the
1113                 # library, as it's probably not present.
1114                 #
1115                 want_krb5=no
1116                 AC_MSG_RESULT(No Heimdal or MIT header found - disabling dissection for some kerberos data in packet decoding)
1117               fi
1118             fi
1119           ])
1120
1121         if test "x$want_krb5" != "xno"
1122         then
1123             #
1124             # Well, we at least have the krb5 header file.
1125             # Check whether this is Heimdal or MIT.
1126             #
1127             AC_MSG_CHECKING(whether the Kerberos library is Heimdal or MIT)
1128             if test "x$ac_krb5_version" = "xHEIMDAL" -o "x$ac_krb5_version" = "xMIT"
1129             then
1130                 #
1131                 # Yes.
1132                 # Check whether we have krb5_kt_resolve - and whether
1133                 # we need to link with -lresolv when linking with
1134                 # the Kerberos library.
1135                 #
1136                 AC_MSG_RESULT($ac_krb5_version)
1137                 ethereal_save_LIBS="$LIBS"
1138                 found_krb5_kt_resolve=no
1139                 for extras in "" "-lresolv"
1140                 do
1141                     LIBS="$KRB5_LIBS $extras"
1142                     if test -z "$extras"
1143                     then
1144                         AC_MSG_CHECKING([whether $ac_krb5_version includes krb5_kt_resolve])
1145                     else
1146                         AC_MSG_CHECKING([whether $ac_krb5_version includes krb5_kt_resolve (linking with $extras)])
1147                     fi
1148                     AC_TRY_LINK(
1149                         [
1150                         ],
1151                         [
1152                             krb5_kt_resolve();
1153                         ],
1154                         [
1155                             #
1156                             # We found "krb5_kt_resolve()", and required
1157                             # the libraries in extras as well.
1158                             #
1159                             AC_MSG_RESULT(yes)
1160                             KRB5_LIBS="$LIBS"
1161                             AC_DEFINE(HAVE_KERBEROS, 1, [Define to use kerberos])
1162                             if test "x$ac_krb5_version" = "xHEIMDAL"
1163                             then
1164                                 AC_DEFINE(HAVE_HEIMDAL_KERBEROS, 1, [Define to use heimdal kerberos])
1165                             elif test "x$ac_krb5_version" = "xMIT"
1166                             then
1167                                 AC_DEFINE(HAVE_MIT_KERBEROS, 1, [Define to use MIT kerberos])
1168                             fi
1169                             found_krb5_kt_resolve=yes
1170                             break
1171                         ],
1172                         [
1173                             AC_MSG_RESULT(no)
1174                         ])
1175                 done
1176                 if test "$found_krb5_kt_resolve" = no
1177                 then
1178                     #
1179                     # We didn't find "krb5_kt_resolve()" in the
1180                     # Kerberos library, even when we tried linking
1181                     # with -lresolv; we can't link with kerberos.
1182                     #
1183                     if test "x$want_krb5" = "xyes"
1184                     then
1185                         #
1186                         # The user tried to force us to use the library,
1187                         # but we can't do so; report an error.
1188                         #
1189                         AC_MSG_ERROR(Usable $ac_krb5_version not found)
1190                     else
1191                         #
1192                         # Restore the versions of CFLAGS and CPPFLAGS
1193                         # from before we added the flags for Kerberos.
1194                         #
1195                         AC_MSG_RESULT(Usable $ac_krb5_version not found - disabling dissection for some kerberos data in packet decoding)
1196                         CFLAGS="$ethereal_save_CFLAGS"
1197                         CPPFLAGS="$ethereal_save_CPPFLAGS"
1198                         KRB5_LIBS=""
1199                         want_krb5=no
1200                     fi
1201                 else
1202                     #
1203                     # We can link with Kerberos; see whether krb5.h
1204                     # defines KEYTYPE_ARCFOUR_56 (where "defines" means
1205                     # "as a #define or as an enum member).
1206                     #
1207                     AC_MSG_CHECKING([whether krb5.h defines KEYTYPE_ARCFOUR_56])
1208                     AC_COMPILE_IFELSE(
1209                       [
1210                         AC_LANG_SOURCE(
1211                           [[
1212                             #include <krb5.h>
1213                             #include <stdio.h>
1214
1215                             main()
1216                             {
1217                               printf("%u\n", KEYTYPE_ARCFOUR_56);
1218                             }
1219                           ]])
1220                       ],
1221                       [
1222                         AC_MSG_RESULT(yes)
1223                         AC_DEFINE(HAVE_KEYTYPE_ARCFOUR_56, 1, [Define if krb5.h defines KEYTYPE_ARCFOUR_56])
1224                       ],
1225                       [
1226                         AC_MSG_RESULT(no)
1227                       ])
1228                 fi
1229                 LIBS="$ethereal_save_LIBS"
1230             else
1231                 #
1232                 # It's not Heimdal or MIT.
1233                 #
1234                 AC_MSG_RESULT(no)
1235                 if test "x$want_krb5" = "xyes"
1236                 then
1237                     #
1238                     # The user tried to force us to use the library,
1239                     # but we can't do so; report an error.
1240                     #
1241                     AC_MSG_ERROR(Kerberos not found)
1242                 else
1243                     #
1244                     # Restore the versions of CFLAGS and CPPFLAGS
1245                     # from before we added the flags for Kerberos.
1246                     #
1247                     AC_MSG_RESULT(Kerberos not found - disabling dissection for some kerberos data in packet decoding)
1248                     CFLAGS="$ethereal_save_CFLAGS"
1249                     CPPFLAGS="$ethereal_save_CPPFLAGS"
1250                     KRB5_LIBS=""
1251                     want_krb5=no
1252                 fi
1253             fi
1254         else
1255             #
1256             # The user asked us not to use Kerberos, or they didn't
1257             # say whether they wanted us to use it but we found
1258             # that we couldn't.
1259             #
1260             # Restore the versions of CFLAGS and CPPFLAGS
1261             # from before we added the flags for Kerberos.
1262             #
1263             CFLAGS="$ethereal_save_CFLAGS"
1264             CPPFLAGS="$ethereal_save_CPPFLAGS"
1265             KRB5_LIBS=""
1266             want_krb5=no
1267         fi
1268         AC_SUBST(KRB5_LIBS)
1269 ])