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