- Extended directories where the apache binaries are looked for
[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 SPNEGO_SRCS=""
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         ac_save_cflags=$CFLAGS
51         CFLAGS="-I$with_krb5/include"
52         AC_TRY_COMPILE([#include <krb5.h>],
53                        [ char *tmp = heimdal_version; ],
54                        [ KRB5_LDFLAGS="-L$with_krb5/lib -lgssapi -lkrb5 -lasn1 -ldes -lcrypt" ],
55                        [ KRB5_LDFLAGS="-L$with_krb5/lib -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err" ])
56         KRB5_CPPFLAGS="-I$with_krb5/include"
57         CFLAGS="$ac_save_cflags"
58         krb5_config_command=""
59      fi
60   fi
61
62   if test -n "$krb5_config_command"; then
63      KRB5_CPPFLAGS=`$krb5_config_command --cflags gssapi 2>/dev/null`
64      KRB5_LDFLAGS=`$krb5_config_command --libs gssapi 2>/dev/null`
65   fi
66   if test "x$KRB5_LDFLAGS" = "x"; then
67      with_krb5=no
68      AC_MSG_RESULT(no)
69   else
70      AC_MSG_RESULT(yes)
71
72      ac_save_CFLAGS=$CFLAGS
73      ac_save_LDFLAGS=$LDFLAGS
74      ac_save_LIBS=$LIBS
75      CFLAGS="$CFLAGS $KRB5_CPPFLAGS"
76      LDFLAGS="$LDFLAGS $KRB5_LDFLAGS"
77      LIBS="$LIBS $LDFLAGS $LIB_resolv"
78
79      AC_CHECK_LIB(krb5, krb5_init_context, [], [with_krb5=no])
80
81      if test "x$with_krb5" != "xno"; then
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      SPNEGO_SRCS="\
96         spnegokrb5/asn1_MechType.c         \
97         spnegokrb5/asn1_MechTypeList.c     \
98         spnegokrb5/asn1_ContextFlags.c     \
99         spnegokrb5/asn1_NegTokenInit.c     \
100         spnegokrb5/asn1_NegTokenTarg.c     \
101         spnegokrb5/der_get.c               \
102         spnegokrb5/der_put.c               \
103         spnegokrb5/der_free.c              \
104         spnegokrb5/der_length.c            \
105         spnegokrb5/der_copy.c              \
106         spnegokrb5/timegm.c                \
107         spnegokrb5/init_sec_context.c      \
108         spnegokrb5/accept_sec_context.c    \
109         spnegokrb5/encapsulate.c           \
110         spnegokrb5/decapsulate.c           \
111         spnegokrb5/external.c"
112   fi
113 fi
114 AC_SUBST(KRB5_CPPFLAGS)
115 AC_SUBST(KRB5_LDFLAGS)
116 AC_SUBST(SPNEGO_SRCS)
117
118 #
119 # Kerberos4 enviroment
120 #
121 KRB4_CPPFLAGS=""
122 KRB4_LDFLAGS=""
123
124 AC_ARG_WITH(krb4,
125   AC_HELP_STRING([--with-krb4=dir], [use krb4 in dir]),
126   [ with_krb4="$withval" ])
127
128 if test "x$with_krb4" != "xno"; then
129   AC_MSG_CHECKING([for Kerberos4 installation])
130   if test "x$with_krb4" != "x"; then
131      if test -x "$with_krb4/bin/krb4-config"; then
132         KRB4_CPPFLAGS=`$with_krb4/bin/krb4-config --cflags krb4 2>/dev/null`
133         KRB4_LDFLAGS=`$with_krb4/bin/krb4-config --libs krb4 2>/dev/null`
134      elif test -x "$with_krb4/bin/krb5-config"; then
135         KRB4_CPPFLAGS=`$with_krb4/bin/krb5-config --cflags krb4 2>/dev/null`
136         KRB4_LDFLAGS=`$with_krb4/bin/krb5-config --libs krb4 2>/dev/null`
137      else
138         AC_MSG_ERROR([failed to find krb4-config or krb5-config in $with_krb4/bin])
139      fi
140   else
141      KRB4_CPPFLAGS=`krb4-config --cflags krb4 2>/dev/null`
142      KRB4_LDFLAGS=`krb4-config --libs krb4 2>/dev/null`
143      if test "x$KRB4_LDFLAGS" = "x"; then
144         KRB4_CPPFLAGS=`$krb5_config_command --cflags krb4 2>/dev/null`
145         KRB4_LDFLAGS=`$krb5_config_command --libs krb4 2>/dev/null`
146         if test $? -ne 0; then
147            KRB4_CPPFLAGS=""
148            KRB4_LDFLAGS=""
149         fi
150      fi
151   fi
152   if test "x$KRB4_LDFLAGS" = "x"; then
153      with_krb4=no
154      AC_MSG_RESULT(no)
155   else
156      AC_MSG_RESULT(yes)
157
158      ac_save_CFLAGS=$CFLAGS
159      ac_save_CPPFLAGS=$CPPFLAGS
160      ac_save_LDFLAGS=$LDFLAGS
161      ac_save_LIBS=$LIBS
162      CFLAGS="$CFLAGS $KRB4_CPPFLAGS"
163      CPPFLAGS="$CFLAGS $KRB4_CPPFLAGS"
164      LDFLAGS="$LDFLAGS $KRB4_LDFLAGS"
165      LIBS="$LIBS $LDFLAGS $LIB_resolv"
166
167 #    if not found krb.h suppose it's in the kerberosIV subdirectory
168      AC_CHECK_HEADER(krb.h, , with_krb4=no)
169      if test "x$with_krb4" = "xno"; then
170          KRB4_CPPFLAGS="$KRB4_CPPFLAGS ${KRB4_CPPFLAGS}/kerberosIV"
171 #        second run of AC_CHECK_HEADER for the same library returns the cached
172 #        result created by previous run :-(
173          AC_CHECK_HEADER(kerberosIV/krb.h, with_krb4=yes,
174                          [  with_krb4=no
175                             KRB4_CPPFLAGS=""
176                             KRB4_LDFLAGS=""])
177      fi
178
179      if test "x$with_krb4" != "xno"; then
180         AC_CHECK_LIB(krb4, krb_get_pw_in_tkt, [], [with_krb4=no])
181         if test "x$with_krb4" = "xno"; then
182            AC_CHECK_LIB(krb, krb_get_pw_in_tkt, [with_krb4=yes], 
183                         [with_krb4=no
184                          KRB4_CPPFLAGS=""
185                          KRB4_LDFLAGS=""])
186         fi
187      fi
188
189      CFLAGS=$ac_save_CFLAGS
190      CPPFLAGS=$ac_save_CPPFLAGS
191      LDFLAGS=$ac_save_LDFLAGS
192      LIBS=$ac_save_LIBS
193
194      AC_DEFINE(KRB4)
195   fi
196 fi
197 AC_SUBST(KRB4_CPPFLAGS)
198 AC_SUBST(KRB4_LDFLAGS)
199
200
201 if test "x$with_krb5" = "xno" -a "x$with_krb4" = "xno"; then
202   AC_MSG_ERROR([No Kerberos enviroment found])
203 fi
204
205 #
206 # Apache enviroment
207 #
208 AC_ARG_WITH(apache,
209   AC_HELP_STRING([--with-apache=dir],[use apache in dir]),
210   [ with_apache="$withval" ])
211
212 AC_MSG_CHECKING([for Apache installation])
213 HTTPD=""
214 APXS=""
215 if test -n "$with_apache"; then
216   apache_dirs="$with_apache/sbin $with_apache/bin"
217 else
218 # XXX the PATH variable should be used rather
219   apache_dirs="/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin"
220 fi
221
222 for dir in $apache_dirs; do
223   if test -z "$HTTPD"; then
224      for name in apache2 apache httpd; do
225         if test -x "$dir/$name"; then
226            HTTPD="$dir/$name"
227            break
228         fi
229      done
230   fi
231   if test -z "$APXS"; then
232      for name in apxs2 apxs; do
233         if test -x "$dir/$name"; then
234            APXS="$dir/$name"
235            break
236         fi
237      done
238   fi
239 done
240
241 if test -z "$HTTPD"; then
242    AC_MSG_ERROR([failed to find apache httpd executable])
243 fi
244 if test -z "$APXS"; then
245    AC_MSG_ERROR([failed to find apache apxs executable])
246 fi
247
248 apache_v1_3=`$HTTPD -v | grep "^Server version: Apache/1.3."`
249 apache_v2_0=`$HTTPD -v | grep "^Server version: Apache/2.0."`
250 if test "x$apache_v1_3" = "x" -a "x$apache_v2_0" = "x"; then
251   AC_MSG_ERROR([cannot find valid apache installation on your system])
252 fi
253 if test -n "$apache_v1_3"; then
254   AC_DEFINE(APXS1)
255 fi
256 AC_MSG_RESULT(yes)
257
258 AC_SUBST(APXS)
259
260 AC_CONFIG_FILES([Makefile])
261
262 AC_OUTPUT