$NetBSD: patch-ab,v 1.12 2000/03/20 02:25:49 itojun Exp $

--- configure.in-	Wed May 12 20:20:02 1999
+++ configure.in	Mon Mar 20 09:48:09 2000
@@ -30,6 +30,7 @@
 fi
 
 AC_PROG_CC
+AC_PROG_CPP
 AC_ISC_POSIX
 
 AC_DEFINE_UNQUOTED(HOSTTYPE, "$host")
@@ -42,11 +43,12 @@
     ;;
   *-*-solaris*)
     # solaris stuff. appro@fy.chalmers.se
-    AC_DEFINE(SECURE_RPC)
-    AC_DEFINE(SECURE_NFS)
+# this stuff breaks AFS/Kerberos. YUCK.
+#    AC_DEFINE(SECURE_RPC)
+#    AC_DEFINE(SECURE_NFS)
     # NIS+ is forced so that we don't have to recompile
     # if we move to NIS+. appro@fy.chalmers.se
-    AC_DEFINE(NIS_PLUS)
+#    AC_DEFINE(NIS_PLUS)
     ;;
   *-*-sunos*)
     os_sunos=yes
@@ -311,9 +313,9 @@
 
 export CFLAGS CC
 
-# Socket pairs appear to be broken on several systems.  I don't know exactly
-# where, so I'll use pipes everywhere for now.
-AC_DEFINE(USE_PIPES)
+dnl # Socket pairs appear to be broken on several systems.  I don't know exactly
+dnl # where, so I'll use pipes everywhere for now.
+dnl AC_DEFINE(USE_PIPES)
 
 AC_MSG_CHECKING([that the compiler works])
 AC_TRY_RUN([ main(int ac, char **av) { return 0; } ],
@@ -370,7 +372,7 @@
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(unistd.h rusage.h sys/time.h lastlog.h utmp.h shadow.h)
-AC_CHECK_HEADERS(sgtty.h sys/select.h sys/ioctl.h machine/endian.h)
+AC_CHECK_HEADERS(sgtty.h sys/select.h sys/ioctl.h sys/filio.h machine/endian.h)
 AC_CHECK_HEADERS(paths.h usersec.h utime.h netinet/in_systm.h)
 AC_CHECK_HEADERS(netinet/in_system.h netinet/ip.h netinet/tcp.h ulimit.h)
 AC_CHECK_HEADERS(sys/resource.h login_cap.h sys/stream.h sys/conf.h)
@@ -903,8 +905,8 @@
     fi
     AC_MSG_RESULT(Assuming TIS headers and libraries are in $withval.)
     AC_DEFINE(HAVE_TIS)
-    CFLAGS="$CFLAGS -I$withval -DHAVE_TIS"
-    LIBS="-L$withval -lauth -lfwall $LIBS"
+    CFLAGS="$CFLAGS -I$withval/include -DHAVE_TIS"
+    LIBS="-L$withval/lib -lauth -lfwall $LIBS"
     AC_MSG_WARN(Remember to read README.TIS. The connection between sshd and TIS authentication
 server is clear text!)
     ;;
@@ -912,55 +914,117 @@
   AC_MSG_RESULT(no)
 )
 
-AC_MSG_CHECKING(whether to use Kerberos)
-AC_ARG_WITH(kerberos5,
-[  --with-kerberos5=[KRB_PREFIX] Compile in Kerberos5 support.],
+AC_MSG_CHECKING(whether to use Kerberos v4)
+AC_ARG_WITH(krb4,
+[  --with-krb4[=PATH]      Compile in Kerberos v4 support.],
 [ case "$withval" in
   yes)
-    with_kerberos5=/usr/local
+    with_krb4=/usr/kerberos
     ;;
   esac ],
-[ with_kerberos5=no ]
+[ with_krb4=no ]
 )
-case "$with_kerberos5" in
+case "$with_krb4" in
 no)
   AC_MSG_RESULT(no)
   ;;
 *)
   AC_MSG_RESULT(yes)
