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