configure.ac: add --with-dmalloc= option to compile with (some) dmalloc support
[shibboleth/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 AC_CHECK_FUNC(xdr_uint64_t,,
32         [CFLAGS="$CFLAGS -DNEED_XDR_LONGLONG"
33          CXXFLAGS="$CXXFLAGS -DNEED_XDR_LONGLONG"])
34
35 # checks for pthreads
36 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
37 if test $enable_threads != "pthread"; then
38     AC_MSG_ERROR([unable to find pthreads, currently this is required])
39 else
40     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
41     LIBS="$PTHREAD_LIBS $LIBS"
42     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
43     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
44 fi
45
46 AC_ARG_WITH(dmalloc,
47             AC_HELP_STRING([--with-dmalloc=PATH], [where dmalloc is installed]),
48             [if test x_$with_dmalloc != x_/usr; then
49                 LDFLAGS="-L${with_dmalloc}/lib $LDFLAGS"
50                 CPPFLAGS="-I${with_dmalloc}/include $CPPFLAGS"
51             fi
52             AC_CHECK_LIB(dmallocxx, dmalloc_shutdown,,
53                          AC_MSG_ERROR([unable to find dmallocxx library]))
54             ])
55
56 AC_ARG_WITH(xerces, 
57             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
58             [if test x_$with_xerces != x_/usr; then
59                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
60                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
61             fi])
62
63
64 AC_ARG_WITH(openssl, 
65             AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
66             [if test x_$with_openssl != x_/usr; then
67                 LDFLAGS="-L${with_openssl}/lib $LDFLAGS"
68                 CPPFLAGS="-I${with_openssl}/include $CPPFLAGS"
69             fi])
70
71 AC_ARG_WITH(log4cpp, 
72             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp is installed]),
73             [if test x_$with_log4cpp != x_/usr; then
74                 LDFLAGS="-L${with_log4cpp}/lib $LDFLAGS"
75                 CPPFLAGS="-I${with_log4cpp}/include $CPPFLAGS"
76             fi])
77
78 AC_ARG_WITH(saml,
79             AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
80             [if test x_$with_saml != x_/usr; then
81                 LDFLAGS="-L${with_saml}/lib $LDFLAGS"
82                 CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
83             fi])
84
85 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
86                 AC_MSG_ERROR([unable to find xerces header files]))
87 saved_LIBS="$LIBS"
88 LIBS="-lxerces-c $LIBS"
89 AC_TRY_LINK(
90         [#include <xercesc/util/PlatformUtils.hpp>],
91         [XMLPlatformUtils::Initialize()],
92         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
93         [AC_MSG_ERROR([unable to link with Xerces])
94                 LIBS="$saved_LIBS"
95         ])
96
97 AC_CHECK_HEADER([openssl/ssl.h],,
98                 AC_MSG_ERROR([unable to find openssl header files]))
99 AC_CHECK_LIB([crypto], [ERR_load_CRYPTO_strings],,
100              AC_MSG_ERROR([unable to link with openssl libraries]))
101 AC_CHECK_LIB([ssl], [SSL_library_init],, 
102              AC_MSG_ERROR([unable to link with openssl libraries]))
103
104 AC_CHECK_HEADER([log4cpp/Category.hh],,
105                 AC_MSG_ERROR([unable to find log4cpp header files]))
106
107 AC_CHECK_HEADER([saml/saml.h],,
108                 AC_MSG_ERROR([unable to find saml header files]))
109
110 saved_LIBS="$LIBS"
111 LIBS="-llog4cpp $LIBS"
112 AC_TRY_LINK(
113         [#include <log4cpp/Category.hh>],
114         [log4cpp::Category::getInstance("foo")],
115         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
116         [AC_MSG_ERROR([unable to link with log4cpp])
117                 LIBS="$saved_LIBS"
118         ])
119
120 saved_LIBS="$LIBS"
121 LIBS="-lsaml $LIBS"
122 AC_TRY_LINK(
123         [#include <saml/saml.h>],
124         [saml::SAMLConfig::getConfig()],
125         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
126         [AC_MSG_ERROR([unable to link with saml])
127                 LIBS="$saved_LIBS"
128         ])
129
130 # output the underlying makefiles
131 WANT_SUBDIRS="shib schemas eduPerson shib-target shar test"
132 AC_CONFIG_FILES([Makefile shib/Makefile schemas/Makefile eduPerson/Makefile \
133                             shib-target/Makefile shar/Makefile test/Makefile])
134
135 # Much of this is taken from mod_dav.
136 # The basic idea is to use configure options to control whether/which types
137 # of web server modules get built. We assume there may eventually be multiple
138 # types (Apache 1/2, iPlanet, others).
139
140 # Apache 1.3 (mod_shire/mod_shibrm)
141 #   --with-apache   (static build, no idea how to do this yet, so not supported)
142 #   --with-apxs     (DSO build, the normal way, uses apxs to derive build flags)
143 #   --without-apxs  (DSO build, you tell us how to build using the environment)
144
145 AC_MSG_CHECKING([for dynamic Apache module support (w/ or w/o APXS)])
146 AC_ARG_WITH(apxs,
147 [  --with-apxs[=FILE]        Build shared Apache module(s). FILE is the optional
148                           pathname to the Apache apxs tool; defaults to "apxs".],
149 [
150     if test "$withval" = "yes"; then
151       for i in /usr/sbin /usr/local/apache/bin ; do
152         if test -f "$i/apxs"; then
153           APXS="$i/apxs"
154         fi
155       done
156       if test -z "$APXS"; then
157         APXS=apxs
158       fi
159     else
160       APXS="$withval"
161     fi
162 ])
163
164 if test "$APXS" = "no"; then
165
166     # --without-apxs means you want the modules,
167     #       but want to tell us how to build them
168     AC_MSG_RESULT(yes, but use environment, not apxs)
169     echo
170     echo "Did you set one or more of these?"
171     echo
172     echo "APXS_CFLAGS APXS_PREFIX APXS_INCLUDE APXS_LIBEXEC APXS_SYSCONFDIR"
173     echo
174
175     AC_MSG_NOTICE([APXS_CFLAGS is $APXS_CFLAGS])
176
177     # try and find the Apache root
178     if test -z "$APXS_PREFIX"; then
179         if test -d "/usr/local/apache"; then
180             APXS_PREFIX="/usr/local/apache"
181         else
182             AC_MSG_ERROR([You MUST set APXS_PREFIX so the right Apache can be located!])
183         fi
184     elif test ! -d "$APXS_PREFIX"; then
185         AC_MSG_ERROR([APXS_PREFIX of $APXS_PREFIX cannot be found])
186     fi
187     AC_MSG_NOTICE([APXS_PREFIX is $APXS_PREFIX])
188     
189
190     # other subfolders might be derived from APXS_PREFIX
191     if test -z "$APXS_INCLUDE"; then
192         if test -f "$APXS_PREFIX/include/httpd.h"; then
193             APXS_INCLUDE="$APXS_PREFIX/include"
194         else
195             AC_MSG_ERROR([can't find Apache include files beneath $APXS_PREFIX])
196         fi
197     elif ! test -f "$APXS_INCLUDE/httpd.h"; then
198         AC_MSG_ERROR([APXS_INCLUDE of $APXS_INCLUDE does not contain Apache headers])
199     fi
200     AC_MSG_NOTICE([APXS_INCLUDE is $APXS_INCLUDE])
201
202     if test -z "$APXS_LIBEXEC"; then
203         if test -d "$APXS_PREFIX/libexec"; then
204             APXS_LIBEXEC="$APXS_PREFIX/libexec"
205         elif test -d "$APXS_PREFIX/modules"; then
206             APXS_LIBEXEC="$APXS_PREFIX/modules"
207         else
208             AC_MSG_ERROR([can't find Apache libexec/module directory beneath $APXS_PREFIX])
209         fi
210     elif ! test -d "$APXS_LIBEXEC"; then
211         AC_MSG_ERROR([APXS_LIBEXEC of $APXS_LIBEXEC does not exist])
212     fi
213     AC_MSG_NOTICE([APXS_LIBEXEC is $APXS_LIBEXEC])
214
215     if test -z "$APXS_SYSCONFDIR"; then
216         if test -d "$APXS_PREFIX/conf"; then
217             APXS_SYSCONFDIR="$APXS_PREFIX/conf"
218         else
219             AC_MSG_ERROR([can't find Apache conf directory beneath $APXS_PREFIX])
220         fi
221     elif ! test -d "$APXS_SYSCONFDIR"; then
222         AC_MSG_ERROR([APXS_SYSCONFDIR of $APXS_SYSCONFDIR does not exist])
223     fi
224     AC_MSG_NOTICE([APXS_SYSCONFDIR is $APXS_SYSCONFDIR])
225
226     WANT_APACHE="yes"
227
228 elif test -n "$APXS"; then
229
230     # extract settings we need from APXS -q
231     APXS_CC="`$APXS -q CC`"
232     APXS_CFLAGS="`$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
233     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
234     APXS_LIBEXEC="`$APXS -q LIBEXECDIR`"
235     APXS_SYSCONFDIR="`$APXS -q SYSCONFDIR`"
236
237     AC_SUBST(APXS)
238     AC_MSG_RESULT(found at $APXS)
239
240     if test -z "`$APXS -q LD_SHLIB`" || test "$APXS_LIBEXEC" = "modules"; then
241             AC_MSG_ERROR(
242 [Your APXS installation is broken and cannot be used.
243     Please see http://www.webdav.org/mod_dav/install.html#apxs for
244     more information.])
245     fi
246
247     WANT_APACHE="yes"
248
249 else
250     # guess we're not doing Apache 1.3
251     AC_MSG_RESULT(no)
252     WANT_APACHE="no"
253 fi
254
255 AM_CONDITIONAL(HAVE_APXS,test -n "$APXS")
256
257 if test "$WANT_APACHE" = "yes"; then
258     AC_ARG_WITH(apreq,
259                 AC_HELP_STRING([--with-apreq=PATH], [where libapreq is installed]),
260                 [if test x_$with_apreq != x_/usr; then
261                     LDFLAGS="-L${with_apreq}/lib $LDFLAGS"
262                     CPPFLAGS="-I${with_apreq}/include $CPPFLAGS"
263                 fi])
264
265     saved_CPPFLAGS="$CPPFLAGS"
266     CPPFLAGS="-I$APXS_INCLUDE $APXS_CFLAGS $CPPFLAGS"
267     AC_CHECK_HEADER([libapreq/apache_request.h],,
268                 AC_MSG_ERROR([unable to find apreq header files]))
269
270 dnl    saved_LIBS="$LIBS"
271 dnl    LIBS="-lapreq $LIBS"
272 dnl    AC_TRY_LINK(
273 dnl        [#include <libapreq/apache_request.h>],
274 dnl        [ApacheRequest_expires],
275 dnl        [AC_DEFINE(HAVE_APREQ,1,[Define if apreq library was found])],
276 dnl        [AC_MSG_ERROR([unable to link with apreq])
277 dnl        ])
278 dnl    LIBS="$saved_LIBS"
279     CPPFLAGS="$saved_CPPFLAGS"
280
281     AC_ARG_ENABLE([apxs-install],
282         AC_HELP_STRING([--enable-apxs-install],
283                         [use apxs to install the apache modules]),
284         APXS_INSTALL="yes", )
285
286
287     AC_SUBST(APXS_CFLAGS)
288     AC_SUBST(APXS_INCLUDE)
289     AC_SUBST(APXS_LIBEXEC)
290     AC_SUBST(APXS_SYSCONFDIR)
291
292     # output the Apache 1.3 makefiles
293     WANT_SUBDIRS="$WANT_SUBDIRS mod_shire mod_shibrm"
294     AC_CONFIG_FILES([mod_shire/Makefile mod_shibrm/Makefile])
295 fi
296
297 AM_CONDITIONAL(DO_APXS_INSTALL,test -n "$APXS_INSTALL")
298
299 AC_SUBST(WANT_SUBDIRS)
300
301 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
302   echo "=================================================================="
303   echo "WARNING: You have chosen to compile Apache modules with a different"
304   echo "         compiler than the one used to compile Apache."
305   echo ""
306   echo "    Current compiler:      $CC"
307   echo "   Apache's compiler:      $APXS_CC"
308   echo ""
309   echo "This could cause some problems."
310   echo "=================================================================="
311 fi
312
313 AC_OUTPUT
314