Check for xmlsec 1.4.
[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(acx_pthread.m4)
7
8 AC_ARG_ENABLE(debug,
9     AC_HELP_STRING(--enable-debug, [Have GCC compile with symbols (Default = no)
10 ]),
11     enable_debug=$enableval, enable_debug=no)
12
13 if test "$enable_debug" = "yes" ; then
14     GCC_CFLAGS="$CFLAGS -g -D_DEBUG"
15     GCC_CXXFLAGS="$CXXFLAGS -g -D_DEBUG"
16 else
17     GCC_CFLAGS="$CFLAGS -O2 -DNDEBUG"
18     GCC_CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG"
19 fi
20
21 AC_PROG_CC([gcc gcc3 cc])
22 AC_PROG_CXX([g++ g++3 c++ CC])
23
24 if test "$GCC" = "yes" ; then
25 #    AC_HAVE_GCC_VERSION(4,0,0,0,
26 #        [
27 #        AC_DEFINE(GCC_HASCLASSVISIBILITY,1,
28 #            [Define to enable class visibility control in gcc.])
29 #        GCC_CFLAGS="$GCC_CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
30 #        GCC_CXXFLAGS="$GCC_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
31 #        ])
32     CFLAGS="-Wall $GCC_CFLAGS"
33     CXXFLAGS="-Wall $GCC_CXXFLAGS"
34 else
35 # Fix for Sun Workshop compiler in debug mode, may be Sun case #6360993
36         case "${host_cpu}-${host_os}" in
37                 *solaris*)
38                         if test "$CXX" = "CC" ; then
39                                 CXXFLAGS="$CXXFLAGS -Qoption ccfe -stabs=no%dfltlit+no%dflthlp"
40                         fi
41                 ;;
42         esac
43 fi
44
45 AC_DISABLE_STATIC
46 AC_PROG_LIBTOOL
47
48 AC_LANG(C)
49
50 # Checks for typedefs, structures, and compiler characteristics.
51 AC_C_CONST
52 AC_TYPE_SIZE_T
53 AC_STRUCT_TM
54
55 # Checks for library functions.
56 AC_FUNC_STRFTIME
57 AC_FUNC_STRERROR_R
58 AC_CHECK_FUNCS([strchr strdup strstr timegm gmtime_r ctime_r strtok_r strcasecmp])
59
60 # checks for pthreads
61 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
62 if test $enable_threads != "pthread"; then
63     AC_MSG_ERROR([unable to find pthreads, currently this is required])
64 else
65     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
66     LIBS="$PTHREAD_LIBS $LIBS"
67     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
68     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
69 fi
70
71 AC_LANG(C++)
72
73 # C++ requirements
74 AC_CXX_REQUIRE_STL
75 AC_CXX_NAMESPACES
76
77 # log4shib settings (favor this version over the log4cpp code)
78 AC_PATH_PROG(LOG4SHIB_CONFIG,log4shib-config)
79 AC_ARG_WITH(log4shib,
80     AC_HELP_STRING([--with-log4shib=PATH], [where log4shib-config is installed]),
81     [
82     LOG4SHIB_CONFIG="${with_log4shib}"
83     if ! test -f "${LOG4SHIB_CONFIG}" ; then
84         LOG4SHIB_CONFIG="${with_log4shib}/bin/log4shib-config"
85     fi
86     ])
87 if test -f "${LOG4SHIB_CONFIG}"; then
88     LDFLAGS="`${LOG4SHIB_CONFIG} --libs` $LDFLAGS"
89     CPPFLAGS="`${LOG4SHIB_CONFIG} --cflags` $CPPFLAGS"
90         AC_CHECK_HEADER([log4shib/Category.hh],,AC_MSG_ERROR([unable to find log4shib header files]))
91         AC_TRY_LINK(
92                 [#include <log4shib/Category.hh>],
93                 [log4shib::Category::getInstance("foo")],
94                 [AC_DEFINE(SHIBSP_LOG4SHIB,1,[Define if log4shib library is used.])],
95                 [AC_MSG_ERROR([unable to link with log4shib])])
96 else
97     AC_MSG_WARN([log4shib-config not found, may need to use --with-log4shib option])
98     AC_MSG_WARN([will look for original log4cpp library])
99     
100         # log4cpp settings
101         AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
102         AC_ARG_WITH(log4cpp,
103             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
104             [
105             LOG4CPP_CONFIG="${with_log4cpp}"
106             if ! test -f "${LOG4CPP_CONFIG}" ; then
107                 LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
108             fi
109             ])
110         if test -f "${LOG4CPP_CONFIG}"; then
111                 AC_MSG_WARN([will try to use log4cpp, note that most non-Internet2 supplied versions are not thread-safe])
112             LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
113             CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
114                 AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
115                 AC_CHECK_HEADER([log4cpp/PropertyConfigurator.hh],,AC_MSG_ERROR([you need at least log4cpp 0.3.x]))
116                 AC_TRY_LINK(
117                         [#include <log4cpp/Category.hh>],
118                         [log4cpp::Category::getInstance("foo")],
119                         [AC_DEFINE(SHIBSP_LOG4CPP,1,[Define if log4cpp library is used.])],
120                         [AC_MSG_ERROR([unable to link with log4cpp])])
121         else
122             AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
123         fi
124 fi
125
126 # Xerces settings
127 AC_ARG_WITH(xerces, 
128             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
129             [if test x_$with_xerces != x_/usr; then
130                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
131                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
132             fi])
133 LIBS="-lxerces-c $LIBS"
134 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
135                 AC_MSG_ERROR([unable to find xerces header files]))
136 AC_MSG_CHECKING([Xerces version])
137 AC_PREPROC_IFELSE(
138     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
139 [#if  _XERCES_VERSION != 20600
140 int i = 0;
141 #else
142 #error cannot use version 2.6.0
143 #endif])],
144     [AC_MSG_RESULT(OK)],
145     [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use a newer version])])
146 AC_TRY_LINK(
147         [#include <xercesc/util/PlatformUtils.hpp>],
148         [xercesc::XMLPlatformUtils::Initialize()],
149         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
150         [AC_MSG_ERROR([unable to link with Xerces])])
151
152
153 #XML-Tooling settings
154 AC_ARG_WITH(xmltooling,
155             AC_HELP_STRING([--with-xmltooling=PATH], [where xmltooling-c is installed]),
156             [if test x_$with_xmltooling != x_/usr; then
157                 LDFLAGS="-L${with_xmltooling}/lib $LDFLAGS"
158                 CPPFLAGS="-I${with_xmltooling}/include $CPPFLAGS"
159             fi])
160 LITE_LIBS="-lxmltooling-lite"
161 XMLSEC_LIBS="-lxmltooling"
162 AC_CHECK_HEADER([xmltooling/base.h],,
163                 AC_MSG_ERROR([unable to find xmltooling header files]))
164
165
166 # XML-Security settings
167 AC_ARG_WITH(xmlsec,
168             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
169             [with_xmlsec=/usr])
170
171 if test x_$with_xmlsec != x_/usr; then
172     LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
173     CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
174 fi        
175 XMLSEC_LIBS="-lxml-security-c $XMLSEC_LIBS"
176
177 # save and append master libs
178 save_LIBS="$LIBS"
179 LIBS="$XMLSEC_LIBS $LIBS"
180
181 AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
182 AC_MSG_CHECKING([XML-Security version])
183 AC_PREPROC_IFELSE(
184     [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
185     [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3)
186 int i = 0;
187 #else
188 #error need version 1.4.0 or later
189 #endif])],
190     [AC_MSG_RESULT(OK)],
191     [AC_MSG_FAILURE([XML-Security version 1.4.0 or greater is required.])])
192 AC_TRY_LINK(
193         [#include <xsec/utils/XSECPlatformUtils.hpp>],
194         [XSECPlatformUtils::Initialise()],,
195         [AC_MSG_ERROR([unable to link with XML-Security])])
196
197 # restore master libs
198 LIBS="$save_LIBS"
199
200 # OpenSAML settings
201 AC_ARG_WITH(saml,
202     AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
203     [if test x_$with_saml != x_/usr; then
204         LDFLAGS="-L${with_saml}/lib $LDFLAGS"
205         CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
206     fi])
207 XMLSEC_LIBS="-lsaml $XMLSEC_LIBS"
208
209 # save and append master libs
210 save_LIBS="$LIBS"
211 LIBS="$XMLSEC_LIBS $LIBS"
212
213 AC_CHECK_HEADER([saml/saml2/metadata/Metadata.h],,
214                 AC_MSG_ERROR([unable to find OpenSAML header files]))
215 AC_TRY_LINK(
216         [#include <saml/SAMLConfig.h>
217 #include <saml/version.h>],
218         [#if _OPENSAML_VERSION >= 20000
219 opensaml::SAMLConfig::getConfig();
220 #else
221 #error Need OpenSAML version 2.0 or higher
222 #endif],
223         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
224         [AC_MSG_ERROR([unable to link with OpenSAML, or version was too old])])
225
226 # restore master libs
227 LIBS="$save_LIBS"
228
229 AC_SUBST(LITE_LIBS)
230 AC_SUBST(XMLSEC_LIBS)
231
232 # output the underlying makefiles
233 WANT_SUBDIRS="doc schemas configs shibsp shibd util"
234 AC_CONFIG_FILES([Makefile doc/Makefile schemas/Makefile \
235         configs/Makefile shibsp/Makefile shibd/Makefile \
236         util/Makefile selinux/Makefile])
237
238 ## ADFS?
239 AC_CONFIG_FILES([adfs/Makefile])
240 AC_ARG_ENABLE([adfs],
241         AC_HELP_STRING([--disable-adfs], [don't build the ADFS module]),
242         [adfs_enabled=$enableval], [adfs_enabled=yes])
243 if test "x$adfs_enabled" = "x" ; then
244    adfs_enabled=yes
245 fi
246 AC_MSG_CHECKING(whether to build the ADFS module)
247 if test "$adfs_enabled" = "no" ; then
248    AC_MSG_RESULT(no)
249 else
250    AC_MSG_RESULT(yes)
251    WANT_SUBDIRS="$WANT_SUBDIRS adfs"
252 fi
253
254
255 #
256 # Build NSAPI module?
257 #
258 AC_MSG_CHECKING(for NSAPI module option)
259 AC_ARG_WITH(nsapi,
260         AC_HELP_STRING([--with-nsapi=DIR], [Build NSAPI module for Netscape/iPlanet/SunONE]),
261         [WANT_NSAPI=$withval],[WANT_NSAPI=no])
262 AC_MSG_RESULT($WANT_NSAPI)
263
264 if test "$WANT_NSAPI" != "no"; then
265   if test ! -d $WANT_NSAPI/bin ; then
266     AC_MSG_ERROR(Please specify the path to the root of your Netscape/iPlanet/SunONE server using --with-nsapi=DIR)
267   fi
268   AC_MSG_CHECKING(for NSAPI include files)
269   if test -d $WANT_NSAPI/include ; then
270     NSAPI_INCLUDE=$WANT_NSAPI/include
271     AC_MSG_RESULT(Netscape-Enterprise 3.x style)
272     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
273     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
274   fi
275   if test -d $WANT_NSAPI/plugins/include ; then
276     test -n "$NSAPI_INCLUDE" && NSAPI_INC_DIR="-I$NSAPI_INCLUDE"
277     NSAPI_INCLUDE="$WANT_NSAPI/plugins/include"
278     AC_MSG_RESULT(iPlanet 4.x / SunONE 6.x style)
279     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
280     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
281   fi
282   if test "$NSAPI_INCLUDE" = ""; then
283     AC_MSG_ERROR(Please check you have nsapi.h in either $WANT_NSAPI/include or $WANT_NSAPI/plugins/include)
284   fi
285 fi
286
287 AC_SUBST(NSAPI_INCLUDE)
288
289 # always output the Makefile, even if you don't use it
290 AC_CONFIG_FILES([nsapi_shib/Makefile])
291 AM_CONDITIONAL(BUILD_NSAPI,test ! "$WANT_NSAPI" = "no")
292
293 # add the NSAPI module to the list of wanted subdirs..
294 if test ! "$WANT_NSAPI" = "no" ; then
295     WANT_SUBDIRS="$WANT_SUBDIRS nsapi_shib"
296 fi
297
298 #
299 # If no --enable-apache-xx specified 
300 # find a default and fake the specific parameters
301 #
302
303 # simple macro to peek at an enable or a with
304 AC_DEFUN([Peek],
305 if test "[${[$1]_][$2]+set}" = set; then
306   peekval="${[$1]_[$2]}"
307   $3
308 fi; dnl
309 )
310
311 AC_MSG_CHECKING(if default apache needed)
312 need_default=yes
313 Peek(enable,apache_13,need_default=no)
314 Peek(enable,apache_20,need_default=no)
315 Peek(enable,apache_22,need_default=no)
316 AC_MSG_RESULT($need_default)
317
318 if test "$need_default" = "yes"; then
319   # find an apxs, then the httpd
320   xs=
321   Peek(with,apxs,xs="$peekval")
322   Peek(with,apxs2,xs="$peekval")
323   Peek(with,apxs22,xs="$peekval")
324   if test "x$xs" = "x"; then
325      AC_PATH_PROGS(xs, apxs2 apxs,
326         AC_MSG_ERROR(No apxs, no apache found.  Try --with-apxs),
327         [/usr/local/apache2/bin:/usr/local/apache/bin:/usr/sbin:$PATH])
328   fi
329   # ask the daemon for the version and set parameters
330   AC_MSG_CHECKING(default apache version)
331   httpd="`$xs -q SBINDIR`/`$xs -q TARGET`"
332   if test "x$httpd" != "x" && test -f $httpd ; then
333      v=`$httpd -v|$SED -n -e 's/.*Apache\/\.*//p'`
334      case $v in
335        1.3*)   [enable_apache_13]=yes
336                [with_apxs]=$xs
337                AC_MSG_RESULT(1.3)
338                ;;
339        2.0*)   [enable_apache_20]=yes
340                [with_apxs2]=$xs
341                AC_MSG_RESULT(2.0)
342                ;;
343        2.2*)   [enable_apache_22]=yes
344                [with_apxs22]=$xs
345                AC_MSG_RESULT(2.2)
346                ;;
347        *)      AC_MSG_ERROR(unusable apache versions: $v. Try setting --with-apxs)
348      esac
349   else 
350      AC_MSG_RESULT(cannot determine version.  Try setting --with-apxs)
351   fi
352 fi
353
354 # Apache 1.3 (mod_shib_13)
355 #   --enable-apache-13
356 #   --with-apxs      (DSO build, the normal way, uses apxs to derive build flags)
357
358 AC_ARG_ENABLE(apache-13,
359         AC_HELP_STRING([--enable-apache-13], [enable the Apache 1.3 module]),
360         [ if test "x$enableval" = "x" ; then
361               WANT_APACHE_13=yes
362           else
363               WANT_APACHE_13="$enableval"
364           fi
365         ],[ WANT_APACHE_13=no ])
366 AC_MSG_CHECKING(whether to build Apache 1.3 module)
367 if test "$WANT_APACHE_13" != yes && test "$WANT_APACHE_13" != no ; then
368    WANT_APACHE_13=yes
369 fi
370 AC_MSG_RESULT($WANT_APACHE_13)
371
372 if test "$WANT_APACHE_13" = "yes" ; then
373     AC_ARG_WITH(apxs, 
374         AC_HELP_STRING([--with-apxs=FILE], [Specifies where to find the Apache 1.3 apxs script.]),
375         [
376         AC_MSG_CHECKING(for user-specified apxs name/location)
377         if test "$withval" != "no" ; then
378           if test "$withval" != "yes"; then
379             APXS=$withval
380             AC_MSG_RESULT("$withval")
381           fi
382         fi
383         ],
384         [
385         AC_PATH_PROG(APXS, apxs, no)
386         if test "$APXS" = "no" ; then
387           for i in /usr/sbin /usr/local/apache/bin ; do
388             if test "$APXS" = "no" && test -f "$i/apxs"; then
389               APXS="$i/apxs"
390             fi
391           done
392         fi
393         ])
394
395     AC_MSG_CHECKING([to see if apxs was located])
396     if test ! -f "$APXS" ; then
397         AC_MSG_RESULT(no)
398         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.])
399     fi
400     AC_MSG_RESULT($APXS)
401     AC_SUBST(APXS)
402
403     # extract settings we need from APXS -q
404     APXS_CC="`$APXS -q CC`"
405     APXS_CFLAGS="`$APXS -q CPPFLAGS` `$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
406     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
407 fi
408
409 AC_SUBST(APXS_CFLAGS)
410 AC_SUBST(APXS_INCLUDE)
411
412
413 # Apache 2.0 (mod_shib_20)
414 #   --enable-apache-20
415 #   --with-apxs2      (DSO build, the normal way, uses apxs to derive build flags)
416 #       --with-apr        (DSO build, APR development package installed separately)
417
418 AC_ARG_ENABLE(apache-20,
419         AC_HELP_STRING([--enable-apache-20], [enable the Apache 2.0 module]),
420         [ if test "x$enableval" = "x" ; then
421               WANT_APACHE_20=yes
422           else
423               WANT_APACHE_20="$enableval"
424           fi
425         ],[ WANT_APACHE_20=no ])
426 AC_MSG_CHECKING(whether to build Apache 2.0 module)
427 if test "$WANT_APACHE_20" != yes && test "$WANT_APACHE_20" != no ; then
428    WANT_APACHE_20=yes
429 fi
430 AC_MSG_RESULT($WANT_APACHE_20)
431
432 if test "$WANT_APACHE_20" = "yes" ; then
433     AC_ARG_WITH(apxs2, 
434         AC_HELP_STRING([--with-apxs2=FILE], [Specifies where to find the Apache 2.0 apxs script.]),
435         [
436         AC_MSG_CHECKING(for user-specified Apache2 apxs name/location)
437         if test "$withval" != "no" ; then
438           if test "$withval" != "yes"; then
439             APXS2=$withval
440             AC_MSG_RESULT("$withval")
441           fi
442         fi
443         ],
444         [
445         AC_PATH_PROG(APXS2, apxs2, no)
446         if test "$APXS2" = "no" ; then
447             AC_PATH_PROG(APXS2, apxs, no)
448         fi
449         if test "$APXS2" = "no" ; then
450           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
451             if test "$APXS2" = "no" && test -f "$i/apxs2" ; then
452               APXS2="$i/apxs2"
453             fi
454           done
455           if test "$APXS2" = "no" ; then
456             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
457               if test "$APXS2" = "no" && test -f "$i/apxs" ; then
458                 APXS2="$i/apxs"
459               fi
460             done
461           fi
462         fi
463         ])
464
465     AC_MSG_CHECKING([to see if Apache2 apxs was located])
466     if test ! -f "$APXS2" ; then
467         AC_MSG_RESULT(no)
468         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.])
469     fi
470     AC_MSG_RESULT($APXS2)
471     AC_SUBST(APXS2)
472
473     # APR settings
474     AC_ARG_WITH(apr, 
475         AC_HELP_STRING([--with-apr=PATH], [where apr-config is installed]),
476         [
477         AC_MSG_CHECKING(for user-specified apr-config name/location)
478         if test "$withval" != "no" ; then
479             if test "$withval" != "yes"; then
480                 APR_CONFIG=$withval
481                 AC_MSG_RESULT("$withval")
482             fi
483         fi
484         ],
485         [
486         AC_PATH_PROG(APR_CONFIG, apr-config)
487         ])
488         if test -f "${APR_CONFIG}"; then
489         APR_CFLAGS="`${APR_CONFIG} --cflags` `${APR_CONFIG} --cppflags` `${APR_CONFIG} --includes`"
490     else
491         AC_MSG_ERROR([Unable to locate apr-config, may need --with-apr option.])
492     fi
493
494     # extract settings we need from APXS2 -q
495     APXS2_CC="`$APXS2 -q CC`"
496     APXS2_CFLAGS="`$APXS2 -q CPPFLAGS` `$APXS2 -q CFLAGS` `$APXS2 -q CFLAGS_SHLIB` $APR_CFLAGS"
497     APXS2_INCLUDE="`$APXS2 -q INCLUDEDIR`"
498 fi
499
500 AC_SUBST(APXS2_CFLAGS)
501 AC_SUBST(APXS2_INCLUDE)
502
503
504 # Apache 2.2 (mod_shib_22)
505 #   --enable-apache-22
506 #   --with-apxs22     (DSO build, the normal way, uses apxs to derive build flags)
507 #       --with-apr1       (DSO build, APR development package installed separately)
508
509 AC_ARG_ENABLE(apache-22,
510         AC_HELP_STRING([--enable-apache-22], [enable the Apache 2.2 module]),
511         [ if test "x$enableval" = "x" ; then
512               WANT_APACHE_22=yes
513           else
514               WANT_APACHE_22="$enableval"
515           fi
516         ],[ WANT_APACHE_22=no ])
517 AC_MSG_CHECKING(whether to build Apache 2.2 module)
518 if test "$WANT_APACHE_22" != yes && test "$WANT_APACHE_22" != no ; then
519    WANT_APACHE_22=yes
520 fi
521 AC_MSG_RESULT($WANT_APACHE_22)
522
523 if test "$WANT_APACHE_22" = "yes" ; then
524     AC_ARG_WITH(apxs22, 
525         AC_HELP_STRING([--with-apxs22=FILE], [Specifies where to find the Apache 2.2 apxs script.]),
526         [
527         AC_MSG_CHECKING(for user-specified Apache2.2 apxs name/location)
528         if test "$withval" != "no" ; then
529           if test "$withval" != "yes"; then
530             APXS22=$withval
531             AC_MSG_RESULT("$withval")
532           fi
533         fi
534         ],
535         [
536         AC_PATH_PROG(APXS22, apxs2, no)
537         if test "$APXS22" = "no" ; then
538             AC_PATH_PROG(APXS22, apxs, no)
539         fi
540         if test "$APXS22" = "no" ; then
541           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
542             if test "$APXS22" = "no" && test -f "$i/apxs2" ; then
543               APXS22="$i/apxs2"
544             fi
545           done
546           if test "$APXS22" = "no" ; then
547             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
548               if test "$APXS22" = "no" && test -f "$i/apxs" ; then
549                 APXS22="$i/apxs"
550               fi
551             done
552           fi
553         fi
554         ])
555
556     AC_MSG_CHECKING([to see if Apache2.2 apxs was located])
557     if test ! -f "$APXS22" ; then
558         AC_MSG_RESULT(no)
559         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.])
560     fi
561     AC_MSG_RESULT($APXS22)
562     AC_SUBST(APXS22)
563
564     # APR1 settings
565     AC_ARG_WITH(apr1, 
566         AC_HELP_STRING([--with-apr1=PATH], [where apr-1-config is installed]),
567         [
568         AC_MSG_CHECKING(for user-specified apr-1-config name/location)
569         if test "$withval" != "no" ; then
570             if test "$withval" != "yes"; then
571                 APR1_CONFIG=$withval
572                 AC_MSG_RESULT("$withval")
573             fi
574         fi
575         ],
576         [
577         AC_PATH_PROG(APR1_CONFIG, apr-1-config)
578         ])
579         if test -f "${APR1_CONFIG}"; then
580         APR1_CFLAGS="`${APR1_CONFIG} --cflags` `${APR1_CONFIG} --cppflags` `${APR1_CONFIG} --includes`"
581     else
582         AC_MSG_ERROR([Unable to locate apr-1-config, may need --with-apr1 option.])
583     fi
584
585     # extract settings we need from APXS22 -q
586     APXS22_CC="`$APXS22 -q CC`"
587     APXS22_CFLAGS="`$APXS22 -q CPPFLAGS` `$APXS22 -q CFLAGS` `$APXS22 -q CFLAGS_SHLIB` $APR1_CFLAGS"
588     APXS22_INCLUDE="`$APXS22 -q INCLUDEDIR`"
589 fi
590
591 AC_SUBST(APXS22_CFLAGS)
592 AC_SUBST(APXS22_INCLUDE)
593
594 # always output the Makefile, even if you don't use it
595 AC_CONFIG_FILES([apache/Makefile])
596 AM_CONDITIONAL(BUILD_AP13,test "$WANT_APACHE_13" = "yes")
597 AM_CONDITIONAL(BUILD_AP20,test "$WANT_APACHE_20" = "yes")
598 AM_CONDITIONAL(BUILD_AP22,test "$WANT_APACHE_22" = "yes")
599
600 # add the apache module to the list of wanted subdirs..
601 if test "$WANT_APACHE_13" = "yes" || test "$WANT_APACHE_20" = "yes" || test "$WANT_APACHE_22" = "yes" ; then
602     WANT_SUBDIRS="$WANT_SUBDIRS apache"
603 fi
604
605
606 #
607 # Implement the checks of the ODBC Storage Service
608 #
609 # 1) Assume the user wants ODBC; if it's not found then just continue without
610 # 2) If the user specifically requested odbc, look for it and ERROR if not found
611 # 3) If the user specifically requested no odbc, don't build it.
612 #
613
614 AC_CONFIG_FILES([odbc-store/Makefile])
615
616 # determine whether we should enable the odbc ccache
617 AC_ARG_ENABLE([odbc],
618         AC_HELP_STRING([--disable-odbc], [disable the ODBC Storage Service]),
619         [odbc_enabled=$enableval], [odbc_enabled=default])
620
621 if test "x$odbc_enabled" = "x" ; then
622    odbc_enabled=yes
623 fi
624
625 # Are we trying to build ODBC?
626 AC_MSG_CHECKING(whether to build the ODBC storage service)
627 if test "$odbc_enabled" = "yes" ; then
628    build_odbc=yes
629    AC_MSG_RESULT(yes)
630 elif test "$odbc_enabled" = "default" ; then
631    build_odbc=yes
632    AC_MSG_RESULT([yes, if it can be found])
633 else
634    build_odbc=no
635    AC_MSG_RESULT(no)
636 fi
637
638 # If we're trying to build ODBC, try to find the odbc_config program.
639 if test "$build_odbc" = "yes" ; then
640    odbc_dir=""
641    AC_ARG_WITH(odbc,
642         AC_HELP_STRING([--with-odbc=PATH], [directory where odbc is installed]),
643             [if test "$with_odbc" = no ; then
644                AC_MSG_ERROR([Try running --disable-odbc instead.])
645              elif test "$with_odbc" != yes ; then
646                odbc_dir="$with_odbc/bin"
647              fi ])
648
649    AC_PATH_PROG(ODBC_CONFIG, odbc_config, no, $odbc_dir $PATH )
650
651    if test "$ODBC_CONFIG" = no ; then
652       if test "$odbc_enabled" = "yes" ; then
653         AC_MSG_ERROR(Cannot find odbc_config)
654       else
655         AC_MSG_WARN(ODBC not found, skipping.)
656       fi
657    fi
658 fi
659
660 if test "$build_odbc" = yes ; then
661    ODBC_CFLAGS=`$ODBC_CONFIG --cflags`
662    ODBC_CFLAGS=`eval echo $ODBC_CFLAGS`
663    ODBC_LIBS=`$ODBC_CONFIG --libs`
664    ODBC_LIBS=`eval echo $ODBC_LIBS`
665
666    save_CPPFLAGS="$CPPFLAGS"
667    CPPFLAGS="$CPPFLAGS $ODBC_CFLAGS"
668
669    AC_CHECK_HEADER([sql.h], [have_sql_h=yes], [have_sql_h=no])
670    if test "$have_sql_h" = no -a "$odbc_enabled" = "yes" ; then
671      AC_MSG_ERROR(unable to find ODBC header files)
672    fi
673
674    if test "$have_sql_h" = yes ; then
675       save_LIBS="$LIBS"
676       LIBS="$LIBS $ODBC_LIBS"
677       AC_MSG_CHECKING(if we can link againt ODBC)
678       AC_TRY_LINK(
679         [#include <sql.h>
680          #include <sqlext.h>
681          #include <stdio.h>],
682         [SQLSetEnvAttr(SQL_NULL_HANDLE, SQL_ATTR_CONNECTION_POOLING, (void*)SQL_CP_ONE_PER_HENV, 0)],
683         [have_odbc_libs=yes],
684         [have_odbc_libs=no])
685       LIBS="$save_LIBS"
686
687       if test "$have_odbc_libs" = no ; then
688          if test "$odbc_enabled" = "yes" ; then
689             AC_MSG_ERROR([unable to link with ODBC Library])
690          else
691             AC_MSG_RESULT(no, skipping ODBC)
692          fi
693       fi
694    fi
695
696    CPPFLAGS="$save_CPPFLAGS"
697 fi
698
699 # if have_odbc_libs=yes then go ahead with building ODBC
700 if test "$have_odbc_libs" = yes ; then
701    # this AC_MSG_RESULT is from above!
702    AC_MSG_RESULT(yes)
703    WANT_SUBDIRS="$WANT_SUBDIRS odbc-store"
704    AC_SUBST(ODBC_CFLAGS)
705    AC_SUBST(ODBC_LIBS)
706 fi
707
708
709 AC_SUBST(WANT_SUBDIRS)
710
711 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
712   echo "=================================================================="
713   echo "WARNING: You have chosen to compile Apache-1.3 modules with a different"
714   echo "         compiler than the one used to compile Apache."
715   echo ""
716   echo "    Current compiler:      $CC"
717   echo "   Apache's compiler:      $APXS_CC"
718   echo ""
719   echo "This could cause problems."
720   echo "=================================================================="
721 fi
722
723 if test -n "$APXS2_CC" && test "$APXS2_CC" != "$CC" ; then
724   echo "=================================================================="
725   echo "WARNING: You have chosen to compile Apache-2.0 modules with a different"
726   echo "         compiler than the one used to compile Apache."
727   echo ""
728   echo "    Current compiler:      $CC"
729   echo "   Apache's compiler:      $APXS2_CC"
730   echo ""
731   echo "This could cause problems."
732   echo "=================================================================="
733 fi
734
735 if test -n "$APXS22_CC" && test "$APXS22_CC" != "$CC" ; then
736   echo "=================================================================="
737   echo "WARNING: You have chosen to compile Apache-2.2 modules with a different"
738   echo "         compiler than the one used to compile Apache."
739   echo ""
740   echo "    Current compiler:      $CC"
741   echo "   Apache's compiler:      $APXS22_CC"
742   echo ""
743   echo "This could cause problems."
744   echo "=================================================================="
745 fi
746
747 LIBTOOL="$LIBTOOL --silent"
748
749 AC_OUTPUT
750