Added a fair amount of functionality that was present in 4.*.
[mod_auth_kerb.git] / configure.in
1 dnl ####################
2 dnl ## Initialization ##
3 dnl ####################
4 AC_INIT(Apache Kerberos Module,
5         alpha2,
6         modauthkerb-developers@lists.sourceforge.net,
7         mod_auth_kerb)
8
9
10 dnl ####################
11 dnl ## Config Options ##
12 dnl ####################
13 AC_ARG_WITH(api,
14 [  --with-api=API                      api to use (apache1, apache2)],
15 [
16         case $withval in
17                 'apache1')
18                         ac_api=apache1
19                         ac_apidefs="-DAPXS1"
20                         ;;
21                 'apache2')
22                         ac_api=apache2
23                         ac_apidefs="-DAPXS2"
24                         ;;
25                 *)
26                         AC_ERROR(You can only specify apache1 or apache2.)
27                         ;;
28         esac
29 ]
30 )
31
32 AC_ARG_WITH(apxs,
33 [  --with-apxs=PATH                    path to apxs],
34 [
35         if test -e $withval ; then
36                 APXS="$withval"
37         else
38                 AC_ERROR(Specified apxs path does not exist.)
39         fi
40 ]
41 )
42
43 AC_ARG_WITH(static,
44 [  --with-static                       module is to be statically linked],
45 [
46         ac_static="yes"
47 ]
48 )
49
50 AC_ARG_WITH(krb5,
51 [  --with-krb5=DIR                     path to Kerberos 5 install],
52 [
53         if test -d $withval ; then
54                 CFLAGS="$CFLAGS -I$withval/include -I$withval/include/kerberosIV"
55                 CPPFLAGS="$CPPFLAGS -I$withval/include -I$withval/include/kerberosIV"
56                 LDFLAGS="$LDFLAGS -L$withval/lib"
57
58                 case "$host" in
59                         *-solaris*)
60                                 LDFLAGS="$LDFLAGS -R$withval/lib"
61                                 ;;
62                 esac
63         else
64                 AC_ERROR(Specified Kerberos 5 directory doesn't exist.)
65         fi
66 ]
67 )
68
69 AC_ARG_WITH(krb5-include,
70 [    --with-krb5-include=DIR           include path to Kerberos 5 install],
71 [
72         if test -d $withval ; then
73                 CFLAGS="$CFLAGS -I$withval -I$withval/include/kerberosIV"
74                 CPPFLAGS="$CPPFLAGS -I$withval -I$withval/include/kerberosIV"
75         else
76                 AC_ERROR(Specified Kerberos 5 directory doesn't exist.)
77         fi
78 ]
79 )
80
81 AC_ARG_WITH(krb5-lib,
82 [    --with-krb5-lib=DIR               lib path to Kerberos 5 install],
83 [
84         if test -d $withval ; then
85                 LDFLAGS="$LDFLAGS -L$withval"
86
87                 case "$host" in
88                         *-solaris*)
89                                 LDFLAGS="$LDFLAGS -R$withval"
90                                 ;;
91                 esac
92         else
93                 AC_ERROR(Specified Kerberos 5 directory doesn't exist.)
94         fi
95 ]
96 )
97
98 AC_ARG_ENABLE(krb5,
99 [  --disable-krb5                      force disabling of krb5 support],
100 [
101         if test "$enable_krb5" = "no" ; then
102                 ac_krb5_disable="yes"
103         fi
104 ],
105 )
106
107 AC_ARG_WITH(krb4,
108 [  --with-krb4=DIR                     path to Kerberos 4 install],
109 [
110         if test -d $withval ; then
111                 CFLAGS="$CFLAGS -I$withval/include"
112                 CPPFLAGS="$CPPFLAGS -I$withval/include"
113                 LDFLAGS="$LDFLAGS -L$withval/lib"
114
115                 case "$host" in
116                         *-solaris*)
117                                 LDFLAGS="$LDFLAGS -R$withval/lib"
118                                 ;;
119                 esac
120         else
121                 AC_ERROR(Specified Kerberos 4 directory doesn't exist.)
122         fi
123 ]
124 )
125
126 AC_ARG_WITH(krb4-include,
127 [    --with-krb4-include=DIR           include path to Kerberos 4 install],
128 [
129         if test -d $withval ; then
130                 CFLAGS="$CFLAGS -I$withval"
131                 CPPFLAGS="$CPPFLAGS -I$withval"
132         else
133                 AC_ERROR(Specified Kerberos 4 directory doesn't exist.)
134         fi
135 ]
136 )
137
138 AC_ARG_WITH(krb4-lib,
139 [    --with-krb4-lib=DIR               lib path to Kerberos 4 install],
140 [
141         if test -d $withval ; then
142                 LDFLAGS="$LDFLAGS -L$withval"
143
144                 case "$host" in
145                         *-solaris*)
146                                 LDFLAGS="$LDFLAGS -R$withval"
147                                 ;;
148                 esac
149         else
150                 AC_ERROR(Specified Kerberos 4 directory doesn't exist.)
151         fi
152 ]
153 )
154
155 AC_ARG_ENABLE(krb4,
156 [  --disable-krb4                      force disabling of krb4 support],
157 [
158         if test "$enable_krb4" = "no" ; then
159                 ac_krb4_disable="yes"
160         fi
161 ],
162 )
163
164
165 dnl ####################
166 dnl ## Program Checks ##
167 dnl ####################
168 AC_PROG_CC
169 if test -z "$ac_static" ; then
170         AC_PATH_PROG(APXS, apxs)
171         if test -z "$APXS" ; then
172                 echo "No apxs found.  Defaulting to static module generation."
173                 ac_static="yes"
174         fi
175 fi
176
177
178 dnl ###############
179 dnl ## Libraries ##
180 dnl ###############
181 if test -z "$ac_krb5_disable" ; then
182         AC_CHECK_LIB(krb5, krb5_get_in_tkt_with_password, [
183                 ac_krb5="yes"
184                 ac_krbdefs="-DKRB5"
185                 ac_krblibs="-lkrb5"
186                 AC_CHECK_LIB(k5crypto, krb5_string_to_key, [
187                         ac_krblibs="$ac_krblibs -lk5crypto"
188                 ], [
189                         AC_CHECK_LIB(crypto, krb5_string_to_key, [
190                                 ac_krblibs="$ac_krblibs -lcrypto"
191                         ], [
192                                 ac_krblibs=""
193                         ], "-lcom_err")
194                 ], "-lcom_err")
195                 ac_krblibs="$ac_krblibs -lcom_err"
196                 
197                 if test -z "$ac_krb4_disable" ; then
198                         if test -n "$ac_krblibs" ; then
199                                 AC_CHECK_LIB(krb4, krb_get_pw_in_tkt, [
200                                         ac_krb4="yes"
201                                         ac_krbdefs="$ac_krbdefs -DKRB4"
202                                         ac_krblibs="$ac_krblibs -lkrb4 $ac_krblibs"
203                                 ],, $ac_krblibs)
204                         fi
205                 fi
206         ],, "-lcom_err")
207 fi
208
209 if test -z "$ac_krb4_disable" -a -z "$ac_krb4" ; then
210         AC_CHECK_LIB(krb, krb_get_pw_in_tkt, [
211                 ac_krb4="yes"
212                 ac_krbdefs="-DKRB4"
213                 ac_krblibs="$ac_krblibs -lkrb -lcom_err"
214         ],, "-lcom_err")
215 fi
216
217 if test -z "$ac_krb4" -a -z "$ac_krb5" ; then
218         AC_ERROR(Neither Kerberos 5 nor 4 support available.)
219 fi
220
221
222 dnl #############
223 dnl ## Headers ##
224 dnl #############
225 if test -n "$ac_krb5" ; then
226         AC_CHECK_HEADERS(krb5.h, [
227                 ac_foundkrb5="yes"
228                 break
229         ])
230
231         if test -z "$ac_foundkrb5" ; then
232                 AC_MSG_RESULT(krb5.h not found... removing krb5 support.)
233                 ac_krb5=""
234         fi
235 fi
236
237 if test -n "$ac_krb4" ; then
238         AC_CHECK_HEADERS(kerberosIV/krb.h krb.h, [
239                 ac_foundkrb4="yes"
240                 break
241         ])
242
243         if test -z "$ac_foundkrb4" ; then
244                 AC_MSG_RESULT(krb.h not found... removing krb4 support.)
245                 ac_krb4=""
246         fi
247 fi
248
249 if test -z "$ac_krb4" -a -z "$ac_krb5" ; then
250         AC_ERROR(Neither Kerberos 5 nor 4 support available.)
251 fi
252
253
254 dnl ##############
255 dnl ## Typedefs ##
256 dnl ##############
257
258
259 dnl ################
260 dnl ## Structures ##
261 dnl ################
262
263
264 dnl ##############################
265 dnl ## Compiler Characteristics ##
266 dnl ##############################
267 if test -z "$ac_api" ; then
268         if test -n "`$APXS -q bindir 2> /dev/null`" ; then
269                 echo "API autodetected to be Apache 2.*"
270                 ac_api=apache2
271                 ac_apidefs="-DAPXS2"
272         else
273                 echo "API autodetected to be Apache 1.*"
274                 ac_api=apache1
275                 ac_apidefs="-DAPXS1"
276         fi
277 fi
278
279
280 dnl #######################
281 dnl ## Library Functions ##
282 dnl #######################
283
284
285 dnl #####################
286 dnl ## System Services ##
287 dnl #####################
288
289
290 dnl ##########################
291 dnl ## Last Minute Settings ##
292 dnl ##########################
293 LIBS="$LIBS $ac_krblibs"
294 DEFS="$DEFS $ac_apidefs $ac_krbdefs"
295 CFLAGS="$CFLAGS $DEFS"
296
297
298 dnl #########################
299 dnl ## Create Output Files ##
300 dnl #########################
301 if test "$ac_static" = "yes" ; then
302         echo ""
303         echo ""
304         echo "This module is to be built statically into Apache.  You will need"
305         echo "to place it into the appropriate location in the source tree and"
306         echo "compile Apache accordingly.  You can look at the online docs at"
307         echo "http://modauthkerb.sourceforge.net/ or README.static for more"
308         echo "information."
309         echo ""
310         echo ""
311 else
312         AC_OUTPUT(Makefile)
313         AC_OUTPUT(src/Makefile)
314 fi
315
316 exit 0