- the spnegokrb5 lib is not used if only krb4 is specified
[mod_auth_kerb.git] / configure.in
index 165ad8f..b2e0c93 100644 (file)
@@ -16,8 +16,8 @@ AC_CHECK_LIB([resolv], [main], [LIB_resolv=-lresolv])
 AC_SUBST(LIB_resolv)
 
 # Checks for header files.
-#AC_HEADER_STDC
-#AC_CHECK_HEADERS([limits.h netdb.h stddef.h stdlib.h string.h unistd.h])
+AC_HEADER_STDC
+AC_CHECK_HEADERS([limits.h netdb.h stddef.h stdlib.h string.h unistd.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 #AC_C_CONST
@@ -35,6 +35,7 @@ AC_STRUCT_TM
 KRB5_CPPFLAGS=""
 KRB5_LDFLAGS=""
 krb5_config_command=krb5-config
+DO_KRB5=
 
 AC_ARG_WITH(krb5,
   AC_HELP_STRING([--with-krb5=dir],[use krb5 in dir]),
@@ -77,8 +78,13 @@ if test "x$with_krb5" != "xno" ; then
      CFLAGS=$ac_save_CFLAGS
      LDFLAGS=$ac_save_LDFLAGS
      LIBS=$ac_save_LIBS
+     AC_DEFINE(KRB5)
+     DO_KRB5=yes
   fi
 fi
+AC_SUBST(KRB5_CPPFLAGS)
+AC_SUBST(KRB5_LDFLAGS)
+AC_SUBST(DO_KRB5)
 
 #
 # Kerberos4 enviroment
@@ -117,41 +123,52 @@ if test "x$with_krb4" != "xno"; then
      AC_MSG_RESULT(yes)
 
      ac_save_CFLAGS=$CFLAGS
+     ac_save_CPPFLAGS=$CPPFLAGS
      ac_save_LDFLAGS=$LDFLAGS
      ac_save_LIBS=$LIBS
      CFLAGS="$CFLAGS $KRB4_CPPFLAGS"
+     CPPFLAGS="$CFLAGS $KRB4_CPPFLAGS"
      LDFLAGS="$LDFLAGS $KRB4_LDFLAGS"
      LIBS="$LIBS $LDFLAGS $LIB_resolv"
-  
-     AC_CHECK_LIB(krb4, krb_get_pw_in_tkt, [], [with_krb4=no])
+
+#    if not found krb.h suppose it's in the kerberosIV subdirectory
+     AC_CHECK_HEADER(krb.h, , with_krb4=no)
      if test "x$with_krb4" = "xno"; then
-        AC_CHECK_LIB(krb, krb_get_pw_in_tkt, [with_krb4=yes], 
-                     [with_krb4=no
-                      KRB4_CPPFLAGS=""
-                      KRB4_LDFLAGS=""])
+         KRB4_CPPFLAGS="$KRB4_CPPFLAGS ${KRB4_CPPFLAGS}/kerberosIV"
+#        second run of AC_CHECK_HEADER for the same library returns the cached
+#        result created by previous run :-(
+         AC_CHECK_HEADER(kerberosIV/krb.h, with_krb4=yes,
+                         [  with_krb4=no
+                            KRB4_CPPFLAGS=""
+                            KRB4_LDFLAGS=""])
+     fi
+
+     if test "x$with_krb4" != "xno"; then
+        AC_CHECK_LIB(krb4, krb_get_pw_in_tkt, [], [with_krb4=no])
+        if test "x$with_krb4" = "xno"; then
+           AC_CHECK_LIB(krb, krb_get_pw_in_tkt, [with_krb4=yes], 
+                        [with_krb4=no
+                         KRB4_CPPFLAGS=""
+                         KRB4_LDFLAGS=""])
+        fi
      fi
 
      CFLAGS=$ac_save_CFLAGS
+     CPPFLAGS=$ac_save_CPPFLAGS
      LDFLAGS=$ac_save_LDFLAGS
      LIBS=$ac_save_LIBS
+
+     AC_DEFINE(KRB4)
   fi
 fi
+AC_SUBST(KRB4_CPPFLAGS)
+AC_SUBST(KRB4_LDFLAGS)
+
 
 if test "x$with_krb5" = "xno" -a "x$with_krb4" = "xno"; then
   AC_MSG_ERROR([No Kerberos enviroment found])
 fi
 
-AC_SUBST(KRB5_CPPFLAGS)
-AC_SUBST(KRB5_LDFLAGS)
-AC_SUBST(KRB4_CPPFLAGS)
-AC_SUBST(KRB4_LDFLAGS)
-if test "x$with_krb5" != "xno"; then
-   AC_DEFINE(KRB5)
-fi
-if test "x$with_krb4" != "xno"; then
-   AC_DEFINE(KRB4)
-fi
-
 #
 # Apache enviroment
 #