apu-config appears to support a limited option set.
[shibboleth/cpp-sp.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([shibboleth], [2.3], [shibboleth-users@internet2.edu], [shibboleth])
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE([shibboleth],[2.3])
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_ERROR([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 # Establish location of xmltooling catalog.
263 XMLTOOLINGXMLDIR=""
264 if test "x$with_xmltooling" = "x" ; then
265    with_xmltooling="/usr"
266 fi
267 if test -f $with_xmltooling/share/xml/xmltooling/catalog.xml ; then
268     XMLTOOLINGXMLDIR="$with_xmltooling"
269 elif test -f $with_xerces/share/xml/xmltooling/catalog.xml ; then
270     XMLTOOLINGXMLDIR="$with_xerces"
271 elif test -f $with_log4shib/share/xml/xmltooling/catalog.xml ; then
272     XMLTOOLINGXMLDIR="$with_log4shib"
273 fi
274 if test "x$XMLTOOLINGXMLDIR" = "x" ; then
275     AC_MSG_ERROR([xmltooling XML catalog not found, may need to use --with-xmltooling option])
276 fi
277 XMLTOOLINGXMLDIR="$XMLTOOLINGXMLDIR/share/xml/xmltooling"
278 AC_SUBST(XMLTOOLINGXMLDIR)
279
280 # XML-Security settings
281 AC_ARG_WITH(xmlsec,
282             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
283             [with_xmlsec=/usr])
284
285 if test x_$with_xmlsec != x_/usr; then
286     LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
287     CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
288 fi        
289 XMLSEC_LIBS="-lxml-security-c $XMLSEC_LIBS"
290
291 # save and append master libs
292 save_LIBS="$LIBS"
293 LIBS="$XMLSEC_LIBS $LIBS"
294
295 AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
296 AC_MSG_CHECKING([XML-Security version])
297 AC_PREPROC_IFELSE(
298     [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
299     [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3)
300 int i = 0;
301 #else
302 #error need version 1.4.0 or later
303 #endif])],
304     [AC_MSG_RESULT(OK)],
305     [AC_MSG_FAILURE([XML-Security version 1.4.0 or greater is required.])])
306 AC_TRY_LINK(
307         [#include <xsec/utils/XSECPlatformUtils.hpp>],
308         [XSECPlatformUtils::Initialise()],,
309         [AC_MSG_ERROR([unable to link with XML-Security])])
310
311 # restore master libs
312 LIBS="$save_LIBS"
313
314 # OpenSAML settings
315 AC_ARG_WITH(saml,
316     AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
317     [if test x_$with_saml != x_/usr; then
318         LDFLAGS="-L${with_saml}/lib $LDFLAGS"
319         CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
320     fi])
321 XMLSEC_LIBS="-lsaml $XMLSEC_LIBS"
322
323 # save and append master libs
324 save_LIBS="$LIBS"
325 LIBS="$XMLSEC_LIBS $LIBS"
326
327 AC_CHECK_HEADER([saml/saml2/metadata/Metadata.h],,
328                 AC_MSG_ERROR([unable to find OpenSAML header files]))
329 AC_TRY_LINK(
330         [#include <saml/SAMLConfig.h>
331 #include <saml/version.h>],
332         [#if _OPENSAML_VERSION >= 20200
333 opensaml::SAMLConfig::getConfig();
334 #else
335 #error Need OpenSAML version 2.2 or higher
336 #endif],
337         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
338         [AC_MSG_ERROR([unable to link with OpenSAML, or version was too old])])
339
340 # restore master libs
341 LIBS="$save_LIBS"
342
343 # Establish location of opensaml catalogs.
344 OPENSAMLXMLDIR=""
345 if test "x$with_saml" = "x" ; then
346     with_saml="/usr"
347 fi
348 if test -f $with_saml/share/xml/opensaml/saml20-catalog.xml ; then
349     OPENSAMLXMLDIR="$with_saml"
350 elif test -f $with_xmltooling/share/xml/opensaml/saml20-catalog.xml ; then
351     OPENSAMLXMLDIR="$with_xmltooling"
352 elif test -f $with_xerces/share/xml/opensaml/saml20-catalog.xml ; then
353     OPENSAMLXMLDIR="$with_xerces"
354 elif test -f $with_log4shib/share/xml/opensaml/saml20-catalog.xml ; then
355     OPENSAMLXMLDIR="$with_log4shib"
356 fi
357 if test "x$OPENSAMLXMLDIR" = "x" ; then
358     AC_MSG_ERROR([opensaml XML catalogs not found, may need to use --with-saml option])
359 fi
360 OPENSAMLXMLDIR="$OPENSAMLXMLDIR/share/xml/opensaml"
361 AC_SUBST(OPENSAMLXMLDIR)
362
363 AC_SUBST(LITE_LIBS)
364 AC_SUBST(XMLSEC_LIBS)
365
366 AC_CONFIG_FILES([shibboleth.spec pkginfo Portfile])
367
368 # output the underlying makefiles
369 WANT_SUBDIRS="doc schemas configs shibsp shibd util"
370 AC_CONFIG_FILES([Makefile doc/Makefile schemas/Makefile \
371         configs/Makefile shibsp/Makefile shibd/Makefile \
372         util/Makefile selinux/Makefile])
373
374 ## ADFS?
375 AC_CONFIG_FILES([adfs/Makefile])
376 AC_ARG_ENABLE([adfs],
377         AC_HELP_STRING([--disable-adfs], [don't build the ADFS module]),
378         [adfs_enabled=$enableval], [adfs_enabled=yes])
379 if test "x$adfs_enabled" = "x" ; then
380    adfs_enabled=yes
381 fi
382 AC_MSG_CHECKING(whether to build the ADFS module)
383 if test "$adfs_enabled" = "no" ; then
384    AC_MSG_RESULT(no)
385 else
386    AC_MSG_RESULT(yes)
387    WANT_SUBDIRS="$WANT_SUBDIRS adfs"
388 fi
389
390
391 #
392 # Build NSAPI module?
393 #
394 AC_MSG_CHECKING(for NSAPI module option)
395 AC_ARG_WITH(nsapi,
396         AC_HELP_STRING([--with-nsapi=DIR], [Build NSAPI module for Netscape/iPlanet/SunONE]),
397         [WANT_NSAPI=$withval],[WANT_NSAPI=no])
398 AC_MSG_RESULT($WANT_NSAPI)
399
400 if test "$WANT_NSAPI" != "no"; then
401   if test ! -d $WANT_NSAPI/bin ; then
402     AC_MSG_ERROR(Please specify the path to the root of your Netscape/iPlanet/SunONE server using --with-nsapi=DIR)
403   fi
404   AC_MSG_CHECKING(for NSAPI include files)
405   if test -d $WANT_NSAPI/include ; then
406     NSAPI_INCLUDE=$WANT_NSAPI/include
407     AC_MSG_RESULT(Netscape-Enterprise 3.x style)
408     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h],,,[#define XP_UNIX])
409     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
410   fi
411   if test -d $WANT_NSAPI/plugins/include ; then
412     test -n "$NSAPI_INCLUDE" && NSAPI_INC_DIR="-I$NSAPI_INCLUDE"
413     NSAPI_INCLUDE="$WANT_NSAPI/plugins/include"
414     AC_MSG_RESULT(iPlanet 4.x / SunONE 6.x style)
415     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h],,,[#define XP_UNIX])
416     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
417   fi
418   if test "$NSAPI_INCLUDE" = ""; then
419     AC_MSG_ERROR(Please check you have nsapi.h in either $WANT_NSAPI/include or $WANT_NSAPI/plugins/include)
420   fi
421 fi
422
423 AC_SUBST(NSAPI_INCLUDE)
424
425 # always output the Makefile, even if you don't use it
426 AC_CONFIG_FILES([nsapi_shib/Makefile])
427 AM_CONDITIONAL(BUILD_NSAPI,test ! "$WANT_NSAPI" = "no")
428
429 # add the NSAPI module to the list of wanted subdirs..
430 if test ! "$WANT_NSAPI" = "no" ; then
431     WANT_SUBDIRS="$WANT_SUBDIRS nsapi_shib"
432 fi
433
434
435 #
436 # Build FastCGI support?
437 #
438 AC_MSG_CHECKING(for FastCGI support)
439 AC_ARG_WITH(fastcgi,
440     AC_HELP_STRING([--with-fastcgi=DIR], [Build FastCGI support]),
441     [WANT_FASTCGI=$withval],[WANT_FASTCGI=no])
442 AC_MSG_RESULT($WANT_FASTCGI)
443
444 if test "$WANT_FASTCGI" != "no"; then
445     if test "$WANT_FASTCGI" != "yes"; then
446         if test x_$WANT_FASTCGI != x_/usr; then
447             FASTCGI_INCLUDE="-I$WANT_FASTCGI/include"
448             FASTCGI_LDFLAGS="-L$WANT_FASTCGI/lib"
449         fi
450     fi
451     AC_CHECK_HEADER([fcgio.h],,
452         AC_MSG_ERROR([unable to find FastCGI header files]))
453     FASTCGI_LIBS="-lfcgi -lfcgi++"
454 fi
455
456 AC_SUBST(FASTCGI_INCLUDE)
457 AC_SUBST(FASTCGI_LDFLAGS)
458 AC_SUBST(FASTCGI_LIBS)
459
460 # always output the Makefile, even if you don't use it
461 AC_CONFIG_FILES([fastcgi/Makefile])
462 AM_CONDITIONAL(BUILD_FASTCGI,test ! "$WANT_FASTCGI" = "no")
463
464 if test ! "$WANT_FASTCGI" = "no" ; then
465     WANT_SUBDIRS="$WANT_SUBDIRS fastcgi"
466 fi
467
468 #
469 # Build Memcached support?
470 #
471 AC_MSG_CHECKING(for Memcached support)
472 AC_ARG_WITH(memcached,
473     AC_HELP_STRING([--with-memcached=DIR], [Build Memcached support]),
474     [WANT_MEMCACHED=$withval],[WANT_MEMCACHED=no])
475 AC_MSG_RESULT($WANT_MEMCACHED)
476
477 if test "$WANT_MEMCACHED" != "no"; then
478     if test "$WANT_MEMCACHED" != "yes"; then
479         if test x_$WANT_MEMCACHED != x_/usr; then
480             MEMCACHED_INCLUDE="-I$WANT_MEMCACHED/include"
481             MEMCACHED_LDFLAGS="-L$WANT_MEMCACHED/lib"
482         fi
483     fi
484     AC_CHECK_HEADER([libmemcached/memcached.h],,
485         AC_MSG_ERROR([unable to find Memcached header files]))
486     MEMCACHED_LIBS="-lmemcached"
487 fi
488
489 AC_SUBST(MEMCACHED_INCLUDE)
490 AC_SUBST(MEMCACHED_LDFLAGS)
491 AC_SUBST(MEMCACHED_LIBS)
492
493 # always output the Makefile, even if you don't use it
494 AC_CONFIG_FILES([memcache-store/Makefile])
495 AM_CONDITIONAL(BUILD_MEMCACHED,test ! "$WANT_MEMCACHED" = "no")
496
497 if test ! "$WANT_MEMCACHED" = "no" ; then
498     WANT_SUBDIRS="$WANT_SUBDIRS memcache-store"
499 fi
500
501
502 #
503 # If no --enable-apache-xx specified 
504 # find a default and fake the specific parameters
505 #
506
507 # simple macro to peek at an enable or a with
508 AC_DEFUN([Peek],
509 if test "[${[$1]_][$2]+set}" = set; then
510   peekval="${[$1]_[$2]}"
511   $3
512 fi; dnl
513 )
514
515 AC_MSG_CHECKING(if default apache needed)
516 need_default=yes
517 Peek(enable,apache_13,need_default=no)
518 Peek(enable,apache_20,need_default=no)
519 Peek(enable,apache_22,need_default=no)
520 AC_MSG_RESULT($need_default)
521
522 if test "$need_default" = "yes"; then
523   # find an apxs, then the httpd
524   xs=
525   Peek(with,apxs,xs="$peekval")
526   Peek(with,apxs2,xs="$peekval")
527   Peek(with,apxs22,xs="$peekval")
528   if test "x$xs" = "x"; then
529      AC_PATH_PROGS(xs, apxs2 apxs,
530         AC_MSG_ERROR(No apxs, no apache found.  Try --with-apxs),
531         [/usr/local/apache2/bin:/usr/local/apache/bin:/usr/sbin:$PATH])
532   fi
533   # ask the daemon for the version and set parameters
534   AC_MSG_CHECKING(default apache version)
535   httpd="`$xs -q SBINDIR`/`$xs -q TARGET`"
536   if test "x$httpd" != "x" && test -f $httpd ; then
537      v=`$httpd -v|$SED -n -e 's/.*Apache\/\.*//p'`
538      case $v in
539        1.3*)   [enable_apache_13]=yes
540                [with_apxs]=$xs
541                AC_MSG_RESULT(1.3)
542                ;;
543        2.0*)   [enable_apache_20]=yes
544                [with_apxs2]=$xs
545                AC_MSG_RESULT(2.0)
546                ;;
547        2.2*)   [enable_apache_22]=yes
548                [with_apxs22]=$xs
549                AC_MSG_RESULT(2.2)
550                ;;
551        *)      AC_MSG_ERROR(unusable apache versions: $v. Try setting --with-apxs)
552      esac
553   else 
554      AC_MSG_RESULT(cannot determine version.  Try setting --with-apxs)
555   fi
556 fi
557
558 # Apache 1.3 (mod_shib_13)
559 #   --enable-apache-13
560 #   --with-apxs      (DSO build, the normal way, uses apxs to derive build flags)
561
562 AC_ARG_ENABLE(apache-13,
563         AC_HELP_STRING([--enable-apache-13], [enable the Apache 1.3 module]),
564         [ if test "x$enableval" = "x" ; then
565               WANT_APACHE_13=yes
566           else
567               WANT_APACHE_13="$enableval"
568           fi
569         ],[ WANT_APACHE_13=no ])
570 AC_MSG_CHECKING(whether to build Apache 1.3 module)
571 if test "$WANT_APACHE_13" != yes && test "$WANT_APACHE_13" != no ; then
572    WANT_APACHE_13=yes
573 fi
574 AC_MSG_RESULT($WANT_APACHE_13)
575
576 if test "$WANT_APACHE_13" = "yes" ; then
577     AC_ARG_WITH(apxs, 
578         AC_HELP_STRING([--with-apxs=FILE], [Specifies where to find the Apache 1.3 apxs script.]),
579         [
580         AC_MSG_CHECKING(for user-specified apxs name/location)
581         if test "$withval" != "no" ; then
582           if test "$withval" != "yes"; then
583             APXS=$withval
584             AC_MSG_RESULT("$withval")
585           fi
586         fi
587         ],
588         [
589         AC_PATH_PROG(APXS, apxs, no)
590         if test "$APXS" = "no" ; then
591           for i in /usr/sbin /usr/local/apache/bin ; do
592             if test "$APXS" = "no" && test -f "$i/apxs"; then
593               APXS="$i/apxs"
594             fi
595           done
596         fi
597         ])
598
599     AC_MSG_CHECKING([to see if apxs was located])
600     if test ! -f "$APXS" ; then
601         AC_MSG_RESULT(no)
602         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.])
603     fi
604     AC_MSG_RESULT($APXS)
605     AC_SUBST(APXS)
606
607     # extract settings we need from APXS -q
608     APXS_CC="`$APXS -q CC`"
609     APXS_CFLAGS="`$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
610     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
611 fi
612
613 AC_SUBST(APXS_CFLAGS)
614 AC_SUBST(APXS_INCLUDE)
615
616
617 # Apache 2.0 (mod_shib_20)
618 #   --enable-apache-20
619 #   --with-apxs2      (DSO build, the normal way, uses apxs to derive build flags)
620 #       --with-apr        (DSO build, APR development package installed separately)
621 #   --with-apu        (DSO build, APR-UTIL development package installed separately)
622
623 AC_ARG_ENABLE(apache-20,
624         AC_HELP_STRING([--enable-apache-20], [enable the Apache 2.0 module]),
625         [ if test "x$enableval" = "x" ; then
626               WANT_APACHE_20=yes
627           else
628               WANT_APACHE_20="$enableval"
629           fi
630         ],[ WANT_APACHE_20=no ])
631 AC_MSG_CHECKING(whether to build Apache 2.0 module)
632 if test "$WANT_APACHE_20" != yes && test "$WANT_APACHE_20" != no ; then
633    WANT_APACHE_20=yes
634 fi
635 AC_MSG_RESULT($WANT_APACHE_20)
636
637 if test "$WANT_APACHE_20" = "yes" ; then
638     AC_ARG_WITH(apxs2, 
639         AC_HELP_STRING([--with-apxs2=FILE], [Specifies where to find the Apache 2.0 apxs script.]),
640         [
641         AC_MSG_CHECKING(for user-specified Apache2 apxs name/location)
642         if test "$withval" != "no" ; then
643           if test "$withval" != "yes"; then
644             APXS2=$withval
645             AC_MSG_RESULT("$withval")
646           fi
647         fi
648         ],
649         [
650         AC_PATH_PROG(APXS2, apxs2, no)
651         if test "$APXS2" = "no" ; then
652             AC_PATH_PROG(APXS2, apxs, no)
653         fi
654         if test "$APXS2" = "no" ; then
655           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
656             if test "$APXS2" = "no" && test -f "$i/apxs2" ; then
657               APXS2="$i/apxs2"
658             fi
659           done
660           if test "$APXS2" = "no" ; then
661             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
662               if test "$APXS2" = "no" && test -f "$i/apxs" ; then
663                 APXS2="$i/apxs"
664               fi
665             done
666           fi
667         fi
668         ])
669
670     AC_MSG_CHECKING([to see if Apache2 apxs was located])
671     if test ! -f "$APXS2" ; then
672         AC_MSG_RESULT(no)
673         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.])
674     fi
675     AC_MSG_RESULT($APXS2)
676     AC_SUBST(APXS2)
677
678     # APR settings
679     AC_ARG_WITH(apr, 
680         AC_HELP_STRING([--with-apr=PATH], [where apr-config is installed]),
681         [
682         AC_MSG_CHECKING(for user-specified apr-config name/location)
683         if test "$withval" != "no" ; then
684             if test "$withval" != "yes"; then
685                 APR_CONFIG=$withval
686                 AC_MSG_RESULT("$withval")
687             fi
688         fi
689         ],
690         [
691         AC_PATH_PROG(APR_CONFIG, apr-config,,[`$APXS2 -q SBINDIR`]:[$PATH])
692         ])
693         if test -f "${APR_CONFIG}"; then
694         APR_CFLAGS="`${APR_CONFIG} --cflags` `${APR_CONFIG} --cppflags` `${APR_CONFIG} --includes`"
695     else
696         AC_MSG_ERROR([Unable to locate apr-config, may need --with-apr option.])
697     fi
698
699     # APU settings
700     AC_ARG_WITH(apu, 
701         AC_HELP_STRING([--with-apu=PATH], [where apu-config is installed]),
702         [
703         AC_MSG_CHECKING(for user-specified apu-config name/location)
704         if test "$withval" != "no" ; then
705             if test "$withval" != "yes"; then
706                 APR_CONFIG=$withval
707                 AC_MSG_RESULT("$withval")
708             fi
709         fi
710         ],
711         [
712         AC_PATH_PROG(APU_CONFIG, apu-config,,[`$APXS2 -q SBINDIR`]:[$PATH])
713         ])
714     if test -f "${APU_CONFIG}"; then
715         APU_CFLAGS="`${APU_CONFIG} --includes`"
716     else
717         AC_MSG_ERROR([Unable to locate apu-config, may need --with-apu option.])
718     fi
719
720     # extract settings we need from APXS2 -q
721     APXS2_CC="`$APXS2 -q CC`"
722     APXS2_CFLAGS="`$APXS2 -q CPPFLAGS` `$APXS2 -q CFLAGS` $APU_CFLAGS"
723     APXS2_INCLUDE="`$APXS2 -q INCLUDEDIR`"
724 fi
725
726 AC_SUBST(APXS2_CFLAGS)
727 AC_SUBST(APXS2_INCLUDE)
728
729
730 # Apache 2.2 (mod_shib_22)
731 #   --enable-apache-22
732 #   --with-apxs22     (DSO build, the normal way, uses apxs to derive build flags)
733 #       --with-apr1       (DSO build, APR development package installed separately)
734 #   --with-apu1       (DSO build, APR-UTIL development package installed separately)
735
736 AC_ARG_ENABLE(apache-22,
737         AC_HELP_STRING([--enable-apache-22], [enable the Apache 2.2 module]),
738         [ if test "x$enableval" = "x" ; then
739               WANT_APACHE_22=yes
740           else
741               WANT_APACHE_22="$enableval"
742           fi
743         ],[ WANT_APACHE_22=no ])
744 AC_MSG_CHECKING(whether to build Apache 2.2 module)
745 if test "$WANT_APACHE_22" != yes && test "$WANT_APACHE_22" != no ; then
746    WANT_APACHE_22=yes
747 fi
748 AC_MSG_RESULT($WANT_APACHE_22)
749
750 if test "$WANT_APACHE_22" = "yes" ; then
751     AC_ARG_WITH(apxs22, 
752         AC_HELP_STRING([--with-apxs22=FILE], [Specifies where to find the Apache 2.2 apxs script.]),
753         [
754         AC_MSG_CHECKING(for user-specified Apache2.2 apxs name/location)
755         if test "$withval" != "no" ; then
756           if test "$withval" != "yes"; then
757             APXS22=$withval
758             AC_MSG_RESULT("$withval")
759           fi
760         fi
761         ],
762         [
763         AC_PATH_PROG(APXS22, apxs2, no)
764         if test "$APXS22" = "no" ; then
765             AC_PATH_PROG(APXS22, apxs, no)
766         fi
767         if test "$APXS22" = "no" ; then
768           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
769             if test "$APXS22" = "no" && test -f "$i/apxs2" ; then
770               APXS22="$i/apxs2"
771             fi
772           done
773           if test "$APXS22" = "no" ; then
774             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
775               if test "$APXS22" = "no" && test -f "$i/apxs" ; then
776                 APXS22="$i/apxs"
777               fi
778             done
779           fi
780         fi
781         ])
782
783     AC_MSG_CHECKING([to see if Apache2.2 apxs was located])
784     if test ! -f "$APXS22" ; then
785         AC_MSG_RESULT(no)
786         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.])
787     fi
788     AC_MSG_RESULT($APXS22)
789     AC_SUBST(APXS22)
790
791     # APR1 settings
792     AC_ARG_WITH(apr1, 
793         AC_HELP_STRING([--with-apr1=PATH], [where apr-1-config is installed]),
794         [
795         AC_MSG_CHECKING(for user-specified apr-1-config name/location)
796         if test "$withval" != "no" ; then
797             if test "$withval" != "yes"; then
798                 APR1_CONFIG=$withval
799                 AC_MSG_RESULT("$withval")
800             fi
801         fi
802         ],
803         [
804         AC_PATH_PROG(APR1_CONFIG, apr-1-config,,[`$APXS22 -q SBINDIR`]:[$PATH])
805         ])
806         if test -f "${APR1_CONFIG}"; then
807         APR1_CFLAGS="`${APR1_CONFIG} --cflags` `${APR1_CONFIG} --cppflags` `${APR1_CONFIG} --includes`"
808     else
809         AC_MSG_ERROR([Unable to locate apr-1-config, may need --with-apr1 option.])
810     fi
811
812     # APU1 settings
813     AC_ARG_WITH(apu1, 
814         AC_HELP_STRING([--with-apu1=PATH], [where apu-1-config is installed]),
815         [
816         AC_MSG_CHECKING(for user-specified apu-1-config name/location)
817         if test "$withval" != "no" ; then
818             if test "$withval" != "yes"; then
819                 APR1_CONFIG=$withval
820                 AC_MSG_RESULT("$withval")
821             fi
822         fi
823         ],
824         [
825         AC_PATH_PROG(APU1_CONFIG, apu-1-config,,[`$APXS22 -q SBINDIR`]:[$PATH])
826         ])
827     if test -f "${APU1_CONFIG}"; then
828         APU1_CFLAGS="`${APU1_CONFIG} --includes`"
829     else
830         AC_MSG_ERROR([Unable to locate apu-1-config, may need --with-apu1 option.])
831     fi
832
833     # extract settings we need from APXS22 -q
834     APXS22_CC="`$APXS22 -q CC`"
835     APXS22_CFLAGS="`$APXS22 -q CPPFLAGS` `$APXS22 -q CFLAGS` $APR1_CFLAGS $APU1_CFLAGS"
836     APXS22_INCLUDE="`$APXS22 -q INCLUDEDIR`"
837 fi
838
839 AC_SUBST(APXS22_CFLAGS)
840 AC_SUBST(APXS22_INCLUDE)
841
842 # always output the Makefile, even if you don't use it
843 AC_CONFIG_FILES([apache/Makefile])
844 AM_CONDITIONAL(BUILD_AP13,test "$WANT_APACHE_13" = "yes")
845 AM_CONDITIONAL(BUILD_AP20,test "$WANT_APACHE_20" = "yes")
846 AM_CONDITIONAL(BUILD_AP22,test "$WANT_APACHE_22" = "yes")
847
848 # add the apache module to the list of wanted subdirs..
849 if test "$WANT_APACHE_13" = "yes" || test "$WANT_APACHE_20" = "yes" || test "$WANT_APACHE_22" = "yes" ; then
850     WANT_SUBDIRS="$WANT_SUBDIRS apache"
851 fi
852
853
854 #
855 # Implement the checks of the ODBC Storage Service
856 #
857 # 1) Assume the user wants ODBC; if it's not found then just continue without
858 # 2) If the user specifically requested odbc, look for it and ERROR if not found
859 # 3) If the user specifically requested no odbc, don't build it.
860 #
861
862 AC_CONFIG_FILES([odbc-store/Makefile])
863
864 # determine whether we should enable the odbc ccache
865 AC_ARG_ENABLE([odbc],
866         AC_HELP_STRING([--disable-odbc], [disable the ODBC Storage Service]),
867         [odbc_enabled=$enableval], [odbc_enabled=default])
868
869 if test "x$odbc_enabled" = "x" ; then
870    odbc_enabled=yes
871 fi
872
873 # Are we trying to build ODBC?
874 AC_MSG_CHECKING(whether to build the ODBC storage service)
875 if test "$odbc_enabled" = "yes" ; then
876    build_odbc=yes
877    AC_MSG_RESULT(yes)
878 elif test "$odbc_enabled" = "default" ; then
879    build_odbc=yes
880    AC_MSG_RESULT([yes, if it can be found])
881 else
882    build_odbc=no
883    AC_MSG_RESULT(no)
884 fi
885
886 # If we're trying to build ODBC, try to find the odbc_config program.
887 if test "$build_odbc" = "yes" ; then
888    odbc_dir=""
889    AC_ARG_WITH(odbc,
890         AC_HELP_STRING([--with-odbc=PATH], [directory where odbc is installed]),
891             [if test "$with_odbc" = no ; then
892                AC_MSG_ERROR([Try running --disable-odbc instead.])
893              elif test "$with_odbc" != yes ; then
894                odbc_dir="$with_odbc/bin"
895                if test "$with_odbc" != /usr ; then
896                  ODBC_CFLAGS="-I$with_odbc/include"
897                  ODBC_LIBS="-L$with_odbc/lib"
898                fi
899              fi ])
900
901    AC_PATH_PROG(ODBC_CONFIG, odbc_config, no, $odbc_dir $PATH )
902    if test "$ODBC_CONFIG" = no ; then
903       AC_MSG_WARN([Cannot find odbc_config, will try to guess settings.])
904       ODBC_LIBS="$ODBC_LIBS -lodbc"
905    else
906       ODBC_CFLAGS=`$ODBC_CONFIG --cflags`
907       ODBC_LIBS=`$ODBC_CONFIG --libs`
908    fi
909
910    save_CPPFLAGS="$CPPFLAGS"
911    CPPFLAGS="$CPPFLAGS $ODBC_CFLAGS"
912
913    AC_CHECK_HEADER([sql.h], [have_sql_h=yes], [have_sql_h=no])
914    if test "$have_sql_h" = no -a "$odbc_enabled" = "yes" ; then
915      AC_MSG_ERROR(unable to find ODBC header files)
916    fi
917
918    if test "$have_sql_h" = yes ; then
919       save_LIBS="$LIBS"
920       LIBS="$LIBS $ODBC_LIBS"
921       AC_MSG_CHECKING(if we can link againt ODBC)
922       AC_TRY_LINK(
923         [#include <sql.h>
924          #include <sqlext.h>
925          #include <stdio.h>],
926         [SQLSetEnvAttr(SQL_NULL_HANDLE, SQL_ATTR_CONNECTION_POOLING, (void*)SQL_CP_ONE_PER_HENV, 0)],
927         [have_odbc_libs=yes],
928         [have_odbc_libs=no])
929       LIBS="$save_LIBS"
930
931       if test "$have_odbc_libs" = no ; then
932          if test "$odbc_enabled" = "yes" ; then
933             AC_MSG_ERROR([unable to link with ODBC Library])
934          else
935             AC_MSG_RESULT(no, skipping ODBC)
936          fi
937       fi
938    fi
939
940    CPPFLAGS="$save_CPPFLAGS"
941 fi
942
943 # if have_odbc_libs=yes then go ahead with building ODBC
944 if test "$have_odbc_libs" = yes ; then
945    # this AC_MSG_RESULT is from above!
946    AC_MSG_RESULT(yes)
947    WANT_SUBDIRS="$WANT_SUBDIRS odbc-store"
948    AC_SUBST(ODBC_CFLAGS)
949    AC_SUBST(ODBC_LIBS)
950 fi
951
952
953 AC_SUBST(WANT_SUBDIRS)
954
955 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
956   echo "=================================================================="
957   echo "WARNING: You have chosen to compile Apache-1.3 modules with a different"
958   echo "         compiler than the one used to compile Apache."
959   echo ""
960   echo "    Current compiler:      $CC"
961   echo "   Apache's compiler:      $APXS_CC"
962   echo ""
963   echo "This could cause problems."
964   echo "=================================================================="
965 fi
966
967 if test -n "$APXS2_CC" && test "$APXS2_CC" != "$CC" ; then
968   echo "=================================================================="
969   echo "WARNING: You have chosen to compile Apache-2.0 modules with a different"
970   echo "         compiler than the one used to compile Apache."
971   echo ""
972   echo "    Current compiler:      $CC"
973   echo "   Apache's compiler:      $APXS2_CC"
974   echo ""
975   echo "This could cause problems."
976   echo "=================================================================="
977 fi
978
979 if test -n "$APXS22_CC" && test "$APXS22_CC" != "$CC" ; then
980   echo "=================================================================="
981   echo "WARNING: You have chosen to compile Apache-2.2 modules with a different"
982   echo "         compiler than the one used to compile Apache."
983   echo ""
984   echo "    Current compiler:      $CC"
985   echo "   Apache's compiler:      $APXS22_CC"
986   echo ""
987   echo "This could cause problems."
988   echo "=================================================================="
989 fi
990
991 LIBTOOL="$LIBTOOL --silent"
992
993 AC_OUTPUT