removed compilation warnings
[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.57)
4 AC_INIT(mod_auth_kerb, 5.3, 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" = "xyes" ; then
43   with_krb5=""
44 fi
45
46 if test "x$with_krb5" != "xno" ; then
47   ac_save_CPPFLAGS="$CPPFLAGS"
48   ac_save_LDFLAGS="$LDFLAGS"
49   ac_save_LIBS="$LIBS"
50    
51   if test -n "$with_krb5"; then
52      if test -x "$with_krb5/bin/krb5-config"; then
53         krb5_config_command="$with_krb5/bin/krb5-config"
54      else
55         krb5_config_command=""
56      fi
57   fi
58
59   dnl
60   dnl find header files
61   dnl
62
63   if test -z "$KRB5_CPPFLAGS"; then
64      TMP_KRB5_CPPFLAGS=""
65      if test -n "$krb5_config_command"; then
66         TMP_KRB5_CPPFLAGS=`$krb5_config_command --cflags gssapi 2>/dev/null`
67      fi
68      if test -z "$TMP_KRB5_CPPFLAGS" -a -n "with_krb5"; then
69         TMP_KRB5_CPPFLAGS="-I$with_krb5/include"
70      fi
71      CPPFLAGS="$CPPFLAGS $TMP_KRB5_CPPFLAGS"
72      AC_CHECK_HEADERS(gssapi.h, 
73                       [ KRB5_CPPFLAGS="$TMP_KRB5_CPPFLAGS" ])
74      if test -z "$KRB5_CPPFLAGS"; then
75         AC_CHECK_HEADERS(gssapi/gssapi.h, 
76                          [ KRB5_CPPFLAGS="$TMP_KRB5_CPPFLAGS" ])
77      fi
78      CPPFLAGS="$ac_save_CPPFLAGS" 
79   fi
80
81   dnl
82   dnl find libraries
83   dnl
84
85   if test -z "$KRB5_LDFLAGS" -a -n "$krb5_config_command"; then
86      TMP_KRB5_LDFLAGS=`$krb5_config_command --libs gssapi 2>/dev/null`
87      if test -n "$TMP_KRB5_LDFLAGS"; then
88         LIBS="$LIBS $TMP_KRB5_LDFLAGS $LIB_resolv"
89         AC_CHECK_LIB(krb5, krb5_init_context,
90                      [ KRB5_LDFLAGS="$TMP_KRB5_LDFLAGS" ])
91         LIBS="$ac_save_LIBS"
92      fi
93   fi
94   if test "x$with_krb5"="x"; then
95         tmp_lf_inc=""
96      else
97         tmp_lf_inc="-L"
98   fi
99   if test -z "$KRB5_LDFLAGS"; then
100      #try MIT
101      TMP_KRB5_LDFLAGS="$tmp_lf_inc$with_krb5/lib -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err"
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
109      TMP_KRB5_LDFLAGS="$tmp_lf_inc$with_krb5/lib -lgssapi -lkrb5 -lasn1 -lcrypto -lroken -lcrypt"
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      #Try Heimdal on OpenBSD
117      TMP_KRB5_LDFLAGS="$tmp_lf_inc$with_krb5/lib -lgssapi -lkrb5 -lasn1 -ldes -lcrypto"
118      LIBS="$LIBS $TMP_KRB5_LDFLAGS $LIB_resolv"
119      AC_CHECK_LIB(krb5, krb5_init_context, [ KRB5_LDFLAGS="$TMP_KRB5_LDFLAGS" ])
120      LIBS="$ac_save_LIBS"
121   fi
122
123   if test -z "$KRB5_LDFLAGS"; then
124      with_krb5=no
125   else
126      AC_DEFINE(KRB5)
127      AC_CHECK_LIB(krb5,
128                   krb5_cc_new_unique,
129                   [ AC_DEFINE(HAVE_KRB5_CC_NEW_UNIQUE) ])
130
131      # check for Heimdal
132      have_heimdal=""
133      AC_MSG_CHECKING(whether we are using Heimdal)
134      ac_save_CFLAGS="$CFLAGS"
135      CFLAGS="$KRB5_CPPFLAGS"
136      AC_TRY_COMPILE([#include <krb5.h>],
137                     [ char *tmp = heimdal_version; ],
138                     [ AC_MSG_RESULT(yes)
139                       AC_DEFINE(HEIMDAL)
140                       have_heimdal=yes ],
141                     [ AC_MSG_RESULT(no) ])
142      CFLAGS="$ac_save_CFLAGS"
143
144 # If SPNEGO is supported by the gssapi libraries, we shouln't build our support.
145 # SPNEGO is supported as of Heimdal 0.7, and MIT 1.5.
146      gssapi_supports_spnego=""
147      AC_MSG_CHECKING(whether the GSSAPI libraries support SPNEGO)
148
149      ac_save_CFLAGS="$CFLAGS"
150      CFLAGS="$KRB5_CPPFLAGS"
151      ac_save_LDFLAGS="$LDFLAGS"
152      if test -n "$with_krb5"; then
153         LDFLAGS="$KRB5_LDFLAGS -Wl,-rpath -Wl,$with_krb5/lib"
154      else 
155         LDFLAGS="$KRB5_LDFLAGS"
156      fi
157      AC_TRY_RUN([
158 #include <string.h>
159 #include <krb5.h>
160 #ifdef HEIMDAL
161 #include <gssapi.h>
162 #else
163 #include <gssapi/gssapi.h>
164 #endif
165 int main(int argc, char** argv)
166 {
167        OM_uint32 major_status, minor_status;
168        gss_OID_set mech_set;
169        gss_OID_desc spnego_oid_desc = {6, (void *)"\x2b\x06\x01\x05\x05\x02"};
170        int SPNEGO = 0;
171                                                                                
172        major_status = gss_indicate_mechs(&minor_status, &mech_set);
173        if (GSS_ERROR(major_status))
174                return 1;
175        else {
176                unsigned int i;
177                for (i=0; i < mech_set->count && !SPNEGO; i++) {
178                        gss_OID tmp_oid = &mech_set->elements[i];
179                       if (tmp_oid->length == spnego_oid_desc.length &&
180                            !memcmp(tmp_oid->elements, spnego_oid_desc.elements, 
181                                    tmp_oid->length)) {
182                                SPNEGO = 1;
183                                break;
184                        }
185                }
186                gss_release_oid_set(&minor_status, &mech_set);
187                return (!SPNEGO);
188        }
189 }],
190                 [ if test $? -eq 0; then 
191                      AC_MSG_RESULT(yes)
192                      AC_DEFINE(GSSAPI_SUPPORTS_SPNEGO)
193                      gssapi_supports_spnego=yes 
194                   else
195                      AC_MSG_RESULT(no)
196                   fi],
197                 [AC_MSG_RESULT(no)])
198
199      CFLAGS="$ac_save_CFLAGS"
200      LDFLAGS="$ac_save_LDFLAGS"
201
202      if test -z "$gssapi_supports_spnego"; then
203         if test -n "$have_heimdal"; then SPNEGO_SRCS="\
204                 spnegokrb5/asn1_MechType.c         \
205                 spnegokrb5/asn1_MechTypeList.c     \
206                 spnegokrb5/asn1_ContextFlags.c     \
207                 spnegokrb5/asn1_NegTokenInit.c     \
208                 spnegokrb5/asn1_NegTokenTarg.c     \
209                 spnegokrb5/init_sec_context.c      \
210                 spnegokrb5/accept_sec_context.c    \
211                 spnegokrb5/encapsulate.c           \
212                 spnegokrb5/decapsulate.c           \
213                 spnegokrb5/external.c"
214         else SPNEGO_SRCS="\
215                 spnegokrb5/asn1_MechType.c         \
216                 spnegokrb5/asn1_MechTypeList.c     \
217                 spnegokrb5/asn1_ContextFlags.c     \
218                 spnegokrb5/asn1_NegTokenInit.c     \
219                 spnegokrb5/asn1_NegTokenTarg.c     \
220                 spnegokrb5/der_get.c               \
221                 spnegokrb5/der_put.c               \
222                 spnegokrb5/der_free.c              \
223                 spnegokrb5/der_length.c            \
224                 spnegokrb5/der_copy.c              \
225                 spnegokrb5/timegm.c                \
226                 spnegokrb5/init_sec_context.c      \
227                 spnegokrb5/accept_sec_context.c    \
228                 spnegokrb5/encapsulate.c           \
229                 spnegokrb5/decapsulate.c           \
230                 spnegokrb5/external.c"
231         fi
232      fi
233   fi
234 fi
235 AC_SUBST(KRB5_CPPFLAGS)
236 AC_SUBST(KRB5_LDFLAGS)
237 AC_SUBST(SPNEGO_SRCS)
238
239 #
240 # Kerberos4 enviroment
241 #
242
243 AC_ARG_WITH(krb4,
244   AC_HELP_STRING([--with-krb4=dir], [use krb4 in dir]),
245   [ with_krb4="$withval" ])
246
247 if test "x$with_krb4" = "xyes" ; then
248   with_krb4=""
249 fi
250
251 if test "x$with_krb4" != "xno"; then
252   AC_MSG_CHECKING([for Kerberos4 installation])
253   if test "x$with_krb4" != "x"; then
254      if test -x "$with_krb4/bin/krb4-config"; then
255         KRB4_CPPFLAGS=`$with_krb4/bin/krb4-config --cflags krb4 2>/dev/null`
256         KRB4_LDFLAGS=`$with_krb4/bin/krb4-config --libs krb4 2>/dev/null`
257      elif test -x "$with_krb4/bin/krb5-config"; then
258         KRB4_CPPFLAGS=`$with_krb4/bin/krb5-config --cflags krb4 2>/dev/null`
259         KRB4_LDFLAGS=`$with_krb4/bin/krb5-config --libs krb4 2>/dev/null`
260      else
261         AC_MSG_ERROR([failed to find krb4-config or krb5-config in $with_krb4/bin])
262      fi
263   else
264      KRB4_CPPFLAGS=`krb4-config --cflags krb4 2>/dev/null`
265      KRB4_LDFLAGS=`krb4-config --libs krb4 2>/dev/null`
266      if test "x$KRB4_LDFLAGS" = "x" -a -n "$krb5_config_command"; then
267         KRB4_CPPFLAGS=`$krb5_config_command --cflags krb4 2>/dev/null`
268         KRB4_LDFLAGS=`$krb5_config_command --libs krb4 2>/dev/null`
269         if test $? -ne 0; then
270            KRB4_CPPFLAGS=""
271            KRB4_LDFLAGS=""
272         fi
273      fi
274   fi
275   if test "x$KRB4_LDFLAGS" = "x"; then
276      with_krb4=no
277      AC_MSG_RESULT(no)
278   else
279      AC_MSG_RESULT(yes)
280
281      ac_save_CFLAGS=$CFLAGS
282      ac_save_CPPFLAGS=$CPPFLAGS
283      ac_save_LDFLAGS=$LDFLAGS
284      ac_save_LIBS=$LIBS
285      CFLAGS="$CFLAGS $KRB4_CPPFLAGS"
286      CPPFLAGS="$CFLAGS $KRB4_CPPFLAGS"
287      LDFLAGS="$LDFLAGS $KRB4_LDFLAGS"
288      LIBS="$LIBS $LDFLAGS $LIB_resolv"
289
290 #    if not found krb.h suppose it's in the kerberosIV subdirectory
291      AC_CHECK_HEADER(krb.h, , with_krb4=no)
292      if test "x$with_krb4" = "xno"; then
293          KRB4_CPPFLAGS="$KRB4_CPPFLAGS ${KRB4_CPPFLAGS}/kerberosIV"
294 #        second run of AC_CHECK_HEADER for the same library returns the cached
295 #        result created by previous run :-(
296          AC_CHECK_HEADER(kerberosIV/krb.h, with_krb4=yes,
297                          [  with_krb4=no
298                             KRB4_CPPFLAGS=""
299                             KRB4_LDFLAGS=""])
300      fi
301
302      if test "x$with_krb4" != "xno"; then
303         AC_CHECK_LIB(krb4, krb_get_pw_in_tkt, [], [with_krb4=no])
304         if test "x$with_krb4" = "xno"; then
305            AC_CHECK_LIB(krb, krb_get_pw_in_tkt, [with_krb4=yes], 
306                         [with_krb4=no
307                          KRB4_CPPFLAGS=""
308                          KRB4_LDFLAGS=""])
309         fi
310      fi
311
312      CFLAGS=$ac_save_CFLAGS
313      CPPFLAGS=$ac_save_CPPFLAGS
314      LDFLAGS=$ac_save_LDFLAGS
315      LIBS=$ac_save_LIBS
316
317      AC_DEFINE(KRB4)
318   fi
319 fi
320 AC_SUBST(KRB4_CPPFLAGS)
321 AC_SUBST(KRB4_LDFLAGS)
322
323
324 if test "x$with_krb5" = "xno" -a "x$with_krb4" = "xno"; then
325   AC_MSG_ERROR([No Kerberos enviroment found])
326 fi
327
328 #
329 # Apache enviroment
330 #
331 AC_ARG_WITH(apache,
332   AC_HELP_STRING([--with-apache=dir],[use apache in dir]),
333   [ with_apache="$withval" ])
334
335 AC_PATH_PROG([APXS], [apxs], [], [$with_apache/bin:$with_apache/sbin:$PATH])
336 if test -z "$APXS"; then
337    AC_PATH_PROG([APXS], [apxs2], [], [$with_apache/bin:$with_apache/sbin:$PATH])
338    if test -z "$APXS"; then
339       AC_MSG_ERROR([failed to find apache apxs executable])
340    fi
341 fi
342 AC_SUBST(APXS)
343
344 AC_CONFIG_FILES([Makefile])
345
346 AC_OUTPUT