Rework the Kerberos Autoconf probes
authorRuss Allbery <rra@stanford.edu>
Wed, 26 May 2010 03:19:14 +0000 (22:19 -0500)
committerDerrick Brashear <shadow@dementia.org>
Tue, 15 Jun 2010 23:30:04 +0000 (16:30 -0700)
Previously, building with Kerberos support required either passing a
flag to configure giving the location of a krb5-config script, or
manually setting variables specifying the Kerberos libraries and
header path.  Replace that code with code that checks for Kerberos
libraries automatically and builds the Kerberos code if any were
found, with support for doing direct library probing if there is no
krb5-config script.

Add several platform-specific overrides directly into the configure
support, so we should be able to build out of the box on Mac OS X 10.3,
HP-UX, and AIX Kerberos with the new probes.

The Kerberos Autoconf macros are now the versions that come with
rra-c-util and are tested with multiple other packages, so both
OpenAFS and those packages will be able to benefit from further
portability improvements.

Update README for the new building instructions, documenting how to
configure the Kerberos probes if they can't automatically figure out
the location and flags for Kerberos on your system.

Change-Id: Ia35bb0dbc6b94c6b4dfe8165388447dbfcb31a29
Reviewed-on: http://gerrit.openafs.org/2026
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

12 files changed:
README
acinclude.m4
configure.in
doc/LICENSE
src/LICENSE
src/aklog/Makefile.in
src/cf/kerberos.m4 [deleted file]
src/cf/krb5.m4 [new file with mode: 0644]
src/cf/lib-depends.m4 [new file with mode: 0644]
src/cf/lib-pathname.m4 [new file with mode: 0644]
src/cf/osconf.m4
src/tsm41/Makefile.in

diff --git a/README b/README
index 19fd2f2..f978a7e 100644 (file)
--- a/README
+++ b/README
@@ -213,11 +213,6 @@ F  OpenBSD Notes
    --with-bsd-kernel-headers= configure option if your kernel source is
    not in /usr/src/sys.
 
-   If you want to build src/aklog, add the following options to your
-   configure.  Note that you shouldn't need aklog because heimdal afslog
-   does (almost) the same thing.
-     --with-krb5 KRB5CFLAGS=-I/usr/include/kerberosV KRB5LIBS=-lcrypto
-
    src/packaging/OpenBSD/buildpkg.sh will make a tar file for installing
    the client.  There is no server package, but I am told that "make
    install" will put server binaries in /usr/afs.
@@ -233,7 +228,6 @@ G  FreeBSD Notes
    The FreeBSD client may now work; It is tested on 7.0 and on current
    as of the commit date.
 
-
    You need kernel source installed to build OpenAFS.  Use the
    --with-bsd-kernel-headers= configure option if your kernel source is
    not in /usr/src/sys.
@@ -258,14 +252,10 @@ H  AIX notes
    Verify this before doing configure and make. For example, assuming ksh/bash:
    export OBJECT_MODE=32
 
-   To build aklog (in order to be able to get tokens from your KRB5 ticket)
-   you have to supply --with-krb5 to configure, the following example is for
-   building on AIX 6.1 with the IBM Kerberos5 (krb5.client.rte and
-   krb5.toolkit.adt on the Expansion Pack):
-
-   ./configure --with-afs-sysname=rs_aix61 --enable-transarc-paths \
-       --enable-supergroups \
-       --with-krb5 KRB5CFLAGS=-I/usr/include KRB5LIBS=-lkrb5
+   To build aklog (in order to be able to get tokens from your Kerberos v5
+   ticket), you will need Kerberos libraries.  On AIX 6.1, the IBM
+   Kerberos v5 libraries are in the packages krb5.client.rte and
+   krb5.toolkit.adt on the Expansion Pack.
 
 I  Other configure options
 
@@ -322,6 +312,19 @@ I  Other configure options
        versions of Ubik servers.  See README.PTHREADED_UBIK for more
        information.  (EXPERIMENTAL)
 
+   --enable-reduced-depends
+       Try to minimize the shared library dependencies encoded in the
+       binaries.  This omits from the link line all the libraries included
+       solely because the Kerberos libraries depend on them and instead
+       links the programs only against libraries whose APIs are called
+       directly.  This will only work with shared Kerberos libraries and
+       will only work on platforms where shared libraries properly encode
+       their own dependencies (such as Linux).  It is intended primarily
+       for building packages for Linux distributions to avoid encoding
+       unnecessary shared library dependencies that make shared library
+       migrations more difficult.  If none of the above made any sense to
+       you, don't bother with this flag.
+
    --enable-supergroups
        Enables support of nested groups in the ptserver.  WARNING: Once
        you make use of this option by nesting one group inside another,
@@ -355,3 +358,40 @@ I  Other configure options
        harmless, but the PAM modules that come with OpenAFS are deprecated
        and should not be used unless you're still using the OpenAFS
        kaserver (which is itself deprecated and should not be used).
