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