--- cygnus/src/aclocal.m4	Tue Jul  1 14:04:37 1997
+++ kerbnet-1.2/aclocal.m4	Tue May 27 21:54:50 1997
@@ -1,20 +1,4 @@
 dnl
-dnl
-dnl arrange to stuff file in substitution
-dnl
-dnl AC_STUFF_FILE_PRE()
-define(AC_STUFF_FILE_PRE,
-[AC_DIVERT_PUSH(AC_DIVERSION_SED)dnl
-1r $1
-AC_DIVERT_POP()dnl
-])dnl
-dnl AC_STUFF_FILE_POST()
-define(AC_STUFF_FILE_POST,
-[AC_DIVERT_PUSH(AC_DIVERSION_SED)dnl
-[$]r $1
-AC_DIVERT_POP()dnl
-])dnl
-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.
@@ -76,67 +60,12 @@
 esac
 ])dnl
 dnl
-dnl append subdir rule -- MAKE_SUBDIRS("making",all)
-dnl
-define(MAKE_SUBDIRS,[dnl
-AC_PUSH_MAKEFILE()dnl
-changequote(<<<,>>>)dnl
-
-$2::
-dnl These don't work well with some versions of GNU make.
-dnl	@case "`echo '$(MAKEFLAGS)'|sed -e 's/ --.*$$//'`" in \
-dnl		*[ik]*) e=:;; *) e="exit 1";; esac; \
-<<<	@e="exit 1";\
-	for i in $(SUBDIRS) ; do \
-		if test -d $$i ; then \
-			echo>>> $1 <<<"in $(CURRENT_DIR)$$i..."; \
-			if (cd $$i ; $(MAKE) CC="$(CC)" CCOPTS="$(CCOPTS)" \
-			    CURRENT_DIR=$(CURRENT_DIR)$$i/ >>>$3<<<) then :; \
-			else $$e; fi; \
-		else \
-			echo "Skipping missing directory $(CURRENT_DIR)$$i" ; \
-		fi \
-	done>>>
-changequote([,])dnl
-AC_POP_MAKEFILE()dnl
-])dnl
-dnl
-dnl take saved makefile stuff and put it in the Makefile
-dnl
-define(EXTRA_RULES,[
->>append.out
-cat - append.out>> Makefile <<"SUBDIREOF"
-# append.out contents
-SUBDIREOF
-])dnl
-dnl
-dnl take saved makefile stuff and put it in the argument
-dnl
-define(EXTRA_RULES_IN,[
->>append.out
-cat - append.out >> $1 <<"SUBDIREOF"
-# append.out contents
-SUBDIREOF
-])dnl
-dnl
-dnl take saved makefile stuff and put it in the argument
-dnl
-define(EXTRA_RULES_OUT,[
->>append.out
-cat - append.out> $1 <<"SUBDIREOF"
-# append.out contents
-SUBDIREOF
-])dnl
-dnl
-dnl drop in standard subdirectory rules
-dnl
-define(DO_SUBDIRS,[dnl
-MAKE_SUBDIRS("making",all-unix, all)
-MAKE_SUBDIRS("cleaning",clean-unix, clean)
-MAKE_SUBDIRS("installing",install-unix, install)
-MAKE_SUBDIRS("checking",check-unix, check)
-MAKE_SUBDIRS("making Makefiles",Makefiles, Makefiles)
-])dnl
+dnl DO_SUBDIRS
+dnl recurse into subdirs by specifying the recursion targets
+dnl the rules are in post.in but the target needs substitution
+AC_DEFUN([DO_SUBDIRS],
+[RECURSE_TARGETS="all-unix clean-unix install-unix install-all install-kdc install-server install-client check-unix Makefiles"
+AC_SUBST(RECURSE_TARGETS)])
 dnl
 dnl drop in standard rules for all configure files -- CONFIG_RULES
 dnl
@@ -151,43 +80,39 @@
 WITH_KRB4 dnl
 AC_CONST dnl
 WITH_NETLIB dnl
+WITH_ORACLE dnl
 KRB_INCLUDE dnl
 AC_ARG_PROGRAM dnl
-AC_PUSH_MAKEFILE()dnl
-[
-SHELL=/bin/sh
+])dnl
 
-Makefiles:: Makefile
+dnl This is somewhat gross and should go away when the build system
+dnl is revamped. -- tlyu
+dnl DECLARE_SYS_ERRLIST - check for sys_errlist in libc
+dnl
+AC_DEFUN([DECLARE_SYS_ERRLIST],
+[AC_CACHE_CHECK([for sys_errlist declaration], krb5_cv_decl_sys_errlist,
+[AC_TRY_COMPILE([#include <stdio.h>
+#include <errno.h>], [1+sys_nerr;],
+krb5_cv_decl_sys_errlist=yes, krb5_cv_decl_sys_errlist=no)])
+# assume sys_nerr won't be declared w/o being in libc
+if test $krb5_cv_decl_sys_errlist = yes; then
+  AC_DEFINE(SYS_ERRLIST_DECLARED)
+  AC_DEFINE(HAVE_SYS_ERRLIST)
+else
+  # This means that sys_errlist is not declared in errno.h, but may still
+  # be in libc.
+  AC_CACHE_CHECK([for sys_errlist in libc], krb5_cv_var_sys_errlist,
+  [AC_TRY_LINK([extern int sys_nerr;], [1+sys_nerr;],
+  krb5_cv_var_sys_errlist=yes, krb5_cv_var_sys_errlist=no;)])
+  if test $krb5_cv_var_sys_errlist = yes; then
+    AC_DEFINE(HAVE_SYS_ERRLIST)
+    # Do this cruft for backwards compatibility for now.
+    AC_DEFINE(NEED_SYS_ERRLIST)
+  else
+    AC_MSG_WARN([sys_errlist is neither in errno.h nor in libc])
+  fi
+fi])
 
-Makefile: $(srcdir)/Makefile.in $(thisconfigdir)/config.status \
-		$(SRCTOP)/config/pre.in $(SRCTOP)/config/post.in
-	cd $(thisconfigdir) && $(SHELL) config.status
-$(thisconfigdir)/config.status: $(srcdir)/$(thisconfigdir)/configure
-	cd $(thisconfigdir) && $(SHELL) config.status --recheck
-$(srcdir)/$(thisconfigdir)/configure: $(srcdir)/$(thisconfigdir)/configure.in \
-		$(SRCTOP)/aclocal.m4
-	cd $(srcdir)/$(thisconfigdir) && \
-		$(SHELL) $(SRCTOP)/util/autoconf/autoconf \
-			--localdir=$(BUILDTOP) \
-			--macrodir=$(BUILDTOP)/util/autoconf
-]
-AC_POP_MAKEFILE()dnl
-])dnl
-dnl
-dnl check for sys_errlist -- DECLARE_SYS_ERRLIST
-dnl
-define(DECLARE_SYS_ERRLIST,[
-AC_MSG_CHECKING([for sys_errlist declaration])
-AC_CACHE_VAL(krb5_cv_decl_errlist,
-[AC_TRY_LINK(
-[#include <stdio.h>
-#include <errno.h>], [1+sys_nerr;],dnl
- krb5_cv_decl_errlist=yes, krb5_cv_decl_errlist=no)])
-AC_MSG_RESULT($krb5_cv_decl_errlist)
-if test $krb5_cv_decl_errlist = no; then
-	AC_DEFINE(NEED_SYS_ERRLIST)
-fi
-])dnl
 dnl
 dnl check for sigmask/sigprocmask -- CHECK_SIGPROCMASK
 dnl
@@ -208,50 +133,6 @@
 define(AC_PROG_ARCHIVE, [AC_PROGRAM_CHECK(ARCHIVE, ar, ar cqv, false)])dnl
 define(AC_PROG_ARCHIVE_ADD, [AC_PROGRAM_CHECK(ARADD, ar, ar cruv, false)])dnl
 dnl
-dnl drop in rules for building error tables -- ET_RULES
-dnl
-define(ET_RULES,[
-AC_PROG_AWK dnl
-AC_PUSH_MAKEFILE()dnl
-[
-
-### /* these are invoked as $(...) foo.et, which works, but could be better */
-COMPILE_ET_H= $(AWK) -f $(SRCTOP)/util/et/et_h.awk outfile=$@
-COMPILE_ET_C= $(AWK) -f $(SRCTOP)/util/et/et_c.awk outfile=$@
-.SUFFIXES:  .h .c .et .ct
-
-.et.h:
-	$(AWK) -f $(SRCTOP)/util/et/et_h.awk outfile=$][*.h $<
-
-.et.c:
-	$(AWK) -f $(SRCTOP)/util/et/et_c.awk outfile=$][*.c $<
-
-]
-AC_POP_MAKEFILE()dnl
-])dnl
-dnl
-dnl drop in rules for building command tables -- SS_RULES
-dnl
-define(SS_RULES,[dnl
-AC_PUSH_MAKEFILE()dnl
-changequote({,})dnl
-{
-
-MAKE_COMMANDS= $(BUILDTOP)/util/ss/mk_cmds
-.SUFFIXES:  .h .c .et .ct
-
-.ct.c:
-	@if [ $< != "$}{*.ct" ]; then \
-		(set -x; cp $< "$}{*.ct" && $(MAKE_COMMANDS) "$}{*.ct" && $(RM) "$}{*.ct") || exit 1; \
-	else \
-		(set -x; $(MAKE_COMMANDS) "$}{*.ct") || exit 1; \
-	fi
-
-}
-changequote([,])dnl
-AC_POP_MAKEFILE()dnl
-])dnl
-dnl
 dnl check for <dirent.h> -- CHECK_DIRENT
 dnl (may need to be more complex later)
 dnl
@@ -350,6 +231,7 @@
 	DEPKRB4_CRYPTO_LIB=
 	KDB4_LIB=
 	DEPKDB4_LIB=
+	KRB4_INCLUDES=
 	LDARGS=
 	krb5_cv_build_krb4_libs=no
 	krb5_cv_krb4_libdir=
@@ -357,33 +239,36 @@
  ADD_DEF(-DKRB5_KRB4_COMPAT)
  if test $withval = yes; then
 	AC_MSG_RESULT(built in krb4 support)
+	KRB4_INCLUDE="-I$SRCTOP/include/kerberosIV"
 	KRB4_LIB='-lkrb4'
 	DEPKRB4_LIB='$(TOPLIBD)/libkrb4.a'
 	KRB4_CRYPTO_LIB='-ldes425'
 	DEPKRB4_CRYPTO_LIB='$(TOPLIBD)/libdes425.a'
 	KDB4_LIB='-lkdb4'
 	DEPKDB4_LIB='$(TOPLIBD)/libkdb4.a'
+	KRB4_INCLUDES='-I$(SRCTOP)/include/kerberosIV'
 	LDARGS=
 	krb5_cv_build_krb4_libs=yes
 	krb5_cv_krb4_libdir=
  else
 	AC_MSG_RESULT(preinstalled krb4 in $withval)
+	KRB4_INCLUDE="-I$withval/include"
 	KRB4_LIB="-lkrb"
 	DEPKRB4_LIB="$withval/lib/libkrb.a"
 	KRB4_CRYPTO_LIB='-ldes425'
 	DEPKRB4_CRYPTO_LIB='$(TOPLIBD)/libdes425.a'
 	KDB4_LIB="-lkdb"
 	DEPKDB4_LIB="$withval/lib/libkdb.a"
+	KRB4_INCLUDES="-I$withval/include"
 	LDARGS="-L$withval/lib"
 	krb5_cv_build_krb4_libs=no
 	krb5_cv_krb4_libdir="$withval/lib"
  fi
 fi
+AC_SUBST(KRB4_INCLUDES)
 AC_SUBST(KRB4_LIB)
-AC_SUBST(KDB4_LIB)
 AC_SUBST(KRB4_CRYPTO_LIB)
 AC_SUBST(DEPKRB4_LIB)
-AC_SUBST(DEPKDB4_LIB)
 AC_SUBST(DEPKRB4_CRYPTO_LIB)
 ])dnl
 dnl
