Description of delegation support in Win AD (thanks Rob Sessink)
[mod_auth_kerb.cvs/.git] / configure.in
1 # Process this file with autoconf to produce a configure script.
2 AC_REVISION($Revision$)
3 AC_PREREQ(2.57)
4 AC_INIT(mod_auth_kerb, 0.5-rc6, 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_config_command=krb5-config
36 SPNEGO_SRCS=""
37
38 AC_ARG_WITH(krb5,
39   AC_HELP_STRING([--with-krb5=dir],[use krb5 in dir]),
40   [ with_krb5="$withval" ])
41
42 if test "x$with_krb5" != "xno" ; then
43   ac_save_CPPFLAGS="$CPPFLAGS"
44   ac_save_LDFLAGS="$LDFLAGS"
45   ac_save_LIBS="$LIBS"
46    
47   if test -n "$with_krb5"; then
48      if test -x "$with_krb5/bin/krb5-config"; then
49         krb5_config_command="$with_krb5/bin/krb5-config"
50      else
51         krb5_config_command=""
52      fi
53   fi
54
55   dnl
56   dnl find header files
57   dnl
58
59   if test -z "$KRB5_CPPFLAGS"; then
60      TMP_KRB5_CPPFLAGS=""
61      if test -n "$krb5_config_command"; then
62         TMP_KRB5_CPPFLAGS=`$krb5_config_command --cflags gssapi 2>/dev/null`
63      fi
64      if test -z "$TMP_KRB5_CPPFLAGS"; then
65         TMP_KRB5_CPPFLAGS="-I$with_krb5/include"
66      fi
67      CPPFLAGS="$CPPFLAGS $TMP_KRB5_CPPFLAGS"
68      AC_CHECK_HEADERS(gssapi.h, 
69                       [ KRB5_CPPFLAGS="$TMP_KRB5_CPPFLAGS" ])
70      if test -z "$KRB5_CPPFLAGS"; then
71         AC_CHECK_HEADERS(gssapi/gssapi.h, 
72                          [ KRB5_CPPFLAGS="$TMP_KRB5_CPPFLAGS" ])
73      fi
74      CPPFLAGS="$ac_save_CPPFLAGS" 
75   fi
76
77   dnl
78   dnl find libraries
79   dnl
80
81   if test -z "$KRB5_LDFLAGS" -a -n "$krb5_config_command"; then
82      TMP_KRB5_LDFLAGS=`$krb5_config_command --libs gssapi 2>/dev/null`
83      if test -n "$TMP_KRB5_LDFLAGS"; then
84         LIBS="$LIBS $TMP_KRB5_LDFLAGS $LIB_resolv"
85         AC_CHECK_LIB(krb5, krb5_init_context,
86                      [ KRB5_LDFLAGS="$TMP_KRB5_LDFLAGS" ])
87         LIBS="$ac_save_LIBS"
88      fi
89   fi
90
91   if test -z "$KRB5_LDFLAGS"; then
92      #try MIT
93      TMP_KRB5_LDFLAGS="-L$with_krb5/lib -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err"
94      LIBS="$LIBS $TMP_KRB5_LDFLAGS $LIB_resolv"
95      AC_CHECK_LIB(krb5, krb5_init_context, [ KRB5_LDFLAGS="$TMP_KRB5_LDFLAGS" ])
96      LIBS="$ac_save_LIBS"
97   fi
98
99   if test -z "$KRB5_LDFLAGS"; then
100      #Try Heimdal
101      TMP_KRB5_LDFLAGS="-L$with_krb5/lib -lgssapi -lkrb5 -lasn1 -lcrypto -lroken -lcrypt"
102      LIBS="$LIBS $TMP_KRB5_LDFLAGS $LIB_resolv"
103      AC_CHECK_LIB(krb5, krb5_init_context, [ KRB5_LDFLAGS="$TMP_KRB5_LDFLAGS" ])
104      LIBS="$ac_save_LIBS"
105   fi
106
107   if test -z "$KRB5_LDFLAGS"; then
108      #Try Heimdal on OpenBSD
109      TMP_KRB5_LDFLAGS="-L$with_krb5/lib -lgssapi -lkrb5 -lasn1 -ldes -lcrypto"
110      LIBS="$LIBS $TMP_KRB5_LDFLAGS $LIB_resolv"
111      AC_CHECK_LIB(krb5, krb5_init_context, [ KRB5_LDFLAGS="$TMP_KRB5_LDFLAGS" ])
112      LIBS="$ac_save_LIBS"
113   fi
114
115   if test -z "$KRB5_LDFLAGS"; then
116      with_krb5=no
117   else
118      with_krb5=yes
119      AC_DEFINE(KRB5)
120
121      # check for Heimdal
122      have_heimdal=""
123      AC_MSG_CHECKING(whether we are using Heimdal)
124      ac_save_CFLAGS="$CFLAGS"
125      CFLAGS="$KRB5_CPPFLAGS"
126      AC_TRY_COMPILE([#include <krb5.h>],
127                     [ char *tmp = heimdal_version; ],
128                     [ AC_MSG_RESULT(yes)
129                       AC_DEFINE(HEIMDAL) ]
130                       have_heimdal=yes,
131                     [ AC_MSG_RESULT(no) ])
132      CFLAGS="$ac_save_CFLAGS"
133
134      if test -n "$have_heimdal"; then
135         SPNEGO_SRCS="\
136                 spnegokrb5/asn1_MechType.c         \
137                 spnegokrb5/asn1_MechTypeList.c     \
138                 spnegokrb5/asn1_ContextFlags.c     \
139                 spnegokrb5/asn1_NegTokenInit.c     \
140                 spnegokrb5/asn1_NegTokenTarg.c     \
141                 spnegokrb5/init_sec_context.c      \
142                 spnegokrb5/accept_sec_context.c    \
143                 spnegokrb5/encapsulate.c           \
144                 spnegokrb5/decapsulate.c           \
145                 spnegokrb5/external.c"
146      else
147         SPNEGO_SRCS="\
148                 spnegokrb5/asn1_MechType.c         \
149                 spnegokrb5/asn1_MechTypeList.c     \
150                 spnegokrb5/asn1_ContextFlags.c     \
151                 spnegokrb5/asn1_NegTokenInit.c     \
152                 spnegokrb5/asn1_NegTokenTarg.c     \
153                 spnegokrb5/der_get.c               \
154                 spnegokrb5/der_put.c               \
155                 spnegokrb5/der_free.c              \
156                 spnegokrb5/der_length.c            \
157                 spnegokrb5/der_copy.c              \
158                 spnegokrb5/timegm.c                \
159                 spnegokrb5/init_sec_context.c      \
160                 spnegokrb5/accept_sec_context.c    \
161                 spnegokrb5/encapsulate.c           \
162                 spnegokrb5/decapsulate.c           \
163                 spnegokrb5/external.c"
164      fi
165   fi
166 fi
167 AC_SUBST(KRB5_CPPFLAGS)
168 AC_SUBST(KRB5_LDFLAGS)
169 AC_SUBST(SPNEGO_SRCS)
170
171 #
172 # Kerberos4 enviroment
173 #
174
175 AC_ARG_WITH(krb4,
176   AC_HELP_STRING([--with-krb4=dir], [use krb4 in dir]),
177   [ with_krb4="$withval" ])
178
179 if test "x$with_krb4" != "xno"; then
180   AC_MSG_CHECKING([for Kerberos4 installation])
181   if test "x$with_krb4" != "x"; then
182      if test -x "$with_krb4/bin/krb4-config"; then
183         KRB4_CPPFLAGS=`$with_krb4/bin/krb4-config --cflags krb4 2>/dev/null`
184         KRB4_LDFLAGS=`$with_krb4/bin/krb4-config --libs krb4 2>/dev/null`
185      elif test -x "$with_krb4/bin/krb5-config"; then
186         KRB4_CPPFLAGS=`$with_krb4/bin/krb5-config --cflags krb4 2>/dev/null`
187         KRB4_LDFLAGS=`$with_krb4/bin/krb5-config --libs krb4 2>/dev/null`
188      else
189         AC_MSG_ERROR([failed to find krb4-config or krb5-config in $with_krb4/bin])
190      fi
191   else
192      KRB4_CPPFLAGS=`krb4-config --cflags krb4 2>/dev/null`
193      KRB4_LDFLAGS=`krb4-config --libs krb4 2>/dev/null`
194      if test "x$KRB4_LDFLAGS" = "x" -a -n "$krb5_config_command"; then
195         KRB4_CPPFLAGS=`$krb5_config_command --cflags krb4 2>/dev/null`
196         KRB4_LDFLAGS=`$krb5_config_command --libs krb4 2>/dev/null`
197         if test $? -ne 0; then
198            KRB4_CPPFLAGS=""
199            KRB4_LDFLAGS=""
200         fi
201      fi
202   fi
203   if test "x$KRB4_LDFLAGS" = "x"; then
204      with_krb4=no
205      AC_MSG_RESULT(no)
206   else
207      AC_MSG_RESULT(yes)
208
209      ac_save_CFLAGS=$CFLAGS
210      ac_save_CPPFLAGS=$CPPFLAGS
211      ac_save_LDFLAGS=$LDFLAGS
212      ac_save_LIBS=$LIBS
213      CFLAGS="$CFLAGS $KRB4_CPPFLAGS"
214      CPPFLAGS="$CFLAGS $KRB4_CPPFLAGS"
215      LDFLAGS="$LDFLAGS $KRB4_LDFLAGS"
216      LIBS="$LIBS $LDFLAGS $LIB_resolv"
217
218 #    if not found krb.h suppose it's in the kerberosIV subdirectory
219      AC_CHECK_HEADER(krb.h, , with_krb4=no)
220      if test "x$with_krb4" = "xno"; then
221          KRB4_CPPFLAGS="$KRB4_CPPFLAGS ${KRB4_CPPFLAGS}/kerberosIV"
222 #        second run of AC_CHECK_HEADER for the same library returns the cached
223 #        result created by previous run :-(
224          AC_CHECK_HEADER(kerberosIV/krb.h, with_krb4=yes,
225                          [  with_krb4=no
226                             KRB4_CPPFLAGS=""
227                             KRB4_LDFLAGS=""])
228      fi
229
230      if test "x$with_krb4" != "xno"; then
231         AC_CHECK_LIB(krb4, krb_get_pw_in_tkt, [], [with_krb4=no])
232         if test "x$with_krb4" = "xno"; then
233            AC_CHECK_LIB(krb, krb_get_pw_in_tkt, [with_krb4=yes], 
234                         [with_krb4=no
235                          KRB4_CPPFLAGS=""
236                          KRB4_LDFLAGS=""])
237         fi
238      fi
239
240      CFLAGS=$ac_save_CFLAGS
241      CPPFLAGS=$ac_save_CPPFLAGS
242      LDFLAGS=$ac_save_LDFLAGS
243      LIBS=$ac_save_LIBS
244
245      AC_DEFINE(KRB4)
246   fi
247 fi
248 AC_SUBST(KRB4_CPPFLAGS)
249 AC_SUBST(KRB4_LDFLAGS)
250
251
252 if test "x$with_krb5" = "xno" -a "x$with_krb4" = "xno"; then
253   AC_MSG_ERROR([No Kerberos enviroment found])
254 fi
255
256 #
257 # Apache enviroment
258 #
259 AC_ARG_WITH(apache,
260   AC_HELP_STRING([--with-apache=dir],[use apache in dir]),
261   [ with_apache="$withval" ])
262
263 AC_PATH_PROG([APXS], [apxs], [], [$with_apache/bin:$with_apache/sbin:$PATH])
264 if test -z "$APXS"; then
265    AC_MSG_ERROR([failed to find apache apxs executable])
266 fi
267 AC_SUBST(APXS)
268
269 AC_CONFIG_FILES([Makefile])
270
271 AC_OUTPUT