https://issues.shibboleth.net/jira/browse/SSPCPP-273
[shibboleth/cpp-sp.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([shibboleth], [2.4], [shibboleth-users@internet2.edu], [shibboleth])
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE([shibboleth],[2.4])
5
6 sinclude(doxygen.m4)
7 sinclude(acx_pthread.m4)
8
9 # Docygen features
10 DX_HTML_FEATURE(ON)
11 DX_CHM_FEATURE(OFF)
12 DX_CHI_FEATURE(OFF)
13 DX_MAN_FEATURE(OFF)
14 DX_RTF_FEATURE(OFF)
15 DX_XML_FEATURE(OFF)
16 DX_PDF_FEATURE(OFF)
17 DX_PS_FEATURE(OFF)
18 DX_INIT_DOXYGEN(shibboleth, doxygen.cfg, doc/api)
19 DX_INCLUDE=
20
21 AC_ARG_ENABLE(debug,
22     AC_HELP_STRING(--enable-debug, [Have GCC compile with symbols (Default = no)
23 ]),
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_PROG_CC([gcc gcc3 cc])
35 AC_PROG_CXX([g++ g++3 c++ CC])
36 AC_CANONICAL_HOST
37
38 if test "$GCC" = "yes" ; then
39 #    AC_HAVE_GCC_VERSION(4,0,0,0,
40 #        [
41 #        AC_DEFINE(GCC_HASCLASSVISIBILITY,1,
42 #            [Define to enable class visibility control in gcc.])
43 #        GCC_CFLAGS="$GCC_CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
44 #        GCC_CXXFLAGS="$GCC_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
45 #        ])
46     CFLAGS="-Wall $GCC_CFLAGS"
47     CXXFLAGS="-Wall $GCC_CXXFLAGS"
48 else
49 # Fix for Sun Workshop compiler in debug mode, may be Sun case #6360993
50         case "${host_cpu}-${host_os}" in
51                 *solaris*)
52                         if test "$CXX" = "CC" ; then
53                                 CXXFLAGS="$CXXFLAGS -Qoption ccfe -stabs=no%dfltlit+no%dflthlp"
54                         fi
55                         ;;
56                 *osf*)
57                         CXXFLAGS="$CXXFLAGS -D_POSIX_PII_SOCKET"
58                         ;;
59         esac
60 fi
61
62 AC_DISABLE_STATIC
63 AC_PROG_LIBTOOL
64
65 AC_LANG(C)
66
67 # Checks for typedefs, structures, and compiler characteristics.
68 AC_C_CONST
69 AC_TYPE_SIZE_T
70 AC_STRUCT_TM
71
72 # Checks for library functions.
73 AC_FUNC_STRFTIME
74 AC_FUNC_STRERROR_R
75 AC_CHECK_FUNCS([strchr strdup strstr timegm gmtime_r strtok_r strcasecmp])
76
77 # checks for pthreads
78 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
79 if test $enable_threads != "pthread"; then
80     AC_MSG_ERROR([unable to find pthreads, currently this is required])
81 else
82     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
83     LIBS="$PTHREAD_LIBS $LIBS"
84     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
85     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
86 fi
87
88 # OpenSSL settings
89 AC_ARG_WITH(openssl,
90     AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
91     [if test x_$with_openssl != x_/usr; then
92         SSLFLAGS="-I${with_openssl}/include"
93     fi])
94
95 if test "x$SSLFLAGS" = "x" ; then
96     AC_PATH_PROG(PKG_CONFIG, pkg-config)
97     if test "x$PKG_CONFIG" != x && test "x$PKG_CONFIG" != "xno" ; then
98         if pkg-config openssl ; then
99             SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
100         else
101             AC_MSG_WARN([OpenSSL not supported by pkg-config, try --with-openssl instead])
102         fi
103     fi
104 fi
105
106 AC_MSG_CHECKING(for OpenSSL cflags)
107 AC_MSG_RESULT($SSLFLAGS)
108 CPPFLAGS="$SSLFLAGS $CPPFLAGS"
109
110 AC_CHECK_HEADER([openssl/x509.h],,
111                 AC_MSG_ERROR([unable to find openssl header files]))
112
113 AC_LANG(C++)
114
115 # C++ requirements
116 AC_CXX_REQUIRE_STL
117 AC_CXX_NAMESPACES
118
119 # Thank you Solaris, really.
120 AC_MSG_CHECKING(for ctime_r)
121  if test -z "$ac_cv_ctime_args"; then
122      AC_TRY_COMPILE(
123      [#include <time.h>],
124      [
125          time_t clock;
126          char buf[26];
127          ctime_r(&clock, buf);
128      ], ac_cv_ctime_args=2)
129
130      AC_TRY_COMPILE(
131      [#include <time.h>],
132      [
133          time_t clock;
134          char buf[26];
135          ctime_r(&clock, buf, 26);
136      ], ac_cv_ctime_args=3)
137  fi
138  if test -z "$ac_cv_ctime_args"; then
139      AC_MSG_RESULT(no)
140  else
141      if test "$ac_cv_ctime_args" = 2; then
142          AC_DEFINE(HAVE_CTIME_R_2,1,[Define if ctime_r is present with 2 parameters.])
143      elif test "$ac_cv_ctime_args" = 3; then
144          AC_DEFINE(HAVE_CTIME_R_3,1,[Define if ctime_r is present with 3 parameters.])
145      fi
146      AC_MSG_RESULT([yes, and it takes $ac_cv_ctime_args arguments])
147  fi 
148
149 # log4shib settings (favor this version over the log4cpp code)
150 AC_PATH_PROG(LOG4SHIB_CONFIG,log4shib-config)
151 AC_ARG_WITH(log4shib,
152     AC_HELP_STRING([--with-log4shib=PATH], [where log4shib-config is installed]),
153     [
154     LOG4SHIB_CONFIG="${with_log4shib}"
155     if ! test -f "${LOG4SHIB_CONFIG}" ; then
156         LOG4SHIB_CONFIG="${with_log4shib}/bin/log4shib-config"
157     fi
158     ])
159 if test -f "${LOG4SHIB_CONFIG}"; then
160     LDFLAGS="`${LOG4SHIB_CONFIG} --libs` $LDFLAGS"
161     CPPFLAGS="`${LOG4SHIB_CONFIG} --cflags` $CPPFLAGS"
162         AC_CHECK_HEADER([log4shib/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4shib header files]))
163         AC_TRY_LINK(
164                 [#include <log4shib/Category.hh>
165 #include <log4shib/CategoryStream.hh>],
166                 [log4shib::Category::getInstance("foo").errorStream() << log4shib::eol],
167                 [AC_DEFINE(SHIBSP_LOG4SHIB,1,[Define if log4shib library is used.])],
168                 [AC_MSG_ERROR([unable to link with log4shib])])
169 else
170     AC_MSG_WARN([log4shib-config not found, may need to use --with-log4shib option])
171     AC_MSG_WARN([will look for original log4cpp library])
172     
173         # log4cpp settings
174         AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
175         AC_ARG_WITH(log4cpp,
176             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
177             [
178             LOG4CPP_CONFIG="${with_log4cpp}"
179             if ! test -f "${LOG4CPP_CONFIG}" ; then
180                 LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
181             fi
182             ])
183         if test -f "${LOG4CPP_CONFIG}"; then
184                 AC_MSG_WARN([will try to use log4cpp, note that most non-Internet2 supplied versions are not thread-safe])
185             LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
186             CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
187                 AC_CHECK_HEADER([log4cpp/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
188                 AC_TRY_LINK(
189                         [#include <log4cpp/Category.hh>
190 #include <log4cpp/CategoryStream.hh>],
191                         [log4cpp::Category::getInstance("foo").errorStream() << log4cpp::eol],
192                         [AC_DEFINE(SHIBSP_LOG4CPP,1,[Define if log4cpp library is used.])],
193                         [AC_MSG_ERROR([unable to link with log4cpp, need version 1.0 or later])])
194         else
195             AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
196         fi
197 fi
198
199 # Xerces settings
200 AC_ARG_WITH(xerces, 
201             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
202             [if test x_$with_xerces != x_/usr; then
203                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
204                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
205             fi])
206 LIBS="-lxerces-c $LIBS"
207 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
208                 AC_MSG_ERROR([unable to find xerces header files]))
209 AC_MSG_CHECKING([Xerces version])
210 AC_PREPROC_IFELSE(
211     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
212 [#if  _XERCES_VERSION != 20600
213 int i = 0;
214 #else
215 #error cannot use version 2.6.0
216 #endif])],
217     [AC_MSG_RESULT(OK)],
218     [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use a newer version])])
219 AC_TRY_LINK(
220         [#include <xercesc/util/PlatformUtils.hpp>],
221         [xercesc::XMLPlatformUtils::Initialize()],
222         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
223         [AC_MSG_ERROR([unable to link with Xerces])])
224
225 AC_MSG_CHECKING([whether Xerces XMLString::release(XMLByte**) exists])
226 AC_TRY_COMPILE([#include <xercesc/util/XMLString.hpp>],
227     [using namespace XERCES_CPP_NAMESPACE;
228       XMLByte* buf=NULL;
229       XMLString::release(&buf);
230     ],
231     [AC_MSG_RESULT([yes])]
232     [AC_DEFINE([SHIBSP_XERCESC_HAS_XMLBYTE_RELEASE], [1], [Define to 1 if Xerces XMLString includes XMLByte release.])],
233     [AC_MSG_RESULT([no])])
234
235 AC_MSG_CHECKING([whether Xerces DOMNodeFilter API returns a short])
236 AC_TRY_COMPILE([#include <xercesc/dom/DOM.hpp>],
237     [using namespace XERCES_CPP_NAMESPACE;
238       class Blocker : public DOMNodeFilter {
239       public:
240         short acceptNode(const DOMNode* node) const {
241             return FILTER_REJECT;
242         }
243       };
244       static Blocker g_Blocker;
245     ],
246     [AC_MSG_RESULT([yes])]
247     [AC_DEFINE([SHIBSP_XERCESC_SHORT_ACCEPTNODE], [1], [Define to 1 if Xerces DOMNodeFilter API returns a short.])],
248     [AC_MSG_RESULT([no])])
249
250 #XML-Tooling settings
251 AC_ARG_WITH(xmltooling,
252             AC_HELP_STRING([--with-xmltooling=PATH], [where xmltooling-c is installed]),
253             [if test x_$with_xmltooling != x_/usr; then
254                 LDFLAGS="-L${with_xmltooling}/lib $LDFLAGS"
255                 CPPFLAGS="-I${with_xmltooling}/include $CPPFLAGS"
256             fi])
257 LITE_LIBS="-lxmltooling-lite"
258 XMLSEC_LIBS="-lxmltooling"
259 AC_CHECK_HEADER([xmltooling/base.h],,
260                 AC_MSG_ERROR([unable to find xmltooling header files]))
261                 
262
263 # save and append master libs
264 save_LIBS="$LIBS"
265 LIBS="$XMLSEC_LIBS $LIBS"
266
267 AC_TRY_LINK(
268     [#include <xmltooling/io/HTTPResponse.h>],
269     [xmltooling::HTTPResponse::sanitizeURL("http://test")],
270     [AC_DEFINE(HAVE_XMLTOOLING,1,[Define if xmltooling library was found])],
271     [AC_MSG_ERROR([unable to link with XMLTooling, or version was too old])])
272
273 # restore master libs
274 LIBS="$save_LIBS"
275
276 # Establish location of xmltooling catalog.
277 XMLTOOLINGXMLDIR=""
278 if test "x$with_xmltooling" = "x" ; then
279    with_xmltooling="/usr"
280 fi
281 if test -f $with_xmltooling/share/xml/xmltooling/catalog.xml ; then
282     XMLTOOLINGXMLDIR="$with_xmltooling"
283 elif test -f $with_xerces/share/xml/xmltooling/catalog.xml ; then
284     XMLTOOLINGXMLDIR="$with_xerces"
285 elif test -f $with_log4shib/share/xml/xmltooling/catalog.xml ; then
286     XMLTOOLINGXMLDIR="$with_log4shib"
287 fi
288 if test "x$XMLTOOLINGXMLDIR" = "x" ; then
289     AC_MSG_ERROR([xmltooling XML catalog not found, may need to use --with-xmltooling option])
290 fi
291 XMLTOOLINGXMLDIR="$XMLTOOLINGXMLDIR/share/xml/xmltooling"
292 AC_SUBST(XMLTOOLINGXMLDIR)
293
294 # XML-Security settings
295 AC_ARG_WITH(xmlsec,
296             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
297             [with_xmlsec=/usr])
298
299 if test x_$with_xmlsec != x_/usr; then
300     LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
301     CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
302 fi        
303 XMLSEC_LIBS="-lxml-security-c $XMLSEC_LIBS"
304
305 # save and append master libs
306 save_LIBS="$LIBS"
307 LIBS="$XMLSEC_LIBS $LIBS"
308
309 AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security-C header files]))
310 AC_MSG_CHECKING([XML-Security-C version])
311 AC_PREPROC_IFELSE(
312     [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
313     [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3)
314 int i = 0;
315 #else
316 #error need version 1.4.0 or later
317 #endif])],
318     [AC_MSG_RESULT(OK)],
319     [AC_MSG_FAILURE([XML-Security-C version 1.4.0 or greater is required.])])
320 AC_TRY_LINK(
321         [#include <xsec/utils/XSECPlatformUtils.hpp>],
322         [XSECPlatformUtils::Initialise()],,
323         [AC_MSG_ERROR([unable to link with XML-Security])])
324
325
326 AC_MSG_CHECKING([whether XML-Security-C supports white/blacklisting of algorithms])
327 AC_TRY_COMPILE([#include <xsec/framework/XSECAlgorithmMapper.hpp>],
328       [XSECAlgorithmMapper* mapper; mapper->whitelistAlgorithm(NULL);],
329       [AC_MSG_RESULT([yes])]
330       [AC_DEFINE([SHIBSP_XMLSEC_WHITELISTING], [1], [Define to 1 if XML-Security-C supports white/blacklisting algorithms.])],
331       [AC_MSG_RESULT([no])])
332
333
334 # restore master libs
335 LIBS="$save_LIBS"
336
337 # OpenSAML settings
338 AC_ARG_WITH(saml,
339     AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
340     [if test x_$with_saml != x_/usr; then
341         LDFLAGS="-L${with_saml}/lib $LDFLAGS"
342         CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
343     fi])
344 XMLSEC_LIBS="-lsaml $XMLSEC_LIBS"
345
346 # save and append master libs
347 save_LIBS="$LIBS"
348 LIBS="$XMLSEC_LIBS $LIBS"
349
350 AC_CHECK_HEADER([saml/saml2/metadata/Metadata.h],,
351                 AC_MSG_ERROR([unable to find OpenSAML header files]))
352 AC_TRY_LINK(
353         [#include <saml/SAMLConfig.h>
354 #include <saml/version.h>],
355         [#if _OPENSAML_VERSION >= 20200
356 opensaml::SAMLConfig::getConfig();
357 #else
358 #error Need OpenSAML version 2.2 or higher
359 #endif],
360         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
361         [AC_MSG_ERROR([unable to link with OpenSAML, or version was too old])])
362
363 # restore master libs
364 LIBS="$save_LIBS"
365
366 # Establish location of opensaml catalogs.
367 OPENSAMLXMLDIR=""
368 if test "x$with_saml" = "x" ; then
369     with_saml="/usr"
370 fi
371 if test -f $with_saml/share/xml/opensaml/saml20-catalog.xml ; then
372     OPENSAMLXMLDIR="$with_saml"
373 elif test -f $with_xmltooling/share/xml/opensaml/saml20-catalog.xml ; then
374     OPENSAMLXMLDIR="$with_xmltooling"
375 elif test -f $with_xerces/share/xml/opensaml/saml20-catalog.xml ; then
376     OPENSAMLXMLDIR="$with_xerces"
377 elif test -f $with_log4shib/share/xml/opensaml/saml20-catalog.xml ; then
378     OPENSAMLXMLDIR="$with_log4shib"
379 fi
380 if test "x$OPENSAMLXMLDIR" = "x" ; then
381     AC_MSG_ERROR([opensaml XML catalogs not found, may need to use --with-saml option])
382 fi
383 OPENSAMLXMLDIR="$OPENSAMLXMLDIR/share/xml/opensaml"
384 AC_SUBST(OPENSAMLXMLDIR)
385
386 AC_SUBST(LITE_LIBS)
387 AC_SUBST(XMLSEC_LIBS)
388
389 AC_CONFIG_FILES([shibboleth.spec pkginfo Portfile])
390
391 # output the underlying makefiles
392 WANT_SUBDIRS="doc schemas configs shibsp shibd util"
393 AC_CONFIG_FILES([Makefile doc/Makefile schemas/Makefile \
394         configs/Makefile shibsp/Makefile shibd/Makefile \
395         util/Makefile selinux/Makefile])
396
397 ## ADFS?
398 AC_CONFIG_FILES([adfs/Makefile])
399 AC_ARG_ENABLE([adfs],
400         AC_HELP_STRING([--disable-adfs], [don't build the ADFS module]),
401         [adfs_enabled=$enableval], [adfs_enabled=yes])
402 if test "x$adfs_enabled" = "x" ; then
403    adfs_enabled=yes
404 fi
405 AC_MSG_CHECKING(whether to build the ADFS module)
406 if test "$adfs_enabled" = "no" ; then
407    AC_MSG_RESULT(no)
408 else
409    AC_MSG_RESULT(yes)
410    WANT_SUBDIRS="$WANT_SUBDIRS adfs"
411 fi
412
413
414 #
415 # Build NSAPI module?
416 #
417 AC_MSG_CHECKING(for NSAPI module option)
418 AC_ARG_WITH(nsapi,
419         AC_HELP_STRING([--with-nsapi=DIR], [Build NSAPI module for Netscape/iPlanet/SunONE]),
420         [WANT_NSAPI=$withval],[WANT_NSAPI=no])
421 AC_MSG_RESULT($WANT_NSAPI)
422
423 if test "$WANT_NSAPI" != "no"; then
424   if test ! -d $WANT_NSAPI/bin ; then
425     AC_MSG_ERROR(Please specify the path to the root of your Netscape/iPlanet/SunONE server using --with-nsapi=DIR)
426   fi
427   AC_MSG_CHECKING(for NSAPI include files)
428   if test -d $WANT_NSAPI/include ; then
429     NSAPI_INCLUDE=$WANT_NSAPI/include
430     AC_MSG_RESULT(Netscape-Enterprise 3.x style)
431     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h],,,[#define XP_UNIX])
432     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
433   fi
434   if test -d $WANT_NSAPI/plugins/include ; then
435     test -n "$NSAPI_INCLUDE" && NSAPI_INC_DIR="-I$NSAPI_INCLUDE"
436     NSAPI_INCLUDE="$WANT_NSAPI/plugins/include"
437     AC_MSG_RESULT(iPlanet 4.x / SunONE 6.x style)
438     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h],,,[#define XP_UNIX])
439     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
440   fi
441   if test "$NSAPI_INCLUDE" = ""; then
442     AC_MSG_ERROR(Please check you have nsapi.h in either $WANT_NSAPI/include or $WANT_NSAPI/plugins/include)
443   fi
444 fi
445
446 AC_SUBST(NSAPI_INCLUDE)
447
448 # always output the Makefile, even if you don't use it
449 AC_CONFIG_FILES([nsapi_shib/Makefile])
450 AM_CONDITIONAL(BUILD_NSAPI,test ! "$WANT_NSAPI" = "no")
451
452 # add the NSAPI module to the list of wanted subdirs..
453 if test ! "$WANT_NSAPI" = "no" ; then
454     WANT_SUBDIRS="$WANT_SUBDIRS nsapi_shib"
455 fi
456
457
458 #
459 # Build FastCGI support?
460 #
461 AC_MSG_CHECKING(for FastCGI support)
462 AC_ARG_WITH(fastcgi,
463     AC_HELP_STRING([--with-fastcgi=DIR], [Build FastCGI support]),
464     [WANT_FASTCGI=$withval],[WANT_FASTCGI=no])
465 AC_MSG_RESULT($WANT_FASTCGI)
466
467 if test "$WANT_FASTCGI" != "no"; then
468     if test "$WANT_FASTCGI" != "yes"; then
469         if test x_$WANT_FASTCGI != x_/usr; then
470             FASTCGI_INCLUDE="-I$WANT_FASTCGI/include"
471             FASTCGI_LDFLAGS="-L$WANT_FASTCGI/lib"
472         fi
473     fi
474     AC_CHECK_HEADER([fcgio.h],,
475         AC_MSG_ERROR([unable to find FastCGI header files]))
476     FASTCGI_LIBS="-lfcgi -lfcgi++"
477 fi
478
479 AC_SUBST(FASTCGI_INCLUDE)
480 AC_SUBST(FASTCGI_LDFLAGS)
481 AC_SUBST(FASTCGI_LIBS)
482
483 # always output the Makefile, even if you don't use it
484 AC_CONFIG_FILES([fastcgi/Makefile])
485 AM_CONDITIONAL(BUILD_FASTCGI,test ! "$WANT_FASTCGI" = "no")
486
487 if test ! "$WANT_FASTCGI" = "no" ; then
488     WANT_SUBDIRS="$WANT_SUBDIRS fastcgi"
489 fi
490
491 #
492 # Build Memcached support?
493 #
494 AC_MSG_CHECKING(for Memcached support)
495 AC_ARG_WITH(memcached,
496     AC_HELP_STRING([--with-memcached=DIR], [Build Memcached support]),
497     [WANT_MEMCACHED=$withval],[WANT_MEMCACHED=no])
498 AC_MSG_RESULT($WANT_MEMCACHED)
499
500 if test "$WANT_MEMCACHED" != "no"; then
501     if test "$WANT_MEMCACHED" != "yes"; then
502         if test x_$WANT_MEMCACHED != x_/usr; then
503             MEMCACHED_INCLUDE="-I$WANT_MEMCACHED/include"
504             MEMCACHED_LDFLAGS="-L$WANT_MEMCACHED/lib"
505         fi
506     fi
507     AC_CHECK_HEADER([libmemcached/memcached.h],,
508         AC_MSG_ERROR([unable to find Memcached header files]))
509     MEMCACHED_LIBS="-lmemcached"
510 fi
511
512 AC_SUBST(MEMCACHED_INCLUDE)
513 AC_SUBST(MEMCACHED_LDFLAGS)
514 AC_SUBST(MEMCACHED_LIBS)
515
516 # always output the Makefile, even if you don't use it
517 AC_CONFIG_FILES([memcache-store/Makefile])
518 AM_CONDITIONAL(BUILD_MEMCACHED,test ! "$WANT_MEMCACHED" = "no")
519
520 if test ! "$WANT_MEMCACHED" = "no" ; then
521     WANT_SUBDIRS="$WANT_SUBDIRS memcache-store"
522 fi
523
524
525 #
526 # If no --enable-apache-xx specified 
527 # find a default and fake the specific parameters
528 #
529
530 # simple macro to peek at an enable or a with
531 AC_DEFUN([Peek],
532 if test "[${[$1]_][$2]+set}" = set; then
533   peekval="${[$1]_[$2]}"
534   $3
535 fi; dnl
536 )
537
538 AC_MSG_CHECKING(if default apache needed)
539 need_default=yes
540 Peek(enable,apache_13,need_default=no)
541 Peek(enable,apache_20,need_default=no)
542 Peek(enable,apache_22,need_default=no)
543 AC_MSG_RESULT($need_default)
544
545 if test "$need_default" = "yes"; then
546   # find an apxs, then the httpd
547   xs=
548   Peek(with,apxs,xs="$peekval")
549   Peek(with,apxs2,xs="$peekval")
550   Peek(with,apxs22,xs="$peekval")
551   if test "x$xs" = "x"; then
552      AC_PATH_PROGS(xs, apxs2 apxs,
553         AC_MSG_ERROR(No apxs, no apache found.  Try --with-apxs),
554         [/usr/local/apache2/bin:/usr/local/apache/bin:/usr/sbin:$PATH])
555   fi
556   # ask the daemon for the version and set parameters
557   AC_MSG_CHECKING(default apache version)
558   httpd="`$xs -q SBINDIR`/`$xs -q TARGET`"
559   if test "x$httpd" != "x" && test -f $httpd ; then
560      v=`$httpd -v|$SED -n -e 's/.*Apache\/\.*//p'`
561      case $v in
562        1.3*)   [enable_apache_13]=yes
563                [with_apxs]=$xs
564                AC_MSG_RESULT(1.3)
565                ;;
566        2.0*)   [enable_apache_20]=yes
567                [with_apxs2]=$xs
568                AC_MSG_RESULT(2.0)
569                ;;
570        2.2*)   [enable_apache_22]=yes
571                [with_apxs22]=$xs
572                AC_MSG_RESULT(2.2)
573                ;;
574        *)      AC_MSG_ERROR(unusable apache versions: $v. Try setting --with-apxs)
575      esac
576   else 
577      AC_MSG_RESULT(cannot determine version.  Try setting --with-apxs)
578   fi
579 fi
580
581 # Apache 1.3 (mod_shib_13)
582 #   --enable-apache-13
583 #   --with-apxs      (DSO build, the normal way, uses apxs to derive build flags)
584
585 AC_ARG_ENABLE(apache-13,
586         AC_HELP_STRING([--enable-apache-13], [enable the Apache 1.3 module]),
587         [ if test "x$enableval" = "x" ; then
588               WANT_APACHE_13=yes
589           else
590               WANT_APACHE_13="$enableval"
591           fi
592         ],[ WANT_APACHE_13=no ])
593 AC_MSG_CHECKING(whether to build Apache 1.3 module)
594 if test "$WANT_APACHE_13" != yes && test "$WANT_APACHE_13" != no ; then
595    WANT_APACHE_13=yes
596 fi
597 AC_MSG_RESULT($WANT_APACHE_13)
598
599 if test "$WANT_APACHE_13" = "yes" ; then
600     AC_ARG_WITH(apxs, 
601         AC_HELP_STRING([--with-apxs=FILE], [Specifies where to find the Apache 1.3 apxs script.]),
602         [
603         AC_MSG_CHECKING(for user-specified apxs name/location)
604         if test "$withval" != "no" ; then
605           if test "$withval" != "yes"; then
606             APXS=$withval
607             AC_MSG_RESULT("$withval")
608           fi
609         fi
610         ],
611         [
612         AC_PATH_PROG(APXS, apxs, no)
613         if test "$APXS" = "no" ; then
614           for i in /usr/sbin /usr/local/apache/bin ; do
615             if test "$APXS" = "no" && test -f "$i/apxs"; then
616               APXS="$i/apxs"
617             fi
618           done
619         fi
620         ])
621
622     AC_MSG_CHECKING([to see if apxs was located])
623     if test ! -f "$APXS" ; then
624         AC_MSG_RESULT(no)
625         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.])
626     fi
627     AC_MSG_RESULT($APXS)
628     AC_SUBST(APXS)
629
630     # extract settings we need from APXS -q
631     APXS_CC="`$APXS -q CC`"
632     APXS_CFLAGS="`$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
633     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
634 fi
635
636 AC_SUBST(APXS_CFLAGS)
637 AC_SUBST(APXS_INCLUDE)
638
639
640 # Apache 2.0 (mod_shib_20)
641 #   --enable-apache-20
642 #   --with-apxs2      (DSO build, the normal way, uses apxs to derive build flags)
643 #       --with-apr        (DSO build, APR development package installed separately)
644 #   --with-apu        (DSO build, APR-UTIL development package installed separately)
645
646 AC_ARG_ENABLE(apache-20,
647         AC_HELP_STRING([--enable-apache-20], [enable the Apache 2.0 module]),
648         [ if test "x$enableval" = "x" ; then
649               WANT_APACHE_20=yes
650           else
651               WANT_APACHE_20="$enableval"
652           fi
653         ],[ WANT_APACHE_20=no ])
654 AC_MSG_CHECKING(whether to build Apache 2.0 module)
655 if test "$WANT_APACHE_20" != yes && test "$WANT_APACHE_20" != no ; then
656    WANT_APACHE_20=yes
657 fi
658 AC_MSG_RESULT($WANT_APACHE_20)
659
660 if test "$WANT_APACHE_20" = "yes" ; then
661     AC_ARG_WITH(apxs2, 
662         AC_HELP_STRING([--with-apxs2=FILE], [Specifies where to find the Apache 2.0 apxs script.]),
663         [
664         AC_MSG_CHECKING(for user-specified Apache2 apxs name/location)
665         if test "$withval" != "no" ; then
666           if test "$withval" != "yes"; then
667             APXS2=$withval
668             AC_MSG_RESULT("$withval")
669           fi
670         fi
671         ],
672         [
673         AC_PATH_PROG(APXS2, apxs2, no)
674         if test "$APXS2" = "no" ; then
675             AC_PATH_PROG(APXS2, apxs, no)
676         fi
677         if test "$APXS2" = "no" ; then
678           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
679             if test "$APXS2" = "no" && test -f "$i/apxs2" ; then
680               APXS2="$i/apxs2"
681             fi
682           done
683           if test "$APXS2" = "no" ; then
684             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
685               if test "$APXS2" = "no" && test -f "$i/apxs" ; then
686                 APXS2="$i/apxs"
687               fi
688             done
689           fi
690         fi
691         ])
692
693     AC_MSG_CHECKING([to see if Apache2 apxs was located])
694     if test ! -f "$APXS2" ; then
695         AC_MSG_RESULT(no)
696         AC_MSG_ERROR([Unable to locate Apache2 apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs2 option.])
697     fi
698     AC_MSG_RESULT($APXS2)
699     AC_SUBST(APXS2)
700
701     # APR settings
702     AC_ARG_WITH(apr, 
703         AC_HELP_STRING([--with-apr=PATH], [where apr-config is installed]),
704         [
705         AC_MSG_CHECKING(for user-specified apr-config name/location)
706         if test "$withval" != "no" ; then
707             if test "$withval" != "yes"; then
708                 APR_CONFIG=$withval
709                 AC_MSG_RESULT("$withval")
710             fi
711         fi
712         ],
713         [
714         AC_PATH_PROG(APR_CONFIG, apr-config,,[`$APXS2 -q SBINDIR`]:[$PATH])
715         ])
716         if test -f "${APR_CONFIG}"; then
717         APR_CFLAGS="`${APR_CONFIG} --cflags` `${APR_CONFIG} --cppflags` `${APR_CONFIG} --includes`"
718     else
719         AC_MSG_ERROR([Unable to locate apr-config, may need --with-apr option.])
720     fi
721
722     # APU settings
723     AC_ARG_WITH(apu, 
724         AC_HELP_STRING([--with-apu=PATH], [where apu-config is installed]),
725         [
726         AC_MSG_CHECKING(for user-specified apu-config name/location)
727         if test "$withval" != "no" ; then
728             if test "$withval" != "yes"; then
729                 APR_CONFIG=$withval
730                 AC_MSG_RESULT("$withval")
731             fi
732         fi
733         ],
734         [
735         AC_PATH_PROG(APU_CONFIG, apu-config,,[`$APXS2 -q SBINDIR`]:[$PATH])
736         ])
737     if test -f "${APU_CONFIG}"; then
738         APU_CFLAGS="`${APU_CONFIG} --includes`"
739     else
740         AC_MSG_ERROR([Unable to locate apu-config, may need --with-apu option.])
741     fi
742
743     # extract settings we need from APXS2 -q
744     APXS2_CC="`$APXS2 -q CC`"
745     APXS2_CFLAGS="`$APXS2 -q CPPFLAGS` `$APXS2 -q CFLAGS` $APU_CFLAGS"
746     APXS2_INCLUDE="`$APXS2 -q INCLUDEDIR`"
747 fi
748
749 AC_SUBST(APXS2_CFLAGS)
750 AC_SUBST(APXS2_INCLUDE)
751
752
753 # Apache 2.2 (mod_shib_22)
754 #   --enable-apache-22
755 #   --with-apxs22     (DSO build, the normal way, uses apxs to derive build flags)
756 #       --with-apr1       (DSO build, APR development package installed separately)
757 #   --with-apu1       (DSO build, APR-UTIL development package installed separately)
758
759 AC_ARG_ENABLE(apache-22,
760         AC_HELP_STRING([--enable-apache-22], [enable the Apache 2.2 module]),
761         [ if test "x$enableval" = "x" ; then
762               WANT_APACHE_22=yes
763           else
764               WANT_APACHE_22="$enableval"
765           fi
766         ],[ WANT_APACHE_22=no ])
767 AC_MSG_CHECKING(whether to build Apache 2.2 module)
768 if test "$WANT_APACHE_22" != yes && test "$WANT_APACHE_22" != no ; then
769    WANT_APACHE_22=yes
770 fi
771 AC_MSG_RESULT($WANT_APACHE_22)
772
773 if test "$WANT_APACHE_22" = "yes" ; then
774     AC_ARG_WITH(apxs22, 
775         AC_HELP_STRING([--with-apxs22=FILE], [Specifies where to find the Apache 2.2 apxs script.]),
776         [
777         AC_MSG_CHECKING(for user-specified Apache2.2 apxs name/location)
778         if test "$withval" != "no" ; then
779           if test "$withval" != "yes"; then
780             APXS22=$withval
781             AC_MSG_RESULT("$withval")
782           fi
783         fi
784         ],
785         [
786         AC_PATH_PROG(APXS22, apxs2, no)
787         if test "$APXS22" = "no" ; then
788             AC_PATH_PROG(APXS22, apxs, no)
789         fi
790         if test "$APXS22" = "no" ; then
791           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
792             if test "$APXS22" = "no" && test -f "$i/apxs2" ; then
793               APXS22="$i/apxs2"
794             fi
795           done
796           if test "$APXS22" = "no" ; then
797             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
798               if test "$APXS22" = "no" && test -f "$i/apxs" ; then
799                 APXS22="$i/apxs"
800               fi
801             done
802           fi
803         fi
804         ])
805
806     AC_MSG_CHECKING([to see if Apache2.2 apxs was located])
807     if test ! -f "$APXS22" ; then
808         AC_MSG_RESULT(no)
809         AC_MSG_ERROR([Unable to locate Apache2.2 apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs22 option.])
810     fi
811     AC_MSG_RESULT($APXS22)
812     AC_SUBST(APXS22)
813
814     # APR1 settings
815     AC_ARG_WITH(apr1, 
816         AC_HELP_STRING([--with-apr1=PATH], [where apr-1-config is installed]),
817         [
818         AC_MSG_CHECKING(for user-specified apr-1-config name/location)
819         if test "$withval" != "no" ; then
820             if test "$withval" != "yes"; then
821                 APR1_CONFIG=$withval
822                 AC_MSG_RESULT("$withval")
823             fi
824         fi
825         ],
826         [
827         AC_PATH_PROG(APR1_CONFIG, apr-1-config,,[`$APXS22 -q SBINDIR`]:[$PATH])
828         ])
829         if test -f "${APR1_CONFIG}"; then
830         APR1_CFLAGS="`${APR1_CONFIG} --cflags` `${APR1_CONFIG} --cppflags` `${APR1_CONFIG} --includes`"
831     else
832         AC_MSG_ERROR([Unable to locate apr-1-config, may need --with-apr1 option.])
833     fi
834
835     # APU1 settings
836     AC_ARG_WITH(apu1, 
837         AC_HELP_STRING([--with-apu1=PATH], [where apu-1-config is installed]),
838         [
839         AC_MSG_CHECKING(for user-specified apu-1-config name/location)
840         if test "$withval" != "no" ; then
841             if test "$withval" != "yes"; then
842                 APR1_CONFIG=$withval
843                 AC_MSG_RESULT("$withval")
844             fi
845         fi
846         ],
847         [
848         AC_PATH_PROG(APU1_CONFIG, apu-1-config,,[`$APXS22 -q SBINDIR`]:[$PATH])
849         ])
850     if test -f "${APU1_CONFIG}"; then
851         APU1_CFLAGS="`${APU1_CONFIG} --includes`"
852     else
853         AC_MSG_ERROR([Unable to locate apu-1-config, may need --with-apu1 option.])
854     fi
855
856     # extract settings we need from APXS22 -q
857     APXS22_CC="`$APXS22 -q CC`"
858     APXS22_CFLAGS="`$APXS22 -q CPPFLAGS` `$APXS22 -q CFLAGS` $APR1_CFLAGS $APU1_CFLAGS"
859     APXS22_INCLUDE="`$APXS22 -q INCLUDEDIR`"
860 fi
861
862 AC_SUBST(APXS22_CFLAGS)
863 AC_SUBST(APXS22_INCLUDE)
864
865 # always output the Makefile, even if you don't use it
866 AC_CONFIG_FILES([apache/Makefile])
867 AM_CONDITIONAL(BUILD_AP13,test "$WANT_APACHE_13" = "yes")
868 AM_CONDITIONAL(BUILD_AP20,test "$WANT_APACHE_20" = "yes")
869 AM_CONDITIONAL(BUILD_AP22,test "$WANT_APACHE_22" = "yes")
870
871 # add the apache module to the list of wanted subdirs..
872 if test "$WANT_APACHE_13" = "yes" || test "$WANT_APACHE_20" = "yes" || test "$WANT_APACHE_22" = "yes" ; then
873     WANT_SUBDIRS="$WANT_SUBDIRS apache"
874 fi
875
876
877 #
878 # Implement the checks of the ODBC Storage Service
879 #
880 # 1) Assume the user wants ODBC; if it's not found then just continue without
881 # 2) If the user specifically requested odbc, look for it and ERROR if not found
882 # 3) If the user specifically requested no odbc, don't build it.
883 #
884
885 AC_CONFIG_FILES([odbc-store/Makefile])
886
887 # determine whether we should enable the odbc ccache
888 AC_ARG_ENABLE([odbc],
889         AC_HELP_STRING([--disable-odbc], [disable the ODBC Storage Service]),
890         [odbc_enabled=$enableval], [odbc_enabled=default])
891
892 if test "x$odbc_enabled" = "x" ; then
893    odbc_enabled=yes
894 fi
895
896 # Are we trying to build ODBC?
897 AC_MSG_CHECKING(whether to build the ODBC storage service)
898 if test "$odbc_enabled" = "yes" ; then
899    build_odbc=yes
900    AC_MSG_RESULT(yes)
901 elif test "$odbc_enabled" = "default" ; then
902    build_odbc=yes
903    AC_MSG_RESULT([yes, if it can be found])
904 else
905    build_odbc=no
906    AC_MSG_RESULT(no)
907 fi
908
909 # If we're trying to build ODBC, try to find the odbc_config program.
910 if test "$build_odbc" = "yes" ; then
911    odbc_dir=""
912    AC_ARG_WITH(odbc,
913         AC_HELP_STRING([--with-odbc=PATH], [directory where odbc is installed]),
914             [if test "$with_odbc" = no ; then
915                AC_MSG_ERROR([Try running --disable-odbc instead.])
916              elif test "$with_odbc" != yes ; then
917                odbc_dir="$with_odbc/bin"
918                if test "$with_odbc" != /usr ; then
919                  ODBC_CFLAGS="-I$with_odbc/include"
920                  ODBC_LIBS="-L$with_odbc/lib"
921                fi
922              fi ])
923
924    AC_PATH_PROG(ODBC_CONFIG, odbc_config, no, $odbc_dir $PATH )
925    if test "$ODBC_CONFIG" = no ; then
926       AC_MSG_WARN([Cannot find odbc_config, will try to guess settings.])
927       ODBC_LIBS="$ODBC_LIBS -lodbc"
928    else
929       ODBC_CFLAGS=`$ODBC_CONFIG --cflags`
930       ODBC_LIBS=`$ODBC_CONFIG --libs`
931    fi
932
933    save_CPPFLAGS="$CPPFLAGS"
934    CPPFLAGS="$CPPFLAGS $ODBC_CFLAGS"
935
936    AC_CHECK_HEADER([sql.h], [have_sql_h=yes], [have_sql_h=no])
937    if test "$have_sql_h" = no -a "$odbc_enabled" = "yes" ; then
938      AC_MSG_ERROR(unable to find ODBC header files)
939    fi
940
941    if test "$have_sql_h" = yes ; then
942       save_LIBS="$LIBS"
943       LIBS="$LIBS $ODBC_LIBS"
944       AC_MSG_CHECKING(if we can link againt ODBC)
945       AC_TRY_LINK(
946         [#include <sql.h>
947          #include <sqlext.h>
948          #include <stdio.h>],
949         [SQLSetEnvAttr(SQL_NULL_HANDLE, SQL_ATTR_CONNECTION_POOLING, (void*)SQL_CP_ONE_PER_HENV, 0)],
950         [have_odbc_libs=yes],
951         [have_odbc_libs=no])
952       LIBS="$save_LIBS"
953
954       if test "$have_odbc_libs" = no ; then
955          if test "$odbc_enabled" = "yes" ; then
956             AC_MSG_ERROR([unable to link with ODBC Library])
957          else
958             AC_MSG_RESULT(no, skipping ODBC)
959          fi
960       fi
961    fi
962
963    CPPFLAGS="$save_CPPFLAGS"
964 fi
965
966 # if have_odbc_libs=yes then go ahead with building ODBC
967 if test "$have_odbc_libs" = yes ; then
968    # this AC_MSG_RESULT is from above!
969    AC_MSG_RESULT(yes)
970    WANT_SUBDIRS="$WANT_SUBDIRS odbc-store"
971    AC_SUBST(ODBC_CFLAGS)
972    AC_SUBST(ODBC_LIBS)
973 fi
974
975
976 AC_SUBST(WANT_SUBDIRS)
977
978 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
979   echo "=================================================================="
980   echo "WARNING: You have chosen to compile Apache-1.3 modules with a different"
981   echo "         compiler than the one used to compile Apache."
982   echo ""
983   echo "    Current compiler:      $CC"
984   echo "   Apache's compiler:      $APXS_CC"
985   echo ""
986   echo "This could cause problems."
987   echo "=================================================================="
988 fi
989
990 if test -n "$APXS2_CC" && test "$APXS2_CC" != "$CC" ; then
991   echo "=================================================================="
992   echo "WARNING: You have chosen to compile Apache-2.0 modules with a different"
993   echo "         compiler than the one used to compile Apache."
994   echo ""
995   echo "    Current compiler:      $CC"
996   echo "   Apache's compiler:      $APXS2_CC"
997   echo ""
998   echo "This could cause problems."
999   echo "=================================================================="
1000 fi
1001
1002 if test -n "$APXS22_CC" && test "$APXS22_CC" != "$CC" ; then
1003   echo "=================================================================="
1004   echo "WARNING: You have chosen to compile Apache-2.2 modules with a different"
1005   echo "         compiler than the one used to compile Apache."
1006   echo ""
1007   echo "    Current compiler:      $CC"
1008   echo "   Apache's compiler:      $APXS22_CC"
1009   echo ""
1010   echo "This could cause problems."
1011   echo "=================================================================="
1012 fi
1013
1014 LIBTOOL="$LIBTOOL --silent"
1015
1016 AC_OUTPUT