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