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