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