-  AC_DEFINE(KERBEROS)
-  AC_DEFINE(KRB5)
-  KERBEROS_ROOT="$with_kerberos5"
-  KERBEROS_INCS="-I${KERBEROS_ROOT}/include"
-  KERBEROS_LIBS="-L${KERBEROS_ROOT}/lib -lgssapi_krb5 -lkrb5 -lcrypto -lcom_err"
-  AC_CHECK_LIB(ndbm, dbm_open, KERBEROS_LIBS="$KERBEROS_LIBS -lndbm")
+  AC_DEFINE(KRB4)
+  KERBEROS_ROOT="$with_krb4"
+  KERBEROS_INCS="-I${KERBEROS_ROOT}/include/kerberosIV"
+  KERBEROS_LIBS="-L${KERBEROS_ROOT}/lib -lkrb -ldes"
   KERBEROS_OBJS="auth-kerberos.o"
+  AC_CHECK_LIB(resolv, dn_expand, KERBEROS_LIBS="$KERBEROS_LIBS -lresolv")
+  dnl Check whether or not the AFS lifetime conversion routines exist.
+  AC_MSG_CHECKING(whether AFS lifetime conversion routines are present)
+  keeplibs="$LIBS"
+  keepcflags="$CFLAGS"
+  LIBS="-L${KERBEROS_ROOT}/lib -lkrb -ldes $LIBS"
+  CFLAGS="-I${KERBEROS_ROOT}/include $CFLAGS"
+  AC_TRY_LINK([#include <krb.h>], [ krb_life_to_time(10, 10);],
+              [AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_KRB_LIFE_TO_TIME)],
+              [AC_MSG_RESULT(no)])
+  LIBS="$keeplibs"
+  CFLAGS="$keepcflags"
   ;;
 esac
-AC_SUBST(KERBEROS_ROOT)
-AC_SUBST(KERBEROS_INCS)
-AC_SUBST(KERBEROS_LIBS)
-AC_SUBST(KERBEROS_OBJS)
-
-AC_MSG_CHECKING(whether to enable passing the Kerberos TGT)
-AC_ARG_ENABLE(kerberos-tgt-passing,
-[  --enable-kerberos-tgt-passing  Pass Kerberos ticket-granting-ticket.],
-[ case "$enableval" in
+
+AC_MSG_CHECKING(whether to use Kerberos v5)
+AC_ARG_WITH(krb5,
+[  --with-krb5[=PATH]      Compile in Kerberos v5 support.],
+[ case "$withval" in
+  yes)
+    with_krb5=/usr/local
+    ;;
+  esac ],
+[ with_krb5=no ]
+)
+case "$with_krb5" in
   no)
     AC_MSG_RESULT(no)
     ;;
   *)
-    if test "$with_kerberos5" = no ; then
+  AC_MSG_RESULT(yes)
+  AC_DEFINE(KRB5)
+  KERBEROS_ROOT="$with_krb5"
+  KERBEROS_INCS="-I${KERBEROS_ROOT}/include/krb5"
+  KERBEROS_LIBS="-L${KERBEROS_ROOT}/lib -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err"
+  AC_CHECK_LIB(ndbm, dbm_open, KERBEROS_LIBS="$KERBEROS_LIBS -lndbm")
+  KERBEROS_OBJS="auth-kerberos.o"
+  ;;
+esac
+
+AC_MSG_CHECKING(whether to use AFS)
+AC_ARG_WITH(afs,
+[  --with-afs              Compile in AFS support (requires KTH krb4).],
+if test "$with_afs" = no; then
       AC_MSG_RESULT(no)
-      AC_MSG_WARN("Passing Kerberos TGT requires Kerberos5 support.")
     else
       AC_MSG_RESULT(yes)
-      AC_DEFINE(KERBEROS_TGT_PASSING)
+  AC_DEFINE(AFS)
+  if test "$with_krb4" = no; then
+    AC_MSG_RESULT(no)
+    AC_MSG_WARN("AFS requires Kerberos v4 support.")
+  else
+    KERBEROS_LIBS="${KERBEROS_LIBS} -lkafs"
+    if test -n "$os_aix"; then
+      KERBEROS_LIBS="${KERBEROS_LIBS} -lld"
     fi
+  fi
+fi
+)
+AC_SUBST(KERBEROS_ROOT)dnl
+AC_SUBST(KERBEROS_INCS)dnl
+AC_SUBST(KERBEROS_LIBS)dnl
+AC_SUBST(KERBEROS_OBJS)dnl
+
+AC_MSG_CHECKING(whether to use Hesiod)
+AC_ARG_WITH(hesiod,
+[  --with-hesiod[=PATH]    Compile in Hesiod support.],
+[ case "$withval" in
+  yes)
+    with_hesiod=/usr/local/athena
     ;;
   esac ],