+
+   You may need to pass one or more of the following options to specify
+   the paths and locations of files needed by the OpenAFS build process:
+
+   --with-krb5[=DIR]
+   --with-krb5-include=DIR
+   --with-krb5-lib=DIR
+       Normally, OpenAFS will automatically build with Kerberos support if
+       Kerberos is found during the build.  If your Kerberos libraries are
+       in an unusual location, however, you may need to pass one or more
+       of these flags.  --with-krb5 forces building with Kerberos support
+       if given and will cause configure to fail if Kerberos is not found.
+       You may optionally specify the root path to your Kerberos
+       installation as an argument to --with-krb5.
+
+       If you have a krb5-config script, it's used to find the flags to
+       build with Kerberos.  If you have no krb5-config script, you can
+       specify the location to the include files with --with-krb5-include
+       and the libraries with --with-krb5-lib.  You may need to do this if
+       Autoconf can't figure out whether to use lib, lib32, or lib64 on
+       your platform.
+
+   There are also some environment variables that you can set to control
+   aspects of the build.  They can be set either on the configure command
+   line (preferred) or in the environment.
+
+   KRB5_CONFIG
+       To specify a particular krb5-config script to use, either set the
+       KRB5_CONFIG environment variable or pass it to configure like:
+
+           ./configure KRB5_CONFIG=/path/to/krb5-config
+
+       To not use krb5-config and force library probing even if there is a
+       krb5-config script on your path, set KRB5_CONFIG to a nonexistent
+       path:
+
+           ./configure KRB5_CONFIG=/nonexistent
index fca4196..72c3124 100644 (file)
@@ -1406,7 +1406,6 @@ AC_SUBST(HTML_XSL)
 AC_SUBST(XSLTPROC)
 
 OPENAFS_OSCONF
-OPENAFS_KRB5CONF
 OPENAFS_FUSE
 
 TOP_SRCDIR="${srcdir}/src"
index 60ee219..e48e5e6 100644 (file)
@@ -26,6 +26,54 @@ AC_PATH_PROGS([PATH_CPP], [cpp], [${CC-cc} -E], [$PATH:/lib:/usr/ccs/lib])
 AC_SUBST([PATH_CPP])
 OPENAFS_CONFIGURE_COMMON
 
