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