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