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