- the spnegokrb5 lib is not used if only krb4 is specified
[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-rc2, 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 DO_KRB5=
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         AC_MSG_ERROR([failed to find krb5-config in $with_krb5/bin])
49      fi
50      krb5_config_command="$with_krb5/bin/krb5-config"
51   fi
52
53   KRB5_CPPFLAGS=`$krb5_config_command --cflags gssapi 2>/dev/null`
54   KRB5_LDFLAGS=`$krb5_config_command --libs gssapi 2>/dev/null`
55   if test "x$KRB5_LDFLAGS" = "x"; then
56      with_krb5=no
57      AC_MSG_RESULT(no)
58   else
59      AC_MSG_RESULT(yes)
60
61      ac_save_CFLAGS=$CFLAGS
62      ac_save_LDFLAGS=$LDFLAGS
63      ac_save_LIBS=$LIBS
64      CFLAGS="$CFLAGS $KRB5_CPPFLAGS"
65      LDFLAGS="$LDFLAGS $KRB5_LDFLAGS"
66      LIBS="$LIBS $LDFLAGS $LIB_resolv"
67
68      AC_CHECK_LIB(krb5, krb5_init_context, [], [with_krb5=no])
69
70      if test "x$with_krb5" != "xno"; then
71         # check if krb5_cc_gen_new() is implemented by the krb5 library
72         AC_CHECK_FUNC(krb5_cc_gen_new, [AC_DEFINE(HAVE_KRB5_CC_GEN_NEW)])
73
74         # check if you're using Heimdal
75         # ...
76      fi
77
78      CFLAGS=$ac_save_CFLAGS
79      LDFLAGS=$ac_save_LDFLAGS
80      LIBS=$ac_save_LIBS
81      AC_DEFINE(KRB5)
82      DO_KRB5=yes
83   fi
84 fi
85 AC_SUBST(KRB5_CPPFLAGS)
86 AC_SUBST(KRB5_LDFLAGS)
87 AC_SUBST(DO_KRB5)
88
89 #
90 # Kerberos4 enviroment
91 #
92 KRB4_CPPFLAGS=""
93 KRB4_LDFLAGS=""
94
95 AC_ARG_WITH(krb4,
96   AC_HELP_STRING([--with-krb4=dir], [use krb4 in dir]),
97   [ with_krb4="$withval" ])
98
99 if test "x$with_krb4" != "xno"; then
100   AC_MSG_CHECKING([for Kerberos4 installation])
101   if test "x$with_krb4" != "x"; then
102      if test -x "$with_krb4/bin/krb4-config"; then
103         KRB4_CPPFLAGS=`$with_krb4/bin/krb4-config --cflags krb4 2>/dev/null`
104         KRB4_LDFLAGS=`$with_krb4/bin/krb4-config --libs krb4 2>/dev/null`
105      elif test -x "$with_krb4/bin/krb5-config"; then
106         KRB4_CPPFLAGS=`$with_krb4/bin/krb5-config --cflags krb4 2>/dev/null`
107         KRB4_LDFLAGS=`$with_krb4/bin/krb5-config --libs krb4 2>/dev/null`
108      else
109         AC_MSG_ERROR([failed to find krb4-config or krb5-config in $with_krb4/bin])
110      fi
111   else
112      KRB4_CPPFLAGS=`krb4-config --cflags krb4 2>/dev/null`
113      KRB4_LDFLAGS=`krb4-config --libs krb4 2>/dev/null`
114      if test "x$KRB4_LDFLAGS" = "x"; then
115         KRB4_CPPFLAGS=`$krb5_config_command --cflags krb4 2>/dev/null`
116         KRB4_LDFLAGS=`$krb5_config_command --libs krb4 2>/dev/null`
117      fi
118   fi
119   if test "x$KRB4_LDFLAGS" = "x"; then
120      with_krb4=no
121      AC_MSG_RESULT(no)
122   else
123      AC_MSG_RESULT(yes)
124
125      ac_save_CFLAGS=$CFLAGS
126      ac_save_CPPFLAGS=$CPPFLAGS
127      ac_save_LDFLAGS=$LDFLAGS
128      ac_save_LIBS=$LIBS
129      CFLAGS="$CFLAGS $KRB4_CPPFLAGS"
130      CPPFLAGS="$CFLAGS $KRB4_CPPFLAGS"
131      LDFLAGS="$LDFLAGS $KRB4_LDFLAGS"
132      LIBS="$LIBS $LDFLAGS $LIB_resolv"
133
134 #    if not found krb.h suppose it's in the kerberosIV subdirectory
135      AC_CHECK_HEADER(krb.h, , with_krb4=no)
136      if test "x$with_krb4" = "xno"; then
137          KRB4_CPPFLAGS="$KRB4_CPPFLAGS ${KRB4_CPPFLAGS}/kerberosIV"
138 #        second run of AC_CHECK_HEADER for the same library returns the cached
139 #        result created by previous run :-(
140          AC_CHECK_HEADER(kerberosIV/krb.h, with_krb4=yes,
141                          [  with_krb4=no
142                             KRB4_CPPFLAGS=""
143                             KRB4_LDFLAGS=""])
144      fi
145
146      if test "x$with_krb4" != "xno"; then
147         AC_CHECK_LIB(krb4, krb_get_pw_in_tkt, [], [with_krb4=no])
148         if test "x$with_krb4" = "xno"; then
149            AC_CHECK_LIB(krb, krb_get_pw_in_tkt, [with_krb4=yes], 
150                         [with_krb4=no
151                          KRB4_CPPFLAGS=""
152                          KRB4_LDFLAGS=""])
153         fi
154      fi
155
156      CFLAGS=$ac_save_CFLAGS
157      CPPFLAGS=$ac_save_CPPFLAGS
158      LDFLAGS=$ac_save_LDFLAGS
159      LIBS=$ac_save_LIBS
160
161      AC_DEFINE(KRB4)
162   fi
163 fi
164 AC_SUBST(KRB4_CPPFLAGS)
165 AC_SUBST(KRB4_LDFLAGS)
166
167
168 if test "x$with_krb5" = "xno" -a "x$with_krb4" = "xno"; then
169   AC_MSG_ERROR([No Kerberos enviroment found])
170 fi
171
172 #
173 # Apache enviroment
174 #
175 AC_ARG_WITH(apache,
176   AC_HELP_STRING([--with-apache=dir],[use apache in dir]),
177   [ with_apache="$withval" ])
178
179 AC_MSG_CHECKING([for Apache installation])
180
181 APXS="apxs"
182 HTTPD="httpd"
183 if test "x$with_apache" != "x"; then
184   if test ! -x "$with_apache/bin/httpd" -o ! -x "$with_apache/bin/apxs"; then
185      AC_MSG_ERROR([failed to find apache files in $with_apache])
186   fi
187   APXS="$with_apache/bin/apxs"
188   if test ! -x $APXS; then
189      APXS="$with_apache/sbin/apxs"
190   fi
191   HTTPD="$with_apache/bin/httpd"
192   if test ! -x $HTTPD; then
193      HTTPD"$with_apache/sbin/httpd"
194   fi
195 fi
196
197 apache_v1_3=`$HTTPD -v | grep "^Server version: Apache/1.3."`
198 apache_v2_0=`$HTTPD -v | grep "^Server version: Apache/2.0."`
199 if test "x$apache_v1_3" = "x" -a "x$apache_v2_0" = "x"; then
200   AC_MSG_ERROR([cannot find valid apache installation on your system])
201 fi
202 if test -n "$apache_v1_3"; then
203   AC_DEFINE(APXS1)
204 fi
205 AC_MSG_RESULT(yes)
206
207 AC_SUBST(APXS)
208
209 AC_CONFIG_FILES([Makefile
210                  spnegokrb5/Makefile])
211
212 AC_OUTPUT