Added AC_DEFINE for ONC library.
[shibboleth/sp.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([shibboleth], [1.0.1], [mace-shib-users@internet2.edu], [shibboleth])
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE(shibboleth, 1.0.1)
5
6 sinclude(acx_pthread.m4)
7 sinclude(acx_rpctest.m4)
8
9 AC_PROG_CC([gcc3 gcc cc])
10 AC_PROG_CXX([g++3 g++ c++ CC])
11 AC_DISABLE_STATIC
12 AC_PROG_LIBTOOL
13
14 AC_LANG(C++)
15
16 # Checks for typedefs, structures, and compiler characteristics.
17 AC_C_CONST
18 AC_TYPE_SIZE_T
19 AC_STRUCT_TM
20
21 # Checks for library functions.
22 AC_FUNC_STRFTIME
23 AC_CHECK_FUNCS([strchr strdup strstr gmtime_r strtok_r strcasecmp])
24 AC_CHECK_HEADERS([dlfcn.h])
25
26 # C++ requirements
27 AC_CXX_REQUIRE_STL
28 AC_CXX_NAMESPACES
29
30
31 # old_LIBS="$LIBS"
32 # AC_SEARCH_LIBS(xdr_uint64_t,nsl,,
33 #       [CFLAGS="$CFLAGS -DNEED_XDR_LONGLONG"
34 #        CXXFLAGS="$CXXFLAGS -DNEED_XDR_LONGLONG"])
35 # LIBS="$old_LIBS"
36
37 # checks for pthreads
38 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
39 if test $enable_threads != "pthread"; then
40     AC_MSG_ERROR([unable to find pthreads, currently this is required])
41 else
42     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
43     LIBS="$PTHREAD_LIBS $LIBS"
44     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
45     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
46 fi
47
48 # Test RPC now -- deal with it later
49 ACX_RPCTEST([rpctest="yes"],[rpctest="no"])
50
51 # Determine whether to use TCP for the shar socket
52 AC_ARG_ENABLE([tcp],
53     AC_HELP_STRING([--enable-tcp], [enable the SHAR to use a TCP socket on Unix]),
54     [tcp_enabled=$enableval], [tcp_enabled=default])
55
56 if test "x$tcp_enabled" = "x" ; then
57    tcp_enabled=yes
58 fi
59
60 if test "$tcp_enabled" = "yes" ; then
61     CFLAGS="$CFLAGS -DWANT_TCP_SHAR"
62     CXXFLAGS="$CXXFLAGS -DWANT_TCP_SHAR"
63 fi
64
65 AC_ARG_WITH(dmalloc,
66             AC_HELP_STRING([--with-dmalloc=PATH], [where dmalloc is installed]),
67             [if test x_$with_dmalloc != x_/usr; then
68                 LDFLAGS="-L${with_dmalloc}/lib $LDFLAGS"
69                 CPPFLAGS="-I${with_dmalloc}/include $CPPFLAGS"
70             fi
71             AC_CHECK_LIB(dmallocxx, dmalloc_shutdown,,
72                          AC_MSG_ERROR([unable to find dmallocxx library]))
73             ])
74
75 AC_ARG_WITH(xerces, 
76             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
77             [if test x_$with_xerces != x_/usr; then
78                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
79                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
80             fi])
81
82
83 AC_ARG_WITH(openssl, 
84             AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
85             [if test x_$with_openssl != x_/usr; then
86                 LDFLAGS="-L${with_openssl}/lib $LDFLAGS"
87                 CPPFLAGS="-I${with_openssl}/include $CPPFLAGS"
88             fi])
89
90 AC_ARG_WITH(log4cpp, 
91             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp is installed]),
92             [if test x_$with_log4cpp != x_/usr; then
93                 LDFLAGS="-L${with_log4cpp}/lib $LDFLAGS"
94                 CPPFLAGS="-I${with_log4cpp}/include $CPPFLAGS"
95             fi])
96
97 AC_ARG_WITH(xmlsec,
98             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),
99             [if test x_$with_xmlsec != x_/usr; then
100                 LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
101                 CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
102             fi])
103
104 AC_ARG_WITH(saml,
105             AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
106             [if test x_$with_saml != x_/usr; then
107                 LDFLAGS="-L${with_saml}/lib $LDFLAGS"
108                 CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
109             fi])
110
111 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
112                 AC_MSG_ERROR([unable to find xerces header files]))
113 saved_LIBS="$LIBS"
114 LIBS="-lxerces-c $LIBS"
115 AC_TRY_LINK(
116         [#include <xercesc/util/PlatformUtils.hpp>],
117         [xercesc::XMLPlatformUtils::Initialize()],
118         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
119         [AC_MSG_ERROR([unable to link with Xerces])
120                 LIBS="$saved_LIBS"
121         ])
122
123 AC_CHECK_HEADER([openssl/ssl.h],,
124                 AC_MSG_ERROR([unable to find openssl header files]))
125 AC_CHECK_LIB([crypto], [ERR_load_CRYPTO_strings],,
126              AC_MSG_ERROR([unable to link with openssl libraries]))
127 AC_CHECK_LIB([ssl], [SSL_library_init],, 
128              AC_MSG_ERROR([unable to link with openssl libraries]))
129
130 AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,
131                 AC_MSG_ERROR([unable to find xsec header files]))
132 saved_LIBS="$LIBS"
133 LIBS="-lxml-security-c $LIBS"
134 AC_TRY_LINK(
135         [#include <xsec/utils/XSECPlatformUtils.hpp>],
136         [XSECPlatformUtils::Initialise()],
137         [AC_DEFINE(HAVE_LIBXSEC,1,[Define if XML-Sec library was found])],
138         [AC_MSG_ERROR([unable to link with XML-Sec])
139                 LIBS="$saved_LIBS"
140         ])
141
142 AC_CHECK_HEADER([log4cpp/Category.hh],,
143                 AC_MSG_ERROR([unable to find log4cpp header files]))
144
145 AC_CHECK_HEADER([saml/saml.h],,
146                 AC_MSG_ERROR([unable to find saml header files]))
147
148 saved_LIBS="$LIBS"
149 LIBS="-llog4cpp $LIBS"
150 AC_TRY_LINK(
151         [#include <log4cpp/Category.hh>],
152         [log4cpp::Category::getInstance("foo")],
153         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
154         [AC_MSG_ERROR([unable to link with log4cpp])
155                 LIBS="$saved_LIBS"
156         ])
157
158 saved_LIBS="$LIBS"
159 LIBS="-lsaml $LIBS"
160 AC_TRY_LINK(
161         [#include <saml/saml.h>],
162         [saml::SAMLConfig::getConfig()],
163         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
164         [AC_MSG_ERROR([unable to link with saml])
165                 LIBS="$saved_LIBS"
166         ])
167
168 # output the underlying makefiles
169 WANT_SUBDIRS="doc shib schemas configs shib-target shar siterefresh test"
170 AC_CONFIG_FILES([Makefile doc/Makefile shib/Makefile schemas/Makefile \
171                  configs/Makefile oncrpc/Makefile oncrpc/rpc/Makefile \
172                  shib-target/Makefile shar/Makefile siterefresh/Makefile \
173                  test/Makefile])
174
175 # now deal with the rpc library, to see if we need to build our own
176 if test $rpctest = "no"; then
177     WANT_SUBDIRS="oncrpc $WANT_SUBDIRS"
178         AC_DEFINE(USE_OUR_ONCRPC,1,[Define if using embedded version of ONC RPC.])
179 fi
180 AM_CONDITIONAL(USE_OUR_ONCRPC,test "$rpctest" = "no")
181
182 # Much of this is taken from mod_dav.
183 # The basic idea is to use configure options to control whether/which types
184 # of web server modules get built. We assume there may eventually be multiple
185 # types (Apache 1/2, iPlanet, others).
186
187 # Apache 1.3 (mod_shire/mod_shibrm)
188 #   --with-apache   (static build, no idea how to do this yet, so not supported)
189 #   --with-apxs     (DSO build, the normal way, uses apxs to derive build flags)
190 #   --without-apxs  (DSO build, you tell us how to build using the environment)
191
192 AC_ARG_ENABLE(apache-13,
193         AC_HELP_STRING([--disable-apache-13], [disable the Apache 1.3 modules]))
194 if test "x$enable_apache_13" = "x" ; then
195    enable_apache_13=yes
196 fi
197
198 if test "$enable_apache_13" != yes ; then
199    AC_MSG_WARN(Building without Apache...)
200    WANT_APACHE=no
201 else
202
203 AC_MSG_CHECKING([for dynamic Apache module support (w/ or w/o APXS)])
204 AC_ARG_WITH(apxs,
205 [  --with-apxs[=FILE]        Build shared Apache module(s). FILE is the optional
206                           pathname to the Apache apxs tool; defaults to "apxs".],
207 [
208     if test "$withval" = "yes"; then
209       for i in /usr/sbin /usr/local/apache/bin ; do
210         if test -f "$i/apxs"; then
211           APXS="$i/apxs"
212         fi
213       done
214       if test -z "$APXS"; then
215         APXS=apxs
216       fi
217     else
218       APXS="$withval"
219     fi
220 ])
221
222 if test "$APXS" = "no"; then
223
224     # --without-apxs means you want the modules,
225     #       but want to tell us how to build them
226     AC_MSG_RESULT(yes, but use environment, not apxs)
227     echo
228     echo "Did you set one or more of these?"
229     echo
230     echo "APXS_CFLAGS APXS_PREFIX APXS_INCLUDE APXS_LIBEXEC APXS_SYSCONFDIR"
231     echo
232
233     AC_MSG_NOTICE([APXS_CFLAGS is $APXS_CFLAGS])
234
235     # try and find the Apache root
236     if test -z "$APXS_PREFIX"; then
237         if test -d "/usr/local/apache"; then
238             APXS_PREFIX="/usr/local/apache"
239         else
240             AC_MSG_ERROR([You MUST set APXS_PREFIX so the right Apache can be located!])
241         fi
242     elif test ! -d "$APXS_PREFIX"; then
243         AC_MSG_ERROR([APXS_PREFIX of $APXS_PREFIX cannot be found])
244     fi
245     AC_MSG_NOTICE([APXS_PREFIX is $APXS_PREFIX])
246     
247
248     # other subfolders might be derived from APXS_PREFIX
249     if test -z "$APXS_INCLUDE"; then
250         if test -f "$APXS_PREFIX/include/httpd.h"; then
251             APXS_INCLUDE="$APXS_PREFIX/include"
252         else
253             AC_MSG_ERROR([can't find Apache include files beneath $APXS_PREFIX])
254         fi
255     elif ! test -f "$APXS_INCLUDE/httpd.h"; then
256         AC_MSG_ERROR([APXS_INCLUDE of $APXS_INCLUDE does not contain Apache headers])
257     fi
258     AC_MSG_NOTICE([APXS_INCLUDE is $APXS_INCLUDE])
259
260     if test -z "$APXS_LIBEXEC"; then
261         if test -d "$APXS_PREFIX/libexec"; then
262             APXS_LIBEXEC="$APXS_PREFIX/libexec"
263         elif test -d "$APXS_PREFIX/modules"; then
264             APXS_LIBEXEC="$APXS_PREFIX/modules"
265         else
266             AC_MSG_ERROR([can't find Apache libexec/module directory beneath $APXS_PREFIX])
267         fi
268     elif ! test -d "$APXS_LIBEXEC"; then
269         AC_MSG_ERROR([APXS_LIBEXEC of $APXS_LIBEXEC does not exist])
270     fi
271     AC_MSG_NOTICE([APXS_LIBEXEC is $APXS_LIBEXEC])
272
273     if test -z "$APXS_SYSCONFDIR"; then
274         if test -d "$APXS_PREFIX/conf"; then
275             APXS_SYSCONFDIR="$APXS_PREFIX/conf"
276         else
277             AC_MSG_ERROR([can't find Apache conf directory beneath $APXS_PREFIX])
278         fi
279     elif ! test -d "$APXS_SYSCONFDIR"; then
280         AC_MSG_ERROR([APXS_SYSCONFDIR of $APXS_SYSCONFDIR does not exist])
281     fi
282     AC_MSG_NOTICE([APXS_SYSCONFDIR is $APXS_SYSCONFDIR])
283
284     WANT_APACHE="yes"
285
286 elif test -n "$APXS"; then
287
288     # extract settings we need from APXS -q
289     APXS_CC="`$APXS -q CC`"
290     APXS_CFLAGS="`$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
291     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
292     APXS_LIBEXEC="`$APXS -q LIBEXECDIR`"
293     APXS_SYSCONFDIR="`$APXS -q SYSCONFDIR`"
294
295     AC_SUBST(APXS)
296     AC_MSG_RESULT(found at $APXS)
297
298     if test -z "`$APXS -q LD_SHLIB`" || test "$APXS_LIBEXEC" = "modules"; then
299             AC_MSG_ERROR(
300 [Your APXS installation is broken and cannot be used.
301     Please see http://www.webdav.org/mod_dav/install.html#apxs for
302     more information.])
303     fi
304
305     WANT_APACHE="yes"
306
307 else
308     # guess we're not doing Apache 1.3
309     AC_MSG_RESULT(no)
310     WANT_APACHE="no"
311 fi
312
313 fi
314
315 AM_CONDITIONAL(HAVE_APXS,test -n "$APXS")
316
317 if test "$WANT_APACHE" = "yes"; then
318     AC_ARG_WITH(apreq,
319                 AC_HELP_STRING([--with-apreq=PATH], [where libapreq is installed]),
320                 [if test x_$with_apreq != x_/usr; then
321                     LDFLAGS="-L${with_apreq}/lib $LDFLAGS"
322                     CPPFLAGS="-I${with_apreq}/include $CPPFLAGS"
323                 fi])
324
325     saved_CPPFLAGS="$CPPFLAGS"
326     CPPFLAGS="-I$APXS_INCLUDE $APXS_CFLAGS $CPPFLAGS"
327     AC_TRY_COMPILE([#include <libapreq/apache_request.h>],
328                    [int i=0],
329                    test_apreq="yes",test_apreq="no")
330     if test "$test_apreq" = "no"; then
331         CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
332         APXS_CFLAGS="$APXS_CFLAGS -U_XOPEN_SOURCE"
333         AC_CHECK_HEADER([libapreq/apache_request.h],,
334             AC_MSG_ERROR([unable to find a usable libapreq header]))
335     fi
336
337 dnl    saved_LIBS="$LIBS"
338 dnl    LIBS="-lapreq $LIBS"
339 dnl    AC_TRY_LINK(
340 dnl        [#include <libapreq/apache_request.h>],
341 dnl        [ApacheRequest_expires],
342 dnl        [AC_DEFINE(HAVE_APREQ,1,[Define if apreq library was found])],
343 dnl        [AC_MSG_ERROR([unable to link with apreq])
344 dnl        ])
345 dnl    LIBS="$saved_LIBS"
346     CPPFLAGS="$saved_CPPFLAGS"
347
348     AC_ARG_ENABLE([apxs-install],
349         AC_HELP_STRING([--enable-apxs-install],
350                         [use apxs to install the apache modules]),
351         APXS_INSTALL="yes", )
352
353
354     AC_SUBST(APXS_CFLAGS)
355     AC_SUBST(APXS_INCLUDE)
356     AC_SUBST(APXS_LIBEXEC)
357     AC_SUBST(APXS_SYSCONFDIR)
358
359     # output the Apache 1.3 makefiles
360     WANT_SUBDIRS="$WANT_SUBDIRS mod_shire mod_shibrm"
361 fi
362 # always output the Makefile, even if we don't use it
363 AC_CONFIG_FILES([mod_shire/Makefile mod_shibrm/Makefile])
364
365 AM_CONDITIONAL(DO_APXS_INSTALL,test -n "$APXS_INSTALL")
366
367 #
368 # Implement the checks of the MySQL Credential Cache
369 #
370 # 1) Assume the user wants MySQL; if it's not found then just continue without
371 # 2) If the user specifically requested Mysql, look for it and ERROR if not found
372 # 3) If the user specifically requested no-mysql, don't build it.
373 #
374
375 AC_CONFIG_FILES([shib-mysql-ccache/Makefile])
376
377 # determine whether we should enable the mysql ccache
378 AC_ARG_ENABLE([mysql],
379         AC_HELP_STRING([--disable-mysql], [disable the MySQL Credential Cache]),
380         [mysql_enabled=$enableval], [mysql_enabled=default])
381
382 if test "x$mysql_enabled" = "x" ; then
383    mysql_enabled=yes
384 fi
385
386 # Are we trying to build MySQL?
387 AC_MSG_CHECKING(whether to build the MySQL ccache)
388 if test "$mysql_enabled" = "yes" ; then
389    build_mysql=yes
390    AC_MSG_RESULT(yes)
391 elif test "$mysql_enabled" = "default" ; then
392    build_mysql=yes
393    AC_MSG_RESULT([yes, if it can be found])
394 else
395    build_mysql=no
396    AC_MSG_RESULT(no)
397 fi
398
399 # If we're trying to build MySQL, try to find the mysql_config program,
400 # verify we've got mysql >= 4, and make sure we can build with mysqld
401 if test "$build_mysql" = "yes" ; then
402    mysql_dir=""
403    AC_ARG_WITH(mysql,
404         AC_HELP_STRING([--with-mysql=PATH], [directory where mysql is installed]),
405             [if test "$with_mysql" = no ; then
406                AC_MSG_ERROR([Try running --disable-mysql instead.])
407              elif test "$with_mysql" != yes ; then
408                mysql_dir="$with_mysql/bin"
409              fi ])
410
411    # Try to find the mysql_config program
412    AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no, $mysql_dir $PATH )
413
414    if test "$MYSQL_CONFIG" = no ; then
415       if test "$mysql_enabled" = "yes" ; then
416         AC_MSG_ERROR(Cannot find mysql_config)
417       else
418         AC_MSG_WARN(MySQL not found.  skipping.)
419       fi
420    fi
421 fi
422
423 # if we found mysql_config then build_mysql is 'yes'
424 if test "$MYSQL_CONFIG" != no ; then
425    AC_MSG_CHECKING(for mysql version >= 4)
426    mysql_version=`$MYSQL_CONFIG --version`
427    mysql_major_version=`echo $mysql_version | awk -F. '{print $1}'`
428    mysql_version_ok=yes
429    if test $mysql_major_version -lt 4 ; then
430      mysql_version_ok=no
431      if test "$mysql_enabled" = "yes" ; then
432        AC_MSG_ERROR(You need MySQL version >= 4, found $mysql_version)
433      fi
434      AC_MSG_RESULT(no.. skipping MySQL)
435    else
436      AC_MSG_RESULT(yes)
437    fi
438 fi
439
440 # if mysql_version_ok is 'yes', then we've made it this far.. ;)
441 if test "$mysql_version_ok" = "yes" ; then
442    AC_MSG_CHECKING(for embedded-MySQL libraries)
443    MYSQL_LIBS=`$MYSQL_CONFIG --libmysqld-libs`
444    if test $? != 0 ; then
445       found_mysql=no
446       if test "$mysql_enabled" = "yes" ; then
447         AC_MSG_ERROR(Could not find the MySQL Embedded-server libraries.)
448       else
449         AC_MSG_RESULT(no.. skipping MySQL)
450       fi
451    else
452       found_mysql=yes
453       AC_MSG_RESULT(yes)
454    fi
455 fi
456
457 # if found_mysql=yes then test that we can actually build mysql
458 if test "$found_mysql" = yes ; then
459    MYSQL_CFLAGS=`$MYSQL_CONFIG --cflags`
460    MYSQL_CFLAGS=`eval echo $MYSQL_CFLAGS`
461    MYSQL_LIBS=`eval echo $MYSQL_LIBS`
462
463    save_CPPFLAGS="$CPPFLAGS"
464    CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
465
466    AC_CHECK_HEADER([mysql.h], [have_mysql_h=yes], [have_mysql_h=no])
467    if test "$have_mysql_h" = no -a "$mysql_enabled" = "yes" ; then
468      AC_MSG_ERROR(unable to find MySQL header files)
469    fi
470
471    if test "$have_mysql_h" = yes ; then
472       save_LIBS="$LIBS"
473       LIBS="$LIBS $MYSQL_LIBS"
474       AC_MSG_CHECKING(if we can link againt mysql)
475       AC_TRY_LINK(
476         [#include <mysql.h>],
477         [mysql_server_init(0, NULL, NULL)],
478         [have_mysql_libs=yes],
479         [have_mysql_libs=no])
480       LIBS="$save_LIBS"
481
482       if test "$have_mysql_libs" = no ; then
483          if "$mysql_enabled" = "yes" ; then
484             AC_MSG_ERROR([unable to link with MySQL Embedded Server Library])
485          else
486             AC_MSG_RESULT(no.  skipping MySQL)
487          fi
488       fi
489    fi
490
491    CPPFLAGS="$save_CPPFLAGS"
492 fi
493
494 # if have_mysql_libs=yes then go ahead with building MySQL
495 if test "$have_mysql_libs" = yes ; then
496    # this AC_MSG_RESULT is from above!
497    AC_MSG_RESULT(yes)
498    WANT_SUBDIRS="$WANT_SUBDIRS shib-mysql-ccache"
499    AC_SUBST(MYSQL_CFLAGS)
500    AC_SUBST(MYSQL_LIBS)
501 fi
502
503
504 AC_SUBST(WANT_SUBDIRS)
505
506 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
507   echo "=================================================================="
508   echo "WARNING: You have chosen to compile Apache modules with a different"
509   echo "         compiler than the one used to compile Apache."
510   echo ""
511   echo "    Current compiler:      $CC"
512   echo "   Apache's compiler:      $APXS_CC"
513   echo ""
514   echo "This could cause some problems."
515   echo "=================================================================="
516 fi
517
518 AC_OUTPUT
519