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