Added #include <string.h> to make compiler stop complaining of memset() and memcmp...
[mod_auth_kerb.git] / configure.in
index 165ad8f..6dea290 100644 (file)
@@ -1,7 +1,7 @@
 # Process this file with autoconf to produce a configure script.
 AC_REVISION($Revision$)
 AC_PREREQ(2.53)
-AC_INIT(mod_auth_kerb, 0.5-rc2, modauthkerb-developers@lists.sourceforge.net)
+AC_INIT(mod_auth_kerb, 0.5-rc3, modauthkerb-developers@lists.sourceforge.net)
 AC_CONFIG_SRCDIR([src/mod_auth_kerb.c])
 AC_CONFIG_HEADER([config.h])
 
@@ -16,12 +16,12 @@ 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
-#AC_TYPE_SIZE_T
+AC_TYPE_SIZE_T
 AC_STRUCT_TM
 
 # Checks for library functions.
@@ -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]),
@@ -70,15 +71,25 @@ if test "x$with_krb5" != "xno" ; then
         # check if krb5_cc_gen_new() is implemented by the krb5 library
         AC_CHECK_FUNC(krb5_cc_gen_new, [AC_DEFINE(HAVE_KRB5_CC_GEN_NEW)])
 
-        # check if you're using Heimdal
-        # ...
+        # check for Heimdal
+        AC_MSG_CHECKING(whether we are using Heimdal)
+       AC_TRY_COMPILE([#include <krb5.h>],
+                      [ char *tmp = heimdal_version; ],
+                      [ AC_MSG_RESULT(yes)
+                        AC_DEFINE(HEIMDAL) ],
+                      [ AC_MSG_RESULT(no) ])
      fi
 
      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
@@ -108,6 +119,10 @@ if test "x$with_krb4" != "xno"; then
      if test "x$KRB4_LDFLAGS" = "x"; then
         KRB4_CPPFLAGS=`$krb5_config_command --cflags krb4 2>/dev/null`
         KRB4_LDFLAGS=`$krb5_config_command --libs krb4 2>/dev/null`
+        if test $? -ne 0; then
+           KRB4_CPPFLAGS=""
+           KRB4_LDFLAGS=""
+        fi
      fi
   fi
   if test "x$KRB4_LDFLAGS" = "x"; then
@@ -117,41 +132,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
 #