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