+dnl Probe for Kerberos.  We have a few platform-specific overrides due to
+dnl weird Kerberos implementations and installation locations.
+AS_CASE([$AFS_SYSNAME],
+    [*_obsd*],
+    [KRB5_CPPFLAGS="-I/usr/include/kerberosV"],
+
+    [ppc_darwin_70],
+    [KRB5_CPPFLAGS="-I/usr/include"
+     KRB5_LDFLAGS="-L/usr/lib -Wl,-search_paths_first"])
+RRA_LIB_KRB5_OPTIONAL
+AS_CASE([$AFS_SYSNAME],
+    [hp_ux*|*_hpux*],
+    [KRB5_LIBS="-l:libkrb5.sl -l:libcom_err.sl"])
+
+dnl Check for the characteristics of whatever Kerberos we found, if we found
+dnl one.
+BUILD_KRB5=no
+MAKE_KRB5="#"
+AS_IF([test x"$KRB5_LIBS" != x],
+    [BUILD_KRB5=yes
+     MAKE_KRB5=
+     RRA_LIB_KRB5_SWITCH
+     AC_CHECK_FUNCS([add_error_table \
+        add_to_error_table \
+        encode_krb5_enc_tkt_part \
+        encode_krb5_ticket \
+        krb5_allow_weak_crypto \
+        krb5_c_encrypt \
+        krb5_decode_ticket \
+        krb5_enctype_enable \
+        krb5_get_prompt_types \
+        krb5_princ_size \
+        krb5_principal_get_comp_string])
+     AC_CHECK_FUNCS([krb5_524_convert_creds], ,
+         [AC_CHECK_FUNCS([krb524_convert_creds_kdc], ,
+             [AC_CHECK_LIB([krb524], [krb524_convert_creds_kdc],
+                 [LIBS="-lkrb524 $LIBS"
+                  KRB5_LIBS="-lkrb524 $KRB5_LIBS"
+                  AC_DEFINE([HAVE_KRB524_CONVERT_CREDS_KDC], 1,
+                     [Define to 1 if you have the `krb524_convert_creds_kdc' function.])])])])
+     AC_CHECK_HEADERS([kerberosIV/krb.h])
+     AC_CHECK_HEADERS([kerberosV/heim_err.h])
+     AC_CHECK_MEMBERS([krb5_creds.keyblock, krb5_creds.session,
+                       krb5_prompt.type], , , [#include <krb5.h>])
+     RRA_LIB_KRB5_RESTORE])
+AC_SUBST([BUILD_KRB5])
+AC_SUBST([MAKE_KRB5])
+
 if test -d 'doc/man-pages' ; then
     MAN_MAKEFILE="doc/man-pages/Makefile doc/man-pages/install-man"
 else
index c913b27..9252889 100644 (file)
@@ -394,3 +394,24 @@ to the following license:
     SUCH DAMAGE.
 
 ====================================================
+
+The files src/cf/krb5.m4, src/cf/lib-depends.m4, and
+src/cf/lib-pathname.m4 are covered by the following license:
+
+  Copyright 2005, 2006, 2007, 2008, 2009, 2010
+    Board of Trustees, Leland Stanford Jr. University
+
+  Permission to use, copy, modify, and distribute this software and its
+  documentation for any purpose and without fee is hereby granted,
+  provided that the above copyright notice appear in all copies and that
+  both that copyright notice and this permission notice appear in
+  supporting documentation, and that the name of Stanford University not
+  be used in advertising or publicity pertaining to distribution of the
+  software without specific, written prior permission.  Stanford
+  University makes no representations about the suitability of this
+  software for any purpose.  It is provided "as is" without express or
+  implied warranty.
+
+  THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
+  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
index c913b27..9252889 100644 (file)
@@ -394,3 +394,24 @@ to the following license:
     SUCH DAMAGE.
 
 ====================================================
+
+The files src/cf/krb5.m4, src/cf/lib-depends.m4, and
+src/cf/lib-pathname.m4 are covered by the following license:
+
+  Copyright 2005, 2006, 2007, 2008, 2009, 2010
+    Board of Trustees, Leland Stanford Jr. University
+
+  Permission to use, copy, modify, and distribute this software and its
+  documentation for any purpose and without fee is hereby granted,
+  provided that the above copyright notice appear in all copies and that
+  both that copyright notice and this permission notice appear in
+  supporting documentation, and that the name of Stanford University not
+  be used in advertising or publicity pertaining to distribution of the
+  software without specific, written prior permission.  Stanford
+  University makes no representations about the suitability of this
+  software for any purpose.  It is provided "as is" without express or
+  implied warranty.
+
+  THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
+  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
index d9c0558..b016b63 100644 (file)
@@ -9,8 +9,8 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 
-OPTMZ = @KRB5CFLAGS@ -DALLOW_REGISTER
-AKLIBS = ${LIBS} @KRB5LIBS@
+OPTMZ = @KRB5_CPPFLAGS@ -DALLOW_REGISTER
+AKLIBS = ${LIBS} @KRB5_LDFLAGS@ @KRB5_LIBS@
 AFSLIBS = ${TOP_LIBDIR}/libprot.a ${TOP_LIBDIR}/libauth.a \
          ${TOP_LIBDIR}/libubik.a ${TOP_LIBDIR}/librxkad.a \
          ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/librx.a \
diff --git a/src/cf/kerberos.m4 b/src/cf/kerberos.m4
deleted file mode 100644 (file)
index 2cb31b9..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-dnl
-dnl $Id$
-dnl
-dnl Kerberos autoconf glue
-dnl
-
-AC_DEFUN([OPENAFS_KRB5CONF],[
-
-dnl AC_ARG_VAR(KRB5CFLAGS, [C flags to compile Kerberos 5 programs])
-dnl AC_ARG_VAR(KRB5LIBS, [Libraries and flags to compile Kerberos 5 programs])
-dnl AC_ARG_VAR(KRB5_CONFIG, [Location of krb5-config script])
-
-AC_ARG_WITH([krb5-conf],
-    [AS_HELP_STRING([--with-krb5-conf=@<:@krb5-config-location@:>@],
-        [use a krb5-config script to configure Kerberos])])
-
-if test X$with_krb5_conf != X; then
-               conf_krb5=YES
-               if test X$with_krb5_conf = Xyes; then
-                       AC_PATH_PROG(KRB5_CONFIG, krb5-config, not_found)
-                       if test X$KRB5_CONFIG = Xnot_found; then
-                               AC_MSG_ERROR([cannot find krb5-config script, you must configure Kerberos manually])
-                       fi
-               else
-                       KRB5_CONFIG=$withval
-               fi
-               KRB5CFLAGS=`$KRB5_CONFIG --cflags krb5`
-               retval=$?
-               if test $retval -ne 0; then
-                       AC_MSG_ERROR([$KRB5_CONFIG failed with an error code of $retval])
-               fi
-               KRB5LIBS=`$KRB5_CONFIG --libs krb5`
-               retval=$?
-               if test $retval -ne 0; then
-                       AC_MSG_ERROR([$KRB5_CONFIG failed with an error code of $retval])
-               fi
-               AC_MSG_RESULT([Adding $KRB5CFLAGS to KRB5CFLAGS])
-               AC_MSG_RESULT([Adding $KRB5LIBS to KRB5LIBS])
-fi
-
-AC_ARG_WITH([krb5], 
-    [AS_HELP_STRING([--with-krb5],
-        [support for Kerberos 5 (manual configuration)])])
-
-if test X$with_krb5 != X; then
-        if test X$conf_krb5 = XYES; then
-               AC_MSG_ERROR([--with-krb5-config and --with-krb5 are mutually exclusive, choose only one])
-       fi
-       if test "X$KRB5CFLAGS" = X; then
-               AC_MSG_WARN([KRB5CFLAGS is not set])
-       fi
-       if test "X$KRB5LIBS" = X; then
-               AC_MSG_WARN([KRB5LIBS is not set])
-       fi
-       conf_krb5=YES
-fi
-
-BUILD_KRB5=no
-MAKE_KRB5=#
-if test X$conf_krb5 = XYES; then
-       AC_MSG_RESULT([Configuring support for Kerberos 5 utilities])
-       BUILD_KRB5=yes
-       MAKE_KRB5=
-       save_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $KRB5CFLAGS"
-       save_LIBS="$LIBS"
-       LIBS="$LIBS $KRB5LIBS"
-       AC_CHECK_FUNCS([add_to_error_table add_error_table krb5_princ_size krb5_principal_get_comp_string encode_krb5_enc_tkt_part encode_krb5_ticket krb5_c_encrypt krb5_decode_ticket krb5_get_prompt_types krb5_allow_weak_crypto krb5_enctype_enable krb5_svc_get_msg])
-       AC_CHECK_FUNCS([krb5_524_convert_creds], ,
-           [AC_CHECK_FUNCS([krb524_convert_creds_kdc], ,
-               [AC_CHECK_LIB([krb524], [krb524_convert_creds_kdc],
-                   [LIBS="-lkrb524 $LIBS"
-                    KRB5LIBS="-lkrb524 $LIBS"
-                    AC_DEFINE([HAVE_KRB524_CONVERT_CREDS_KDC], 1,
-                        [Define to 1 if you have the `krb524_convert_creds_kdc' function.])])])])
-       AC_CHECK_HEADERS([kerberosIV/krb.h])
-       AC_CHECK_HEADERS([kerberosV/heim_err.h])
-
-       AC_CHECK_MEMBERS([krb5_creds.keyblock,
-                         krb5_creds.session,
-                         krb5_prompt.type],
-                        [], [], [#include <krb5.h>])
-
-       CPPFLAGS="$save_CPPFLAGS"
-       LIBS="$save_LIBS"
-fi
-
-AC_SUBST(BUILD_KRB5)
-AC_SUBST(MAKE_KRB5)
-AC_SUBST(KRB5CFLAGS)
-AC_SUBST(KRB5LIBS)
-
-])dnl
diff --git a/src/cf/krb5.m4 b/src/cf/krb5.m4
new file mode 100644 (file)
index 0000000..d7c2798
--- /dev/null
@@ -0,0 +1,261 @@
+dnl Find the compiler and linker flags for Kerberos v5.
+dnl
+dnl Finds the compiler and linker flags for linking with Kerberos v5
+dnl libraries.  Provides the --with-krb5, --with-krb5-include, and
+dnl --with-krb5-lib configure options to specify non-standard paths to the
+dnl Kerberos libraries.  Uses krb5-config where available unless reduced
+dnl dependencies is requested.
+dnl
+dnl Provides the macro RRA_LIB_KRB5 and sets the substitution variables
+dnl KRB5_CPPFLAGS, KRB5_LDFLAGS, and KRB5_LIBS.  Also provides
+dnl RRA_LIB_KRB5_SWITCH to set CPPFLAGS, LDFLAGS, and LIBS to include the
+dnl Kerberos libraries, saving the current values first, and
+dnl RRA_LIB_KRB5_RESTORE to restore those settings to before the last
+dnl RRA_LIB_KRB5_SWITCH.
+dnl
+dnl If KRB5_CPPFLAGS, KRB5_LDFLAGS, or KRB5_LIBS are set before calling these
+dnl macros, their values will be added to whatever the macros discover.
+dnl
+dnl Provides the RRA_LIB_KRB5_OPTIONAL macro, which should be used if Kerberos
+dnl support is optional.  This macro will still always set the substitution
+dnl variables, but they'll be empty unless --with-krb5 is given.  Also,
+dnl HAVE_KERBEROS will be defined if --with-krb5 is given and
+dnl $rra_use_kerberos will be set to "true".
+dnl
+dnl Sets the Automake conditional KRB5_USES_COM_ERR saying whether we use
+dnl com_err, since if we're also linking with AFS libraries, we may have to
+dnl change library ordering in that case.
+dnl
+dnl Depends on RRA_ENABLE_REDUCED_DEPENDS and RRA_SET_LDFLAGS.
+dnl
+dnl Written by Russ Allbery <rra@stanford.edu>
+dnl Copyright 2005, 2006, 2007, 2008, 2009, 2010
+dnl     Board of Trustees, Leland Stanford Jr. University
+dnl
+dnl See LICENSE for licensing terms.
+
+dnl Save the current CPPFLAGS, LDFLAGS, and LIBS settings and switch to
+dnl versions that include the Kerberos v5 flags.  Used as a wrapper, with
+dnl RRA_LIB_KRB5_RESTORE, around tests.
+AC_DEFUN([RRA_LIB_KRB5_SWITCH],
+[rra_krb5_save_CPPFLAGS="$CPPFLAGS"
+ rra_krb5_save_LDFLAGS="$LDFLAGS"
+ rra_krb5_save_LIBS="$LIBS"
+ CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS"
+ LDFLAGS="$KRB5_LDFLAGS $LDFLAGS"
+ LIBS="$KRB5_LIBS $LIBS"])
+
+dnl Restore CPPFLAGS, LDFLAGS, and LIBS to their previous values (before
+dnl RRA_LIB_KRB5_SWITCH was called).
+AC_DEFUN([RRA_LIB_KRB5_RESTORE],
+[CPPFLAGS="$rra_krb5_save_CPPFLAGS"
+ LDFLAGS="$rra_krb5_save_LDFLAGS"
+ LIBS="$rra_krb5_save_LIBS"])
+
+dnl Set KRB5_CPPFLAGS and KRB5_LDFLAGS based on rra_krb5_root,
+dnl rra_krb5_libdir, and rra_krb5_includedir.
+AC_DEFUN([_RRA_LIB_KRB5_PATHS],
+[AS_IF([test x"$rra_krb5_libdir" != x],
+    [KRB5_LDFLAGS="-L$rra_krb5_libdir"],
+    [AS_IF([test x"$rra_krb5_root" != x],
+        [RRA_SET_LDFLAGS([KRB5_LDFLAGS], [$rra_krb5_root])])])
+ AS_IF([test x"$rra_krb5_includedir" != x],
+    [KRB5_CPPFLAGS="-I$rra_krb5_includedir"],
+    [AS_IF([test x"$rra_krb5_root" != x],
+        [AS_IF([test x"$rra_krb5_root" != x/usr],
+            [KRB5_CPPFLAGS="-I${rra_krb5_root}/include"])])])])
+
+dnl Does the appropriate library checks for reduced-dependency Kerberos v5
+dnl linkage.  The single argument, if true, says to fail if Kerberos could not
+dnl be found.
+AC_DEFUN([_RRA_LIB_KRB5_REDUCED],
+[RRA_LIB_KRB5_SWITCH
+ AC_CHECK_LIB([krb5], [krb5_init_context], [KRB5_LIBS="-lkrb5"],
+     [AS_IF([test x"$1" = xtrue],
+         [AC_MSG_ERROR([cannot find usable Kerberos v5 library])])])
+ LIBS="$KRB5_LIBS $LIBS"
+ AC_CHECK_FUNCS([krb5_get_error_message],
+     [AC_CHECK_FUNCS([krb5_free_error_message])],
+     [AC_CHECK_FUNCS([krb5_get_error_string], ,
+         [AC_CHECK_FUNCS([krb5_get_err_txt], ,
+             [AC_CHECK_LIB([ksvc], [krb5_svc_get_msg],
+                 [KRB5_LIBS="$KRB5_LIBS -lksvc"
+                  AC_DEFINE([HAVE_KRB5_SVC_GET_MSG], [1])
+                  AC_CHECK_HEADERS([ibm_svc/krb5_svc.h])],
+                 [AC_CHECK_LIB([com_err], [com_err],
+                     [KRB5_LIBS="$KRB5_LIBS -lcom_err"],
+                     [AC_MSG_ERROR([cannot find usable com_err library])])
+                  AC_CHECK_HEADERS([et/com_err.h])])])])])
+ RRA_LIB_KRB5_RESTORE])
+
+dnl Does the appropriate library checks for Kerberos v5 linkage when we don't
+dnl have krb5-config or reduced dependencies.  The single argument, if true,
+dnl says to fail if Kerberos could not be found.
+AC_DEFUN([_RRA_LIB_KRB5_MANUAL],
+[RRA_LIB_KRB5_SWITCH
+ rra_krb5_extra=
+ LIBS=
+ AC_SEARCH_LIBS([res_search], [resolv], ,
+    [AC_SEARCH_LIBS([__res_search], [resolv])])
+ AC_SEARCH_LIBS([gethostbyname], [nsl])
+ AC_SEARCH_LIBS([socket], [socket], ,
+    [AC_CHECK_LIB([nsl], [socket], [LIBS="-lnsl -lsocket $LIBS"], ,
+        [-lsocket])])
+ AC_SEARCH_LIBS([crypt], [crypt])
+ AC_SEARCH_LIBS([rk_simple_execve], [roken])
+ rra_krb5_extra="$LIBS"
+ LIBS="$rra_krb5_save_LIBS"
+ AC_CHECK_LIB([krb5], [krb5_init_context],
+    [KRB5_LIBS="-lkrb5 -lasn1 -lcom_err -lcrypto $rra_krb5_extra"],
+    [AC_CHECK_LIB([krb5support], [krb5int_getspecific],
+        [rra_krb5_extra="-lkrb5support $rra_krb5_extra"],
+        [AC_CHECK_LIB([pthreads], [pthread_setspecific],
+            [rra_krb5_pthread="-lpthreads"],
+            [AC_CHECK_LIB([pthread], [pthread_setspecific],
+                [rra_krb5_pthread="-lpthread"])])
+         AC_CHECK_LIB([krb5support], [krb5int_setspecific],
+            [rra_krb5_extra="-lkrb5support $rra_krb5_extra $rra_krb5_pthread"],
+            , [$rra_krb5_pthread])])
+     AC_CHECK_LIB([com_err], [error_message],
+        [rra_krb5_extra="-lcom_err $rra_krb5_extra"])
+     AC_CHECK_LIB([ksvc], [krb5_svc_get_msg],
+        [rra_krb5_extra="-lksvc $rra_krb5_extra"])
+     AC_CHECK_LIB([k5crypto], [krb5int_hash_md5],
+        [rra_krb5_extra="-lk5crypto $rra_krb5_extra"])
+     AC_CHECK_LIB([k5profile], [profile_get_values],
+        [rra_krb5_extra="-lk5profile $rra_krb5_extra"])
+     AC_CHECK_LIB([krb5], [krb5_cc_default],
+        [KRB5_LIBS="-lkrb5 $rra_krb5_extra"],
+        [AS_IF([test x"$1" = xtrue],
+            [AC_MSG_ERROR([cannot find usable Kerberos v5 library])])],
+        [$rra_krb5_extra])],
+    [-lasn1 -lcom_err -lcrypto $rra_krb5_extra])
+ LIBS="$KRB5_LIBS $LIBS"
+ AC_CHECK_FUNCS([krb5_get_error_message],
+     [AC_CHECK_FUNCS([krb5_free_error_message])],
+     [AC_CHECK_FUNCS([krb5_get_error_string], ,
+         [AC_CHECK_FUNCS([krb5_get_err_txt], ,
+             [AC_CHECK_FUNCS([krb5_svc_get_msg],
+                 [AC_CHECK_HEADERS([ibm_svc/krb5_svc.h])],
+                 [AC_CHECK_HEADERS([et/com_err.h])])])])])
+ RRA_LIB_KRB5_RESTORE])
+
+dnl Sanity-check the results of krb5-config and be sure we can really link a
+dnl Kerberos program.  If that fails, clear KRB5_CPPFLAGS and KRB5_LIBS so
+dnl that we know we don't have usable flags and fall back on the manual
+dnl check.
+AC_DEFUN([_RRA_LIB_KRB5_CHECK],
+[RRA_LIB_KRB5_SWITCH
+ AC_CHECK_FUNC([krb5_init_context],
+    [RRA_LIB_KRB5_RESTORE],
+    [RRA_LIB_KRB5_RESTORE
+     KRB5_CPPFLAGS=
+     KRB5_LIBS=
+     _RRA_LIB_KRB5_PATHS
+     _RRA_LIB_KRB5_MANUAL([$1])])])
+
+dnl The core of the library checking, shared between RRA_LIB_KRB5 and
+dnl RRA_LIB_KRB5_OPTIONAL.  The single argument, if "true", says to fail if
+dnl Kerberos could not be found.
+AC_DEFUN([_RRA_LIB_KRB5_INTERNAL],
+[AC_REQUIRE([RRA_ENABLE_REDUCED_DEPENDS])
+ AS_IF([test x"$rra_reduced_depends" = xtrue],
+    [_RRA_LIB_KRB5_PATHS
+     _RRA_LIB_KRB5_REDUCED([$1])],
+    [AC_ARG_VAR([KRB5_CONFIG], [Path to krb5-config])
+     AS_IF([test x"$rra_krb5_root" != x && test -z "$KRB5_CONFIG"],
+         [AS_IF([test -x "${rra_krb5_root}/bin/krb5-config"],
+             [KRB5_CONFIG="${rra_krb5_root}/bin/krb5-config"])],
+         [AC_PATH_PROG([KRB5_CONFIG], [krb5-config])])
+     AS_IF([test x"$KRB5_CONFIG" != x && test -x "$KRB5_CONFIG"],
+         [AC_CACHE_CHECK([for krb5 support in krb5-config],
+             [rra_cv_lib_krb5_config],
+             [AS_IF(["$KRB5_CONFIG" 2>&1 | grep krb5 >/dev/null 2>&1],
+                 [rra_cv_lib_krb5_config=yes],
+                 [rra_cv_lib_krb5_config=no])])
+          AS_IF([test x"$rra_cv_lib_krb5_config" = xyes],
+              [KRB5_CPPFLAGS=`"$KRB5_CONFIG" --cflags krb5 2>/dev/null`
+               KRB5_LIBS=`"$KRB5_CONFIG" --libs krb5 2>/dev/null`],
+              [KRB5_CPPFLAGS=`"$KRB5_CONFIG" --cflags 2>/dev/null`
+               KRB5_LIBS=`"$KRB5_CONFIG" --libs 2>/dev/null`])
+          KRB5_CPPFLAGS=`echo "$KRB5_CPPFLAGS" | sed 's%-I/usr/include ?%%'`
+          _RRA_LIB_KRB5_CHECK([$1])
+          RRA_LIB_KRB5_SWITCH
+          AC_CHECK_FUNCS([krb5_get_error_message],
+              [AC_CHECK_FUNCS([krb5_free_error_message])],
+              [AC_CHECK_FUNCS([krb5_get_error_string], ,
+                  [AC_CHECK_FUNCS([krb5_get_err_txt], ,
+                      [AC_CHECK_FUNCS([krb5_svc_get_msg],
+                          [AC_CHECK_HEADERS([ibm_svc/krb5_svc.h])],
+                          [AC_CHECK_HEADERS([et/com_err.h])])])])])
+          RRA_LIB_KRB5_RESTORE],
+         [_RRA_LIB_KRB5_PATHS
+          _RRA_LIB_KRB5_MANUAL([$1])])])
+ rra_krb5_uses_com_err=false
+ case "$LIBS" in
+ *-lcom_err*)
+     rra_krb5_uses_com_err=true
+     ;;
+ esac
+ AM_CONDITIONAL([KRB5_USES_COM_ERR], [test x"$rra_krb5_uses_com_err" = xtrue])])
+
+dnl The main macro for packages with mandatory Kerberos support.
+AC_DEFUN([RRA_LIB_KRB5],
+[rra_krb5_root=
+ rra_krb5_libdir=
+ rra_krb5_includedir=
+ AC_SUBST([KRB5_CPPFLAGS])
+ AC_SUBST([KRB5_LDFLAGS])
+ AC_SUBST([KRB5_LIBS])
+
+ AC_ARG_WITH([krb5],
+    [AS_HELP_STRING([--with-krb5=DIR],
+        [Location of Kerberos v5 headers and libraries])],
+    [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
+        [rra_krb5_root="$withval"])])
+ AC_ARG_WITH([krb5-include],
+    [AS_HELP_STRING([--with-krb5-include=DIR],
+        [Location of Kerberos v5 headers])],
+    [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
+        [rra_krb5_includedir="$withval"])])
+ AC_ARG_WITH([krb5-lib],
+    [AS_HELP_STRING([--with-krb5-lib=DIR],
+        [Location of Kerberos v5 libraries])],
+    [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
+        [rra_krb5_libdir="$withval"])])
+ _RRA_LIB_KRB5_INTERNAL([true])])
+
+dnl The main macro for packages with optional Kerberos support.
+AC_DEFUN([RRA_LIB_KRB5_OPTIONAL],
+[rra_krb5_root=
+ rra_krb5_libdir=
+ rra_krb5_includedir=
+ rra_use_kerberos=
+ AC_SUBST([KRB5_CPPFLAGS])
+ AC_SUBST([KRB5_LDFLAGS])
+ AC_SUBST([KRB5_LIBS])
+
+ AC_ARG_WITH([krb5],
+    [AS_HELP_STRING([--with-krb5@<:@=DIR@:>@],
+        [Location of Kerberos v5 headers and libraries])],
+    [AS_IF([test x"$withval" = xno],
+        [rra_use_kerberos=false],
+        [AS_IF([test x"$withval" != xyes], [rra_krb5_root="$withval"])
+         rra_use_kerberos=true])])
+ AC_ARG_WITH([krb5-include],
+    [AS_HELP_STRING([--with-krb5-include=DIR],
+        [Location of Kerberos v5 headers])],
+    [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
+        [rra_krb5_includedir="$withval"])])
+ AC_ARG_WITH([krb5-lib],
+    [AS_HELP_STRING([--with-krb5-lib=DIR],
+        [Location of Kerberos v5 libraries])],
+    [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
+        [rra_krb5_libdir="$withval"])])
+
+ AS_IF([test x"$rra_use_kerberos" != xfalse],
+     [AS_IF([test x"$rra_use_kerberos" = xtrue],
+         [_RRA_LIB_KRB5_INTERNAL([true])],
+         [_RRA_LIB_KRB5_INTERNAL([false])])])
+ AS_IF([test x"$KRB5_LIBS" != x],
+    [AC_DEFINE([HAVE_KERBEROS], 1, [Define to enable Kerberos features.])])])
diff --git a/src/cf/lib-depends.m4 b/src/cf/lib-depends.m4
new file mode 100644 (file)
index 0000000..039e245
--- /dev/null
@@ -0,0 +1,23 @@
+dnl Provides option to change library probes.
+dnl
+dnl This file provides RRA_ENABLE_REDUCED_DEPENDS, which adds the configure
+dnl option --enable-reduced-depends to request that library probes assume
+dnl shared libraries are in use and dependencies of libraries should not be
+dnl probed.  If this option is given, the shell variable rra_reduced_depends
+dnl is set to true; otherwise, it is set to false.
+dnl
+dnl This macro doesn't do much but is defined separately so that other macros
+dnl can require it with AC_REQUIRE.
+dnl
+dnl Written by Russ Allbery <rra@stanford.edu>
+dnl Copyright 2005, 2006, 2007
+dnl     Board of Trustees, Leland Stanford Jr. University
+dnl
+dnl See LICENSE for licensing terms.
+
+AC_DEFUN([RRA_ENABLE_REDUCED_DEPENDS],
+[rra_reduced_depends=false
+AC_ARG_ENABLE([reduced-depends],
+    [AS_HELP_STRING([--enable-reduced-depends],
+        [Try to minimize shared library dependencies])],
+    [AS_IF([test x"$enableval" = xyes], [rra_reduced_depends=true])])])
diff --git a/src/cf/lib-pathname.m4 b/src/cf/lib-pathname.m4
new file mode 100644 (file)
index 0000000..fc326a0
--- /dev/null
@@ -0,0 +1,55 @@
+dnl Determine the library path name.
+dnl
+dnl Red Hat systems and some other Linux systems use lib64 and lib32 rather
+dnl than just lib in some circumstances.  This file provides an Autoconf
+dnl macro, RRA_SET_LDFLAGS, which given a variable, a prefix, and an optional
+dnl suffix, adds -Lprefix/lib, -Lprefix/lib32, or -Lprefix/lib64 to the
+dnl variable depending on which directories exist and the size of a long in
+dnl the compilation environment.  If a suffix is given, a slash and that
+dnl suffix will be appended, to allow for adding a subdirectory of the library
+dnl directory.
+dnl
+dnl This file also provides the Autoconf macro RRA_SET_LIBDIR, which sets the
+dnl libdir variable to PREFIX/lib{,32,64} as appropriate.
+dnl
+dnl Written by Russ Allbery <rra@stanford.edu>
+dnl Copyright 2008, 2009 Board of Trustees, Leland Stanford Jr. University
+dnl
+dnl See LICENSE for licensing terms.
+
+dnl Probe for the alternate library name that we should attempt on this
+dnl architecture, given the size of an int, and set rra_lib_arch_name to that
+dnl name.  Separated out so that it can be AC_REQUIRE'd and not run multiple
+dnl times.
+dnl
+dnl There is an unfortunate abstraction violation here where we assume we know
+dnl the cache variable name used by Autoconf.  Unfortunately, Autoconf doesn't
+dnl provide any other way of getting at that information in shell that I can
+dnl see.
+AC_DEFUN([_RRA_LIB_ARCH_NAME],
+[rra_lib_arch_name=lib
+ AC_CHECK_SIZEOF([long])
+ AS_IF([test "$ac_cv_sizeof_long" -eq 4 && test -d /usr/lib32],
+     [rra_lib_arch_name=lib32],
+     [AS_IF([test "$ac_cv_sizeof_long" -eq 8 && test -d /usr/lib64],
+         [rra_lib_arch_name=lib64])])])
+
+dnl Set VARIABLE to -LPREFIX/lib{,32,64} or -LPREFIX/lib{,32,64}/SUFFIX as
+dnl appropriate.
+AC_DEFUN([RRA_SET_LDFLAGS],
+[AC_REQUIRE([_RRA_LIB_ARCH_NAME])
+ AS_IF([test -d "$2/$rra_lib_arch_name"],
+    [AS_IF([test x"$3" = x],
+        [$1="[$]$1 -L$2/${rra_lib_arch_name}"],
+        [$1="[$]$1 -L$2/${rra_lib_arch_name}/$3"])],
+    [AS_IF([test x"$3" = x],
+        [$1="[$]$1 -L$2/lib"],
+        [$1="[$]$1 -L$2/lib/$3"])])
+ $1=`echo "[$]$1" | sed -e 's/^ *//'`])
+
+dnl Set libdir to PREFIX/lib{,32,64} as appropriate.
+AC_DEFUN([RRA_SET_LIBDIR],
+[AC_REQUIRE([_RRA_LIB_ARCH_NAME])
+ AS_IF([test -d "$1/$rra_lib_arch_name"],
+    [libdir="$1/${rra_lib_arch_name}"],
+    [libdir="$1/lib"])])
index 7fb5515..eb2c641 100644 (file)
@@ -444,8 +444,6 @@ case $AFS_SYSNAME in
                ;;
 
        *_obsd*)
-               KRB5CFLAGS="-I/usr/include/kerberosV"
-               KRB5LIBS="-lkrb5 -lcrypto"
                LEX="flex -l"
                MT_CFLAGS='-DAFS_PTHREAD_ENV -pthread -D_REENTRANT ${XCFLAGS}'
                MT_LIBS="-pthread"
index 74560bb..d1f4b2e 100644 (file)
@@ -76,7 +76,7 @@ clean:
        $(RM) -f *.o $(AUTHLIBS) $(AUTHFILES) so_locations
 
 aklog_dynamic_auth: ${AUTH_KRB5_OBJS} ${AFSLIBS} ${AUTHFILES}
-       $(LD) -o $@ ${AUTH_KRB5_OBJS} $(AFSLIBS) ${AUTHFILES} @KRB5LIBS@ ${XLIBS} ${AKLDFLAGS}
+       $(LD) -o $@ ${AUTH_KRB5_OBJS} $(AFSLIBS) ${AUTHFILES} @KRB5_LIBS@ ${XLIBS} ${AKLDFLAGS}
 
 afs_dynamic_auth: ${AUTH_OBJS} ${AFSLIBS} ${AUTHFILES}
        $(LD) -o $@ ${AUTH_OBJS} $(AFSLIBS) ${AUTHFILES} ${XLIBS} ${LDFLAGS}
@@ -88,7 +88,7 @@ aix_auth_common.o: ${srcdir}/aix_auth_common.c
        ${CCRULE}
 
 aix_aklog.o: ${srcdir}/aix_aklog.c
-       ${CCRULE} @KRB5CFLAGS@
+       ${CCRULE} @KRB5_CPPFLAGS@
 
 aix_ktc_krb.o: ${srcdir}/aix_ktc.c
        ${CCRULE} -DAFS_KERBEROS_ENV