Version bump
[shibboleth/cpp-sp.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([shibboleth],[2.5.5],[https://issues.shibboleth.net/],[shibboleth-sp])
3 AC_CONFIG_SRCDIR(shibsp)
4 AC_CONFIG_AUX_DIR(build-aux)
5 AC_CONFIG_MACRO_DIR(m4)
6 AM_INIT_AUTOMAKE
7 AC_DISABLE_STATIC
8 AC_PROG_LIBTOOL
9
10 # Docygen features
11 DX_HTML_FEATURE(ON)
12 DX_CHM_FEATURE(OFF)
13 DX_CHI_FEATURE(OFF)
14 DX_MAN_FEATURE(OFF)
15 DX_RTF_FEATURE(OFF)
16 DX_XML_FEATURE(OFF)
17 DX_PDF_FEATURE(OFF)
18 DX_PS_FEATURE(OFF)
19 DX_INIT_DOXYGEN(shibboleth, doxygen.cfg, doc/api)
20 DX_INCLUDE=
21
22 AC_ARG_ENABLE(debug,
23     AS_HELP_STRING([--enable-debug],[Have GCC compile with symbols (Default = no)]),
24     enable_debug=$enableval, enable_debug=no)
25
26 if test "$enable_debug" = "yes" ; then
27     GCC_CFLAGS="$CFLAGS -g -D_DEBUG"
28     GCC_CXXFLAGS="$CXXFLAGS -g -D_DEBUG"
29 else
30     GCC_CFLAGS="$CFLAGS -O2 -DNDEBUG"
31     GCC_CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG"
32 fi
33
34 AC_CONFIG_HEADERS([config.h shibsp/config_pub.h])
35 AC_CONFIG_FILES([shibboleth.spec])
36
37 AC_PROG_CC([gcc gcc3 cc])
38 AC_PROG_CXX([g++ g++3 c++ CC])
39 AC_CANONICAL_HOST
40
41 if test "$GCC" = "yes" ; then
42 #    AC_HAVE_GCC_VERSION(4,0,0,0,
43 #        [
44 #        AC_DEFINE(GCC_HASCLASSVISIBILITY,1,
45 #            [Define to enable class visibility control in gcc.])
46 #        GCC_CFLAGS="$GCC_CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
47 #        GCC_CXXFLAGS="$GCC_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
48 #        ])
49     CFLAGS="-Wall $GCC_CFLAGS"
50     CXXFLAGS="-Wall $GCC_CXXFLAGS"
51 fi
52
53 # Fix for Sun Workshop compiler in debug mode, may be Sun case #6360993
54 # Also enables POSIX semantics for some functions.
55 case "${host_cpu}-${host_os}" in
56     *solaris*)
57         CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS"
58         CXXFLAGS="$CXXFLAGS -D_POSIX_PTHREAD_SEMANTICS"
59         if test "$CXX" = "CC" ; then
60                 CXXFLAGS="$CXXFLAGS -Qoption ccfe -stabs=no%dfltlit+no%dflthlp"
61         fi
62     ;;
63         *osf*)
64         CXXFLAGS="$CXXFLAGS -D_POSIX_PII_SOCKET"
65         ;;
66 esac
67
68 AC_LANG(C)
69
70 # Checks for typedefs, structures, and compiler characteristics.
71 AC_C_CONST
72 AC_TYPE_SIZE_T
73 AC_STRUCT_TM
74
75 # Checks for library functions.
76 AC_FUNC_STRFTIME
77 AC_FUNC_STRERROR_R
78 AC_CHECK_HEADERS([sys/utsname.h grp.h pwd.h])
79 AC_CHECK_HEADERS([sys/socket.h], [AC_DEFINE([SHIBSP_HAVE_SYS_SOCKET_H],[1],[Define to 1 if you have the <sys/socket> header file.])], [])
80 AC_CHECK_FUNCS([strchr strdup strstr timegm gmtime_r localtime_r strtok_r strcasecmp getpwnam getgrnam initgroups])
81 AC_CHECK_TYPES([struct sockaddr_storage], [], [], [[#include <sys/socket.h>]])
82 AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [[#include <sys/socket.h>]])
83
84 AC_CACHE_CHECK([for SOCK_CLOEXEC support], [shib_cv_sock_cloexec],
85 [AC_TRY_RUN([
86 #include <sys/types.h>
87 #include <sys/socket.h>
88 int main()
89 {
90 return socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0) == -1;
91 }], [shib_cv_sock_cloexec=yes], [shib_cv_sock_cloexec=no], [shib_cv_sock_cloexec=no])])
92
93 if test "$shib_cv_sock_cloexec" = "yes"; then
94         AC_DEFINE([HAVE_SOCK_CLOEXEC], 1, [Define if the SOCK_CLOEXEC flag is supported])
95 fi
96
97 # checks for pthreads
98 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
99 if test $enable_threads != "pthread"; then
100     AC_MSG_ERROR([unable to find pthreads, currently this is required])
101 else
102     AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])
103     LIBS="$PTHREAD_LIBS $LIBS"
104     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
105     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
106 fi
107
108 # OpenSSL settings
109 AC_ARG_WITH(openssl,
110     AS_HELP_STRING([--with-openssl=PATH],[where openssl is installed]),
111     [if test x_$with_openssl != x_/usr; then
112         SSLFLAGS="-I${with_openssl}/include"
113     fi])
114
115 if test "x$with_openssl" = "x" ; then
116     AC_PATH_PROG(PKG_CONFIG, pkg-config)
117     if test "x$PKG_CONFIG" != x && test "x$PKG_CONFIG" != "xno" ; then
118         if pkg-config openssl ; then
119             SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
120         else
121             AC_MSG_WARN([OpenSSL not supported by pkg-config, try --with-openssl instead])
122         fi
123     fi
124 fi
125
126 AC_MSG_CHECKING(for OpenSSL cflags)
127 AC_MSG_RESULT($SSLFLAGS)
128 CPPFLAGS="$SSLFLAGS $CPPFLAGS"
129
130 AC_CHECK_HEADER([openssl/x509.h],,AC_MSG_ERROR([unable to find openssl header files]))
131
132 AC_LANG([C++])
133
134 # C++ requirements
135 AC_CXX_NAMESPACES
136 AC_CXX_REQUIRE_STL
137
138 # Boost
139 BOOST_REQUIRE
140 BOOST_BIND
141 BOOST_LAMBDA
142 BOOST_POINTER_CONTAINER
143 BOOST_SMART_PTR
144 BOOST_STRING_ALGO
145 BOOST_TUPLE
146 CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS"
147
148 # Thank you Solaris, really.
149 AC_MSG_CHECKING(for ctime_r)
150 if test -z "$ac_cv_ctime_args"; then
151     AC_COMPILE_IFELSE(
152         [AC_LANG_PROGRAM([[#include <time.h>]], [[time_t clock; char buf[26]; ctime_r(&clock, buf);]])],
153         [ac_cv_ctime_args=2],[])
154
155     AC_COMPILE_IFELSE(
156         [AC_LANG_PROGRAM([[#include <time.h>]], [[time_t clock; char buf[26]; ctime_r(&clock, buf, 26);]])],
157         [ac_cv_ctime_args=3],[])
158 fi
159 if test -z "$ac_cv_ctime_args"; then
160     AC_MSG_RESULT(no)
161 else
162     if test "$ac_cv_ctime_args" = 2; then
163         AC_DEFINE([HAVE_CTIME_R_2],[1],[Define if ctime_r is present with 2 parameters.])
164     elif test "$ac_cv_ctime_args" = 3; then
165         AC_DEFINE([HAVE_CTIME_R_3],[1],[Define if ctime_r is present with 3 parameters.])
166     fi
167     AC_MSG_RESULT([yes, and it takes $ac_cv_ctime_args arguments])
168 fi 
169
170 # log4shib settings (favor this version over the log4cpp code)
171 AC_PATH_PROG(LOG4SHIB_CONFIG,log4shib-config)
172 AC_ARG_WITH(log4shib,
173     AS_HELP_STRING([--with-log4shib=PATH],[where log4shib-config is installed]),
174     [
175     LOG4SHIB_CONFIG="${with_log4shib}"
176     if ! test -f "${LOG4SHIB_CONFIG}"; then
177         LOG4SHIB_CONFIG="${with_log4shib}/bin/log4shib-config"
178     fi
179     ])
180 if test -f "${LOG4SHIB_CONFIG}" ; then
181     LIBS="`${LOG4SHIB_CONFIG} --libs` $LIBS"
182     CPPFLAGS="`${LOG4SHIB_CONFIG} --cflags` $CPPFLAGS"
183     AC_CHECK_HEADER([log4shib/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4shib header files]))
184     AC_LINK_IFELSE(
185         [AC_LANG_PROGRAM([[#include <log4shib/Category.hh>
186 #include <log4shib/CategoryStream.hh>]],
187             [[log4shib::Category::getInstance("foo").errorStream() << log4shib::eol]])],
188         [AC_DEFINE([SHIBSP_LOG4SHIB],[1],[Define to 1 if log4shib library is used.])],
189         [AC_MSG_ERROR([unable to link with log4shib])])
190 else
191     AC_MSG_WARN([log4shib-config not found, may need to use --with-log4shib option])
192     AC_MSG_WARN([will look for original log4cpp library])
193     
194     # log4cpp settings
195     AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
196     AC_ARG_WITH(log4cpp,
197         AS_HELP_STRING([--with-log4cpp=PATH],[where log4cpp-config is installed]),
198         [
199         LOG4CPP_CONFIG="${with_log4cpp}"
200         if ! test -f "${LOG4CPP_CONFIG}"; then
201             LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
202         fi
203         ])
204     if test -f "${LOG4CPP_CONFIG}"; then
205         AC_MSG_WARN([will try to use log4cpp, note that most non-Internet2 supplied versions are not thread-safe])
206         LIBS="`${LOG4CPP_CONFIG} --libs` $LIBS"
207         CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
208         AC_CHECK_HEADER([log4cpp/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
209         AC_LINK_IFELSE(
210             [AC_LANG_PROGRAM([[#include <log4cpp/Category.hh>
211 #include <log4cpp/CategoryStream.hh>]],
212                 [[log4cpp::Category::getInstance("foo").errorStream() << log4cpp::eol]])],
213             [AC_DEFINE([SHIBSP_LOG4CPP],[1],[Define to 1 if log4cpp library is used.])],
214             [AC_MSG_ERROR([unable to link with log4cpp, need version 1.0 or later])])
215     else
216         AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
217     fi
218 fi
219
220 # Xerces settings
221 AC_ARG_WITH(xerces,
222     AS_HELP_STRING([--with-xerces=PATH],[where xerces-c is installed]),,
223     [with_xerces=/usr])
224 if test x_$with_xerces != x_/usr; then
225     CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
226     LIBS="-L${with_xerces}/lib -lxerces-c $LIBS"
227 else
228     LIBS="-lxerces-c $LIBS"
229 fi
230
231 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
232 AC_MSG_CHECKING([Xerces version])
233 AC_PREPROC_IFELSE(
234     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
235 [#if  _XERCES_VERSION >= 20700
236 int i = 0;
237 #else
238 #error version 2.7.0 or above required
239 #endif])],
240     [AC_MSG_RESULT(OK)],
241     [AC_MSG_FAILURE([Xerces-C v2.7.0 or higher is required, v3.x preferred])])
242 AC_LINK_IFELSE(
243     [AC_LANG_PROGRAM([[#include <xercesc/util/PlatformUtils.hpp>]],[[xercesc::XMLPlatformUtils::Initialize()]])],
244     ,[AC_MSG_ERROR([unable to link with Xerces])])
245
246 AC_MSG_CHECKING([whether Xerces XMLString::release(XMLByte**) exists])
247 AC_COMPILE_IFELSE(
248     [AC_LANG_PROGRAM([[#include <xercesc/util/XMLString.hpp>]],
249     [[using namespace XERCES_CPP_NAMESPACE; XMLByte* buf=NULL; XMLString::release(&buf);]])],
250     [AC_MSG_RESULT([yes])AC_DEFINE([SHIBSP_XERCESC_HAS_XMLBYTE_RELEASE],[1],[Define to 1 if Xerces XMLString includes XMLByte release.])],
251     [AC_MSG_RESULT([no])])
252
253 AC_MSG_CHECKING([whether Xerces DOMNodeFilter API returns a short])
254 AC_COMPILE_IFELSE(
255     [AC_LANG_PROGRAM([[#include <xercesc/dom/DOM.hpp>]],
256         [[using namespace XERCES_CPP_NAMESPACE;
257       class Blocker : public DOMNodeFilter {
258       public:
259         short acceptNode(const DOMNode* node) const {
260             return FILTER_REJECT;
261         }
262       };
263       static Blocker g_Blocker;
264     ]])],
265     [AC_MSG_RESULT([yes])AC_DEFINE([SHIBSP_XERCESC_SHORT_ACCEPTNODE],[1],[Define to 1 if Xerces DOMNodeFilter API returns a short.])],
266     [AC_MSG_RESULT([no])])
267
268 # XML-Security settings
269 AC_ARG_WITH(xmlsec,
270     AS_HELP_STRING([--with-xmlsec=PATH],[where xmlsec is installed]),,
271     [with_xmlsec=/usr])
272 if test x_$with_xmlsec != x_/usr; then
273     CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
274     XMLSEC_LIBS="-L${with_xmlsec}/lib -lxml-security-c $XMLSEC_LIBS"
275 else
276     XMLSEC_LIBS="-lxml-security-c $XMLSEC_LIBS"
277 fi
278
279 # save and append master libs
280 save_LIBS="$LIBS"
281 LIBS="$XMLSEC_LIBS $LIBS"
282
283 AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security-C header files]))
284 AC_MSG_CHECKING([XML-Security-C version])
285 AC_PREPROC_IFELSE(
286     [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
287     [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3)
288 int i = 0;
289 #else
290 #error need version 1.4.0 or later
291 #endif])],
292     [AC_MSG_RESULT(OK)],
293     [AC_MSG_FAILURE([XML-Security-C version 1.4.0 or greater is required.])])
294 AC_LINK_IFELSE(
295     [AC_LANG_PROGRAM([[#include <xsec/utils/XSECPlatformUtils.hpp>]],
296         [[XSECPlatformUtils::Initialise()]])],,
297     [AC_MSG_ERROR([unable to link with XML-Security])])
298
299 AC_MSG_CHECKING([whether XML-Security-C supports white/blacklisting of algorithms])
300 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <xsec/framework/XSECAlgorithmMapper.hpp>]], [[XSECAlgorithmMapper* mapper; mapper->whitelistAlgorithm(NULL);]])],[AC_MSG_RESULT([yes])
301       AC_DEFINE([SHIBSP_XMLSEC_WHITELISTING],[1],[Define to 1 if XML-Security-C supports white/blacklisting algorithms.])],[AC_MSG_RESULT([no])])
302
303 # restore master libs
304 LIBS="$save_LIBS"
305
306 #XML-Tooling settings
307 AC_ARG_WITH(xmltooling,
308     AS_HELP_STRING([--with-xmltooling=PATH],[where xmltooling is installed]),,
309     [with_xmltooling=/usr])
310 if test x_$with_xmltooling != x_/usr; then
311     CPPFLAGS="-I${with_xmltooling}/include $CPPFLAGS"
312     DX_INCLUDE="${with_xmltooling}/include"
313     LITE_LIBS="-L${with_xmltooling}/lib -lxmltooling-lite"
314     XMLSEC_LIBS="-L${with_xmltooling}/lib -lxmltooling $XMLSEC_LIBS"
315 else
316     LITE_LIBS="-lxmltooling-lite"
317     XMLSEC_LIBS="-lxmltooling $XMLSEC_LIBS"
318 fi
319
320 AC_CHECK_HEADER([xmltooling/base.h],,AC_MSG_ERROR([unable to find xmltooling header files]))
321
322 # save and append master libs
323 save_LIBS="$LIBS"
324 LIBS="$XMLSEC_LIBS $LIBS"
325
326 AC_LINK_IFELSE(
327     [AC_LANG_PROGRAM([[#include <xmltooling/XMLToolingConfig.h>
328 #include <xmltooling/version.h>]],
329         [[#if _XMLTOOLING_VERSION >= 10500
330 xmltooling::XMLToolingConfig::getConfig();
331 #else
332 #error Need XMLTooling version 1.5 or higher
333 #endif]])],
334     ,[AC_MSG_ERROR([unable to link with XMLTooling, or version was too old])])
335
336 # restore master libs
337 LIBS="$save_LIBS"
338
339 # Establish location of xmltooling catalog.
340 XMLTOOLINGXMLDIR=""
341 if test "x$with_xmltooling" = "x" ; then
342    with_xmltooling="/usr"
343 fi
344 if test -f $with_xmltooling/share/xml/xmltooling/catalog.xml ; then
345     XMLTOOLINGXMLDIR="$with_xmltooling"
346 elif test -f $with_xerces/share/xml/xmltooling/catalog.xml ; then
347     XMLTOOLINGXMLDIR="$with_xerces"
348 elif test -f $with_log4shib/share/xml/xmltooling/catalog.xml ; then
349     XMLTOOLINGXMLDIR="$with_log4shib"
350 fi
351 if test "x$XMLTOOLINGXMLDIR" = "x" ; then
352     AC_MSG_ERROR([xmltooling XML catalog not found, may need to use --with-xmltooling option])
353 fi
354 XMLTOOLINGXMLDIR="$XMLTOOLINGXMLDIR/share/xml/xmltooling"
355 AC_SUBST(XMLTOOLINGXMLDIR)
356
357 # OpenSAML settings
358 AC_ARG_WITH(saml,
359     AS_HELP_STRING([--with-saml=PATH],[where opensaml is installed]),,
360     [with_saml=/usr])
361 if test x_$with_saml != x_/usr; then
362     CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
363     DX_INCLUDE="$DX_INCLUDE ${with_saml}/include"
364     XMLSEC_LIBS="-L${with_saml}/lib -lsaml $XMLSEC_LIBS"
365 else
366     XMLSEC_LIBS="-lsaml $XMLSEC_LIBS"
367 fi
368
369 # save and append master libs
370 save_LIBS="$LIBS"
371 LIBS="$XMLSEC_LIBS $LIBS"
372
373 AC_CHECK_HEADER([saml/saml2/metadata/Metadata.h],,AC_MSG_ERROR([unable to find OpenSAML header files]))
374 AC_LINK_IFELSE(
375     [AC_LANG_PROGRAM([[#include <saml/SAMLConfig.h>
376 #include <saml/version.h>]],
377 [[#if _OPENSAML_VERSION >= 20500
378 opensaml::SAMLConfig::getConfig();
379 #else
380 #error Need OpenSAML version 2.5 or higher
381 #endif]])],
382     ,[AC_MSG_ERROR([unable to link with OpenSAML, or version was too old])
383         ])
384
385 # restore master libs
386 LIBS="$save_LIBS"
387
388 # Establish location of opensaml catalogs.
389 OPENSAMLXMLDIR=""
390 if test "x$with_saml" = "x" ; then
391     with_saml="/usr"
392 fi
393 if test -f $with_saml/share/xml/opensaml/saml20-catalog.xml ; then
394     OPENSAMLXMLDIR="$with_saml"
395 elif test -f $with_xmltooling/share/xml/opensaml/saml20-catalog.xml ; then
396     OPENSAMLXMLDIR="$with_xmltooling"
397 elif test -f $with_xerces/share/xml/opensaml/saml20-catalog.xml ; then
398     OPENSAMLXMLDIR="$with_xerces"
399 elif test -f $with_log4shib/share/xml/opensaml/saml20-catalog.xml ; then
400     OPENSAMLXMLDIR="$with_log4shib"
401 fi
402 if test "x$OPENSAMLXMLDIR" = "x" ; then
403     AC_MSG_ERROR([opensaml XML catalogs not found, may need to use --with-saml option])
404 fi
405 OPENSAMLXMLDIR="$OPENSAMLXMLDIR/share/xml/opensaml"
406 AC_SUBST(OPENSAMLXMLDIR)
407
408 AC_SUBST(LITE_LIBS)
409 AC_SUBST(XMLSEC_LIBS)
410
411 # output the underlying makefiles
412 WANT_SUBDIRS="doc schemas configs shibsp plugins shibd util"
413 AC_CONFIG_FILES([Makefile doc/Makefile schemas/Makefile \
414         configs/Makefile shibsp/Makefile plugins/Makefile \
415         shibd/Makefile util/Makefile selinux/Makefile])
416
417 ## ADFS?
418 AC_CONFIG_FILES([adfs/Makefile])
419 AC_ARG_ENABLE([adfs],
420     AS_HELP_STRING([--disable-adfs],[don't build the ADFS module]),
421     [adfs_enabled=$enableval], [adfs_enabled=yes])
422 if test "x$adfs_enabled" = "x" ; then
423     adfs_enabled=yes
424 fi
425 AC_MSG_CHECKING(whether to build the ADFS module)
426 if test "$adfs_enabled" = "no" ; then
427     AC_MSG_RESULT(no)
428 else
429     AC_MSG_RESULT(yes)
430     WANT_SUBDIRS="$WANT_SUBDIRS adfs"
431 fi
432
433 ## systemd
434 dnl Systemd will be disabled by default and requires you to run configure with
435 dnl --enable-systemd to look for and enable systemd.
436 AC_ARG_ENABLE(systemd,
437     AS_HELP_STRING([--enable-systemd],[Build with systemd (Default = no)]),
438         [if test "x$enableval" = "x" ; then
439          WANT_SYSTEMD=no
440          else
441              WANT_SYSTEMD="$enableval"
442          fi
443         ],[ WANT_SYSTEMD=no ])
444 AC_MSG_CHECKING(whether to build with systemd)
445
446 AC_MSG_RESULT($WANT_SYSTEMD)
447 if test "$WANT_SYSTEMD" = "yes" ; then
448         AC_CHECK_HEADER([systemd/sd-daemon.h], [
449             AC_CHECK_LIB([systemd-daemon], [sd_notify], [hassdnotify="y"])])
450         AS_IF([test "x$hassdnotify=" = x], [
451            AC_MSG_ERROR([Unable to find a suitable libsystemd-daemon library])
452         ])
453         AC_DEFINE([HAVE_SD_NOTIFY],[1],[Define to 1 if you have the sd_notify function.])
454         PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon])
455         AC_SUBST([SYSTEMD_CFLAGS])
456         AC_SUBST([SYSTEMD_LIBS])
457 fi
458
459 #
460 # Build NSAPI module?
461 #
462 AC_MSG_CHECKING(for NSAPI module option)
463 AC_ARG_WITH(nsapi,
464     AS_HELP_STRING([--with-nsapi=DIR],[Build NSAPI module for Netscape/iPlanet/SunONE]),
465     [WANT_NSAPI=$withval],[WANT_NSAPI=no])
466 AC_MSG_RESULT($WANT_NSAPI)
467
468 if test "$WANT_NSAPI" != "no"; then
469   if test ! -d $WANT_NSAPI/bin ; then
470     AC_MSG_ERROR([Please specify the path to the root of your Netscape/iPlanet/SunONE server using --with-nsapi=DIR])
471   fi
472   AC_MSG_CHECKING(for NSAPI include files)
473   if test -d $WANT_NSAPI/include ; then
474     NSAPI_INCLUDE=$WANT_NSAPI/include
475     AC_MSG_RESULT(Netscape-Enterprise 3.x style)
476     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h],,,[#define XP_UNIX])
477     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
478   fi
479   if test -d $WANT_NSAPI/plugins/include ; then
480     test -n "$NSAPI_INCLUDE" && NSAPI_INC_DIR="-I$NSAPI_INCLUDE"
481     NSAPI_INCLUDE="$WANT_NSAPI/plugins/include"
482     AC_MSG_RESULT(iPlanet 4.x / SunONE 6.x style)
483     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h],,,[#define XP_UNIX])
484     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
485   fi
486   if test "$NSAPI_INCLUDE" = ""; then
487     AC_MSG_ERROR([Please check you have nsapi.h in either $WANT_NSAPI/include or $WANT_NSAPI/plugins/include])
488   fi
489 fi
490
491 AC_SUBST(NSAPI_INCLUDE)
492
493 # always output the Makefile, even if you don't use it
494 AC_CONFIG_FILES([nsapi_shib/Makefile])
495 AM_CONDITIONAL(BUILD_NSAPI,test ! "$WANT_NSAPI" = "no")
496
497 # add the NSAPI module to the list of wanted subdirs..
498 if test ! "$WANT_NSAPI" = "no" ; then
499     WANT_SUBDIRS="$WANT_SUBDIRS nsapi_shib"
500 fi
501
502
503 #
504 # Build FastCGI support?
505 #
506 AC_MSG_CHECKING(for FastCGI support)
507 AC_ARG_WITH(fastcgi,
508     AS_HELP_STRING([--with-fastcgi=DIR],[Build FastCGI support]),
509     [WANT_FASTCGI=$withval],[WANT_FASTCGI=no])
510 AC_MSG_RESULT($WANT_FASTCGI)
511
512 if test "$WANT_FASTCGI" != "no"; then
513
514     if test "$WANT_FASTCGI" != "yes"; then
515         if test x_$WANT_FASTCGI != x_/usr; then
516             FASTCGI_INCLUDE="-I$WANT_FASTCGI/include"
517             FASTCGI_LDFLAGS="-L$WANT_FASTCGI/lib"
518         fi
519     fi
520
521     # save and append master flags
522     save_CPPFLAGS="$CPPFLAGS"
523     CPPFLAGS="$FASTCGI_INCLUDE $CPPFLAGS"
524
525     AC_CHECK_HEADER([fcgio.h],,AC_MSG_ERROR([unable to find FastCGI header files]))
526     FASTCGI_LIBS="-lfcgi -lfcgi++"
527
528     # restore standard flags
529     CPPFLAGS="$save_CPPFLAGS"
530 fi
531
532 AC_SUBST(FASTCGI_INCLUDE)
533 AC_SUBST(FASTCGI_LDFLAGS)
534 AC_SUBST(FASTCGI_LIBS)
535
536 # always output the Makefile, even if you don't use it
537 AC_CONFIG_FILES([fastcgi/Makefile])
538 AM_CONDITIONAL(BUILD_FASTCGI,test ! "$WANT_FASTCGI" = "no")
539
540 if test ! "$WANT_FASTCGI" = "no" ; then
541     WANT_SUBDIRS="$WANT_SUBDIRS fastcgi"
542 fi
543
544 #
545 # Build Memcached support?
546 #
547 AC_MSG_CHECKING(for Memcached support)
548 AC_ARG_WITH(memcached,
549     AS_HELP_STRING([--with-memcached=DIR],[Build Memcached support]),
550     [WANT_MEMCACHED=$withval],[WANT_MEMCACHED=no])
551 AC_MSG_RESULT($WANT_MEMCACHED)
552
553 if test "$WANT_MEMCACHED" != "no"; then
554
555     if test "$WANT_MEMCACHED" != "yes"; then
556         if test x_$WANT_MEMCACHED != x_/usr; then
557             MEMCACHED_INCLUDE="-I$WANT_MEMCACHED/include"
558             MEMCACHED_LDFLAGS="-L$WANT_MEMCACHED/lib"
559         fi
560     fi
561
562     # save and append master flags
563     save_CPPFLAGS="$CPPFLAGS"
564     CPPFLAGS="$MEMCACHED_INCLUDE $CPPFLAGS"    
565
566     AC_CHECK_HEADER([libmemcached/memcached.h],,
567         AC_MSG_ERROR([unable to find Memcached header files]))
568     AC_CHECK_DECL([memcached_last_error_message],
569         [AC_DEFINE([HAVE_MEMCACHED_LAST_ERROR_MESSAGE],[1],[Define to 1 if libmemcached supports error handling function.])],,
570         [#include <libmemcached/memcached.h>])
571     MEMCACHED_LIBS="-lmemcached"
572
573     # restore standard flags
574     CPPFLAGS="$save_CPPFLAGS"
575 fi
576
577 AC_SUBST(MEMCACHED_INCLUDE)
578 AC_SUBST(MEMCACHED_LDFLAGS)
579 AC_SUBST(MEMCACHED_LIBS)
580
581 # always output the Makefile, even if you don't use it
582 AC_CONFIG_FILES([memcache-store/Makefile])
583 AM_CONDITIONAL(BUILD_MEMCACHED,test ! "$WANT_MEMCACHED" = "no")
584
585 if test ! "$WANT_MEMCACHED" = "no" ; then
586     WANT_SUBDIRS="$WANT_SUBDIRS memcache-store"
587 fi
588
589
590 #
591 # If no --enable-apache-xx specified 
592 # find a default and fake the specific parameters
593 #
594
595 # simple macro to peek at an enable or a with
596 AC_DEFUN([Peek],
597 if test "[${[$1]_][$2]+set}" = set; then
598   peekval="${[$1]_[$2]}"
599   $3
600 fi; dnl
601 )
602
603 AC_MSG_CHECKING(if default apache needed)
604 need_default=yes
605 Peek(enable,apache_13,need_default=no)
606 Peek(enable,apache_20,need_default=no)
607 Peek(enable,apache_22,need_default=no)
608 Peek(enable,apache_24,need_default=no)
609 AC_MSG_RESULT($need_default)
610
611 if test "$need_default" = "yes"; then
612   # find an apxs, then the httpd
613   xs=
614   Peek(with,apxs,xs="$peekval")
615   Peek(with,apxs2,xs="$peekval")
616   Peek(with,apxs22,xs="$peekval")
617   Peek(with,apxs24,xs="$peekval")
618   if test "x$xs" = "x"; then
619      AC_PATH_PROGS(xs, apxs2 apxs,
620         AC_MSG_ERROR(No apxs, no Apache found. Try --with-apxs, --with-apxs2, etc.),
621         [/usr/local/apache2/bin:/usr/local/apache/bin:/usr/sbin:$PATH])
622   fi
623   # ask the daemon for the version and set parameters
624   AC_MSG_CHECKING(default apache version)
625   httpd="`$xs -q SBINDIR`/`$xs -q TARGET`"
626   if test "x$httpd" != "x" && test -f $httpd ; then
627      v=`$httpd -v|$SED -n -e 's/.*Apache\/\.*//p'`
628      case $v in
629        1.3*)   [enable_apache_13]=yes
630                [with_apxs]=$xs
631                AC_MSG_RESULT(1.3)
632                ;;
633        2.0*)   [enable_apache_20]=yes
634                [with_apxs2]=$xs
635                AC_MSG_RESULT(2.0)
636                ;;
637        2.2*)   [enable_apache_22]=yes
638                [with_apxs22]=$xs
639                AC_MSG_RESULT(2.2)
640                ;;
641        2.4*)   [enable_apache_24]=yes
642                [with_apxs24]=$xs
643                AC_MSG_RESULT(2.4)
644                ;;
645        *)      AC_MSG_ERROR(unusable Apache versions: $v. Try setting --with-apxs, --with=apxs2, etc.)
646      esac
647   else 
648      AC_MSG_RESULT(cannot determine Apache version. Try setting --with-apxs, --with-apxs2, etc.)
649   fi
650 fi
651
652 # Apache 1.3 (mod_shib_13)
653 #   --enable-apache-13
654 #   --with-apxs      (DSO build, the normal way, uses apxs to derive build flags)
655
656 AC_ARG_ENABLE(apache-13,
657         AS_HELP_STRING([--enable-apache-13],[enable the Apache 1.3 module]),
658         [if test "x$enableval" = "x" ; then
659          WANT_APACHE_13=yes
660          else
661              WANT_APACHE_13="$enableval"
662          fi
663         ],[ WANT_APACHE_13=no ])
664 AC_MSG_CHECKING(whether to build Apache 1.3 module)
665 if test "$WANT_APACHE_13" != yes && test "$WANT_APACHE_13" != no ; then
666    WANT_APACHE_13=yes
667 fi
668 AC_MSG_RESULT($WANT_APACHE_13)
669
670 if test "$WANT_APACHE_13" = "yes" ; then
671     AC_ARG_WITH(apxs, 
672         AS_HELP_STRING([--with-apxs=FILE],[Specifies where to find the Apache 1.3 apxs script.]),
673         [
674         AC_MSG_CHECKING(for user-specified apxs name/location)
675         if test "$withval" != "no" ; then
676           if test "$withval" != "yes"; then
677             APXS=$withval
678             AC_MSG_RESULT("$withval")
679           fi
680         fi
681         ],
682         [
683         AC_PATH_PROG(APXS, apxs, no)
684         if test "$APXS" = "no" ; then
685           for i in /usr/sbin /usr/local/apache/bin ; do
686             if test "$APXS" = "no" && test -f "$i/apxs"; then
687               APXS="$i/apxs"
688             fi
689           done
690         fi
691         ])
692
693     AC_MSG_CHECKING([to see if apxs was located])
694     if test ! -f "$APXS" ; then
695         AC_MSG_RESULT(no)
696         AC_MSG_ERROR([Unable to locate apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs option.])
697     fi
698     AC_MSG_RESULT($APXS)
699     AC_SUBST(APXS)
700
701     # extract settings we need from APXS -q
702     APXS_CC="`$APXS -q CC`"
703     APXS_CFLAGS="`$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
704     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
705 fi
706
707 AC_SUBST(APXS_CFLAGS)
708 AC_SUBST(APXS_INCLUDE)
709
710
711 # Apache 2.0 (mod_shib_20)
712 #   --enable-apache-20
713 #   --with-apxs2      (DSO build, the normal way, uses apxs to derive build flags)
714 #   --with-apr        (DSO build, APR development package installed separately)
715 #   --with-apu        (DSO build, APR-UTIL development package installed separately)
716
717 AC_ARG_ENABLE(apache-20,
718         AS_HELP_STRING([--enable-apache-20],[enable the Apache 2.0 module]),
719         [if test "x$enableval" = "x" ; then
720          WANT_APACHE_20=yes
721          else
722              WANT_APACHE_20="$enableval"
723          fi
724         ],[ WANT_APACHE_20=no ])
725 AC_MSG_CHECKING(whether to build Apache 2.0 module)
726 if test "$WANT_APACHE_20" != yes && test "$WANT_APACHE_20" != no ; then
727     WANT_APACHE_20=yes
728 fi
729 AC_MSG_RESULT($WANT_APACHE_20)
730
731 if test "$WANT_APACHE_20" = "yes" ; then
732     AC_ARG_WITH(apxs2, 
733         AS_HELP_STRING([--with-apxs2=FILE],[Specifies where to find the Apache 2.0 apxs script.]),
734         [
735         AC_MSG_CHECKING(for user-specified Apache 2.0 apxs name/location)
736         if test "$withval" != "no" ; then
737           if test "$withval" != "yes"; then
738             APXS2=$withval
739             AC_MSG_RESULT("$withval")
740           fi
741         fi
742         ],
743         [
744         AC_PATH_PROG(APXS2, apxs2, no)
745         if test "$APXS2" = "no" ; then
746             AC_PATH_PROG(APXS2, apxs, no)
747         fi
748         if test "$APXS2" = "no" ; then
749           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
750             if test "$APXS2" = "no" && test -f "$i/apxs2" ; then
751               APXS2="$i/apxs2"
752             fi
753           done
754           if test "$APXS2" = "no" ; then
755             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
756               if test "$APXS2" = "no" && test -f "$i/apxs" ; then
757                 APXS2="$i/apxs"
758               fi
759             done
760           fi
761         fi
762         ])
763
764     AC_MSG_CHECKING([to see if Apache 2.0 apxs was located])
765     if test ! -f "$APXS2" ; then
766         AC_MSG_RESULT(no)
767         AC_MSG_ERROR([Unable to locate Apache 2.0 apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs2 option.])
768     fi
769     AC_MSG_RESULT($APXS2)
770     AC_SUBST(APXS2)
771
772     # APR settings
773     AC_ARG_WITH(apr, 
774         AS_HELP_STRING([--with-apr=PATH],[where apr-config is installed]),
775         [
776         AC_MSG_CHECKING(for user-specified apr-config name/location)
777         if test "$withval" != "no" ; then
778             if test "$withval" != "yes"; then
779                 APR_CONFIG=$withval
780                 AC_MSG_RESULT("$withval")
781             fi
782         fi
783         ],
784         [
785         AC_PATH_PROG(APR_CONFIG, apr-config,,[`$APXS2 -q SBINDIR`]:[$PATH])
786         ])
787         if test -f "${APR_CONFIG}"; then
788         APR_CFLAGS="`${APR_CONFIG} --cflags` `${APR_CONFIG} --cppflags` `${APR_CONFIG} --includes`"
789     else
790         AC_MSG_ERROR([Unable to locate apr-config, may need --with-apr option.])
791     fi
792
793     # APU settings
794     AC_ARG_WITH(apu, 
795         AS_HELP_STRING([--with-apu=PATH],[where apu-config is installed]),
796         [
797         AC_MSG_CHECKING(for user-specified apu-config name/location)
798         if test "$withval" != "no" ; then
799             if test "$withval" != "yes"; then
800                 APU_CONFIG=$withval
801                 AC_MSG_RESULT("$withval")
802             fi
803         fi
804         ],
805         [
806         AC_PATH_PROG(APU_CONFIG, apu-config,,[`$APXS2 -q SBINDIR`]:[$PATH])
807         ])
808     if test -f "${APU_CONFIG}"; then
809         APU_CFLAGS="`${APU_CONFIG} --includes`"
810     else
811         AC_MSG_ERROR([Unable to locate apu-config, may need --with-apu option.])
812     fi
813
814     # extract settings we need from APXS2 -q
815     APXS2_CC="`$APXS2 -q CC`"
816     APXS2_CFLAGS="`$APXS2 -q CPPFLAGS` `$APXS2 -q CFLAGS` $APR_CFLAGS $APU_CFLAGS"
817     APXS2_INCLUDE="`$APXS2 -q INCLUDEDIR`"
818 fi
819
820 AC_SUBST(APXS2_CFLAGS)
821 AC_SUBST(APXS2_INCLUDE)
822
823
824 # Apache 2.2 (mod_shib_22)
825 #   --enable-apache-22
826 #   --with-apxs22     (DSO build, the normal way, uses apxs to derive build flags)
827 #   --with-apr1       (DSO build, APR development package installed separately)
828 #   --with-apu1       (DSO build, APR-UTIL development package installed separately)
829
830 AC_ARG_ENABLE(apache-22,
831         AS_HELP_STRING([--enable-apache-22],[enable the Apache 2.2 module]),
832         [if test "x$enableval" = "x" ; then
833          WANT_APACHE_22=yes
834          else
835              WANT_APACHE_22="$enableval"
836          fi
837         ],[ WANT_APACHE_22=no ])
838 AC_MSG_CHECKING(whether to build Apache 2.2 module)
839 if test "$WANT_APACHE_22" != yes && test "$WANT_APACHE_22" != no ; then
840     WANT_APACHE_22=yes
841 fi
842 AC_MSG_RESULT($WANT_APACHE_22)
843
844 if test "$WANT_APACHE_22" = "yes" ; then
845     AC_ARG_WITH(apxs22, 
846         AS_HELP_STRING([--with-apxs22=FILE],[Specifies where to find the Apache 2.2 apxs script.]),
847         [
848         AC_MSG_CHECKING(for user-specified Apache 2.2 apxs name/location)
849         if test "$withval" != "no" ; then
850           if test "$withval" != "yes"; then
851             APXS22=$withval
852             AC_MSG_RESULT("$withval")
853           fi
854         fi
855         ],
856         [
857         AC_PATH_PROG(APXS22, apxs2, no)
858         if test "$APXS22" = "no" ; then
859             AC_PATH_PROG(APXS22, apxs, no)
860         fi
861         if test "$APXS22" = "no" ; then
862           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
863             if test "$APXS22" = "no" && test -f "$i/apxs2" ; then
864               APXS22="$i/apxs2"
865             fi
866           done
867           if test "$APXS22" = "no" ; then
868             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
869               if test "$APXS22" = "no" && test -f "$i/apxs" ; then
870                 APXS22="$i/apxs"
871               fi
872             done
873           fi
874         fi
875         ])
876
877     AC_MSG_CHECKING([to see if Apache 2.2 apxs was located])
878     if test ! -f "$APXS22" ; then
879         AC_MSG_RESULT(no)
880         AC_MSG_ERROR([Unable to locate Apache 2.2 apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs22 option.])
881     fi
882     AC_MSG_RESULT($APXS22)
883     AC_SUBST(APXS22)
884
885     # APR1 settings
886     AC_ARG_WITH(apr1, 
887         AS_HELP_STRING([--with-apr1=PATH],[where apr-1-config is installed]),
888         [
889         AC_MSG_CHECKING(for user-specified apr-1-config name/location)
890         if test "$withval" != "no" ; then
891             if test "$withval" != "yes"; then
892                 APR1_CONFIG=$withval
893                 AC_MSG_RESULT("$withval")
894             fi
895         fi
896         ],
897         [
898         AC_PATH_PROG(APR1_CONFIG, apr-1-config,,[`$APXS22 -q SBINDIR`]:[$PATH])
899         ])
900         if test -f "${APR1_CONFIG}"; then
901         APR1_CFLAGS="`${APR1_CONFIG} --cflags` `${APR1_CONFIG} --cppflags` `${APR1_CONFIG} --includes`"
902     else
903         AC_MSG_ERROR([Unable to locate apr-1-config, may need --with-apr1 option.])
904     fi
905
906     # APU1 settings
907     AC_ARG_WITH(apu1, 
908         AS_HELP_STRING([--with-apu1=PATH],[where apu-1-config is installed]),
909         [
910         AC_MSG_CHECKING(for user-specified apu-1-config name/location)
911         if test "$withval" != "no" ; then
912             if test "$withval" != "yes"; then
913                 APU1_CONFIG=$withval
914                 AC_MSG_RESULT("$withval")
915             fi
916         fi
917         ],
918         [
919         AC_PATH_PROG(APU1_CONFIG, apu-1-config,,[`$APXS22 -q SBINDIR`]:[$PATH])
920         ])
921     if test -f "${APU1_CONFIG}"; then
922         APU1_CFLAGS="`${APU1_CONFIG} --includes`"
923     else
924         AC_MSG_ERROR([Unable to locate apu-1-config, may need --with-apu1 option.])
925     fi
926
927     # extract settings we need from APXS22 -q
928     APXS22_CC="`$APXS22 -q CC`"
929     APXS22_CFLAGS="`$APXS22 -q CPPFLAGS` `$APXS22 -q CFLAGS` $APR1_CFLAGS $APU1_CFLAGS"
930     APXS22_INCLUDE="`$APXS22 -q INCLUDEDIR`"
931 fi
932
933 AC_SUBST(APXS22_CFLAGS)
934 AC_SUBST(APXS22_INCLUDE)
935
936 # Apache 2.4 (mod_shib_24)
937 #   --enable-apache-24
938 #   --with-apxs24     (DSO build, the normal way, uses apxs to derive build flags)
939 #   --with-apr1       (DSO build, APR development package installed separately)
940 #   --with-apu1       (DSO build, APR-UTIL development package installed separately)
941
942 AC_ARG_ENABLE(apache-24,
943         AS_HELP_STRING([--enable-apache-24],[enable the Apache 2.4 module]),
944         [if test "x$enableval" = "x" ; then
945          WANT_APACHE_24=yes
946          else
947              WANT_APACHE_24="$enableval"
948          fi
949         ],[ WANT_APACHE_24=no ])
950 AC_MSG_CHECKING(whether to build Apache 2.4 module)
951 if test "$WANT_APACHE_24" != yes && test "$WANT_APACHE_24" != no ; then
952     WANT_APACHE_24=yes
953 fi
954 AC_MSG_RESULT($WANT_APACHE_24)
955
956 if test "$WANT_APACHE_24" = "yes" ; then
957     AC_ARG_WITH(apxs24, 
958         AS_HELP_STRING([--with-apxs24=FILE],[Specifies where to find the Apache 2.4 apxs script.]),
959         [
960         AC_MSG_CHECKING(for user-specified Apache 2.4 apxs name/location)
961         if test "$withval" != "no" ; then
962           if test "$withval" != "yes"; then
963             APXS24=$withval
964             AC_MSG_RESULT("$withval")
965           fi
966         fi
967         ],
968         [
969         AC_PATH_PROG(APXS24, apxs2, no)
970         if test "$APXS24" = "no" ; then
971             AC_PATH_PROG(APXS24, apxs, no)
972         fi
973         if test "$APXS24" = "no" ; then
974           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
975             if test "$APXS24" = "no" && test -f "$i/apxs2" ; then
976               APXS24="$i/apxs2"
977             fi
978           done
979           if test "$APXS24" = "no" ; then
980             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
981               if test "$APXS24" = "no" && test -f "$i/apxs" ; then
982                 APXS24="$i/apxs"
983               fi
984             done
985           fi
986         fi
987         ])
988
989     AC_MSG_CHECKING([to see if Apache 2.4 apxs was located])
990     if test ! -f "$APXS24" ; then
991         AC_MSG_RESULT(no)
992         AC_MSG_ERROR([Unable to locate Apache 2.4 apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs24 option.])
993     fi
994     AC_MSG_RESULT($APXS24)
995     AC_SUBST(APXS24)
996
997     # If we haven't done this work already for Apache 2.2
998     if test "$WANT_APACHE_22" != "yes" ; then
999         # APR1 settings
1000         AC_ARG_WITH(apr1,
1001             AS_HELP_STRING([--with-apr1=PATH],[where apr-1-config is installed]),
1002             [
1003             AC_MSG_CHECKING(for user-specified apr-1-config name/location)
1004             if test "$withval" != "no" ; then
1005                 if test "$withval" != "yes"; then
1006                     APR1_CONFIG=$withval
1007                     AC_MSG_RESULT("$withval")
1008                 fi
1009             fi
1010             ],
1011             [
1012             AC_PATH_PROG(APR1_CONFIG, apr-1-config,,[`$APXS24 -q SBINDIR`]:[$PATH])
1013             ])
1014         if test -f "${APR1_CONFIG}"; then
1015             APR1_CFLAGS="`${APR1_CONFIG} --cflags` `${APR1_CONFIG} --cppflags` `${APR1_CONFIG} --includes`"
1016         else
1017             AC_MSG_ERROR([Unable to locate apr-1-config, may need --with-apr1 option.])
1018         fi
1019
1020         # APU1 settings
1021         AC_ARG_WITH(apu1,
1022             AS_HELP_STRING([--with-apu1=PATH],[where apu-1-config is installed]),
1023             [
1024             AC_MSG_CHECKING(for user-specified apu-1-config name/location)
1025             if test "$withval" != "no" ; then
1026                 if test "$withval" != "yes"; then
1027                     APU1_CONFIG=$withval
1028                     AC_MSG_RESULT("$withval")
1029                 fi
1030             fi
1031             ],
1032             [
1033             AC_PATH_PROG(APU1_CONFIG, apu-1-config,,[`$APXS24 -q SBINDIR`]:[$PATH])
1034             ])
1035         if test -f "${APU1_CONFIG}"; then
1036             APU1_CFLAGS="`${APU1_CONFIG} --includes`"
1037         else
1038             AC_MSG_ERROR([Unable to locate apu-1-config, may need --with-apu1 option.])
1039         fi
1040     fi
1041     
1042     # extract settings we need from APXS24 -q
1043     APXS24_CC="`$APXS24 -q CC`"
1044     APXS24_CFLAGS="`$APXS24 -q CPPFLAGS` `$APXS24 -q CFLAGS` $APR1_CFLAGS $APU1_CFLAGS"
1045     APXS24_INCLUDE="`$APXS24 -q INCLUDEDIR`"
1046 fi
1047
1048 AC_SUBST(APXS24_CFLAGS)
1049 AC_SUBST(APXS24_INCLUDE)
1050
1051 # always output the Makefile, even if you don't use it
1052 AC_CONFIG_FILES([apache/Makefile])
1053 AM_CONDITIONAL(BUILD_AP13,test "$WANT_APACHE_13" = "yes")
1054 AM_CONDITIONAL(BUILD_AP20,test "$WANT_APACHE_20" = "yes")
1055 AM_CONDITIONAL(BUILD_AP22,test "$WANT_APACHE_22" = "yes")
1056 AM_CONDITIONAL(BUILD_AP24,test "$WANT_APACHE_24" = "yes")
1057
1058 # add the apache module to the list of wanted subdirs..
1059 if test "$WANT_APACHE_13" = "yes" || test "$WANT_APACHE_20" = "yes" || test "$WANT_APACHE_22" = "yes" || test "$WANT_APACHE_24" = "yes" ; then
1060     WANT_SUBDIRS="$WANT_SUBDIRS apache"
1061 fi
1062
1063
1064 #
1065 # Implement the checks of the ODBC Storage Service
1066 #
1067 # 1) Assume the user wants ODBC; if it's not found then just continue without
1068 # 2) If the user specifically requested odbc, look for it and ERROR if not found
1069 # 3) If the user specifically requested no odbc, don't build it.
1070 #
1071
1072 AC_CONFIG_FILES([odbc-store/Makefile])
1073
1074 # determine whether we should enable the odbc ccache
1075 AC_ARG_ENABLE([odbc],
1076         AS_HELP_STRING([--disable-odbc],[disable the ODBC Storage Service]),
1077         [odbc_enabled=$enableval], [odbc_enabled=default])
1078 if test "x$odbc_enabled" = "x" ; then
1079     odbc_enabled=yes
1080 fi
1081
1082 # Are we trying to build ODBC?
1083 AC_MSG_CHECKING(whether to build the ODBC storage service)
1084 if test "$odbc_enabled" = "yes" ; then
1085     build_odbc=yes
1086     AC_MSG_RESULT(yes)
1087 elif test "$odbc_enabled" = "default" ; then
1088     build_odbc=yes
1089     AC_MSG_RESULT([yes, if it can be found])
1090 else
1091     build_odbc=no
1092     AC_MSG_RESULT(no)
1093 fi
1094
1095 # If we're trying to build ODBC, try to find the odbc_config program.
1096 if test "$build_odbc" = "yes" ; then
1097     odbc_dir=""
1098     AC_ARG_WITH(odbc,
1099            AS_HELP_STRING([--with-odbc=PATH],[directory where odbc is installed]),
1100             [if test "$with_odbc" = no ; then
1101             AC_MSG_ERROR([Try running --disable-odbc instead.])
1102          elif test "$with_odbc" != yes ; then
1103             odbc_dir="$with_odbc/bin"
1104             if test "$with_odbc" != /usr ; then
1105                 ODBC_CFLAGS="-I$with_odbc/include"
1106                 ODBC_LIBS="-L$with_odbc/lib"
1107             fi
1108          fi])
1109
1110    AC_PATH_PROG(ODBC_CONFIG, odbc_config, no, $odbc_dir $PATH )
1111    if test "$ODBC_CONFIG" = no ; then
1112       AC_MSG_WARN([Cannot find odbc_config, will try to guess settings.])
1113       ODBC_LIBS="$ODBC_LIBS -lodbc"
1114    else
1115       ODBC_CFLAGS=`$ODBC_CONFIG --cflags`
1116       ODBC_LIBS=`$ODBC_CONFIG --libs`
1117    fi
1118
1119    save_CPPFLAGS="$CPPFLAGS"
1120    CPPFLAGS="$CPPFLAGS $ODBC_CFLAGS"
1121
1122    AC_CHECK_HEADER([sql.h], [have_sql_h=yes], [have_sql_h=no])
1123    if test "$have_sql_h" = no -a "$odbc_enabled" = "yes" ; then
1124      AC_MSG_ERROR(unable to find ODBC header files)
1125    fi
1126
1127    if test "$have_sql_h" = yes ; then
1128       save_LIBS="$LIBS"
1129       LIBS="$LIBS $ODBC_LIBS"
1130       AC_MSG_CHECKING(if we can link againt ODBC)
1131       AC_LINK_IFELSE(
1132         [AC_LANG_PROGRAM([[#include <sql.h>
1133  #include <sqlext.h>
1134  #include <stdio.h>]],
1135             [[SQLSetEnvAttr(SQL_NULL_HANDLE, SQL_ATTR_CONNECTION_POOLING, (void*)SQL_CP_ONE_PER_HENV, 0)]])],
1136         [have_odbc_libs=yes],[have_odbc_libs=no])
1137       LIBS="$save_LIBS"
1138       if test "$have_odbc_libs" = no ; then
1139          if test "$odbc_enabled" = "yes" ; then
1140             AC_MSG_ERROR([unable to link with ODBC Library])
1141          else
1142             AC_MSG_RESULT([no, skipping ODBC])
1143          fi
1144       fi
1145    fi
1146
1147    CPPFLAGS="$save_CPPFLAGS"
1148 fi
1149
1150 # if have_odbc_libs=yes then go ahead with building ODBC
1151 if test "$have_odbc_libs" = yes ; then
1152    # this AC_MSG_RESULT is from above!
1153    AC_MSG_RESULT(yes)
1154    WANT_SUBDIRS="$WANT_SUBDIRS odbc-store"
1155    AC_SUBST(ODBC_CFLAGS)
1156    AC_SUBST(ODBC_LIBS)
1157 fi
1158
1159 # GSS-API checking
1160
1161 GSSAPI_ROOT="/usr"
1162 AC_ARG_WITH(gssapi-includes,
1163   AS_HELP_STRING([--with-gssapi-includes=DIR],[Specify location of GSSAPI header]),
1164   [ GSSAPI_INCS="-I$withval"
1165     want_gss="yes" ]
1166 )
1167
1168 AC_ARG_WITH(gssapi-libs,
1169   AS_HELP_STRING([--with-gssapi-libs=DIR],[Specify location of GSSAPI libs]),
1170   [ GSSAPI_LIB_DIR="-L$withval"
1171     want_gss="yes" ]
1172 )
1173
1174 AC_ARG_WITH(gssapi,
1175   AS_HELP_STRING([--with-gssapi=DIR],[Where to look for GSSAPI]),
1176   [ GSSAPI_ROOT="$withval"
1177   if test x"$GSSAPI_ROOT" != xno; then
1178     want_gss="yes"
1179     if test x"$GSSAPI_ROOT" = xyes; then
1180       dnl if yes, then use default root
1181       GSSAPI_ROOT="/usr"
1182     fi
1183   fi
1184 ])
1185
1186 save_CPPFLAGS="$CPPFLAGS"
1187 AC_MSG_CHECKING([if GSSAPI support is requested])
1188 if test x"$want_gss" = xyes; then
1189   AC_MSG_RESULT(yes)
1190
1191   if test -z "$GSSAPI_INCS"; then
1192      if test -f "$GSSAPI_ROOT/bin/krb5-config"; then
1193         GSSAPI_INCS=`$GSSAPI_ROOT/bin/krb5-config --cflags gssapi`
1194      elif test "$GSSAPI_ROOT" != "yes"; then
1195         GSSAPI_INCS="-I$GSSAPI_ROOT/include"
1196      fi
1197   fi
1198
1199   CPPFLAGS="$CPPFLAGS $GSSAPI_INCS"
1200
1201   AC_CHECK_HEADER(gss.h,
1202     [
1203       dnl found in the given dirs
1204       AC_DEFINE([SHIBSP_HAVE_GSSGNU],[1],[if you have the GNU gssapi libraries])
1205       gnu_gss=yes
1206     ],
1207     [
1208       dnl not found, check Heimdal or MIT
1209       AC_CHECK_HEADERS([gssapi/gssapi.h], [], [not_mit=1])
1210       AC_CHECK_HEADERS(
1211         [gssapi/gssapi_generic.h gssapi/gssapi_krb5.h],
1212         [],
1213         [not_mit=1],
1214         [
1215 AC_INCLUDES_DEFAULT
1216 #ifdef HAVE_GSSAPI_GSSAPI_H
1217 #include <gssapi/gssapi.h>
1218 #endif
1219         ])
1220       if test "x$not_mit" = "x1"; then
1221         dnl MIT not found, check for Heimdal
1222         AC_CHECK_HEADER([gssapi.h],
1223             [
1224               dnl found
1225               AC_DEFINE([SHIBSP_HAVE_GSSHEIMDAL],[1],[if you have the Heimdal gssapi libraries])
1226             ],
1227             [
1228               dnl no header found, disabling GSS
1229               want_gss=no
1230               AC_MSG_WARN([disabling GSSAPI since no header files was found])
1231             ]
1232           )
1233       else
1234         dnl MIT found
1235         AC_DEFINE([SHIBSP_HAVE_GSSMIT],[1],[if you have the MIT gssapi libraries])
1236         dnl check if we have a really old MIT kerberos (<= 1.2)
1237         AC_MSG_CHECKING([if gssapi headers declare GSS_C_NT_HOSTBASED_SERVICE])
1238         AC_COMPILE_IFELSE([
1239           AC_LANG_PROGRAM([[
1240 #include <gssapi/gssapi.h>
1241 #include <gssapi/gssapi_generic.h>
1242 #include <gssapi/gssapi_krb5.h>
1243           ]],[[
1244             gss_import_name(
1245                             (OM_uint32 *)0,
1246                             (gss_buffer_t)0,
1247                             GSS_C_NT_HOSTBASED_SERVICE,
1248                             (gss_name_t *)0);
1249           ]])
1250         ],[
1251           AC_MSG_RESULT([yes])
1252         ],[
1253           AC_MSG_RESULT([no])
1254           AC_DEFINE([HAVE_OLD_GSSMIT],[1],[if you have an old MIT gssapi library, lacking GSS_C_NT_HOSTBASED_SERVICE])
1255         ])
1256       fi
1257     ]
1258   )
1259 else
1260   AC_MSG_RESULT(no)
1261 fi
1262 if test x"$want_gss" = xyes; then
1263   AC_DEFINE([SHIBSP_HAVE_GSSAPI],[1],[if you have the gssapi libraries])
1264
1265   if test -n "$gnu_gss"; then
1266     LDFLAGS="$LDFLAGS $GSSAPI_LIB_DIR"
1267     LIBS="$LIBS -lgss"
1268   else
1269     if test -z "$GSSAPI_LIB_DIR"; then
1270       GSSAPI_LIB_DIR="$GSSAPI_ROOT/lib$libsuff"
1271     fi
1272     if test "$GSSAPI_ROOT" != "yes"; then
1273        LDFLAGS="$LDFLAGS -L$GSSAPI_ROOT/lib$libsuff"
1274     fi
1275     if test -f "$GSSAPI_ROOT/bin/krb5-config"; then
1276       dnl krb5-config doesn't have --libs-only-L or similar, put everything
1277       dnl into LIBS
1278       gss_libs=`$GSSAPI_ROOT/bin/krb5-config --libs gssapi`
1279     else
1280       if test "x$not_mit" = "x1"; then
1281         gss_libs="-lgssapi"
1282       else
1283         gss_libs="-lgssapi_krb5"
1284       fi
1285     fi
1286     LIBS="$LIBS $gss_libs"
1287   fi
1288
1289   AC_MSG_CHECKING([whether GSS-API naming extensions are available])
1290   AC_COMPILE_IFELSE(
1291     [AC_LANG_PROGRAM([[
1292 #ifdef SHIBSP_HAVE_GSSGNU
1293 # include <gss.h>
1294 #elif defined SHIBSP_HAVE_GSSMIT
1295 # include <gssapi/gssapi.h>
1296 # include <gssapi/gssapi_ext.h>
1297 #else
1298 # include <gssapi.h>
1299 #endif]],
1300     [[gss_get_name_attribute(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);]])],
1301     [AC_MSG_RESULT([yes])AC_DEFINE([HAVE_GSSAPI_NAMINGEXTS],[1],[Define to 1 if GSS-API naming extensions are available.])],
1302     [AC_MSG_RESULT([no])])
1303
1304   AC_MSG_CHECKING([whether GSS-API composite name import is available])
1305   AC_COMPILE_IFELSE(
1306     [AC_LANG_PROGRAM([[
1307 #ifdef SHIBSP_HAVE_GSSGNU
1308 # include <gss.h>
1309 #elif defined SHIBSP_HAVE_GSSMIT
1310 # include <gssapi/gssapi.h>
1311 # include <gssapi/gssapi_ext.h>
1312 #else
1313 # include <gssapi.h>
1314 #endif]],
1315     [[
1316     OM_uint32 minor;
1317     gss_name_t srcname;
1318     gss_buffer_desc importbuf;
1319     gss_import_name(&minor, &importbuf, GSS_C_NT_EXPORT_NAME_COMPOSITE, &srcname);
1320     ]])],
1321     [AC_MSG_RESULT([yes])AC_DEFINE([HAVE_GSSAPI_COMPOSITE_NAME],[1],[Define to 1 if GSS-API composite name import is available.])],
1322     [AC_MSG_RESULT([no])])
1323     
1324 else
1325   CPPFLAGS="$save_CPPFLAGS"
1326 fi
1327
1328
1329 AC_SUBST(WANT_SUBDIRS)
1330
1331 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
1332   echo "=================================================================="
1333   echo "WARNING: You have chosen to compile Apache-1.3 modules with a different"
1334   echo "         compiler than the one used to compile Apache."
1335   echo ""
1336   echo "    Current compiler:      $CC"
1337   echo "   Apache's compiler:      $APXS_CC"
1338   echo ""
1339   echo "This could cause problems."
1340   echo "=================================================================="
1341 fi
1342
1343 if test -n "$APXS2_CC" && test "$APXS2_CC" != "$CC" ; then
1344   echo "=================================================================="
1345   echo "WARNING: You have chosen to compile Apache-2.0 modules with a different"
1346   echo "         compiler than the one used to compile Apache."
1347   echo ""
1348   echo "    Current compiler:      $CC"
1349   echo "   Apache's compiler:      $APXS2_CC"
1350   echo ""
1351   echo "This could cause problems."
1352   echo "=================================================================="
1353 fi
1354
1355 if test -n "$APXS22_CC" && test "$APXS22_CC" != "$CC" ; then
1356   echo "=================================================================="
1357   echo "WARNING: You have chosen to compile Apache-2.2 modules with a different"
1358   echo "         compiler than the one used to compile Apache."
1359   echo ""
1360   echo "    Current compiler:      $CC"
1361   echo "   Apache's compiler:      $APXS22_CC"
1362   echo ""
1363   echo "This could cause problems."
1364   echo "=================================================================="
1365 fi
1366
1367 if test -n "$APXS24_CC" && test "$APXS24_CC" != "$CC" ; then
1368   echo "=================================================================="
1369   echo "WARNING: You have chosen to compile Apache-2.4 modules with a different"
1370   echo "         compiler than the one used to compile Apache."
1371   echo ""
1372   echo "    Current compiler:      $CC"
1373   echo "   Apache's compiler:      $APXS24_CC"
1374   echo ""
1375   echo "This could cause problems."
1376   echo "=================================================================="
1377 fi
1378
1379 LIBTOOL="$LIBTOOL --silent"
1380
1381 AC_OUTPUT