Fix memory leak in gss_krb5int_copy_ccache
[krb5.git] / src / configure.in
index 74985522dda256820e6cb8e7627971cf3d93e211..8777e20def46532f2c192835a2a8f5f67b59e2a7 100644 (file)
@@ -14,6 +14,39 @@ dnl
 dnl
 AC_REQUIRE_CPP
 dnl
+AC_CACHE_CHECK(if va_copy is available, krb5_cv_va_copy,
+[AC_LINK_IFELSE([
+#include <stdarg.h>
+void f(va_list ap) {
+  va_list ap2;
+  va_copy(ap2, ap);
+  va_end(ap2);
+}
+va_list x;
+int main()
+{
+  f(x);
+  return 0;
+}], krb5_cv_va_copy=yes, krb5_cv_va_copy=no)])
+if test "$krb5_cv_va_copy" = yes; then
+  AC_DEFINE(HAS_VA_COPY,1,[Define if va_copy macro or function is available.])
+fi
+dnl
+dnl Note that this isn't checking if the copied value *works*, just
+dnl whether the C language constraints permit the copying.  If
+dnl va_list is defined as an array type, it can't be assigned.
+AC_CACHE_CHECK(if va_list objects can be copied by assignment,
+              krb5_cv_va_simple_copy,
+[AC_COMPILE_IFELSE([
+#include <stdarg.h>
+void f(va_list va2) {
+  va_list va1;
+  va1 = va2;
+}], krb5_cv_va_simple_copy=yes, krb5_cv_va_simple_copy=no)])
+if test "$krb5_cv_va_simple_copy" = yes; then
+  AC_DEFINE(CAN_COPY_VA_LIST,1,[Define if va_list objects can be simply copied by assignment.])
+fi
+dnl
 dnl The following lines are so that configure --help gives some global 
 dnl configuration options.
 dnl
@@ -22,26 +55,12 @@ AC_KRB5_TCL
 AC_ARG_ENABLE([athena],
 [  --enable-athena         build with MIT Project Athena configuration],,)
 dnl
-if test -z "$KRB4_LIB"; then
-kadminv4=""
-krb524=""
-libkrb4=""
-KRB4=""
-else
-kadminv4=kadmin.v4
-krb524=krb524
-libkrb4=lib/krb4
-KRB4=krb4
-fi
-AC_SUBST(KRB4)
-AC_SUBST(krb524)
-dnl
 dnl Begin autoconf tests for the Makefiles generated out of the top-level
 dnl configure.in...
 dnl
 AC_CHECK_FUNCS(memmove)
 KRB5_BUILD_LIBOBJS
-KRB5_BUILD_LIBRARY_WITH_DEPS
+KRB5_BUILD_LIBRARY
 KRB5_BUILD_PROGRAM
 dnl for slave
 AC_TYPE_MODE_T
@@ -56,7 +75,23 @@ LIBUTIL=-lutil
 AC_SUBST(LIBUTIL)
 dnl for kdc
 AC_CHECK_HEADERS(syslog.h stdarg.h sys/select.h sys/sockio.h ifaddrs.h unistd.h)
-AC_CHECK_FUNCS(openlog syslog closelog strftime vsprintf)
+AC_CHECK_FUNCS(openlog syslog closelog strftime vsprintf vasprintf vsnprintf)
+AC_CHECK_FUNCS(strlcpy)
+EXTRA_SUPPORT_SYMS=
+AC_CHECK_FUNC(strlcpy, [STRLCPY_ST_OBJ= STRLCPY_OBJ=], [STRLCPY_ST_OBJ=strlcpy.o STRLCPY_OBJ='$(OUTPRE)strlcpy.$(OBJEXT)' EXTRA_SUPPORT_SYMS="$EXTRA_SUPPORT_SYMS krb5int_strlcpy krb5int_strlcat"])
+AC_SUBST(STRLCPY_OBJ)
+AC_SUBST(STRLCPY_ST_OBJ)
+AC_CHECK_FUNC(vasprintf,
+[PRINTF_ST_OBJ=
+PRINTF_OBJ=],
+[PRINTF_ST_OBJ=printf.o
+PRINTF_OBJ='$(OUTPRE)printf.$(OBJEXT)'
+EXTRA_SUPPORT_SYMS="$EXTRA_SUPPORT_SYMS krb5int_asprintf krb5int_vasprintf"])
+AC_SUBST(PRINTF_OBJ)
+AC_SUBST(PRINTF_ST_OBJ)
+KRB5_NEED_PROTO([#include <stdarg.h>
+#include <stdio.h>
+],vasprintf)
 KRB5_NEED_PROTO([#include <string.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -64,6 +99,7 @@ KRB5_NEED_PROTO([#include <string.h>
 /* Solaris 8 declares swab in stdlib.h.  */
 #include <stdlib.h>
 ],swab,1)
