Library updates.
[shibboleth/cpp-sp.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([shibboleth], [1.3], [shibboleth-users@internet2.edu], [shibboleth])
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE([shibboleth],[1.3])
5
6 sinclude(acx_pthread.m4)
7 sinclude(acx_rpctest.m4)
8
9 AC_ARG_ENABLE(debug,
10     AC_HELP_STRING(--enable-debug, [Have GCC compile with symbols (Default = no)
11 ]),
12     enable_debug=$enableval, enable_debug=no)
13
14 if test "$enable_debug" = "yes" ; then
15     GCC_CFLAGS="$CFLAGS -Wall -g -D_DEBUG"
16     GCC_CXXFLAGS="$CXXFLAGS -Wall -g -D_DEBUG"
17 else
18     GCC_CFLAGS="$CFLAGS -Wall -O2 -DNDEBUG"
19     GCC_CXXFLAGS="$CXXFLAGS -Wall -O2 -DNDEBUG"
20 fi
21
22 AC_PROG_CC([gcc gcc3 cc])
23 AC_PROG_CXX([g++ g++3 c++ CC])
24
25 if test "$GCC" = "yes" ; then
26     CFLAGS="$GCC_CFLAGS"
27     CXXFLAGS="$GCC_CXXFLAGS"
28 fi
29
30 AC_DISABLE_STATIC
31 AC_PROG_LIBTOOL
32
33 AC_LANG(C++)
34
35 # C++ requirements
36 AC_CXX_REQUIRE_STL
37 AC_CXX_NAMESPACES
38
39 AC_LANG(C)
40
41 # Checks for typedefs, structures, and compiler characteristics.
42 AC_C_CONST
43 AC_TYPE_SIZE_T
44 AC_STRUCT_TM
45
46 # Checks for library functions.
47 AC_FUNC_STRFTIME
48 AC_FUNC_STRERROR_R
49 AC_CHECK_FUNCS([strchr strdup strstr gmtime_r ctime_r strtok_r strcasecmp])
50 AC_CHECK_HEADERS([dlfcn.h])
51
52 # old_LIBS="$LIBS"
53 # AC_SEARCH_LIBS(xdr_uint64_t,nsl,,
54 #       [CFLAGS="$CFLAGS -DNEED_XDR_LONGLONG"
55 #        CXXFLAGS="$CXXFLAGS -DNEED_XDR_LONGLONG"])
56 # LIBS="$old_LIBS"
57
58 # checks for pthreads
59 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
60 if test $enable_threads != "pthread"; then
61     AC_MSG_ERROR([unable to find pthreads, currently this is required])
62 else
63     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
64     LIBS="$PTHREAD_LIBS $LIBS"
65     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
66     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
67 fi
68
69 # Test RPC now -- finish dealing with it later
70 AC_ARG_ENABLE(native-rpc,
71         AC_HELP_STRING([--enable-native-rpc], [use the OS-supplied Sun RPC library, default is NO, except Linux]),
72         [ if test "x$enableval" = "x" ; then
73               NATIVE_RPC=yes
74           else
75               NATIVE_RPC="$enableval"
76           fi
77         ], [ NATIVE_RPC=no ])
78 ACX_RPCTEST([rpctest="yes"],[rpctest="no"])
79 AC_MSG_NOTICE([does the native Sun RPC library support svcfd_create...$rpctest])
80 if test $NATIVE_RPC = "no"; then
81         case "${host}" in
82                 *-*-linux*)
83                         if test $rpctest = "yes"; then
84                                 AC_MSG_WARN([embedded Sun RPC library does not support Linux])
85                                 NATIVE_RPC="yes"
86                         else
87                                 AC_MSG_ERROR([embedded Sun RPC library won't work, but neither will native version])
88                         fi
89                 ;;
90         esac
91 fi
92 if test $NATIVE_RPC = "yes" && test $rpctest = "no"; then
93         AC_MSG_WARN([native Sun RPC won't work, using internal version])
94         NATIVE_RPC = "no"
95 fi
96 if test $NATIVE_RPC = "yes"; then
97         AC_CHECK_DECLS([svcfd_create],,,[#include <rpc/rpc.h>])
98         AC_LANG_PUSH(C++)
99         AC_COMPILE_IFELSE(
100                 AC_LANG_PROGRAM(
101                         [[#include <rpc/rpc.h>
102 static SVCXPRT* xprt = NULL;]],
103                 [[svc_destroy(xprt);]]),
104         AC_DEFINE(HAVE_WORKING_SVC_DESTROY,1,[Define if RPC SVC macros work on this platform]),)
105         AC_LANG_POP(C++)
106 else
107         AC_CHECK_TYPES([struct rpcent],,,[#include <netdb.h>])
108         AC_CHECK_DECLS(sys_errlist)
109         AC_DEFINE(HAVE_DECL_SVCFD_CREATE,1,[ Define to 1 if you have the declaration of svcfd_create, and to 0 if you don't.])
110         AC_DEFINE(HAVE_WORKING_SVC_DESTROY,1,[Define if RPC SVC macros work on this platform])
111 fi
112
113 AC_ARG_WITH(dmalloc,
114             AC_HELP_STRING([--with-dmalloc=PATH], [where dmalloc is installed]),
115             [if test x_$with_dmalloc != x_/usr; then
116                 LDFLAGS="-L${with_dmalloc}/lib $LDFLAGS"
117                 CPPFLAGS="-I${with_dmalloc}/include $CPPFLAGS"
118             fi
119             AC_CHECK_LIB(dmallocxx, dmalloc_shutdown,,
120                          AC_MSG_ERROR([unable to find dmallocxx library]))
121             ])
122
123 # OpenSSL settings
124 AC_PATH_PROG(PKG_CONFIG, pkg-config)
125 if test "x$PKG_CONFIG" = x || test "x$PKG_CONFIG" = "xno" ; then
126     AC_ARG_WITH(openssl, 
127             AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
128             [if test x_$with_openssl != x_/usr; then
129             SSLLIBS="-L${with_openssl}/lib"
130             SSLFLAGS="-I${with_openssl}/include"
131             fi])
132     SSLLIBS="$SSLLIBS -lssl -lcrypto"
133 else
134     SSLLIBS="`$PKG_CONFIG --libs openssl`"
135     SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
136 fi
137 AC_MSG_CHECKING(for OpenSSL libraries)
138 AC_MSG_RESULT($SSLLIBS)
139 LIBS="$LIBS $SSLLIBS"
140 AC_MSG_CHECKING(for OpenSSL cflags)
141 AC_MSG_RESULT($SSLFLAGS)
142 CPPFLAGS="$SSLFLAGS $CPPFLAGS"
143
144 AC_CHECK_HEADER([openssl/ssl.h],,
145                 AC_MSG_ERROR([unable to find openssl header files]))
146 AC_MSG_CHECKING(for ERR_load_CRYPTO_string)
147 AC_TRY_LINK_FUNC([ERR_load_CRYPTO_strings],,
148              AC_MSG_ERROR([unable to link with openssl libraries]))
149 AC_MSG_RESULT(yes)
150 AC_MSG_CHECKING(for SSL_library_init)
151 AC_TRY_LINK_FUNC([SSL_library_init],, 
152              AC_MSG_ERROR([unable to link with openssl libraries]))
153 AC_MSG_RESULT(yes)
154
155 AC_LANG(C++)
156
157 # log4cpp settings
158 AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
159 AC_ARG_WITH(log4cpp,
160             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp is installed]),
161             [LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"])
162 if test -f "${LOG4CPP_CONFIG}"; then
163     LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
164     CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
165 else
166     AC_MSG_WARN([log4cpp-config not found, guessing at log4cpp build settings])
167     LIBS="-llog4cpp $LIBS"
168 fi
169 AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
170 AC_TRY_LINK(
171         [#include <log4cpp/Category.hh>],
172         [log4cpp::Category::getInstance("foo")],
173         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
174         [AC_MSG_ERROR([unable to link with log4cpp])])
175
176 # Xerces settings
177 AC_ARG_WITH(xerces, 
178             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
179             [if test x_$with_xerces != x_/usr; then
180                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
181                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
182             fi])
183 LIBS="-lxerces-c $LIBS"
184 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
185                 AC_MSG_ERROR([unable to find xerces header files]))
186 AC_MSG_CHECKING([Xerces version])
187 AC_PREPROC_IFELSE(
188         [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
189 [#if  _XERCES_VERSION > 20200 && _XERCES_VERSION != 20600
190 int i = 0;
191 #else
192 #error requires version > 2.2.0 but not 2.6.0
193 #endif])],
194         [AC_MSG_RESULT(OK)],
195         [AC_MSG_ERROR([Shibboleth requires patched Xerces version 2.6.1 (http://shibboleth.internet2.edu/downloads/)])])
196 AC_TRY_LINK(
197         [#include <xercesc/util/PlatformUtils.hpp>],
198         [xercesc::XMLPlatformUtils::Initialize()],
199         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
200         [AC_MSG_ERROR([unable to link with Xerces])])
201
202
203 # XML-Security settings
204 AC_ARG_WITH(xmlsec,
205             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),
206             [if test x_$with_xmlsec != x_/usr; then
207                 LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
208                 CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
209             fi])
210 LIBS="-lxml-security-c $LIBS"
211 AC_CHECK_HEADER([xsec/xenc/XENCEncryptionMethod.hpp],,AC_MSG_ERROR([unable to find xml-security 1.1 header files]),[#include <xercesc/dom/DOM.hpp>])
212 AC_TRY_LINK(
213         [#include <xsec/utils/XSECPlatformUtils.hpp>],
214         [XSECPlatformUtils::Initialise()],
215         [AC_DEFINE(HAVE_LIBXSEC,1,[Define if XML-Sec library was found])],
216         [AC_MSG_ERROR([unable to link with xml-security])])
217
218 # OpenSAML settings
219 AC_ARG_WITH(saml,
220             AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
221             [if test x_$with_saml != x_/usr; then
222                 LDFLAGS="-L${with_saml}/lib $LDFLAGS"
223                 CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
224             fi])
225 AC_CHECK_HEADER([saml/saml.h],,
226                 AC_MSG_ERROR([unable to find saml header files]))
227 LIBS="-lsaml $LIBS"
228 AC_TRY_LINK(
229         [#include <saml/saml.h>
230 #include <saml/version.h>],
231         [#if _OPENSAML_VERSION >= 10100
232 saml::SAMLConfig::getConfig();
233 #else
234 #error Need OpenSAML version 1.1 or higher
235 #endif],
236         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
237         [AC_MSG_ERROR([unable to link with saml, or version too old])])
238
239 # output the underlying makefiles
240 WANT_SUBDIRS="doc shib schemas configs shib-target shar siterefresh test xmlproviders adfs"
241 AC_CONFIG_FILES([Makefile doc/Makefile shib/Makefile schemas/Makefile \
242                  configs/Makefile oncrpc/Makefile oncrpc/rpc/Makefile \
243                  shib-target/Makefile shar/Makefile siterefresh/Makefile \
244                  test/Makefile xmlproviders/Makefile adfs/Makefile selinux/Makefile])
245
246
247 # now deal with the rpc library, to see if we need to build our own
248 if test $NATIVE_RPC = "no"; then
249     WANT_SUBDIRS="oncrpc $WANT_SUBDIRS"
250         AC_DEFINE(USE_OUR_ONCRPC,1,[Define if using embedded version of ONC RPC.])
251 fi
252 AM_CONDITIONAL(USE_OUR_ONCRPC,test "$NATIVE_RPC" = "no")
253
254 #
255 # Build NSAPI module?
256 #
257 AC_MSG_CHECKING(for NSAPI module option)
258 AC_ARG_WITH(nsapi,
259         AC_HELP_STRING([--with-nsapi=DIR], [Build NSAPI module for Netscape/iPlanet/SunONE]),
260         [WANT_NSAPI=$withval],[WANT_NSAPI=no])
261 AC_MSG_RESULT($WANT_NSAPI)
262
263 if test "$WANT_NSAPI" != "no"; then
264   if test ! -d $WANT_NSAPI/bin ; then
265     AC_MSG_ERROR(Please specify the path to the root of your Netscape/iPlanet/SunONE server using --with-nsapi=DIR)
266   fi
267   AC_MSG_CHECKING(for NSAPI include files)
268   if test -d $WANT_NSAPI/include ; then
269     NSAPI_INCLUDE=$WANT_NSAPI/include
270     AC_MSG_RESULT(Netscape-Enterprise 3.x style)
271     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
272     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
273   fi
274   if test -d $WANT_NSAPI/plugins/include ; then
275     test -n "$NSAPI_INCLUDE" && NSAPI_INC_DIR="-I$NSAPI_INCLUDE"
276     NSAPI_INCLUDE="$WANT_NSAPI/plugins/include"
277     AC_MSG_RESULT(iPlanet 4.x / SunONE 6.x style)
278     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
279     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
280   fi
281   if test "$NSAPI_INCLUDE" = ""; then
282     AC_MSG_ERROR(Please check you have nsapi.h in either $WANT_NSAPI/include or $WANT_NSAPI/plugins/include)
283   fi
284 fi
285
286 AC_SUBST(NSAPI_INCLUDE)
287
288 # always output the Makefile, even if you don't use it
289 AC_CONFIG_FILES([nsapi_shib/Makefile])
290 AM_CONDITIONAL(BUILD_NSAPI,test ! "$WANT_NSAPI" = "no")
291
292 # add the NSAPI module to the list of wanted subdirs..
293 if test ! "$WANT_NSAPI" = "no" ; then
294     WANT_SUBDIRS="$WANT_SUBDIRS nsapi_shib"
295 fi
296
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"; 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
355 # Apache 1.3 (mod_shib_13)
356 #   --enable-apache-13
357 #   --with-apxs      (DSO build, the normal way, uses apxs to derive build flags)
358
359 AC_ARG_ENABLE(apache-13,
360         AC_HELP_STRING([--enable-apache-13], [enable the Apache 1.3 module]),
361         [ if test "x$enableval" = "x" ; then
362               WANT_APACHE_13=yes
363           else
364               WANT_APACHE_13="$enableval"
365           fi
366         ],[ WANT_APACHE_13=no ])
367 AC_MSG_CHECKING(whether to build Apache 1.3 module)
368 if test "$WANT_APACHE_13" != yes && test "$WANT_APACHE_13" != no ; then
369    WANT_APACHE_13=yes
370 fi
371 AC_MSG_RESULT($WANT_APACHE_13)
372
373 if test "$WANT_APACHE_13" = "yes" ; then
374     AC_ARG_WITH(apxs, 
375         AC_HELP_STRING([--with-apxs=FILE], [Specifies where to find the Apache 1.3 apxs script.]),
376         [
377         AC_MSG_CHECKING(for user-specified apxs name/location)
378         if test "$withval" != "no" ; then
379           if test "$withval" != "yes"; then
380             APXS=$withval
381             AC_MSG_RESULT("$withval")
382           fi
383         fi
384         ],
385         [
386         AC_PATH_PROG(APXS, apxs, no)
387         if test "$APXS" = "no" ; then
388           for i in /usr/sbin /usr/local/apache/bin ; do
389             if test "$APXS" = "no" && test -f "$i/apxs"; then
390               APXS="$i/apxs"
391             fi
392           done
393         fi
394         ])
395
396     AC_MSG_CHECKING([to see if apxs was located])
397     if test ! -f "$APXS" ; then
398         AC_MSG_RESULT(no)
399         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.])
400     fi
401     AC_MSG_RESULT($APXS)
402     AC_SUBST(APXS)
403
404     # extract settings we need from APXS -q
405     APXS_CC="`$APXS -q CC`"
406     APXS_CFLAGS="`$APXS -q CPPFLAGS` `$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
407     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
408 fi
409
410 AC_SUBST(APXS_CFLAGS)
411 AC_SUBST(APXS_INCLUDE)
412
413
414 # Apache 2.0 (mod_shib_20)
415 #   --enable-apache-20
416 #   --with-apxs2      (DSO build, the normal way, uses apxs to derive build flags)
417 #       --with-apr        (DSO build, APR development package installed separately)
418
419 AC_ARG_ENABLE(apache-20,
420         AC_HELP_STRING([--enable-apache-20], [enable the Apache 2.0 module]),
421         [ if test "x$enableval" = "x" ; then
422               WANT_APACHE_20=yes
423           else
424               WANT_APACHE_20="$enableval"
425           fi
426         ],[ WANT_APACHE_20=no ])
427 AC_MSG_CHECKING(whether to build Apache 2.0 module)
428 if test "$WANT_APACHE_20" != yes && test "$WANT_APACHE_20" != no ; then
429    WANT_APACHE_20=yes
430 fi
431 AC_MSG_RESULT($WANT_APACHE_20)
432
433 if test "$WANT_APACHE_20" = "yes" ; then
434     AC_ARG_WITH(apxs2, 
435         AC_HELP_STRING([--with-apxs2=FILE], [Specifies where to find the Apache 2.0 apxs script.]),
436         [
437         AC_MSG_CHECKING(for user-specified Apache2 apxs name/location)
438         if test "$withval" != "no" ; then
439           if test "$withval" != "yes"; then
440             APXS2=$withval
441             AC_MSG_RESULT("$withval")
442           fi
443         fi
444         ],
445         [
446         AC_PATH_PROG(APXS2, apxs2, no)
447         if test "$APXS2" = "no" ; then
448             AC_PATH_PROG(APXS2, apxs, no)
449         fi
450         if test "$APXS2" = "no" ; then
451           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
452             if test "$APXS2" = "no" && test -f "$i/apxs2" ; then
453               APXS2="$i/apxs2"
454             fi
455           done
456           if test "$APXS2" = "no" ; then
457             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
458               if test "$APXS2" = "no" && test -f "$i/apxs" ; then
459                 APXS2="$i/apxs"
460               fi
461             done
462           fi
463         fi
464         ])
465
466     AC_MSG_CHECKING([to see if Apache2 apxs was located])
467     if test ! -f "$APXS2" ; then
468         AC_MSG_RESULT(no)
469         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.])
470     fi
471     AC_MSG_RESULT($APXS2)
472     AC_SUBST(APXS2)
473
474     # APR settings
475     AC_ARG_WITH(apr, 
476         AC_HELP_STRING([--with-apr=PATH], [where apr-config is installed]),
477         [
478         AC_MSG_CHECKING(for user-specified apr-config name/location)
479         if test "$withval" != "no" ; then
480             if test "$withval" != "yes"; then
481                 APR_CONFIG=$withval
482                 AC_MSG_RESULT("$withval")
483             fi
484         fi
485         ],
486         [
487         AC_PATH_PROG(APR_CONFIG, apr-config,,[`$APXS2 -q SBINDIR`]:[$PATH])
488         ])
489         if test -f "${APR_CONFIG}"; then
490         APR_CFLAGS="`${APR_CONFIG} --cflags` `${APR_CONFIG} --cppflags` `${APR_CONFIG} --includes`"
491     else
492         AC_MSG_ERROR([Unable to locate apr-config, may need --with-apr option.])
493     fi
494
495     # extract settings we need from APXS2 -q
496     APXS2_CC="`$APXS2 -q CC`"
497     APXS2_CFLAGS="`$APXS2 -q CPPFLAGS` `$APXS2 -q CFLAGS` `$APXS2 -q CFLAGS_SHLIB` $APR_CFLAGS"
498     APXS2_INCLUDE="`$APXS2 -q INCLUDEDIR`"
499 fi
500
501 AC_SUBST(APXS2_CFLAGS)
502 AC_SUBST(APXS2_INCLUDE)
503
504
505 # Apache 2.2 (mod_shib_22)
506 #   --enable-apache-22
507 #   --with-apxs22     (DSO build, the normal way, uses apxs to derive build flags)
508 #       --with-apr1       (DSO build, APR development package installed separately)
509
510 AC_ARG_ENABLE(apache-22,
511         AC_HELP_STRING([--enable-apache-22], [enable the Apache 2.2 module]),
512         [ if test "x$enableval" = "x" ; then
513               WANT_APACHE_22=yes
514           else
515               WANT_APACHE_22="$enableval"
516           fi
517         ],[ WANT_APACHE_22=no ])
518 AC_MSG_CHECKING(whether to build Apache 2.2 module)
519 if test "$WANT_APACHE_22" != yes && test "$WANT_APACHE_22" != no ; then
520    WANT_APACHE_22=yes
521 fi
522 AC_MSG_RESULT($WANT_APACHE_22)
523
524 if test "$WANT_APACHE_22" = "yes" ; then
525     AC_ARG_WITH(apxs22, 
526         AC_HELP_STRING([--with-apxs22=FILE], [Specifies where to find the Apache 2.2 apxs script.]),
527         [
528         AC_MSG_CHECKING(for user-specified Apache2.2 apxs name/location)
529         if test "$withval" != "no" ; then
530           if test "$withval" != "yes"; then
531             APXS22=$withval
532             AC_MSG_RESULT("$withval")
533           fi
534         fi
535         ],
536         [
537         AC_PATH_PROG(APXS22, apxs2, no)
538         if test "$APXS22" = "no" ; then
539             AC_PATH_PROG(APXS22, apxs, no)
540         fi
541         if test "$APXS22" = "no" ; then
542           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
543             if test "$APXS22" = "no" && test -f "$i/apxs2" ; then
544               APXS22="$i/apxs2"
545             fi
546           done
547           if test "$APXS22" = "no" ; then
548             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
549               if test "$APXS22" = "no" && test -f "$i/apxs" ; then
550                 APXS22="$i/apxs"
551               fi
552             done
553           fi
554         fi
555         ])
556
557     AC_MSG_CHECKING([to see if Apache2.2 apxs was located])
558     if test ! -f "$APXS22" ; then
559         AC_MSG_RESULT(no)
560         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.])
561     fi
562     AC_MSG_RESULT($APXS22)
563     AC_SUBST(APXS22)
564
565     # APR1 settings
566     AC_ARG_WITH(apr1, 
567         AC_HELP_STRING([--with-apr1=PATH], [where apr-1-config is installed]),
568         [
569         AC_MSG_CHECKING(for user-specified apr-1-config name/location)
570         if test "$withval" != "no" ; then
571             if test "$withval" != "yes"; then
572                 APR1_CONFIG=$withval
573                 AC_MSG_RESULT("$withval")
574             fi
575         fi
576         ],
577         [
578         AC_PATH_PROG(APR1_CONFIG, apr-1-config,,[`$APXS22 -q SBINDIR`]:[$PATH])
579         ])
580         if test -f "${APR1_CONFIG}"; then
581         APR1_CFLAGS="`${APR1_CONFIG} --cflags` `${APR1_CONFIG} --cppflags` `${APR1_CONFIG} --includes`"
582     else
583         AC_MSG_ERROR([Unable to locate apr-1-config, may need --with-apr1 option.])
584     fi
585
586     # extract settings we need from APXS22 -q
587     APXS22_CC="`$APXS22 -q CC`"
588     APXS22_CFLAGS="`$APXS22 -q CPPFLAGS` `$APXS22 -q CFLAGS` `$APXS22 -q CFLAGS_SHLIB` $APR1_CFLAGS"
589     APXS22_INCLUDE="`$APXS22 -q INCLUDEDIR`"
590 fi
591
592 AC_SUBST(APXS22_CFLAGS)
593 AC_SUBST(APXS22_INCLUDE)
594
595 # always output the Makefile, even if you don't use it
596 AC_CONFIG_FILES([apache/Makefile])
597 AM_CONDITIONAL(BUILD_AP13,test "$WANT_APACHE_13" = "yes")
598 AM_CONDITIONAL(BUILD_AP20,test "$WANT_APACHE_20" = "yes")
599 AM_CONDITIONAL(BUILD_AP22,test "$WANT_APACHE_22" = "yes")
600
601 # add the apache module to the list of wanted subdirs..
602 if test "$WANT_APACHE_13" = "yes" || test "$WANT_APACHE_20" = "yes" || test "$WANT_APACHE_22" = "yes" ; then
603     WANT_SUBDIRS="$WANT_SUBDIRS apache"
604 fi
605
606
607 #
608 # Implement the checks of the MySQL Credential Cache
609 #
610 # 1) Assume the user wants MySQL; if it's not found then just continue without
611 # 2) If the user specifically requested Mysql, look for it and ERROR if not found
612 # 3) If the user specifically requested no-mysql, don't build it.
613 #
614
615 AC_CONFIG_FILES([shib-mysql-ccache/Makefile])
616
617 # determine whether we should enable the mysql ccache
618 AC_ARG_ENABLE([mysql],
619         AC_HELP_STRING([--disable-mysql], [disable the MySQL Credential Cache]),
620         [mysql_enabled=$enableval], [mysql_enabled=default])
621
622 if test "x$mysql_enabled" = "x" ; then
623    mysql_enabled=yes
624 fi
625
626 # Are we trying to build MySQL?
627 AC_MSG_CHECKING(whether to build the MySQL ccache)
628 if test "$mysql_enabled" = "yes" ; then
629    build_mysql=yes
630    AC_MSG_RESULT(yes)
631 elif test "$mysql_enabled" = "default" ; then
632    build_mysql=yes
633    AC_MSG_RESULT([yes, if it can be found])
634 else
635    build_mysql=no
636    AC_MSG_RESULT(no)
637 fi
638
639 # If we're trying to build MySQL, try to find the mysql_config program,
640 # verify we've got mysql >= 4, and make sure we can build with mysqld
641 if test "$build_mysql" = "yes" ; then
642    mysql_dir=""
643    AC_ARG_WITH(mysql,
644         AC_HELP_STRING([--with-mysql=PATH], [directory where mysql is installed]),
645             [if test "$with_mysql" = no ; then
646              AC_MSG_ERROR([Try running --disable-mysql instead.])
647          elif test "$with_mysql" != yes ; then
648              mysql_dir="$with_mysql/bin"
649          fi ])
650
651    # Try to find the mysql_config program
652    AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no, $mysql_dir $PATH )
653
654    if test "$MYSQL_CONFIG" = no ; then
655       if test "$mysql_enabled" = "yes" ; then
656         AC_MSG_ERROR(Cannot find mysql_config)
657       else
658         AC_MSG_WARN(MySQL not found.  skipping.)
659       fi
660    fi
661 fi
662
663 # if we found mysql_config then build_mysql is 'yes'
664 if test "$MYSQL_CONFIG" != no ; then
665    AC_MSG_CHECKING(for mysql version >= 4)
666    mysql_version=`$MYSQL_CONFIG --version`
667    mysql_major_version=`echo $mysql_version | awk -F. '{print $1}'`
668    mysql_version_ok=yes
669    if test $mysql_major_version -lt 4 ; then
670      mysql_version_ok=no
671      if test "$mysql_enabled" = "yes" ; then
672        AC_MSG_ERROR(You need MySQL version >= 4, found $mysql_version)
673      fi
674      AC_MSG_RESULT(no.. skipping MySQL)
675    else
676      AC_MSG_RESULT(yes)
677    fi
678 fi
679
680 # if mysql_version_ok is 'yes', then we've made it this far.. ;)
681 if test "$mysql_version_ok" = "yes" ; then
682    AC_MSG_CHECKING(for embedded-MySQL libraries)
683    MYSQL_LIBS=`$MYSQL_CONFIG --libmysqld-libs`
684    if test $? != 0 ; then
685       found_mysql=no
686       if test "$mysql_enabled" = "yes" ; then
687         AC_MSG_ERROR(Could not find the MySQL Embedded-server libraries.)
688       else
689         AC_MSG_RESULT(no.. skipping MySQL)
690       fi
691    else
692       found_mysql=yes
693       AC_MSG_RESULT(yes)
694    fi
695 fi
696
697 # if found_mysql=yes then test that we can actually build mysql
698 if test "$found_mysql" = yes ; then
699    MYSQL_CFLAGS=`$MYSQL_CONFIG --cflags`
700    MYSQL_CFLAGS=`eval echo $MYSQL_CFLAGS`
701    MYSQL_LIBS=`eval echo $MYSQL_LIBS`
702
703    save_CPPFLAGS="$CPPFLAGS"
704    CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
705
706    AC_CHECK_HEADER([mysql.h], [have_mysql_h=yes], [have_mysql_h=no])
707    if test "$have_mysql_h" = no -a "$mysql_enabled" = "yes" ; then
708      AC_MSG_ERROR(unable to find MySQL header files)
709    fi
710
711    if test "$have_mysql_h" = yes ; then
712       save_LIBS="$LIBS"
713       LIBS="$LIBS $MYSQL_LIBS"
714       AC_MSG_CHECKING(if we can link againt mysql)
715       AC_TRY_LINK(
716         [#include <mysql.h>
717          #include <stdio.h>],
718         [mysql_server_init(0, NULL, NULL)],
719         [have_mysql_libs=yes],
720         [have_mysql_libs=no])
721       LIBS="$save_LIBS"
722
723       if test "$have_mysql_libs" = no ; then
724          if test "$mysql_enabled" = "yes" ; then
725             AC_MSG_ERROR([unable to link with MySQL Embedded Server Library])
726          else
727             AC_MSG_RESULT(no.  skipping MySQL)
728          fi
729       fi
730    fi
731
732    CPPFLAGS="$save_CPPFLAGS"
733 fi
734
735 # if have_mysql_libs=yes then go ahead with building MySQL
736 if test "$have_mysql_libs" = yes ; then
737    # this AC_MSG_RESULT is from above!
738    AC_MSG_RESULT(yes)
739    WANT_SUBDIRS="$WANT_SUBDIRS shib-mysql-ccache"
740    AC_SUBST(MYSQL_CFLAGS)
741    AC_SUBST(MYSQL_LIBS)
742 fi
743
744
745 AC_SUBST(WANT_SUBDIRS)
746
747 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
748   echo "=================================================================="
749   echo "WARNING: You have chosen to compile Apache-1.3 modules with a different"
750   echo "         compiler than the one used to compile Apache."
751   echo ""
752   echo "    Current compiler:      $CC"
753   echo "   Apache's compiler:      $APXS_CC"
754   echo ""
755   echo "This could cause problems."
756   echo "=================================================================="
757 fi
758
759 if test -n "$APXS2_CC" && test "$APXS2_CC" != "$CC" ; then
760   echo "=================================================================="
761   echo "WARNING: You have chosen to compile Apache-2 modules with a different"
762   echo "         compiler than the one used to compile Apache."
763   echo ""
764   echo "    Current compiler:      $CC"
765   echo "   Apache's compiler:      $APXS2_CC"
766   echo ""
767   echo "This could cause problems."
768   echo "=================================================================="
769 fi
770
771 LIBTOOL="$LIBTOOL --silent"
772
773 AC_OUTPUT
774