added prelim support for Apache 1.3 modules
[shibboleth/cpp-sp.git] / configure.ac
1 dnl $Id$ 
2
3 AC_PREREQ([2.50])
4 AC_INIT([shibboleth], [0.1], [mace-shib-users@internet2.edu], [shibboleth])
5 AM_CONFIG_HEADER(config.h)
6 AM_INIT_AUTOMAKE
7
8 sinclude(acx_pthread.m4)
9
10 AC_PROG_CC([gcc3 gcc cc])
11 AC_PROG_CXX([g++3 g++ c++ CC])
12 AC_DISABLE_STATIC
13 AC_PROG_LIBTOOL
14
15 AC_LANG(C++)
16
17 # Checks for typedefs, structures, and compiler characteristics.
18 AC_C_CONST
19 AC_TYPE_SIZE_T
20 AC_STRUCT_TM
21
22 # Checks for library functions.
23 AC_FUNC_STRFTIME
24 AC_CHECK_FUNCS([strchr strdup strstr gmtime_r])
25 AC_CHECK_HEADERS([dlfcn.h])
26
27 # C++ requirements
28 AC_CXX_REQUIRE_STL
29 AC_CXX_NAMESPACES
30
31 # checks for pthreads
32 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
33 if test $enable_threads != "pthread"; then
34     AC_MSG_ERROR([unable to find pthreads, currently this is required])
35 else
36     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
37     LIBS="$PTHREAD_LIBS $LIBS"
38     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
39     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
40 fi
41
42 AC_ARG_WITH(xerces, 
43             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
44             [if test x_$with_xerces != x_/usr; then
45                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
46                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
47             fi])
48
49
50 AC_ARG_WITH(openssl, 
51             AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
52             [if test x_$with_openssl != x_/usr; then
53                 LDFLAGS="-L${with_openssl}/lib $LDFLAGS"
54                 CPPFLAGS="-I${with_openssl}/include $CPPFLAGS"
55             fi])
56
57 AC_ARG_WITH(log4cpp, 
58             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp is installed]),
59             [if test x_$with_log4cpp != x_/usr; then
60                 LDFLAGS="-L${with_log4cpp}/lib $LDFLAGS"
61                 CPPFLAGS="-I${with_log4cpp}/include $CPPFLAGS"
62             fi])
63
64 AC_ARG_WITH(saml,
65             AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
66             [if test x_$with_saml != x_/usr; then
67                 LDFLAGS="-L${with_saml}/lib $LDFLAGS"
68                 CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
69             fi])
70
71 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
72                 AC_MSG_ERROR([unable to find xerces header files]))
73 saved_LIBS="$LIBS"
74 LIBS="-lxerces-c $LIBS"
75 AC_TRY_LINK(
76         [#include <xercesc/util/PlatformUtils.hpp>],
77         [XMLPlatformUtils::Initialize()],
78         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
79         [AC_MSG_ERROR([unable to link with Xerces])
80                 LIBS="$saved_LIBS"
81         ])
82
83 AC_CHECK_HEADER([openssl/ssl.h],,
84                 AC_MSG_ERROR([unable to find openssl header files]))
85 AC_CHECK_LIB([crypto], [ERR_load_CRYPTO_strings],,
86              AC_MSG_ERROR([unable to link with openssl libraries]))
87 AC_CHECK_LIB([ssl], [SSL_library_init],, 
88              AC_MSG_ERROR([unable to link with openssl libraries]))
89
90 AC_CHECK_HEADER([log4cpp/Category.hh],,
91                 AC_MSG_ERROR([unable to find log4cpp header files]))
92
93 AC_CHECK_HEADER([saml/saml.h],,
94                 AC_MSG_ERROR([unable to find saml header files]))
95
96 saved_LIBS="$LIBS"
97 LIBS="-llog4cpp $LIBS"
98 AC_TRY_LINK(
99         [#include <log4cpp/Category.hh>],
100         [log4cpp::Category::getInstance("foo")],
101         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
102         [AC_MSG_ERROR([unable to link with log4cpp])
103                 LIBS="$saved_LIBS"
104         ])
105
106 saved_LIBS="$LIBS"
107 LIBS="-lsaml $LIBS"
108 AC_TRY_LINK(
109         [#include <saml/saml.h>],
110         [saml::SAMLConfig::getConfig()],
111         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
112         [AC_MSG_ERROR([unable to link with saml])
113                 LIBS="$saved_LIBS"
114         ])
115
116 # output the underlying makefiles
117 WANT_SUBDIRS="shib schemas eduPerson shib-target shar test"
118 AC_CONFIG_FILES([Makefile shib/Makefile schemas/Makefile eduPerson/Makefile \
119                             shib-target/Makefile shar/Makefile test/Makefile])
120
121 # Much of this is taken from mod_dav.
122 # The basic idea is to use configure options to control whether/which types
123 # of web server modules get built. We assume there may eventually be multiple
124 # types (Apache 1/2, iPlanet, others).
125
126 # Apache 1.3 (mod_shire/mod_shibrm)
127 #   --with-apache   (static build, no idea how to do this yet, so not supported)
128 #   --with-apxs     (DSO build, the normal way, uses apxs to derive build flags)
129 #   --without-apxs  (DSO build, you tell us how to build using the environment)
130
131 AC_MSG_CHECKING([for dynamic Apache module support (w/ or w/o APXS)])
132 AC_ARG_WITH(apxs,
133 [  --with-apxs[=FILE]        Build shared Apache module(s). FILE is the optional
134                           pathname to the Apache apxs tool; defaults to "apxs".],
135 [
136     if test "$withval" = "yes"; then
137       for i in /usr/sbin /usr/local/apache/bin ; do
138         if test -f "$i/apxs"; then
139           APXS="$i/apxs"
140         fi
141       done
142       if test -z "$APXS"; then
143         APXS=apxs
144       fi
145     else
146       APXS="$withval"
147     fi
148 ])
149
150 if test "$APXS" = "no"; then
151
152     # --without-apxs means you want the modules,
153     #       but want to tell us how to build them
154     AC_MSG_RESULT(yes, but use environment, not apxs)
155     echo
156     echo "Did you set one or more of these?"
157     echo
158     echo "APXS_CFLAGS APXS_PREFIX APXS_INCLUDE APXS_LIBEXEC APXS_SYSCONFDIR"
159     echo
160
161     AC_MSG_NOTICE([APXS_CFLAGS is $APXS_CFLAGS])
162
163     # try and find the Apache root
164     if test -z "$APXS_PREFIX"; then
165         if test -d "/usr/local/apache"; then
166             APXS_PREFIX="/usr/local/apache"
167         else
168             AC_MSG_ERROR([You MUST set APXS_PREFIX so the right Apache can be located!])
169         fi
170     elif test ! -d "$APXS_PREFIX"; then
171         AC_MSG_ERROR([APXS_PREFIX of $APXS_PREFIX cannot be found])
172     fi
173     AC_MSG_NOTICE([APXS_PREFIX is $APXS_PREFIX])
174     
175
176     # other subfolders might be derived from APXS_PREFIX
177     if test -z "$APXS_INCLUDE"; then
178         if test -f "$APXS_PREFIX/include/httpd.h"; then
179             APXS_INCLUDE="$APXS_PREFIX/include"
180         else
181             AC_MSG_ERROR([can't find Apache include files beneath $APXS_PREFIX])
182         fi
183     elif ! test -f "$APXS_INCLUDE/httpd.h"; then
184         AC_MSG_ERROR([APXS_INCLUDE of $APXS_INCLUDE does not contain Apache headers])
185     fi
186     AC_MSG_NOTICE([APXS_INCLUDE is $APXS_INCLUDE])
187
188     if test -z "$APXS_LIBEXEC"; then
189         if test -d "$APXS_PREFIX/libexec"; then
190             APXS_LIBEXEC="$APXS_PREFIX/libexec"
191         elif test -d "$APXS_PREFIX/modules"; then
192             APXS_LIBEXEC="$APXS_PREFIX/modules"
193         else
194             AC_MSG_ERROR([can't find Apache libexec/module directory beneath $APXS_PREFIX])
195         fi
196     elif ! test -d "$APXS_LIBEXEC"; then
197         AC_MSG_ERROR([APXS_LIBEXEC of $APXS_LIBEXEC does not exist])
198     fi
199     AC_MSG_NOTICE([APXS_LIBEXEC is $APXS_LIBEXEC])
200
201     if test -z "$APXS_SYSCONFDIR"; then
202         if test -d "$APXS_PREFIX/conf"; then
203             APXS_SYSCONFDIR="$APXS_PREFIX/conf"
204         else
205             AC_MSG_ERROR([can't find Apache conf directory beneath $APXS_PREFIX])
206         fi
207     elif ! test -d "$APXS_SYSCONFDIR"; then
208         AC_MSG_ERROR([APXS_SYSCONFDIR of $APXS_SYSCONFDIR does not exist])
209     fi
210     AC_MSG_NOTICE([APXS_SYSCONFDIR is $APXS_SYSCONFDIR])
211
212     WANT_APACHE="yes"
213
214 elif test -n "$APXS"; then
215
216     # extract settings we need from APXS -q
217     APXS_CC="`$APXS -q CC`"
218     APXS_CFLAGS="`$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
219     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
220     APXS_LIBEXEC="`$APXS -q LIBEXECDIR`"
221     APXS_SYSCONFDIR="`$APXS -q SYSCONFDIR`"
222
223     AC_SUBST(APXS)
224     AC_MSG_RESULT(found at $APXS)
225
226     if test -z "`$APXS -q LD_SHLIB`" || test "$APXS_LIBEXEC" = "modules"; then
227             AC_MSG_ERROR(
228 [Your APXS installation is broken and cannot be used.
229     Please see http://www.webdav.org/mod_dav/install.html#apxs for
230     more information.])
231     fi
232
233     WANT_APACHE="yes"
234
235 else
236     # guess we're not doing Apache 1.3
237     AC_MSG_RESULT(no)
238     WANT_APACHE="no"
239 fi
240
241 if test "$WANT_APACHE" = "yes"; then
242     AC_ARG_WITH(apreq,
243                 AC_HELP_STRING([--with-apreq=PATH], [where libapreq is installed]),
244                 [if test x_$with_apreq != x_/usr; then
245                     LDFLAGS="-L${with_apreq}/lib $LDFLAGS"
246                     CPPFLAGS="-I${with_apreq}/include $CPPFLAGS"
247                 fi])
248
249     AC_SUBST(APXS_CFLAGS)
250     AC_SUBST(APXS_INCLUDE)
251     AC_SUBST(APXS_LIBEXEC)
252     AC_SUBST(APXS_SYSCONFDIR)
253
254     # output the Apache 1.3 makefiles
255     WANT_SUBDIRS="$WANT_SUBDIRS mod_shire mod_shibrm"
256     AC_CONFIG_FILES([mod_shire/Makefile mod_shibrm/Makefile])
257 fi
258
259 AC_SUBST(WANT_SUBDIRS)
260
261 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
262   echo "=================================================================="
263   echo "WARNING: You have chosen to compile Apache modules with a different"
264   echo "         compiler than the one used to compile Apache."
265   echo ""
266   echo "    Current compiler:      $CC"
267   echo "   Apache's compiler:      $APXS_CC"
268   echo ""
269   echo "This could cause some problems."
270   echo "=================================================================="
271 fi
272
273 AC_OUTPUT
274