+KRB5_NEED_PROTO([#include <ctype.h>],isblank,1)
 dnl
 AC_PROG_AWK
 KRB5_AC_INET6
@@ -79,6 +115,16 @@ if test "$withval" = yes; then
        AC_DEFINE(KRBCONF_VAGUE_ERRORS,1,[Define if the KDC should return only vague error codes to clients])
 fi
 dnl
+dnl WITH_CRYPTO_IMPL
+dnl
+CRYPTO_IMPL="builtin"
+AC_ARG_WITH([crypto-impl],
+AC_HELP_STRING([--with-crypto-impl=IMPL], [use specified crypto implementation @<:@builtin@:>@]),
+[CRYPTO_IMPL=$withval
+AC_MSG_RESULT("k5crypto will use \'$withval\'")
+], withval=builtin)dnl
+AC_SUBST(CRYPTO_IMPL)
+dnl
 dnl --with-kdc-kdb-update makes the KDC update the database with last request
 dnl information and failure information.
 dnl
@@ -108,31 +154,92 @@ if test "$enableval" = yes ; then
 else
        AC_DEFINE(NOCACHE,1,[Define if the KDC should use no replay cache])
 fi
-AC_ARG_ENABLE([fakeka],
-AC_HELP_STRING([--enable-fakeka],[build the Fake KA server (emulates an AFS kaserver) @<:@default: don't build@:>@]), , enableval=no)dnl
-if test "$enableval" = yes; then
-       FAKEKA=fakeka
-else
-       FAKEKA=
-fi
-AC_SUBST(FAKEKA)
 KRB5_RUN_FLAGS
 dnl
-dnl for krb524
 AC_TYPE_SIGNAL
 dnl
 dnl from old include/configure.in
 AH_TEMPLATE([HAVE_STRUCT_SOCKADDR_STORAGE], 
 [Define if "struct sockaddr_storage" is available.])
 dnl
-AC_CONFIG_HEADER(include/krb5/autoconf.h)
+AC_CONFIG_HEADERS(include/autoconf.h, [echo timestamp > include/autoconf.stamp])
 AC_PROG_INSTALL
 AC_PROG_AWK
 AC_PROG_LEX
 AC_C_CONST
-AC_CHECK_FUNCS(strdup setvbuf inet_ntoa inet_aton seteuid setresuid setreuid setegid setresgid setregid setsid flock fchmod chmod strftime strptime geteuid setenv unsetenv getenv gethostbyname2 getifaddrs gmtime_r localtime_r pthread_mutex_lock sched_yield dlopen bswap16 bswap64 mkstemp)
+AC_HEADER_DIRENT
+AC_CHECK_FUNCS(strdup setvbuf inet_ntoa inet_aton seteuid setresuid setreuid setegid setresgid setregid setsid flock fchmod chmod strftime strptime geteuid setenv unsetenv getenv gethostbyname2 getifaddrs gmtime_r localtime_r pthread_mutex_lock sched_yield bswap16 bswap64 mkstemp getusershell lstat access ftime getcwd srand48 srand srandom stat strchr strerror strerror_r strstr timezone umask waitpid sem_init sem_trywait daemon)
+dnl
+AC_CHECK_FUNC(mkstemp,
+[MKSTEMP_ST_OBJ=
+MKSTEMP_OBJ=],
+[MKSTEMP_ST_OBJ='mkstemp.o'
+MKSTEMP_OBJ='$(OUTPRE)mkstemp.$(OBJEXT)'
+EXTRA_SUPPORT_SYMS="$EXTRA_SUPPORT_SYMS krb5int_mkstemp"])
+AC_SUBST(MKSTEMP_OBJ)
+AC_SUBST(MKSTEMP_ST_OBJ)
+AC_SUBST(EXTRA_SUPPORT_SYMS)
+dnl
 AC_HEADER_STDARG
-AC_CHECK_HEADERS(unistd.h paths.h regex.h regexp.h regexpr.h fcntl.h memory.h ifaddrs.h sys/filio.h sched.h byteswap.h machine/endian.h machine/byte_order.h sys/bswap.h endian.h)
+DECLARE_SYS_ERRLIST
+AC_CHECK_HEADERS(unistd.h paths.h regex.h regexpr.h fcntl.h memory.h ifaddrs.h sys/filio.h sched.h byteswap.h machine/endian.h machine/byte_order.h sys/bswap.h endian.h pwd.h arpa/inet.h alloca.h dlfcn.h limits.h pthread.h semaphore.h krb_db.h kdc.h)
+AC_CHECK_HEADER(regexp.h, [], [],
+[#define INIT char *sp = instring;
+#define GETC() (*sp++)
+#define PEEKC() (*sp)
+#define UNGETC(c) (--sp)
+#define RETURN(c) return(c)
+#define ERROR(c)
+])
+AC_CHECK_MEMBERS([struct sockaddr_in.sin_len, struct sockaddr.sa_len], , ,
+  [#include <sys/types.h>
+#include <netinet/in.h>])
+AC_CHECK_MEMBERS([struct stat.st_mtimensec,struct stat.st_mtimespec.tv_nsec,struct stat.st_mtim.tv_nsec],,,[#include <sys/types.h>
+#include <sys/stat.h>])
+KRB5_AC_REGEX_FUNCS
+AC_TYPE_OFF_T
+dnl
+dnl Fancy caching of perror result...
+AC_MSG_CHECKING(for perror declaration)
+AC_CACHE_VAL(krb5_cv_decl_perror,
+[AC_EGREP_HEADER(perror, errno.h, 
+  krb5_cv_decl_perror=yes, krb5_cv_decl_perror=no)])dnl
+AC_MSG_RESULT($krb5_cv_decl_perror)
+if test $krb5_cv_decl_perror = yes; then
+       AC_DEFINE(HDR_HAS_PERROR,1,[Define if errno.h declares perror])
+fi
+dnl
+KRB5_NEED_PROTO([#include <time.h>],strptime)
+CHECK_WAIT_TYPE
+CHECK_SIGPROCMASK
+AC_TYPE_GETGROUPS
+CHECK_SETJMP
+dnl
+dnl *rpcent return types needed for lib/rpc
+dnl
+AC_MSG_CHECKING([return type of setrpcent])
+AC_CACHE_VAL(k5_cv_type_setrpcent,
+[AC_TRY_COMPILE([#include <netdb.h>
+#ifdef __cplusplus
+extern "C"
+#endif
+extern void setrpcent();],
+[int i;], k5_cv_type_setrpcent=void, k5_cv_type_setrpcent=int)])dnl
+AC_MSG_RESULT($k5_cv_type_setrpcent)
+AC_DEFINE_UNQUOTED(SETRPCENT_TYPE, $k5_cv_type_setrpcent, [Define as return type of setrpcent])
+dnl
+AC_MSG_CHECKING([return type of endrpcent])
+AC_CACHE_VAL(k5_cv_type_endrpcent,
+[AC_TRY_COMPILE([#include <netdb.h>
+#ifdef __cplusplus
+extern "C"
+#endif
+extern void endrpcent();],
+[int i;], k5_cv_type_endrpcent=void, k5_cv_type_endrpcent=int)])dnl
+AC_MSG_RESULT($k5_cv_type_endrpcent)
+AC_DEFINE_UNQUOTED(ENDRPCENT_TYPE, $k5_cv_type_endrpcent, [Define as return type of endrpcent])
+dnl
+dnl
 dnl bswap_16 is a macro in byteswap.h under GNU libc
 AC_MSG_CHECKING(for bswap_16)
 AC_CACHE_VAL(krb5_cv_bswap_16,[
@@ -153,6 +260,26 @@ if test "$krb5_cv_bswap_64" = yes; then
   AC_DEFINE(HAVE_BSWAP_64,1,[Define to 1 if bswap_64 is available via byteswap.h])
 fi
 dnl
+dnl Needed for ksu and some appl stuff.
+dnl
+case $krb5_cv_host in
+alpha*-dec-osf*)
+       AC_CHECK_LIB(security,setluid,
+               AC_DEFINE(HAVE_SETLUID,1,[Define if setluid provided in OSF/1 security library])
+               KSU_LIBS="-lsecurity"
+       )
+       ;;
+esac
+AC_SUBST(KSU_LIBS)
+dnl
+if test $ac_cv_func_setenv = no || test $ac_cv_func_unsetenv = no \
+  || test $ac_cv_func_getenv = no; then
+  SETENVOBJ=setenv.o
+else
+  SETENVOBJ=
+fi
+AC_SUBST(SETENVOBJ)
+dnl
 dnl Check what the return types for gethostbyname_r and getservbyname_r are.
 dnl
 AC_CHECK_FUNC(gethostbyname_r,[
@@ -320,7 +447,7 @@ AC_CHECK_HEADER(termios.h,dnl
   AC_DEFINE(POSIX_TERMIOS,1,[Define if termios.h exists and tcsetattr exists]))])
 dnl
 KRB5_SIGTYPE
-AC_CHECK_HEADERS(stdlib.h string.h stddef.h unistd.h sys/types.h sys/file.h sys/param.h sys/stat.h sys/time.h netinet/in.h sys/uio.h sys/filio.h sys/select.h time.h paths.h)
+AC_CHECK_HEADERS(stdlib.h string.h stddef.h sys/types.h sys/file.h sys/param.h sys/stat.h sys/time.h netinet/in.h sys/uio.h sys/filio.h sys/select.h time.h paths.h errno.h)
 AC_HEADER_STDARG
 KRB5_AC_INET6
 dnl
@@ -371,11 +498,6 @@ if test $krb5_cv_has_ansi_stdio = yes; then
 AC_DEFINE(ANSI_STDIO,1,[Define if ANSI stdio is present (in particular "b" option to fopen)])
 fi
 dnl
-dnl Word sizes...
-AC_CHECK_SIZEOF(short)
-AC_CHECK_SIZEOF(int)
-AC_CHECK_SIZEOF(long)
-dnl
 dnl then from osconf.h, we have
 dnl
 AC_HEADER_TIME
@@ -451,37 +573,18 @@ AC_ARG_ENABLE([athena],
 [  --enable-athena         build with MIT Project Athena configuration],
 AC_DEFINE(KRB5_ATHENA_COMPAT,1,[Define if MIT Project Athena default configuration should be used]),)
 
-if test "$KRB4_LIB" = ''; then
-       AC_MSG_NOTICE(No Kerberos 4 compatibility)
-       maybe_kerberosIV=
-else
-       AC_MSG_NOTICE(Kerberos 4 compatibility enabled)
-       maybe_kerberosIV=kerberosIV
-       AC_DEFINE(KRB5_KRB4_COMPAT,1,[Define if Kerberos V4 backwards compatibility should be supported])
-fi
-AC_SUBST(maybe_kerberosIV)
 dnl
 AC_C_INLINE
 AH_TOP([
 #ifndef KRB5_AUTOCONF_H
-/* Leading comment stops autoconf/config.status from turning these
-   into #define statements.  But the preprocessor will still pay
-   attention to them.  (Comment removal is in translation phase 3;
-   processing of #undef is phase 4.)  */
-/*x*/#undef PACKAGE_NAME
-/*x*/#undef PACKAGE_VERSION
-/*x*/#undef PACKAGE_BUGREPORT
-/*x*/#undef PACKAGE_STRING
-/*x*/#undef PACKAGE_TARNAME
+#define KRB5_AUTOCONF_H
 ])
 AH_BOTTOM([
 #if defined(__GNUC__) && !defined(inline)
 /* Silence gcc pedantic warnings about ANSI C.  */
 # define inline __inline__
 #endif
-
-#define KRB5_AUTOCONF_H
-#endif
+#endif /* KRB5_AUTOCONF_H */
 ])
 dnl
 dnl Not used yet, but let's find out what we've got on the platforms
@@ -494,6 +597,351 @@ AC_CHECK_TYPES([uint32_t, int32_t, uint64_t, int64_t, uint_least32_t, uintptr_t,
 # include <inttypes.h>
 #endif
 ])
+AC_CHECK_TYPES([struct cmsghdr, struct in_pktinfo, struct in6_pktinfo, struct sockaddr_storage], , , [
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+])
+AC_CHECK_TYPES([struct rt_msghdr], , , [
+#include <sys/socket.h>
+#include <net/if.h>
+#include <net/route.h>
+])
+dnl
+dnl stuff for util/profile
+dnl
+dnl AC_KRB5_TCL already done
+DO_TCL=
+test "$TCL_LIBS" != "" && DO_TCL=ok
+AC_SUBST(DO_TCL)
+dnl
+dnl types libdb2 wants
+dnl
+AC_CHECK_TYPES([ssize_t, u_char, u_int, u_long, u_int8_t, u_int16_t, u_int32_t, int8_t, int16_t, int32_t])
+dnl
+dnl Some libdb2 test programs want a shell that supports functions.
+FCTSH=false
+AC_PATH_PROG(SH,sh,false)
+AC_PATH_PROG(SH5,sh5,false)
+AC_PATH_PROG(BASH,bash,false)
+for prog in $SH $SH5 $BASH; do
+  AC_MSG_CHECKING(if $prog supports functions)
+  if $prog -c 'foo() { true; }; foo' >/dev/null 2>&1; then
+    AC_MSG_RESULT(yes)
+    FCTSH=$prog
+    break
+  else
+    AC_MSG_RESULT(no)
+  fi
+done
+AC_SUBST(FCTSH)
+dnl
+dnl Test for POSIX 2001 *printf support (X/Open System Interfaces extension
+dnl to ANSI/ISO C 1999 specification).  Specifically, positional
+dnl specifications; not checking for other features like %zx at present.
+AC_MSG_CHECKING(for POSIX printf positional specification support)
+AC_CACHE_VAL(ac_cv_printf_positional,[
+AC_TRY_RUN([
+#include <stdio.h>
+#include <string.h>
+const char expected[] = "200 100";
+int main () {
+    char buf[30];
+    sprintf(buf, "%2\$x %1\$d", 100, 512);
+    if (strcmp(expected, buf)) {
+       fprintf(stderr,"bad result: <%s> wanted: <%s>\n", buf, expected);
+       return 1;
+    }
+    return 0;
+}],
+  ac_cv_printf_positional=yes,
+  ac_cv_printf_positional=no,
+  AC_MSG_ERROR([Cannot test for printf positional argument support when cross compiling]))])
+dnl Nothing for autoconf.h for now.
+AC_MSG_RESULT($ac_cv_printf_positional)
+dnl
+dnl
+dnl for kadmin
+dnl
+AC_PROG_YACC
+ath_compat=
+AC_ARG_ENABLE([athena],
+[  --enable-athena         build with MIT Project Athena configuration],
+ath_compat=compat,)
+dnl The following are tests for the presence of programs required for
+dnl kadmin testing.
+AC_CHECK_PROG(have_RUNTEST,runtest,runtest)
+AC_CHECK_PROG(have_PERL,perl,perl)
+AC_KRB5_TCL    
+if test "$have_PERL" = perl -a "$have_RUNTEST" = runtest -a "$TCL_LIBS" != ""; then
+       DO_TEST=ok
+fi
+AC_SUBST(DO_TEST) 
+dnl
+dnl The following are substituted into kadmin/testing/scripts/env-setup.sh
+RBUILD=`pwd`
+AC_SUBST(RBUILD)
+case "$srcdir" in
+/*)    S_TOP=$srcdir ;;
+*)     S_TOP=`pwd`/$srcdir ;;
+esac
+AC_SUBST(S_TOP)
+AC_PATH_PROG(PERL_PATH,perl)
+AC_PATH_PROG(EXPECT,expect)
+dnl For kadmin/testing/util/Makefile.in
+if test "$TCL_LIBS" != "" ;  then
+       DO_ALL=tcl
+fi
+AC_SUBST(DO_ALL)
+KRB5_AC_PRIOCNTL_HACK
+K5_GEN_FILE(kadmin/testing/scripts/env-setup.sh:kadmin/testing/scripts/env-setup.shin)
+dnl for lib/kadm5
+AC_CHECK_PROG(RUNTEST,runtest,runtest)
+AC_CHECK_PROG(PERL,perl,perl)
+dnl
+dnl lib/gssapi
+AC_CHECK_HEADER(stdint.h,[
+       include_stdint='awk '\''END{printf("%cinclude <stdint.h>\n", 35);}'\'' < /dev/null'],
+       include_stdint='echo "/* no stdint.h */"')
+AC_SUBST(include_stdint)
+AC_CHECK_HEADER(inttypes.h,[
+       include_inttypes='awk '\''END{printf("%cinclude <inttypes.h>\n", 35);}'\'' < /dev/null'],
+       include_inttypes='echo "/* no inttypes.h */"')
+AC_SUBST(include_inttypes)
+AC_CHECK_HEADER(xom.h,[
+       include_xom='awk '\''END{printf("%cinclude <xom.h>\n", 35);}'\'' < /dev/null'], [
+       include_xom='echo "/* no xom.h */"'])
+AC_SUBST(include_xom)
+dnl
+dnl
+dnl lib/rpc
+### Check where struct rpcent is declared.
+#
+# This is necessary to determine:
+# 1. If /usr/include/netdb.h declares struct rpcent
+# 2. If /usr/include/rpc/netdb.h declares struct rpcent
+#
+# We have our own rpc/netdb.h, and if /usr/include/netdb.h includes
+# rpc/netdb.h, then nastiness could happen.
+#
+# Logic: If /usr/include/netdb.h declares struct rpcent, then check
+# rpc/netdb.h.  If /usr/include/rpc/netdb.h declares struct rpcent,
+# then define STRUCT_RPCENT_IN_RPC_NETDB_H, otherwise do not.  If
+# neither netdb.h nor rpc/netdb.h declares struct rpcent, then define
+# STRUCT_RPCENT_IN_RPC_NETDB_H anyway.
+#
+AC_MSG_CHECKING([where struct rpcent is declared])
+AC_TRY_COMPILE([#include <netdb.h>],
+[struct rpcent e;
+char c = e.r_name[0];
+int i = e.r_number;],
+[AC_TRY_COMPILE([#include <rpc/netdb.h>],
+[struct rpcent e;
+char c = e.r_name[0];
+int i = e.r_number;],
+[AC_MSG_RESULT([rpc/netdb.h])
+rpcent_define='#define STRUCT_RPCENT_IN_RPC_NETDB_H'],
+[AC_MSG_RESULT([netdb.h])])],
+[AC_MSG_RESULT([nowhere])
+rpcent_define='#define STRUCT_RPCENT_IN_RPC_NETDB_H'])
+AC_SUBST(rpcent_define)
+
+AC_CHECK_HEADERS(sys/select.h sys/time.h unistd.h)
+if test $ac_cv_header_sys_select_h = yes; then
+  GSSRPC__SYS_SELECT_H='#include <sys/select.h>'
+else
+  GSSRPC__SYS_SELECT_H='/* #include <sys/select.h> */'
+fi
+AC_SUBST(GSSRPC__SYS_SELECT_H)
+if test $ac_cv_header_sys_time_h = yes; then
+  GSSRPC__SYS_TIME_H='#include <sys/time.h>'
+else
+  GSSRPC__SYS_TIME_H='/* #include <sys/time.h> */'
+fi
+AC_SUBST(GSSRPC__SYS_TIME_H)
+if test $ac_cv_header_unistd_h = yes; then
+  GSSRPC__UNISTD_H='#include <unistd.h>'
+else
+  GSSRPC__UNISTD_H='/* #include <unistd.h> */'
+fi
+AC_SUBST(GSSRPC__UNISTD_H)
+
+AC_CACHE_CHECK([for MAXHOSTNAMELEN in sys/param.h],
+  [krb5_cv_header_sys_param_h_maxhostnamelen],
+  [AC_TRY_COMPILE([#include <sys/param.h>],
+    [int i = MAXHOSTNAMELEN;],
+    [krb5_cv_header_sys_param_h_maxhostnamelen=yes],
+    [krb5_cv_header_sys_param_h_maxhostnamelen=no])])
+AC_CACHE_CHECK([for MAXHOSTNAMELEN in netdb.h],
+  [krb5_cv_header_netdb_h_maxhostnamelen],
+  [AC_TRY_COMPILE([#include <netdb.h>],
+    [int i = MAXHOSTNAMELEN;],
+    [krb5_cv_header_netdb_h_maxhostnamelen=yes],
+    [krb5_cv_header_netdb_h_maxhostnamelen=no])])
+
+GSSRPC__SYS_PARAM_H='/* #include <sys/param.h> */'
+GSSRPC__NETDB_H='/* #include <netdb.h> */'
+if test $krb5_cv_header_sys_param_h_maxhostnamelen = yes; then
+  GSSRPC__SYS_PARAM_H='#include <sys/param.h>'
+else
+  if test $krb5_cv_header_netdb_h_maxhostnamelen = yes; then
+    GSSRPC__NETDB_H='#include <netdb.h>'
+  else
+    AC_MSG_WARN([can't find MAXHOSTNAMELEN definition; faking it])
+  fi
+fi
+AC_SUBST(GSSRPC__SYS_PARAM_H)
+AC_SUBST(GSSRPC__NETDB_H)
+
+AC_CACHE_CHECK([for uint32_t in sys/types.h],
+  [krb5_cv_header_sys_types_h_uint32_t],
+  [AC_TRY_COMPILE([#include <sys/types.h>],
+      [uint32_t i = 0;],
+      [krb5_cv_header_sys_types_h_uint32_t=yes],
+      [krb5_cv_header_sys_types_h_uint32_t=no])])
+AC_CACHE_CHECK([for uint32_t in stdint.h],
+  [krb5_cv_header_stdint_h_uint32_t],
+  [AC_TRY_COMPILE([#include <stdint.h>],
+      [uint32_t i = 0;],
+      [krb5_cv_header_stdint_h_uint32_t=yes],
+      [krb5_cv_header_stdint_h_uint32_t=no])])
+AC_CACHE_CHECK([for uint32_t in inttypes.h],
+  [krb5_cv_header_inttypes_h_uint32_t],
+  [AC_TRY_COMPILE([#include <inttypes.h>],
+      [uint32_t i = 0;],
+      [krb5_cv_header_inttypes_h_uint32_t=yes],
+      [krb5_cv_header_inttypes_h_uint32_t=no])])
+GSSRPC__STDINT_H='/* #include <stdint.h> */'
+GSSRPC__INTTYPES_H='/* #include <inttypes.h> */'
+GSSRPC__FAKE_UINT32='/* #undef GSSRPC__FAKE_INT32 */'
+if test $krb5_cv_header_sys_types_h_uint32_t = yes; then
+  : # already included sys/types.h
+else
+  if test $krb5_cv_header_stdint_h_uint32_t = yes; then
+    GSSRPC__STDINT_H='#include <stdint.h>'
+  else
+    if test $krb5_cv_header_inttypes_h_uint32_t = yes; then
+      GSSRPC__INTTYPES_H='#include <inttypes.h>'
+    else
+      AC_MSG_WARN([can't find a fixed-width 32-bit type anywhere; faking it])
+      GSSRPC__FAKE_UINT32='#define GSSRPC__FAKE_UINT32 1'
+    fi
+  fi
+fi
+AC_SUBST(GSSRPC__STDINT_H)
+AC_SUBST(GSSRPC__INTTYPES_H)
+AC_SUBST(GSSRPC__FAKE_UINT32)
+
+AC_CACHE_CHECK([for BSD type aliases], [krb5_cv_type_bsdaliases],
+  [AC_TRY_COMPILE(
+    [#include <sys/types.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif],
+    [u_char c;
+u_int i;
+u_long l;], [krb5_cv_type_bsdaliases=yes], [krb5_cv_type_bsdaliases=no])])
+if test $krb5_cv_type_bsdaliases = yes; then
+  GSSRPC__BSD_TYPEALIASES='/* #undef GSSRPC__BSD_TYPEALIASES */'
+else
+  GSSRPC__BSD_TYPEALIASES='#define GSSRPC__BSD_TYPEALIASES 1'
+fi
+AC_SUBST(GSSRPC__BSD_TYPEALIASES)
+#
+# sockaddr length field checks
+#
+AC_CHECK_MEMBERS([struct sockaddr_in.sin_len], , ,
+  [#include <sys/types.h>
+@%:@include <netinet/in.h>])
+AC_CHECK_MEMBERS([struct sockaddr.sa_len], , ,
+  [#include <sys/types.h>
+@%:@include <sys/socket.h>])
+
+AC_MSG_CHECKING([return type of setrpcent])
+AC_CACHE_VAL(k5_cv_type_setrpcent,
+[AC_TRY_COMPILE([#include <netdb.h>
+#ifdef __cplusplus
+extern "C"
+#endif
+extern void setrpcent();],
+[int i;], k5_cv_type_setrpcent=void, k5_cv_type_setrpcent=int)])dnl
+AC_MSG_RESULT($k5_cv_type_setrpcent)
+AC_DEFINE_UNQUOTED(SETRPCENT_TYPE, $k5_cv_type_setrpcent, [Define as return type of setrpcent])
+dnl
+AC_MSG_CHECKING([return type of endrpcent])
+AC_CACHE_VAL(k5_cv_type_endrpcent,
+[AC_TRY_COMPILE([#include <netdb.h>
+#ifdef __cplusplus
+extern "C"
+#endif
+extern void endrpcent();],
+[int i;], k5_cv_type_endrpcent=void, k5_cv_type_endrpcent=int)])dnl
+AC_MSG_RESULT($k5_cv_type_endrpcent)
+AC_DEFINE_UNQUOTED(ENDRPCENT_TYPE, $k5_cv_type_endrpcent, [Define as return type of endrpcent])
+K5_GEN_FILE(include/gssrpc/types.h:include/gssrpc/types.hin)
+changequote(<<, >>)
+case "$krb5_cv_host" in
+*-*-solaris2.[012345]*)
+       PASS=tcp
+       ;;
+*)
+       PASS="tcp udp"
+       ;;
+esac
+changequote([, ])
+AC_SUBST(PASS)
+
+dnl for pkinit
+AC_ARG_ENABLE([pkinit],
+[  --disable-pkinit        disable PKINIT plugin support],,
+enable_pkinit=try)
+if test "$enable_pkinit" = yes || test "$enable_pkinit" = try; then
+  AC_CACHE_CHECK(for a recent enough OpenSSL, k5_cv_openssl_version_okay,
+[AC_COMPILE_IFELSE([#include <openssl/opensslv.h>
+#if OPENSSL_VERSION_NUMBER < 0x00908000L
+# error openssl is too old, need 0.9.8
+#endif
+int i = 1;
+], k5_cv_openssl_version_okay=yes, k5_cv_openssl_version_okay=no)])
+  old_LIBS="$LIBS"
+  AC_CHECK_LIB(crypto, PKCS7_get_signer_info)
+  LIBS="$old_LIBS"
+fi
+if test "$k5_cv_openssl_version_okay" = yes && (test "$enable_pkinit" = yes || test "$enable_pkinit" = try); then
+  K5_GEN_MAKEFILE(plugins/preauth/pkinit)
+elif test "$k5_cv_openssl_version_okay" = no && test "$enable_pkinit" = yes; then
+  AC_MSG_ERROR([Version of OpenSSL is too old; cannot enable PKINIT.])
+else
+  AC_DEFINE([DISABLE_PKINIT], 1, [Define to disable PKINIT plugin support])
+  AC_MSG_NOTICE([Disabling PKINIT support.])
+fi
+
+dnl for lib/apputils
+AC_REPLACE_FUNCS(daemon)
+
+dnl for tests/
+if test x"$RUNTEST" != x; then
+       HAVE_RUNTEST=yes
+else
+       HAVE_RUNTEST=no
+fi
+AC_SUBST(HAVE_RUNTEST)
+
+dnl for plugins/kdb/db2
+dnl
+dnl AIX is unusual in that it wants all symbols resolved at link time
+dnl  Fortunately, it will allow us to link the kdb library now, even if
+dnl it is linked again later.
+case $krb5_cv_host in
+*-*-aix*)
+       DB_EXTRA_LIBS=-ldb
+       ;;
+*)
+       DB_EXTRA_LIBS=
+       ;;
+esac
+AC_SUBST(DB_EXTRA_LIBS)
+
 dnl
 dnl
 dnl Check for thread safety issues.
@@ -525,26 +973,144 @@ if test "$enable_thread_support" = yes; then
   fi # tsmissing not empty
 fi # enable_thread_support
 dnl
-HOST_TYPE=$krb5_cv_host
-AC_SUBST(HOST_TYPE)
+dnl Sadly, we seem to have accidentally committed ourselves in 1.4 to
+dnl an ABI that includes the existence of libkrb5support.0 even
+dnl though random apps should never use anything from it.  And on
+dnl the Mac, to which that didn't apply, we can't use major version 0.
+dnl
+case $krb5_cv_host in
+*-*-darwin* | *-*-rhapsody*) SUPPORTLIB_MAJOR=1 ;;
+*)                          SUPPORTLIB_MAJOR=0 ;;
+esac
+AC_SUBST(SUPPORTLIB_MAJOR)
+dnl
+dnl On the Mac we need CoreFoundation for UCS-2 conversion for RC4.
+case $krb5_cv_host in
+*-*-darwin* | *-*-rhapsody*) CRYPTO_LIBS="-framework CoreFoundation" ;;
+*)                          CRYPTO_LIBS="" ;;
+esac
+AC_SUBST(CRYPTO_LIBS)
 dnl
 dnl
 if test "$COM_ERR_VERSION" = k5 ; then
-  AC_CONFIG_SUBDIRS(util/et)
+  K5_GEN_MAKEFILE(util/et)
 fi
 if test "$SS_VERSION" = k5 ; then
-  AC_CONFIG_SUBDIRS(util/ss)
+  K5_GEN_MAKEFILE(util/ss)
 fi
-AC_CONFIG_SUBDIRS(util/profile util/pty)
-AC_CONFIG_SUBDIRS(lib/crypto lib/krb5 lib/des425 lib/apputils)
-if test -n "$KRB4_LIB"; then
-  AC_CONFIG_SUBDIRS(lib/krb4)
+dnl
+dnl
+ldap_plugin_dir=""
+ldap_lib=""
+if test -n "$OPENLDAP_PLUGIN"; then
+  AC_CHECK_HEADERS(ldap.h lber.h, :, [AC_MSG_ERROR($ac_header not found)])
+  AC_CHECK_LIB(ldap, ldap_init, :, [AC_MSG_ERROR(libldap not found or missing ldap_init)])
+  old_LIBS="$LIBS"
+  LIBS="$LIBS -lldap"
+  AC_CHECK_FUNCS(ldap_initialize ldap_url_parse_nodn ldap_unbind_ext_s ldap_str2dn ldap_explode_dn)
+  LIBS="$old_LIBS"
+
+  BER_OKAY=0
+  AC_CHECK_LIB(ldap, ber_init, [BER_OKAY=1])
+  if test "$BER_OKAY" = "1"; then 
+    LDAP_LIBS='-lldap'
+  else
+    AC_CHECK_LIB(lber, ber_init, [BER_OKAY=1], [AC_MSG_WARN([libber not found])])
+    if test "$BER_OKAY" = "1"; then 
+      LDAP_LIBS='-lldap -llber'
+    else
+      AC_ERROR("BER library missing - cannot build LDAP database module")
+    fi
+  fi
+  AC_DEFINE([ENABLE_LDAP], 1, [Define if LDAP KDB support within the Kerberos library (mainly ASN.1 code) should be enabled.])
+  AC_SUBST(LDAP_LIBS)
+
+  K5_GEN_MAKEFILE(plugins/kdb/ldap)
+  K5_GEN_MAKEFILE(plugins/kdb/ldap/ldap_util)
+  K5_GEN_MAKEFILE(plugins/kdb/ldap/libkdb_ldap)
+  ldap_plugin_dir=plugins/kdb/ldap
+  LDAP=yes
+else
+  LDAP=no
 fi
-AC_CONFIG_SUBDIRS(lib/kdb lib/gssapi lib/rpc lib/kadm5)
-dnl if test -n "$KRB4_LIB"; then
-dnl   AC_CONFIG_SUBDIRS(krb524)
-dnl fi
+AC_SUBST(ldap_plugin_dir)
+AC_SUBST(LDAP)
+
+dnl We really should look for and use python-config.
+PYTHON_LIB=
+AC_CHECK_HEADERS(Python.h python2.3/Python.h python2.5/Python.h)
+AC_CHECK_LIB(python2.3,main,[PYTHON_LIB=-lpython2.3],
+  AC_CHECK_LIB(python2.5,main,[PYTHON_LIB=-lpython2.5]))
+AC_SUBST(PYTHON_LIB)
+
+dnl
+dnl Kludge for simple server --- FIXME is this the best way to do this?
+dnl
+if test "$ac_cv_lib_socket" = "yes" -a "$ac_cv_lib_nsl" = "yes"; then
+       AC_DEFINE(BROKEN_STREAMS_SOCKETS,1,[Define if socket can't be bound to 0.0.0.0])
+fi
+dnl
+AC_CONFIG_SUBDIRS(appl/libpty appl/bsd appl/gssftp appl/telnet)
 
-AC_CONFIG_SUBDIRS(kadmin clients plugins/kdb/db2 appl tests)
 AC_CONFIG_FILES(krb5-config, [chmod +x krb5-config])
-V5_AC_OUTPUT_MAKEFILE(. util util/support util/send-pr lib kdc slave krb524 config-files gen-manpages include include/krb5 include/kerberosIV)
+V5_AC_OUTPUT_MAKEFILE(.
+
+       util util/support util/profile util/send-pr
+
+       lib lib/kdb
+
+       lib/crypto lib/crypto/krb lib/crypto/krb/crc32 lib/crypto/builtin/des
+       lib/crypto/krb/dk lib/crypto/builtin/enc_provider
+       lib/crypto/krb/hash_provider lib/crypto/krb/keyhash_provider
+       lib/crypto/builtin lib/crypto/builtin/md4 lib/crypto/builtin/md5
+       lib/crypto/krb/old lib/crypto/krb/raw lib/crypto/builtin/sha1
+       lib/crypto/builtin/arcfour lib/crypto/krb/yarrow lib/crypto/builtin/aes
+       lib/crypto/crypto_tests
+
+       lib/krb5 lib/krb5/error_tables lib/krb5/asn.1 lib/krb5/ccache
+dnl    lib/krb5/ccache/ccapi
+       lib/krb5/keytab lib/krb5/krb lib/krb5/rcache lib/krb5/os
+       lib/krb5/unicode
+
+       lib/gssapi lib/gssapi/generic lib/gssapi/krb5 lib/gssapi/spnego
+       lib/gssapi/mechglue
+
+       lib/rpc lib/rpc/unit-test
+
+       lib/kadm5 lib/kadm5/clnt lib/kadm5/srv lib/kadm5/unit-test
+
+       lib/apputils
+
+dnl    ccapi ccapi/lib ccapi/lib/unix ccapi/server ccapi/server/unix ccapi/test
+
+       kdc slave config-files gen-manpages include
+
+       plugins/locate/python
+       plugins/kdb/db2
+       plugins/kdb/db2/libdb2
+       plugins/kdb/db2/libdb2/hash
+       plugins/kdb/db2/libdb2/btree
+       plugins/kdb/db2/libdb2/db
+       plugins/kdb/db2/libdb2/mpool
+       plugins/kdb/db2/libdb2/recno
+       plugins/kdb/db2/libdb2/test
+       plugins/preauth/cksum_body plugins/preauth/encrypted_challenge
+       plugins/preauth/wpse
+       plugins/authdata/greet
+
+       clients clients/klist clients/kinit clients/kvno
+       clients/kdestroy clients/kpasswd clients/ksu
+
+       kadmin kadmin/cli kadmin/dbutil kadmin/ktutil kadmin/server
+       kadmin/testing kadmin/testing/scripts kadmin/testing/util
+
+       appl
+       appl/sample appl/sample/sclient appl/sample/sserver
+       appl/simple appl/simple/client appl/simple/server
+       appl/gss-sample appl/user_user
+
+       tests tests/resolve tests/asn.1 tests/create tests/hammer
+       tests/verify tests/gssapi tests/dejagnu tests/threads tests/shlib
+       tests/gss-threads tests/misc tests/mkeystash_compat
+       util/collected-client-lib
+)