import cyrus-sasl-2.1.23
[cyrus-sasl.git] / aclocal.m4
1 # generated automatically by aclocal 1.7.9 -*- Autoconf -*-
2
3 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
4 # Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 # Do all the work for Automake.                            -*- Autoconf -*-
15
16 # This macro actually does too much some checks are only needed if
17 # your package does certain things.  But this isn't really a big deal.
18
19 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
20 # Free Software Foundation, Inc.
21
22 # This program is free software; you can redistribute it and/or modify
23 # it under the terms of the GNU General Public License as published by
24 # the Free Software Foundation; either version 2, or (at your option)
25 # any later version.
26
27 # This program is distributed in the hope that it will be useful,
28 # but WITHOUT ANY WARRANTY; without even the implied warranty of
29 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30 # GNU General Public License for more details.
31
32 # You should have received a copy of the GNU General Public License
33 # along with this program; if not, write to the Free Software
34 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
35 # 02111-1307, USA.
36
37 # serial 10
38
39 AC_PREREQ([2.54])
40
41 # Autoconf 2.50 wants to disallow AM_ names.  We explicitly allow
42 # the ones we care about.
43 m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
44
45 # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
46 # AM_INIT_AUTOMAKE([OPTIONS])
47 # -----------------------------------------------
48 # The call with PACKAGE and VERSION arguments is the old style
49 # call (pre autoconf-2.50), which is being phased out.  PACKAGE
50 # and VERSION should now be passed to AC_INIT and removed from
51 # the call to AM_INIT_AUTOMAKE.
52 # We support both call styles for the transition.  After
53 # the next Automake release, Autoconf can make the AC_INIT
54 # arguments mandatory, and then we can depend on a new Autoconf
55 # release and drop the old call support.
56 AC_DEFUN([AM_INIT_AUTOMAKE],
57 [AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
58  AC_REQUIRE([AC_PROG_INSTALL])dnl
59 # test to see if srcdir already configured
60 if test "`cd $srcdir && pwd`" != "`pwd`" &&
61    test -f $srcdir/config.status; then
62   AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
63 fi
64
65 # test whether we have cygpath
66 if test -z "$CYGPATH_W"; then
67   if (cygpath --version) >/dev/null 2>/dev/null; then
68     CYGPATH_W='cygpath -w'
69   else
70     CYGPATH_W=echo
71   fi
72 fi
73 AC_SUBST([CYGPATH_W])
74
75 # Define the identity of the package.
76 dnl Distinguish between old-style and new-style calls.
77 m4_ifval([$2],
78 [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
79  AC_SUBST([PACKAGE], [$1])dnl
80  AC_SUBST([VERSION], [$2])],
81 [_AM_SET_OPTIONS([$1])dnl
82  AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
83  AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
84
85 _AM_IF_OPTION([no-define],,
86 [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
87  AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
88
89 # Some tools Automake needs.
90 AC_REQUIRE([AM_SANITY_CHECK])dnl
91 AC_REQUIRE([AC_ARG_PROGRAM])dnl
92 AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
93 AM_MISSING_PROG(AUTOCONF, autoconf)
94 AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
95 AM_MISSING_PROG(AUTOHEADER, autoheader)
96 AM_MISSING_PROG(MAKEINFO, makeinfo)
97 AM_MISSING_PROG(AMTAR, tar)
98 AM_PROG_INSTALL_SH
99 AM_PROG_INSTALL_STRIP
100 # We need awk for the "check" target.  The system "awk" is bad on
101 # some platforms.
102 AC_REQUIRE([AC_PROG_AWK])dnl
103 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
104 AC_REQUIRE([AM_SET_LEADING_DOT])dnl
105
106 _AM_IF_OPTION([no-dependencies],,
107 [AC_PROVIDE_IFELSE([AC_PROG_CC],
108                   [_AM_DEPENDENCIES(CC)],
109                   [define([AC_PROG_CC],
110                           defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
111 AC_PROVIDE_IFELSE([AC_PROG_CXX],
112                   [_AM_DEPENDENCIES(CXX)],
113                   [define([AC_PROG_CXX],
114                           defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
115 ])
116 ])
117
118
119 # When config.status generates a header, we must update the stamp-h file.
120 # This file resides in the same directory as the config header
121 # that is generated.  The stamp files are numbered to have different names.
122
123 # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
124 # loop where config.status creates the headers, so we can generate
125 # our stamp files there.
126 AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
127 [# Compute $1's index in $config_headers.
128 _am_stamp_count=1
129 for _am_header in $config_headers :; do
130   case $_am_header in
131     $1 | $1:* )
132       break ;;
133     * )
134       _am_stamp_count=`expr $_am_stamp_count + 1` ;;
135   esac
136 done
137 echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
138
139 # Copyright 2002  Free Software Foundation, Inc.
140
141 # This program is free software; you can redistribute it and/or modify
142 # it under the terms of the GNU General Public License as published by
143 # the Free Software Foundation; either version 2, or (at your option)
144 # any later version.
145
146 # This program is distributed in the hope that it will be useful,
147 # but WITHOUT ANY WARRANTY; without even the implied warranty of
148 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
149 # GNU General Public License for more details.
150
151 # You should have received a copy of the GNU General Public License
152 # along with this program; if not, write to the Free Software
153 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
154
155 # AM_AUTOMAKE_VERSION(VERSION)
156 # ----------------------------
157 # Automake X.Y traces this macro to ensure aclocal.m4 has been
158 # generated from the m4 files accompanying Automake X.Y.
159 AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.7"])
160
161 # AM_SET_CURRENT_AUTOMAKE_VERSION
162 # -------------------------------
163 # Call AM_AUTOMAKE_VERSION so it can be traced.
164 # This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
165 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
166          [AM_AUTOMAKE_VERSION([1.7.9])])
167
168 # Helper functions for option handling.                    -*- Autoconf -*-
169
170 # Copyright 2001, 2002  Free Software Foundation, Inc.
171
172 # This program is free software; you can redistribute it and/or modify
173 # it under the terms of the GNU General Public License as published by
174 # the Free Software Foundation; either version 2, or (at your option)
175 # any later version.
176
177 # This program is distributed in the hope that it will be useful,
178 # but WITHOUT ANY WARRANTY; without even the implied warranty of
179 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
180 # GNU General Public License for more details.
181
182 # You should have received a copy of the GNU General Public License
183 # along with this program; if not, write to the Free Software
184 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
185 # 02111-1307, USA.
186
187 # serial 2
188
189 # _AM_MANGLE_OPTION(NAME)
190 # -----------------------
191 AC_DEFUN([_AM_MANGLE_OPTION],
192 [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
193
194 # _AM_SET_OPTION(NAME)
195 # ------------------------------
196 # Set option NAME.  Presently that only means defining a flag for this option.
197 AC_DEFUN([_AM_SET_OPTION],
198 [m4_define(_AM_MANGLE_OPTION([$1]), 1)])
199
200 # _AM_SET_OPTIONS(OPTIONS)
201 # ----------------------------------
202 # OPTIONS is a space-separated list of Automake options.
203 AC_DEFUN([_AM_SET_OPTIONS],
204 [AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
205
206 # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
207 # -------------------------------------------
208 # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
209 AC_DEFUN([_AM_IF_OPTION],
210 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
211
212 #
213 # Check to make sure that the build environment is sane.
214 #
215
216 # Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
217
218 # This program is free software; you can redistribute it and/or modify
219 # it under the terms of the GNU General Public License as published by
220 # the Free Software Foundation; either version 2, or (at your option)
221 # any later version.
222
223 # This program is distributed in the hope that it will be useful,
224 # but WITHOUT ANY WARRANTY; without even the implied warranty of
225 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
226 # GNU General Public License for more details.
227
228 # You should have received a copy of the GNU General Public License
229 # along with this program; if not, write to the Free Software
230 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
231 # 02111-1307, USA.
232
233 # serial 3
234
235 # AM_SANITY_CHECK
236 # ---------------
237 AC_DEFUN([AM_SANITY_CHECK],
238 [AC_MSG_CHECKING([whether build environment is sane])
239 # Just in case
240 sleep 1
241 echo timestamp > conftest.file
242 # Do `set' in a subshell so we don't clobber the current shell's
243 # arguments.  Must try -L first in case configure is actually a
244 # symlink; some systems play weird games with the mod time of symlinks
245 # (eg FreeBSD returns the mod time of the symlink's containing
246 # directory).
247 if (
248    set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
249    if test "$[*]" = "X"; then
250       # -L didn't work.
251       set X `ls -t $srcdir/configure conftest.file`
252    fi
253    rm -f conftest.file
254    if test "$[*]" != "X $srcdir/configure conftest.file" \
255       && test "$[*]" != "X conftest.file $srcdir/configure"; then
256
257       # If neither matched, then we have a broken ls.  This can happen
258       # if, for instance, CONFIG_SHELL is bash and it inherits a
259       # broken ls alias from the environment.  This has actually
260       # happened.  Such a system could not be considered "sane".
261       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
262 alias in your environment])
263    fi
264
265    test "$[2]" = conftest.file
266    )
267 then
268    # Ok.
269    :
270 else
271    AC_MSG_ERROR([newly created file is older than distributed files!
272 Check your system clock])
273 fi
274 AC_MSG_RESULT(yes)])
275
276 #  -*- Autoconf -*-
277
278
279 # Copyright 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
280
281 # This program is free software; you can redistribute it and/or modify
282 # it under the terms of the GNU General Public License as published by
283 # the Free Software Foundation; either version 2, or (at your option)
284 # any later version.
285
286 # This program is distributed in the hope that it will be useful,
287 # but WITHOUT ANY WARRANTY; without even the implied warranty of
288 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
289 # GNU General Public License for more details.
290
291 # You should have received a copy of the GNU General Public License
292 # along with this program; if not, write to the Free Software
293 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
294 # 02111-1307, USA.
295
296 # serial 3
297
298 # AM_MISSING_PROG(NAME, PROGRAM)
299 # ------------------------------
300 AC_DEFUN([AM_MISSING_PROG],
301 [AC_REQUIRE([AM_MISSING_HAS_RUN])
302 $1=${$1-"${am_missing_run}$2"}
303 AC_SUBST($1)])
304
305
306 # AM_MISSING_HAS_RUN
307 # ------------------
308 # Define MISSING if not defined so far and test if it supports --run.
309 # If it does, set am_missing_run to use it, otherwise, to nothing.
310 AC_DEFUN([AM_MISSING_HAS_RUN],
311 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
312 test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
313 # Use eval to expand $SHELL
314 if eval "$MISSING --run true"; then
315   am_missing_run="$MISSING --run "
316 else
317   am_missing_run=
318   AC_MSG_WARN([`missing' script is too old or missing])
319 fi
320 ])
321
322 # AM_AUX_DIR_EXPAND
323
324 # Copyright 2001 Free Software Foundation, Inc.
325
326 # This program is free software; you can redistribute it and/or modify
327 # it under the terms of the GNU General Public License as published by
328 # the Free Software Foundation; either version 2, or (at your option)
329 # any later version.
330
331 # This program is distributed in the hope that it will be useful,
332 # but WITHOUT ANY WARRANTY; without even the implied warranty of
333 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
334 # GNU General Public License for more details.
335
336 # You should have received a copy of the GNU General Public License
337 # along with this program; if not, write to the Free Software
338 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
339 # 02111-1307, USA.
340
341 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
342 # $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
343 # `$srcdir', `$srcdir/..', or `$srcdir/../..'.
344 #
345 # Of course, Automake must honor this variable whenever it calls a
346 # tool from the auxiliary directory.  The problem is that $srcdir (and
347 # therefore $ac_aux_dir as well) can be either absolute or relative,
348 # depending on how configure is run.  This is pretty annoying, since
349 # it makes $ac_aux_dir quite unusable in subdirectories: in the top
350 # source directory, any form will work fine, but in subdirectories a
351 # relative path needs to be adjusted first.
352 #
353 # $ac_aux_dir/missing
354 #    fails when called from a subdirectory if $ac_aux_dir is relative
355 # $top_srcdir/$ac_aux_dir/missing
356 #    fails if $ac_aux_dir is absolute,
357 #    fails when called from a subdirectory in a VPATH build with
358 #          a relative $ac_aux_dir
359 #
360 # The reason of the latter failure is that $top_srcdir and $ac_aux_dir
361 # are both prefixed by $srcdir.  In an in-source build this is usually
362 # harmless because $srcdir is `.', but things will broke when you
363 # start a VPATH build or use an absolute $srcdir.
364 #
365 # So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
366 # iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
367 #   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
368 # and then we would define $MISSING as
369 #   MISSING="\${SHELL} $am_aux_dir/missing"
370 # This will work as long as MISSING is not called from configure, because
371 # unfortunately $(top_srcdir) has no meaning in configure.
372 # However there are other variables, like CC, which are often used in
373 # configure, and could therefore not use this "fixed" $ac_aux_dir.
374 #
375 # Another solution, used here, is to always expand $ac_aux_dir to an
376 # absolute PATH.  The drawback is that using absolute paths prevent a
377 # configured tree to be moved without reconfiguration.
378
379 # Rely on autoconf to set up CDPATH properly.
380 AC_PREREQ([2.50])
381
382 AC_DEFUN([AM_AUX_DIR_EXPAND], [
383 # expand $ac_aux_dir to an absolute path
384 am_aux_dir=`cd $ac_aux_dir && pwd`
385 ])
386
387 # AM_PROG_INSTALL_SH
388 # ------------------
389 # Define $install_sh.
390
391 # Copyright 2001 Free Software Foundation, Inc.
392
393 # This program is free software; you can redistribute it and/or modify
394 # it under the terms of the GNU General Public License as published by
395 # the Free Software Foundation; either version 2, or (at your option)
396 # any later version.
397
398 # This program is distributed in the hope that it will be useful,
399 # but WITHOUT ANY WARRANTY; without even the implied warranty of
400 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
401 # GNU General Public License for more details.
402
403 # You should have received a copy of the GNU General Public License
404 # along with this program; if not, write to the Free Software
405 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
406 # 02111-1307, USA.
407
408 AC_DEFUN([AM_PROG_INSTALL_SH],
409 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
410 install_sh=${install_sh-"$am_aux_dir/install-sh"}
411 AC_SUBST(install_sh)])
412
413 # AM_PROG_INSTALL_STRIP
414
415 # Copyright 2001 Free Software Foundation, Inc.
416
417 # This program is free software; you can redistribute it and/or modify
418 # it under the terms of the GNU General Public License as published by
419 # the Free Software Foundation; either version 2, or (at your option)
420 # any later version.
421
422 # This program is distributed in the hope that it will be useful,
423 # but WITHOUT ANY WARRANTY; without even the implied warranty of
424 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
425 # GNU General Public License for more details.
426
427 # You should have received a copy of the GNU General Public License
428 # along with this program; if not, write to the Free Software
429 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
430 # 02111-1307, USA.
431
432 # One issue with vendor `install' (even GNU) is that you can't
433 # specify the program used to strip binaries.  This is especially
434 # annoying in cross-compiling environments, where the build's strip
435 # is unlikely to handle the host's binaries.
436 # Fortunately install-sh will honor a STRIPPROG variable, so we
437 # always use install-sh in `make install-strip', and initialize
438 # STRIPPROG with the value of the STRIP variable (set by the user).
439 AC_DEFUN([AM_PROG_INSTALL_STRIP],
440 [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
441 # Installed binaries are usually stripped using `strip' when the user
442 # run `make install-strip'.  However `strip' might not be the right
443 # tool to use in cross-compilation environments, therefore Automake
444 # will honor the `STRIP' environment variable to overrule this program.
445 dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
446 if test "$cross_compiling" != no; then
447   AC_CHECK_TOOL([STRIP], [strip], :)
448 fi
449 INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
450 AC_SUBST([INSTALL_STRIP_PROGRAM])])
451
452 #                                                          -*- Autoconf -*-
453 # Copyright (C) 2003  Free Software Foundation, Inc.
454
455 # This program is free software; you can redistribute it and/or modify
456 # it under the terms of the GNU General Public License as published by
457 # the Free Software Foundation; either version 2, or (at your option)
458 # any later version.
459
460 # This program is distributed in the hope that it will be useful,
461 # but WITHOUT ANY WARRANTY; without even the implied warranty of
462 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
463 # GNU General Public License for more details.
464
465 # You should have received a copy of the GNU General Public License
466 # along with this program; if not, write to the Free Software
467 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
468 # 02111-1307, USA.
469
470 # serial 1
471
472 # Check whether the underlying file-system supports filenames
473 # with a leading dot.  For instance MS-DOS doesn't.
474 AC_DEFUN([AM_SET_LEADING_DOT],
475 [rm -rf .tst 2>/dev/null
476 mkdir .tst 2>/dev/null
477 if test -d .tst; then
478   am__leading_dot=.
479 else
480   am__leading_dot=_
481 fi
482 rmdir .tst 2>/dev/null
483 AC_SUBST([am__leading_dot])])
484
485 # serial 5                                              -*- Autoconf -*-
486
487 # Copyright (C) 1999, 2000, 2001, 2002, 2003  Free Software Foundation, Inc.
488
489 # This program is free software; you can redistribute it and/or modify
490 # it under the terms of the GNU General Public License as published by
491 # the Free Software Foundation; either version 2, or (at your option)
492 # any later version.
493
494 # This program is distributed in the hope that it will be useful,
495 # but WITHOUT ANY WARRANTY; without even the implied warranty of
496 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
497 # GNU General Public License for more details.
498
499 # You should have received a copy of the GNU General Public License
500 # along with this program; if not, write to the Free Software
501 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
502 # 02111-1307, USA.
503
504
505 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
506 # written in clear, in which case automake, when reading aclocal.m4,
507 # will think it sees a *use*, and therefore will trigger all it's
508 # C support machinery.  Also note that it means that autoscan, seeing
509 # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
510
511
512
513 # _AM_DEPENDENCIES(NAME)
514 # ----------------------
515 # See how the compiler implements dependency checking.
516 # NAME is "CC", "CXX", "GCJ", or "OBJC".
517 # We try a few techniques and use that to set a single cache variable.
518 #
519 # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
520 # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
521 # dependency, and given that the user is not expected to run this macro,
522 # just rely on AC_PROG_CC.
523 AC_DEFUN([_AM_DEPENDENCIES],
524 [AC_REQUIRE([AM_SET_DEPDIR])dnl
525 AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
526 AC_REQUIRE([AM_MAKE_INCLUDE])dnl
527 AC_REQUIRE([AM_DEP_TRACK])dnl
528
529 ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
530        [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
531        [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
532        [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
533                    [depcc="$$1"   am_compiler_list=])
534
535 AC_CACHE_CHECK([dependency style of $depcc],
536                [am_cv_$1_dependencies_compiler_type],
537 [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
538   # We make a subdir and do the tests there.  Otherwise we can end up
539   # making bogus files that we don't know about and never remove.  For
540   # instance it was reported that on HP-UX the gcc test will end up
541   # making a dummy file named `D' -- because `-MD' means `put the output
542   # in D'.
543   mkdir conftest.dir
544   # Copy depcomp to subdir because otherwise we won't find it if we're
545   # using a relative directory.
546   cp "$am_depcomp" conftest.dir
547   cd conftest.dir
548   # We will build objects and dependencies in a subdirectory because
549   # it helps to detect inapplicable dependency modes.  For instance
550   # both Tru64's cc and ICC support -MD to output dependencies as a
551   # side effect of compilation, but ICC will put the dependencies in
552   # the current directory while Tru64 will put them in the object
553   # directory.
554   mkdir sub
555
556   am_cv_$1_dependencies_compiler_type=none
557   if test "$am_compiler_list" = ""; then
558      am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
559   fi
560   for depmode in $am_compiler_list; do
561     # Setup a source with many dependencies, because some compilers
562     # like to wrap large dependency lists on column 80 (with \), and
563     # we should not choose a depcomp mode which is confused by this.
564     #
565     # We need to recreate these files for each test, as the compiler may
566     # overwrite some of them when testing with obscure command lines.
567     # This happens at least with the AIX C compiler.
568     : > sub/conftest.c
569     for i in 1 2 3 4 5 6; do
570       echo '#include "conftst'$i'.h"' >> sub/conftest.c
571       : > sub/conftst$i.h
572     done
573     echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
574
575     case $depmode in
576     nosideeffect)
577       # after this tag, mechanisms are not by side-effect, so they'll
578       # only be used when explicitly requested
579       if test "x$enable_dependency_tracking" = xyes; then
580         continue
581       else
582         break
583       fi
584       ;;
585     none) break ;;
586     esac
587     # We check with `-c' and `-o' for the sake of the "dashmstdout"
588     # mode.  It turns out that the SunPro C++ compiler does not properly
589     # handle `-M -o', and we need to detect this.
590     if depmode=$depmode \
591        source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
592        depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
593        $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
594          >/dev/null 2>conftest.err &&
595        grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
596        grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
597        ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
598       # icc doesn't choke on unknown options, it will just issue warnings
599       # (even with -Werror).  So we grep stderr for any message
600       # that says an option was ignored.
601       if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else
602         am_cv_$1_dependencies_compiler_type=$depmode
603         break
604       fi
605     fi
606   done
607
608   cd ..
609   rm -rf conftest.dir
610 else
611   am_cv_$1_dependencies_compiler_type=none
612 fi
613 ])
614 AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
615 AM_CONDITIONAL([am__fastdep$1], [
616   test "x$enable_dependency_tracking" != xno \
617   && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
618 ])
619
620
621 # AM_SET_DEPDIR
622 # -------------
623 # Choose a directory name for dependency files.
624 # This macro is AC_REQUIREd in _AM_DEPENDENCIES
625 AC_DEFUN([AM_SET_DEPDIR],
626 [AC_REQUIRE([AM_SET_LEADING_DOT])dnl
627 AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
628 ])
629
630
631 # AM_DEP_TRACK
632 # ------------
633 AC_DEFUN([AM_DEP_TRACK],
634 [AC_ARG_ENABLE(dependency-tracking,
635 [  --disable-dependency-tracking Speeds up one-time builds
636   --enable-dependency-tracking  Do not reject slow dependency extractors])
637 if test "x$enable_dependency_tracking" != xno; then
638   am_depcomp="$ac_aux_dir/depcomp"
639   AMDEPBACKSLASH='\'
640 fi
641 AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
642 AC_SUBST([AMDEPBACKSLASH])
643 ])
644
645 # Generate code to set up dependency tracking.   -*- Autoconf -*-
646
647 # Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
648
649 # This program is free software; you can redistribute it and/or modify
650 # it under the terms of the GNU General Public License as published by
651 # the Free Software Foundation; either version 2, or (at your option)
652 # any later version.
653
654 # This program is distributed in the hope that it will be useful,
655 # but WITHOUT ANY WARRANTY; without even the implied warranty of
656 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
657 # GNU General Public License for more details.
658
659 # You should have received a copy of the GNU General Public License
660 # along with this program; if not, write to the Free Software
661 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
662 # 02111-1307, USA.
663
664 #serial 2
665
666 # _AM_OUTPUT_DEPENDENCY_COMMANDS
667 # ------------------------------
668 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
669 [for mf in $CONFIG_FILES; do
670   # Strip MF so we end up with the name of the file.
671   mf=`echo "$mf" | sed -e 's/:.*$//'`
672   # Check whether this is an Automake generated Makefile or not.
673   # We used to match only the files named `Makefile.in', but
674   # some people rename them; so instead we look at the file content.
675   # Grep'ing the first line is not enough: some people post-process
676   # each Makefile.in and add a new line on top of each file to say so.
677   # So let's grep whole file.
678   if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
679     dirpart=`AS_DIRNAME("$mf")`
680   else
681     continue
682   fi
683   grep '^DEP_FILES *= *[[^ @%:@]]' < "$mf" > /dev/null || continue
684   # Extract the definition of DEP_FILES from the Makefile without
685   # running `make'.
686   DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
687   test -z "$DEPDIR" && continue
688   # When using ansi2knr, U may be empty or an underscore; expand it
689   U=`sed -n -e '/^U = / s///p' < "$mf"`
690   test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
691   # We invoke sed twice because it is the simplest approach to
692   # changing $(DEPDIR) to its actual value in the expansion.
693   for file in `sed -n -e '
694     /^DEP_FILES = .*\\\\$/ {
695       s/^DEP_FILES = //
696       :loop
697         s/\\\\$//
698         p
699         n
700         /\\\\$/ b loop
701       p
702     }
703     /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
704        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
705     # Make sure the directory exists.
706     test -f "$dirpart/$file" && continue
707     fdir=`AS_DIRNAME(["$file"])`
708     AS_MKDIR_P([$dirpart/$fdir])
709     # echo "creating $dirpart/$file"
710     echo '# dummy' > "$dirpart/$file"
711   done
712 done
713 ])# _AM_OUTPUT_DEPENDENCY_COMMANDS
714
715
716 # AM_OUTPUT_DEPENDENCY_COMMANDS
717 # -----------------------------
718 # This macro should only be invoked once -- use via AC_REQUIRE.
719 #
720 # This code is only required when automatic dependency tracking
721 # is enabled.  FIXME.  This creates each `.P' file that we will
722 # need in order to bootstrap the dependency handling code.
723 AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
724 [AC_CONFIG_COMMANDS([depfiles],
725      [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
726      [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
727 ])
728
729 # Check to see how 'make' treats includes.      -*- Autoconf -*-
730
731 # Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
732
733 # This program is free software; you can redistribute it and/or modify
734 # it under the terms of the GNU General Public License as published by
735 # the Free Software Foundation; either version 2, or (at your option)
736 # any later version.
737
738 # This program is distributed in the hope that it will be useful,
739 # but WITHOUT ANY WARRANTY; without even the implied warranty of
740 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
741 # GNU General Public License for more details.
742
743 # You should have received a copy of the GNU General Public License
744 # along with this program; if not, write to the Free Software
745 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
746 # 02111-1307, USA.
747
748 # serial 2
749
750 # AM_MAKE_INCLUDE()
751 # -----------------
752 # Check to see how make treats includes.
753 AC_DEFUN([AM_MAKE_INCLUDE],
754 [am_make=${MAKE-make}
755 cat > confinc << 'END'
756 am__doit:
757         @echo done
758 .PHONY: am__doit
759 END
760 # If we don't find an include directive, just comment out the code.
761 AC_MSG_CHECKING([for style of include used by $am_make])
762 am__include="#"
763 am__quote=
764 _am_result=none
765 # First try GNU make style include.
766 echo "include confinc" > confmf
767 # We grep out `Entering directory' and `Leaving directory'
768 # messages which can occur if `w' ends up in MAKEFLAGS.
769 # In particular we don't look at `^make:' because GNU make might
770 # be invoked under some other name (usually "gmake"), in which
771 # case it prints its new name instead of `make'.
772 if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
773    am__include=include
774    am__quote=
775    _am_result=GNU
776 fi
777 # Now try BSD make style include.
778 if test "$am__include" = "#"; then
779    echo '.include "confinc"' > confmf
780    if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
781       am__include=.include
782       am__quote="\""
783       _am_result=BSD
784    fi
785 fi
786 AC_SUBST([am__include])
787 AC_SUBST([am__quote])
788 AC_MSG_RESULT([$_am_result])
789 rm -f confinc confmf
790 ])
791
792 # AM_CONDITIONAL                                              -*- Autoconf -*-
793
794 # Copyright 1997, 2000, 2001 Free Software Foundation, Inc.
795
796 # This program is free software; you can redistribute it and/or modify
797 # it under the terms of the GNU General Public License as published by
798 # the Free Software Foundation; either version 2, or (at your option)
799 # any later version.
800
801 # This program is distributed in the hope that it will be useful,
802 # but WITHOUT ANY WARRANTY; without even the implied warranty of
803 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
804 # GNU General Public License for more details.
805
806 # You should have received a copy of the GNU General Public License
807 # along with this program; if not, write to the Free Software
808 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
809 # 02111-1307, USA.
810
811 # serial 5
812
813 AC_PREREQ(2.52)
814
815 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
816 # -------------------------------------
817 # Define a conditional.
818 AC_DEFUN([AM_CONDITIONAL],
819 [ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
820         [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
821 AC_SUBST([$1_TRUE])
822 AC_SUBST([$1_FALSE])
823 if $2; then
824   $1_TRUE=
825   $1_FALSE='#'
826 else
827   $1_TRUE='#'
828   $1_FALSE=
829 fi
830 AC_CONFIG_COMMANDS_PRE(
831 [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
832   AC_MSG_ERROR([conditional "$1" was never defined.
833 Usually this means the macro was only invoked conditionally.])
834 fi])])
835
836 dnl init_automake.m4--cmulocal automake setup macro
837 dnl Rob Earhart
838 dnl $Id: init_automake.m4,v 1.4 2003/10/08 20:35:24 rjs3 Exp $
839
840 AC_DEFUN([CMU_INIT_AUTOMAKE], [
841         AC_REQUIRE([AM_INIT_AUTOMAKE])
842         ACLOCAL="$ACLOCAL -I \$(top_srcdir)/cmulocal"
843         ])
844
845 dnl
846 dnl $Id: c-attribute.m4,v 1.3 2003/10/08 20:35:24 rjs3 Exp $
847 dnl
848
849 dnl
850 dnl Test for __attribute__
851 dnl
852
853 AC_DEFUN([CMU_C___ATTRIBUTE__], [
854 AC_MSG_CHECKING(for __attribute__)
855 AC_CACHE_VAL(ac_cv___attribute__, [
856 AC_TRY_COMPILE([
857 #include <stdlib.h>
858 ],
859 [
860 static void foo(void) __attribute__ ((noreturn));
861
862 static void
863 foo(void)
864 {
865   exit(1);
866 }
867 ],
868 ac_cv___attribute__=yes,
869 ac_cv___attribute__=no)])
870 if test "$ac_cv___attribute__" = "yes"; then
871   AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
872 fi
873 AC_MSG_RESULT($ac_cv___attribute__)
874 ])
875
876
877 dnl
878 dnl Additional macros for configure.in packaged up for easier theft.
879 dnl $Id: cyrus.m4,v 1.4 2003/10/08 20:35:24 rjs3 Exp $
880 dnl tjs@andrew.cmu.edu 6-may-1998
881 dnl
882
883 dnl It would be good if ANDREW_ADD_LIBPATH could detect if something was
884 dnl already there and not redundantly add it if it is.
885
886 dnl add -L(arg), and possibly (runpath switch)(arg), to LDFLAGS
887 dnl (so the runpath for shared libraries is set).
888 AC_DEFUN([CMU_ADD_LIBPATH], [
889   # this is CMU ADD LIBPATH
890   if test "$andrew_runpath_switch" = "none" ; then
891         LDFLAGS="-L$1 ${LDFLAGS}"
892   else
893         LDFLAGS="-L$1 $andrew_runpath_switch$1 ${LDFLAGS}"
894   fi
895 ])
896
897 dnl add -L(1st arg), and possibly (runpath switch)(1st arg), to (2nd arg)
898 dnl (so the runpath for shared libraries is set).
899 AC_DEFUN([CMU_ADD_LIBPATH_TO], [
900   # this is CMU ADD LIBPATH TO
901   if test "$andrew_runpath_switch" = "none" ; then
902         $2="-L$1 ${$2}"
903   else
904         $2="-L$1 ${$2} $andrew_runpath_switch$1"
905   fi
906 ])
907
908 dnl runpath initialization
909 AC_DEFUN([CMU_GUESS_RUNPATH_SWITCH], [
910    # CMU GUESS RUNPATH SWITCH
911   AC_CACHE_CHECK(for runpath switch, andrew_runpath_switch, [
912     # first, try -R
913     SAVE_LDFLAGS="${LDFLAGS}"
914     LDFLAGS="-R /usr/lib"
915     AC_TRY_LINK([],[],[andrew_runpath_switch="-R"], [
916         LDFLAGS="-Wl,-rpath,/usr/lib"
917     AC_TRY_LINK([],[],[andrew_runpath_switch="-Wl,-rpath,"],
918     [andrew_runpath_switch="none"])
919     ])
920   LDFLAGS="${SAVE_LDFLAGS}"
921   ])])
922
923
924 # serial 40 AC_PROG_LIBTOOL
925 AC_DEFUN([AC_PROG_LIBTOOL],
926 [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
927
928 # Save cache, so that ltconfig can load it
929 AC_CACHE_SAVE
930
931 # Actually configure libtool.  ac_aux_dir is where install-sh is found.
932 CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
933 LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
934 LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
935 DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
936 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
937 $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
938 || AC_MSG_ERROR([libtool configure failed])
939
940 # Reload cache, that may have been modified by ltconfig
941 AC_CACHE_LOAD
942
943 # This can be used to rebuild libtool when needed
944 LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
945
946 # Always use our own libtool.
947 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
948 AC_SUBST(LIBTOOL)dnl
949
950 # Redirect the config.log output again, so that the ltconfig log is not
951 # clobbered by the next message.
952 exec 5>>./config.log
953 ])
954
955 AC_DEFUN([AC_LIBTOOL_SETUP],
956 [AC_PREREQ(2.13)dnl
957 AC_REQUIRE([AC_ENABLE_SHARED])dnl
958 AC_REQUIRE([AC_ENABLE_STATIC])dnl
959 AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
960 AC_REQUIRE([AC_CANONICAL_HOST])dnl
961 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
962 AC_REQUIRE([AC_PROG_RANLIB])dnl
963 AC_REQUIRE([AC_PROG_CC])dnl
964 AC_REQUIRE([AC_PROG_LD])dnl
965 AC_REQUIRE([AC_PROG_NM])dnl
966 AC_REQUIRE([AC_PROG_LN_S])dnl
967 dnl
968
969 case "$target" in
970 NONE) lt_target="$host" ;;
971 *) lt_target="$target" ;;
972 esac
973
974 # Check for any special flags to pass to ltconfig.
975 libtool_flags="--cache-file=$cache_file"
976 test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
977 test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
978 test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
979 test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
980 test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
981 ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
982 [libtool_flags="$libtool_flags --enable-dlopen"])
983 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
984 [libtool_flags="$libtool_flags --enable-win32-dll"])
985 AC_ARG_ENABLE(libtool-lock,
986   [  --disable-libtool-lock  avoid locking (might break parallel builds)])
987 test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
988 test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
989
990 # Some flags need to be propagated to the compiler or linker for good
991 # libtool support.
992 case "$lt_target" in
993 *-*-irix6*)
994   # Find out which ABI we are using.
995   echo '[#]line __oline__ "configure"' > conftest.$ac_ext
996   if AC_TRY_EVAL(ac_compile); then
997     case "`/usr/bin/file conftest.o`" in
998     *32-bit*)
999       LD="${LD-ld} -32"
1000       ;;
1001     *N32*)
1002       LD="${LD-ld} -n32"
1003       ;;
1004     *64-bit*)
1005       LD="${LD-ld} -64"
1006       ;;
1007     esac
1008   fi
1009   rm -rf conftest*
1010   ;;
1011
1012 *-*-sco3.2v5*)
1013   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
1014   SAVE_CFLAGS="$CFLAGS"
1015   CFLAGS="$CFLAGS -belf"
1016   AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
1017     [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
1018   if test x"$lt_cv_cc_needs_belf" != x"yes"; then
1019     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
1020     CFLAGS="$SAVE_CFLAGS"
1021   fi
1022   ;;
1023
1024 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
1025 [*-*-cygwin* | *-*-mingw*)
1026   AC_CHECK_TOOL(DLLTOOL, dlltool, false)
1027   AC_CHECK_TOOL(AS, as, false)
1028   AC_CHECK_TOOL(OBJDUMP, objdump, false)
1029   ;;
1030 ])
1031 esac
1032 ])
1033
1034 # AC_LIBTOOL_DLOPEN - enable checks for dlopen support
1035 AC_DEFUN([AC_LIBTOOL_DLOPEN], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
1036
1037 # AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
1038 AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
1039
1040 # AC_ENABLE_SHARED - implement the --enable-shared flag
1041 # Usage: AC_ENABLE_SHARED[(DEFAULT)]
1042 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1043 #   `yes'.
1044 AC_DEFUN([AC_ENABLE_SHARED], [dnl
1045 define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
1046 AC_ARG_ENABLE(shared,
1047 changequote(<<, >>)dnl
1048 <<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
1049 changequote([, ])dnl
1050 [p=${PACKAGE-default}
1051 case "$enableval" in
1052 yes) enable_shared=yes ;;
1053 no) enable_shared=no ;;
1054 *)
1055   enable_shared=no
1056   # Look at the argument we got.  We use all the common list separators.
1057   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1058   for pkg in $enableval; do
1059     if test "X$pkg" = "X$p"; then
1060       enable_shared=yes
1061     fi
1062   done
1063   IFS="$ac_save_ifs"
1064   ;;
1065 esac],
1066 enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
1067 ])
1068
1069 # AC_DISABLE_SHARED - set the default shared flag to --disable-shared
1070 AC_DEFUN([AC_DISABLE_SHARED], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1071 AC_ENABLE_SHARED(no)])
1072
1073 # AC_ENABLE_STATIC - implement the --enable-static flag
1074 # Usage: AC_ENABLE_STATIC[(DEFAULT)]
1075 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1076 #   `yes'.
1077 AC_DEFUN([AC_ENABLE_STATIC], [dnl
1078 define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
1079 AC_ARG_ENABLE(static,
1080 changequote(<<, >>)dnl
1081 <<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
1082 changequote([, ])dnl
1083 [p=${PACKAGE-default}
1084 case "$enableval" in
1085 yes) enable_static=yes ;;
1086 no) enable_static=no ;;
1087 *)
1088   enable_static=no
1089   # Look at the argument we got.  We use all the common list separators.
1090   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1091   for pkg in $enableval; do
1092     if test "X$pkg" = "X$p"; then
1093       enable_static=yes
1094     fi
1095   done
1096   IFS="$ac_save_ifs"
1097   ;;
1098 esac],
1099 enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
1100 ])
1101
1102 # AC_DISABLE_STATIC - set the default static flag to --disable-static
1103 AC_DEFUN([AC_DISABLE_STATIC], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1104 AC_ENABLE_STATIC(no)])
1105
1106
1107 # AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
1108 # Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
1109 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1110 #   `yes'.
1111 AC_DEFUN([AC_ENABLE_FAST_INSTALL], [dnl
1112 define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
1113 AC_ARG_ENABLE(fast-install,
1114 changequote(<<, >>)dnl
1115 <<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
1116 changequote([, ])dnl
1117 [p=${PACKAGE-default}
1118 case "$enableval" in
1119 yes) enable_fast_install=yes ;;
1120 no) enable_fast_install=no ;;
1121 *)
1122   enable_fast_install=no
1123   # Look at the argument we got.  We use all the common list separators.
1124   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1125   for pkg in $enableval; do
1126     if test "X$pkg" = "X$p"; then
1127       enable_fast_install=yes
1128     fi
1129   done
1130   IFS="$ac_save_ifs"
1131   ;;
1132 esac],
1133 enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
1134 ])
1135
1136 # AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
1137 AC_DEFUN([AC_DISABLE_FAST_INSTALL], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1138 AC_ENABLE_FAST_INSTALL(no)])
1139
1140 # AC_PROG_LD - find the path to the GNU or non-GNU linker
1141 AC_DEFUN([AC_PROG_LD],
1142 [AC_ARG_WITH(gnu-ld,
1143 [  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
1144 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
1145 AC_REQUIRE([AC_PROG_CC])dnl
1146 AC_REQUIRE([AC_CANONICAL_HOST])dnl
1147 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
1148 ac_prog=ld
1149 if test "$ac_cv_prog_gcc" = yes; then
1150   # Check if gcc -print-prog-name=ld gives a path.
1151   AC_MSG_CHECKING([for ld used by GCC])
1152   ac_prog=`($CC -print-prog-name=ld) 2>&5`
1153   case "$ac_prog" in
1154     # Accept absolute paths.
1155 changequote(,)dnl
1156     [\\/]* | [A-Za-z]:[\\/]*)
1157       re_direlt='/[^/][^/]*/\.\./'
1158 changequote([,])dnl
1159       # Canonicalize the path of ld
1160       ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
1161       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
1162         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
1163       done
1164       test -z "$LD" && LD="$ac_prog"
1165       ;;
1166   "")
1167     # If it fails, then pretend we aren't using GCC.
1168     ac_prog=ld
1169     ;;
1170   *)
1171     # If it is relative, then search for the first ld in PATH.
1172     with_gnu_ld=unknown
1173     ;;
1174   esac
1175 elif test "$with_gnu_ld" = yes; then
1176   AC_MSG_CHECKING([for GNU ld])
1177 else
1178   AC_MSG_CHECKING([for non-GNU ld])
1179 fi
1180 AC_CACHE_VAL(ac_cv_path_LD,
1181 [if test -z "$LD"; then
1182   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
1183   for ac_dir in $PATH; do
1184     test -z "$ac_dir" && ac_dir=.
1185     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
1186       ac_cv_path_LD="$ac_dir/$ac_prog"
1187       # Check to see if the program is GNU ld.  I'd rather use --version,
1188       # but apparently some GNU ld's only accept -v.
1189       # Break only if it was the GNU/non-GNU ld that we prefer.
1190       if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
1191         test "$with_gnu_ld" != no && break
1192       else
1193         test "$with_gnu_ld" != yes && break
1194       fi
1195     fi
1196   done
1197   IFS="$ac_save_ifs"
1198 else
1199   ac_cv_path_LD="$LD" # Let the user override the test with a path.
1200 fi])
1201 LD="$ac_cv_path_LD"
1202 if test -n "$LD"; then
1203   AC_MSG_RESULT($LD)
1204 else
1205   AC_MSG_RESULT(no)
1206 fi
1207 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
1208 AC_PROG_LD_GNU
1209 ])
1210
1211 AC_DEFUN([AC_PROG_LD_GNU],
1212 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
1213 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
1214 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
1215   ac_cv_prog_gnu_ld=yes
1216 else
1217   ac_cv_prog_gnu_ld=no
1218 fi])
1219 ])
1220
1221 # AC_PROG_NM - find the path to a BSD-compatible name lister
1222 AC_DEFUN([AC_PROG_NM],
1223 [AC_MSG_CHECKING([for BSD-compatible nm])
1224 AC_CACHE_VAL(ac_cv_path_NM,
1225 [if test -n "$NM"; then
1226   # Let the user override the test.
1227   ac_cv_path_NM="$NM"
1228 else
1229   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
1230   for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
1231     test -z "$ac_dir" && ac_dir=.
1232     if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
1233       # Check to see if the nm accepts a BSD-compat flag.
1234       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
1235       #   nm: unknown option "B" ignored
1236       if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
1237         ac_cv_path_NM="$ac_dir/nm -B"
1238         break
1239       elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
1240         ac_cv_path_NM="$ac_dir/nm -p"
1241         break
1242       else
1243         ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
1244         continue # so that we can try to find one that supports BSD flags
1245       fi
1246     fi
1247   done
1248   IFS="$ac_save_ifs"
1249   test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
1250 fi])
1251 NM="$ac_cv_path_NM"
1252 AC_MSG_RESULT([$NM])
1253 ])
1254
1255 # AC_CHECK_LIBM - check for math library
1256 AC_DEFUN([AC_CHECK_LIBM],
1257 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
1258 LIBM=
1259 case "$lt_target" in
1260 *-*-beos* | *-*-cygwin*)
1261   # These system don't have libm
1262   ;;
1263 *-ncr-sysv4.3*)
1264   AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
1265   AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
1266   ;;
1267 *)
1268   AC_CHECK_LIB(m, main, LIBM="-lm")
1269   ;;
1270 esac
1271 ])
1272
1273 # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
1274 # the libltdl convenience library, adds --enable-ltdl-convenience to
1275 # the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
1276 # is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
1277 # to be `${top_builddir}/libltdl'.  Make sure you start DIR with
1278 # '${top_builddir}/' (note the single quotes!) if your package is not
1279 # flat, and, if you're not using automake, define top_builddir as
1280 # appropriate in the Makefiles.
1281 AC_DEFUN([AC_LIBLTDL_CONVENIENCE], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1282   case "$enable_ltdl_convenience" in
1283   no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
1284   "") enable_ltdl_convenience=yes
1285       ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
1286   esac
1287   LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
1288   INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
1289 ])
1290
1291 # AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
1292 # the libltdl installable library, and adds --enable-ltdl-install to
1293 # the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
1294 # is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
1295 # to be `${top_builddir}/libltdl'.  Make sure you start DIR with
1296 # '${top_builddir}/' (note the single quotes!) if your package is not
1297 # flat, and, if you're not using automake, define top_builddir as
1298 # appropriate in the Makefiles.
1299 # In the future, this macro may have to be called after AC_PROG_LIBTOOL.
1300 AC_DEFUN([AC_LIBLTDL_INSTALLABLE], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1301   AC_CHECK_LIB(ltdl, main,
1302   [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
1303   [if test x"$enable_ltdl_install" = xno; then
1304      AC_MSG_WARN([libltdl not installed, but installation disabled])
1305    else
1306      enable_ltdl_install=yes
1307    fi
1308   ])
1309   if test x"$enable_ltdl_install" = x"yes"; then
1310     ac_configure_args="$ac_configure_args --enable-ltdl-install"
1311     LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
1312     INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
1313   else
1314     ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
1315     LIBLTDL="-lltdl"
1316     INCLTDL=
1317   fi
1318 ])
1319
1320 dnl old names
1321 AC_DEFUN([AM_PROG_LIBTOOL], [indir([AC_PROG_LIBTOOL])])dnl
1322 AC_DEFUN([AM_ENABLE_SHARED], [indir([AC_ENABLE_SHARED], $@)])dnl
1323 AC_DEFUN([AM_ENABLE_STATIC], [indir([AC_ENABLE_STATIC], $@)])dnl
1324 AC_DEFUN([AM_DISABLE_SHARED], [indir([AC_DISABLE_SHARED], $@)])dnl
1325 AC_DEFUN([AM_DISABLE_STATIC], [indir([AC_DISABLE_STATIC], $@)])dnl
1326 AC_DEFUN([AM_PROG_LD], [indir([AC_PROG_LD])])dnl
1327 AC_DEFUN([AM_PROG_NM], [indir([AC_PROG_NM])])dnl
1328
1329 dnl This is just to silence aclocal about the macro not being used
1330 ifelse([AC_DISABLE_FAST_INSTALL])dnl
1331
1332 dnl bsd_sockets.m4--which socket libraries do we need? 
1333 dnl Derrick Brashear
1334 dnl from Zephyr
1335 dnl $Id: bsd_sockets.m4,v 1.10 2005/04/26 19:14:07 shadow Exp $
1336
1337 dnl Hacked on by Rob Earhart to not just toss stuff in LIBS
1338 dnl It now puts everything required for sockets into LIB_SOCKET
1339
1340 AC_DEFUN([CMU_SOCKETS], [
1341         save_LIBS="$LIBS"
1342         LIB_SOCKET=""
1343         AC_CHECK_FUNC(connect, :,
1344                 AC_CHECK_LIB(nsl, gethostbyname,
1345                              LIB_SOCKET="-lnsl $LIB_SOCKET")
1346                 AC_CHECK_LIB(socket, connect,
1347                              LIB_SOCKET="-lsocket $LIB_SOCKET")
1348         )
1349         LIBS="$LIB_SOCKET $save_LIBS"
1350         AC_CHECK_FUNC(res_search, :,
1351                 LIBS="-lresolv $LIB_SOCKET $save_LIBS"
1352                 AC_TRY_LINK([[
1353 #include <sys/types.h>
1354 #include <netinet/in.h>
1355 #include <arpa/nameser.h>
1356 #ifdef HAVE_ARPA_NAMESER_COMPAT_H
1357 #include <arpa/nameser_compat.h>
1358 #endif
1359 #include <resolv.h>]],[[
1360 const char host[12]="openafs.org";
1361 u_char ans[1024];
1362 res_search( host, C_IN, T_MX, (u_char *)&ans, sizeof(ans));
1363 return 0;
1364 ]], LIB_SOCKET="-lresolv $LIB_SOCKET")
1365         )
1366         LIBS="$LIB_SOCKET $save_LIBS"
1367         AC_CHECK_FUNCS(dn_expand dns_lookup)
1368         LIBS="$save_LIBS"
1369         AC_SUBST(LIB_SOCKET)
1370         ])
1371
1372 dnl Functions to check what database to use for libsasldb
1373
1374 dnl Berkeley DB specific checks first..
1375
1376 dnl Figure out what database type we're using
1377 AC_DEFUN([SASL_DB_CHECK], [
1378 cmu_save_LIBS="$LIBS"
1379 AC_ARG_WITH(dblib, [  --with-dblib=DBLIB      set the DB library to use [berkeley] ],
1380   dblib=$withval,
1381   dblib=auto_detect)
1382
1383 CYRUS_BERKELEY_DB_OPTS()
1384
1385 SASL_DB_LIB=""
1386
1387 case "$dblib" in
1388 dnl this is unbelievably painful due to confusion over what db-3 should be
1389 dnl named.  arg.
1390   berkeley)
1391         CYRUS_BERKELEY_DB_CHK()
1392         CPPFLAGS="${CPPFLAGS} ${BDB_INCADD}"
1393         SASL_DB_INC=$BDB_INCADD
1394         SASL_DB_LIB="${BDB_LIBADD}"
1395         ;;
1396   gdbm)
1397         AC_ARG_WITH(gdbm,[  --with-gdbm=PATH        use gdbm from PATH],
1398                     with_gdbm="${withval}")
1399
1400         case "$with_gdbm" in
1401            ""|yes)
1402                AC_CHECK_HEADER(gdbm.h, [
1403                         AC_CHECK_LIB(gdbm, gdbm_open, SASL_DB_LIB="-lgdbm",
1404                                            dblib="no")],
1405                         dblib="no")
1406                ;;
1407            *)
1408                if test -d $with_gdbm; then
1409                  CPPFLAGS="${CPPFLAGS} -I${with_gdbm}/include"
1410                  LDFLAGS="${LDFLAGS} -L${with_gdbm}/lib"
1411                  SASL_DB_LIB="-lgdbm" 
1412                else
1413                  with_gdbm="no"
1414                fi
1415        esac
1416         ;;
1417   ndbm)
1418         dnl We want to attempt to use -lndbm if we can, just in case
1419         dnl there's some version of it installed and overriding libc
1420         AC_CHECK_HEADER(ndbm.h, [
1421                         AC_CHECK_LIB(ndbm, dbm_open, SASL_DB_LIB="-lndbm", [
1422                                 AC_CHECK_FUNC(dbm_open,,dblib="no")])],
1423                                 dblib="no")
1424         ;;
1425   auto_detect)
1426         dnl How about berkeley db?
1427         CYRUS_BERKELEY_DB_CHK()
1428         if test "$dblib" = no; then
1429           dnl How about ndbm?
1430           AC_CHECK_HEADER(ndbm.h, [
1431                 AC_CHECK_LIB(ndbm, dbm_open,
1432                              dblib="ndbm"; SASL_DB_LIB="-lndbm",
1433                              dblib="weird")],
1434                    dblib="no")
1435           if test "$dblib" = "weird"; then
1436             dnl Is ndbm in the standard library?
1437             AC_CHECK_FUNC(dbm_open, dblib="ndbm", dblib="no")
1438           fi
1439
1440           if test "$dblib" = no; then
1441             dnl Can we use gdbm?
1442             AC_CHECK_HEADER(gdbm.h, [
1443                 AC_CHECK_LIB(gdbm, gdbm_open, dblib="gdbm";
1444                                              SASL_DB_LIB="-lgdbm", dblib="no")],
1445                              dblib="no")
1446           fi
1447         else
1448           dnl we took Berkeley
1449           CPPFLAGS="${CPPFLAGS} ${BDB_INCADD}"
1450           SASL_DB_INC=$BDB_INCADD
1451           SASL_DB_LIB="${BDB_LIBADD}"
1452         fi
1453         ;;
1454   none)
1455         ;;
1456   no)
1457         ;;
1458   *)
1459         AC_MSG_WARN([Bad DB library implementation specified;])
1460         AC_ERROR([Use either \"berkeley\", \"gdbm\", \"ndbm\" or \"none\"])
1461         dblib=no
1462         ;;
1463 esac
1464 LIBS="$cmu_save_LIBS"
1465
1466 AC_MSG_CHECKING(DB library to use)
1467 AC_MSG_RESULT($dblib)
1468
1469 SASL_DB_BACKEND="db_${dblib}.lo"
1470 SASL_DB_BACKEND_STATIC="db_${dblib}.o allockey.o"
1471 SASL_DB_BACKEND_STATIC_SRCS="../sasldb/db_${dblib}.c ../sasldb/allockey.c"
1472 SASL_DB_UTILS="saslpasswd2 sasldblistusers2"
1473 SASL_DB_MANS="saslpasswd2.8 sasldblistusers2.8"
1474
1475 case "$dblib" in
1476   gdbm) 
1477     SASL_MECHS="$SASL_MECHS libsasldb.la"
1478     AC_DEFINE(SASL_GDBM,[],[Use GDBM for SASLdb])
1479     ;;
1480   ndbm)
1481     SASL_MECHS="$SASL_MECHS libsasldb.la"
1482     AC_DEFINE(SASL_NDBM,[],[Use NDBM for SASLdb])
1483     ;;
1484   berkeley)
1485     SASL_MECHS="$SASL_MECHS libsasldb.la"
1486     AC_DEFINE(SASL_BERKELEYDB,[],[Use BerkeleyDB for SASLdb])
1487     ;;
1488   *)
1489     AC_MSG_WARN([Disabling SASL authentication database support])
1490     dnl note that we do not add libsasldb.la to SASL_MECHS, since it
1491     dnl will just fail to load anyway.
1492     SASL_DB_BACKEND="db_none.lo"
1493     SASL_DB_BACKEND_STATIC="db_none.o"
1494     SASL_DB_BACKEND_STATIC_SRCS="../sasldb/db_none.c"
1495     SASL_DB_UTILS=""
1496     SASL_DB_MANS=""
1497     SASL_DB_LIB=""
1498     ;;
1499 esac
1500
1501 if test "$enable_static" = yes; then
1502     if test "$dblib" != "none"; then
1503       SASL_STATIC_SRCS="$SASL_STATIC_SRCS ../plugins/sasldb.c $SASL_DB_BACKEND_STATIC_SRCS"
1504       SASL_STATIC_OBJS="$SASL_STATIC_OBJS sasldb.o $SASL_DB_BACKEND_STATIC"
1505       AC_DEFINE(STATIC_SASLDB,[],[Link SASLdb Staticly])
1506     else
1507       SASL_STATIC_OBJS="$SASL_STATIC_OBJS $SASL_DB_BACKEND_STATIC"
1508       SASL_STATIC_SRCS="$SASL_STATIC_SRCS $SASL_DB_BACKEND_STATIC_SRCS"
1509     fi
1510 fi
1511
1512 AC_SUBST(SASL_DB_UTILS)
1513 AC_SUBST(SASL_DB_MANS)
1514 AC_SUBST(SASL_DB_BACKEND)
1515 AC_SUBST(SASL_DB_BACKEND_STATIC)
1516 AC_SUBST(SASL_DB_INC)
1517 AC_SUBST(SASL_DB_LIB)
1518 ])
1519
1520 dnl Figure out what database path we're using
1521 AC_DEFUN([SASL_DB_PATH_CHECK], [
1522 AC_ARG_WITH(dbpath, [  --with-dbpath=PATH      set the DB path to use [/etc/sasldb2] ],
1523   dbpath=$withval,
1524   dbpath=/etc/sasldb2)
1525 AC_MSG_CHECKING(DB path to use)
1526 AC_MSG_RESULT($dbpath)
1527 AC_DEFINE_UNQUOTED(SASL_DB_PATH, "$dbpath", [Path to default SASLdb database])])
1528
1529 dnl $Id: berkdb.m4,v 1.20 2005/04/26 19:14:07 shadow Exp $
1530
1531 AC_DEFUN([CMU_DB_INC_WHERE1], [
1532 saved_CPPFLAGS=$CPPFLAGS
1533 CPPFLAGS="$saved_CPPFLAGS -I$1"
1534 AC_TRY_COMPILE([#include <db.h>],
1535 [DB *db;
1536 db_create(&db, NULL, 0);
1537 db->open(db, "foo.db", NULL, DB_UNKNOWN, DB_RDONLY, 0644);],
1538 ac_cv_found_db_inc=yes,
1539 ac_cv_found_db_inc=no)
1540 CPPFLAGS=$saved_CPPFLAGS
1541 ])
1542
1543 AC_DEFUN([CMU_DB_INC_WHERE], [
1544    for i in $1; do
1545       AC_MSG_CHECKING(for db headers in $i)
1546       CMU_DB_INC_WHERE1($i)
1547       CMU_TEST_INCPATH($i, db)
1548       if test "$ac_cv_found_db_inc" = "yes"; then
1549         ac_cv_db_where_inc=$i
1550         AC_MSG_RESULT(found)
1551         break
1552       else
1553         AC_MSG_RESULT(not found)
1554       fi
1555     done
1556 ])
1557
1558 #
1559 # Test for lib files
1560 #
1561
1562 AC_DEFUN([CMU_DB3_LIB_WHERE1], [
1563 AC_REQUIRE([CMU_AFS])
1564 AC_REQUIRE([CMU_KRB4])
1565 saved_LIBS=$LIBS
1566   LIBS="$saved_LIBS -L$1 -ldb-3"
1567 AC_TRY_LINK([#include <db.h>],
1568 [db_env_create(NULL, 0);],
1569 [ac_cv_found_db_3_lib=yes],
1570 ac_cv_found_db_3_lib=no)
1571 LIBS=$saved_LIBS
1572 ])
1573 AC_DEFUN([CMU_DB4_LIB_WHERE1], [
1574 AC_REQUIRE([CMU_AFS])
1575 AC_REQUIRE([CMU_KRB4])
1576 saved_LIBS=$LIBS
1577 LIBS="$saved_LIBS -L$1 -ldb-4"
1578 AC_TRY_LINK([#include <db.h>],
1579 [db_env_create(NULL, 0);],
1580 [ac_cv_found_db_4_lib=yes],
1581 ac_cv_found_db_4_lib=no)
1582 LIBS=$saved_LIBS
1583 ])
1584
1585 AC_DEFUN([CMU_DB_LIB_WHERE], [
1586    for i in $1; do
1587       AC_MSG_CHECKING(for db libraries in $i)
1588 if test "$enable_db4" = "yes"; then
1589       CMU_DB4_LIB_WHERE1($i)
1590       CMU_TEST_LIBPATH($i, [db-4])
1591       ac_cv_found_db_lib=$ac_cv_found_db_4_lib
1592 else
1593       CMU_DB3_LIB_WHERE1($i)
1594       CMU_TEST_LIBPATH($i, [db-3])
1595       ac_cv_found_db_lib=$ac_cv_found_db_3_lib
1596 fi
1597       if test "$ac_cv_found_db_lib" = "yes" ; then
1598         ac_cv_db_where_lib=$i
1599         AC_MSG_RESULT(found)
1600         break
1601       else
1602         AC_MSG_RESULT(not found)
1603       fi
1604     done
1605 ])
1606
1607 AC_DEFUN([CMU_USE_DB], [
1608 AC_REQUIRE([CMU_FIND_LIB_SUBDIR])
1609 AC_ARG_WITH(db,
1610         [  --with-db=PREFIX      Compile with db support],
1611         [if test "X$with_db" = "X"; then
1612                 with_db=yes
1613         fi])
1614 AC_ARG_WITH(db-lib,
1615         [  --with-db-lib=dir     use db libraries in dir],
1616         [if test "$withval" = "yes" -o "$withval" = "no"; then
1617                 AC_MSG_ERROR([No argument for --with-db-lib])
1618         fi])
1619 AC_ARG_WITH(db-include,
1620         [  --with-db-include=dir use db headers in dir],
1621         [if test "$withval" = "yes" -o "$withval" = "no"; then
1622                 AC_MSG_ERROR([No argument for --with-db-include])
1623         fi])
1624 AC_ARG_ENABLE(db4,
1625         [  --enable-db4          use db 4.x libraries])
1626         
1627         if test "X$with_db" != "X"; then
1628           if test "$with_db" != "yes"; then
1629             ac_cv_db_where_lib=$with_db/$CMU_LIB_SUBDIR
1630             ac_cv_db_where_inc=$with_db/include
1631           fi
1632         fi
1633
1634         if test "X$with_db_lib" != "X"; then
1635           ac_cv_db_where_lib=$with_db_lib
1636         fi
1637         if test "X$ac_cv_db_where_lib" = "X"; then
1638           CMU_DB_LIB_WHERE(/usr/athena/$CMU_LIB_SUBDIR /usr/$CMU_LIB_SUBDIR /usr/local/$CMU_LIB_SUBDIR)
1639         fi
1640
1641         if test "X$with_db_include" != "X"; then
1642           ac_cv_db_where_inc=$with_db_include
1643         fi
1644         if test "X$ac_cv_db_where_inc" = "X"; then
1645           CMU_DB_INC_WHERE(/usr/athena/include /usr/local/include)
1646         fi
1647
1648         AC_MSG_CHECKING(whether to include db)
1649         if test "X$ac_cv_db_where_lib" = "X" -o "X$ac_cv_db_where_inc" = "X"; then
1650           ac_cv_found_db=no
1651           AC_MSG_RESULT(no)
1652         else
1653           ac_cv_found_db=yes
1654           AC_MSG_RESULT(yes)
1655           DB_INC_DIR=$ac_cv_db_where_inc
1656           DB_LIB_DIR=$ac_cv_db_where_lib
1657           DB_INC_FLAGS="-I${DB_INC_DIR}"
1658           if test "$enable_db4" = "yes"; then
1659              DB_LIB_FLAGS="-L${DB_LIB_DIR} -ldb-4"
1660           else
1661              DB_LIB_FLAGS="-L${DB_LIB_DIR} -ldb-3"
1662           fi
1663           dnl Do not force configure.in to put these in CFLAGS and LIBS unconditionally
1664           dnl Allow makefile substitutions....
1665           AC_SUBST(DB_INC_FLAGS)
1666           AC_SUBST(DB_LIB_FLAGS)
1667           if test "X$RPATH" = "X"; then
1668                 RPATH=""
1669           fi
1670           case "${host}" in
1671             *-*-linux*)
1672               if test "X$RPATH" = "X"; then
1673                 RPATH="-Wl,-rpath,${DB_LIB_DIR}"
1674               else 
1675                 RPATH="${RPATH}:${DB_LIB_DIR}"
1676               fi
1677               ;;
1678             *-*-hpux*)
1679               if test "X$RPATH" = "X"; then
1680                 RPATH="-Wl,+b${DB_LIB_DIR}"
1681               else 
1682                 RPATH="${RPATH}:${DB_LIB_DIR}"
1683               fi
1684               ;;
1685             *-*-irix*)
1686               if test "X$RPATH" = "X"; then
1687                 RPATH="-Wl,-rpath,${DB_LIB_DIR}"
1688               else 
1689                 RPATH="${RPATH}:${DB_LIB_DIR}"
1690               fi
1691               ;;
1692             *-*-solaris2*)
1693               if test "$ac_cv_prog_gcc" = yes; then
1694                 if test "X$RPATH" = "X"; then
1695                   RPATH="-Wl,-R${DB_LIB_DIR}"
1696                 else 
1697                   RPATH="${RPATH}:${DB_LIB_DIR}"
1698                 fi
1699               else
1700                 RPATH="${RPATH} -R${DB_LIB_DIR}"
1701               fi
1702               ;;
1703           esac
1704           AC_SUBST(RPATH)
1705         fi
1706         ])
1707
1708
1709
1710 dnl ---- CUT HERE ---
1711
1712 dnl These are the Cyrus Berkeley DB macros.  In an ideal world these would be
1713 dnl identical to the above.
1714
1715 dnl They are here so that they can be shared between Cyrus IMAPd
1716 dnl and Cyrus SASL with relative ease.
1717
1718 dnl The big difference between this and the ones above is that we don't assume
1719 dnl that we know the name of the library, and we try a lot of permutations
1720 dnl instead.  We also assume that DB4 is acceptable.
1721
1722 dnl When we're done, there will be a BDB_LIBADD and a BDB_INCADD which should
1723 dnl be used when necessary.  We should probably be smarter about our RPATH
1724 dnl handling.
1725
1726 dnl Call these with BERKELEY_DB_CHK.
1727
1728 dnl We will also set $dblib to "berkeley" if we are successful, "no" otherwise.
1729
1730 dnl this is unbelievably painful due to confusion over what db-3 should be
1731 dnl named and where the db-3 header file is located.  arg.
1732 AC_DEFUN([CYRUS_BERKELEY_DB_CHK_LIB],
1733 [
1734         BDB_SAVE_LDFLAGS=$LDFLAGS
1735
1736         if test -d $with_bdb_lib; then
1737             CMU_ADD_LIBPATH_TO($with_bdb_lib, LDFLAGS)
1738             CMU_ADD_LIBPATH_TO($with_bdb_lib, BDB_LIBADD)
1739         else
1740             BDB_LIBADD=""
1741         fi
1742
1743         saved_LIBS=$LIBS
1744         for dbname in db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db-3.3 db3.3 db33 db-3.2 db3.2 db32 db-3.1 db3.1 db31 db-3 db30 db3 db
1745           do
1746             LIBS="$saved_LIBS -l$dbname"
1747             AC_TRY_LINK([#include <db.h>],
1748             [db_create(NULL, NULL, 0);],
1749             BDB_LIBADD="$BDB_LIBADD -l$dbname"; dblib="berkeley"; dbname=db,
1750             dblib="no")
1751             if test "$dblib" = "berkeley"; then break; fi
1752           done
1753         if test "$dblib" = "no"; then
1754             LIBS="$saved_LIBS -ldb"
1755             AC_TRY_LINK([#include <db.h>],
1756             [db_open(NULL, 0, 0, 0, NULL, NULL, NULL);],
1757             BDB_LIBADD="$BDB_LIBADD -ldb"; dblib="berkeley"; dbname=db,
1758             dblib="no")
1759         fi
1760         LIBS=$saved_LIBS
1761
1762         LDFLAGS=$BDB_SAVE_LDFLAGS
1763 ])
1764
1765 AC_DEFUN([CYRUS_BERKELEY_DB_OPTS],
1766 [
1767 AC_ARG_WITH(bdb-libdir,
1768         [  --with-bdb-libdir=DIR   Berkeley DB lib files are in DIR],
1769         with_bdb_lib=$withval,
1770         [ test "${with_bdb_lib+set}" = set || with_bdb_lib=none])
1771 AC_ARG_WITH(bdb-incdir,
1772         [  --with-bdb-incdir=DIR   Berkeley DB include files are in DIR],
1773         with_bdb_inc=$withval,
1774         [ test "${with_bdb_inc+set}" = set || with_bdb_inc=none ])
1775 ])
1776
1777 AC_DEFUN([CYRUS_BERKELEY_DB_CHK],
1778 [
1779         AC_REQUIRE([CYRUS_BERKELEY_DB_OPTS])
1780
1781         cmu_save_CPPFLAGS=$CPPFLAGS
1782
1783         if test -d $with_bdb_inc; then
1784             CPPFLAGS="$CPPFLAGS -I$with_bdb_inc"
1785             BDB_INCADD="-I$with_bdb_inc"
1786         else
1787             BDB_INCADD=""
1788         fi
1789
1790         dnl Note that FreeBSD puts it in a wierd place
1791         dnl (but they should use with-bdb-incdir)
1792         AC_CHECK_HEADER(db.h,
1793                         [CYRUS_BERKELEY_DB_CHK_LIB()],
1794                         dblib="no")
1795
1796         CPPFLAGS=$cmu_save_CPPFLAGS
1797 ])
1798
1799 dnl $Id: common.m4,v 1.13 2006/02/25 18:29:46 cg2v Exp $
1800
1801 AC_DEFUN([CMU_TEST_LIBPATH], [
1802 changequote(<<, >>)
1803 define(<<CMU_AC_CV_FOUND>>, translit(ac_cv_found_$2_lib, <<- *>>, <<__p>>))
1804 changequote([, ])
1805 if test "$CMU_AC_CV_FOUND" = "yes"; then
1806   if test \! -r "$1/lib$2.a" -a \! -r "$1/lib$2.so" -a \! -r "$1/lib$2.sl" -a \! -r "$1/lib$2.dylib"; then
1807     CMU_AC_CV_FOUND=no
1808   fi
1809 fi
1810 ])
1811
1812 AC_DEFUN([CMU_TEST_INCPATH], [
1813 changequote(<<, >>)
1814 define(<<CMU_AC_CV_FOUND>>, translit(ac_cv_found_$2_inc, [ *], [_p]))
1815 changequote([, ])
1816 if test "$CMU_AC_CV_FOUND" = "yes"; then
1817   if test \! -r "$1/$2.h"; then
1818     CMU_AC_CV_FOUND=no
1819   fi
1820 fi
1821 ])
1822
1823 dnl CMU_CHECK_HEADER_NOCACHE(HEADER-FILE, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
1824 AC_DEFUN([CMU_CHECK_HEADER_NOCACHE],
1825 [dnl Do the transliteration at runtime so arg 1 can be a shell variable.
1826 ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
1827 AC_MSG_CHECKING([for $1])
1828 AC_TRY_CPP([#include <$1>], eval "ac_cv_header_$ac_safe=yes",
1829   eval "ac_cv_header_$ac_safe=no")
1830 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
1831   AC_MSG_RESULT(yes)
1832   ifelse([$2], , :, [$2])
1833 else
1834   AC_MSG_RESULT(no)
1835 ifelse([$3], , , [$3
1836 ])dnl
1837 fi
1838 ])
1839
1840 AC_DEFUN([CMU_FIND_LIB_SUBDIR],
1841 [dnl
1842 AC_ARG_WITH([lib-subdir], AC_HELP_STRING([--with-lib-subdir=DIR],[Find libraries in DIR instead of lib]))
1843 AC_CHECK_SIZEOF(long)
1844 AC_CACHE_CHECK([what directory libraries are found in], [ac_cv_cmu_lib_subdir],
1845 [test "X$with_lib_subdir" = "Xyes" && with_lib_subdir=
1846 test "X$with_lib_subdir" = "Xno" && with_lib_subdir=
1847 if test "X$with_lib_subdir" = "X" ; then
1848   ac_cv_cmu_lib_subdir=lib
1849   if test $ac_cv_sizeof_long -eq 4 ; then
1850     test -d /usr/lib32 && ac_cv_cmu_lib_subdir=lib32
1851   fi
1852   if test $ac_cv_sizeof_long -eq 8 ; then
1853     test -d /usr/lib64 && ac_cv_cmu_lib_subdir=lib64
1854   fi
1855 else
1856   ac_cv_cmu_lib_subdir=$with_lib_subdir
1857 fi])
1858 AC_SUBST(CMU_LIB_SUBDIR, $ac_cv_cmu_lib_subdir)
1859 ])
1860
1861 dnl afs.m4--AFS libraries, includes, and dependencies
1862 dnl $Id: afs.m4,v 1.29 2005/04/26 19:14:07 shadow Exp $
1863 dnl Chaskiel Grundman
1864 dnl based on kerberos_v4.m4
1865 dnl Derrick Brashear
1866 dnl from KTH krb and Arla
1867
1868 AC_DEFUN([CMU_AFS_INC_WHERE1], [
1869 cmu_save_CPPFLAGS=$CPPFLAGS
1870 CPPFLAGS="$cmu_save_CPPFLAGS -I$1"
1871 AC_TRY_COMPILE([#include <afs/param.h>],
1872 [#ifndef SYS_NAME
1873 choke me
1874 #endif
1875 int foo;],
1876 ac_cv_found_afs_inc=yes,
1877 ac_cv_found_afs_inc=no)
1878 CPPFLAGS=$cmu_save_CPPFLAGS
1879 ])
1880
1881 AC_DEFUN([CMU_AFS_LIB_WHERE1], [
1882 save_LIBS="$LIBS"
1883 save_LDFLAGS="$LDFLAGS"
1884
1885 LIBS="-lauth $1/afs/util.a $LIB_SOCKET $LIBS"
1886 LDFLAGS="-L$1 -L$1/afs $LDFLAGS"
1887 dnl suppress caching
1888 AC_TRY_LINK([],[afsconf_Open();], ac_cv_found_afs_lib=yes, ac_cv_found_afs_lib=no)
1889 LIBS="$save_LIBS"
1890 LDFLAGS="$save_LDFLAGS"
1891 ])
1892
1893 AC_DEFUN([CMU_AFS_WHERE], [
1894 AC_REQUIRE([CMU_FIND_LIB_SUBDIR])
1895    for i in $1; do
1896       AC_MSG_CHECKING(for AFS in $i)
1897       CMU_AFS_INC_WHERE1("$i/include")
1898       ac_cv_found_lwp_inc=$ac_cv_found_afs_inc
1899       CMU_TEST_INCPATH($i/include, lwp) 
1900       ac_cv_found_afs_inc=$ac_cv_found_lwp_inc
1901       if test "$ac_cv_found_afs_inc" = "yes"; then
1902         CMU_AFS_LIB_WHERE1("$i/$CMU_LIB_SUBDIR")
1903         if test "$ac_cv_found_afs_lib" = "yes"; then
1904           ac_cv_afs_where=$i
1905           AC_MSG_RESULT(found)
1906           break
1907         else
1908           AC_MSG_RESULT(not found)
1909         fi
1910       else
1911         AC_MSG_RESULT(not found)
1912       fi
1913     done
1914 ])
1915
1916 AC_DEFUN([CMU_AFS], [
1917 AC_REQUIRE([CMU_FIND_LIB_SUBDIR])
1918 AC_REQUIRE([CMU_SOCKETS])
1919 AC_REQUIRE([CMU_LIBSSL])
1920 AC_ARG_WITH(AFS,
1921         [  --with-afs=PREFIX      Compile with AFS support],
1922         [if test "X$with_AFS" = "X"; then
1923                 with_AFS=yes
1924         fi])
1925
1926         if test "X$with_AFS" != "X"; then
1927           ac_cv_afs_where=$with_AFS
1928         fi
1929         if test "X$ac_cv_afs_where" = "X"; then
1930           CMU_AFS_WHERE(/usr/afsws /usr/local /usr/athena /Library/OpenAFS/Tools)
1931         fi
1932
1933         AC_MSG_CHECKING(whether to include AFS)
1934         if test "X$ac_cv_afs_where" = "Xno" -o "X$ac_cv_afs_where" = "X"; then
1935           ac_cv_found_afs=no
1936           AC_MSG_RESULT(no)
1937         else
1938           ac_cv_found_afs=yes
1939           AC_MSG_RESULT(yes)
1940           AFS_INC_DIR="$ac_cv_afs_where/include"
1941           AFS_LIB_DIR="$ac_cv_afs_where/$CMU_LIB_SUBDIR"
1942           AFS_TOP_DIR="$ac_cv_afs_where"
1943           AFS_INC_FLAGS="-I${AFS_INC_DIR}"
1944           AFS_LIB_FLAGS="-L${AFS_LIB_DIR} -L${AFS_LIB_DIR}/afs"
1945           cmu_save_LIBS="$LIBS"
1946           cmu_save_CPPFLAGS="$CPPFLAGS"
1947           CPPFLAGS="$CPPFLAGS ${AFS_INC_FLAGS}"
1948           cmu_save_LDFLAGS="$LDFLAGS"
1949           LDFLAGS="$cmu_save_LDFLAGS ${AFS_LIB_FLAGS}"
1950                         
1951           AC_CHECK_HEADERS(afs/stds.h)
1952
1953           AC_MSG_CHECKING([if libdes is needed])
1954           AC_TRY_LINK([],[des_quad_cksum();],AFS_DES_LIB="",AFS_DES_LIB="maybe")
1955           if test "X$AFS_DES_LIB" != "X"; then
1956               LIBS="$cmu_save_LIBS -ldes"
1957               AC_TRY_LINK([], [des_quad_cksum();],AFS_DES_LIB="yes")
1958               if test "X$AFS_DES_LIB" = "Xyes"; then
1959                   AC_MSG_RESULT([yes])
1960                   AFS_LIBDES="-ldes"
1961                   AFS_LIBDESA="${AFS_LIB_DIR}/libdes.a"
1962               else
1963                   LIBS="$cmu_save_LIBS $LIBSSL_LIB_FLAGS"
1964                   AC_TRY_LINK([],
1965                   [des_quad_cksum();],AFS_DES_LIB="libcrypto")
1966                   if test "X$AFS_DES_LIB" = "Xlibcrypto"; then
1967                       AC_MSG_RESULT([libcrypto])
1968                       AFS_LIBDES="$LIBSSL_LIB_FLAGS"
1969                       AFS_LIBDESA="$LIBSSL_LIB_FLAGS"
1970                   else
1971                       LIBS="$cmu_save_LIBS -L$LIBSSL_LIB_DIR -ldescompat $LIBSSL_LIB_FLAGS"
1972                       AC_TRY_LINK([],
1973                       [des_quad_cksum();],AFS_DES_LIB="libcrypto+descompat")
1974                       if test "X$AFS_DES_LIB" = "Xlibcrypto+descompat"; then
1975                           AC_MSG_RESULT([libcrypto+descompat])
1976                           AFS_LIBDES="-L$LIBSSL_LIB_DIR -ldescompat $LIBSSL_LIB_FLAGS"
1977                           AFS_LIBDESA="-L$LIBSSL_LIB_DIR -ldescompat $LIBSSL_LIB_FLAGS"
1978                       else
1979                           AC_MSG_RESULT([unknown])
1980                           AC_MSG_ERROR([Could not use -ldes])
1981                       fi 
1982                   fi 
1983               fi 
1984           else
1985              AC_MSG_RESULT([no])
1986           fi
1987
1988
1989           AFS_CLIENT_LIBS_STATIC="${AFS_LIB_DIR}/afs/libvolser.a ${AFS_LIB_DIR}/afs/libvldb.a ${AFS_LIB_DIR}/afs/libkauth.a ${AFS_LIB_DIR}/afs/libprot.a ${AFS_LIB_DIR}/libubik.a ${AFS_LIB_DIR}/afs/libauth.a ${AFS_LIB_DIR}/librxkad.a ${AFS_LIB_DIR}/librx.a ${AFS_LIB_DIR}/afs/libsys.a ${AFS_LIB_DIR}/librx.a ${AFS_LIB_DIR}/liblwp.a ${AFS_LIBDESA} ${AFS_LIB_DIR}/afs/libcmd.a ${AFS_LIB_DIR}/afs/libcom_err.a ${AFS_LIB_DIR}/afs/util.a"
1990           AFS_KTC_LIBS_STATIC="${AFS_LIB_DIR}/afs/libauth.a ${AFS_LIB_DIR}/afs/libsys.a ${AFS_LIB_DIR}/librx.a ${AFS_LIB_DIR}/liblwp.a ${AFS_LIBDESA} ${AFS_LIB_DIR}/afs/libcom_err.a ${AFS_LIB_DIR}/afs/util.a"
1991           AFS_CLIENT_LIBS="-lvolser -lvldb -lkauth -lprot -lubik -lauth -lrxkad -lrx ${AFS_LIB_DIR}/afs/libsys.a -lrx -llwp ${AFS_LIBDES} -lcmd -lcom_err ${AFS_LIB_DIR}/afs/util.a"
1992           AFS_RX_LIBS="-lauth -lrxkad -lrx ${AFS_LIB_DIR}/afs/libsys.a -lrx -llwp ${AFS_LIBDES} -lcmd -lcom_err ${AFS_LIB_DIR}/afs/util.a"
1993           AFS_KTC_LIBS="-lauth ${AFS_LIB_DIR}/afs/libsys.a -lrx -llwp ${AFS_LIBDES} -lcom_err ${AFS_LIB_DIR}/afs/util.a"
1994
1995           LIBS="$cmu_save_LIBS $AFS_CLIENT_LIBS ${LIB_SOCKET}"
1996           AC_CHECK_FUNC(des_pcbc_init)
1997           if test "X$ac_cv_func_des_pcbc_init" != "Xyes"; then
1998            AC_CHECK_LIB(descompat, des_pcbc_init, AFS_DESCOMPAT_LIB="-ldescompat")
1999            if test "X$AFS_DESCOMPAT_LIB" != "X" ; then
2000                 AFS_CLIENT_LIBS_STATIC="$AFS_CLIENT_LIBS_STATIC $AFS_DESCOMPAT_LIB"
2001                 AFS_KTC_LIBS_STATIC="$AFS_KTC_LIBS_STATIC $AFS_DESCOMPAT_LIB"
2002                 AFS_CLIENT_LIBS="$AFS_CLIENT_LIBS $AFS_DESCOMPAT_LIB"
2003                 AFS_KTC_LIBS="$AFS_KTC_LIBS $AFS_DESCOMPAT_LIB"
2004            else
2005
2006            AC_MSG_CHECKING([if rxkad needs des_pcbc_init])
2007            AC_TRY_LINK(,[tkt_DecodeTicket();],RXKAD_PROBLEM=no,RXKAD_PROBLEM=maybe)
2008             if test "$RXKAD_PROBLEM" = "maybe"; then
2009               AC_TRY_LINK([int des_pcbc_init() { return 0;}],
2010               [tkt_DecodeTicket();],RXKAD_PROBLEM=yes,RXKAD_PROBLEM=error)
2011               if test "$RXKAD_PROBLEM" = "yes"; then
2012                     AC_MSG_RESULT([yes])
2013                     AC_MSG_ERROR([cannot use rxkad])
2014               else
2015                     AC_MSG_RESULT([unknown])        
2016                     AC_MSG_ERROR([Unknown error testing rxkad])
2017               fi
2018             else
2019               AC_MSG_RESULT([no])
2020             fi
2021            fi
2022           fi
2023
2024           LIBS="$cmu_save_LIBS"
2025           AC_CHECK_FUNC(flock)
2026           LIBS="$cmu_save_LIBS ${AFS_CLIENT_LIBS} ${LIB_SOCKET}"
2027           if test "X$ac_cv_func_flock" != "Xyes"; then
2028              AC_MSG_CHECKING([if AFS needs flock])
2029              AC_TRY_LINK([#include <afs/param.h>
2030 #ifdef HAVE_AFS_STDS_H
2031 #include <afs/stds.h>
2032 #endif
2033 #include <ubik.h>
2034 #include <afs/cellconfig.h>
2035 #include <afs/auth.h>
2036 #include <afs/volser.h>
2037 struct ubik_client * cstruct;
2038 int sigvec() {return 0;}
2039 extern int UV_SetSecurity();],
2040              [vsu_ClientInit(1,"","",0,
2041                              &cstruct,UV_SetSecurity)],
2042              AFS_FLOCK=no,AFS_FLOCK=yes)
2043              if test $AFS_FLOCK = "no"; then
2044                 AC_MSG_RESULT([no])
2045              else
2046                AC_MSG_RESULT([yes])
2047                LDFLAGS="$LDFLAGS -L/usr/ucblib"
2048                AC_CHECK_LIB(ucb, flock,:, [AC_CHECK_LIB(BSD, flock)])
2049              fi
2050           fi
2051           LIBS="$cmu_save_LIBS"
2052           AC_CHECK_FUNC(sigvec)
2053           LIBS="$cmu_save_LIBS ${AFS_CLIENT_LIBS} ${LIB_SOCKET}"
2054           if test "X$ac_cv_func_sigvec" != "Xyes"; then
2055              AC_MSG_CHECKING([if AFS needs sigvec])
2056              AC_TRY_LINK([#include <afs/param.h>
2057 #ifdef HAVE_AFS_STDS_H
2058 #include <afs/stds.h>
2059 #endif
2060 #include <ubik.h>
2061 #include <afs/cellconfig.h>
2062 #include <afs/auth.h>
2063 #include <afs/volser.h>
2064 struct ubik_client * cstruct;
2065 int flock() {return 0;}
2066 extern int UV_SetSecurity();],
2067              [vsu_ClientInit(1,"","",0,
2068                              &cstruct,UV_SetSecurity)],
2069              AFS_SIGVEC=no,AFS_SIGVEC=yes)
2070              if test $AFS_SIGVEC = "no"; then
2071                 AC_MSG_RESULT([no])
2072              else
2073                AC_MSG_RESULT([yes])
2074                LDFLAGS="$LDFLAGS -L/usr/ucblib"
2075                AC_CHECK_LIB(ucb, sigvec,:,[AC_CHECK_LIB(BSD, sigvec)])
2076              fi
2077           fi
2078           if test "$ac_cv_lib_ucb_flock" = "yes" -o "$ac_cv_lib_ucb_sigvec" = "yes"; then
2079              AFS_LIB_FLAGS="${AFS_LIB_FLAGS} -L/usr/ucblib -R/usr/ucblib"
2080           fi
2081           if test "$ac_cv_lib_ucb_flock" = "yes" -o "$ac_cv_lib_ucb_sigvec" = "yes"; then
2082              AFS_BSD_LIB="-lucb"
2083           elif test "$ac_cv_lib_BSD_flock" = "yes" -o "$ac_cv_lib_BSD_sigvec" = "yes"; then
2084              AFS_BSD_LIB="-lBSD"
2085           fi
2086           if test "X$AFS_BSD_LIB" != "X" ; then
2087                 AFS_CLIENT_LIBS_STATIC="$AFS_CLIENT_LIBS_STATIC $AFS_BSD_LIB"
2088                 AFS_KTC_LIBS_STATIC="$AFS_KTC_LIBS_STATIC $AFS_BSD_LIB"
2089                 AFS_CLIENT_LIBS="$AFS_CLIENT_LIBS $AFS_BSD_LIB"
2090                 AFS_RX_LIBS="$AFS_CLIENT_LIBS $AFS_BSD_LIB"
2091                 AFS_KTC_LIBS="$AFS_KTC_LIBS $AFS_BSD_LIB"
2092           fi
2093
2094           AC_MSG_CHECKING([if libaudit is needed])
2095           AFS_LIBAUDIT=""
2096           LIBS="$cmu_save_LIBS $AFS_CLIENT_LIBS ${LIB_SOCKET}"
2097           AC_TRY_LINK([#include <afs/param.h>
2098 #ifdef HAVE_AFS_STDS_H
2099 #include <afs/stds.h>
2100 #endif
2101 #include <afs/cellconfig.h>
2102 #include <afs/auth.h>],
2103           [afsconf_SuperUser();],AFS_AUDIT_LIB="",AFS_AUDIT_LIB="maybe")
2104           if test "X$AFS_AUDIT_LIB" != "X"; then
2105           LIBS="$cmu_save_LIBS -lvolser -lvldb -lkauth -lprot -lubik -lauth -laudit -lrxkad -lrx ${AFS_LIB_DIR}/afs/libsys.a -lrx -llwp ${AFS_LIBDES} -lcmd -lcom_err ${AFS_LIB_DIR}/afs/util.a $AFS_BSD_LIB $AFS_DESCOMPAT_LIB $LIB_SOCKET"
2106              AC_TRY_LINK([#include <afs/param.h>
2107 #ifdef HAVE_AFS_STDS_H
2108 #include <afs/stds.h>
2109 #endif
2110 #include <afs/cellconfig.h>
2111 #include <afs/auth.h>],
2112              [afsconf_SuperUser();],AFS_AUDIT_LIB="yes")
2113              if test "X$AFS_AUDIT_LIB" = "Xyes"; then
2114                  AC_MSG_RESULT([yes])
2115                  AFS_LIBAUDIT="-laudit"
2116                  AFS_CLIENT_LIBS_STATIC="${AFS_LIB_DIR}/afs/libvolser.a ${AFS_LIB_DIR}/afs/libvldb.a ${AFS_LIB_DIR}/afs/libkauth.a ${AFS_LIB_DIR}/afs/libprot.a ${AFS_LIB_DIR}/libubik.a ${AFS_LIB_DIR}/afs/libauth.a ${AFS_LIB_DIR}/afs/libaudit.a ${AFS_LIB_DIR}/librxkad.a ${AFS_LIB_DIR}/librx.a ${AFS_LIB_DIR}/afs/libsys.a ${AFS_LIB_DIR}/librx.a ${AFS_LIB_DIR}/liblwp.a ${AFS_LIBDESA} ${AFS_LIB_DIR}/afs/libcmd.a ${AFS_LIB_DIR}/afs/libcom_err.a ${AFS_LIB_DIR}/afs/util.a"
2117                  AFS_CLIENT_LIBS="-lvolser -lvldb -lkauth -lprot -lubik -lauth -laudit -lrxkad -lrx ${AFS_LIB_DIR}/afs/libsys.a -lrx -llwp ${AFS_LIBDES} -lcmd -lcom_err ${AFS_LIB_DIR}/afs/util.a $AFS_BSD_LIB $AFS_DESCOMPAT_LIB"
2118                  AFS_RX_LIBS="-lauth -laudit -lrxkad -lrx ${AFS_LIB_DIR}/afs/libsys.a -lrx -llwp ${AFS_LIBDES} -lcmd -lcom_err ${AFS_LIB_DIR}/afs/util.a $AFS_BSD_LIB $AFS_DESCOMPAT_LIB"
2119              else
2120                  AC_MSG_RESULT([unknown])
2121                  AC_MSG_ERROR([Could not use -lauth while testing for -laudit])
2122              fi 
2123           else
2124              AC_MSG_RESULT([no])
2125           fi
2126
2127           AC_CHECK_FUNCS(VL_ProbeServer)
2128           AC_MSG_CHECKING([if new-style afs_ integer types are defined])
2129           AC_CACHE_VAL(ac_cv_afs_int32,
2130 dnl The next few lines contain a quoted argument to egrep
2131 dnl It is critical that there be no leading or trailing whitespace
2132 dnl or newlines
2133 [AC_EGREP_CPP(dnl
2134 changequote(<<,>>)dnl
2135 <<(^|[^a-zA-Z_0-9])afs_int32[^a-zA-Z_0-9]>>dnl
2136 changequote([,]), [#include <afs/param.h>
2137 #ifdef HAVE_AFS_STDS_H
2138 #include <afs/stds.h>
2139 #endif],
2140 ac_cv_afs_int32=yes, ac_cv_afs_int32=no)])
2141           AC_MSG_RESULT($ac_cv_afs_int32)
2142           if test $ac_cv_afs_int32 = yes ; then
2143             AC_DEFINE(HAVE_AFS_INT32,, [AFS provides new "unambiguous" type names])
2144           else
2145             AC_DEFINE(afs_int16, int16, [it's a type definition])
2146             AC_DEFINE(afs_int32, int32, [it's a type definition])
2147             AC_DEFINE(afs_uint16, u_int16, [it's a type definition])
2148             AC_DEFINE(afs_uint32, u_int32, [it's a type definition])
2149           fi
2150
2151           CPPFLAGS="${cmu_save_CPPFLAGS}"
2152           LDFLAGS="${cmu_save_LDFLAGS}"
2153           LIBS="${cmu_save_LIBS}"
2154           AC_DEFINE(AFS_ENV,, [Use AFS. (find what needs this and nuke it)])
2155           AC_DEFINE(AFS,, [Use AFS. (find what needs this and nuke it)])
2156           AC_SUBST(AFS_CLIENT_LIBS_STATIC)
2157           AC_SUBST(AFS_KTC_LIBS_STATIC)
2158           AC_SUBST(AFS_CLIENT_LIBS)
2159           AC_SUBST(AFS_RX_LIBS)
2160           AC_SUBST(AFS_KTC_LIBS)
2161           AC_SUBST(AFS_INC_FLAGS)
2162           AC_SUBST(AFS_LIB_FLAGS)
2163           AC_SUBST(AFS_TOP_DIR)
2164           AC_SUBST(AFS_LIBAUDIT)
2165           AC_SUBST(AFS_LIBDES)
2166           AC_SUBST(AFS_LIBDESA)
2167         fi
2168         ])
2169
2170 AC_DEFUN([CMU_NEEDS_AFS],
2171 [AC_REQUIRE([CMU_AFS])
2172 if test "$ac_cv_found_afs" != "yes"; then
2173         AC_ERROR([Cannot continue without AFS])
2174 fi])
2175
2176 dnl libssl.m4--Ssl libraries and includes
2177 dnl Derrick Brashear
2178 dnl from KTH kafs and Arla
2179 dnl $Id: libssl.m4,v 1.10 2005/04/26 19:14:08 shadow Exp $
2180
2181 AC_DEFUN([CMU_LIBSSL_INC_WHERE1], [
2182 saved_CPPFLAGS=$CPPFLAGS
2183 CPPFLAGS="$saved_CPPFLAGS -I$1"
2184 CMU_CHECK_HEADER_NOCACHE(openssl/ssl.h,
2185 ac_cv_found_libssl_inc=yes,
2186 ac_cv_found_libssl_inc=no)
2187 CPPFLAGS=$saved_CPPFLAGS
2188 ])
2189
2190 AC_DEFUN([CMU_LIBSSL_INC_WHERE], [
2191    for i in $1; do
2192       AC_MSG_CHECKING(for libssl headers in $i)
2193       CMU_LIBSSL_INC_WHERE1($i)
2194       CMU_TEST_INCPATH($i, ssl)
2195       if test "$ac_cv_found_libssl_inc" = "yes"; then
2196         ac_cv_libssl_where_inc=$i
2197         AC_MSG_RESULT(found)
2198         break
2199       else
2200         AC_MSG_RESULT(not found)
2201       fi
2202     done
2203 ])
2204
2205 AC_DEFUN([CMU_LIBSSL_LIB_WHERE1], [
2206 saved_LIBS=$LIBS
2207 LIBS="$saved_LIBS -L$1 -lssl -lcrypto $LIB_SOCKET"
2208 AC_TRY_LINK(,
2209 [SSL_write();],
2210 [ac_cv_found_ssl_lib=yes],
2211 ac_cv_found_ssl_lib=no)
2212 LIBS=$saved_LIBS
2213 ])
2214
2215 AC_DEFUN([CMU_LIBSSL_LIB_WHERE], [
2216    for i in $1; do
2217       AC_MSG_CHECKING(for libssl libraries in $i)
2218       CMU_LIBSSL_LIB_WHERE1($i)
2219       dnl deal with false positives from implicit link paths
2220       CMU_TEST_LIBPATH($i, ssl)
2221       if test "$ac_cv_found_ssl_lib" = "yes" ; then
2222         ac_cv_libssl_where_lib=$i
2223         AC_MSG_RESULT(found)
2224         break
2225       else
2226         AC_MSG_RESULT(not found)
2227       fi
2228     done
2229 ])
2230
2231 AC_DEFUN([CMU_LIBSSL], [
2232 AC_REQUIRE([CMU_FIND_LIB_SUBDIR])
2233 AC_REQUIRE([CMU_SOCKETS])
2234 AC_ARG_WITH(libssl,
2235         [  --with-libssl=PREFIX      Compile with Libssl support],
2236         [if test "X$with_libssl" = "X"; then
2237                 with_libssl=yes
2238         fi])
2239 AC_ARG_WITH(libssl-lib,
2240         [  --with-libssl-lib=dir     use libssl libraries in dir],
2241         [if test "$withval" = "yes" -o "$withval" = "no"; then
2242                 AC_MSG_ERROR([No argument for --with-libssl-lib])
2243         fi])
2244 AC_ARG_WITH(libssl-include,
2245         [  --with-libssl-include=dir use libssl headers in dir],
2246         [if test "$withval" = "yes" -o "$withval" = "no"; then
2247                 AC_MSG_ERROR([No argument for --with-libssl-include])
2248         fi])
2249
2250         if test "X$with_libssl" != "X"; then
2251           if test "$with_libssl" != "yes" -a "$with_libssl" != no; then
2252             ac_cv_libssl_where_lib=$with_libssl/$CMU_LIB_SUBDIR
2253             ac_cv_libssl_where_inc=$with_libssl/include
2254           fi
2255         fi
2256
2257         if test "$with_libssl" != "no"; then 
2258           if test "X$with_libssl_lib" != "X"; then
2259             ac_cv_libssl_where_lib=$with_libssl_lib
2260           fi
2261           if test "X$ac_cv_libssl_where_lib" = "X"; then
2262             CMU_LIBSSL_LIB_WHERE(/usr/local/$CMU_LIB_SUBDIR/openssl /usr/$CMU_LIB_SUBDIR/openssl /usr/local/$CMU_LIB_SUBDIR /usr/$CMU_LIB_SUBDIR)
2263           fi
2264
2265           if test "X$with_libssl_include" != "X"; then
2266             ac_cv_libssl_where_inc=$with_libssl_include
2267           fi
2268           if test "X$ac_cv_libssl_where_inc" = "X"; then
2269             CMU_LIBSSL_INC_WHERE(/usr/local/include /usr/include)
2270           fi
2271         fi
2272
2273         AC_MSG_CHECKING(whether to include libssl)
2274         if test "X$ac_cv_libssl_where_lib" = "X" -a "X$ac_cv_libssl_where_inc" = "X"; then
2275           ac_cv_found_libssl=no
2276           AC_MSG_RESULT(no)
2277         else
2278           ac_cv_found_libssl=yes
2279           AC_MSG_RESULT(yes)
2280           LIBSSL_INC_DIR=$ac_cv_libssl_where_inc
2281           LIBSSL_LIB_DIR=$ac_cv_libssl_where_lib
2282           LIBSSL_INC_FLAGS="-I${LIBSSL_INC_DIR}"
2283           LIBSSL_LIB_FLAGS="-L${LIBSSL_LIB_DIR} -lssl -lcrypto"
2284           if test "X$RPATH" = "X"; then
2285                 RPATH=""
2286           fi
2287           case "${host}" in
2288             *-*-linux*)
2289               if test "X$RPATH" = "X"; then
2290                 RPATH="-Wl,-rpath,${LIBSSL_LIB_DIR}"
2291               else 
2292                 RPATH="${RPATH}:${LIBSSL_LIB_DIR}"
2293               fi
2294               ;;
2295             *-*-hpux*)
2296               if test "X$RPATH" = "X"; then
2297                 RPATH="-Wl,+b${LIBSSL_LIB_DIR}"
2298               else 
2299                 RPATH="${RPATH}:${LIBSSL_LIB_DIR}"
2300               fi
2301               ;;
2302             *-*-irix*)
2303               if test "X$RPATH" = "X"; then
2304                 RPATH="-Wl,-rpath,${LIBSSL_LIB_DIR}"
2305               else 
2306                 RPATH="${RPATH}:${LIBSSL_LIB_DIR}"
2307               fi
2308               ;;
2309             *-*-solaris2*)
2310               if test "$ac_cv_prog_gcc" = yes; then
2311                 if test "X$RPATH" = "X"; then
2312                   RPATH="-Wl,-R${LIBSSL_LIB_DIR}"
2313                 else 
2314                   RPATH="${RPATH}:${LIBSSL_LIB_DIR}"
2315                 fi
2316               else
2317                 RPATH="${RPATH} -R${LIBSSL_LIB_DIR}"
2318               fi
2319               ;;
2320           esac
2321           AC_SUBST(RPATH)
2322         fi
2323         AC_SUBST(LIBSSL_INC_DIR)
2324         AC_SUBST(LIBSSL_LIB_DIR)
2325         AC_SUBST(LIBSSL_INC_FLAGS)
2326         AC_SUBST(LIBSSL_LIB_FLAGS)
2327         ])
2328
2329
2330 dnl kerberos_v4.m4--Kerberos 4 libraries and includes
2331 dnl Derrick Brashear
2332 dnl from KTH krb and Arla
2333 dnl $Id: kerberos_v4.m4,v 1.28 2005/04/26 19:14:08 shadow Exp $
2334
2335 AC_DEFUN([CMU_KRB_SENDAUTH_PROTO], [
2336 AC_MSG_CHECKING(for krb_sendauth prototype)
2337 AC_TRY_COMPILE(
2338 [#include <krb.h>
2339 int krb_sendauth (long options, int fd, KTEXT ktext, char *service,
2340                   char *inst, char *realm, u_long checksum,
2341                   MSG_DAT *msg_data, CREDENTIALS *cred,
2342                   Key_schedule schedule, struct sockaddr_in *laddr,
2343                   struct sockaddr_in *faddr, char *version);],
2344 [int foo = krb_sendauth(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); ],
2345 ac_cv_krb_sendauth_proto=no,
2346 ac_cv_krb_sendauth_proto=yes)
2347 AC_MSG_RESULT($ac_cv_krb_sendauth_proto)
2348 if test "$ac_cv_krb_sendauth_proto" = yes; then
2349         AC_DEFINE(HAVE_KRB_SENDAUTH_PROTO)dnl
2350 fi
2351 AC_MSG_RESULT($ac_cv_krb_sendauth_proto)
2352 ])
2353
2354 AC_DEFUN([CMU_KRB_SET_KEY_PROTO], [
2355 AC_MSG_CHECKING(for krb_set_key prototype)
2356 AC_CACHE_VAL(ac_cv_krb_set_key_proto, [
2357 cmu_save_CPPFLAGS="$CPPFLAGS"
2358 CPPFLAGS="${CPPFLAGS} ${KRB_INC_FLAGS}"
2359 AC_TRY_COMPILE(
2360 [#include <krb.h>
2361 int krb_set_key(char *key, int cvt);],
2362 [int foo = krb_set_key(0, 0);],
2363 ac_cv_krb_set_key_proto=no,
2364 ac_cv_krb_set_key_proto=yes)
2365 ])
2366 CPPFLAGS="${cmu_save_CPPFLAGS}"
2367 if test "$ac_cv_krb_set_key_proto" = yes; then
2368         AC_DEFINE(HAVE_KRB_SET_KEY_PROTO)dnl
2369 fi
2370 AC_MSG_RESULT($ac_cv_krb_set_key_proto)
2371 ])
2372
2373 AC_DEFUN([CMU_KRB4_32_DEFN], [
2374 AC_MSG_CHECKING(for KRB4_32 definition)
2375 AC_CACHE_VAL(ac_cv_krb4_32_defn, [
2376 cmu_save_CPPFLAGS="$CPPFLAGS"
2377 CPPFLAGS="${CPPFLAGS} ${KRB_INC_FLAGS}"
2378 AC_TRY_COMPILE(
2379 [#include <krb.h>
2380 ],
2381 [KRB4_32 foo = 1;],
2382 ac_cv_krb4_32_defn=yes,
2383 ac_cv_krb4_32_defn=no)
2384 ])
2385 CPPFLAGS="${cmu_save_CPPFLAGS}"
2386 if test "$ac_cv_krb4_32_defn" = yes; then
2387         AC_DEFINE(HAVE_KRB4_32_DEFINE)dnl
2388 fi
2389 AC_MSG_RESULT($ac_cv_krb4_32_defn)
2390 ])
2391
2392 AC_DEFUN([CMU_KRB_RD_REQ_PROTO], [
2393 AC_MSG_CHECKING(for krb_rd_req prototype)
2394 AC_CACHE_VAL(ac_cv_krb_rd_req_proto, [
2395 cmu_save_CPPFLAGS="$CPPFLAGS"
2396 CPPFLAGS="${CPPFLAGS} ${KRB_INC_FLAGS}"
2397 AC_TRY_COMPILE(
2398 [#include <krb.h>
2399 int krb_rd_req(KTEXT authent, char *service, char *instance,
2400 unsigned KRB_INT32 from_addr, AUTH_DAT *ad, char *fn);],
2401 [int foo = krb_rd_req(0,0,0,0,0,0);],
2402 ac_cv_krb_rd_req_proto=no,
2403 ac_cv_krb_rd_req_proto=yes)
2404 ])
2405 CPPFLAGS="${cmu_save_CPPFLAGS}"
2406 if test "$ac_cv_krb_rd_req_proto" = yes; then
2407         AC_DEFINE(HAVE_KRB_RD_REQ_PROTO)dnl
2408 fi
2409 AC_MSG_RESULT($ac_cv_krb_rd_req_proto)
2410 ])
2411
2412 AC_DEFUN([CMU_KRB_INC_WHERE1], [
2413 saved_CPPFLAGS=$CPPFLAGS
2414 CPPFLAGS="$saved_CPPFLAGS -I$1"
2415 AC_TRY_COMPILE([#include <krb.h>],
2416 [struct ktext foo;],
2417 ac_cv_found_krb_inc=yes,
2418 ac_cv_found_krb_inc=no)
2419 if test "$ac_cv_found_krb_inc" = "no"; then
2420   CPPFLAGS="$saved_CPPFLAGS -I$1 -I$1/kerberosIV"
2421   AC_TRY_COMPILE([#include <krb.h>],
2422   [struct ktext foo;],
2423   [ac_cv_found_krb_inc=yes],
2424   ac_cv_found_krb_inc=no)
2425 fi
2426 CPPFLAGS=$saved_CPPFLAGS
2427 ])
2428
2429 AC_DEFUN([CMU_KRB_INC_WHERE], [
2430    for i in $1; do
2431       AC_MSG_CHECKING(for kerberos headers in $i)
2432       CMU_KRB_INC_WHERE1($i)
2433       CMU_TEST_INCPATH($i, krb)
2434       if test "$ac_cv_found_krb_inc" = "yes"; then
2435         ac_cv_krb_where_inc=$i
2436         AC_MSG_RESULT(found)
2437         break
2438       else
2439         AC_MSG_RESULT(not found)
2440       fi
2441     done
2442 ])
2443
2444 #
2445 # Test for kerberos lib files
2446 #
2447
2448 AC_DEFUN([CMU_KRB_LIB_WHERE1], [
2449 saved_LIBS=$LIBS
2450 LIBS="$saved_LIBS -L$1 -lkrb ${KRB_LIBDES}"
2451 AC_TRY_LINK(,
2452 [dest_tkt();],
2453 [ac_cv_found_krb_lib=yes],
2454 ac_cv_found_krb_lib=no)
2455 LIBS=$saved_LIBS
2456 ])
2457
2458 AC_DEFUN([CMU_KRB_LIB_WHERE], [
2459    for i in $1; do
2460       AC_MSG_CHECKING(for kerberos libraries in $i)
2461       CMU_KRB_LIB_WHERE1($i)
2462       dnl deal with false positives from implicit link paths
2463       CMU_TEST_LIBPATH($i, krb)
2464       if test "$ac_cv_found_krb_lib" = "yes" ; then
2465         ac_cv_krb_where_lib=$i
2466         AC_MSG_RESULT(found)
2467         break
2468       else
2469         AC_MSG_RESULT(not found)
2470       fi
2471     done
2472 ])
2473
2474 AC_DEFUN([CMU_KRB4], [
2475 AC_REQUIRE([CMU_FIND_LIB_SUBDIR])
2476 AC_REQUIRE([CMU_SOCKETS])
2477 AC_REQUIRE([CMU_LIBSSL])
2478 AC_ARG_WITH(krb4,
2479         [  --with-krb4=PREFIX      Compile with Kerberos 4 support],
2480         [if test "X$with_krb4" = "X"; then
2481                 with_krb4=yes
2482         fi])
2483 AC_ARG_WITH(krb4-lib,
2484         [  --with-krb4-lib=dir     use kerberos 4 libraries in dir],
2485         [if test "$withval" = "yes" -o "$withval" = "no"; then
2486                 AC_MSG_ERROR([No argument for --with-krb4-lib])
2487         fi])
2488 AC_ARG_WITH(krb4-include,
2489         [  --with-krb4-include=dir use kerberos 4 headers in dir],
2490         [if test "$withval" = "yes" -o "$withval" = "no"; then
2491                 AC_MSG_ERROR([No argument for --with-krb4-include])
2492         fi])
2493
2494         if test "X$with_krb4" != "X"; then
2495           if test "$with_krb4" != "yes" -a "$with_krb4" != "no"; then
2496             ac_cv_krb_where_lib=$with_krb4/$CMU_LIB_SUBDIR
2497             ac_cv_krb_where_inc=$with_krb4/include
2498           fi
2499         fi
2500        
2501         if test "$with_krb4" != "no"; then
2502           if test "X$with_krb4_lib" != "X"; then
2503             ac_cv_krb_where_lib=$with_krb4_lib
2504           fi
2505           if test "X$with_krb4_include" != "X"; then
2506             ac_cv_krb_where_inc=$with_krb4_include
2507           fi
2508           if test "X$ac_cv_krb_where_inc" = "X"; then
2509             CMU_KRB_INC_WHERE(/usr/athena/include /usr/include/kerberosIV /usr/local/include /usr/include/kerberos)
2510           fi
2511
2512           AC_MSG_CHECKING([if libdes is needed])
2513           AC_TRY_LINK([],[des_quad_cksum();],KRB_DES_LIB="",KRB_DES_LIB="maybe")
2514           if test "X$KRB_DES_LIB" != "X"; then
2515               LIBS="$cmu_save_LIBS -ldes"
2516               AC_TRY_LINK([], [des_quad_cksum();],KRB_DES_LIB="yes")
2517               if test "X$KRB_DES_LIB" = "Xyes"; then
2518                   AC_MSG_RESULT([yes])
2519                   KRB_LIBDES="-ldes"
2520                   KRB_LIBDESA='$(KRB_LIB_DIR)/libdes.a'
2521               else
2522                   LIBS="$cmu_save_LIBS $LIBSSL_LIB_FLAGS"
2523                   AC_TRY_LINK([],
2524                   [des_quad_cksum();],KRB_DES_LIB="libcrypto")
2525                   if test "X$KRB_DES_LIB" = "Xlibcrypto"; then
2526                       AC_MSG_RESULT([libcrypto])
2527                       KRB_LIBDES="$LIBSSL_LIB_FLAGS"
2528                       KRB_LIBDESA="$LIBSSL_LIB_FLAGS"
2529                   else
2530                       LIBS="$cmu_save_LIBS -L$LIBSSL_LIB_DIR -ldescompat $LIBSSL_LIB_FLAGS"
2531                       AC_TRY_LINK([],
2532                       [des_quad_cksum();],KRB_DES_LIB="libcrypto+descompat")
2533                       if test "X$KRB_DES_LIB" = "Xlibcrypto+descompat"; then
2534                           AC_MSG_RESULT([libcrypto+descompat])
2535                           KRB_LIBDES="-L$LIBSSL_LIB_DIR -ldescompat $LIBSSL_LIB_FLAGS"
2536                           KRB_LIBDESA="-L$LIBSSL_LIB_DIR -ldescompat $LIBSSL_LIB_FLAGS"
2537                       else
2538                           AC_MSG_RESULT([unknown])
2539                           AC_MSG_ERROR([Could not use -ldes])
2540                       fi 
2541                   fi 
2542               fi 
2543           else
2544              AC_MSG_RESULT([no])
2545           fi
2546           if test "X$ac_cv_krb_where_lib" = "X"; then
2547             CMU_KRB_LIB_WHERE(/usr/athena/$CMU_LIB_SUBDIR /usr/local/$CMU_LIB_SUBDIR /usr/$CMU_LIB_SUBDIR)
2548           fi
2549         fi
2550           LIBS="${cmu_save_LIBS}"
2551
2552
2553         AC_MSG_CHECKING([whether to include kerberos 4])
2554         if test "X$ac_cv_krb_where_lib" = "X" -o "X$ac_cv_krb_where_inc" = "X"; then
2555           ac_cv_found_krb=no
2556           AC_MSG_RESULT(no)
2557         else
2558           ac_cv_found_krb=yes
2559           AC_MSG_RESULT(yes)
2560           KRB_INC_DIR=$ac_cv_krb_where_inc
2561           KRB_LIB_DIR=$ac_cv_krb_where_lib
2562           KRB_INC_FLAGS="-I${KRB_INC_DIR}"
2563           KRB_LIB_FLAGS="-L${KRB_LIB_DIR} -lkrb ${KRB_LIBDES}"
2564           LIBS="${cmu_save_LIBS} ${KRB_LIB_FLAGS}"
2565           AC_CHECK_LIB(resolv, dns_lookup, KRB_LIB_FLAGS="${KRB_LIB_FLAGS} -lresolv",,"${KRB_LIB_FLAGS}")
2566           AC_CHECK_LIB(crypt, crypt, KRB_LIB_FLAGS="${KRB_LIB_FLAGS} -lcrypt",,"${KRB_LIB_FLAGS}")
2567           LIBS="${LIBS} ${KRB_LIB_FLAGS}"
2568           AC_CHECK_FUNCS(krb_get_int krb_life_to_time)
2569           AC_SUBST(KRB_INC_FLAGS)
2570           AC_SUBST(KRB_LIB_FLAGS)
2571           LIBS="${cmu_save_LIBS}"
2572           AC_DEFINE(HAVE_KRB4,,[Kerberos V4 is present])dnl zephyr uses this
2573           AC_DEFINE(KERBEROS,,[Use kerberos 4. find out what needs this symbol])
2574           if test "X$RPATH" = "X"; then
2575                 RPATH=""
2576           fi
2577           case "${host}" in
2578             *-*-linux*)
2579               if test "X$RPATH" = "X"; then
2580                 RPATH="-Wl,-rpath,${KRB_LIB_DIR}"
2581               else 
2582                 RPATH="${RPATH}:${KRB_LIB_DIR}"
2583               fi
2584               ;;
2585             *-*-hpux*)
2586               if test "X$RPATH" = "X"; then
2587                 RPATH="-Wl,+b${KRB_LIB_DIR}"
2588               else 
2589                 RPATH="${RPATH}:${KRB_LIB_DIR}"
2590               fi
2591               ;;
2592             *-*-irix*)
2593               if test "X$RPATH" = "X"; then
2594                 RPATH="-Wl,-rpath,${KRB_LIB_DIR}"
2595               else 
2596                 RPATH="${RPATH}:${KRB_LIB_DIR}"
2597               fi
2598               ;;
2599             *-*-solaris2*)
2600               if test "$ac_cv_prog_gcc" = yes; then
2601                 if test "X$RPATH" = "X"; then
2602                   RPATH="-Wl,-R${KRB_LIB_DIR}"
2603                 else 
2604                   RPATH="${RPATH}:${KRB_LIB_DIR}"
2605                 fi
2606               else
2607                 RPATH="${RPATH} -R${KRB_LIB_DIR}"
2608               fi
2609               ;;
2610           esac
2611           AC_SUBST(RPATH)
2612         fi
2613         ])
2614
2615
2616 dnl
2617 dnl macros for configure.in to detect openssl
2618 dnl $Id: openssl.m4,v 1.11 2006/05/17 18:30:19 murch Exp $
2619 dnl
2620
2621 AC_DEFUN([CMU_HAVE_OPENSSL], [
2622 AC_REQUIRE([CMU_FIND_LIB_SUBDIR])
2623 AC_ARG_WITH(openssl,[  --with-openssl=PATH     use OpenSSL from PATH],
2624         with_openssl=$withval, with_openssl="yes")
2625
2626         save_CPPFLAGS=$CPPFLAGS
2627         save_LDFLAGS=$LDFLAGS
2628
2629         if test -d $with_openssl; then
2630           CPPFLAGS="${CPPFLAGS} -I${with_openssl}/include"
2631           CMU_ADD_LIBPATH(${with_openssl}/$CMU_LIB_SUBDIR)
2632         fi
2633
2634 case "$with_openssl" in
2635         no)
2636           with_openssl="no";;
2637         *) 
2638           dnl if openssl has been compiled with the rsaref2 libraries,
2639           dnl we need to include the rsaref libraries in the crypto check
2640                 LIB_RSAREF=""
2641                 AC_CHECK_LIB(rsaref, RSAPublicEncrypt,
2642                         cmu_have_rsaref=yes;
2643                         [AC_CHECK_LIB(RSAglue, RSAPublicEncrypt,
2644                                 LIB_RSAREF="-lRSAglue -lrsaref",
2645                                 LIB_RSAREF="-lrsaref")],
2646                         cmu_have_rsaref=no)
2647
2648                 AC_CHECK_HEADER(openssl/evp.h, [
2649                         AC_CHECK_LIB(crypto, EVP_DigestInit,
2650                                         with_openssl="yes",
2651                                         with_openssl="no", $LIB_RSAREF)],
2652                         with_openssl=no)
2653                 ;;
2654 esac
2655
2656         if test "$with_openssl" != "no"; then
2657                 AC_DEFINE(HAVE_OPENSSL,[],[Do we have OpenSSL?])
2658         else
2659                 CPPFLAGS=$save_CPPFLAGS
2660                 LDFLAGS=$save_LDFLAGS
2661         fi
2662 ])
2663
2664 dnl checking for kerberos 4 libraries (and DES)
2665
2666 AC_DEFUN([SASL_DES_CHK], [
2667 AC_ARG_WITH(des, [  --with-des=DIR          with DES (look in DIR) [yes] ],
2668         with_des=$withval,
2669         with_des=yes)
2670
2671 LIB_DES=""
2672 if test "$with_des" != no; then
2673   if test -d $with_des; then
2674     CPPFLAGS="$CPPFLAGS -I${with_des}/include"
2675     LDFLAGS="$LDFLAGS -L${with_des}/lib"
2676   fi
2677
2678   if test "$with_openssl" != no; then
2679     dnl check for openssl installing -lcrypto, then make vanilla check
2680     AC_CHECK_LIB(crypto, des_cbc_encrypt, [
2681         AC_CHECK_HEADER(openssl/des.h, [AC_DEFINE(WITH_SSL_DES,[],[Use OpenSSL DES Implementation])
2682                                        LIB_DES="-lcrypto";
2683                                        with_des=yes],
2684                        with_des=no)],
2685         with_des=no, $LIB_RSAREF)
2686
2687     dnl same test again, different symbol name
2688     if test "$with_des" = no; then
2689       AC_CHECK_LIB(crypto, DES_cbc_encrypt, [
2690         AC_CHECK_HEADER(openssl/des.h, [AC_DEFINE(WITH_SSL_DES,[],[Use OpenSSL DES Implementation])
2691                                        LIB_DES="-lcrypto";
2692                                        with_des=yes],
2693                        with_des=no)],
2694         with_des=no, $LIB_RSAREF)
2695     fi
2696   fi
2697
2698   if test "$with_des" = no; then
2699     AC_CHECK_LIB(des, des_cbc_encrypt, [LIB_DES="-ldes";
2700                                         with_des=yes], with_des=no)
2701   fi
2702
2703   if test "$with_des" = no; then
2704      AC_CHECK_LIB(des425, des_cbc_encrypt, [LIB_DES="-ldes425";
2705                                        with_des=yes], with_des=no)
2706   fi
2707
2708   if test "$with_des" = no; then
2709      AC_CHECK_LIB(des524, des_cbc_encrypt, [LIB_DES="-ldes524";
2710                                        with_des=yes], with_des=no)
2711   fi
2712
2713   if test "$with_des" = no; then
2714     dnl if openssl is around, we might be able to use that for des
2715
2716     dnl if openssl has been compiled with the rsaref2 libraries,
2717     dnl we need to include the rsaref libraries in the crypto check
2718     LIB_RSAREF=""
2719     AC_CHECK_LIB(rsaref, RSAPublicEncrypt,
2720                  LIB_RSAREF="-lRSAglue -lrsaref"; cmu_have_rsaref=yes,
2721                  cmu_have_rsaref=no)
2722
2723     AC_CHECK_LIB(crypto, des_cbc_encrypt, [
2724         AC_CHECK_HEADER(openssl/des.h, [AC_DEFINE(WITH_SSL_DES,[],[Use OpenSSL DES Implementation])
2725                                         LIB_DES="-lcrypto";
2726                                         with_des=yes],
2727                         with_des=no)], 
2728         with_des=no, $LIB_RSAREF)
2729   fi
2730 fi
2731
2732 if test "$with_des" != no; then
2733   AC_DEFINE(WITH_DES,[],[Use DES])
2734 fi
2735
2736 AC_SUBST(LIB_DES)
2737 ])
2738
2739 AC_DEFUN([SASL_KERBEROS_V4_CHK], [
2740   AC_REQUIRE([SASL_DES_CHK])
2741
2742   AC_ARG_ENABLE(krb4, [  --enable-krb4           enable KERBEROS_V4 authentication [[no]] ],
2743     krb4=$enableval,
2744     krb4=no)
2745
2746   if test "$krb4" != no; then
2747     dnl In order to compile kerberos4, we need libkrb and libdes.
2748     dnl (We've already gotten libdes from SASL_DES_CHK)
2749     dnl we might need -lresolv for kerberos
2750     AC_CHECK_LIB(resolv,res_search)
2751
2752     dnl if we were ambitious, we would look more aggressively for the
2753     dnl krb4 install
2754     if test -d ${krb4}; then
2755        AC_CACHE_CHECK(for Kerberos includes, cyrus_krbinclude, [
2756          for krbhloc in include/kerberosIV include/kerberos include
2757          do
2758            if test -f ${krb4}/${krbhloc}/krb.h ; then
2759              cyrus_krbinclude=${krb4}/${krbhloc}
2760              break
2761            fi
2762          done
2763          ])
2764
2765        if test -n "${cyrus_krbinclude}"; then
2766          CPPFLAGS="$CPPFLAGS -I${cyrus_krbinclude}"
2767        fi
2768        LDFLAGS="$LDFLAGS -L$krb4/lib"
2769     fi
2770
2771     if test "$with_des" != no; then
2772       AC_CHECK_HEADER(krb.h, [
2773         AC_CHECK_LIB(com_err, com_err, [
2774           AC_CHECK_LIB(krb, krb_mk_priv,
2775                      [COM_ERR="-lcom_err"; SASL_KRB_LIB="-lkrb"; krb4lib="yes"],
2776                      krb4lib=no, $LIB_DES -lcom_err)], [
2777           AC_CHECK_LIB(krb, krb_mk_priv,
2778                      [COM_ERR=""; SASL_KRB_LIB="-lkrb"; krb4lib="yes"],
2779                      krb4lib=no, $LIB_DES)])], krb4="no")
2780
2781       if test "$krb4" != "no" -a "$krb4lib" = "no"; then
2782         AC_CHECK_LIB(krb4, krb_mk_priv,
2783                      [COM_ERR=""; SASL_KRB_LIB="-lkrb4"; krb4=yes],
2784                      krb4=no, $LIB_DES)
2785       fi
2786       if test "$krb4" = no; then
2787           AC_WARN(No Kerberos V4 found)
2788       fi
2789     else
2790       AC_WARN(No DES library found for Kerberos V4 support)
2791       krb4=no
2792     fi
2793   fi
2794
2795   if test "$krb4" != no; then
2796     cmu_save_LIBS="$LIBS"
2797     LIBS="$LIBS $SASL_KRB_LIB"
2798     AC_CHECK_FUNCS(krb_get_err_text)
2799     LIBS="$cmu_save_LIBS"
2800   fi
2801
2802   AC_MSG_CHECKING(KERBEROS_V4)
2803   if test "$krb4" != no; then
2804     AC_MSG_RESULT(enabled)
2805     SASL_MECHS="$SASL_MECHS libkerberos4.la"
2806     SASL_STATIC_SRCS="$SASL_STATIC_SRCS ../plugins/kerberos4.c"
2807     SASL_STATIC_OBJS="$SASL_STATIC_OBJS kerberos4.o"
2808     AC_DEFINE(STATIC_KERBEROS4,[],[User KERBEROS_V4 Staticly])
2809     AC_DEFINE(HAVE_KRB,[],[Do we have Kerberos 4 Support?])
2810     SASL_KRB_LIB="$SASL_KRB_LIB $LIB_DES $COM_ERR"
2811   else
2812     AC_MSG_RESULT(disabled)
2813   fi
2814   AC_SUBST(SASL_KRB_LIB)
2815 ])
2816
2817
2818 # sasl2.m4--sasl2 libraries and includes
2819 # Rob Siemborski
2820 # $Id: sasl2.m4,v 1.52 2006/05/18 19:25:00 murch Exp $
2821
2822 # SASL2_CRYPT_CHK
2823 # ---------------
2824 AC_DEFUN([SASL_GSSAPI_CHK],
2825 [AC_REQUIRE([SASL2_CRYPT_CHK])
2826 AC_REQUIRE([CMU_SOCKETS])
2827 AC_ARG_ENABLE([gssapi],
2828               [AC_HELP_STRING([--enable-gssapi=<DIR>],
2829                               [enable GSSAPI authentication [yes]])],
2830               [gssapi=$enableval],
2831               [gssapi=yes])
2832 AC_ARG_WITH([gss_impl],
2833             [AC_HELP_STRING([--with-gss_impl={heimdal|mit|cybersafe|seam|auto}],
2834                             [choose specific GSSAPI implementation [[auto]]])],
2835             [gss_impl=$withval],
2836             [gss_impl=auto])
2837
2838 if test "$gssapi" != no; then
2839   platform=
2840   case "${host}" in
2841     *-*-linux*)
2842       platform=__linux
2843       ;;
2844     *-*-hpux*)
2845       platform=__hpux
2846       ;;
2847     *-*-irix*)
2848       platform=__irix
2849       ;;
2850     *-*-solaris2*)
2851 # When should we use __sunos?
2852       platform=__solaris
2853       ;;
2854     *-*-aix*)
2855       platform=__aix
2856       ;;
2857     *)
2858       AC_WARN([The system type is not recognized. If you believe that CyberSafe GSSAPI works on this platform, please update the configure script])
2859       if test "$gss_impl" = "cybersafe"; then
2860         AC_ERROR([CyberSafe was forced, cannot continue as platform is not supported])
2861       fi
2862       ;;
2863   esac
2864
2865   cmu_saved_CPPFLAGS=$CPPFLAGS
2866
2867   if test -d ${gssapi}; then
2868     CPPFLAGS="$CPPFLAGS -I$gssapi/include"
2869 # We want to keep -I in our CPPFLAGS, but only if we succeed
2870     cmu_saved_CPPFLAGS=$CPPFLAGS
2871     LDFLAGS="$LDFLAGS -L$gssapi/lib"
2872
2873     if test -n "$platform"; then
2874       if test "$gss_impl" = "auto" -o "$gss_impl" = "cybersafe"; then
2875         CPPFLAGS="$CPPFLAGS -D$platform"
2876         if test -d "${gssapi}/appsec-sdk/include"; then
2877           CPPFLAGS="$CPPFLAGS -I${gssapi}/appsec-sdk/include"
2878         fi
2879       fi
2880     fi
2881   fi
2882   AC_CHECK_HEADER([gssapi.h],
2883                   [AC_DEFINE(HAVE_GSSAPI_H,,
2884                              [Define if you have the gssapi.h header file])],
2885                   [AC_CHECK_HEADER([gssapi/gssapi.h],,
2886                                    [AC_WARN([Disabling GSSAPI - no include files found]); gssapi=no])])
2887
2888   CPPFLAGS=$cmu_saved_CPPFLAGS
2889
2890 fi
2891
2892 if test "$gssapi" != no; then
2893   # We need to find out which gssapi implementation we are
2894   # using. Supported alternatives are: MIT Kerberos 5,
2895   # Heimdal Kerberos 5 (http://www.pdc.kth.se/heimdal),
2896   # CyberSafe Kerberos 5 (http://www.cybersafe.com/)
2897   # and Sun SEAM (http://wwws.sun.com/software/security/kerberos/)
2898   #
2899   # The choice is reflected in GSSAPIBASE_LIBS
2900
2901   AC_CHECK_LIB(resolv,res_search)
2902   if test -d ${gssapi}; then
2903      gssapi_dir="${gssapi}/lib"
2904      GSSAPIBASE_LIBS="-L$gssapi_dir"
2905      GSSAPIBASE_STATIC_LIBS="-L$gssapi_dir"
2906   else
2907      # FIXME: This is only used for building cyrus, and then only as
2908      # a real hack.  it needs to be fixed.
2909      gssapi_dir="/usr/local/lib"
2910   fi
2911
2912   # Check a full link against the Heimdal libraries.
2913   # If this fails, check a full link against the MIT libraries.
2914   # If this fails, check a full link against the CyberSafe libraries.
2915   # If this fails, check a full link against the Solaris 8 and up libgss.
2916
2917   if test "$gss_impl" = "auto" -o "$gss_impl" = "heimdal"; then
2918     gss_failed=0
2919     AC_CHECK_LIB(gssapi,gss_unwrap,gss_impl="heimdal",gss_failed=1,
2920                  ${GSSAPIBASE_LIBS} -lgssapi -lkrb5 -lasn1 -lroken ${LIB_CRYPT} ${LIB_DES} -lcom_err ${LIB_SOCKET})
2921     if test "$gss_impl" != "auto" -a "$gss_failed" = "1"; then
2922       gss_impl="failed"
2923     fi
2924   fi
2925
2926   if test "$gss_impl" = "auto" -o "$gss_impl" = "mit"; then
2927     # check for libkrb5support first
2928     AC_CHECK_LIB(krb5support,krb5int_getspecific,K5SUP=-lkrb5support K5SUPSTATIC=$gssapi_dir/libkrb5support.a,,${LIB_SOCKET})
2929
2930     gss_failed=0
2931     AC_CHECK_LIB(gssapi_krb5,gss_unwrap,gss_impl="mit",gss_failed=1,
2932                  ${GSSAPIBASE_LIBS} -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err ${K5SUP} ${LIB_SOCKET})
2933     if test "$gss_impl" != "auto" -a "$gss_failed" = "1"; then
2934       gss_impl="failed"
2935     fi
2936   fi
2937
2938   # For Cybersafe one has to set a platform define in order to make compilation work
2939   if test "$gss_impl" = "auto" -o "$gss_impl" = "cybersafe"; then
2940
2941     cmu_saved_CPPFLAGS=$CPPFLAGS
2942     cmu_saved_GSSAPIBASE_LIBS=$GSSAPIBASE_LIBS
2943 # FIXME - Note that the libraries are in .../lib64 for 64bit kernels
2944     if test -d "${gssapi}/appsec-rt/lib"; then
2945       GSSAPIBASE_LIBS="$GSSAPIBASE_LIBS -L${gssapi}/appsec-rt/lib"
2946     fi
2947     CPPFLAGS="$CPPFLAGS -D$platform"
2948     if test -d "${gssapi}/appsec-sdk/include"; then
2949       CPPFLAGS="$CPPFLAGS -I${gssapi}/appsec-sdk/include"
2950     fi
2951
2952     gss_failed=0
2953
2954 # Check for CyberSafe with two libraries first, than fall back to a single 
2955 # library (older CyberSafe)
2956
2957     unset ac_cv_lib_gss_csf_gss_acq_user
2958     AC_CHECK_LIB(gss,csf_gss_acq_user,gss_impl="cybersafe03",
2959                  [unset ac_cv_lib_gss_csf_gss_acq_user;
2960                   AC_CHECK_LIB(gss,csf_gss_acq_user,gss_impl="cybersafe",
2961                                gss_failed=1,$GSSAPIBASE_LIBS -lgss)],
2962                  [${GSSAPIBASE_LIBS} -lgss -lcstbk5])
2963
2964     if test "$gss_failed" = "1"; then
2965 # Restore variables
2966       GSSAPIBASE_LIBS=$cmu_saved_GSSAPIBASE_LIBS
2967       CPPFLAGS=$cmu_saved_CPPFLAGS
2968
2969       if test "$gss_impl" != "auto"; then
2970         gss_impl="failed"
2971       fi
2972     fi
2973   fi
2974
2975   if test "$gss_impl" = "auto" -o "$gss_impl" = "seam"; then
2976     gss_failed=0
2977     AC_CHECK_LIB(gss,gss_unwrap,gss_impl="seam",gss_failed=1,-lgss)
2978     if test "$gss_impl" != "auto" -a "$gss_failed" = "1"; then
2979       gss_impl="failed"
2980     fi
2981   fi
2982
2983   if test "$gss_impl" = "mit"; then
2984     GSSAPIBASE_LIBS="$GSSAPIBASE_LIBS -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err ${K5SUP}"
2985     GSSAPIBASE_STATIC_LIBS="$GSSAPIBASE_LIBS $gssapi_dir/libgssapi_krb5.a $gssapi_dir/libkrb5.a $gssapi_dir/libk5crypto.a $gssapi_dir/libcom_err.a ${K5SUPSTATIC}"
2986   elif test "$gss_impl" = "heimdal"; then
2987     CPPFLAGS="$CPPFLAGS -DKRB5_HEIMDAL"
2988     GSSAPIBASE_LIBS="$GSSAPIBASE_LIBS -lgssapi -lkrb5 -lasn1 -lroken ${LIB_CRYPT} ${LIB_DES} -lcom_err"
2989     GSSAPIBASE_STATIC_LIBS="$GSSAPIBASE_STATIC_LIBS $gssapi_dir/libgssapi.a $gssapi_dir/libkrb5.a $gssapi_dir/libasn1.a $gssapi_dir/libroken.a $gssapi_dir/libcom_err.a ${LIB_CRYPT}"
2990   elif test "$gss_impl" = "cybersafe03"; then
2991 # Version of CyberSafe with two libraries
2992     CPPFLAGS="$CPPFLAGS -D$platform -I${gssapi}/appsec-sdk/include"
2993     GSSAPIBASE_LIBS="$GSSAPIBASE_LIBS -lgss -lcstbk5"
2994     # there is no static libgss for CyberSafe
2995     GSSAPIBASE_STATIC_LIBS=none
2996   elif test "$gss_impl" = "cybersafe"; then
2997     CPPFLAGS="$CPPFLAGS -D$platform -I${gssapi}/appsec-sdk/include"
2998     GSSAPIBASE_LIBS="$GSSAPIBASE_LIBS -lgss"
2999     # there is no static libgss for CyberSafe
3000     GSSAPIBASE_STATIC_LIBS=none
3001   elif test "$gss_impl" = "seam"; then
3002     GSSAPIBASE_LIBS=-lgss
3003     # there is no static libgss on Solaris 8 and up
3004     GSSAPIBASE_STATIC_LIBS=none
3005   elif test "$gss_impl" = "failed"; then
3006     gssapi="no"
3007     GSSAPIBASE_LIBS=
3008     GSSAPIBASE_STATIC_LIBS=
3009     AC_WARN([Disabling GSSAPI - specified library not found])
3010   else
3011     gssapi="no"
3012     GSSAPIBASE_LIBS=
3013     GSSAPIBASE_STATIC_LIBS=
3014     AC_WARN([Disabling GSSAPI - no library])
3015   fi
3016 fi
3017
3018 #
3019 # Cybersafe defines both GSS_C_NT_HOSTBASED_SERVICE and GSS_C_NT_USER_NAME
3020 # in gssapi\rfckrb5.h
3021 #
3022 if test "$gssapi" != "no"; then
3023   if test "$gss_impl" = "cybersafe" -o "$gss_impl" = "cybersafe03"; then
3024     AC_EGREP_CPP(hostbased_service_gss_nt_yes,
3025                  [#include <gssapi/gssapi.h>
3026                   #ifdef GSS_C_NT_HOSTBASED_SERVICE
3027                     hostbased_service_gss_nt_yes
3028                   #endif],
3029                  [AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE,,
3030                             [Define if your GSSAPI implimentation defines GSS_C_NT_HOSTBASED_SERVICE])],
3031                  [AC_WARN([Cybersafe define not found])])
3032
3033   elif test "$ac_cv_header_gssapi_h" = "yes"; then
3034     AC_EGREP_HEADER(GSS_C_NT_HOSTBASED_SERVICE, gssapi.h,
3035                     [AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE,,
3036                                [Define if your GSSAPI implimentation defines GSS_C_NT_HOSTBASED_SERVICE])])
3037   elif test "$ac_cv_header_gssapi_gssapi_h"; then
3038     AC_EGREP_HEADER(GSS_C_NT_HOSTBASED_SERVICE, gssapi/gssapi.h,
3039                     [AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE,,
3040                                [Define if your GSSAPI implimentation defines GSS_C_NT_HOSTBASED_SERVICE])])
3041   fi
3042
3043   if test "$gss_impl" = "cybersafe" -o "$gss_impl" = "cybersafe03"; then
3044     AC_EGREP_CPP(user_name_yes_gss_nt,
3045                  [#include <gssapi/gssapi.h>
3046                   #ifdef GSS_C_NT_USER_NAME
3047                    user_name_yes_gss_nt
3048                   #endif],
3049                  [AC_DEFINE(HAVE_GSS_C_NT_USER_NAME,,
3050                             [Define if your GSSAPI implimentation defines GSS_C_NT_USER_NAME])],
3051                  [AC_WARN([Cybersafe define not found])])
3052   elif test "$ac_cv_header_gssapi_h" = "yes"; then
3053     AC_EGREP_HEADER(GSS_C_NT_USER_NAME, gssapi.h,
3054                     [AC_DEFINE(HAVE_GSS_C_NT_USER_NAME,,
3055                                [Define if your GSSAPI implimentation defines GSS_C_NT_USER_NAME])])
3056   elif test "$ac_cv_header_gssapi_gssapi_h"; then
3057     AC_EGREP_HEADER(GSS_C_NT_USER_NAME, gssapi/gssapi.h,
3058                     [AC_DEFINE(HAVE_GSS_C_NT_USER_NAME,,
3059                                [Define if your GSSAPI implimentation defines GSS_C_NT_USER_NAME])])
3060   fi
3061 fi
3062
3063 GSSAPI_LIBS=""
3064 AC_MSG_CHECKING([GSSAPI])
3065 if test "$gssapi" != no; then
3066   AC_MSG_RESULT([with implementation ${gss_impl}])
3067   AC_CHECK_LIB(resolv,res_search,GSSAPIBASE_LIBS="$GSSAPIBASE_LIBS -lresolv")
3068   SASL_MECHS="$SASL_MECHS libgssapiv2.la"
3069   SASL_STATIC_OBJS="$SASL_STATIC_OBJS gssapi.o"
3070   SASL_STATIC_SRCS="$SASL_STATIC_SRCS ../plugins/gssapi.c"
3071
3072   cmu_save_LIBS="$LIBS"
3073   LIBS="$LIBS $GSSAPIBASE_LIBS"
3074   AC_CHECK_FUNCS(gsskrb5_register_acceptor_identity)
3075   LIBS="$cmu_save_LIBS"
3076 else
3077   AC_MSG_RESULT([disabled])
3078 fi
3079 AC_SUBST(GSSAPI_LIBS)
3080 AC_SUBST(GSSAPIBASE_LIBS)
3081 ])# SASL_GSSAPI_CHK
3082
3083
3084 # SASL_SET_GSSAPI_LIBS
3085 # --------------------
3086 AC_DEFUN([SASL_SET_GSSAPI_LIBS],
3087 [SASL_GSSAPI_LIBS_SET="yes"
3088 ])
3089
3090
3091 # CMU_SASL2
3092 # ---------
3093 # What we want to do here is setup LIB_SASL with what one would
3094 # generally want to have (e.g. if static is requested, make it that,
3095 # otherwise make it dynamic.
3096 #
3097 # We also want to create LIB_DYN_SASL and DYNSASLFLAGS.
3098 #
3099 # Also sets using_static_sasl to "no" "static" or "staticonly"
3100 #
3101 AC_DEFUN([CMU_SASL2],
3102 [AC_REQUIRE([SASL_GSSAPI_CHK])
3103
3104 AC_ARG_WITH(sasl,
3105             [AC_HELP_STRING([--with-sasl=DIR],[Compile with libsasl2 in <DIR>])],
3106             with_sasl="$withval",
3107             with_sasl="yes")
3108
3109 AC_ARG_WITH(staticsasl,
3110             [AC_HELP_STRING([--with-staticsasl=DIR],
3111                             [Compile with staticly linked libsasl2 in <DIR>])],
3112             [with_staticsasl="$withval";
3113              if test $with_staticsasl != "no"; then
3114                using_static_sasl="static"
3115              fi],
3116             [with_staticsasl="no"; using_static_sasl="no"])
3117
3118 SASLFLAGS=""
3119 LIB_SASL=""
3120
3121 cmu_saved_CPPFLAGS=$CPPFLAGS
3122 cmu_saved_LDFLAGS=$LDFLAGS
3123 cmu_saved_LIBS=$LIBS
3124
3125 if test ${with_staticsasl} != "no"; then
3126   if test -d ${with_staticsasl}; then
3127     if test -d ${with_staticsasl}/lib64 ; then
3128       ac_cv_sasl_where_lib=${with_staticsasl}/lib64
3129     else
3130       ac_cv_sasl_where_lib=${with_staticsasl}/lib
3131     fi
3132     ac_cv_sasl_where_lib=${with_staticsasl}/lib
3133     ac_cv_sasl_where_inc=${with_staticsasl}/include
3134
3135     SASLFLAGS="-I$ac_cv_sasl_where_inc"
3136     LIB_SASL="-L$ac_cv_sasl_where_lib"
3137     CPPFLAGS="${cmu_saved_CPPFLAGS} -I${ac_cv_sasl_where_inc}"
3138     LDFLAGS="${cmu_saved_LDFLAGS} -L${ac_cv_sasl_where_lib}"
3139   else
3140     with_staticsasl="/usr"
3141   fi
3142
3143   AC_CHECK_HEADER(sasl/sasl.h,
3144                   [AC_CHECK_HEADER(sasl/saslutil.h,
3145                                    [for i42 in lib64 lib; do
3146                                       if test -r ${with_staticsasl}/$i42/libsasl2.a; then
3147                                         ac_cv_found_sasl=yes
3148                                         AC_MSG_CHECKING([for static libsasl])
3149                                         LIB_SASL="$LIB_SASL ${with_staticsasl}/$i42/libsasl2.a"
3150                                       fi
3151                                     done
3152                                     if test ! "$ac_cv_found_sasl" = "yes"; then
3153                                       AC_MSG_CHECKING([for static libsasl])
3154                                       AC_ERROR([Could not find ${with_staticsasl}/lib*/libsasl2.a])
3155                                     fi])])
3156
3157   AC_MSG_RESULT([found])
3158
3159   if test "x$SASL_GSSAPI_LIBS_SET" = "x"; then
3160     LIB_SASL="$LIB_SASL $GSSAPIBASE_STATIC_LIBS"
3161   else
3162     SASL_GSSAPI_LIBS_SET=""
3163     cmu_saved_LIBS="$GSSAPIBASE_STATIC_LIBS $cmu_saved_LIBS" 
3164   fi
3165 fi
3166
3167 if test -d ${with_sasl}; then
3168   ac_cv_sasl_where_lib=${with_sasl}/lib
3169   ac_cv_sasl_where_inc=${with_sasl}/include
3170
3171   DYNSASLFLAGS="-I$ac_cv_sasl_where_inc"
3172   if test "$ac_cv_sasl_where_lib" != ""; then
3173     CMU_ADD_LIBPATH_TO($ac_cv_sasl_where_lib, LIB_DYN_SASL)
3174   fi
3175   LIB_DYN_SASL="$LIB_DYN_SASL -lsasl2"
3176   CPPFLAGS="${cmu_saved_CPPFLAGS} -I${ac_cv_sasl_where_inc}"
3177   LDFLAGS="${cmu_saved_LDFLAGS} -L${ac_cv_sasl_where_lib}"
3178 fi
3179
3180 # be sure to check for a SASLv2 specific function
3181 AC_CHECK_HEADER(sasl/sasl.h,
3182                 [AC_CHECK_HEADER(sasl/saslutil.h,
3183                                  [AC_CHECK_LIB(sasl2, prop_get, 
3184                                                ac_cv_found_sasl=yes,
3185                                                ac_cv_found_sasl=no)],
3186                                  ac_cv_found_sasl=no)],
3187                 ac_cv_found_sasl=no)
3188
3189 if test "$ac_cv_found_sasl" = "yes"; then
3190   if test "$ac_cv_sasl_where_lib" != ""; then
3191     CMU_ADD_LIBPATH_TO($ac_cv_sasl_where_lib, DYNLIB_SASL)
3192   fi
3193   DYNLIB_SASL="$DYNLIB_SASL -lsasl2"
3194   if test "$using_static_sasl" != "static"; then
3195     LIB_SASL=$DYNLIB_SASL
3196     SASLFLAGS=$DYNSASLFLAGS
3197   fi
3198 else
3199   DYNLIB_SASL=""
3200   DYNSASLFLAGS=""
3201   using_static_sasl="staticonly"
3202 fi
3203
3204 if test "x$SASL_GSSAPI_LIBS_SET" != "x"; then
3205   SASL_GSSAPI_LIBS_SET=""
3206   cmu_saved_LIBS="$GSSAPIBASE_LIBS $cmu_saved_LIBS" 
3207 fi
3208
3209 LIBS="$cmu_saved_LIBS"
3210 LDFLAGS="$cmu_saved_LDFLAGS"
3211 CPPFLAGS="$cmu_saved_CPPFLAGS"
3212
3213 AC_SUBST(LIB_DYN_SASL)
3214 AC_SUBST(DYNSASLFLAGS)
3215 AC_SUBST(LIB_SASL)
3216 AC_SUBST(SASLFLAGS)
3217 ])# CMU_SASL2
3218
3219
3220 # CMU_SASL2_REQUIRED
3221 # ------------------
3222 AC_DEFUN([CMU_SASL2_REQUIRED],
3223 [AC_REQUIRE([CMU_SASL2])
3224 if test "$ac_cv_found_sasl" != "yes"; then
3225   AC_ERROR([Cannot continue without libsasl2.
3226 Get it from ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/.])
3227 fi])
3228
3229
3230 # CMU_SASL2_REQUIRE_VER
3231 # ---------------------
3232 AC_DEFUN([CMU_SASL2_REQUIRE_VER],
3233 [AC_REQUIRE([CMU_SASL2_REQUIRED])
3234
3235 cmu_saved_CPPFLAGS=$CPPFLAGS
3236 CPPFLAGS="$CPPFLAGS $SASLFLAGS"
3237
3238 AC_TRY_CPP([
3239 #include <sasl/sasl.h>
3240
3241 #ifndef SASL_VERSION_MAJOR
3242 #error SASL_VERSION_MAJOR not defined
3243 #endif
3244 #ifndef SASL_VERSION_MINOR
3245 #error SASL_VERSION_MINOR not defined
3246 #endif
3247 #ifndef SASL_VERSION_STEP
3248 #error SASL_VERSION_STEP not defined
3249 #endif
3250
3251 #if SASL_VERSION_MAJOR < $1 || SASL_VERSION_MINOR < $2 || SASL_VERSION_STEP < $3
3252 #error SASL version is less than $1.$2.$3
3253 #endif
3254 ],,
3255            [AC_ERROR([Incorrect SASL headers found.  This package requires SASL $1.$2.$3 or newer.])])
3256
3257 CPPFLAGS=$cmu_saved_CPPFLAGS
3258 ])# CMU_SASL2_REQUIRE_VER
3259
3260
3261 # CMU_SASL2_CHECKAPOP_REQUIRED
3262 # ----------------------------
3263 AC_DEFUN([CMU_SASL2_CHECKAPOP_REQUIRED],
3264 [AC_REQUIRE([CMU_SASL2_REQUIRED])
3265
3266 cmu_saved_LDFLAGS=$LDFLAGS
3267
3268 LDFLAGS="$LDFLAGS $LIB_SASL"
3269
3270 AC_CHECK_LIB(sasl2, sasl_checkapop,
3271              [AC_DEFINE(HAVE_APOP,[],[Does SASL support APOP?])],
3272              [AC_MSG_ERROR([libsasl2 without working sasl_checkapop.  Cannot continue.])])
3273
3274 LDFLAGS=$cmu_saved_LDFLAGS
3275 ])# CMU_SASL2_CHECKAPOP_REQUIRED
3276
3277
3278 # SASL2_CRYPT_CHK
3279 # ---------------
3280 AC_DEFUN([SASL2_CRYPT_CHK],
3281 [AC_CHECK_FUNC(crypt, cmu_have_crypt=yes,
3282                [AC_CHECK_LIB(crypt, crypt,
3283                              LIB_CRYPT="-lcrypt"; cmu_have_crypt=yes,
3284                              cmu_have_crypt=no)])
3285 AC_SUBST(LIB_CRYPT)
3286 ])# SASL2_CRYPT_CHK
3287
3288 dnl Check for PLAIN (and therefore crypt)
3289
3290 AC_DEFUN([SASL_PLAIN_CHK],[
3291 AC_REQUIRE([SASL2_CRYPT_CHK])
3292
3293 dnl PLAIN
3294  AC_ARG_ENABLE(plain, [  --enable-plain          enable PLAIN authentication [yes] ],
3295   plain=$enableval,
3296   plain=yes)
3297
3298  PLAIN_LIBS=""
3299  if test "$plain" != no; then
3300   dnl In order to compile plain, we need crypt.
3301   if test "$cmu_have_crypt" = yes; then
3302     PLAIN_LIBS=$LIB_CRYPT
3303   fi
3304  fi
3305  AC_SUBST(PLAIN_LIBS)
3306
3307  AC_MSG_CHECKING(PLAIN)
3308  if test "$plain" != no; then
3309   AC_MSG_RESULT(enabled)
3310   SASL_MECHS="$SASL_MECHS libplain.la"
3311   if test "$enable_static" = yes; then
3312     SASL_STATIC_OBJS="$SASL_STATIC_OBJS plain.o"
3313     SASL_STATIC_SRCS="$SASL_STATIC_SRCS ../plugins/plain.c"
3314     AC_DEFINE(STATIC_PLAIN,[],[Link PLAIN Staticly])
3315   fi
3316  else
3317   AC_MSG_RESULT(disabled)
3318  fi
3319 ])
3320
3321 dnl
3322 dnl macros for configure.in to detect openldap
3323 dnl $Id: openldap.m4,v 1.2 2006/03/13 19:16:11 mel Exp $
3324 dnl
3325
3326 dnl
3327 dnl Check for OpenLDAP version compatility
3328 AC_DEFUN([CMU_OPENLDAP_API],
3329 [AC_CACHE_CHECK([OpenLDAP api], [cmu_cv_openldap_api],[
3330     AC_EGREP_CPP(__openldap_api,[
3331 #include <ldap.h>
3332
3333 #ifdef LDAP_API_FEATURE_X_OPENLDAP
3334 char *__openldap_api = LDAP_API_FEATURE_X_OPENLDAP;
3335 #endif
3336 ],      [cmu_cv_openldap_api=yes], [cmu_cv_openldap_api=no])])
3337 ])
3338
3339 dnl
3340 dnl Check for OpenLDAP version compatility
3341 AC_DEFUN([CMU_OPENLDAP_COMPAT],
3342 [AC_CACHE_CHECK([OpenLDAP version], [cmu_cv_openldap_compat],[
3343     AC_EGREP_CPP(__openldap_compat,[
3344 #include <ldap.h>
3345
3346 /* Require 2.1.27+ and 2.2.6+ */
3347 #if LDAP_VENDOR_VERSION_MAJOR == 2  && LDAP_VENDOR_VERSION_MINOR == 1 && LDAP_VENDOR_VERSION_PATCH > 26
3348 char *__openldap_compat = "2.1.27 or better okay";
3349 #elif LDAP_VENDOR_VERSION_MAJOR == 2  && LDAP_VENDOR_VERSION_MINOR == 2 && LDAP_VENDOR_VERSION_PATCH > 5
3350 char *__openldap_compat = "2.2.6 or better okay";
3351 #elif LDAP_VENDOR_VERSION_MAJOR == 2  && LDAP_VENDOR_VERSION_MINOR > 2
3352 char *__openldap_compat = "2.3 or better okay"
3353 #endif
3354 ],      [cmu_cv_openldap_compat=yes], [cmu_cv_openldap_compat=no])])
3355 ])
3356
3357
3358 dnl See whether we can use IPv6 related functions
3359 dnl contributed by Hajimu UMEMOTO
3360
3361 AC_DEFUN([IPv6_CHECK_FUNC], [
3362 AC_CHECK_FUNC($1, [dnl
3363   ac_cv_lib_socket_$1=no
3364   ac_cv_lib_inet6_$1=no
3365 ], [dnl
3366   AC_CHECK_LIB(socket, $1, [dnl
3367     LIBS="$LIBS -lsocket"
3368     ac_cv_lib_inet6_$1=no
3369   ], [dnl
3370     AC_MSG_CHECKING([whether your system has IPv6 directory])
3371     AC_CACHE_VAL(ipv6_cv_dir, [dnl
3372       for ipv6_cv_dir in /usr/local/v6 /usr/inet6 no; do
3373         if test $ipv6_cv_dir = no -o -d $ipv6_cv_dir; then
3374           break
3375         fi
3376       done])dnl
3377     AC_MSG_RESULT($ipv6_cv_dir)
3378     if test $ipv6_cv_dir = no; then
3379       ac_cv_lib_inet6_$1=no
3380     else
3381       if test x$ipv6_libinet6 = x; then
3382         ipv6_libinet6=no
3383         SAVELDFLAGS="$LDFLAGS"
3384         LDFLAGS="$LDFLAGS -L$ipv6_cv_dir/lib"
3385       fi
3386       AC_CHECK_LIB(inet6, $1, [dnl
3387         if test $ipv6_libinet6 = no; then
3388           ipv6_libinet6=yes
3389           LIBS="$LIBS -linet6"
3390         fi],)dnl
3391       if test $ipv6_libinet6 = no; then
3392         LDFLAGS="$SAVELDFLAGS"
3393       fi
3394     fi])dnl
3395 ])dnl
3396 ipv6_cv_$1=no
3397 if test $ac_cv_func_$1 = yes -o $ac_cv_lib_socket_$1 = yes \
3398      -o $ac_cv_lib_inet6_$1 = yes
3399 then
3400   ipv6_cv_$1=yes
3401 fi
3402 if test $ipv6_cv_$1 = no; then
3403   if test $1 = getaddrinfo; then
3404     for ipv6_cv_pfx in o n; do
3405       AC_EGREP_HEADER(${ipv6_cv_pfx}$1, netdb.h,
3406                       [AC_CHECK_FUNC(${ipv6_cv_pfx}$1)])
3407       if eval test X\$ac_cv_func_${ipv6_cv_pfx}$1 = Xyes; then
3408         AC_DEFINE(HAVE_GETADDRINFO,[],[Do we have a getaddrinfo?])
3409         ipv6_cv_$1=yes
3410         break
3411       fi
3412     done
3413   fi
3414 fi
3415 if test $ipv6_cv_$1 = yes; then
3416   ifelse([$2], , :, [$2])
3417 else
3418   ifelse([$3], , :, [$3])
3419 fi])
3420
3421
3422 dnl See whether we have ss_family in sockaddr_storage
3423 AC_DEFUN([IPv6_CHECK_SS_FAMILY], [
3424 AC_MSG_CHECKING([whether you have ss_family in struct sockaddr_storage])
3425 AC_CACHE_VAL(ipv6_cv_ss_family, [dnl
3426 AC_TRY_COMPILE([#include <sys/types.h>
3427 #include <sys/socket.h>],
3428         [struct sockaddr_storage ss; int i = ss.ss_family;],
3429         [ipv6_cv_ss_family=yes], [ipv6_cv_ss_family=no])])dnl
3430 if test $ipv6_cv_ss_family = yes; then
3431   ifelse([$1], , AC_DEFINE(HAVE_SS_FAMILY,[],[Is there an ss_family in sockaddr_storage?]), [$1])
3432 else
3433   ifelse([$2], , :, [$2])
3434 fi
3435 AC_MSG_RESULT($ipv6_cv_ss_family)])
3436
3437
3438 dnl whether you have sa_len in struct sockaddr
3439 AC_DEFUN([IPv6_CHECK_SA_LEN], [
3440 AC_MSG_CHECKING([whether you have sa_len in struct sockaddr])
3441 AC_CACHE_VAL(ipv6_cv_sa_len, [dnl
3442 AC_TRY_COMPILE([#include <sys/types.h>
3443 #include <sys/socket.h>],
3444                [struct sockaddr sa; int i = sa.sa_len;],
3445                [ipv6_cv_sa_len=yes], [ipv6_cv_sa_len=no])])dnl
3446 if test $ipv6_cv_sa_len = yes; then
3447   ifelse([$1], , AC_DEFINE(HAVE_SOCKADDR_SA_LEN,[],[Does sockaddr have an sa_len?]), [$1])
3448 else
3449   ifelse([$2], , :, [$2])
3450 fi
3451 AC_MSG_RESULT($ipv6_cv_sa_len)])
3452
3453
3454 dnl See whether sys/socket.h has socklen_t
3455 AC_DEFUN([IPv6_CHECK_SOCKLEN_T], [
3456 AC_MSG_CHECKING(for socklen_t)
3457 AC_CACHE_VAL(ipv6_cv_socklen_t, [dnl
3458 AC_TRY_LINK([#include <sys/types.h>
3459 #include <sys/socket.h>],
3460             [socklen_t len = 0;],
3461             [ipv6_cv_socklen_t=yes], [ipv6_cv_socklen_t=no])])dnl
3462 if test $ipv6_cv_socklen_t = yes; then
3463   ifelse([$1], , AC_DEFINE(HAVE_SOCKLEN_T,[],[Do we have a socklen_t?]), [$1])
3464 else
3465   ifelse([$2], , :, [$2])
3466 fi
3467 AC_MSG_RESULT($ipv6_cv_socklen_t)])
3468
3469