source: trunk/third/cyrus-sasl/aclocal.m4 @ 18842

Revision 18842, 72.9 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18841, which included commits to RCS files with non-trunk default branches.
Line 
1dnl aclocal.m4 generated automatically by aclocal 1.4
2
3dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl This program is distributed in the hope that it will be useful,
9dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11dnl PARTICULAR PURPOSE.
12
13
14# serial 40 AC_PROG_LIBTOOL
15AC_DEFUN(AC_PROG_LIBTOOL,
16[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
17
18# Save cache, so that ltconfig can load it
19AC_CACHE_SAVE
20
21# Actually configure libtool.  ac_aux_dir is where install-sh is found.
22CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
23LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
24LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
25DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
26${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
27$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
28|| AC_MSG_ERROR([libtool configure failed])
29
30# Reload cache, that may have been modified by ltconfig
31AC_CACHE_LOAD
32
33# This can be used to rebuild libtool when needed
34LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
35
36# Always use our own libtool.
37LIBTOOL='$(SHELL) $(top_builddir)/libtool'
38AC_SUBST(LIBTOOL)dnl
39
40# Redirect the config.log output again, so that the ltconfig log is not
41# clobbered by the next message.
42exec 5>>./config.log
43])
44
45AC_DEFUN(AC_LIBTOOL_SETUP,
46[AC_PREREQ(2.13)dnl
47AC_REQUIRE([AC_ENABLE_SHARED])dnl
48AC_REQUIRE([AC_ENABLE_STATIC])dnl
49AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
50AC_REQUIRE([AC_CANONICAL_HOST])dnl
51AC_REQUIRE([AC_CANONICAL_BUILD])dnl
52AC_REQUIRE([AC_PROG_RANLIB])dnl
53AC_REQUIRE([AC_PROG_CC])dnl
54AC_REQUIRE([AC_PROG_LD])dnl
55AC_REQUIRE([AC_PROG_NM])dnl
56AC_REQUIRE([AC_PROG_LN_S])dnl
57dnl
58
59case "$target" in
60NONE) lt_target="$host" ;;
61*) lt_target="$target" ;;
62esac
63
64# Check for any special flags to pass to ltconfig.
65libtool_flags="--cache-file=$cache_file"
66test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
67test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
68test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
69test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
70test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
71ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
72[libtool_flags="$libtool_flags --enable-dlopen"])
73ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
74[libtool_flags="$libtool_flags --enable-win32-dll"])
75AC_ARG_ENABLE(libtool-lock,
76  [  --disable-libtool-lock  avoid locking (might break parallel builds)])
77test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
78test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
79
80# Some flags need to be propagated to the compiler or linker for good
81# libtool support.
82case "$lt_target" in
83*-*-irix6*)
84  # Find out which ABI we are using.
85  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
86  if AC_TRY_EVAL(ac_compile); then
87    case "`/usr/bin/file conftest.o`" in
88    *32-bit*)
89      LD="${LD-ld} -32"
90      ;;
91    *N32*)
92      LD="${LD-ld} -n32"
93      ;;
94    *64-bit*)
95      LD="${LD-ld} -64"
96      ;;
97    esac
98  fi
99  rm -rf conftest*
100  ;;
101
102*-*-sco3.2v5*)
103  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
104  SAVE_CFLAGS="$CFLAGS"
105  CFLAGS="$CFLAGS -belf"
106  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
107    [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
108  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
109    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
110    CFLAGS="$SAVE_CFLAGS"
111  fi
112  ;;
113
114ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
115[*-*-cygwin* | *-*-mingw*)
116  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
117  AC_CHECK_TOOL(AS, as, false)
118  AC_CHECK_TOOL(OBJDUMP, objdump, false)
119  ;;
120])
121esac
122])
123
124# AC_LIBTOOL_DLOPEN - enable checks for dlopen support
125AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
126
127# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
128AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
129
130# AC_ENABLE_SHARED - implement the --enable-shared flag
131# Usage: AC_ENABLE_SHARED[(DEFAULT)]
132#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
133#   `yes'.
134AC_DEFUN(AC_ENABLE_SHARED, [dnl
135define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
136AC_ARG_ENABLE(shared,
137changequote(<<, >>)dnl
138<<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
139changequote([, ])dnl
140[p=${PACKAGE-default}
141case "$enableval" in
142yes) enable_shared=yes ;;
143no) enable_shared=no ;;
144*)
145  enable_shared=no
146  # Look at the argument we got.  We use all the common list separators.
147  IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
148  for pkg in $enableval; do
149    if test "X$pkg" = "X$p"; then
150      enable_shared=yes
151    fi
152  done
153  IFS="$ac_save_ifs"
154  ;;
155esac],
156enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
157])
158
159# AC_DISABLE_SHARED - set the default shared flag to --disable-shared
160AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
161AC_ENABLE_SHARED(no)])
162
163# AC_ENABLE_STATIC - implement the --enable-static flag
164# Usage: AC_ENABLE_STATIC[(DEFAULT)]
165#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
166#   `yes'.
167AC_DEFUN(AC_ENABLE_STATIC, [dnl
168define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
169AC_ARG_ENABLE(static,
170changequote(<<, >>)dnl
171<<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
172changequote([, ])dnl
173[p=${PACKAGE-default}
174case "$enableval" in
175yes) enable_static=yes ;;
176no) enable_static=no ;;
177*)
178  enable_static=no
179  # Look at the argument we got.  We use all the common list separators.
180  IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
181  for pkg in $enableval; do
182    if test "X$pkg" = "X$p"; then
183      enable_static=yes
184    fi
185  done
186  IFS="$ac_save_ifs"
187  ;;
188esac],
189enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
190])
191
192# AC_DISABLE_STATIC - set the default static flag to --disable-static
193AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
194AC_ENABLE_STATIC(no)])
195
196
197# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
198# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
199#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
200#   `yes'.
201AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
202define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
203AC_ARG_ENABLE(fast-install,
204changequote(<<, >>)dnl
205<<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
206changequote([, ])dnl
207[p=${PACKAGE-default}
208case "$enableval" in
209yes) enable_fast_install=yes ;;
210no) enable_fast_install=no ;;
211*)
212  enable_fast_install=no
213  # Look at the argument we got.  We use all the common list separators.
214  IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
215  for pkg in $enableval; do
216    if test "X$pkg" = "X$p"; then
217      enable_fast_install=yes
218    fi
219  done
220  IFS="$ac_save_ifs"
221  ;;
222esac],
223enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
224])
225
226# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
227AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
228AC_ENABLE_FAST_INSTALL(no)])
229
230# AC_PROG_LD - find the path to the GNU or non-GNU linker
231AC_DEFUN(AC_PROG_LD,
232[AC_ARG_WITH(gnu-ld,
233[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
234test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
235AC_REQUIRE([AC_PROG_CC])dnl
236AC_REQUIRE([AC_CANONICAL_HOST])dnl
237AC_REQUIRE([AC_CANONICAL_BUILD])dnl
238ac_prog=ld
239if test "$ac_cv_prog_gcc" = yes; then
240  # Check if gcc -print-prog-name=ld gives a path.
241  AC_MSG_CHECKING([for ld used by GCC])
242  ac_prog=`($CC -print-prog-name=ld) 2>&5`
243  case "$ac_prog" in
244    # Accept absolute paths.
245changequote(,)dnl
246    [\\/]* | [A-Za-z]:[\\/]*)
247      re_direlt='/[^/][^/]*/\.\./'
248changequote([,])dnl
249      # Canonicalize the path of ld
250      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
251      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
252        ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
253      done
254      test -z "$LD" && LD="$ac_prog"
255      ;;
256  "")
257    # If it fails, then pretend we aren't using GCC.
258    ac_prog=ld
259    ;;
260  *)
261    # If it is relative, then search for the first ld in PATH.
262    with_gnu_ld=unknown
263    ;;
264  esac
265elif test "$with_gnu_ld" = yes; then
266  AC_MSG_CHECKING([for GNU ld])
267else
268  AC_MSG_CHECKING([for non-GNU ld])
269fi
270AC_CACHE_VAL(ac_cv_path_LD,
271[if test -z "$LD"; then
272  IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
273  for ac_dir in $PATH; do
274    test -z "$ac_dir" && ac_dir=.
275    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
276      ac_cv_path_LD="$ac_dir/$ac_prog"
277      # Check to see if the program is GNU ld.  I'd rather use --version,
278      # but apparently some GNU ld's only accept -v.
279      # Break only if it was the GNU/non-GNU ld that we prefer.
280      if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
281        test "$with_gnu_ld" != no && break
282      else
283        test "$with_gnu_ld" != yes && break
284      fi
285    fi
286  done
287  IFS="$ac_save_ifs"
288else
289  ac_cv_path_LD="$LD" # Let the user override the test with a path.
290fi])
291LD="$ac_cv_path_LD"
292if test -n "$LD"; then
293  AC_MSG_RESULT($LD)
294else
295  AC_MSG_RESULT(no)
296fi
297test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
298AC_PROG_LD_GNU
299])
300
301AC_DEFUN(AC_PROG_LD_GNU,
302[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
303[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
304if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
305  ac_cv_prog_gnu_ld=yes
306else
307  ac_cv_prog_gnu_ld=no
308fi])
309])
310
311# AC_PROG_NM - find the path to a BSD-compatible name lister
312AC_DEFUN(AC_PROG_NM,
313[AC_MSG_CHECKING([for BSD-compatible nm])
314AC_CACHE_VAL(ac_cv_path_NM,
315[if test -n "$NM"; then
316  # Let the user override the test.
317  ac_cv_path_NM="$NM"
318else
319  IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
320  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
321    test -z "$ac_dir" && ac_dir=.
322    if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
323      # Check to see if the nm accepts a BSD-compat flag.
324      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
325      #   nm: unknown option "B" ignored
326      if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
327        ac_cv_path_NM="$ac_dir/nm -B"
328        break
329      elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
330        ac_cv_path_NM="$ac_dir/nm -p"
331        break
332      else
333        ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
334        continue # so that we can try to find one that supports BSD flags
335      fi
336    fi
337  done
338  IFS="$ac_save_ifs"
339  test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
340fi])
341NM="$ac_cv_path_NM"
342AC_MSG_RESULT([$NM])
343])
344
345# AC_CHECK_LIBM - check for math library
346AC_DEFUN(AC_CHECK_LIBM,
347[AC_REQUIRE([AC_CANONICAL_HOST])dnl
348LIBM=
349case "$lt_target" in
350*-*-beos* | *-*-cygwin*)
351  # These system don't have libm
352  ;;
353*-ncr-sysv4.3*)
354  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
355  AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
356  ;;
357*)
358  AC_CHECK_LIB(m, main, LIBM="-lm")
359  ;;
360esac
361])
362
363# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
364# the libltdl convenience library, adds --enable-ltdl-convenience to
365# the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
366# is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
367# to be `${top_builddir}/libltdl'.  Make sure you start DIR with
368# '${top_builddir}/' (note the single quotes!) if your package is not
369# flat, and, if you're not using automake, define top_builddir as
370# appropriate in the Makefiles.
371AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
372  case "$enable_ltdl_convenience" in
373  no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
374  "") enable_ltdl_convenience=yes
375      ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
376  esac
377  LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
378  INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
379])
380
381# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
382# the libltdl installable library, and adds --enable-ltdl-install to
383# the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
384# is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
385# to be `${top_builddir}/libltdl'.  Make sure you start DIR with
386# '${top_builddir}/' (note the single quotes!) if your package is not
387# flat, and, if you're not using automake, define top_builddir as
388# appropriate in the Makefiles.
389# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
390AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
391  AC_CHECK_LIB(ltdl, main,
392  [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
393  [if test x"$enable_ltdl_install" = xno; then
394     AC_MSG_WARN([libltdl not installed, but installation disabled])
395   else
396     enable_ltdl_install=yes
397   fi
398  ])
399  if test x"$enable_ltdl_install" = x"yes"; then
400    ac_configure_args="$ac_configure_args --enable-ltdl-install"
401    LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
402    INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
403  else
404    ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
405    LIBLTDL="-lltdl"
406    INCLTDL=
407  fi
408])
409
410dnl old names
411AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
412AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
413AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
414AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
415AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
416AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
417AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
418
419dnl This is just to silence aclocal about the macro not being used
420ifelse([AC_DISABLE_FAST_INSTALL])dnl
421
422# Like AC_CONFIG_HEADER, but automatically create stamp file.
423
424AC_DEFUN(AM_CONFIG_HEADER,
425[AC_PREREQ([2.12])
426AC_CONFIG_HEADER([$1])
427dnl When config.status generates a header, we must update the stamp-h file.
428dnl This file resides in the same directory as the config header
429dnl that is generated.  We must strip everything past the first ":",
430dnl and everything past the last "/".
431AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
432ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
433<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
434<<am_indx=1
435for am_file in <<$1>>; do
436  case " <<$>>CONFIG_HEADERS " in
437  *" <<$>>am_file "*<<)>>
438    echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
439    ;;
440  esac
441  am_indx=`expr "<<$>>am_indx" + 1`
442done<<>>dnl>>)
443changequote([,]))])
444
445# Do all the work for Automake.  This macro actually does too much --
446# some checks are only needed if your package does certain things.
447# But this isn't really a big deal.
448
449# serial 1
450
451dnl Usage:
452dnl AM_INIT_AUTOMAKE(package,version, [no-define])
453
454AC_DEFUN(AM_INIT_AUTOMAKE,
455[AC_REQUIRE([AC_PROG_INSTALL])
456PACKAGE=[$1]
457AC_SUBST(PACKAGE)
458VERSION=[$2]
459AC_SUBST(VERSION)
460dnl test to see if srcdir already configured
461if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
462  AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
463fi
464ifelse([$3],,
465AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
466AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
467AC_REQUIRE([AM_SANITY_CHECK])
468AC_REQUIRE([AC_ARG_PROGRAM])
469dnl FIXME This is truly gross.
470missing_dir=`cd $ac_aux_dir && pwd`
471AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
472AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
473AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
474AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
475AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
476AC_REQUIRE([AC_PROG_MAKE_SET])])
477
478#
479# Check to make sure that the build environment is sane.
480#
481
482AC_DEFUN(AM_SANITY_CHECK,
483[AC_MSG_CHECKING([whether build environment is sane])
484# Just in case
485sleep 1
486echo timestamp > conftestfile
487# Do `set' in a subshell so we don't clobber the current shell's
488# arguments.  Must try -L first in case configure is actually a
489# symlink; some systems play weird games with the mod time of symlinks
490# (eg FreeBSD returns the mod time of the symlink's containing
491# directory).
492if (
493   set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
494   if test "[$]*" = "X"; then
495      # -L didn't work.
496      set X `ls -t $srcdir/configure conftestfile`
497   fi
498   if test "[$]*" != "X $srcdir/configure conftestfile" \
499      && test "[$]*" != "X conftestfile $srcdir/configure"; then
500
501      # If neither matched, then we have a broken ls.  This can happen
502      # if, for instance, CONFIG_SHELL is bash and it inherits a
503      # broken ls alias from the environment.  This has actually
504      # happened.  Such a system could not be considered "sane".
505      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
506alias in your environment])
507   fi
508
509   test "[$]2" = conftestfile
510   )
511then
512   # Ok.
513   :
514else
515   AC_MSG_ERROR([newly created file is older than distributed files!
516Check your system clock])
517fi
518rm -f conftest*
519AC_MSG_RESULT(yes)])
520
521dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
522dnl The program must properly implement --version.
523AC_DEFUN(AM_MISSING_PROG,
524[AC_MSG_CHECKING(for working $2)
525# Run test in a subshell; some versions of sh will print an error if
526# an executable is not found, even if stderr is redirected.
527# Redirect stdin to placate older versions of autoconf.  Sigh.
528if ($2 --version) < /dev/null > /dev/null 2>&1; then
529   $1=$2
530   AC_MSG_RESULT(found)
531else
532   $1="$3/missing $2"
533   AC_MSG_RESULT(missing)
534fi
535AC_SUBST($1)])
536
537dnl init_automake.m4--cmulocal automake setup macro
538dnl Rob Earhart
539dnl $Id: aclocal.m4,v 1.1.1.2 2003-02-12 22:34:28 ghudson Exp $
540
541AC_DEFUN(CMU_INIT_AUTOMAKE, [
542        AC_REQUIRE([AM_INIT_AUTOMAKE])
543        ACLOCAL="$ACLOCAL -I \$(top_srcdir)/cmulocal"
544        ])
545
546dnl
547dnl $Id: aclocal.m4,v 1.1.1.2 2003-02-12 22:34:28 ghudson Exp $
548dnl
549
550dnl
551dnl Test for __attribute__
552dnl
553
554AC_DEFUN(CMU_C___ATTRIBUTE__, [
555AC_MSG_CHECKING(for __attribute__)
556AC_CACHE_VAL(ac_cv___attribute__, [
557AC_TRY_COMPILE([
558#include <stdlib.h>
559],
560[
561static void foo(void) __attribute__ ((noreturn));
562
563static void
564foo(void)
565{
566  exit(1);
567}
568],
569ac_cv___attribute__=yes,
570ac_cv___attribute__=no)])
571if test "$ac_cv___attribute__" = "yes"; then
572  AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
573fi
574AC_MSG_RESULT($ac_cv___attribute__)
575])
576
577
578dnl
579dnl Additional macros for configure.in packaged up for easier theft.
580dnl $Id: aclocal.m4,v 1.1.1.2 2003-02-12 22:34:28 ghudson Exp $
581dnl tjs@andrew.cmu.edu 6-may-1998
582dnl
583
584dnl It would be good if ANDREW_ADD_LIBPATH could detect if something was
585dnl already there and not redundantly add it if it is.
586
587dnl add -L(arg), and possibly (runpath switch)(arg), to LDFLAGS
588dnl (so the runpath for shared libraries is set).
589AC_DEFUN(CMU_ADD_LIBPATH, [
590  # this is CMU ADD LIBPATH
591  if test "$andrew_runpath_switch" = "none" ; then
592        LDFLAGS="-L$1 ${LDFLAGS}"
593  else
594        LDFLAGS="-L$1 $andrew_runpath_switch$1 ${LDFLAGS}"
595  fi
596])
597
598dnl add -L(1st arg), and possibly (runpath switch)(1st arg), to (2nd arg)
599dnl (so the runpath for shared libraries is set).
600AC_DEFUN(CMU_ADD_LIBPATH_TO, [
601  # this is CMU ADD LIBPATH TO
602  if test "$andrew_runpath_switch" = "none" ; then
603        $2="-L$1 ${$2}"
604  else
605        $2="-L$1 ${$2} $andrew_runpath_switch$1"
606  fi
607])
608
609dnl runpath initialization
610AC_DEFUN(CMU_GUESS_RUNPATH_SWITCH, [
611   # CMU GUESS RUNPATH SWITCH
612  AC_CACHE_CHECK(for runpath switch, andrew_runpath_switch, [
613    # first, try -R
614    SAVE_LDFLAGS="${LDFLAGS}"
615    LDFLAGS="-R /usr/lib"
616    AC_TRY_LINK([],[],[andrew_runpath_switch="-R"], [
617        LDFLAGS="-Wl,-rpath,/usr/lib"
618    AC_TRY_LINK([],[],[andrew_runpath_switch="-Wl,-rpath,"],
619    [andrew_runpath_switch="none"])
620    ])
621  LDFLAGS="${SAVE_LDFLAGS}"
622  ])])
623
624dnl libtoolhack.m4--hack to make libtool behave better
625dnl Rob Earhart
626dnl $Id: aclocal.m4,v 1.1.1.2 2003-02-12 22:34:28 ghudson Exp $
627
628dnl Libtool tries to compile an empty file to see whether it can build
629dnl shared libraries, and treats *any* warning as a problem.
630dnl Solaris's and HP's cc complains about the empty file.  So we hack
631dnl the CFLAGS to make cc not complain.
632
633AC_DEFUN(CMU_PROG_LIBTOOL, [
634AC_REQUIRE([AC_PROG_CC])
635if test "$ac_cv_prog_gcc" = no; then
636  case "$host_os" in
637    solaris2*)
638      save_cflags="${CFLAGS}"
639      CFLAGS="-erroff=E_EMPTY_TRANSLATION_UNIT ${CFLAGS}"
640      ;;
641    hpux*)
642      save_cflags="${CFLAGS}"
643      CFLAGS="-w"
644      ;;
645  esac
646fi
647
648AM_PROG_LIBTOOL
649
650if test "$ac_cv_prog_gcc" = no; then
651  case "$host_os" in
652    solaris2*|hpux*)
653      CFLAGS="${save_cflags}"
654  esac
655fi
656])
657
658# Define a conditional.
659
660AC_DEFUN(AM_CONDITIONAL,
661[AC_SUBST($1_TRUE)
662AC_SUBST($1_FALSE)
663if $2; then
664  $1_TRUE=
665  $1_FALSE='#'
666else
667  $1_TRUE='#'
668  $1_FALSE=
669fi])
670
671dnl bsd_sockets.m4--which socket libraries do we need?
672dnl Derrick Brashear
673dnl from Zephyr
674dnl $Id: aclocal.m4,v 1.1.1.2 2003-02-12 22:34:28 ghudson Exp $
675
676dnl Hacked on by Rob Earhart to not just toss stuff in LIBS
677dnl It now puts everything required for sockets into LIB_SOCKET
678
679AC_DEFUN(CMU_SOCKETS, [
680        save_LIBS="$LIBS"
681        LIB_SOCKET=""
682        AC_CHECK_FUNC(connect, :,
683                AC_CHECK_LIB(nsl, gethostbyname,
684                             LIB_SOCKET="-lnsl $LIB_SOCKET")
685                AC_CHECK_LIB(socket, connect,
686                             LIB_SOCKET="-lsocket $LIB_SOCKET")
687        )
688        LIBS="$LIB_SOCKET $save_LIBS"
689        AC_CHECK_FUNC(res_search, :,
690                AC_CHECK_LIB(resolv, res_search,
691                              LIB_SOCKET="-lresolv $LIB_SOCKET")
692        )
693        LIBS="$LIB_SOCKET $save_LIBS"
694        AC_CHECK_FUNCS(dn_expand dns_lookup)
695        LIBS="$save_LIBS"
696        AC_SUBST(LIB_SOCKET)
697        ])
698
699dnl Functions to check what database to use for libsasldb
700
701dnl Berkeley DB specific checks first..
702
703dnl Figure out what database type we're using
704AC_DEFUN(SASL_DB_CHECK, [
705cmu_save_LIBS="$LIBS"
706AC_ARG_WITH(dblib, [  --with-dblib=DBLIB      set the DB library to use [berkeley] ],
707  dblib=$withval,
708  dblib=auto_detect)
709
710CYRUS_BERKELEY_DB_OPTS()
711
712SASL_DB_LIB=""
713
714case "$dblib" in
715dnl this is unbelievably painful due to confusion over what db-3 should be
716dnl named.  arg.
717  berkeley)
718        CYRUS_BERKELEY_DB_CHK()
719        CPPFLAGS="${CPPFLAGS} ${BDB_INCADD}"
720        SASL_DB_INC=$BDB_INCADD
721        SASL_DB_LIB="${BDB_LIBADD}"
722        ;;
723  gdbm)
724        AC_ARG_WITH(with-gdbm,[  --with-gdbm=PATH        use gdbm from PATH],
725                    with_gdbm="${withval}")
726
727        case "$with_gdbm" in
728           ""|yes)
729               AC_CHECK_HEADER(gdbm.h, [
730                        AC_CHECK_LIB(gdbm, gdbm_open, SASL_DB_LIB="-lgdbm",
731                                           dblib="no")],
732                        dblib="no")
733               ;;
734           *)
735               if test -d $with_gdbm; then
736                 CPPFLAGS="${CPPFLAGS} -I${with_gdbm}/include"
737                 LDFLAGS="${LDFLAGS} -L${with_gdbm}/lib"
738                 SASL_DB_LIB="-lgdbm"
739               else
740                 with_gdbm="no"
741               fi
742       esac
743        ;;
744  ndbm)
745        dnl We want to attempt to use -lndbm if we can, just in case
746        dnl there's some version of it installed and overriding libc
747        AC_CHECK_HEADER(ndbm.h, [
748                        AC_CHECK_LIB(ndbm, dbm_open, SASL_DB_LIB="-lndbm", [
749                                AC_CHECK_FUNC(dbm_open,,dblib="no")])],
750                                dblib="no")
751        ;;
752  auto_detect)
753        dnl How about berkeley db?
754        CYRUS_BERKELEY_DB_CHK()
755        if test "$dblib" = no; then
756          dnl How about ndbm?
757          AC_CHECK_HEADER(ndbm.h, [
758                AC_CHECK_LIB(ndbm, dbm_open,
759                             dblib="ndbm"; SASL_DB_LIB="-lndbm",
760                             dblib="weird")],
761                   dblib="no")
762          if test "$dblib" = "weird"; then
763            dnl Is ndbm in the standard library?
764            AC_CHECK_FUNC(dbm_open, dblib="ndbm", dblib="no")
765          fi
766
767          if test "$dblib" = no; then
768            dnl Can we use gdbm?
769            AC_CHECK_HEADER(gdbm.h, [
770                AC_CHECK_LIB(gdbm, gdbm_open, dblib="gdbm";
771                                             SASL_DB_LIB="-lgdbm", dblib="no")],
772                             dblib="no")
773          fi
774        else
775          dnl we took Berkeley
776          CPPFLAGS="${CPPFLAGS} ${BDB_INCADD}"
777          SASL_DB_INC=$BDB_INCADD
778          SASL_DB_LIB="${BDB_LIBADD}"
779        fi
780        ;;
781  none)
782        ;;
783  no)
784        ;;
785  *)
786        AC_MSG_WARN([Bad DB library implementation specified;])
787        AC_ERROR([Use either \"berkeley\", \"gdbm\", \"ndbm\" or \"none\"])
788        dblib=no
789        ;;
790esac
791LIBS="$cmu_save_LIBS"
792
793AC_MSG_CHECKING(DB library to use)
794AC_MSG_RESULT($dblib)
795
796SASL_DB_BACKEND="db_${dblib}.lo"
797SASL_DB_BACKEND_STATIC="../sasldb/db_${dblib}.o ../sasldb/allockey.o"
798SASL_DB_UTILS="saslpasswd2 sasldblistusers2"
799SASL_DB_MANS="saslpasswd2.8 sasldblistusers2.8"
800
801case "$dblib" in
802  gdbm)
803    SASL_MECHS="$SASL_MECHS libsasldb.la"
804    AC_DEFINE(SASL_GDBM)
805    ;;
806  ndbm)
807    SASL_MECHS="$SASL_MECHS libsasldb.la"
808    AC_DEFINE(SASL_NDBM)
809    ;;
810  berkeley)
811    SASL_MECHS="$SASL_MECHS libsasldb.la"
812    AC_DEFINE(SASL_BERKELEYDB)
813    ;;
814  *)
815    AC_MSG_WARN([Disabling SASL authentication database support])
816    dnl note that we do not add libsasldb.la to SASL_MECHS, since it
817    dnl will just fail to load anyway.
818    SASL_DB_BACKEND="db_none.lo"
819    SASL_DB_BACKEND_STATIC="../sasldb/db_none.o"
820    SASL_DB_UTILS=""
821    SASL_DB_MANS=""
822    SASL_DB_LIB=""
823    ;;
824esac
825
826if test "$enable_static" = yes; then
827    if test "$dblib" != "none"; then
828      SASL_STATIC_OBJS="$SASL_STATIC_OBJS ../plugins/sasldb.o $SASL_DB_BACKEND_STATIC"
829      AC_DEFINE(STATIC_SASLDB)
830    else
831      SASL_STATIC_OBJS="$SASL_STATIC_OBJS $SASL_DB_BACKEND_STATIC"
832    fi
833fi
834AC_SUBST(SASL_DB_UTILS)
835AC_SUBST(SASL_DB_MANS)
836AC_SUBST(SASL_DB_BACKEND)
837AC_SUBST(SASL_DB_BACKEND_STATIC)
838AC_SUBST(SASL_DB_INC)
839AC_SUBST(SASL_DB_LIB)
840])
841
842dnl Figure out what database path we're using
843AC_DEFUN(SASL_DB_PATH_CHECK, [
844AC_ARG_WITH(dbpath, [  --with-dbpath=PATH      set the DB path to use [/etc/sasldb2] ],
845  dbpath=$withval,
846  dbpath=/etc/sasldb2)
847AC_MSG_CHECKING(DB path to use)
848AC_MSG_RESULT($dbpath)
849AC_DEFINE_UNQUOTED(SASL_DB_PATH, "$dbpath")])
850
851dnl $Id: aclocal.m4,v 1.1.1.2 2003-02-12 22:34:28 ghudson Exp $
852
853AC_DEFUN(CMU_DB_INC_WHERE1, [
854saved_CPPFLAGS=$CPPFLAGS
855CPPFLAGS="$saved_CPPFLAGS -I$1"
856AC_TRY_COMPILE([#include <db.h>],
857[DB *db;
858db_create(&db, NULL, 0);
859db->open(db, "foo.db", NULL, DB_UNKNOWN, DB_RDONLY, 0644);],
860ac_cv_found_db_inc=yes,
861ac_cv_found_db_inc=no)
862CPPFLAGS=$saved_CPPFLAGS
863])
864
865AC_DEFUN(CMU_DB_INC_WHERE, [
866   for i in $1; do
867      AC_MSG_CHECKING(for db headers in $i)
868      CMU_DB_INC_WHERE1($i)
869      CMU_TEST_INCPATH($i, db)
870      if test "$ac_cv_found_db_inc" = "yes"; then
871        ac_cv_db_where_inc=$i
872        AC_MSG_RESULT(found)
873        break
874      else
875        AC_MSG_RESULT(not found)
876      fi
877    done
878])
879
880#
881# Test for lib files
882#
883
884AC_DEFUN(CMU_DB3_LIB_WHERE1, [
885AC_REQUIRE([CMU_AFS])
886AC_REQUIRE([CMU_KRB4])
887saved_LIBS=$LIBS
888  LIBS="$saved_LIBS -L$1 -ldb-3"
889AC_TRY_LINK(,
890[db_env_create();],
891[ac_cv_found_db_3_lib=yes],
892ac_cv_found_db_3_lib=no)
893LIBS=$saved_LIBS
894])
895AC_DEFUN(CMU_DB4_LIB_WHERE1, [
896AC_REQUIRE([CMU_AFS])
897AC_REQUIRE([CMU_KRB4])
898saved_LIBS=$LIBS
899LIBS="$saved_LIBS -L$1 -ldb-4"
900AC_TRY_LINK(,
901[db_env_create();],
902[ac_cv_found_db_4_lib=yes],
903ac_cv_found_db_4_lib=no)
904LIBS=$saved_LIBS
905])
906
907AC_DEFUN(CMU_DB_LIB_WHERE, [
908   for i in $1; do
909      AC_MSG_CHECKING(for db libraries in $i)
910if test "$enable_db4" = "yes"; then
911      CMU_DB4_LIB_WHERE1($i)
912      CMU_TEST_LIBPATH($i, [db-4])
913      ac_cv_found_db_lib=$ac_cv_found_db_4_lib
914else
915      CMU_DB3_LIB_WHERE1($i)
916      CMU_TEST_LIBPATH($i, [db-3])
917      ac_cv_found_db_lib=$ac_cv_found_db_3_lib
918fi
919      if test "$ac_cv_found_db_lib" = "yes" ; then
920        ac_cv_db_where_lib=$i
921        AC_MSG_RESULT(found)
922        break
923      else
924        AC_MSG_RESULT(not found)
925      fi
926    done
927])
928
929AC_DEFUN(CMU_USE_DB, [
930AC_ARG_WITH(db,
931        [  --with-db=PREFIX      Compile with db support],
932        [if test "X$with_db" = "X"; then
933                with_db=yes
934        fi])
935AC_ARG_WITH(db-lib,
936        [  --with-db-lib=dir     use db libraries in dir],
937        [if test "$withval" = "yes" -o "$withval" = "no"; then
938                AC_MSG_ERROR([No argument for --with-db-lib])
939        fi])
940AC_ARG_WITH(db-include,
941        [  --with-db-include=dir use db headers in dir],
942        [if test "$withval" = "yes" -o "$withval" = "no"; then
943                AC_MSG_ERROR([No argument for --with-db-include])
944        fi])
945AC_ARG_ENABLE(db4,
946        [  --enable-db4          use db 4.x libraries])
947       
948        if test "X$with_db" != "X"; then
949          if test "$with_db" != "yes"; then
950            ac_cv_db_where_lib=$with_db/lib
951            ac_cv_db_where_inc=$with_db/include
952          fi
953        fi
954
955        if test "X$with_db_lib" != "X"; then
956          ac_cv_db_where_lib=$with_db_lib
957        fi
958        if test "X$ac_cv_db_where_lib" = "X"; then
959          CMU_DB_LIB_WHERE(/usr/athena/lib /usr/lib /usr/local/lib)
960        fi
961
962        if test "X$with_db_include" != "X"; then
963          ac_cv_db_where_inc=$with_db_include
964        fi
965        if test "X$ac_cv_db_where_inc" = "X"; then
966          CMU_DB_INC_WHERE(/usr/athena/include /usr/local/include)
967        fi
968
969        AC_MSG_CHECKING(whether to include db)
970        if test "X$ac_cv_db_where_lib" = "X" -o "X$ac_cv_db_where_inc" = "X"; then
971          ac_cv_found_db=no
972          AC_MSG_RESULT(no)
973        else
974          ac_cv_found_db=yes
975          AC_MSG_RESULT(yes)
976          DB_INC_DIR=$ac_cv_db_where_inc
977          DB_LIB_DIR=$ac_cv_db_where_lib
978          DB_INC_FLAGS="-I${DB_INC_DIR}"
979          if test "$enable_db4" = "yes"; then
980             DB_LIB_FLAGS="-L${DB_LIB_DIR} -ldb-4"
981          else
982             DB_LIB_FLAGS="-L${DB_LIB_DIR} -ldb-3"
983          fi
984          dnl Do not force configure.in to put these in CFLAGS and LIBS unconditionally
985          dnl Allow makefile substitutions....
986          AC_SUBST(DB_INC_FLAGS)
987          AC_SUBST(DB_LIB_FLAGS)
988          if test "X$RPATH" = "X"; then
989                RPATH=""
990          fi
991          case "${host}" in
992            *-*-linux*)
993              if test "X$RPATH" = "X"; then
994                RPATH="-Wl,-rpath,${DB_LIB_DIR}"
995              else
996                RPATH="${RPATH}:${DB_LIB_DIR}"
997              fi
998              ;;
999            *-*-hpux*)
1000              if test "X$RPATH" = "X"; then
1001                RPATH="-Wl,+b${DB_LIB_DIR}"
1002              else
1003                RPATH="${RPATH}:${DB_LIB_DIR}"
1004              fi
1005              ;;
1006            *-*-irix*)
1007              if test "X$RPATH" = "X"; then
1008                RPATH="-Wl,-rpath,${DB_LIB_DIR}"
1009              else
1010                RPATH="${RPATH}:${DB_LIB_DIR}"
1011              fi
1012              ;;
1013            *-*-solaris2*)
1014              if test "$ac_cv_prog_gcc" = yes; then
1015                if test "X$RPATH" = "X"; then
1016                  RPATH="-Wl,-R${DB_LIB_DIR}"
1017                else
1018                  RPATH="${RPATH}:${DB_LIB_DIR}"
1019                fi
1020              else
1021                RPATH="${RPATH} -R${DB_LIB_DIR}"
1022              fi
1023              ;;
1024          esac
1025          AC_SUBST(RPATH)
1026        fi
1027        ])
1028
1029
1030
1031dnl ---- CUT HERE ---
1032
1033dnl These are the Cyrus Berkeley DB macros.  In an ideal world these would be
1034dnl identical to the above.
1035
1036dnl They are here so that they can be shared between Cyrus IMAPd
1037dnl and Cyrus SASL with relative ease.
1038
1039dnl The big difference between this and the ones above is that we don't assume
1040dnl that we know the name of the library, and we try a lot of permutations
1041dnl instead.  We also assume that DB4 is acceptable.
1042
1043dnl When we're done, there will be a BDB_LIBADD and a BDB_INCADD which should
1044dnl be used when necessary.  We should probably be smarter about our RPATH
1045dnl handling.
1046
1047dnl Call these with BERKELEY_DB_CHK.
1048
1049dnl We will also set $dblib to "berkeley" if we are successful, "no" otherwise.
1050
1051dnl this is unbelievably painful due to confusion over what db-3 should be
1052dnl named and where the db-3 header file is located.  arg.
1053AC_DEFUN(CYRUS_BERKELEY_DB_CHK_LIB,
1054[
1055        BDB_SAVE_LIBS=$LIBS
1056
1057        if test -d $with_bdb_lib; then
1058            CMU_ADD_LIBPATH_TO($with_bdb_lib, LIBS)
1059            CMU_ADD_LIBPATH_TO($with_bdb_lib, BDB_LIBADD)
1060        else
1061            BDB_LIBADD=""
1062        fi
1063
1064        for dbname in db-4.1 db4.1 db-4.0 db4.0 db-4 db4 db-3.3 db3.3 db-3.2 db3.2 db-3.1 db3.1 db-3 db3 db
1065          do
1066            AC_CHECK_LIB($dbname, db_create, BDB_LIBADD="$BDB_LIBADD -l$dbname";
1067              dblib="berkeley"; break, dblib="no")
1068          done
1069        if test "$dblib" = "no"; then
1070          AC_CHECK_LIB(db, db_open, BDB_LIBADD="$BDB_LIBADD -ldb";
1071            dblib="berkeley"; dbname=db,
1072            dblib="no")
1073        fi
1074
1075        LIBS=$BDB_SAVE_LIBS
1076])
1077
1078AC_DEFUN(CYRUS_BERKELEY_DB_OPTS,
1079[
1080AC_ARG_WITH(bdb-libdir,
1081        [  --with-bdb-libdir=DIR   Berkeley DB lib files are in DIR],
1082        with_bdb_lib=$withval,
1083        with_bdb_lib=none)
1084AC_ARG_WITH(bdb-incdir,
1085        [  --with-bdb-incdir=DIR   Berkeley DB include files are in DIR],
1086        with_bdb_inc=$withval,
1087        with_bdb_inc=none)
1088])
1089
1090AC_DEFUN(CYRUS_BERKELEY_DB_CHK,
1091[
1092        AC_REQUIRE([CYRUS_BERKELEY_DB_OPTS])
1093
1094        cmu_save_CPPFLAGS=$CPPFLAGS
1095
1096        if test -d $with_bdb_inc; then
1097            CPPFLAGS="$CPPFLAGS -I$with_bdb_inc"
1098            BDB_INCADD="-I$with_bdb_inc"
1099        else
1100            BDB_INCADD=""
1101        fi
1102
1103        dnl Note that FreeBSD puts it in a wierd place
1104        dnl (but they should use with-bdb-incdir)
1105        AC_CHECK_HEADER(db.h,
1106                        CYRUS_BERKELEY_DB_CHK_LIB(),
1107                        dblib="no")
1108
1109        CPPFLAGS=$cmu_save_CPPFLAGS
1110])
1111
1112dnl $Id: aclocal.m4,v 1.1.1.2 2003-02-12 22:34:28 ghudson Exp $
1113
1114AC_DEFUN(CMU_TEST_LIBPATH, [
1115changequote(<<, >>)
1116define(<<CMU_AC_CV_FOUND>>, translit(ac_cv_found_$2_lib, <<- *>>, <<__p>>))
1117changequote([, ])
1118if test "$CMU_AC_CV_FOUND" = "yes"; then
1119  if test \! -r "$1/lib$2.a" -a \! -r "$1/lib$2.so" -a \! -r "$1/lib$2.sl"; then
1120    CMU_AC_CV_FOUND=no
1121  fi
1122fi
1123])
1124
1125AC_DEFUN(CMU_TEST_INCPATH, [
1126changequote(<<, >>)
1127define(<<CMU_AC_CV_FOUND>>, translit(ac_cv_found_$2_inc, [ *], [_p]))
1128changequote([, ])
1129if test "$CMU_AC_CV_FOUND" = "yes"; then
1130  if test \! -r "$1/$2.h"; then
1131    CMU_AC_CV_FOUND=no
1132  fi
1133fi
1134])
1135
1136dnl CMU_CHECK_HEADER_NOCACHE(HEADER-FILE, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
1137AC_DEFUN(CMU_CHECK_HEADER_NOCACHE,
1138[dnl Do the transliteration at runtime so arg 1 can be a shell variable.
1139ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
1140AC_MSG_CHECKING([for $1])
1141AC_TRY_CPP([#include <$1>], eval "ac_cv_header_$ac_safe=yes",
1142  eval "ac_cv_header_$ac_safe=no")
1143if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
1144  AC_MSG_RESULT(yes)
1145  ifelse([$2], , :, [$2])
1146else
1147  AC_MSG_RESULT(no)
1148ifelse([$3], , , [$3
1149])dnl
1150fi
1151])
1152
1153dnl afs.m4--AFS libraries, includes, and dependencies
1154dnl $Id: aclocal.m4,v 1.1.1.2 2003-02-12 22:34:28 ghudson Exp $
1155dnl Chaskiel Grundman
1156dnl based on kerberos_v4.m4
1157dnl Derrick Brashear
1158dnl from KTH krb and Arla
1159
1160AC_DEFUN(CMU_AFS_INC_WHERE1, [
1161cmu_save_CPPFLAGS=$CPPFLAGS
1162CPPFLAGS="$cmu_save_CPPFLAGS -I$1"
1163AC_TRY_COMPILE([#include <afs/param.h>],
1164[#ifndef SYS_NAME
1165choke me
1166#endif
1167int foo;],
1168ac_cv_found_afs_inc=yes,
1169ac_cv_found_afs_inc=no)
1170CPPFLAGS=$cmu_save_CPPFLAGS
1171])
1172
1173AC_DEFUN(CMU_AFS_LIB_WHERE1, [
1174save_LIBS="$LIBS"
1175save_LDFLAGS="$LDFLAGS"
1176
1177LIBS="-lauth $1/afs/util.a $LIB_SOCKET $LIBS"
1178LDFLAGS="-L$1 -L$1/afs $LDFLAGS"
1179dnl suppress caching
1180AC_TRY_LINK([],[afsconf_Open();], ac_cv_found_afs_lib=yes, ac_cv_found_afs_lib=no)
1181LIBS="$save_LIBS"
1182LDFLAGS="$save_LDFLAGS"
1183])
1184
1185AC_DEFUN(CMU_AFS_WHERE, [
1186   for i in $1; do
1187      AC_MSG_CHECKING(for AFS in $i)
1188      CMU_AFS_INC_WHERE1("$i/include")
1189      ac_cv_found_lwp_inc=$ac_cv_found_afs_inc
1190      CMU_TEST_INCPATH($i/include, lwp)
1191      ac_cv_found_afs_inc=$ac_cv_found_lwp_inc
1192      if test "$ac_cv_found_afs_inc" = "yes"; then
1193        CMU_AFS_LIB_WHERE1("$i/lib")
1194        if test "$ac_cv_found_afs_lib" = "yes"; then
1195          ac_cv_afs_where=$i
1196          AC_MSG_RESULT(found)
1197          break
1198        else
1199          AC_MSG_RESULT(not found)
1200        fi
1201      else
1202        AC_MSG_RESULT(not found)
1203      fi
1204    done
1205])
1206
1207AC_DEFUN(CMU_AFS, [
1208AC_REQUIRE([CMU_SOCKETS])
1209AC_REQUIRE([CMU_LIBSSL])
1210AC_ARG_WITH(AFS,
1211        [  --with-afs=PREFIX      Compile with AFS support],
1212        [if test "X$with_AFS" = "X"; then
1213                with_AFS=yes
1214        fi])
1215
1216        if test "X$with_AFS" != "X"; then
1217          ac_cv_afs_where=$with_AFS
1218        fi
1219        if test "X$ac_cv_afs_where" = "X"; then
1220          CMU_AFS_WHERE(/usr/afsws /usr/local /usr/athena)
1221        fi
1222
1223        AC_MSG_CHECKING(whether to include AFS)
1224        if test "X$ac_cv_afs_where" = "Xno" -o "X$ac_cv_afs_where" = "X"; then
1225          ac_cv_found_afs=no
1226          AC_MSG_RESULT(no)
1227        else
1228          ac_cv_found_afs=yes
1229          AC_MSG_RESULT(yes)
1230          AFS_INC_DIR="$ac_cv_afs_where/include"
1231          AFS_LIB_DIR="$ac_cv_afs_where/lib"
1232          AFS_TOP_DIR="$ac_cv_afs_where"
1233          AFS_INC_FLAGS="-I${AFS_INC_DIR}"
1234          AFS_LIB_FLAGS="-L${AFS_LIB_DIR} -L${AFS_LIB_DIR}/afs"
1235          cmu_save_LIBS="$LIBS"
1236          cmu_save_CPPFLAGS="$CPPFLAGS"
1237          CPPFLAGS="$CPPFLAGS ${AFS_INC_FLAGS}"
1238          cmu_save_LDFLAGS="$LDFLAGS"
1239          LDFLAGS="$cmu_save_LDFLAGS ${AFS_LIB_FLAGS}"
1240                       
1241          AC_CHECK_HEADER(afs/stds.h)
1242
1243          AC_MSG_CHECKING([if libdes is needed])
1244          AC_TRY_LINK([],[des_quad_cksum();],AFS_DES_LIB="",AFS_DES_LIB="maybe")
1245          if test "X$AFS_DES_LIB" != "X"; then
1246              LIBS="$cmu_save_LIBS -ldes"
1247              AC_TRY_LINK([], [des_quad_cksum();],AFS_DES_LIB="yes")
1248              if test "X$AFS_DES_LIB" = "Xyes"; then
1249                  AC_MSG_RESULT([yes])
1250                  AFS_LIBDES="-ldes"
1251                  AFS_LIBDESA="${AFS_LIB_DIR}/libdes.a"
1252              else
1253                  LIBS="$cmu_save_LIBS $LIBSSL_LIB_FLAGS"
1254                  AC_TRY_LINK([],
1255                  [des_quad_cksum();],AFS_DES_LIB="libcrypto")
1256                  if test "X$AFS_DES_LIB" = "Xlibcrypto"; then
1257                      AC_MSG_RESULT([libcrypto])
1258                      AFS_LIBDES="$LIBSSL_LIB_FLAGS"
1259                      AFS_LIBDESA="$LIBSSL_LIB_FLAGS"
1260                  else
1261                      AC_MSG_RESULT([unknown])
1262                      AC_MSG_ERROR([Could not use -ldes])
1263                  fi
1264              fi
1265          else
1266             AC_MSG_RESULT([no])
1267          fi
1268
1269
1270          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"
1271          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"
1272          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"
1273          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"
1274          AFS_KTC_LIBS="-lauth ${AFS_LIB_DIR}/afs/libsys.a -lrx -llwp ${AFS_LIBDES} -lcom_err ${AFS_LIB_DIR}/afs/util.a"
1275          LIBS="$cmu_save_LIBS"
1276          AC_CHECK_FUNC(flock)
1277          LIBS="$cmu_save_LIBS ${AFS_CLIENT_LIBS} ${LIB_SOCKET}"
1278          if test "X$ac_cv_func_flock" != "Xyes"; then
1279             AC_MSG_CHECKING([if AFS needs flock])
1280             AC_TRY_LINK([#include <afs/param.h>
1281#ifdef HAVE_AFS_STDS_H
1282#include <afs/stds.h>
1283#endif
1284#include <ubik.h>
1285#include <afs/cellconfig.h>
1286#include <afs/auth.h>
1287#include <afs/volser.h>
1288struct ubik_client * cstruct;
1289int sigvec() {return 0;}
1290extern int UV_SetSecurity();],
1291             [vsu_ClientInit(1,"","",0,
1292                             &cstruct,UV_SetSecurity)],
1293             AFS_FLOCK=no,AFS_FLOCK=yes)
1294             if test $AFS_FLOCK = "no"; then
1295                AC_MSG_RESULT([no])
1296             else
1297               AC_MSG_RESULT([yes])
1298               LDFLAGS="$LDFLAGS -L/usr/ucblib"
1299               AC_CHECK_LIB(ucb, flock,:, [AC_CHECK_LIB(BSD, flock)])
1300             fi
1301          fi
1302          LIBS="$cmu_save_LIBS"
1303          AC_CHECK_FUNC(sigvec)
1304          LIBS="$cmu_save_LIBS ${AFS_CLIENT_LIBS} ${LIB_SOCKET}"
1305          if test "X$ac_cv_func_sigvec" != "Xyes"; then
1306             AC_MSG_CHECKING([if AFS needs sigvec])
1307             AC_TRY_LINK([#include <afs/param.h>
1308#ifdef HAVE_AFS_STDS_H
1309#include <afs/stds.h>
1310#endif
1311#include <ubik.h>
1312#include <afs/cellconfig.h>
1313#include <afs/auth.h>
1314#include <afs/volser.h>
1315struct ubik_client * cstruct;
1316int flock() {return 0;}
1317extern int UV_SetSecurity();],
1318             [vsu_ClientInit(1,"","",0,
1319                             &cstruct,UV_SetSecurity)],
1320             AFS_SIGVEC=no,AFS_SIGVEC=yes)
1321             if test $AFS_SIGVEC = "no"; then
1322                AC_MSG_RESULT([no])
1323             else
1324               AC_MSG_RESULT([yes])
1325               LDFLAGS="$LDFLAGS -L/usr/ucblib"
1326               AC_CHECK_LIB(ucb, sigvec,:,[AC_CHECK_LIB(BSD, sigvec)])
1327             fi
1328          fi
1329          if test "$ac_cv_lib_ucb_flock" = "yes" -o "$ac_cv_lib_ucb_sigvec" = "yes"; then
1330             AFS_LIB_FLAGS="${AFS_LIB_FLAGS} -L/usr/ucblib -R/usr/ucblib"
1331          fi
1332          if test "$ac_cv_lib_ucb_flock" = "yes" -o "$ac_cv_lib_ucb_sigvec" = "yes"; then
1333             AFS_BSD_LIB="-lucb"
1334          elif test "$ac_cv_lib_BSD_flock" = "yes" -o "$ac_cv_lib_BSD_sigvec" = "yes"; then
1335             AFS_BSD_LIB="-lBSD"
1336          fi
1337          if test "X$AFS_BSD_LIB" != "X" ; then
1338                AFS_CLIENT_LIBS_STATIC="$AFS_CLIENT_LIBS_STATIC $AFS_BSD_LIB"
1339                AFS_KTC_LIBS_STATIC="$AFS_KTC_LIBS_STATIC $AFS_BSD_LIB"
1340                AFS_CLIENT_LIBS="$AFS_CLIENT_LIBS $AFS_BSD_LIB"
1341                AFS_RX_LIBS="$AFS_CLIENT_LIBS $AFS_BSD_LIB"
1342                AFS_KTC_LIBS="$AFS_KTC_LIBS $AFS_BSD_LIB"
1343          fi
1344          LIBS="$cmu_save_LIBS $AFS_CLIENT_LIBS ${LIB_SOCKET}"
1345          AC_CHECK_FUNC(des_pcbc_init)
1346          if test "X$ac_cv_func_des_pcbc_init" != "Xyes"; then
1347           AC_CHECK_LIB(descompat, des_pcbc_init, AFS_DESCOMPAT_LIB="-ldescompat")
1348           if test "X$AFS_DESCOMPAT_LIB" != "X" ; then
1349                AFS_CLIENT_LIBS_STATIC="$AFS_CLIENT_LIBS_STATIC $AFS_DESCOMPAT_LIB"
1350                AFS_KTC_LIBS_STATIC="$AFS_KTC_LIBS_STATIC $AFS_DESCOMPAT_LIB"
1351                AFS_CLIENT_LIBS="$AFS_CLIENT_LIBS $AFS_DESCOMPAT_LIB"
1352                AFS_KTC_LIBS="$AFS_KTC_LIBS $AFS_DESCOMPAT_LIB"
1353           else
1354
1355           AC_MSG_CHECKING([if rxkad needs des_pcbc_init])
1356           AC_TRY_LINK(,[tkt_DecodeTicket();],RXKAD_PROBLEM=no,RXKAD_PROBLEM=maybe)
1357            if test "$RXKAD_PROBLEM" = "maybe"; then
1358              AC_TRY_LINK([int des_pcbc_init() { return 0;}],
1359              [tkt_DecodeTicket();],RXKAD_PROBLEM=yes,RXKAD_PROBLEM=error)
1360              if test "$RXKAD_PROBLEM" = "yes"; then
1361                    AC_MSG_RESULT([yes])
1362                    AC_MSG_ERROR([cannot use rxkad])
1363              else
1364                    AC_MSG_RESULT([unknown])       
1365                    AC_MSG_ERROR([Unknown error testing rxkad])
1366              fi
1367            else
1368              AC_MSG_RESULT([no])
1369            fi
1370           fi
1371          fi
1372
1373          AC_MSG_CHECKING([if libaudit is needed])
1374          AFS_LIBAUDIT=""
1375          LIBS="$cmu_save_LIBS $AFS_CLIENT_LIBS ${LIB_SOCKET}"
1376          AC_TRY_LINK([#include <afs/param.h>
1377#ifdef HAVE_AFS_STDS_H
1378#include <afs/stds.h>
1379#endif
1380#include <afs/cellconfig.h>
1381#include <afs/auth.h>],
1382          [afsconf_SuperUser();],AFS_AUDIT_LIB="",AFS_AUDIT_LIB="maybe")
1383          if test "X$AFS_AUDIT_LIB" != "X"; then
1384          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"
1385             AC_TRY_LINK([#include <afs/param.h>
1386#ifdef HAVE_AFS_STDS_H
1387#include <afs/stds.h>
1388#endif
1389#include <afs/cellconfig.h>
1390#include <afs/auth.h>],
1391             [afsconf_SuperUser();],AFS_AUDIT_LIB="yes")
1392             if test "X$AFS_AUDIT_LIB" = "Xyes"; then
1393                 AC_MSG_RESULT([yes])
1394                 AFS_LIBAUDIT="-laudit"
1395                 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"
1396                 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"
1397                 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"
1398             else
1399                 AC_MSG_RESULT([unknown])
1400                 AC_MSG_ERROR([Could not use -lauth while testing for -laudit])
1401             fi
1402          else
1403             AC_MSG_RESULT([no])
1404          fi
1405
1406          AC_CHECK_FUNCS(VL_ProbeServer)
1407          AC_MSG_CHECKING([if new-style afs_ integer types are defined])
1408          AC_CACHE_VAL(ac_cv_afs_int32,
1409dnl The next few lines contain a quoted argument to egrep
1410dnl It is critical that there be no leading or trailing whitespace
1411dnl or newlines
1412[AC_EGREP_CPP(dnl
1413changequote(<<,>>)dnl
1414<<(^|[^a-zA-Z_0-9])afs_int32[^a-zA-Z_0-9]>>dnl
1415changequote([,]), [#include <afs/param.h>
1416#ifdef HAVE_AFS_STDS_H
1417#include <afs/stds.h>
1418#endif],
1419ac_cv_afs_int32=yes, ac_cv_afs_int32=no)])
1420          AC_MSG_RESULT($ac_cv_afs_int32)
1421          if test $ac_cv_afs_int32 = yes ; then
1422            AC_DEFINE(HAVE_AFS_INT32,, [AFS provides new "unambiguous" type names])
1423          else
1424            AC_DEFINE(afs_int16, int16, [it's a type definition])
1425            AC_DEFINE(afs_int32, int32, [it's a type definition])
1426            AC_DEFINE(afs_uint16, u_int16, [it's a type definition])
1427            AC_DEFINE(afs_uint32, u_int32, [it's a type definition])
1428          fi
1429
1430          CPPFLAGS="${cmu_save_CPPFLAGS}"
1431          LDFLAGS="${cmu_save_LDFLAGS}"
1432          LIBS="${cmu_save_LIBS}"
1433          AC_DEFINE(AFS_ENV,, [Use AFS. (find what needs this and nuke it)])
1434          AC_DEFINE(AFS,, [Use AFS. (find what needs this and nuke it)])
1435          AC_SUBST(AFS_CLIENT_LIBS_STATIC)
1436          AC_SUBST(AFS_KTC_LIBS_STATIC)
1437          AC_SUBST(AFS_CLIENT_LIBS)
1438          AC_SUBST(AFS_RX_LIBS)
1439          AC_SUBST(AFS_KTC_LIBS)
1440          AC_SUBST(AFS_INC_FLAGS)
1441          AC_SUBST(AFS_LIB_FLAGS)
1442          AC_SUBST(AFS_TOP_DIR)
1443          AC_SUBST(AFS_LIBAUDIT)
1444          AC_SUBST(AFS_LIBDES)
1445          AC_SUBST(AFS_LIBDESA)
1446        fi
1447        ])
1448
1449AC_DEFUN(CMU_NEEDS_AFS,
1450[AC_REQUIRE([CMU_AFS])
1451if test "$ac_cv_found_afs" != "yes"; then
1452        AC_ERROR([Cannot continue without AFS])
1453fi])
1454
1455dnl libssl.m4--Ssl libraries and includes
1456dnl Derrick Brashear
1457dnl from KTH kafs and Arla
1458dnl $Id: aclocal.m4,v 1.1.1.2 2003-02-12 22:34:28 ghudson Exp $
1459
1460AC_DEFUN(CMU_LIBSSL_INC_WHERE1, [
1461saved_CPPFLAGS=$CPPFLAGS
1462CPPFLAGS="$saved_CPPFLAGS -I$1"
1463CMU_CHECK_HEADER_NOCACHE(openssl/ssl.h,
1464ac_cv_found_libssl_inc=yes,
1465ac_cv_found_libssl_inc=no)
1466CPPFLAGS=$saved_CPPFLAGS
1467])
1468
1469AC_DEFUN(CMU_LIBSSL_INC_WHERE, [
1470   for i in $1; do
1471      AC_MSG_CHECKING(for libssl headers in $i)
1472      CMU_LIBSSL_INC_WHERE1($i)
1473      CMU_TEST_INCPATH($i, ssl)
1474      if test "$ac_cv_found_libssl_inc" = "yes"; then
1475        ac_cv_libssl_where_inc=$i
1476        AC_MSG_RESULT(found)
1477        break
1478      else
1479        AC_MSG_RESULT(not found)
1480      fi
1481    done
1482])
1483
1484AC_DEFUN(CMU_LIBSSL_LIB_WHERE1, [
1485saved_LIBS=$LIBS
1486LIBS="$saved_LIBS -L$1 -lssl -lcrypto $LIB_SOCKET"
1487AC_TRY_LINK(,
1488[SSL_write();],
1489[ac_cv_found_ssl_lib=yes],
1490ac_cv_found_ssl_lib=no)
1491LIBS=$saved_LIBS
1492])
1493
1494AC_DEFUN(CMU_LIBSSL_LIB_WHERE, [
1495   for i in $1; do
1496      AC_MSG_CHECKING(for libssl libraries in $i)
1497      CMU_LIBSSL_LIB_WHERE1($i)
1498      dnl deal with false positives from implicit link paths
1499      CMU_TEST_LIBPATH($i, ssl)
1500      if test "$ac_cv_found_ssl_lib" = "yes" ; then
1501        ac_cv_libssl_where_lib=$i
1502        AC_MSG_RESULT(found)
1503        break
1504      else
1505        AC_MSG_RESULT(not found)
1506      fi
1507    done
1508])
1509
1510AC_DEFUN(CMU_LIBSSL, [
1511AC_REQUIRE([CMU_SOCKETS])
1512AC_ARG_WITH(libssl,
1513        [  --with-libssl=PREFIX      Compile with Libssl support],
1514        [if test "X$with_libssl" = "X"; then
1515                with_libssl=yes
1516        fi])
1517AC_ARG_WITH(libssl-lib,
1518        [  --with-libssl-lib=dir     use libssl libraries in dir],
1519        [if test "$withval" = "yes" -o "$withval" = "no"; then
1520                AC_MSG_ERROR([No argument for --with-libssl-lib])
1521        fi])
1522AC_ARG_WITH(libssl-include,
1523        [  --with-libssl-include=dir use libssl headers in dir],
1524        [if test "$withval" = "yes" -o "$withval" = "no"; then
1525                AC_MSG_ERROR([No argument for --with-libssl-include])
1526        fi])
1527
1528        if test "X$with_libssl" != "X"; then
1529          if test "$with_libssl" != "yes" -a "$with_libssl" != no; then
1530            ac_cv_libssl_where_lib=$with_libssl/lib
1531            ac_cv_libssl_where_inc=$with_libssl/include
1532          fi
1533        fi
1534
1535        if test "$with_libssl" != "no"; then
1536          if test "X$with_libssl_lib" != "X"; then
1537            ac_cv_libssl_where_lib=$with_libssl_lib
1538          fi
1539          if test "X$ac_cv_libssl_where_lib" = "X"; then
1540            CMU_LIBSSL_LIB_WHERE(/usr/local/lib/openssl /usr/lib/openssl /usr/local/lib /usr/lib)
1541          fi
1542
1543          if test "X$with_libssl_include" != "X"; then
1544            ac_cv_libssl_where_inc=$with_libssl_include
1545          fi
1546          if test "X$ac_cv_libssl_where_inc" = "X"; then
1547            CMU_LIBSSL_INC_WHERE(/usr/local/include /usr/include)
1548          fi
1549        fi
1550
1551        AC_MSG_CHECKING(whether to include libssl)
1552        if test "X$ac_cv_libssl_where_lib" = "X" -a "X$ac_cv_libssl_where_inc" = "X"; then
1553          ac_cv_found_libssl=no
1554          AC_MSG_RESULT(no)
1555        else
1556          ac_cv_found_libssl=yes
1557          AC_MSG_RESULT(yes)
1558          LIBSSL_INC_DIR=$ac_cv_libssl_where_inc
1559          LIBSSL_LIB_DIR=$ac_cv_libssl_where_lib
1560          LIBSSL_INC_FLAGS="-I${LIBSSL_INC_DIR}"
1561          LIBSSL_LIB_FLAGS="-L${LIBSSL_LIB_DIR} -lssl -lcrypto"
1562          if test "X$RPATH" = "X"; then
1563                RPATH=""
1564          fi
1565          case "${host}" in
1566            *-*-linux*)
1567              if test "X$RPATH" = "X"; then
1568                RPATH="-Wl,-rpath,${LIBSSL_LIB_DIR}"
1569              else
1570                RPATH="${RPATH}:${LIBSSL_LIB_DIR}"
1571              fi
1572              ;;
1573            *-*-hpux*)
1574              if test "X$RPATH" = "X"; then
1575                RPATH="-Wl,+b${LIBSSL_LIB_DIR}"
1576              else
1577                RPATH="${RPATH}:${LIBSSL_LIB_DIR}"
1578              fi
1579              ;;
1580            *-*-irix*)
1581              if test "X$RPATH" = "X"; then
1582                RPATH="-Wl,-rpath,${LIBSSL_LIB_DIR}"
1583              else
1584                RPATH="${RPATH}:${LIBSSL_LIB_DIR}"
1585              fi
1586              ;;
1587            *-*-solaris2*)
1588              if test "$ac_cv_prog_gcc" = yes; then
1589                if test "X$RPATH" = "X"; then
1590                  RPATH="-Wl,-R${LIBSSL_LIB_DIR}"
1591                else
1592                  RPATH="${RPATH}:${LIBSSL_LIB_DIR}"
1593                fi
1594              else
1595                RPATH="${RPATH} -R${LIBSSL_LIB_DIR}"
1596              fi
1597              ;;
1598          esac
1599          AC_SUBST(RPATH)
1600        fi
1601        AC_SUBST(LIBSSL_INC_DIR)
1602        AC_SUBST(LIBSSL_LIB_DIR)
1603        AC_SUBST(LIBSSL_INC_FLAGS)
1604        AC_SUBST(LIBSSL_LIB_FLAGS)
1605        ])
1606
1607
1608dnl kerberos_v4.m4--Kerberos 4 libraries and includes
1609dnl Derrick Brashear
1610dnl from KTH krb and Arla
1611dnl $Id: aclocal.m4,v 1.1.1.2 2003-02-12 22:34:28 ghudson Exp $
1612
1613AC_DEFUN(CMU_KRB_SENDAUTH_PROTO, [
1614AC_MSG_CHECKING(for krb_sendauth prototype)
1615AC_TRY_COMPILE(
1616[#include <krb.h>
1617int krb_sendauth (long options, int fd, KTEXT ktext, char *service,
1618                  char *inst, char *realm, u_long checksum,
1619                  MSG_DAT *msg_data, CREDENTIALS *cred,
1620                  Key_schedule schedule, struct sockaddr_in *laddr,
1621                  struct sockaddr_in *faddr, char *version);],
1622[int foo = krb_sendauth(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); ],
1623ac_cv_krb_sendauth_proto=no,
1624ac_cv_krb_sendauth_proto=yes)
1625AC_MSG_RESULT($ac_cv_krb_sendauth_proto)
1626if test "$ac_cv_krb_sendauth_proto" = yes; then
1627        AC_DEFINE(HAVE_KRB_SENDAUTH_PROTO)dnl
1628fi
1629AC_MSG_RESULT($ac_cv_krb_sendauth_proto)
1630])
1631
1632AC_DEFUN(CMU_KRB_SET_KEY_PROTO, [
1633AC_MSG_CHECKING(for krb_set_key prototype)
1634AC_CACHE_VAL(ac_cv_krb_set_key_proto, [
1635cmu_save_CPPFLAGS="$CPPFLAGS"
1636CPPFLAGS="${CPPFLAGS} ${KRB_INC_FLAGS}"
1637AC_TRY_COMPILE(
1638[#include <krb.h>
1639int krb_set_key(char *key, int cvt);],
1640[int foo = krb_set_key(0, 0);],
1641ac_cv_krb_set_key_proto=no,
1642ac_cv_krb_set_key_proto=yes)
1643])
1644CPPFLAGS="${cmu_save_CPPFLAGS}"
1645if test "$ac_cv_krb_set_key_proto" = yes; then
1646        AC_DEFINE(HAVE_KRB_SET_KEY_PROTO)dnl
1647fi
1648AC_MSG_RESULT($ac_cv_krb_set_key_proto)
1649])
1650
1651AC_DEFUN(CMU_KRB4_32_DEFN, [
1652AC_MSG_CHECKING(for KRB4_32 definition)
1653AC_CACHE_VAL(ac_cv_krb4_32_defn, [
1654cmu_save_CPPFLAGS="$CPPFLAGS"
1655CPPFLAGS="${CPPFLAGS} ${KRB_INC_FLAGS}"
1656AC_TRY_COMPILE(
1657[#include <krb.h>
1658],
1659[KRB4_32 foo = 1;],
1660ac_cv_krb4_32_defn=yes,
1661ac_cv_krb4_32_defn=no)
1662])
1663CPPFLAGS="${cmu_save_CPPFLAGS}"
1664if test "$ac_cv_krb4_32_defn" = yes; then
1665        AC_DEFINE(HAVE_KRB4_32_DEFINE)dnl
1666fi
1667AC_MSG_RESULT($ac_cv_krb4_32_defn)
1668])
1669
1670AC_DEFUN(CMU_KRB_RD_REQ_PROTO, [
1671AC_MSG_CHECKING(for krb_rd_req prototype)
1672AC_CACHE_VAL(ac_cv_krb_rd_req_proto, [
1673cmu_save_CPPFLAGS="$CPPFLAGS"
1674CPPFLAGS="${CPPFLAGS} ${KRB_INC_FLAGS}"
1675AC_TRY_COMPILE(
1676[#include <krb.h>
1677int krb_rd_req(KTEXT authent, char *service, char *instance,
1678unsigned KRB_INT32 from_addr, AUTH_DAT *ad, char *fn);],
1679[int foo = krb_rd_req(0,0,0,0,0,0);],
1680ac_cv_krb_rd_req_proto=no,
1681ac_cv_krb_rd_req_proto=yes)
1682])
1683CPPFLAGS="${cmu_save_CPPFLAGS}"
1684if test "$ac_cv_krb_rd_req_proto" = yes; then
1685        AC_DEFINE(HAVE_KRB_RD_REQ_PROTO)dnl
1686fi
1687AC_MSG_RESULT($ac_cv_krb_rd_req_proto)
1688])
1689
1690AC_DEFUN(CMU_KRB_INC_WHERE1, [
1691saved_CPPFLAGS=$CPPFLAGS
1692CPPFLAGS="$saved_CPPFLAGS -I$1"
1693AC_TRY_COMPILE([#include <krb.h>],
1694[struct ktext foo;],
1695ac_cv_found_krb_inc=yes,
1696ac_cv_found_krb_inc=no)
1697if test "$ac_cv_found_krb_inc" = "no"; then
1698  CPPFLAGS="$saved_CPPFLAGS -I$1 -I$1/kerberosIV"
1699  AC_TRY_COMPILE([#include <krb.h>],
1700  [struct ktext foo;],
1701  [ac_cv_found_krb_inc=yes],
1702  ac_cv_found_krb_inc=no)
1703fi
1704CPPFLAGS=$saved_CPPFLAGS
1705])
1706
1707AC_DEFUN(CMU_KRB_INC_WHERE, [
1708   for i in $1; do
1709      AC_MSG_CHECKING(for kerberos headers in $i)
1710      CMU_KRB_INC_WHERE1($i)
1711      CMU_TEST_INCPATH($i, krb)
1712      if test "$ac_cv_found_krb_inc" = "yes"; then
1713        ac_cv_krb_where_inc=$i
1714        AC_MSG_RESULT(found)
1715        break
1716      else
1717        AC_MSG_RESULT(not found)
1718      fi
1719    done
1720])
1721
1722#
1723# Test for kerberos lib files
1724#
1725
1726AC_DEFUN(CMU_KRB_LIB_WHERE1, [
1727saved_LIBS=$LIBS
1728LIBS="$saved_LIBS -L$1 -lkrb $KRB_LIBDES"
1729AC_TRY_LINK(,
1730[dest_tkt();],
1731[ac_cv_found_krb_lib=yes],
1732ac_cv_found_krb_lib=no)
1733LIBS=$saved_LIBS
1734])
1735
1736AC_DEFUN(CMU_KRB_LIB_WHERE, [
1737   for i in $1; do
1738      AC_MSG_CHECKING(for kerberos libraries in $i)
1739      CMU_KRB_LIB_WHERE1($i)
1740      dnl deal with false positives from implicit link paths
1741      CMU_TEST_LIBPATH($i, krb)
1742      if test "$ac_cv_found_krb_lib" = "yes" ; then
1743        ac_cv_krb_where_lib=$i
1744        AC_MSG_RESULT(found)
1745        break
1746      else
1747        AC_MSG_RESULT(not found)
1748      fi
1749    done
1750])
1751
1752AC_DEFUN(CMU_KRB4, [
1753AC_REQUIRE([CMU_SOCKETS])
1754AC_REQUIRE([CMU_LIBSSL])
1755AC_ARG_WITH(krb4,
1756        [  --with-krb4=PREFIX      Compile with Kerberos 4 support],
1757        [if test "X$with_krb4" = "X"; then
1758                with_krb4=yes
1759        fi])
1760AC_ARG_WITH(krb4-lib,
1761        [  --with-krb4-lib=dir     use kerberos 4 libraries in dir],
1762        [if test "$withval" = "yes" -o "$withval" = "no"; then
1763                AC_MSG_ERROR([No argument for --with-krb4-lib])
1764        fi])
1765AC_ARG_WITH(krb4-include,
1766        [  --with-krb4-include=dir use kerberos 4 headers in dir],
1767        [if test "$withval" = "yes" -o "$withval" = "no"; then
1768                AC_MSG_ERROR([No argument for --with-krb4-include])
1769        fi])
1770
1771        if test "X$with_krb4" != "X"; then
1772          if test "$with_krb4" != "yes" -a "$with_krb4" != "no"; then
1773            ac_cv_krb_where_lib=$with_krb4/lib
1774            ac_cv_krb_where_inc=$with_krb4/include
1775          fi
1776        fi
1777
1778        if test "$with_krb4" != "no"; then
1779          if test "X$with_krb4_lib" != "X"; then
1780            ac_cv_krb_where_lib=$with_krb4_lib
1781          fi
1782          if test "X$with_krb4_include" != "X"; then
1783            ac_cv_krb_where_inc=$with_krb4_include
1784          fi
1785          if test "X$ac_cv_krb_where_inc" = "X"; then
1786            CMU_KRB_INC_WHERE(/usr/athena/include /usr/include/kerberosIV /usr/local/include /usr/include/kerberos)
1787          fi
1788        fi
1789
1790          AC_MSG_CHECKING([if libdes is needed])
1791          AC_TRY_LINK([],[des_quad_cksum();],KRB_DES_LIB="",KRB_DES_LIB="maybe")
1792          if test "X$KRB_DES_LIB" != "X"; then
1793              LIBS="$cmu_save_LIBS -ldes"
1794              AC_TRY_LINK([], [des_quad_cksum();],KRB_DES_LIB="yes")
1795              if test "X$KRB_DES_LIB" = "Xyes"; then
1796                  AC_MSG_RESULT([yes])
1797                  KRB_LIBDES="-ldes"
1798                  KRB_LIBDESA="${KRB_LIB_DIR}/libdes.a"
1799              else
1800                  LIBS="$cmu_save_LIBS $LIBSSL_LIB_FLAGS"
1801                  AC_TRY_LINK([],
1802                  [des_quad_cksum();],KRB_DES_LIB="libcrypto")
1803                  if test "X$KRB_DES_LIB" = "Xlibcrypto"; then
1804                      AC_MSG_RESULT([libcrypto])
1805                      KRB_LIBDES="$LIBSSL_LIB_FLAGS"
1806                      KRB_LIBDESA="$LIBSSL_LIB_FLAGS"
1807                  else
1808                      AC_MSG_RESULT([unknown])
1809                      AC_MSG_ERROR([Could not use -ldes])
1810                  fi
1811              fi
1812          else
1813             AC_MSG_RESULT([no])
1814          fi
1815          LIBS="${cmu_save_LIBS}"
1816
1817          if test "X$ac_cv_krb_where_lib" = "X"; then
1818            CMU_KRB_LIB_WHERE(/usr/athena/lib /usr/local/lib /usr/lib)
1819          fi
1820
1821        AC_MSG_CHECKING(whether to include kerberos 4)
1822        if test "X$ac_cv_krb_where_lib" = "X" -o "X$ac_cv_krb_where_inc" = "X"; then
1823          ac_cv_found_krb=no
1824          AC_MSG_RESULT(no)
1825        else
1826          ac_cv_found_krb=yes
1827          AC_MSG_RESULT(yes)
1828          KRB_INC_DIR=$ac_cv_krb_where_inc
1829          KRB_LIB_DIR=$ac_cv_krb_where_lib
1830          KRB_INC_FLAGS="-I${KRB_INC_DIR}"
1831          KRB_LIB_FLAGS="-L${KRB_LIB_DIR} -lkrb ${KRB_LIBDES}"
1832          LIBS="${cmu_save_LIBS} ${KRB_LIB_FLAGS}"
1833          AC_CHECK_LIB(resolv, dns_lookup, KRB_LIB_FLAGS="${KRB_LIB_FLAGS} -lresolv",,"${KRB_LIB_FLAGS}")
1834          AC_CHECK_LIB(crypt, crypt, KRB_LIB_FLAGS="${KRB_LIB_FLAGS} -lcrypt",,"${KRB_LIB_FLAGS}")
1835          AC_CHECK_FUNCS(krb_get_int krb_life_to_time)
1836          AC_SUBST(KRB_INC_FLAGS)
1837          AC_SUBST(KRB_LIB_FLAGS)
1838          LIBS="${cmu_save_LIBS}"
1839          AC_DEFINE(KERBEROS,,[Use kerberos 4. find out what needs this symbol])
1840          if test "X$RPATH" = "X"; then
1841                RPATH=""
1842          fi
1843          case "${host}" in
1844            *-*-linux*)
1845              if test "X$RPATH" = "X"; then
1846                RPATH="-Wl,-rpath,${KRB_LIB_DIR}"
1847              else
1848                RPATH="${RPATH}:${KRB_LIB_DIR}"
1849              fi
1850              ;;
1851            *-*-hpux*)
1852              if test "X$RPATH" = "X"; then
1853                RPATH="-Wl,+b${KRB_LIB_DIR}"
1854              else
1855                RPATH="${RPATH}:${KRB_LIB_DIR}"
1856              fi
1857              ;;
1858            *-*-irix*)
1859              if test "X$RPATH" = "X"; then
1860                RPATH="-Wl,-rpath,${KRB_LIB_DIR}"
1861              else
1862                RPATH="${RPATH}:${KRB_LIB_DIR}"
1863              fi
1864              ;;
1865            *-*-solaris2*)
1866              if test "$ac_cv_prog_gcc" = yes; then
1867                if test "X$RPATH" = "X"; then
1868                  RPATH="-Wl,-R${KRB_LIB_DIR}"
1869                else
1870                  RPATH="${RPATH}:${KRB_LIB_DIR}"
1871                fi
1872              else
1873                RPATH="${RPATH} -R${KRB_LIB_DIR}"
1874              fi
1875              ;;
1876          esac
1877          AC_SUBST(RPATH)
1878        fi
1879        ])
1880
1881
1882dnl checking for kerberos 4 libraries (and DES)
1883
1884AC_DEFUN(SASL_DES_CHK, [
1885AC_ARG_WITH(des, [  --with-des=DIR          with DES (look in DIR) [yes] ],
1886        with_des=$withval,
1887        with_des=yes)
1888
1889LIB_DES=""
1890if test "$with_des" != no; then
1891  if test -d $with_des; then
1892    CPPFLAGS="$CPPFLAGS -I${with_des}/include"
1893    LDFLAGS="$LDFLAGS -L${with_des}/lib"
1894  fi
1895
1896  dnl check for openssl installing -lcrypto, then make vanilla check
1897  AC_CHECK_LIB(crypto, des_cbc_encrypt, [
1898      AC_CHECK_HEADER(openssl/des.h, [AC_DEFINE(WITH_SSL_DES)
1899                                     LIB_DES="-lcrypto";
1900                                     with_des=yes],
1901                     with_des=no)],
1902      with_des=no, $LIB_RSAREF)
1903
1904  dnl same test again, different symbol name
1905  if test "$with_des" = no; then
1906    AC_CHECK_LIB(crypto, DES_cbc_encrypt, [
1907      AC_CHECK_HEADER(openssl/des.h, [AC_DEFINE(WITH_SSL_DES)
1908                                     LIB_DES="-lcrypto";
1909                                     with_des=yes],
1910                     with_des=no)],
1911      with_des=no, $LIB_RSAREF)
1912  fi
1913
1914  if test "$with_des" = no; then
1915    AC_CHECK_LIB(des, des_cbc_encrypt, [LIB_DES="-ldes";
1916                                        with_des=yes], with_des=no)
1917  fi
1918
1919  if test "$with_des" = no; then
1920     AC_CHECK_LIB(des425, des_cbc_encrypt, [LIB_DES="-ldes425";
1921                                       with_des=yes], with_des=no)
1922  fi
1923
1924  if test "$with_des" = no; then
1925     AC_CHECK_LIB(des524, des_cbc_encrypt, [LIB_DES="-ldes524";
1926                                       with_des=yes], with_des=no)
1927  fi
1928
1929  if test "$with_des" = no; then
1930    dnl if openssl is around, we might be able to use that for des
1931
1932    dnl if openssl has been compiled with the rsaref2 libraries,
1933    dnl we need to include the rsaref libraries in the crypto check
1934    LIB_RSAREF=""
1935    AC_CHECK_LIB(rsaref, RSAPublicEncrypt,
1936                 LIB_RSAREF="-lRSAglue -lrsaref"; cmu_have_rsaref=yes,
1937                 cmu_have_rsaref=no)
1938
1939    AC_CHECK_LIB(crypto, des_cbc_encrypt, [
1940        AC_CHECK_HEADER(openssl/des.h, [AC_DEFINE(WITH_SSL_DES)
1941                                        LIB_DES="-lcrypto";
1942                                        with_des=yes],
1943                        with_des=no)],
1944        with_des=no, $LIB_RSAREF)
1945  fi
1946fi
1947
1948if test "$with_des" != no; then
1949  AC_DEFINE(WITH_DES)
1950fi
1951
1952AC_SUBST(LIB_DES)
1953])
1954
1955AC_DEFUN(SASL_KERBEROS_V4_CHK, [
1956  AC_REQUIRE([SASL_DES_CHK])
1957
1958  AC_ARG_ENABLE(krb4, [  --enable-krb4           enable KERBEROS_V4 authentication [yes] ],
1959    krb4=$enableval,
1960    krb4=yes)
1961
1962  if test "$krb4" != no; then
1963    dnl In order to compile kerberos4, we need libkrb and libdes.
1964    dnl (We've already gotten libdes from SASL_DES_CHK)
1965    dnl we might need -lresolv for kerberos
1966    AC_CHECK_LIB(resolv,res_search)
1967
1968    dnl if we were ambitious, we would look more aggressively for the
1969    dnl krb4 install
1970    if test -d ${krb4}; then
1971       AC_CACHE_CHECK(for Kerberos includes, cyrus_krbinclude, [
1972         for krbhloc in include/kerberosIV include/kerberos include
1973         do
1974           if test -f ${krb4}/${krbhloc}/krb.h ; then
1975             cyrus_krbinclude=${krb4}/${krbhloc}
1976             break
1977           fi
1978         done
1979         ])
1980
1981       if test -n "${cyrus_krbinclude}"; then
1982         CPPFLAGS="$CPPFLAGS -I${cyrus_krbinclude}"
1983       fi
1984       LDFLAGS="$LDFLAGS -L$krb4/lib"
1985    fi
1986
1987    if test "$with_des" != no; then
1988      AC_CHECK_HEADER(krb.h, [
1989        AC_CHECK_LIB(com_err, com_err, [
1990          AC_CHECK_LIB(krb, krb_mk_priv,
1991                     [COM_ERR="-lcom_err"; SASL_KRB_LIB="-lkrb"; krb4lib="yes"],
1992                     krb4lib=no, $LIB_DES -lcom_err)], [
1993          AC_CHECK_LIB(krb, krb_mk_priv,
1994                     [COM_ERR=""; SASL_KRB_LIB="-lkrb"; krb4lib="yes"],
1995                     krb4lib=no, $LIB_DES)])], krb4="no")
1996
1997    if test "$krb4" = "yes" -a "$krb4lib" = "no"; then
1998        AC_CHECK_LIB(krb4, krb_mk_priv,
1999                     [COM_ERR=""; SASL_KRB_LIB="-lkrb4"; krb4=yes],
2000                     krb4=no, $LIB_DES)
2001        if test "$krb4" = no; then
2002          AC_WARN(No Kerberos V4 found)
2003        fi
2004      fi
2005    else
2006      AC_WARN(No DES library found for Kerberos V4 support)
2007      krb4=no
2008    fi
2009  fi
2010
2011  if test "$krb4" != no; then
2012    cmu_save_LIBS="$LIBS"
2013    LIBS="$LIBS $SASL_KRB_LIB"
2014    AC_CHECK_FUNCS(krb_get_err_text)
2015    LIBS="$cmu_save_LIBS"
2016  fi
2017
2018  AC_MSG_CHECKING(KERBEROS_V4)
2019  if test "$krb4" != no; then
2020    AC_MSG_RESULT(enabled)
2021    SASL_MECHS="$SASL_MECHS libkerberos4.la"
2022    SASL_STATIC_OBJS="$SASL_STATIC_OBJS ../plugins/kerberos4.o"
2023    AC_DEFINE(STATIC_KERBEROS4)
2024    AC_DEFINE(HAVE_KRB)
2025    SASL_KRB_LIB="$SASL_KRB_LIB $LIB_DES $COM_ERR"
2026  else
2027    AC_MSG_RESULT(disabled)
2028  fi
2029  AC_SUBST(SASL_KRB_LIB)
2030])
2031
2032
2033dnl
2034dnl macros for configure.in to detect openssl
2035dnl $Id: aclocal.m4,v 1.1.1.2 2003-02-12 22:34:28 ghudson Exp $
2036dnl
2037
2038AC_DEFUN(CMU_HAVE_OPENSSL, [
2039AC_ARG_WITH(with-openssl,[  --with-openssl=PATH     use OpenSSL from PATH],
2040        with_openssl="${withval}", with_openssl="yes")
2041
2042case "$with_openssl" in
2043        no) with_openssl="no";;
2044        ""|yes)
2045          dnl if openssl has been compiled with the rsaref2 libraries,
2046          dnl we need to include the rsaref libraries in the crypto check
2047                LIB_RSAREF=""
2048                AC_CHECK_LIB(rsaref, RSAPublicEncrypt,
2049                       LIB_RSAREF="-lRSAglue -lrsaref"; cmu_have_rsaref=yes,
2050                       cmu_have_rsaref=no)
2051
2052                AC_CHECK_HEADER(openssl/evp.h, [
2053                        AC_CHECK_LIB(crypto, EVP_DigestInit,
2054                                        with_openssl="yes",
2055                                        with_openssl="no", $LIB_RSAREF)],
2056                        with_openssl=no)
2057                ;;
2058        *)
2059                if test -d $with_openssl; then
2060                  CPPFLAGS="${CPPFLAGS} -I${with_openssl}/include"
2061                  LDFLAGS="${LDFLAGS} -L${with_openssl}/lib"
2062                else
2063                  with_openssl="no"
2064                fi
2065                ;;
2066esac
2067        if test "$with_openssl" != "no"; then
2068                AC_DEFINE(HAVE_OPENSSL)
2069        fi
2070])
2071dnl sasl2.m4--sasl2 libraries and includes
2072dnl Rob Siemborski
2073dnl $Id: aclocal.m4,v 1.1.1.2 2003-02-12 22:34:28 ghudson Exp $
2074
2075AC_DEFUN(SASL_GSSAPI_CHK,[
2076 AC_ARG_ENABLE(gssapi, [  --enable-gssapi=<DIR>   enable GSSAPI authentication [yes] ],
2077    gssapi=$enableval,
2078    gssapi=yes)
2079
2080 if test "$gssapi" != no; then
2081    if test -d ${gssapi}; then
2082       CPPFLAGS="$CPPFLAGS -I$gssapi/include"
2083       LDFLAGS="$LDFLAGS -L$gssapi/lib"
2084    fi
2085    AC_CHECK_HEADER(gssapi.h, AC_DEFINE(HAVE_GSSAPI_H,,[Define if you have the gssapi.h header file]), [
2086      AC_CHECK_HEADER(gssapi/gssapi.h,, AC_WARN(Disabling GSSAPI); gssapi=no)])
2087 fi
2088
2089 if test "$gssapi" != no; then
2090  dnl We need to find out which gssapi implementation we are
2091  dnl using. Supported alternatives are: MIT Kerberos 5 and
2092  dnl Heimdal Kerberos 5 (http://www.pdc.kth.se/heimdal)
2093  dnl
2094  dnl The choice is reflected in GSSAPIBASE_LIBS
2095  dnl we might need libdb
2096  AC_CHECK_LIB(db, db_open)
2097
2098  gss_impl="mit";
2099  AC_CHECK_LIB(resolv,res_search)
2100  if test -d ${gssapi}; then
2101     CPPFLAGS="$CPPFLAGS -I$gssapi/include"
2102     LDFLAGS="$LDFLAGS -L$gssapi/lib"
2103  fi
2104
2105  if test -d ${gssapi}; then
2106     gssapi_dir="${gssapi}/lib"
2107     GSSAPIBASE_LIBS="-L$gssapi_dir"
2108     GSSAPIBASE_STATIC_LIBS="-L$gssapi_dir"
2109  else
2110     dnl FIXME: This is only used for building cyrus, and then only as
2111     dnl a real hack.  it needs to be fixed.
2112     gssapi_dir="/usr/local/lib"
2113  fi
2114
2115  # Check a full link against the heimdal libraries.  If this fails, assume
2116  # MIT.
2117  AC_CHECK_LIB(gssapi,gss_unwrap,gss_impl="heimdal",,$GSSAPIBASE_LIBS -lgssapi -lkrb5 -lasn1 -lroken ${LIB_CRYPT} -lcom_err)
2118
2119  if test "$gss_impl" = "mit"; then
2120     GSSAPIBASE_LIBS="$GSSAPIBASE_LIBS -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err"
2121     GSSAPIBASE_STATIC_LIBS="$GSSAPIBASE_LIBS $gssapi_dir/libgssapi_krb5.a $gssapi_dir/libkrb5.a $gssapi_dir/libk5crypto.a $gssapi_dir/libcom_err.a"
2122  elif test "$gss_impl" = "heimdal"; then
2123     GSSAPIBASE_LIBS="$GSSAPIBASE_LIBS -lgssapi -lkrb5 -lasn1 -lroken ${LIB_CRYPT} -lcom_err"
2124     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}"
2125  else
2126     gssapi="no"
2127     AC_WARN(Disabling GSSAPI)
2128  fi
2129 fi
2130
2131 if test "$ac_cv_header_gssapi_h" = "yes"; then
2132  AC_EGREP_HEADER(GSS_C_NT_HOSTBASED_SERVICE, gssapi.h,
2133    AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE,,[Define if your GSSAPI implimentation defines GSS_C_NT_HOSTBASED_SERVICE]))
2134 elif test "$ac_cv_header_gssapi_gssapi_h"; then
2135  AC_EGREP_HEADER(GSS_C_NT_HOSTBASED_SERVICE, gssapi/gssapi.h,
2136    AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE,,[Define if your GSSAPI implimentation defines GSS_C_NT_HOSTBASED_SERVICE]))
2137 fi
2138
2139 GSSAPI_LIBS=""
2140 AC_MSG_CHECKING(GSSAPI)
2141 if test "$gssapi" != no; then
2142  AC_MSG_RESULT(with implementation ${gss_impl})
2143  AC_CHECK_LIB(resolv,res_search,GSSAPIBASE_LIBS="$GSSAPIBASE_LIBS -lresolv")
2144  SASL_MECHS="$SASL_MECHS libgssapiv2.la"
2145  SASL_STATIC_OBJS="$SASL_STATIC_OBJS ../plugins/gssapi.o"
2146
2147  cmu_save_LIBS="$LIBS"
2148  LIBS="$LIBS $GSSAPIBASE_LIBS"
2149  AC_CHECK_FUNCS(gsskrb5_register_acceptor_identity)
2150  LIBS="$cmu_save_LIBS"
2151else
2152  AC_MSG_RESULT(disabled)
2153fi
2154AC_SUBST(GSSAPI_LIBS)
2155AC_SUBST(GSSAPIBASE_LIBS)
2156])
2157
2158dnl What we want to do here is setup LIB_SASL with what one would
2159dnl generally want to have (e.g. if static is requested, make it that,
2160dnl otherwise make it dynamic.
2161
2162dnl We also want to creat LIB_DYN_SASL and DYNSASLFLAGS.
2163
2164dnl Also sets using_static_sasl to "no" "static" or "staticonly"
2165
2166AC_DEFUN(CMU_SASL2, [
2167AC_ARG_WITH(sasl,
2168            [  --with-sasl=DIR         Compile with libsasl2 in <DIR>],
2169            with_sasl="$withval",
2170            with_sasl="yes")
2171
2172AC_ARG_WITH(staticsasl,
2173            [  --with-staticsasl=DIR   Compile with staticly linked libsasl2 in <DIR>],
2174            with_staticsasl="$withval";
2175            if test $with_staticsasl != "no"; then
2176                using_static_sasl="static"
2177            fi,
2178            with_staticsasl="no"; using_static_sasl="no")
2179
2180        SASLFLAGS=""
2181        LIB_SASL=""
2182
2183        cmu_saved_CPPFLAGS=$CPPFLAGS
2184        cmu_saved_LDFLAGS=$LDFLAGS
2185        cmu_saved_LIBS=$LIBS
2186
2187        if test ${with_staticsasl} != "no"; then
2188          if test -d ${with_staticsasl}; then
2189            ac_cv_sasl_where_lib=${with_staticsasl}/lib
2190            ac_cv_sasl_where_inc=${with_staticsasl}/include
2191
2192            SASLFLAGS="-I$ac_cv_sasl_where_inc"
2193            LIB_SASL="-L$ac_cv_sasl_where_lib"
2194            CPPFLAGS="${cmu_saved_CPPFLAGS} -I${ac_cv_sasl_where_inc}"
2195            LDFLAGS="${cmu_saved_LDFLAGS} -L${ac_cv_sasl_where_lib}"
2196          else
2197            with_staticsasl="/usr"
2198          fi
2199
2200          AC_CHECK_HEADER(sasl/sasl.h, [
2201            AC_CHECK_HEADER(sasl/saslutil.h, [
2202             if test -r ${with_staticsasl}/lib/libsasl2.a; then
2203                ac_cv_found_sasl=yes
2204                AC_MSG_CHECKING(for static libsasl)
2205                LIB_SASL="$LIB_SASL ${with_staticsasl}/lib/libsasl2.a"
2206             else
2207                AC_MSG_CHECKING(for static libsasl)
2208                AC_ERROR([Could not find ${with_staticsasl}/lib/libsasl2.a])
2209             fi
2210            ])])
2211
2212          AC_MSG_RESULT(found)
2213
2214          SASL_GSSAPI_CHK
2215
2216          LIB_SASL="$LIB_SASL $GSSAPIBASE_STATIC_LIBS"
2217        fi
2218
2219        if test -d ${with_sasl}; then
2220            ac_cv_sasl_where_lib=${with_sasl}/lib
2221            ac_cv_sasl_where_inc=${with_sasl}/include
2222
2223            DYNSASLFLAGS="-I$ac_cv_sasl_where_inc"
2224            if test "$ac_cv_sasl_where_lib" != ""; then
2225                CMU_ADD_LIBPATH_TO($ac_cv_sasl_where_lib, LIB_DYN_SASL)
2226            fi
2227            LIB_DYN_SASL="$LIB_DYN_SASL -lsasl2"
2228            CPPFLAGS="${cmu_saved_CPPFLAGS} -I${ac_cv_sasl_where_inc}"
2229            LDFLAGS="${cmu_saved_LDFLAGS} -L${ac_cv_sasl_where_lib}"
2230        fi
2231
2232        dnl be sure to check for a SASLv2 specific function
2233        AC_CHECK_HEADER(sasl/sasl.h, [
2234            AC_CHECK_HEADER(sasl/saslutil.h, [
2235              AC_CHECK_LIB(sasl2, prop_get,
2236                           ac_cv_found_sasl=yes,
2237                           ac_cv_found_sasl=no)],
2238                           ac_cv_found_sasl=no)], ac_cv_found_sasl=no)
2239
2240        if test "$ac_cv_found_sasl" = "yes"; then
2241            if test "$ac_cv_sasl_where_lib" != ""; then
2242                CMU_ADD_LIBPATH_TO($ac_cv_sasl_where_lib, DYNLIB_SASL)
2243            fi
2244            DYNLIB_SASL="$DYNLIB_SASL -lsasl2"
2245            if test "$using_static_sasl" != "static"; then
2246                LIB_SASL=$DYNLIB_SASL
2247                SASLFLAGS=$DYNSASLFLAGS
2248            fi
2249        else
2250            DYNLIB_SASL=""
2251            DYNSASLFLAGS=""
2252            using_static_sasl="staticonly"
2253        fi
2254
2255        LIBS="$cmu_saved_LIBS"
2256        LDFLAGS="$cmu_saved_LDFLAGS"
2257        CPPFLAGS="$cmu_saved_CPPFLAGS"
2258
2259        AC_SUBST(LIB_DYN_SASL)
2260        AC_SUBST(DYNSASLFLAGS)
2261        AC_SUBST(LIB_SASL)
2262        AC_SUBST(SASLFLAGS)
2263        ])
2264
2265AC_DEFUN(CMU_SASL2_REQUIRED,
2266[AC_REQUIRE([CMU_SASL2])
2267if test "$ac_cv_found_sasl" != "yes"; then
2268        AC_ERROR([Cannot continue without libsasl2.
2269Get it from ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/.])
2270fi])
2271
2272AC_DEFUN(CMU_SASL2_CHECKAPOP_REQUIRED, [
2273        AC_REQUIRE([CMU_SASL2_REQUIRED])
2274
2275        cmu_saved_LDFLAGS=$LDFLAGS
2276
2277        LDFLAGS="$LDFLAGS $LIB_SASL"
2278
2279        AC_CHECK_LIB(sasl2, sasl_checkapop, AC_DEFINE(HAVE_APOP),
2280                AC_MSG_ERROR([libsasl2 without working sasl_checkapop.  Cannot continue.]))
2281
2282        LDFLAGS=$cmu_saved_LDFLAGS
2283])
2284
2285dnl Check for PLAIN (and therefore crypt)
2286
2287AC_DEFUN(SASL_CRYPT_CHK,[
2288 AC_CHECK_FUNC(crypt, cmu_have_crypt=yes, [
2289  AC_CHECK_LIB(crypt, crypt,
2290               LIB_CRYPT="-lcrypt"; cmu_have_crypt=yes,
2291               cmu_have_crypt=no)])
2292 AC_SUBST(LIB_CRYPT)
2293])
2294
2295AC_DEFUN(SASL_PLAIN_CHK,[
2296AC_REQUIRE([SASL_CRYPT_CHK])
2297
2298dnl PLAIN
2299 AC_ARG_ENABLE(plain, [  --enable-plain          enable PLAIN authentication [yes] ],
2300  plain=$enableval,
2301  plain=yes)
2302
2303 PLAIN_LIBS=""
2304 if test "$plain" != no; then
2305  dnl In order to compile plain, we need crypt.
2306  if test "$cmu_have_crypt" = yes; then
2307    PLAIN_LIBS=$LIB_CRYPT
2308  fi
2309 fi
2310 AC_SUBST(PLAIN_LIBS)
2311
2312 AC_MSG_CHECKING(PLAIN)
2313 if test "$plain" != no; then
2314  AC_MSG_RESULT(enabled)
2315  SASL_MECHS="$SASL_MECHS libplain.la"
2316  if test "$enable_static" = yes; then
2317    SASL_STATIC_OBJS="$SASL_STATIC_OBJS ../plugins/plain.o"
2318    AC_DEFINE(STATIC_PLAIN)
2319  fi
2320 else
2321  AC_MSG_RESULT(disabled)
2322 fi
2323])
2324
2325dnl See whether we can use IPv6 related functions
2326dnl contributed by Hajimu UMEMOTO
2327
2328AC_DEFUN(IPv6_CHECK_FUNC, [
2329AC_CHECK_FUNC($1, [dnl
2330  ac_cv_lib_socket_$1=no
2331  ac_cv_lib_inet6_$1=no
2332], [dnl
2333  AC_CHECK_LIB(socket, $1, [dnl
2334    LIBS="$LIBS -lsocket"
2335    ac_cv_lib_inet6_$1=no
2336  ], [dnl
2337    AC_MSG_CHECKING([whether your system has IPv6 directory])
2338    AC_CACHE_VAL(ipv6_cv_dir, [dnl
2339      for ipv6_cv_dir in /usr/local/v6 /usr/inet6 no; do
2340        if test $ipv6_cv_dir = no -o -d $ipv6_cv_dir; then
2341          break
2342        fi
2343      done])dnl
2344    AC_MSG_RESULT($ipv6_cv_dir)
2345    if test $ipv6_cv_dir = no; then
2346      ac_cv_lib_inet6_$1=no
2347    else
2348      if test x$ipv6_libinet6 = x; then
2349        ipv6_libinet6=no
2350        SAVELDFLAGS="$LDFLAGS"
2351        LDFLAGS="$LDFLAGS -L$ipv6_cv_dir/lib"
2352      fi
2353      AC_CHECK_LIB(inet6, $1, [dnl
2354        if test $ipv6_libinet6 = no; then
2355          ipv6_libinet6=yes
2356          LIBS="$LIBS -linet6"
2357        fi],)dnl
2358      if test $ipv6_libinet6 = no; then
2359        LDFLAGS="$SAVELDFLAGS"
2360      fi
2361    fi])dnl
2362])dnl
2363if test $ac_cv_func_$1 = yes -o $ac_cv_lib_socket_$1 = yes \
2364     -o $ac_cv_lib_inet6_$1 = yes
2365then
2366  ipv6_cv_$1=yes
2367  ifelse([$2], , :, [$2])
2368else
2369  ipv6_cv_$1=no
2370  ifelse([$3], , :, [$3])
2371fi])
2372
2373
2374dnl See whether we have ss_family in sockaddr_storage
2375AC_DEFUN(IPv6_CHECK_SS_FAMILY, [
2376AC_MSG_CHECKING([whether you have ss_family in struct sockaddr_storage])
2377AC_CACHE_VAL(ipv6_cv_ss_family, [dnl
2378AC_TRY_COMPILE([#include <sys/types.h>
2379#include <sys/socket.h>],
2380        [struct sockaddr_storage ss; int i = ss.ss_family;],
2381        [ipv6_cv_ss_family=yes], [ipv6_cv_ss_family=no])])dnl
2382if test $ipv6_cv_ss_family = yes; then
2383  ifelse([$1], , AC_DEFINE(HAVE_SS_FAMILY), [$1])
2384else
2385  ifelse([$2], , :, [$2])
2386fi
2387AC_MSG_RESULT($ipv6_cv_ss_family)])
2388
2389
2390dnl whether you have sa_len in struct sockaddr
2391AC_DEFUN(IPv6_CHECK_SA_LEN, [
2392AC_MSG_CHECKING([whether you have sa_len in struct sockaddr])
2393AC_CACHE_VAL(ipv6_cv_sa_len, [dnl
2394AC_TRY_COMPILE([#include <sys/types.h>
2395#include <sys/socket.h>],
2396               [struct sockaddr sa; int i = sa.sa_len;],
2397               [ipv6_cv_sa_len=yes], [ipv6_cv_sa_len=no])])dnl
2398if test $ipv6_cv_sa_len = yes; then
2399  ifelse([$1], , AC_DEFINE(HAVE_SOCKADDR_SA_LEN), [$1])
2400else
2401  ifelse([$2], , :, [$2])
2402fi
2403AC_MSG_RESULT($ipv6_cv_sa_len)])
2404
2405
2406dnl See whether sys/socket.h has socklen_t
2407AC_DEFUN(IPv6_CHECK_SOCKLEN_T, [
2408AC_MSG_CHECKING(for socklen_t)
2409AC_CACHE_VAL(ipv6_cv_socklen_t, [dnl
2410AC_TRY_LINK([#include <sys/types.h>
2411#include <sys/socket.h>],
2412            [socklen_t len = 0;],
2413            [ipv6_cv_socklen_t=yes], [ipv6_cv_socklen_t=no])])dnl
2414if test $ipv6_cv_socklen_t = yes; then
2415  ifelse([$1], , AC_DEFINE(HAVE_SOCKLEN_T), [$1])
2416else
2417  ifelse([$2], , :, [$2])
2418fi
2419AC_MSG_RESULT($ipv6_cv_socklen_t)])
2420
2421
Note: See TracBrowser for help on using the repository browser.