Added MIT resources document
[krb5.git] / src / aclocal.m4
index d788f0a5e8b5775b40ccbe4effd40ce0f60ce998..c7aaf0c6e6419bcae0a0a041357a2558136b589e 100644 (file)
@@ -1,28 +1,9 @@
 AC_PREREQ(2.52)
-AC_COPYRIGHT([Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
+AC_COPYRIGHT([Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
 Massachusetts Institute of Technology.
 ])
 dnl
-dnl Figure out the top of the source and build trees.  We depend on localdir
-dnl being a relative pathname; we could make it general later, but for now 
-dnl this is good enough.
-dnl
-dnl esyscmd([test -r aclocal.m4 && echo YES])
-define([fileexists],[dnl
-pushdef([x],esyscmd([if test -r $1; then echo YES;else echo NO; fi]))dnl
-dnl Strip out newline.
-ifelse(x,[YES
-],[YES],x,[NO
-],[NO],UNKNOWN)[]popdef([x])])
-define([K5_TOPDIR],dnl
-ifelse(fileexists(./aclocal.m4),YES,[.],[dnl
-ifelse(fileexists(../aclocal.m4),YES,[..],[dnl
-ifelse(fileexists(../../aclocal.m4),YES,[../..],[dnl
-ifelse(fileexists(../../../aclocal.m4),YES,[../../..],[dnl
-ifelse(fileexists(../../../../aclocal.m4),YES,[../../../..],[dnl
-errprint(__file__:__line__: Cannot find path to aclocal.m4[
-]) m4exit(1) dnl sometimes that does not work?
-builtin(m4exit,1)UNKNOWN])])])])]))
+define([K5_TOPDIR],[.])dnl
 dnl
 AC_DEFUN(V5_SET_TOPDIR,[dnl
 ac_reltopdir="K5_TOPDIR"
@@ -74,7 +55,6 @@ AC_REQUIRE_CPP
 if test -z "$LD" ; then LD=$CC; fi
 AC_ARG_VAR(LD,[linker command [CC]])
 AC_SUBST(LDFLAGS) dnl
-WITH_KRB4 dnl
 KRB5_AC_CHOOSE_ET dnl
 KRB5_AC_CHOOSE_SS dnl
 KRB5_AC_CHOOSE_DB dnl
@@ -91,7 +71,6 @@ dnl in which the configure file lives.
 dnl
 CONFIG_RELTOPDIR=$ac_reltopdir
 AC_SUBST(CONFIG_RELTOPDIR)
-AC_SUBST(subdirs)
 lib_frag=$srcdir/$ac_config_fragdir/lib.in
 AC_SUBST_FILE(lib_frag)
 libobj_frag=$srcdir/$ac_config_fragdir/libobj.in
@@ -207,7 +186,7 @@ if test "$enable_thread_support" = yes; then
       # don't exclude CFLAGS when linking.  *sigh*
       PTHREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_C_SOURCE=199506L"
       ;;
-    solaris2.[1-9])
+    solaris2.[[1-9]])
       # On Solaris 10 with gcc 3.4.3, the autoconf archive macro doesn't
       # get the right result.   XXX What about Solaris 9 and earlier?
       if test "$GCC" = yes ; then
@@ -410,8 +389,7 @@ if test $ac_cv_func_getaddrinfo = yes; then
 fi
 dnl
 AC_REQUIRE([KRB5_SOCKADDR_SA_LEN])dnl
-AC_ARG_ENABLE([ipv6], , AC_MSG_WARN(enable/disable-ipv6 option is deprecated))dnl
-AC_MSG_CHECKING(for IPv6 compile-time support)
+AC_MSG_CHECKING(for IPv6 compile-time support without -DINET6)
 AC_CACHE_VAL(krb5_cv_inet6,[
 if test "$ac_cv_func_inet_ntop" != "yes" ; then
   krb5_cv_inet6=no
@@ -454,116 +432,34 @@ if test $krb5_cv_inet6 = yes || test "$krb5_cv_inet6_with_dinet6" = yes; then
   if test "$krb5_cv_inet6_with_dinet6" = yes; then
     AC_DEFINE(INET6,1,[May need to be defined to enable IPv6 support, for example on IRIX])
   fi
-  AC_DEFINE(KRB5_USE_INET6,1,[Define if we should compile in IPv6 support (even if we can't use it at run time)])
-fi
-])dnl
-dnl
-dnl Generic File existence tests
-dnl 
-dnl K5_AC_CHECK_FILE(FILE, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
-dnl
-AC_DEFUN(K5_AC_CHECK_FILE,
-[AC_REQUIRE([AC_PROG_CC])dnl
-dnl Do the transliteration at runtime so arg 1 can be a shell variable.
-ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
-AC_MSG_CHECKING([for $1])
-AC_CACHE_VAL(ac_cv_file_$ac_safe,
-[if test "$cross_compiling" = yes; then
-  errprint(__file__:__line__: warning: Cannot check for file existence when cross compiling
-)dnl
-  AC_MSG_ERROR(Cannot check for file existence when cross compiling)
-else
-  if test -r $1; then
-    eval "ac_cv_file_$ac_safe=yes"
-  else
-    eval "ac_cv_file_$ac_safe=no"
-  fi
-fi])dnl
-if eval "test \"`echo '$ac_cv_file_'$ac_safe`\" = yes"; then
-  AC_MSG_RESULT(yes)
-  ifelse([$2], , :, [$2])
-else
-  AC_MSG_RESULT(no)
-ifelse([$3], , , [$3
-np])dnl
-fi
-])
-dnl
-dnl K5_AC_CHECK_FILES(FILE... [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
-dnl
-AC_DEFUN(K5_AC_CHECK_FILES,
-[AC_REQUIRE([AC_PROG_CC])dnl
-for ac_file in $1
-do
-K5_AC_CHECK_FILE($ac_file,
-[changequote(, )dnl
-  ac_tr_file=HAVE`echo $ac_file | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
-changequote([, ])dnl
-  AC_DEFINE_UNQUOTED($ac_tr_file) $2], $3)dnl
-done
-])
-dnl
-dnl set $(KRB4) from --with-krb4=value -- WITH_KRB4
-dnl
-AC_DEFUN(WITH_KRB4,[
-AC_ARG_WITH([krb4],
-[  --without-krb4          omit Kerberos V4 backwards compatibility (default)
-  --with-krb4             use V4 libraries included with V5
-  --with-krb4=KRB4DIR     use preinstalled V4 libraries],
-,
-withval=no
-)dnl
-if test $withval = no; then
-       AC_MSG_NOTICE(no krb4 support)
-       KRB4_LIB=
-       KRB4_DEPLIB=
-       KRB4_INCLUDES=
-       KRB4_LIBPATH=
-       KRB_ERR_H_DEP=
-       krb5_cv_build_krb4_libs=no
-       krb5_cv_krb4_libdir=
-else
- AC_DEFINE([KRB5_KRB4_COMPAT], 1, [Define this if building with krb4 compat])
- if test $withval = yes; then
-       AC_MSG_NOTICE(enabling built in krb4 support)
-       KRB4_DEPLIB='$(TOPLIBD)/libkrb4$(DEPLIBEXT)'
-       KRB4_LIB=-lkrb4
-       KRB4_INCLUDES='-I$(SRCTOP)/include/kerberosIV -I$(BUILDTOP)/include/kerberosIV'
-       KRB4_LIBPATH=
-       KRB_ERR_H_DEP='$(BUILDTOP)/include/kerberosIV/krb_err.h'
-       krb5_cv_build_krb4_libs=yes
-       krb5_cv_krb4_libdir=
- else
-       AC_MSG_NOTICE(using preinstalled krb4 in $withval)
-       KRB4_LIB="-lkrb"
-dnl    DEPKRB4_LIB="$withval/lib/libkrb.a"
-       KRB4_INCLUDES="-I$withval/include"
-       KRB4_LIBPATH="-L$withval/lib"
-       KRB_ERR_H_DEP=
-       krb5_cv_build_krb4_libs=no
-       krb5_cv_krb4_libdir="$withval/lib"
- fi
 fi
-AC_SUBST(KRB4_INCLUDES)
-AC_SUBST(KRB4_LIBPATH)
-AC_SUBST(KRB4_LIB)
-AC_SUBST(KRB4_DEPLIB)
-AC_SUBST(KRB_ERR_H_DEP)
-dnl We always compile the des425 library
-DES425_DEPLIB='$(TOPLIBD)/libdes425$(DEPLIBEXT)'
-DES425_LIB=-ldes425
-AC_SUBST(DES425_DEPLIB)
-AC_SUBST(DES425_LIB)
 ])dnl
 dnl
-dnl
 AC_DEFUN(KRB5_AC_CHECK_FOR_CFLAGS,[
 AC_BEFORE([$0],[AC_PROG_CC])
 AC_BEFORE([$0],[AC_PROG_CXX])
 krb5_ac_cflags_set=${CFLAGS+set}
 krb5_ac_cxxflags_set=${CXXFLAGS+set}
+krb5_ac_warn_cflags_set=${WARN_CFLAGS+set}
+krb5_ac_warn_cxxflags_set=${WARN_CXXFLAGS+set}
 ])
 dnl
+AC_DEFUN(TRY_WARN_CC_FLAG,[dnl
+  cachevar=`echo "krb5_cv_cc_flag_$1" | sed -e s/=/_eq_/g -e s/-/_dash_/g -e s/[[^a-zA-Z0-9_]]/_/g`
+  AC_CACHE_CHECK([if C compiler supports $1], [$cachevar],
+  [# first try without, then with
+  AC_TRY_COMPILE([], 1;,
+    [old_cflags="$CFLAGS"
+     CFLAGS="$CFLAGS $1"
+     AC_TRY_COMPILE([], 1;, eval $cachevar=yes, eval $cachevar=no)
+     CFLAGS="$old_cflags"],
+    [AC_MSG_ERROR(compiling simple test program with $CFLAGS failed)])])
+  if eval test '"${'$cachevar'}"' = yes; then
+    WARN_CFLAGS="$WARN_CFLAGS $1"
+  fi
+  eval flag_supported='${'$cachevar'}'
+])dnl
+dnl
 AC_DEFUN(WITH_CC,[dnl
 AC_REQUIRE([KRB5_AC_CHECK_FOR_CFLAGS])dnl
 AC_REQUIRE([AC_PROG_CC])dnl
@@ -589,9 +485,8 @@ withval=no)
 if test "$withval" = yes; then
   AC_DEFINE(CONFIG_SMALL,1,[Define to reduce code size even if it means more cpu usage])
 fi
-# maybe add -Waggregate-return, or can we assume that actually works by now?
 # -Wno-long-long, if needed, for k5-platform.h without inttypes.h etc.
-extra_gcc_warn_opts="-Wall -Wcast-qual -Wcast-align -Wconversion -Wshadow"
+extra_gcc_warn_opts="-Wall -Wcast-align -Wshadow"
 # -Wmissing-prototypes
 if test "$GCC" = yes ; then
   # Putting this here means we get -Os after -O2, which works.
@@ -603,41 +498,64 @@ if test "$GCC" = yes ; then
       *)        CFLAGS="$CFLAGS -Os" ;;
     esac
   fi
-  if test "x$krb5_ac_cflags_set" = xset ; then
-    AC_MSG_NOTICE(not adding extra gcc warning flags because CFLAGS was set)
+  if test "x$krb5_ac_warn_cflags_set" = xset ; then
+    AC_MSG_NOTICE(not adding extra gcc warning flags because WARN_CFLAGS was set)
   else
     AC_MSG_NOTICE(adding extra warning flags for gcc)
-    CFLAGS="$CFLAGS $extra_gcc_warn_opts -Wmissing-prototypes"
+    WARN_CFLAGS="$WARN_CFLAGS $extra_gcc_warn_opts -Wmissing-prototypes"
     if test "`uname -s`" = Darwin ; then
       AC_MSG_NOTICE(skipping pedantic warnings on Darwin)
     elif test "`uname -s`" = Linux ; then
       AC_MSG_NOTICE(skipping pedantic warnings on Linux)
     else
-      CFLAGS="$CFLAGS -pedantic"
+      WARN_CFLAGS="$WARN_CFLAGS -pedantic"
     fi
     if test "$ac_cv_cxx_compiler_gnu" = yes; then
-      if test "x$krb5_ac_cxxflags_set" = xset ; then
-        AC_MSG_NOTICE(not adding extra g++ warnings because CXXFLAGS was set)
+      if test "x$krb5_ac_warn_cxxflags_set" = xset ; then
+        AC_MSG_NOTICE(not adding extra g++ warnings because WARN_CXXFLAGS was set)
       else
         AC_MSG_NOTICE(adding extra warning flags for g++)
-        CXXFLAGS="$CXXFLAGS $extra_gcc_warn_opts"
+        WARN_CXXFLAGS="$WARN_CXXFLAGS $extra_gcc_warn_opts"
       fi
     fi
     # Currently, G++ does not support -Wno-format-zero-length.
-    # So only add it to CFLAGS.
-    AC_CACHE_CHECK([if GCC supports -Wno-format-zero-length],
-                  krb5_cv_gcc_Wno_format_zero_length,
-    [# first try without, then with
-    AC_TRY_COMPILE([], 1;,
-      [old_cflags="$CFLAGS"
-       CFLAGS="$CFLAGS -Wno-format-zero-length"
-       AC_TRY_COMPILE([], 1;, krb5_cv_gcc_Wno_format_zero_length=yes,
-       krb5_cv_gcc_Wno_format_zero_length=no)
-       CFLAGS="$old_cflags"],
-      [AC_MSG_ERROR(compiling simple test program with $CFLAGS failed)])])
-    if test "$krb5_cv_gcc_Wno_format_zero_length" = yes; then
-      CFLAGS="$CFLAGS -Wno-format-zero-length"
+    TRY_WARN_CC_FLAG(-Wno-format-zero-length)
+    # Other flags here may not be supported on some versions of
+    # gcc that people want to use.
+    for flag in overflow strict-overflow missing-format-attribute missing-prototypes return-type missing-braces parentheses switch unused-function unused-label unused-variable unused-value unknown-pragmas sign-compare newline-eof error=uninitialized ; do
+      TRY_WARN_CC_FLAG(-W$flag)
+    done
+    #  old-style-definition? generates many, many warnings
+    #
+    # Warnings that we'd like to turn into errors on versions of gcc
+    # that support promoting only specific warnings to errors, but
+    # we'll take as warnings on older compilers.  (If such a warning
+    # is added after the -Werror=foo feature, you can just put
+    # error=foo in the above list, and skip the test for the
+    # warning-only form.)  At least in some versions, -Werror= doesn't
+    # seem to make the conditions actual errors, but still issues
+    # warnings; I guess we'll take what we can get.
+    #
+    # We're currently targeting C89+, not C99, so disallow some
+    # constructs.
+    for flag in declaration-after-statement variadic-macros ; do
+      TRY_WARN_CC_FLAG(-Werror=$flag)
+      if test "$flag_supported" = no; then
+        TRY_WARN_CC_FLAG(-W$flag)
+      fi
+    done
+    # We require function declarations now.
+    #
+    # In some compiler versions -- e.g., "gcc version 4.2.1 (Apple
+    # Inc. build 5664)" -- the -Werror- option works, but the -Werror=
+    # version doesn't cause implicitly declared functions to be
+    # flagged as errors.  If neither works, -Wall implies
+    # -Wimplicit-function-declaration so don't bother.
+    TRY_WARN_CC_FLAG(-Werror-implicit-function-declaration)
+    if test "implicit-function-declaration_supported" = no; then
+      TRY_WARN_CC_FLAG(-Werror=implicit-function-declaration)
     fi
+    #
   fi
   if test "`uname -s`" = Darwin ; then
     # Someday this should be a feature test.
@@ -684,7 +602,19 @@ else
        ;;
     esac
   fi
+  if test "`uname -s`" = SunOS ; then
+    # Using Solaris but not GCC, assume Sunsoft compiler.
+    # We have some error-out-on-warning options available.
+    # Sunsoft 12 compiler defaults to -xc99=all, it appears, so "inline"
+    # works, but it also means that declaration-in-code warnings won't
+    # be issued.
+    # -v -fd -errwarn=E_DECLARATION_IN_CODE ...
+    WARN_CFLAGS="-errtags=yes -errwarn=E_BAD_PTR_INT_COMBINATION,E_BAD_PTR_INT_COMB_ARG,E_PTR_TO_VOID_IN_ARITHMETIC,E_NO_IMPLICIT_DECL_ALLOWED,E_ATTRIBUTE_PARAM_UNDEFINED"
+    WARN_CXXFLAGS="-errtags=yes +w +w2 -xport64"
+  fi
 fi
+AC_SUBST(WARN_CFLAGS)
+AC_SUBST(WARN_CXXFLAGS)
 ])dnl
 dnl
 dnl
@@ -721,7 +651,7 @@ dnl  Note: Be careful in quoting.
 dnl        The ac_foreach generates the list of fragments to include
 dnl        or "" if $2 is empty
 AC_DEFUN(_K5_GEN_MAKEFILE,[dnl
-AC_CONFIG_FILES([$1/Makefile:$srcdir/]K5_TOPDIR[/config/pre.in:$1/Makefile.in:$srcdir/]K5_TOPDIR[/config/post.in])
+AC_CONFIG_FILES([$1/Makefile:$srcdir/]K5_TOPDIR[/config/pre.in:$1/Makefile.in:$1/deps:$srcdir/]K5_TOPDIR[/config/post.in])
 ])
 dnl
 dnl K5_GEN_FILE( <ac_output arguments> )
@@ -741,7 +671,7 @@ dnl
 define(_V5_AC_OUTPUT_MAKEFILE,
 [ifelse($2, , ,AC_CONFIG_FILES($2))
 AC_FOREACH([DIR], [$1],dnl
- [AC_CONFIG_FILES(DIR[/Makefile:$srcdir/]K5_TOPDIR[/config/pre.in:]DIR[/Makefile.in:$srcdir/]K5_TOPDIR[/config/post.in])])
+ [AC_CONFIG_FILES(DIR[/Makefile:$srcdir/]K5_TOPDIR[/config/pre.in:]DIR[/Makefile.in:]DIR[/deps:$srcdir/]K5_TOPDIR[/config/post.in])])
 K5_AC_OUTPUT])dnl
 dnl
 dnl
@@ -754,31 +684,6 @@ AC_CHECK_MEMBER(struct sockaddr.sa_len,
 ,,[#include <sys/types.h>
 #include <sys/socket.h>])])
 dnl
-dnl
-dnl CHECK_UTMP: check utmp structure and functions
-dnl
-AC_DEFUN(CHECK_UTMP,[
-AC_CHECK_MEMBERS([struct utmp.ut_pid, struct utmp.ut_type, struct utmp.ut_host, struct utmp.ut_exit],,,
-[#include <sys/types.h>
-#include <utmp.h>])
-
-# Define the names actually used in the krb5 code currently:
-if test $ac_cv_member_struct_utmp_ut_pid = no; then
-  AC_DEFINE(NO_UT_PID,1,[Define if ut_pid field not found])
-fi
-if test $ac_cv_member_struct_utmp_ut_type = no; then
-  AC_DEFINE(NO_UT_TYPE,1,[Define if ut_type field not found])
-fi
-if test $ac_cv_member_struct_utmp_ut_host = no; then
-  AC_DEFINE(NO_UT_HOST,1,[Define if ut_host field not found])
-fi
-if test $ac_cv_member_struct_utmp_ut_exit = no; then
-  AC_DEFINE(NO_UT_EXIT,1,[Define if ut_exit field not found])
-fi
-
-AC_CHECK_FUNCS(setutent setutxent updwtmp updwtmpx)
-])dnl
-dnl
 dnl WITH_NETLIB
 dnl 
 dnl
@@ -800,49 +705,6 @@ AC_DEFUN(KRB5_AC_NEED_DAEMON, [
 KRB5_NEED_PROTO([#ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif],daemon,1)])dnl
-dnl
-dnl Check if stdarg or varargs is available *and compiles*; prefer stdarg.
-dnl (This was sent to djm for incorporation into autoconf 3/12/1996.  KR)
-dnl
-AC_DEFUN(AC_HEADER_STDARG, [
-
-AC_MSG_CHECKING([for stdarg.h])
-AC_CACHE_VAL(ac_cv_header_stdarg_h,
-[AC_TRY_COMPILE([#include <stdarg.h>], [
-  } /* ac_try_compile will have started a function body */
-  int aoeu (char *format, ...) {
-    va_list v;
-    int i;
-    va_start (v, format);
-    i = va_arg (v, int);
-    va_end (v);
-],ac_cv_header_stdarg_h=yes,ac_cv_header_stdarg_h=no)])dnl
-AC_MSG_RESULT($ac_cv_header_stdarg_h)
-if test $ac_cv_header_stdarg_h = yes; then
-  AC_DEFINE(HAVE_STDARG_H, 1, [Define if stdarg available and compiles])
-else
-
-AC_MSG_CHECKING([for varargs.h])
-AC_CACHE_VAL(ac_cv_header_varargs_h,
-[AC_TRY_COMPILE([#include <varargs.h>],[
-  } /* ac_try_compile will have started a function body */
-  int aoeu (va_alist) va_dcl {
-    va_list v;
-    int i;
-    va_start (v);
-    i = va_arg (v, int);
-    va_end (v);
-],ac_cv_header_varargs_h=yes,ac_cv_header_varargs_h=no)])dnl
-AC_MSG_RESULT($ac_cv_header_varargs_h)
-if test $ac_cv_header_varargs_h = yes; then
-  AC_DEFINE(HAVE_VARARGS_H, 1, [Define if varargs available and compiles])
-else
-  AC_MSG_ERROR(Neither stdarg nor varargs compile?)
-fi
-
-fi dnl stdarg test failure
-
-])dnl
 
 dnl
 dnl KRB5_AC_NEED_LIBGEN --- check if libgen needs to be linked in for
@@ -1150,13 +1012,22 @@ AC_REQUIRE([AC_PROG_ARCHIVE])dnl
 AC_REQUIRE([AC_PROG_ARCHIVE_ADD])dnl
 AC_REQUIRE([AC_PROG_INSTALL])dnl
 AC_CHECK_PROG(AR, ar, ar, false)
+if test "$AR" = "false"; then
+  AC_MSG_ERROR([ar not found in PATH])
+fi
 AC_CHECK_PROG(PERL, perl, perl, false)
 if test "$ac_cv_prog_PERL" = "false"; then
   AC_MSG_ERROR(Perl is now required for Kerberos builds.)
 fi
 AC_SUBST(LIBLIST)
 AC_SUBST(LIBLINKS)
+AC_SUBST(PLUGIN)
+AC_SUBST(PLUGINLINK)
+AC_SUBST(PLUGININST)
+AC_SUBST(KDB5_PLUGIN_DEPLIBS)
+AC_SUBST(KDB5_PLUGIN_LIBS)
 AC_SUBST(MAKE_SHLIB_COMMAND)
+AC_SUBST(SHLIB_RPATH_FLAGS)
 AC_SUBST(SHLIB_EXPFLAGS)
 AC_SUBST(SHLIB_EXPORT_FILE_DEP)
 AC_SUBST(DYNOBJ_EXPDEPS)
@@ -1198,6 +1069,7 @@ AC_REQUIRE([KRB5_AC_NEED_LIBGEN])dnl
 AC_SUBST(CC_LINK)
 AC_SUBST(CXX_LINK)
 AC_SUBST(RPATH_FLAG)
+AC_SUBST(PROG_RPATH_FLAGS)
 AC_SUBST(DEPLIBEXT)])
 
 dnl
@@ -1208,7 +1080,9 @@ dnl Set up environment for running dynamic executables out of build tree
 AC_DEFUN(KRB5_RUN_FLAGS,
 [AC_REQUIRE([KRB5_LIB_AUX])dnl
 KRB5_RUN_ENV="$RUN_ENV"
-AC_SUBST(KRB5_RUN_ENV)])
+KRB5_RUN_VARS="$RUN_VARS"
+AC_SUBST(KRB5_RUN_ENV)
+AC_SUBST(KRB5_RUN_VARS)])
 
 dnl
 dnl KRB5_LIB_AUX
@@ -1218,14 +1092,23 @@ dnl Parse configure options related to library building.
 AC_DEFUN(KRB5_LIB_AUX,
 [AC_REQUIRE([KRB5_LIB_PARAMS])dnl
 
-AC_ARG_ENABLE([static],,
-[if test "$enableval" != no; then
-  AC_MSG_ERROR([Sorry, static libraries do not work in this release.])
-fi])
-AC_ARG_ENABLE([shared], , 
-[if test "$enableval" != yes; then
-  AC_MSG_ERROR([Sorry, this release builds only shared libraries, cannot disable them.])
-fi])
+AC_ARG_ENABLE([static],,, [enable_static=no])
+AC_ARG_ENABLE([shared],,, [enable_shared=yes])
+
+if test "x$enable_static" = "x$enable_shared"; then
+  AC_MSG_ERROR([--enable-static must be specified with --disable-shared])
+fi
+
+AC_ARG_ENABLE([rpath],
+AC_HELP_STRING([--disable-rpath],[suppress run path flags in link lines]),,
+[enable_rpath=yes])
+
+if test "x$enable_rpath" != xyes ; then
+       # Unset the rpath flag values set by shlib.conf
+       SHLIB_RPATH_FLAGS=
+       RPATH_FLAG=
+       PROG_RPATH_FLAGS=
+fi
 
 if test "$SHLIBEXT" = ".so-nobuild"; then
    AC_MSG_ERROR([Shared libraries are not yet supported on this platform.])
@@ -1233,17 +1116,29 @@ fi
 
 DEPLIBEXT=$SHLIBEXT
 
-if test "$krb5_force_static" = "yes"; then
+if test "x$enable_static" = xyes; then
+       AC_MSG_NOTICE([using static libraries])
        LIBLIST='lib$(LIBBASE)$(STLIBEXT)'
        LIBLINKS='$(TOPLIBD)/lib$(LIBBASE)$(STLIBEXT)'
+       PLUGIN='libkrb5_$(LIBBASE)$(STLIBEXT)'
+       PLUGINLINK='$(TOPLIBD)/libkrb5_$(LIBBASE)$(STLIBEXT)'
+       PLUGININST=install-static
        OBJLISTS=OBJS.ST
-       # This used to be install-static, but now we only follow this
-       # path for internal libraries we don't want installed, not for
-       # configure-time requests for installed static libraries.
-       LIBINSTLIST=
-#      CFLAGS="$CFLAGS -D_KDB5_STATIC_LINK"
+       LIBINSTLIST=install-static
+       DEPLIBEXT=$STLIBEXT
+       AC_DEFINE([STATIC_PLUGINS], 1, [Define for static plugin linkage])
+
+       KDB5_PLUGIN_DEPLIBS='$(TOPLIBD)/libkrb5_db2$(DEPLIBEXT)'
+       KDB5_PLUGIN_LIBS='-lkrb5_db2'
+       if test "x$OPENLDAP_PLUGIN" = xyes; then
+               KDB5_PLUGIN_DEBLIBS=$KDB5_PLUGIN_DEPLIBS' $(TOPLIBD)/libkrb5_ldap$(DEPLIBEXT) $(TOPLIBD)/libkdb_ldap$(DEPLIBEXT)'
+               KDB5_PLUGIN_LIBS=$KDB5_PLUGIN_LIBS' -lkrb5_kldap -lkdb_ldap $(LDAP_LIBS)'
+       fi
+       # kadm5srv_mit normally comes before kdb on the link line.  Add it
+       # again after the KDB plugins, since they depend on it for XDR stuff.
+       KDB5_PLUGIN_DEPLIBS=$KDB5_PLUGIN_DEPLIBS' $(TOPLIBD)/libkadm5srv_mit$(DEPLIBEXT)'
+       KDB5_PLUGIN_LIBS=$KDB5_PLUGIN_LIBS' -lkadm5srv_mit'
 
-       AC_MSG_RESULT([Forcing static libraries.])
        # avoid duplicate rules generation for AIX and such
        SHLIBEXT=.so-nobuild
        SHLIBVEXT=.so.v-nobuild
@@ -1257,23 +1152,25 @@ else
        fi
        case "$SHLIBSEXT" in
        .so.s-nobuild)
-               SHLIB_HAVE_MINOR_VERS=no
                LIBLIST='lib$(LIBBASE)$(SHLIBEXT)'
                LIBLINKS='$(TOPLIBD)/lib$(LIBBASE)$(SHLIBEXT) $(TOPLIBD)/lib$(LIBBASE)$(SHLIBVEXT)'
                LIBINSTLIST="install-shared"
                ;;
        *)
-               SHLIB_HAVE_MINOR_VERS=yes
                LIBLIST='lib$(LIBBASE)$(SHLIBEXT) lib$(LIBBASE)$(SHLIBSEXT)'
                LIBLINKS='$(TOPLIBD)/lib$(LIBBASE)$(SHLIBEXT) $(TOPLIBD)/lib$(LIBBASE)$(SHLIBVEXT) $(TOPLIBD)/lib$(LIBBASE)$(SHLIBSEXT)'
                LIBINSTLIST="install-shlib-soname"
                ;;
        esac
        OBJLISTS="OBJS.SH"
+       PLUGIN='$(LIBBASE)$(DYNOBJEXT)'
+       PLUGINLINK='../$(PLUGIN)'
+       PLUGININST=install-plugin
+       KDB5_PLUGIN_DEPLIBS=
+       KDB5_PLUGIN_LIBS=
 fi
 CC_LINK="$CC_LINK_SHARED"
 CXX_LINK="$CXX_LINK_SHARED"
-AC_SUBST(SHLIB_HAVE_MINOR_VERS)
 
 if test -z "$LIBLIST"; then
        AC_MSG_ERROR([must enable one of shared or static libraries])
@@ -1434,7 +1331,8 @@ AC_DEFUN([KRB5_NEED_PROTO], [
 ifelse([$3], ,[if test "x$ac_cv_func_$2" = xyes; then])
 AC_CACHE_CHECK([if $2 needs a prototype provided], krb5_cv_func_$2_noproto,
 AC_TRY_COMPILE([$1],
-[struct k5foo {int foo; } xx;
+[#undef $2
+struct k5foo {int foo; } xx;
 extern int $2 (struct k5foo*);
 $2(&xx);
 ],
@@ -1505,6 +1403,7 @@ AC_ARG_WITH([system-et],
 AC_HELP_STRING(--with-system-et,use system compile_et and -lcom_err @<:@default: build and install a local version@:>@))
 AC_MSG_CHECKING(which version of com_err to use)
 if test "x$with_system_et" = xyes ; then
+  # This will be changed to "intlsys" if textdomain support is present.
   COM_ERR_VERSION=sys
   AC_MSG_RESULT(system)
 else
@@ -1533,11 +1432,29 @@ EOF
                 ],[ &et_foo_error_table; ],:,
                 [AC_MSG_ERROR(cannot use et_foo_error_table)])
   # Anything else we need to test for?
-  rm -f conf$$e.et conf$$e.c conf$$e.h
+  rm -f conf$$e.c conf$$e.h
   krb5_cv_compile_et_useful=yes
   ])
+  AC_CACHE_CHECK(whether compile_et supports --textdomain,
+                 krb5_cv_compile_et_textdomain,[
+  krb5_cv_compile_et_textdomain=no
+  if compile_et --textdomain=xyzw conf$$e.et >/dev/null 2>&1 ; then
+    if grep -q xyzw conf$$e.c; then
+      krb5_cv_compile_et_textdomain=yes
+    fi
+  fi
+  rm -f conf$$e.c conf$$e.h
+  ])
+  if test "$krb5_cv_compile_et_textdomain" = yes; then
+    COM_ERR_VERSION=intlsys
+  fi
+  rm -f conf$$e.et
 fi
 AC_SUBST(COM_ERR_VERSION)
+if test "$COM_ERR_VERSION" = k5 -o "$COM_ERR_VERSION" = intlsys; then
+  AC_DEFINE(HAVE_COM_ERR_INTL,1,
+            [Define if com_err has compatible gettext support])
+fi
 ])
 AC_DEFUN([KRB5_AC_CHOOSE_SS],[
 AC_ARG_WITH(system-ss,
@@ -1713,18 +1630,6 @@ fi])
 dnl
 dnl
 m4_include(config/ac-archive/acx_pthread.m4)
-#
-# KRB5_AC_LIBUTIL
-#
-# Check for libutil, for NetBSD, et al.; needed for openpty() and
-# logwtmp() on some platforms.
-#
-AC_DEFUN([KRB5_AC_LIBUTIL],
-       [AC_CHECK_LIB(util, main,
-               [AC_DEFINE(HAVE_LIBUTIL,1,[Define if util library is available with openpty, logwtmp, etc])
-  UTIL_LIB=-lutil])dnl
-AC_SUBST(UTIL_LIB)
-])
 dnl
 dnl
 dnl
@@ -1760,7 +1665,6 @@ else
   : # neither enabled
 dnl  AC_MSG_NOTICE(disabling ldap backend module support)
 fi
-AC_SUBST(OPENLDAP_PLUGIN)
 ])dnl
 dnl
 dnl If libkeyutils exists (on Linux) include it and use keyring ccache