Increased version number before publishing a new release
[mod_auth_kerb.git] / configure.in
1 # Process this file with autoconf to produce a configure script.
2 AC_REVISION($Revision$)
3 AC_PREREQ(2.53)
4 AC_INIT(mod_auth_kerb, 0.5-rc4, modauthkerb-developers@lists.sourceforge.net)
5 AC_CONFIG_SRCDIR([src/mod_auth_kerb.c])
6 AC_CONFIG_HEADER([config.h])
7
8 # Checks for programs.
9 AC_PROG_CC
10 AC_PROG_MAKE_SET
11
12 # Checks for libraries.
13 # FIXME: Replace `main' with a function in `-lresolv':
14 LIB_resolv=""
15 AC_CHECK_LIB([resolv], [main], [LIB_resolv=-lresolv])
16 AC_SUBST(LIB_resolv)
17
18 # Checks for header files.
19 AC_HEADER_STDC
20 AC_CHECK_HEADERS([limits.h netdb.h stddef.h stdlib.h string.h unistd.h])
21
22 # Checks for typedefs, structures, and compiler characteristics.
23 #AC_C_CONST
24 AC_TYPE_SIZE_T
25 AC_STRUCT_TM
26
27 # Checks for library functions.
28 #AC_FUNC_MALLOC
29 #AC_FUNC_MEMCMP
30 #AC_CHECK_FUNCS([gethostbyname memset putenv strcasecmp strchr strdup strerror])
31
32 #
33 # kerberos5 enviroment
34 #
35 KRB5_CPPFLAGS=""
36 KRB5_LDFLAGS=""
37 krb5_config_command=krb5-config
38 DO_KRB5=
39
40 AC_ARG_WITH(krb5,
41   AC_HELP_STRING([--with-krb5=dir],[use krb5 in dir]),
42   [ with_krb5="$withval" ])
43
44 if test "x$with_krb5" != "xno" ; then
45   AC_MSG_CHECKING([for Kerberos5 installation])
46   if test "x$with_krb5" != "x"; then
47      if test -x "$with_krb5/bin/krb5-config"; then
48         krb5_config_command="$with_krb5/bin/krb5-config"
49      else 
50         # quick fix for OpenBSD installations where krb5-config is missing.
51         # OpenBSD uses Heimdal, so add openbsd-specific configuration 
52         # libs for Heimdal 
53         KRB5_CPPFLAGS="-I$with_krb5/include"
54         KRB5_LDFLAGS="-L$with_krb5/lib -lgssapi -lkrb5 -lasn1 -ldes -lcrypt"
55         krb5_config_command=""
56      fi
57   fi
58
59   if test -n "$krb5_config_command"; then
60      KRB5_CPPFLAGS=`$krb5_config_command --cflags gssapi 2>/dev/null`
61      KRB5_LDFLAGS=`$krb5_config_command --libs gssapi 2>/dev/null`
62   fi
63   if test "x$KRB5_LDFLAGS" = "x"; then
64      with_krb5=no
65      AC_MSG_RESULT(no)
66   else
67      AC_MSG_RESULT(yes)
68
69      ac_save_CFLAGS=$CFLAGS
70      ac_save_LDFLAGS=$LDFLAGS
71      ac_save_LIBS=$LIBS
72      CFLAGS="$CFLAGS $KRB5_CPPFLAGS"
73      LDFLAGS="$LDFLAGS $KRB5_LDFLAGS"
74      LIBS="$LIBS $LDFLAGS $LIB_resolv"
75
76      AC_CHECK_LIB(krb5, krb5_init_context, [], [with_krb5=no])
77
78      if test "x$with_krb5" != "xno"; then
79         # check if krb5_cc_gen_new() is implemented by the krb5 library
80         AC_CHECK_FUNC(krb5_cc_gen_new, [AC_DEFINE(HAVE_KRB5_CC_GEN_NEW)])
81
82         # check for Heimdal
83         AC_MSG_CHECKING(whether we are using Heimdal)
84         AC_TRY_COMPILE([#include <krb5.h>],
85                        [ char *tmp = heimdal_version; ],
86                        [ AC_MSG_RESULT(yes)
87                          AC_DEFINE(HEIMDAL) ],
88                        [ AC_MSG_RESULT(no) ])
89      fi
90
91      CFLAGS=$ac_save_CFLAGS
92      LDFLAGS=$ac_save_LDFLAGS
93      LIBS=$ac_save_LIBS
94      AC_DEFINE(KRB5)
95      DO_KRB5=yes
96   fi
97 fi
98 AC_SUBST(KRB5_CPPFLAGS)
99 AC_SUBST(KRB5_LDFLAGS)
100 AC_SUBST(DO_KRB5)
101
102 #
103 # Kerberos4 enviroment
104 #
105 KRB4_CPPFLAGS=""
106 KRB4_LDFLAGS=""
107
108 AC_ARG_WITH(krb4,
109   AC_HELP_STRING([--with-krb4=dir], [use krb4 in dir]),
110   [ with_krb4="$withval" ])
111
112 if test "x$with_krb4" != "xno"; then
113   AC_MSG_CHECKING([for Kerberos4 installation])
114   if test "x$with_krb4" != "x"; then
115      if test -x "$with_krb4/bin/krb4-config"; then
116         KRB4_CPPFLAGS=`$with_krb4/bin/krb4-config --cflags krb4 2>/dev/null`
117         KRB4_LDFLAGS=`$with_krb4/bin/krb4-config --libs krb4 2>/dev/null`
118      elif test -x "$with_krb4/bin/krb5-config"; then
119         KRB4_CPPFLAGS=`$with_krb4/bin/krb5-config --cflags krb4 2>/dev/null`
120         KRB4_LDFLAGS=`$with_krb4/bin/krb5-config --libs krb4 2>/dev/null`
121      else
122         AC_MSG_ERROR([failed to find krb4-config or krb5-config in $with_krb4/bin])
123      fi
124   else
125      KRB4_CPPFLAGS=`krb4-config --cflags krb4 2>/dev/null`
126      KRB4_LDFLAGS=`krb4-config --libs krb4 2>/dev/null`
127      if test "x$KRB4_LDFLAGS" = "x"; then
128         KRB4_CPPFLAGS=`$krb5_config_command --cflags krb4 2>/dev/null`
129         KRB4_LDFLAGS=`$krb5_config_command --libs krb4 2>/dev/null`
130         if test $? -ne 0; then
131            KRB4_CPPFLAGS=""
132            KRB4_LDFLAGS=""
133         fi
134      fi
135   fi
136   if test "x$KRB4_LDFLAGS" = "x"; then
137      with_krb4=no
138      AC_MSG_RESULT(no)
139   else
140      AC_MSG_RESULT(yes)
141
142      ac_save_CFLAGS=$CFLAGS
143      ac_save_CPPFLAGS=$CPPFLAGS
144      ac_save_LDFLAGS=$LDFLAGS
145      ac_save_LIBS=$LIBS
146      CFLAGS="$CFLAGS $KRB4_CPPFLAGS"
147      CPPFLAGS="$CFLAGS $KRB4_CPPFLAGS"
148      LDFLAGS="$LDFLAGS $KRB4_LDFLAGS"
149      LIBS="$LIBS $LDFLAGS $LIB_resolv"
150
151 #    if not found krb.h suppose it's in the kerberosIV subdirectory
152      AC_CHECK_HEADER(krb.h, , with_krb4=no)
153      if test "x$with_krb4" = "xno"; then
154          KRB4_CPPFLAGS="$KRB4_CPPFLAGS ${KRB4_CPPFLAGS}/kerberosIV"
155 #        second run of AC_CHECK_HEADER for the same library returns the cached
156 #        result created by previous run :-(
157          AC_CHECK_HEADER(kerberosIV/krb.h, with_krb4=yes,
158                          [  with_krb4=no
159                             KRB4_CPPFLAGS=""
160                             KRB4_LDFLAGS=""])
161      fi
162
163      if test "x$with_krb4" != "xno"; then
164         AC_CHECK_LIB(krb4, krb_get_pw_in_tkt, [], [with_krb4=no])
165         if test "x$with_krb4" = "xno"; then
166            AC_CHECK_LIB(krb, krb_get_pw_in_tkt, [with_krb4=yes], 
167                         [with_krb4=no
168                          KRB4_CPPFLAGS=""
169                          KRB4_LDFLAGS=""])
170         fi
171      fi
172
173      CFLAGS=$ac_save_CFLAGS
174      CPPFLAGS=$ac_save_CPPFLAGS
175      LDFLAGS=$ac_save_LDFLAGS
176      LIBS=$ac_save_LIBS
177
178      AC_DEFINE(KRB4)
179   fi
180 fi
181 AC_SUBST(KRB4_CPPFLAGS)
182 AC_SUBST(KRB4_LDFLAGS)
183
184
185 if test "x$with_krb5" = "xno" -a "x$with_krb4" = "xno"; then
186   AC_MSG_ERROR([No Kerberos enviroment found])
187 fi
188
189 #
190 # Apache enviroment
191 #
192 AC_ARG_WITH(apache,
193   AC_HELP_STRING([--with-apache=dir],[use apache in dir]),
194   [ with_apache="$withval" ])
195
196 AC_MSG_CHECKING([for Apache installation])
197
198 APXS="apxs"
199 HTTPD="httpd"
200 if test "x$with_apache" != "x"; then
201   if test ! -x "$with_apache/bin/httpd" -o ! -x "$with_apache/bin/apxs"; then
202      AC_MSG_ERROR([failed to find apache files in $with_apache])
203   fi
204   APXS="$with_apache/bin/apxs"
205   if test ! -x $APXS; then
206      APXS="$with_apache/sbin/apxs"
207   fi
208   HTTPD="$with_apache/bin/httpd"
209   if test ! -x $HTTPD; then
210      HTTPD"$with_apache/sbin/httpd"
211   fi
212 fi
213
214 apache_v1_3=`$HTTPD -v | grep "^Server version: Apache/1.3."`
215 apache_v2_0=`$HTTPD -v | grep "^Server version: Apache/2.0."`
216 if test "x$apache_v1_3" = "x" -a "x$apache_v2_0" = "x"; then
217   AC_MSG_ERROR([cannot find valid apache installation on your system])
218 fi
219 if test -n "$apache_v1_3"; then
220   AC_DEFINE(APXS1)
221 fi
222 AC_MSG_RESULT(yes)
223
224 AC_SUBST(APXS)
225
226 AC_CONFIG_FILES([Makefile
227                  spnegokrb5/Makefile])
228
229 AC_OUTPUT