Re-port RPC library to Solaris
[shibboleth/sp.git] / configure.ac
1 dnl $Id$ 
2
3 AC_PREREQ([2.50])
4 AC_INIT([shibboleth], [0.1], [mace-shib-users@internet2.edu], [shibboleth])
5 AM_CONFIG_HEADER(config.h)
6 AM_INIT_AUTOMAKE(shibboleth, 0.1)
7
8 sinclude(acx_pthread.m4)
9 sinclude(acx_rpctest.m4)
10
11 AC_PROG_CC([gcc3 gcc cc])
12 AC_PROG_CXX([g++3 g++ c++ CC])
13 AC_DISABLE_STATIC
14 AC_PROG_LIBTOOL
15
16 AC_LANG(C++)
17
18 # Checks for typedefs, structures, and compiler characteristics.
19 AC_C_CONST
20 AC_TYPE_SIZE_T
21 AC_STRUCT_TM
22
23 # Checks for library functions.
24 AC_FUNC_STRFTIME
25 AC_CHECK_FUNCS([strchr strdup strstr gmtime_r])
26 AC_CHECK_HEADERS([dlfcn.h])
27
28 # C++ requirements
29 AC_CXX_REQUIRE_STL
30 AC_CXX_NAMESPACES
31
32
33 old_LIBS="$LIBS"
34 AC_SEARCH_LIBS(xdr_uint64_t,nsl,,
35         [CFLAGS="$CFLAGS -DNEED_XDR_LONGLONG"
36          CXXFLAGS="$CXXFLAGS -DNEED_XDR_LONGLONG"])
37 LIBS="$old_LIBS"
38
39 # checks for pthreads
40 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
41 if test $enable_threads != "pthread"; then
42     AC_MSG_ERROR([unable to find pthreads, currently this is required])
43 else
44     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
45     LIBS="$PTHREAD_LIBS $LIBS"
46     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
47     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
48 fi
49
50 AC_ARG_WITH(dmalloc,
51             AC_HELP_STRING([--with-dmalloc=PATH], [where dmalloc is installed]),
52             [if test x_$with_dmalloc != x_/usr; then
53                 LDFLAGS="-L${with_dmalloc}/lib $LDFLAGS"
54                 CPPFLAGS="-I${with_dmalloc}/include $CPPFLAGS"
55             fi
56             AC_CHECK_LIB(dmallocxx, dmalloc_shutdown,,
57                          AC_MSG_ERROR([unable to find dmallocxx library]))
58             ])
59
60 AC_ARG_WITH(xerces, 
61             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
62             [if test x_$with_xerces != x_/usr; then
63                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
64                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
65             fi])
66
67
68 AC_ARG_WITH(openssl, 
69             AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
70             [if test x_$with_openssl != x_/usr; then
71                 LDFLAGS="-L${with_openssl}/lib $LDFLAGS"
72                 CPPFLAGS="-I${with_openssl}/include $CPPFLAGS"
73             fi])
74
75 AC_ARG_WITH(log4cpp, 
76             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp is installed]),
77             [if test x_$with_log4cpp != x_/usr; then
78                 LDFLAGS="-L${with_log4cpp}/lib $LDFLAGS"
79                 CPPFLAGS="-I${with_log4cpp}/include $CPPFLAGS"
80             fi])
81
82 AC_ARG_WITH(xmlsec,
83             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),
84             [if test -f "${with_xmlsec}/bin/xmlsec-config"; then
85                 LDFLAGS="`${with_xmlsec}/bin/xmlsec-config --libs` $LDFLAGS"
86                 CPPFLAGS="`${with_xmlsec}/bin/xmlsec-config --cflags` $CPPFLAGS"
87             fi])
88
89 AC_ARG_WITH(saml,
90             AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
91             [if test x_$with_saml != x_/usr; then
92                 LDFLAGS="-L${with_saml}/lib $LDFLAGS"
93                 CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
94             fi])
95
96 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
97                 AC_MSG_ERROR([unable to find xerces header files]))
98 saved_LIBS="$LIBS"
99 LIBS="-lxerces-c $LIBS"
100 AC_TRY_LINK(
101         [#include <xercesc/util/PlatformUtils.hpp>],
102         [XMLPlatformUtils::Initialize()],
103         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
104         [AC_MSG_ERROR([unable to link with Xerces])
105                 LIBS="$saved_LIBS"
106         ])
107
108 AC_CHECK_HEADER([openssl/ssl.h],,
109                 AC_MSG_ERROR([unable to find openssl header files]))
110 AC_CHECK_LIB([crypto], [ERR_load_CRYPTO_strings],,
111              AC_MSG_ERROR([unable to link with openssl libraries]))
112 AC_CHECK_LIB([ssl], [SSL_library_init],, 
113              AC_MSG_ERROR([unable to link with openssl libraries]))
114
115 AC_CHECK_HEADER([libxml/parser.h],,
116                 AC_MSG_ERROR([unable to find libxml2 header files]))
117 AC_CHECK_LIB([xml2], [xmlInitParser],echo "foo" > /dev/null,
118              AC_MSG_ERROR([unable to link with libxml2]))
119
120 AC_CHECK_HEADER([xmlsec/xmlsec.h],,
121                 AC_MSG_ERROR([unable to find xmlsec header files]))
122 AC_CHECK_LIB([xmlsec], [xmlSecInit],echo "foo" > /dev/null,
123              AC_MSG_ERROR([unable to link with xmlsec]))
124
125 AC_CHECK_HEADER([log4cpp/Category.hh],,
126                 AC_MSG_ERROR([unable to find log4cpp header files]))
127
128 AC_CHECK_HEADER([saml/saml.h],,
129                 AC_MSG_ERROR([unable to find saml header files]))
130
131 saved_LIBS="$LIBS"
132 LIBS="-llog4cpp $LIBS"
133 AC_TRY_LINK(
134         [#include <log4cpp/Category.hh>],
135         [log4cpp::Category::getInstance("foo")],
136         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
137         [AC_MSG_ERROR([unable to link with log4cpp])
138                 LIBS="$saved_LIBS"
139         ])
140
141 saved_LIBS="$LIBS"
142 LIBS="-lsaml $LIBS"
143 AC_TRY_LINK(
144         [#include <saml/saml.h>],
145         [saml::SAMLConfig::getConfig()],
146         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
147         [AC_MSG_ERROR([unable to link with saml])
148                 LIBS="$saved_LIBS"
149         ])
150
151 # output the underlying makefiles
152 WANT_SUBDIRS="shib schemas configs eduPerson shib-target shar test"
153 AC_CONFIG_FILES([Makefile shib/Makefile schemas/Makefile eduPerson/Makefile \
154                  configs/Makefile oncrpc/Makefile oncrpc/rpc/Makefile \
155                  shib-target/Makefile shar/Makefile test/Makefile])
156
157 # now test the rpc library, to see if we need to build our own
158 ACX_RPCTEST([rpctest="yes"],[rpctest="no"])
159 if test $rpctest = "no"; then
160     WANT_SUBDIRS="oncrpc $WANT_SUBDIRS"
161     AM_CONDITIONAL(USE_OUR_ONCRPC,test "$rpctest" = "no")
162 fi
163
164 # Much of this is taken from mod_dav.
165 # The basic idea is to use configure options to control whether/which types
166 # of web server modules get built. We assume there may eventually be multiple
167 # types (Apache 1/2, iPlanet, others).
168
169 # Apache 1.3 (mod_shire/mod_shibrm)
170 #   --with-apache   (static build, no idea how to do this yet, so not supported)
171 #   --with-apxs     (DSO build, the normal way, uses apxs to derive build flags)
172 #   --without-apxs  (DSO build, you tell us how to build using the environment)
173
174 AC_MSG_CHECKING([for dynamic Apache module support (w/ or w/o APXS)])
175 AC_ARG_WITH(apxs,
176 [  --with-apxs[=FILE]        Build shared Apache module(s). FILE is the optional
177                           pathname to the Apache apxs tool; defaults to "apxs".],
178 [
179     if test "$withval" = "yes"; then
180       for i in /usr/sbin /usr/local/apache/bin ; do
181         if test -f "$i/apxs"; then
182           APXS="$i/apxs"
183         fi
184       done
185       if test -z "$APXS"; then
186         APXS=apxs
187       fi
188     else
189       APXS="$withval"
190     fi
191 ])
192
193 if test "$APXS" = "no"; then
194
195     # --without-apxs means you want the modules,
196     #       but want to tell us how to build them
197     AC_MSG_RESULT(yes, but use environment, not apxs)
198     echo
199     echo "Did you set one or more of these?"
200     echo
201     echo "APXS_CFLAGS APXS_PREFIX APXS_INCLUDE APXS_LIBEXEC APXS_SYSCONFDIR"
202     echo
203
204     AC_MSG_NOTICE([APXS_CFLAGS is $APXS_CFLAGS])
205
206     # try and find the Apache root
207     if test -z "$APXS_PREFIX"; then
208         if test -d "/usr/local/apache"; then
209             APXS_PREFIX="/usr/local/apache"
210         else
211             AC_MSG_ERROR([You MUST set APXS_PREFIX so the right Apache can be located!])
212         fi
213     elif test ! -d "$APXS_PREFIX"; then
214         AC_MSG_ERROR([APXS_PREFIX of $APXS_PREFIX cannot be found])
215     fi
216     AC_MSG_NOTICE([APXS_PREFIX is $APXS_PREFIX])
217     
218
219     # other subfolders might be derived from APXS_PREFIX
220     if test -z "$APXS_INCLUDE"; then
221         if test -f "$APXS_PREFIX/include/httpd.h"; then
222             APXS_INCLUDE="$APXS_PREFIX/include"
223         else
224             AC_MSG_ERROR([can't find Apache include files beneath $APXS_PREFIX])
225         fi
226     elif ! test -f "$APXS_INCLUDE/httpd.h"; then
227         AC_MSG_ERROR([APXS_INCLUDE of $APXS_INCLUDE does not contain Apache headers])
228     fi
229     AC_MSG_NOTICE([APXS_INCLUDE is $APXS_INCLUDE])
230
231     if test -z "$APXS_LIBEXEC"; then
232         if test -d "$APXS_PREFIX/libexec"; then
233             APXS_LIBEXEC="$APXS_PREFIX/libexec"
234         elif test -d "$APXS_PREFIX/modules"; then
235             APXS_LIBEXEC="$APXS_PREFIX/modules"
236         else
237             AC_MSG_ERROR([can't find Apache libexec/module directory beneath $APXS_PREFIX])
238         fi
239     elif ! test -d "$APXS_LIBEXEC"; then
240         AC_MSG_ERROR([APXS_LIBEXEC of $APXS_LIBEXEC does not exist])
241     fi
242     AC_MSG_NOTICE([APXS_LIBEXEC is $APXS_LIBEXEC])
243
244     if test -z "$APXS_SYSCONFDIR"; then
245         if test -d "$APXS_PREFIX/conf"; then
246             APXS_SYSCONFDIR="$APXS_PREFIX/conf"
247         else
248             AC_MSG_ERROR([can't find Apache conf directory beneath $APXS_PREFIX])
249         fi
250     elif ! test -d "$APXS_SYSCONFDIR"; then
251         AC_MSG_ERROR([APXS_SYSCONFDIR of $APXS_SYSCONFDIR does not exist])
252     fi
253     AC_MSG_NOTICE([APXS_SYSCONFDIR is $APXS_SYSCONFDIR])
254
255     WANT_APACHE="yes"
256
257 elif test -n "$APXS"; then
258
259     # extract settings we need from APXS -q
260     APXS_CC="`$APXS -q CC`"
261     APXS_CFLAGS="`$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
262     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
263     APXS_LIBEXEC="`$APXS -q LIBEXECDIR`"
264     APXS_SYSCONFDIR="`$APXS -q SYSCONFDIR`"
265
266     AC_SUBST(APXS)
267     AC_MSG_RESULT(found at $APXS)
268
269     if test -z "`$APXS -q LD_SHLIB`" || test "$APXS_LIBEXEC" = "modules"; then
270             AC_MSG_ERROR(
271 [Your APXS installation is broken and cannot be used.
272     Please see http://www.webdav.org/mod_dav/install.html#apxs for
273     more information.])
274     fi
275
276     WANT_APACHE="yes"
277
278 else
279     # guess we're not doing Apache 1.3
280     AC_MSG_RESULT(no)
281     WANT_APACHE="no"
282 fi
283
284 AM_CONDITIONAL(HAVE_APXS,test -n "$APXS")
285
286 if test "$WANT_APACHE" = "yes"; then
287     AC_ARG_WITH(apreq,
288                 AC_HELP_STRING([--with-apreq=PATH], [where libapreq is installed]),
289                 [if test x_$with_apreq != x_/usr; then
290                     LDFLAGS="-L${with_apreq}/lib $LDFLAGS"
291                     CPPFLAGS="-I${with_apreq}/include $CPPFLAGS"
292                 fi])
293
294     saved_CPPFLAGS="$CPPFLAGS"
295     CPPFLAGS="-I$APXS_INCLUDE $APXS_CFLAGS $CPPFLAGS"
296     AC_CHECK_HEADER([libapreq/apache_request.h],,
297                 AC_MSG_ERROR([unable to find apreq header files]))
298
299 dnl    saved_LIBS="$LIBS"
300 dnl    LIBS="-lapreq $LIBS"
301 dnl    AC_TRY_LINK(
302 dnl        [#include <libapreq/apache_request.h>],
303 dnl        [ApacheRequest_expires],
304 dnl        [AC_DEFINE(HAVE_APREQ,1,[Define if apreq library was found])],
305 dnl        [AC_MSG_ERROR([unable to link with apreq])
306 dnl        ])
307 dnl    LIBS="$saved_LIBS"
308     CPPFLAGS="$saved_CPPFLAGS"
309
310     AC_ARG_ENABLE([apxs-install],
311         AC_HELP_STRING([--enable-apxs-install],
312                         [use apxs to install the apache modules]),
313         APXS_INSTALL="yes", )
314
315
316     AC_SUBST(APXS_CFLAGS)
317     AC_SUBST(APXS_INCLUDE)
318     AC_SUBST(APXS_LIBEXEC)
319     AC_SUBST(APXS_SYSCONFDIR)
320
321     # output the Apache 1.3 makefiles
322     WANT_SUBDIRS="$WANT_SUBDIRS mod_shire mod_shibrm"
323     AC_CONFIG_FILES([mod_shire/Makefile mod_shibrm/Makefile])
324 fi
325
326 AM_CONDITIONAL(DO_APXS_INSTALL,test -n "$APXS_INSTALL")
327
328 AC_SUBST(WANT_SUBDIRS)
329
330 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
331   echo "=================================================================="
332   echo "WARNING: You have chosen to compile Apache modules with a different"
333   echo "         compiler than the one used to compile Apache."
334   echo ""
335   echo "    Current compiler:      $CC"
336   echo "   Apache's compiler:      $APXS_CC"
337   echo ""
338   echo "This could cause some problems."
339   echo "=================================================================="
340 fi
341
342 AC_OUTPUT
343