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