@@ -402,7 +287,18 @@
   fi
 fi
 AC_CACHE_VAL(ac_cv_prog_cc,[dnl
-  test -z "$CC" && CC=cc
+  if test -z "$CC" ; then
+    dnl CYGNUS LOCAL: HP base-system compilers are crap.
+    dnl Also, we need ANSI compilers now, with the new admin code.
+    case "`(uname -s) 2>/dev/null`:`(uname -r) 2>/dev/null`" in
+      HP-UX:*9.*)  CC=gcc ;;
+      HP-UX:*10.*) CC="gcc -O" ;;
+      SunOS:4.*)   CC=gcc ;;
+      SunOS:5.*)   CC=gcc ;;	# no -O, our Solaris box is too slow
+      AIX:*)	   CC="xlc -D_ALL_SOURCE" ;;
+      *) CC=cc ;;
+    esac
+  fi
   AC_TRY_LINK([#include <stdio.h>],[printf("hi\n");], ,
     AC_MSG_ERROR(Can't find a working compiler.))
   ac_cv_prog_cc="$CC"
@@ -458,7 +354,7 @@
 dnl Imake LinkFile rule, so they occur in the right place -- LinkFile(dst,src)
 dnl
 define(LinkFile,[
-AC_LN_S
+AC_REQUIRE([AC_LN_S])
 AC_PUSH_MAKEFILE()dnl
 changequote({,})dnl
 
@@ -476,7 +372,7 @@
 dnl	ln -s ../foo ./bar/blotz
 dnl
 define(LinkFileDir,[
-AC_LN_S
+AC_REQUIRE([AC_LN_S])
 AC_PUSH_MAKEFILE()dnl
 changequote({,})dnl
 
@@ -615,10 +511,10 @@
 dnl
 define(V5_AC_OUTPUT_MAKEFILE,
 [ifelse($1, , ac_v5_makefile_dirs=., ac_v5_makefile_dirs="$1")
+ifelse($2, , filelist="", filelist="$2")
 dnl OPTIMIZE THIS FOR COMMON CASE!!
-filelist=""
 for x in $ac_v5_makefile_dirs; do
-  filelist="$filelist $x/Makefile.tmp:$x/Makefile.in $x/pre.tmp:$ac_prepend $x/post.tmp:$ac_postpend"
+  filelist="$filelist $x/Makefile.tmp:$ac_prepend+$x/Makefile.in+$ac_postpend"
 done
 AC_OUTPUT($filelist,
 [EOF
@@ -676,12 +572,12 @@
 	`
     test "$s" = "" && s=.
     echo creating $d/Makefile
-    cat - $d/pre.tmp $d/Makefile.tmp $d/post.tmp append.tmp > $d/Makefile <<EOX
+    cat - $d/Makefile.tmp append.tmp > $d/Makefile <<EOX
 thisconfigdir=$x
 SRCTOP=$s
 BUILDTOP=$x$ac_reltopdir
 EOX
-    rm  $d/pre.tmp $d/Makefile.tmp $d/post.tmp
+    rm  $d/Makefile.tmp
 # sed -f $CONF_FRAGDIR/mac-mf.sed < Makefile > MakeFile
   fi
 done
@@ -689,20 +585,28 @@
 ],
 CONF_FRAGDIR=$srcdir/${ac_config_fragdir} )])dnl
 dnl
+dnl CHECK_STRUCT_MEMBER(headers, struct, field)
+dnl look for field in struct, using headers...
+dnl
+define(CHECK_STRUCT_MEMBER,[
+AC_MSG_CHECKING(whether struct $2 contains $3)
+AC_CACHE_VAL(krb5_cv_struct_$2_$3,
+[AC_TRY_COMPILE($1, [struct $2 actest; actest.$3;],
+krb5_cv_struct_$2_$3=yes, krb5_cv_struct_$2_$3=no)])
+AC_MSG_RESULT([$]krb5_cv_struct_$2_$3)
+if test $krb5_cv_struct_$2_$3 = yes; then
+  AC_DEFINE_UNQUOTED(HAVE_[]translit(struct_$2_$3, [a-z], [A-Z]))
+fi
+])dnl
+dnl
 dnl KRB5_SOCKADDR_SA_LEN: define HAVE_SA_LEN if sockaddr contains the sa_len
 dnl component
 dnl
 AC_DEFUN([KRB5_SOCKADDR_SA_LEN],[ dnl
-AC_MSG_CHECKING(Whether struct sockaddr contains sa_len)
-AC_CACHE_VAL(krb5_cv_sockaddr_sa_len,
-[AC_TRY_COMPILE([#include <sys/types.h>
+CHECK_STRUCT_MEMBER([#include <sys/types.h>
 #include <sys/socket.h>
-],
-[struct sockaddr sa;
-sa.sa_len;],
-krb5_cv_sockaddr_sa_len=yes,krb5_cv_sockaddr_sa_len=no)])
-AC_MSG_RESULT([$]krb5_cv_sockaddr_sa_len)
-if test $krb5_cv_sockaddr_sa_len = yes; then
+], sockaddr, sa_len)
+if test $krb5_cv_struct_sockaddr_sa_len = yes; then
    AC_DEFINE_UNQUOTED(HAVE_SA_LEN)
    fi
 ])
@@ -711,54 +615,26 @@
 dnl CHECK_UTMP: check utmp structure and functions
 dnl
 define(CHECK_UTMP,[
-AC_MSG_CHECKING([ut_pid in struct utmp])
-AC_CACHE_VAL(krb5_cv_struct_ut_pid,
-[AC_TRY_COMPILE(
-[#include <sys/types.h>
-#include <utmp.h>],
-[struct utmp ut; ut.ut_pid;],
-krb5_cv_struct_ut_pid=yes, krb5_cv_struct_ut_pid=no)])
-AC_MSG_RESULT($krb5_cv_struct_ut_pid)
-if test $krb5_cv_struct_ut_pid = no; then
+define(CHECK_UTMP_HEADERS,[#include <sys/types.h>
+#include <utmp.h>
+])
+CHECK_STRUCT_MEMBER(CHECK_UTMP_HEADERS, utmp, ut_pid)
+if test $krb5_cv_struct_utmp_ut_pid = no; then
   AC_DEFINE(NO_UT_PID)
 fi
-AC_MSG_CHECKING([ut_type in struct utmp])
-AC_CACHE_VAL(krb5_cv_struct_ut_type,
-[AC_TRY_COMPILE(
-[#include <sys/types.h>
-#include <utmp.h>],
-[struct utmp ut; ut.ut_type;],
-krb5_cv_struct_ut_type=yes, krb5_cv_struct_ut_type=no)])
-AC_MSG_RESULT($krb5_cv_struct_ut_type)
-if test $krb5_cv_struct_ut_type = no; then
+CHECK_STRUCT_MEMBER(CHECK_UTMP_HEADERS, utmp, ut_type)
+if test $krb5_cv_struct_utmp_ut_type = no; then
   AC_DEFINE(NO_UT_TYPE)
 fi
-AC_MSG_CHECKING([ut_host in struct utmp])
-AC_CACHE_VAL(krb5_cv_struct_ut_host,
-[AC_TRY_COMPILE(
-[#include <sys/types.h>
-#include <utmp.h>],
-[struct utmp ut; ut.ut_host;],
-krb5_cv_struct_ut_host=yes, krb5_cv_struct_ut_host=no)])
-AC_MSG_RESULT($krb5_cv_struct_ut_host)
-if test $krb5_cv_struct_ut_host = no; then
+CHECK_STRUCT_MEMBER(CHECK_UTMP_HEADERS, utmp, ut_host)
+if test $krb5_cv_struct_utmp_ut_host = no; then
   AC_DEFINE(NO_UT_HOST)
 fi
-AC_MSG_CHECKING([ut_exit in struct utmp])
-AC_CACHE_VAL(krb5_cv_struct_ut_exit,
-[AC_TRY_COMPILE(
-[#include <sys/types.h>
-#include <utmp.h>],
-[struct utmp ut; ut.ut_exit;],
-krb5_cv_struct_ut_exit=yes, krb5_cv_struct_ut_exit=no)])
-AC_MSG_RESULT($krb5_cv_struct_ut_exit)
-if test $krb5_cv_struct_ut_exit = no; then
+CHECK_STRUCT_MEMBER(CHECK_UTMP_HEADERS, utmp, ut_exit)
+if test $krb5_cv_struct_utmp_ut_exit = no; then
   AC_DEFINE(NO_UT_EXIT)
 fi
-AC_FUNC_CHECK(setutent,AC_DEFINE(HAVE_SETUTENT))
-AC_FUNC_CHECK(setutxent,AC_DEFINE(HAVE_SETUTXENT))
-AC_FUNC_CHECK(updwtmp,AC_DEFINE(HAVE_UPDWTMP))
-AC_FUNC_CHECK(updwtmpx,AC_DEFINE(HAVE_UPDWTMPX))
+AC_CHECK_FUNCS(setutent setutxent updwtmp updwtmpx)
 ])dnl
 dnl
 dnl
@@ -794,8 +670,8 @@
 ,dnl
 [if test "`(uname) 2>/dev/null`" != IRIX ; then
   AC_CHECK_LIB(socket,main)
+  AC_CHECK_LIB(nsl,main)]
 fi
-AC_CHECK_LIB(nsl,main)]
 )])dnl
 dnl
 dnl HAS_ANSI_VOLATILE
@@ -812,92 +688,199 @@
 fi
 ])dnl
 dnl
-dnl This rule tells KRB5_LIBRARIES to use the kadm library.
+dnl set oracle logging parameter
 dnl
-kadm_deplib=''
-kadm_lib=''
-define(USE_KADM_LIBRARY,[
-kadm_deplib="\[$](TOPLIBD)/libkadm.a"
-kadm_lib=-lkadm])
-dnl
-dnl This rule tells KRB5_LIBRARIES to use the krb5util library.
-dnl
-kutil_deplib=''
-kutil_lib=''
-define(USE_KRB5UTIL_LIBRARY,[
-kutil_deplib="\[$](TOPLIBD)/libkrb5util.a"
-kutil_lib=-lkrb5util])
-dnl
-dnl This rule tells KRB5_LIBRARIES to include the aname dbm library.
-dnl
-kaname_deplib=''
-kaname_libs=''
-define(USE_ANAME,[
-WITH_ANAME_DB
-kaname_libs="$dblibs"
-if test "$dbval" = "db"; then
-  if test -n "$krb5_cv_shlib_version_libdb"; then
-    kaname_deplib="\$(TOPLIBD)/libdb.$krb5_cv_shlibs_ext.$krb5_cv_shlib_version_libdb"
-  else
-    kaname_deplib="\$(TOPLIBD)/libdb.$krb5_cv_noshlibs_ext"
-  fi
+define(WITH_ORACLE_LOG,[
+AC_ARG_WITH([oracle-logging],
+[  --with-oracle-logging     Allow Oracle to be used for logging info.],
+,
+withval=no
+)dnl
+if test $withval = yes -o "$with_oracle" = yes; then
+	ADD_DEF(-DHAVE_ORACLE_LOG -I$(ORACLE_HOME)/rdbms/demo)
+	AC_MSG_RESULT(adding Oracle logging ability)
+	OCI_LDFLAGS="-L$(ORACLE_HOME)/lib"
+	OCI_LIBS="-lclntsh -lm"
 fi
+AC_SUBST(OCI_LDFLAGS)
+AC_SUBST(OCI_LIBS)
 ])dnl
 dnl
-dnl This rule tells KRB5_LIBRARIES to include the kdb5 and dbm libraries.
+dnl set $(USE_OCI_KDB) from --with-oracle
 dnl
-kdb5_deplib=''
-kdb5_lib=''
-kdbm_deplib=''
-kdbm_libs=''
-define(USE_KDB5_LIBRARY,[
-kdb5_deplib="\[$](TOPLIBD)/libkdb5.a"
-kdb5_lib=-lkdb5
-WITH_KDB_DB
-kdbm_libs="$dblibs"
-if test "$dbval" = "db"; then
-  if test -n "$krb5_cv_shlib_version_libdb"; then
-    kdbm_deplib="\$(TOPLIBD)/libdb.$krb5_cv_shlibs_ext.$krb5_cv_shlib_version_libdb"
-  else
-    kdbm_deplib="\$(TOPLIBD)/libdb.$krb5_cv_noshlibs_ext"
-  fi
-fi
-])
+define(WITH_ORACLE,[
+AC_ARG_WITH([oracle],
+[  --with-oracle             Use Oracle for backend database],
+,
+withval=no
+)dnl
+if test $withval = yes; then
+	ADD_DEF(-DUSE_OCI_KDB -I$(ORACLE_HOME)/rdbms/demo)
+	AC_MSG_RESULT(built in Oracle OCI support)
+	AC_REQUIRE([WITH_ORACLE_LOG])
+	OCI_LDFLAGS="-L$(ORACLE_HOME)/lib"
+	OCI_LIBS="-lclntsh -lm"
+# The next line is the old OCI_LIBS...
+#	OCI_LIBS="-lclient -lsqlnet -lncr -lsqlnet -lclient -lcommon -lgeneric -lsqlnet -lncr -lsqlnet -lclient -lcommon -lgeneric -lepc -lnlsrtl3 -lc3v6 -lcore3 -lnlsrtl3 -lcore3 -lnlsrtl3 -lm"
+fi
+AC_SUBST(OCI_LDFLAGS)
+AC_SUBST(OCI_LIBS)
+])dnl
+dnl
+dnl This rule tells KRB5_LIBRARIES to use the kadm5srv library.
+dnl
+define([krb5m4_kadmsrv_deplib],[])dnl
+define([krb5m4_kadmsrv_lib],[])dnl
+AC_DEFUN(USE_KADMSRV_LIBRARY,[
+AC_REQUIRE([USE_DYN_LIBRARY])dnl
+AC_REQUIRE([USE_GSSRPC_LIBRARY])dnl
+undefine([krb5m4_kadmsrv_deplib])dnl
+define([krb5m4_kadmsrv_deplib],\[$](TOPLIBD)/libkadm5srv.a)dnl
+undefine([krb5m4_kadmsrv_lib])dnl
+define([krb5m4_kadmsrv_lib],-lkadm5srv)])
+dnl
+dnl This rule tells KRB5_LIBRARIES to use the kadm5clnt library.
+dnl
+define([krb5m4_kadmclnt_deplib],[])dnl
+define([krb5m4_kadmclnt_lib],[])dnl
+AC_DEFUN(USE_KADMCLNT_LIBRARY,[
+undefine([krb5m4_kadmclnt_deplib])dnl
+define([krb5m4_kadmclnt_deplib],\[$](TOPLIBD)/libkadm5clnt.a)dnl
+undefine([krb5m4_kadmclnt_lib])dnl
+define([krb5m4_kadmclnt_lib],-lkadm5clnt) ])
+dnl
+dnl This rule tells KRB5_LIBRARIES to use the gssrpc library.
+dnl
+define([krb5m4_gssrpc_deplib],[])dnl
+define([krb5m4_gssrpc_lib],[])dnl
+AC_DEFUN(USE_GSSRPC_LIBRARY,[
+AC_REQUIRE([USE_GSSAPI_LIBRARY])dnl
+undefine([krb5m4_gssrpc_deplib])dnl
+define([krb5m4_gssrpc_deplib],\[$](TOPLIBD)/libgssrpc.a)dnl
+undefine([krb5m4_gssrpc_lib])dnl
+define([krb5m4_gssrpc_lib],-lgssrpc) ])
+dnl
+dnl This rule tells KRB5_LIBRARIES to use the gssapi library.
+dnl
+define([krb5m4_gssapi_deplib],[])dnl
+define([krb5m4_gssapi_lib],[])dnl
+AC_DEFUN(USE_GSSAPI_LIBRARY,[
+undefine([krb5m4_gssapi_deplib])dnl
+define([krb5m4_gssapi_deplib],\[$](TOPLIBD)/libgssapi_krb5.a)dnl
+undefine([krb5m4_gssapi_lib])dnl
+define([krb5m4_gssapi_lib],-lgssapi_krb5) ])
 dnl
-dnl This rule tells KRB5_LIBRARIES to include the kdb4 library.
+dnl This rule tells KRB5_LIBRARIES to use the krb5util library.
 dnl
-kdb4_deplib=''
-kdb4_lib=''
-define(USE_KDB4_LIBRARY,[
-kdb4_deplib=$DEPKRB4_LIB
-kdb4_lib=$KDB4_LIB])
+define([krb5m4_kutil_deplib],[])dnl
+define([krb5m4_kutil_lib],[])dnl
+AC_DEFUN(USE_KRB5UTIL_LIBRARY,[
+undefine([krb5m4_kutil_deplib])dnl
+define([krb5m4_kutil_deplib],\[$](TOPLIBD)/libkrb5util.a)dnl
+undefine([krb5m4_kutil_lib])dnl
+define([krb5m4_kutil_lib],-lkrb5util) ])
+dnl
+dnl This rule tells KRB5_LIBRARIES to include the aname db library.
+dnl
+AC_DEFUN(USE_ANAME,[AC_REQUIRE([USE_DB_LIBRARY]) ])dnl
+dnl
+dnl This rule tells KRB5_LIBRARIES to include the kdb5 and db libraries.
+dnl (Updated to also require OCI libraries if necessary).
+dnl
+define([krb5m4_kdb5_deplib],[])dnl
+define([krb5m4_kdb5_lib],[])dnl
+AC_DEFUN(USE_KDB5_LIBRARY,[
+undefine([krb5m4_kdb5_deplib])dnl
+define([krb5m4_kdb5_deplib],\[$](TOPLIBD)/libkdb5.a)dnl
+undefine([krb5m4_kdb5_lib])dnl
+define([krb5m4_kdb5_lib],-lkdb5)dnl
+AC_REQUIRE([USE_DB_LIBRARY])dnl
+AC_REQUIRE([USE_OCI_LIBRARY])dnl
+])
 dnl
 dnl This rule tells KRB5_LIBRARIES to include the krb4 libraries.
 dnl
-krb4_deplib=''
-krb5_lib=''
-define(USE_KRB4_LIBRARY,[
-krb4_deplib="$DEPKRB4_LIB $DEPKRB4_CRYPTO_LIB"
-krb4_lib="$KRB4_LIB $KRB4_CRYPTO_LIB"])
+define([krb5m4_krb4_deplib],[])dnl
+define([krb5m4_krb4_lib],[])dnl
+AC_DEFUN(USE_KRB4_LIBRARY,[
+undefine([krb5m4_krb4_deplib])dnl
+define([krb5m4_krb4_deplib],$DEPKRB4_LIB $DEPKRB4_CRYPTO_LIB)dnl
+undefine([krb5m4_krb4_lib])dnl
+define([krb5m4_krb4_lib],$KRB4_LIB $KRB4_CRYPTO_LIB)])
 dnl
 dnl This rule tells KRB5_LIBRARIES to include the ss library.
 dnl
-ss_deplib=''
-ss_lib=''
-define(USE_SS_LIBRARY,[
-ss_deplib="\[$](TOPLIBD)/libss.a"
-ss_lib=-lss
+define([krb5m4_ss_deplib],[])dnl
+define([krb5m4_ss_lib],[])dnl
+AC_DEFUN(USE_SS_LIBRARY,[
+undefine([krb5m4_ss_deplib])dnl
+define([krb5m4_ss_deplib],\[$](TOPLIBD)/libss.a)dnl
+undefine([krb5m4_ss_lib])dnl
+define([krb5m4_ss_lib],-lss)dnl
+])
+dnl
+dnl This rule tells KRB5_LIBRARIES to include the dyn library.
+dnl
+define([krb5m4_dyn_deplib],[])dnl
+define([krb5m4_dyn_lib],[])dnl
+AC_DEFUN(USE_DYN_LIBRARY,[
+undefine([krb5m4_dyn_deplib])dnl
+define([krb5m4_dyn_deplib],\[$](TOPLIBD)/libdyn.a)dnl
+undefine([krb5m4_dyn_lib])dnl
+define([krb5m4_dyn_lib],-ldyn)dnl
+])
+dnl
+dnl This rule tells KRB5_LIBRARIES to include the db library.
+dnl
+define([krb5m4_db_deplib],[])dnl
+define([krb5m4_db_lib],[])dnl
+AC_DEFUN(USE_DB_LIBRARY,[
+undefine([krb5m4_db_deplib])dnl
+define([krb5m4_db_deplib],\[$](TOPLIBD)/libdb.a)dnl
+undefine([krb5m4_db_lib])dnl
+define([krb5m4_db_lib],-ldb)dnl
+])
+dnl
+dnl This rule tells KRB5_LIBRARIES to include the OCI libraries.
+dnl
+define([krb5m4_oci_deplib],[])dnl
+define([krb5m4_oci_lib],[])dnl
+AC_DEFUN(USE_OCI_LIBRARY,[
+undefine([krb5m4_oci_lib])dnl
+define([krb5m4_oci_lib],$OCI_LDFLAGS $OCI_LIBS)dnl
 ])
 dnl
 dnl This rule generates library lists for programs.
 dnl
 define(KRB5_LIBRARIES,[
-DEPLIBS="\[$](DEPLOCAL_LIBRARIES) $kadm_deplib $kdb5_deplib $kutil_deplib \[$](TOPLIBD)/libkrb5.a $kdb4_deplib $krb4_deplib $kdbm_deplib $kaname_deplib \[$](TOPLIBD)/libcrypto.a $ss_deplib \[$](TOPLIBD)/libcom_err.a"
-LIBS="\[$](LOCAL_LIBRARIES) $kadm_lib $kdb5_lib $kdb4_lib $kutil_lib $krb4_lib -lkrb5 $kdbm_libs $kaname_libs -lcrypto $ss_lib -lcom_err $LIBS"
+dnl
+dnl under solaris, if we use compile() and step(), we need -lgen
+save_LIBS="$LIBS"
+LIBS=-lgen
+dnl this will fail if there's no compile/step in -lgen, or if there's
+dnl no -lgen.  This is fine.
+AC_CHECK_FUNCS(compile step)
+[if test "$ac_cv_func_compile" = yes ; then
+	LIBS="$save_LIBS -lgen"
+else
+	LIBS="$save_LIBS"
+fi]
+dnl this is ugly, but it wouldn't be necessary if krb5 didn't abuse
+dnl configure so badly
+SRVDEPLIBS="\[$](DEPLOCAL_LIBRARIES) krb5m4_kadmsrv_deplib krb5m4_gssrpc_deplib krb5m4_gssapi_deplib krb5m4_kdb5_deplib krb5m4_kutil_deplib \[$](TOPLIBD)/libkrb5.a $kdb4_deplib krb5m4_krb4_deplib \[$](TOPLIBD)/libcrypto.a krb5m4_ss_deplib krb5m4_dyn_deplib krb5m4_db_deplib krb5m4_oci_deplib \[$](TOPLIBD)/libcom_err.a \[$](SHLIB_EXTRA_DEPS)"
+SRVLIBS="\[$](LOCAL_LIBRARIES) krb5m4_kadmsrv_lib krb5m4_gssrpc_lib krb5m4_gssapi_lib krb5m4_kdb5_lib $kdb4_lib krb5m4_kutil_lib krb5m4_krb4_lib -lkrb5 -lcrypto krb5m4_ss_lib krb5m4_dyn_lib krb5m4_db_lib krb5m4_oci_lib -lcom_err $LIBS"
+CLNTDEPLIBS="\[$](DEPLOCAL_LIBRARIES) krb5m4_kadmclnt_deplib krb5m4_gssrpc_deplib krb5m4_gssapi_deplib krb5m4_kdb5_deplib krb5m4_kutil_deplib \[$](TOPLIBD)/libkrb5.a $kdb4_deplib krb5m4_krb4_deplib \[$](TOPLIBD)/libcrypto.a krb5m4_ss_deplib krb5m4_dyn_deplib krb5m4_db_deplib krb5m4_oci_deplib \[$](TOPLIBD)/libcom_err.a \[$](SHLIB_EXTRA_DEPS)"
+CLNTLIBS="\[$](LOCAL_LIBRARIES) krb5m4_kadmclnt_lib krb5m4_gssrpc_lib krb5m4_gssapi_lib krb5m4_kdb5_lib $kdb4_lib krb5m4_kutil_lib krb5m4_krb4_lib -lkrb5 -lcrypto krb5m4_ss_lib krb5m4_dyn_lib krb5m4_db_lib krb5m4_oci_lib -lcom_err $LIBS"
+DEPLIBS="\[$](DEPLOCAL_LIBRARIES) krb5m4_kadmclnt_deplib krb5m4_kadmsrv_deplib krb5m4_gssrpc_deplib krb5m4_gssapi_deplib krb5m4_kdb5_deplib krb5m4_kutil_deplib \[$](TOPLIBD)/libkrb5.a $kdb4_deplib krb5m4_krb4_deplib \[$](TOPLIBD)/libcrypto.a krb5m4_ss_deplib krb5m4_dyn_deplib krb5m4_db_deplib krb5m4_oci_deplib \[$](TOPLIBD)/libcom_err.a \[$](SHLIB_EXTRA_DEPS)"
+LIBS="\[$](LOCAL_LIBRARIES) krb5m4_kadmclnt_lib krb5m4_kadmsrv_lib krb5m4_gssrpc_lib krb5m4_gssapi_lib krb5m4_kdb5_lib $kdb4_lib krb5m4_kutil_lib krb5m4_krb4_lib -lkrb5 -lcrypto krb5m4_ss_lib krb5m4_dyn_lib krb5m4_db_lib krb5m4_oci_lib -lcom_err $LIBS"
 LDFLAGS="$LDFLAGS -L\$(TOPLIBD)"
 AC_SUBST(LDFLAGS)
 AC_SUBST(LDARGS)
-AC_SUBST(DEPLIBS)])
+AC_SUBST(DEPLIBS)
+AC_SUBST(SRVDEPLIBS)
+AC_SUBST(SRVLIBS)
+AC_SUBST(CLNTDEPLIBS)
+AC_SUBST(CLNTLIBS)])
 dnl
 dnl This rule supports the generation of the shared library object files
 dnl
@@ -917,7 +900,8 @@
 dnl This rule adds the additional Makefile fragment necessary to actually 
 dnl create the shared library
 dnl
-dnl V5_MAKE_SHARED_LIB(libname, version, libdir, dirname_relative_to_libdir)
+dnl V5_MAKE_SHARED_LIB(libname, version, libdir, dirname_relative_to_libdir,
+dnl		       lib_subdirs)
 dnl
 define(V5_MAKE_SHARED_LIB,[
 if test "[$]krb5_cv_staticlibs_enabled" = yes
@@ -927,53 +911,52 @@
 	SHLIB_STATIC_TARGET=
 	fi
 AC_ARG_ENABLE([shared],
-[  --enable-shared         build with shared libraries],[
-SHLIB_TAIL_COMP=$krb5_cv_shlibs_tail_comp
-AC_SUBST(SHLIB_TAIL_COMP)
-LD_UNRESOLVED_PREFIX=$krb5_cv_shlibs_sym_ufo
-AC_SUBST(LD_UNRESOLVED_PREFIX)
-LD_SHLIBDIR_PREFIX=$krb5_cv_shlibs_dirhead
-AC_SUBST(LD_SHLIBDIR_PREFIX)
-SHLIB_RPATH_DIRS=
-if test $krb5_cv_shlibs_use_dirs = yes ; then
+[  --enable-shared         build with shared libraries], ,enable_shared=no)
+if test "$enable_shared" != no ; then
+  SHLIB_TAIL_COMP=$krb5_cv_shlibs_tail_comp
+  AC_SUBST(SHLIB_TAIL_COMP)
+  LD_UNRESOLVED_PREFIX=$krb5_cv_shlibs_sym_ufo
+  AC_SUBST(LD_UNRESOLVED_PREFIX)
+  LD_SHLIBDIR_PREFIX=$krb5_cv_shlibs_dirhead
+  AC_SUBST(LD_SHLIBDIR_PREFIX)
+  SHLIB_RPATH_DIRS=
+  if test $krb5_cv_shlibs_use_dirs = yes ; then
 	if test $krb5_cv_shlibs_use_colon_dirs = yes ; then
-		SHLIB_RPATH_DIRS="${krb5_cv_shlibs_dirhead}$(KRB5_SHLIBDIR)"
+		SHLIB_RPATH_DIRS="${krb5_cv_shlibs_dirhead}\$(KRB5_SHLIBDIR)"
 	else
 		SHLIB_RPATH_DIRS="${krb5_cv_shlibs_dirhead}\$(KRB5_SHLIBDIR)"
 	fi
-fi
-AC_SUBST(SHLIB_RPATH_DIRS)
-SHLIB_LIBDIRS="-L\$(TOPLIBD)"
-if test X$krb5_cv_krb4_libdir != X ; then
+  fi
+  AC_SUBST(SHLIB_RPATH_DIRS)
+  SHLIB_LIBDIRS="-L\$(TOPLIBD)"
+  if test X$krb5_cv_krb4_libdir != X ; then
 	SHLIB_LIBDIRS="$SHLIB_LIBDIRS -L$krb5_cv_krb4_libdir"
-fi
-AC_SUBST(SHLIB_LIBDIRS)
-HOST_TYPE=$krb5_cv_host
-AC_SUBST(HOST_TYPE)
-if test "$krb5_cv_shlibs_ext" = ""; then
-  AC_MSG_ERROR(Library building info can't be determined by this lame configure
-script; try reconfiguring again from the top of the tree.)
-fi
-SHEXT=$krb5_cv_shlibs_ext
-AC_SUBST(SHEXT)
-STEXT=$krb5_cv_noshlibs_ext
-AC_SUBST(STEXT)
-if test "$krb5_cv_shlibs_versioned_filenames" = "yes" ; then
-VEXT=".$2" # Version of library goes in archive name
-if test "$krb5_cv_shlibs_need_nover" = yes; then
-	DO_MAKE_SHLIB="$1.\$""(SHEXT).$2 $1.\$""(SHEXT)"
-else
-	DO_MAKE_SHLIB="$1.\$""(SHEXT).$2"
-fi
-else # $krb5_cv_shlibs_versioned_filenames
-VEXT=
+  fi
+  AC_SUBST(SHLIB_LIBDIRS)
+  HOST_TYPE=$krb5_cv_host
+  AC_SUBST(HOST_TYPE)
+  if test "$krb5_cv_shlibs_ext" = ""; then
+    AC_MSG_ERROR(Library building info can't be determined by this lame configure
+	script; try reconfiguring again from the top of the tree.)
+  fi
+  SHEXT=$krb5_cv_shlibs_ext
+  AC_SUBST(SHEXT)
+  if test "$krb5_cv_shlibs_versioned_filenames" = "yes" ; then
+	VEXT=".$2" # Version of library goes in archive name
+	if test "$krb5_cv_shlibs_need_nover" = yes; then
+		DO_MAKE_SHLIB="$1.\$""(SHEXT).$2 $1.\$""(SHEXT)"
+	else
+		DO_MAKE_SHLIB="$1.\$""(SHEXT).$2"
+	fi
+  else # $krb5_cv_shlibs_versioned_filenames
+	VEXT=
 	DO_MAKE_SHLIB="$1.\$""(SHEXT)"
-fi
-AC_SUBST(VEXT)
-dnl export the version of the library....
-krb5_cv_shlib_version_$1=$2
-AC_SUBST(SHLIB_NAME)
-AC_PUSH_MAKEFILE()dnl
+  fi
+  AC_SUBST(VEXT)
+  dnl export the version of the library....
+  krb5_cv_shlib_version_$1=$2
+  AC_SUBST(SHLIB_NAME)
+  AC_PUSH_MAKEFILE()dnl
 
 all-unix:: [$](DO_MAKE_SHLIB) [$](SHLIB_STATIC_TARGET)
 
@@ -983,65 +966,73 @@
 $1.[$](SHEXT)$(VEXT): [$](LIBDONE) [$](DEPLIBS)
 	[$](BUILDTOP)/util/makeshlib [$]@	\
 		"[$](SHLIB_LIBDIRS)" \
-		"[$](SHLIB_LIBS)" "[$](SHLIB_LDFLAGS)" "$2" [$](LIB_SUBDIRS)
+		"[$](SHLIB_LIBS)" "[$](SHLIB_LDFLAGS)" "$2" [$](LIB_SUBDIRS) $5
 AC_POP_MAKEFILE()dnl
-if test "$krb5_cv_shlibs_versioned_filenames" = "yes" ; then
-LinkFile($1.[$](SHEXT),$1.[$](SHEXT).$2)
-fi
-],[
-STEXT=$krb5_cv_noshlibs_ext
-AC_SUBST(STEXT)
-DO_MAKE_SHLIB=
-AC_PUSH_MAKEFILE()
+  if test "$krb5_cv_shlibs_versioned_filenames" = "yes" ; then
+	LinkFile($1.[$](SHEXT),$1.[$](SHEXT).$2)
+  fi
+
+else # not shared
+
+  DO_MAKE_SHLIB=
+  AC_PUSH_MAKEFILE()
 all-unix:: [$](DO_MAKE_SHLIB) [$](SHLIB_STATIC_TARGET)
 
 clean-unix:: 
 	$(RM) $1.[$](STEXT)
 AC_POP_MAKEFILE()
-])dnl
+fi # not shared
 AC_SUBST(DO_MAKE_SHLIB)
 AC_SUBST(SHLIB_STATIC_TARGET)
+STEXT=$krb5_cv_noshlibs_ext
+AC_SUBST(STEXT)
+SHLIB_MODE=$krb5_cv_shlib_mode
+AC_SUBST(SHLIB_MODE)
 
 AC_ARG_ENABLE([shared],
-[  --enable-shared         build shared libraries],[
-# Note that even if we aren't installing versions of the library with
-# Version identifiers in the file name, we still need to make the links
-# in ${BUILDTOP}/lib for dependencies.
-# The following makes sure that the path of symlinks traces back to the real library; it is
-# not an error that $2 is used in some places and $VEXT in others.
-LinkFileDir($3/$1.[$](SHEXT).$2, $1.[$](SHEXT)[$](VEXT), $4)
-AppendRule([$3/$1.[$](SHEXT): $3/$1.[$](SHEXT).$2
+[  --enable-shared         build shared libraries], ,enable_shared=no)dnl
+if test "$enable_shared" != no; then
+  # Note that even if we aren't installing versions of the library with
+  # Version identifiers in the file name, we still need to make the links
+  # in ${BUILDTOP}/lib for dependencies.
+  # The following makes sure that the path of symlinks traces back to the real
+  # library; it is not an error that $2 is used in some places and $VEXT in
+  # others.
+  LinkFileDir($3/$1.[$](SHEXT).$2, $1.[$](SHEXT)[$](VEXT), $4)
+  AppendRule([$3/$1.[$](SHEXT): $3/$1.[$](SHEXT).$2
 	[$](RM) $3/$1.[$](SHEXT)
 	[$](LN) $1.[$](SHEXT).$2 $3/$1.[$](SHEXT)
 ])
-AppendRule(clean::[
+  AppendRule(clean::[
 	[$](RM) $3/$1.[$](SHEXT).$2 $3/$1.[$](SHEXT)
 ])
-if test "$krb5_cv_shlibs_need_nover" = "yes" ; then
-AppendRule([all-unix:: $3/$1.$(SHEXT).$2 $3/$1.$(SHEXT)])
-else
-AppendRule([all-unix:: $3/$1.$(SHEXT)[$](VEXT)])
-fi
-AppendRule([install::	$1.[$](SHEXT)[$](VEXT)
+  if test "$krb5_cv_shlibs_need_nover" = "yes" ; then
+	AppendRule([all-unix:: $3/$1.$(SHEXT).$2 $3/$1.$(SHEXT)])
+  else
+	AppendRule([all-unix:: $3/$1.$(SHEXT)[$](VEXT)])
+  fi
+  AppendRule([install-all install-kdc install-server install-client install::	$1.[$](SHEXT)[$](VEXT)
 	[$](RM) [$](DESTDIR)[$](KRB5_SHLIBDIR)[$](S)$1.[$](SHEXT)[$](VEXT)
-	[$](INSTALL_DATA) $1.[$](SHEXT)[$](VEXT)	\
+	[$](INSTALL_SHLIB) $1.[$](SHEXT)[$](VEXT)	\
 		[$](DESTDIR)[$](KRB5_SHLIBDIR)[$](S)$1.[$](SHEXT)[$](VEXT)
 ])
-if test "$krb5_cv_shlibs_need_nover" = "yes" ; then
-AppendRule([install::	$1.[$](SHEXT).$2
+  if test "$krb5_cv_shlibs_need_nover" = "yes" ; then
+    AppendRule([install-all install-kdc install-server install-client install::	$1.[$](SHEXT).$2
 	[$](RM) [$](DESTDIR)[$](KRB5_SHLIBDIR)[$](S)$1.[$](SHEXT)
 	[$](LN) $1.[$](SHEXT).$2 \
 		[$](DESTDIR)[$](KRB5_SHLIBDIR)[$](S)$1.[$](SHEXT)])
-])
+  fi
 fi
 if test -n "$krb5_cv_staticlibs_enabled" ; then
-        AppendRule([install:: $1.[$](STEXT)
+    AppendRule([install-all install-kdc install:: $1.[$](STEXT)
 	[$](INSTALL_DATA) $1.[$](STEXT) [$](DESTDIR)[$](KRB5_LIBDIR)[$](S)$1.[$](STEXT)
 	$(RANLIB) $(DESTDIR)$(KRB5_LIBDIR)[$](S)$1.[$](STEXT)])
-        LinkFileDir($3/$1.[$](STEXT),$1.[$](STEXT),$4)
-        AppendRule([all-unix:: $3/$1.[$](STEXT)])
+    LinkFileDir($3/$1.[$](STEXT),$1.[$](STEXT),$4)
+    AppendRule([all-unix:: $3/$1.[$](STEXT)])
 fi
 ])dnl
+dnl In case USE_SHARED_LIBS isn't used.
+AC_SUBST(SHLIB_EXTRA_DEPS)dnl
 dnl
 dnl Defines LDARGS correctly so that we actually link with the shared library
 dnl
@@ -1059,136 +1050,22 @@
 	if test "$krb5_cv_exe_need_dirs" = yes; then
 		LDARGS="$LDARGS ${krb5_cv_shlibs_dirhead}\$(KRB5_SHLIBDIR)"
 	fi
+	SHLIB_EXTRA_DEPS=$krb5_cv_shlib_extra_deps
 	SHLIB_TAIL_COMP=$krb5_cv_shlibs_tail_comp
 	AC_SUBST(SHLIB_TAIL_COMP)
   else
 	AC_MSG_RESULT(Using archive libraries)
 	LDARGS="$krb5_cv_noshlibs_ldflag -L\$(TOPLIBD) $LDARGS"
+	SHLIB_EXTRA_DEPS=
   fi
 else
   LDARGS="-L\$(TOPLIBD) $LDARGS"
 fi
 AC_SUBST(LDARGS)
+AC_SUBST(SHLIB_EXTRA_DEPS)
 ])dnl
 dnl
 dnl
-dnl Database determination
-dnl
-dnl
-dnl Check for missing DBM prototypes
-dnl
-AC_DEFUN(AC_CHECK_DBM_PROTO,[
- AC_MSG_CHECKING([for missing $2 prototype])
- AC_CACHE_VAL(krb5_cv_missing_$2_prototype,
-  AC_EGREP_HEADER([$2], [$1.h],
-   eval krb5_cv_missing_$2_prototype=no,
-   AC_TRY_LINK(
-[#include <$1.h>
-int $2();],
-[$2();], $4
-    eval krb5_cv_missing_$2_prototype=yes,
-    $3
-    eval krb5_cv_missing_$2_prototype=no)))
- if eval "test \"`echo '$krb5_cv_missing_'$1_prototype`\" = yes"; then
-  AC_MSG_RESULT(yes)
- else
-  AC_MSG_RESULT(no)
- fi
-])dnl
-dnl
-dnl
-dnl --with-aname-db=[dbm type]
-dnl --with-aname-dbopts=[compile flags]
-dnl
-dnl --with-kdb-db=[dbm type]
-dnl --with-kdb-dbopts=[compile flags]
-dnl
-dnl
-define(WITH_ANAME_DB,[
-AC_ARG_WITH([aname-db],
-[  --with-aname-db=DBM     name conversion database type],
-dbval="$withval",
-dbval=
-)dnl
-AC_ARG_WITH([aname-dbopts],
-[  --with-aname-dbopts=CCOPTS  compilation flags],
-dbflags="$withval",
-)dnl
-CHECK_DB
-CPPFLAGS="$CPPFLAGS $dbflags"
-AC_MSG_RESULT(Using $dbval for name conversion database.)
-])dnl
-dnl
-dnl
-dnl
-define(WITH_KDB_DB,[
-AC_ARG_WITH([kdb-db],
-[  --with-kdb-db=DBM       kerberos database type],
-dbval="$withval",
-dbval=
-)dnl
-AC_ARG_WITH([kdb-dbopts],
-[  --with-kdb-dbopts=CCOPTS  compilation flags],
-dbflags="$withval",
-)dnl
-CHECK_DB
-CPPFLAGS="$CPPFLAGS $dbflags"
-AC_MSG_RESULT(Using $dbval for kerberos database.)
-])dnl
-dnl
-dnl
-define(CHECK_DB,[
-if test "$dbval" = "" -o "$dbval" = ndbm; then
-	OLIBS="$LIBS"
-	AC_HEADER_CHECK(ndbm.h,[dbval=ndbm
-	  AC_CHECK_FUNC(dbm_nextkey,,
-	    AC_CHECK_LIB(ndbm,dbm_nextkey,[dblibs=-lndbm],
-	      AC_CHECK_LIB(dbm,dbm_nextkey,[dblibs=-ldbm],
-		AC_CHECK_LIB(gdbm,dbm_nextkey,[dblibs=-lgdbm]))))
-	  AC_DEFINE(NDBM)
-	  AC_CHECK_DBM_PROTO($dbval,dbm_error,,
-		AC_DEFINE(MISSING_ERROR_PROTO))
-	  AC_CHECK_DBM_PROTO($dbval,dbm_clearerr,,
-		AC_DEFINE(MISSING_CLEARERR_PROTO))])
-	LIBS="$OLIBS"
-fi
-if test "$dbval" = "" -o "$dbval" = dbm; then
-	OLIBS="$LIBS"
-	AC_HEADER_CHECK(dbm.h,[dbval=dbm
-	  AC_CHECK_FUNC(nextkey,,
-	    AC_CHECK_LIB(dbm,dbm_nextkey,[dblibs=-ldbm]))
-	  AC_DEFINE(ODBM)
-	  AC_CHECK_DBM_PROTO($dbval,dbm_error,,
-		AC_DEFINE(MISSING_ERROR_PROTO))
-	  AC_CHECK_DBM_PROTO($dbval,dbm_clearerr,,
-		AC_DEFINE(MISSING_CLEARERR_PROTO))])
-	LIBS="$OLIBS"
-fi
-if test "$dbval" = "" -o "$dbval" = db; then
-	dbval=db
-	dblibs=-ldb
-	AC_DEFINE(BERK_DB_DBM)
-fi
-])dnl
-dnl
-dnl
-dnl
-dnl
-AC_DEFUN(WITH_KDB4,[
-AC_ARG_WITH([kdb4],
-[  --with-kdb4		use Kerberos version 4 database library.
-  --without-kdb4	Avoid using Kerberos version 4 database library.],
-,
-withval=no)dnl
-if test "$withval" = no; then
-$2
-:
-else
-$1
-:
-fi
-])dnl
-dnl
 dnl Check for prototype support - used by application not including k5-int.h
 dnl
 define(KRB5_CHECK_PROTOS,[
@@ -1273,3 +1150,224 @@
 fi
 AC_SUBST(KRB5_RUN_ENV)
 ])dnl
+dnl
+dnl figure out how many arguments gettimeofday has. 
+dnl
+define(KRB5_GETTIMEOFDAY_ARGS,[
+AC_TIME_WITH_SYS_TIME
+AC_CHECK_HEADERS(sys/time.h)
+AC_MSG_CHECKING([whether gettimeofday will accept two arguments])
+AC_CACHE_VAL(krb5_cv_gettimeofday_twoargs,
+[AC_TRY_COMPILE([#if TIME_WITH_SYS_TIME
+#include <sys/time.h>
+#include <time.h>
+#else
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif
+#endif
+],
+[struct timezone z; struct timeval v; gettimeofday(&v,&z);],
+krb5_cv_gettimeofday_twoargs=yes,krb5_cv_gettimeofday_twoargs=no)])
+AC_MSG_RESULT($krb5_cv_gettimeofday_twoargs)
+if test $krb5_cv_gettimeofday_twoargs = yes; then
+AC_DEFINE(KRB5_GETTIMEOFDAY_TWOARGS)
+fi
+])dnl
+dnl
+dnl BEGIN CYGNUS LOCAL: Added Tcl and Tk analysis
+dnl
+dnl
+dnl
+dnl AC_KRB5_TCL - determine if the TCL library is present on system
+dnl
+AC_DEFUN(AC_KRB5_TCL,[
+tcl_inc=
+tcl_lib=
+TCL_WITH=
+AC_ARG_WITH(tcl,
+[  --with-tcl=path         where TCL resides],
+        TCL_WITH=$withval
+        if test "$withval" != yes -a "$withval" != no ; then
+                tcl_lib=$withval/lib
+        fi)
+tcl_found=no
+tcl_search_dirs="$exec_prefix/lib /usr/local/lib /usr/lib"
+AC_MSG_CHECKING(Tcl location)
+if test -d ${SRCTOP}/support/tcl; then tclsupport=yes; else tclsupport=no; fi
+if test "$with_tcl" = no ; then
+    tcl_found=no
+    AC_MSG_RESULT(disabled by command line option)
+elif (test "$with_tcl" = "" || test "$with_tcl" = yes) && test $tclsupport = yes ; then
+    # Pull from build tree.  Yuck!
+    if test ! -r ${BUILDTOP}/support/tcl/unix/tclConfig.sh ; then
+	AC_MSG_ERROR(Can't find tclConfig.sh in build tree.)
+    fi
+    tcl_lib=${BUILDTOP}/support/tcl/unix
+    . ${BUILDTOP}/support/tcl/unix/tclConfig.sh
+    AC_MSG_RESULT(in build tree)
+    tcl_found=yes
+
+    KRB5_TCL_LIBS="${TCL_BUILD_LIB_SPEC} ${TCL_LIBS}"
+    KRB5_TCL_INC="-I${SRCTOP}/support/tcl/generic"
+    TCL_LIB="$KRB5_TCL_LIBS"
+    TCL_DEPLIB=${BUILDTOP}/support/tcl/unix/${TCL_LIB_FILE}
+    KRB5_TCL_FOUND=tcl
+elif (test "$with_tcl" = "" || test "$with_tcl" = yes) && test $tclsupport = no ; then
+    for i in $tcl_search_dirs ; do
+	if test -r $i/tclConfig.sh ; then
+	    tcl_lib=$i
+	    tcl_found=yes
+	    break
+	fi
+    done
+    if test $tcl_found = no ; then
+	if test "$with_tcl" = yes ; then
+	    AC_MSG_ERROR(not found)
+	else
+	    AC_MSG_WARN(not found)
+	fi
+    else
+	. $tcl_lib/tclConfig.sh
+	AC_MSG_RESULT(found $tcl_lib/tclConfig.sh)
+    fi
+else # with_tcl is neither yes nor no -- a pathname was given
+    if test ! -r $with_tcl/lib/tclConfig.sh ; then
+	AC_MSG_ERROR(Can't find $with_tcl/lib/tclConfig.sh)
+    fi
+    tcl_lib=$with_tcl/lib
+    . $tcl_lib/tclConfig.sh
+    AC_MSG_RESULT(found $tcl_lib/tclConfig.sh)
+    tcl_found=yes
+    tclsupport=no # ignore it
+fi
+if test "$tcl_found/$tclsupport" = "yes/no" ; then
+	if test -f "$TCL_PREFIX/include/tcl.h" ; then
+		# any normal Tcl installation
+		tcl_inc="$TCL_PREFIX/include"
+	elif test -f "$TCL_PREFIX/include/tcl/tcl.h" ; then
+		# Linux Debian
+		tcl_inc="$TCL_PREFIX/include/tcl"
+	else
+		AC_MSG_WARN(Found tclConfig.sh but not tcl.h.)
+		tcl_found=no
+	fi
+	KRB5_TCL_LIBS="$TCL_LIB_SPEC $TCL_LIBS"
+	KRB5_TCL_INC="-I$tcl_inc"
+	TCL_LIB=$KRB5_TCL_LIBS
+	TCL_DEPLIB=
+fi
+if test "$tcl_found" = yes; then
+    AC_SUBST(KRB5_TCL_LIBS)
+    AC_SUBST(KRB5_TCL_INC)
+    KRB5_TCL_FOUND=tcl
+    AC_SUBST(KRB5_TCL_FOUND)
+    AC_MSG_CHECKING(Tcl configuration)
+    AC_MSG_RESULT(version: TCL $TCL_VERSION.$TCL_PATCH_LEVEL)
+fi
+])dnl end of AC_KRB5_TCL
+dnl
+dnl
+dnl AC_KRB5_TK - determine if the TK library is present on system
+dnl
+AC_DEFUN(AC_KRB5_TK,[
+AC_REQUIRE([AC_KRB5_TCL])
+tk_inc=
+tk_lib=
+AC_ARG_WITH(tk,
+[  --with-tk=path         where TK resides],
+        if test "$withval" != yes -a "$withval" != no ; then
+                tk_lib=$withval/lib
+        fi)
+if test $tcl_found = no && test "$with_tk" != "" && test "$with_tk" != no ; then
+    AC_MSG_ERROR(Tk cannot be required when Tcl is not available)
+fi
+tk_found=no
+tk_search_dirs="$tcl_lib $exec_prefix/lib /usr/local/lib /usr/lib"
+AC_MSG_CHECKING(Tk location)
+if test -d ${SRCTOP}/support/tk ; then tksupport=yes ; else tksupport=no ; fi
+if test "$with_tk" = no ; then
+    tk_found=no
+    AC_MSG_RESULT(disabled by command line option)
+elif (test "$with_tk" = "" || test "$with_tk" = yes) && test $tksupport = yes ; then
+    # Pull from build tree.  Yuck!
+    if test ! -r ${BUILDTOP}/support/tk/unix/tkConfig.sh ; then
+	AC_MSG_ERROR(Can't find tkConfig.sh in build tree.)
+    fi
+    tk_lib=${BUILDTOP}/support/tk/unix
+    . ${BUILDTOP}/support/tk/unix/tkConfig.sh
+    AC_MSG_RESULT(in build tree)
+    tk_found=yes
+
+    KRB5_TK_LIBS="${TK_BUILD_LIB_SPEC} ${TK_LIBS}"
+    KRB5_TK_INC="-I${SRCTOP}/support/tk/generic"
+    KRB5_TK_INC="$KRB5_TK_INC ${TK_XINCLUDES}"
+    KRB5_TK_LIBS="$KRB5_TK_LIBS ${TK_XLIBSW}"
+    TK_LIB="$KRB5_TK_LIBS"
+    TK_DEPLIB=${BUILDTOP}/support/tk/unix/${TK_LIB_FILE}
+    KRB5_TK_FOUND=tk
+elif (test "$with_tk" = "" || test "$with_tk" = yes) && test $tksupport = no ; then
+    for i in $tk_search_dirs ; do
+	if test -r $i/tkConfig.sh ; then
+	    tk_lib=$i
+	    tk_found=yes
+	    break
+	fi
+    done
+    if test $tk_found = no ; then
+	if test "$with_tk" = yes ; then
+	    AC_MSG_ERROR(not found)
+	else
+	    AC_MSG_WARN(not found)
+	fi
+    else
+	. $tk_lib/tkConfig.sh
+	AC_MSG_RESULT(found $tk_lib/tkConfig.sh)
+    fi
+else # with_tk is neither yes nor no -- a pathname was given
+    if test ! -r $with_tk/lib/tkConfig.sh ; then
+	AC_MSG_ERROR(Can't find $with_tk/lib/tkConfig.sh)
+    fi
+    tk_lib=$with_tk/lib
+    . $tk_lib/tkConfig.sh
+    AC_MSG_RESULT(found $tk_lib/tkConfig.sh)
+    tk_found=yes
+    tksupport=no # ignore it
+fi
+if test "$tk_found/$tksupport" = "yes/no" ; then
+	if test -f "$TK_PREFIX/include/tk.h" ; then
+		# any normal Tk installation
+		tk_inc="$TK_PREFIX/include"
+	elif test -f "$TK_PREFIX/include/tcl/tk.h" ; then
+		# Linux Debian
+		tk_inc="$TK_PREFIX/include/tcl"
+	else
+		AC_MSG_WARN(Found tkConfig.sh but not tk.h.)
+		tk_found=no
+	fi
+	KRB5_TK_LIBS="$TK_LIB_SPEC $TK_LIBS"
+	KRB5_TK_INC="-I$tk_inc $TK_XINCLUDES"
+
+	AC_SUBST(KRB5_TK_LIBS)
+	AC_SUBST(KRB5_TK_INC)
+
+	KRB5_TK_FOUND=tk
+	AC_SUBST(KRB5_TK_FOUND)
+fi
+
+if test "$tcl_found$tk_found" = "yesyes" ; then
+	AC_MSG_CHECKING(Tk configuration)
+
+	dnl
+	dnl It is assumed that tcl and tk are properly installed and fully
+	dnl functional if we got to this point, so no further checks
+	dnl are made.
+	dnl
+
+	AC_MSG_RESULT(version: TK $TK_VERSION.$TK_PATCH_LEVEL)
+fi
+])dnl end of AC_KRB5_TK
+dnl
+dnl END CYGNUS LOCAL
