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