-  AC_MSG_RESULT(no)
+[ with_hesiod=no ]
 )
+case "$with_hesiod" in
+no)
+  AC_MSG_RESULT(no)
+  ;;
+*)
+  AC_MSG_RESULT(yes)
+  AC_DEFINE(HESIOD)
+  HESIOD_ROOT="$with_hesiod"
+  HESIOD_INCS="-I${HESIOD_ROOT}/include"
+  HESIOD_LIBS="-L${HESIOD_ROOT}/lib -lhesiod"
+  ;;
+esac
+AC_SUBST(HESIOD_ROOT)dnl
+AC_SUBST(HESIOD_INCS)dnl
+AC_SUBST(HESIOD_LIBS)dnl
 
 AC_MSG_CHECKING(whether to use libwrap)
 AC_ARG_WITH(libwrap,
@@ -970,11 +1034,19 @@
     AC_MSG_RESULT(no)
     ;;
   yes)
-    AC_MSG_RESULT(yes)
-    AC_CHECK_LIB(wrap, request_init, [
-	AC_DEFINE(LIBWRAP)
-        WRAPLIBS="-lwrap"
-        AC_DEFINE(HAVE_LIBWRAP) ])
+    WRAPLIBS="-lwrap"
+    OLDLIBS="$LIBS"
+    LIBS="$WRAPLIBS $LIBS"
+    AC_TRY_LINK([ int allow_severity; int deny_severity; ],
+                [ request_init(); ], [
+		    AC_MSG_RESULT(yes)
+		    AC_DEFINE(LIBWRAP)
+		    AC_DEFINE(HAVE_LIBWRAP)
+		], [
+		    AC_MSG_RESULT(no)
+		    WRAPLIBS=""
+		])
+    LIBS="$OLDLIBS"
     ;;
   *)
     AC_MSG_RESULT(yes)
@@ -1227,14 +1299,14 @@
 [ case "$enableval" in
   no)
        AC_MSG_RESULT(no)
-       SSHINSTALLMODE=0711
+       SSHINSTALLMODE=0511
        ;;
   *)   AC_MSG_RESULT(yes)
-       SSHINSTALLMODE=04711
+       SSHINSTALLMODE=04511
        ;;
   esac ],
   AC_MSG_RESULT(yes)
-  SSHINSTALLMODE=04711
+  SSHINSTALLMODE=04511
 )
 
 AC_MSG_CHECKING(whether to enable TCP_NODELAY)
@@ -1336,4 +1408,4 @@
 AC_SUBST(SSHDCONFOBJS)
 AC_SUBST(SSHINSTALLMODE)
 
-AC_OUTPUT(Makefile sshd.8 ssh.1 make-ssh-known-hosts.1 zlib-1.0.4/Makefile)
+AC_OUTPUT(Makefile sshd.8 ssh.1 make-ssh-known-hosts.pl make-ssh-known-hosts.1 zlib-1.0.4/Makefile)
