Package fixes.
[shibboleth/xmltooling.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([xmltooling], [1.0], [mace-opensaml-users@internet2.edu], [xmltooling])
3 AM_CONFIG_HEADER(config.h)
4 AM_CONFIG_HEADER(xmltooling/config_pub.h)
5 AM_INIT_AUTOMAKE([xmltooling], [1.0])
6
7 sinclude(doxygen.m4)
8 sinclude(acx_pthread.m4)
9
10 # Docygen features
11 DX_HTML_FEATURE(ON)
12 DX_CHM_FEATURE(OFF)
13 DX_CHI_FEATURE(OFF)
14 DX_MAN_FEATURE(OFF)
15 DX_RTF_FEATURE(OFF)
16 DX_XML_FEATURE(OFF)
17 DX_PDF_FEATURE(OFF)
18 DX_PS_FEATURE(OFF)
19 DX_INIT_DOXYGEN(xmltooling, doxygen.cfg, doc/api)
20
21 AC_ARG_ENABLE(debug,
22     AC_HELP_STRING(--enable-debug, [Have GCC compile with symbols (Default = no)]),
23     enable_debug=$enableval, enable_debug=no)
24
25 if test "$enable_debug" = "yes" ; then
26     GCC_CFLAGS="$CFLAGS -g -D_DEBUG"
27     GCC_CXXFLAGS="$CXXFLAGS -g -D_DEBUG"
28 else
29     GCC_CFLAGS="$CFLAGS -O2 -DNDEBUG"
30     GCC_CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG"
31 fi
32
33 AC_PROG_CC([gcc gcc3 cc])
34 AC_PROG_CXX([g++ g++3 c++ CC])
35 AC_CANONICAL_HOST
36
37 if test "$GCC" = "yes" ; then
38 #    AC_HAVE_GCC_VERSION(4,0,0,0,
39 #        [
40 #        AC_DEFINE(GCC_HASCLASSVISIBILITY,1,
41 #            [Define to enable class visibility control in gcc.])
42 #        GCC_CFLAGS="$GCC_CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
43 #        GCC_CXXFLAGS="$GCC_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
44 #        ])
45     CFLAGS="-Wall $GCC_CFLAGS"
46     CXXFLAGS="-Wall $GCC_CXXFLAGS"
47 else
48 # Fix for Sun Workshop compiler in debug mode, may be Sun case #6360993
49         case "${host_cpu}-${host_os}" in
50                 *solaris*)
51                         if test "$CXX" = "CC" ; then
52                                 CXXFLAGS="$CXXFLAGS -Qoption ccfe -stabs=no%dfltlit+no%dflthlp"
53                         fi
54                 ;;
55         esac
56 fi
57
58 AC_DISABLE_STATIC
59 AC_PROG_LIBTOOL
60
61 # Checks for typedefs, structures, and compiler characteristics.
62 AC_C_CONST
63 AC_TYPE_SIZE_T
64
65 # Checks for library functions.
66 AC_CHECK_FUNCS([strchr strdup strstr timegm strcasecmp])
67 AC_CHECK_HEADERS([dlfcn.h])
68 AC_CHECK_FUNC(dlclose, , [ AC_CHECK_LIB(dl, dlopen) ])
69
70 # checks for pthreads
71 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
72 if test $enable_threads != "pthread"; then
73     AC_MSG_ERROR([unable to find pthreads, currently this is required])
74 else
75     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
76         AM_CONDITIONAL(BUILD_PTHREAD,test "$enable_threads" = "pthread")
77     LIBS="$PTHREAD_LIBS $LIBS"
78     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
79     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
80 fi
81
82 AC_CHECK_FUNCS([pthread_rwlock_init])
83
84 AC_LANG(C++)
85
86 # C++ requirements
87 AC_CXX_REQUIRE_STL
88 AC_CXX_NAMESPACES
89
90 # are covariant methods allowed?
91 AC_TRY_LINK(
92      [ class base { public: virtual base *GetPtr( void ) { return this; } }; ],
93      [ class derived: virtual public base { public: virtual derived *GetPtr( void ) { return this; } }; ],
94      [AC_DEFINE(HAVE_COVARIANT_RETURNS,1,[Define if C++ compiler supports covariant virtual methods.])])
95
96 # log4shib settings (favor this version over the log4cpp code)
97 AC_PATH_PROG(LOG4SHIB_CONFIG,log4shib-config)
98 AC_ARG_WITH(log4shib,
99     AC_HELP_STRING([--with-log4shib=PATH], [where log4shib-config is installed]),
100     [
101     LOG4SHIB_CONFIG="${with_log4shib}"
102     if ! test -f "${LOG4SHIB_CONFIG}" ; then
103         LOG4SHIB_CONFIG="${with_log4shib}/bin/log4shib-config"
104     fi
105     ])
106 if test -f "${LOG4SHIB_CONFIG}"; then
107     LDFLAGS="`${LOG4SHIB_CONFIG} --libs` $LDFLAGS"
108     CPPFLAGS="`${LOG4SHIB_CONFIG} --cflags` $CPPFLAGS"
109         AC_CHECK_HEADER([log4shib/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4shib header files]))
110         AC_TRY_LINK(
111                 [#include <log4shib/Category.hh>
112 #include <log4shib/CategoryStream.hh>],
113                 [log4shib::Category::getInstance("foo").errorStream() << log4shib::eol],
114                 [AC_DEFINE(XMLTOOLING_LOG4SHIB,1,[Define if log4shib library is used.])],
115                 [AC_MSG_ERROR([unable to link with log4shib])])
116 else
117     AC_MSG_WARN([log4shib-config not found, may need to use --with-log4shib option])
118     AC_MSG_WARN([will look for original log4cpp library])
119     
120         # log4cpp settings
121         AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
122         AC_ARG_WITH(log4cpp,
123             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
124             [
125             LOG4CPP_CONFIG="${with_log4cpp}"
126             if ! test -f "${LOG4CPP_CONFIG}" ; then
127                 LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
128             fi
129             ])
130         if test -f "${LOG4CPP_CONFIG}"; then
131                 AC_MSG_WARN([will try to use log4cpp, note that most non-Internet2 supplied versions are not thread-safe])
132             LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
133             CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
134                 AC_CHECK_HEADER([log4cpp/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
135                 AC_TRY_LINK(
136                         [#include <log4cpp/Category.hh>
137 #include <log4cpp/CategoryStream.hh>],
138                         [log4cpp::Category::getInstance("foo").errorStream() << log4cpp::eol],
139                         [AC_DEFINE(XMLTOOLING_LOG4CPP,1,[Define if log4cpp library is used.])],
140                         [AC_MSG_ERROR([unable to link with log4cpp, need version 1.0 or later])])
141         else
142             AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
143         fi
144 fi
145
146 # Xerces settings
147 AC_ARG_WITH(xerces, 
148             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
149             [if test x_$with_xerces != x_/usr; then
150                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
151                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
152             fi])
153 LIBS="-lxerces-c $LIBS"
154 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
155 AC_MSG_CHECKING([Xerces version])
156 AC_PREPROC_IFELSE(
157     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
158 [#if  _XERCES_VERSION != 20600
159 int i = 0;
160 #else
161 #error cannot use version 2.6.0
162 #endif])],
163     [AC_MSG_RESULT(OK)],
164     [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use a newer version])])
165 AC_TRY_LINK(
166         [#include <xercesc/util/PlatformUtils.hpp>],
167         [xercesc::XMLPlatformUtils::Initialize()],
168         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
169         [AC_MSG_ERROR([unable to link with Xerces])])
170
171
172 # XML-Security settings
173 AC_ARG_WITH(xmlsec,
174             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
175             [with_xmlsec=/usr])
176
177 if test x_$with_xmlsec != x_no; then
178
179     # OpenSSL settings (need to do this first in case it's in a different spot from xmlsec)
180     AC_ARG_WITH(openssl,
181         AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
182         [if test x_$with_openssl != x_/usr; then
183             SSLFLAGS="-I${with_openssl}/include"
184             SSLLIBS="-L${with_openssl}/lib -lcrypto -lssl"
185         else
186             SSLLIBS="-lcrypto -lssl"
187         fi])
188     
189     if test "x$SSLLIBS" = "x" ; then
190         AC_PATH_PROG(PKG_CONFIG, pkg-config)
191         if test "x$PKG_CONFIG" != x && test "x$PKG_CONFIG" != "xno" ; then
192             if pkg-config openssl ; then
193                 SSLLIBS="`$PKG_CONFIG --libs openssl`"
194                 SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
195             else
196                 AC_MSG_ERROR([OpenSSL not supported by pkg-config, try --with-openssl instead])
197             fi
198         fi
199     fi
200     
201     if test "x$SSLLIBS" = "x" ; then
202         SSLLIBS="-lcrypto -lssl"
203     fi
204     
205     AC_MSG_CHECKING(for OpenSSL cflags)
206     AC_MSG_RESULT($SSLFLAGS)
207     CPPFLAGS="$CPPFLAGS $SSLFLAGS"
208     AC_MSG_CHECKING(for OpenSSL libraries)
209     AC_MSG_RESULT($SSLLIBS)
210     XMLSEC_LIBS="$XMLSEC_LIBS $SSLLIBS"
211
212     # save and append master libs
213     save_LIBS="$LIBS"
214     LIBS="$XMLSEC_LIBS $LIBS"
215     
216     AC_CHECK_HEADER([openssl/pem.h],,
217                     AC_MSG_ERROR([unable to find openssl header files]))
218     AC_MSG_CHECKING(for ERR_load_CRYPTO_string)
219     AC_TRY_LINK_FUNC([ERR_load_CRYPTO_strings],,
220                  AC_MSG_ERROR([unable to link with openssl libraries]))
221     AC_MSG_RESULT(yes)
222
223     # restore master libs
224     LIBS="$save_LIBS"
225
226     if test x_$with_xmlsec != x_/usr; then
227         CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
228         LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
229     fi        
230     XMLSEC_LIBS="$XMLSEC_LIBS -lxml-security-c"
231     
232     # save and append master libs
233     save_LIBS="$LIBS"
234     LIBS="$XMLSEC_LIBS $LIBS"
235     
236     AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
237     AC_MSG_CHECKING([XML-Security version])
238     AC_PREPROC_IFELSE(
239             [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
240         [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3)
241 int i = 0;
242 #else
243 #error need version 1.4.0 or later
244 #endif])],
245         [AC_MSG_RESULT(OK)],
246         [AC_MSG_FAILURE([XML-Security version 1.4.0 or greater is required.])])
247     AC_TRY_LINK(
248             [#include <xsec/utils/XSECPlatformUtils.hpp>],
249             [XSECPlatformUtils::Initialise()],,
250             [AC_MSG_ERROR([unable to link with XML-Security])])
251
252         # restore master libs
253         LIBS="$save_LIBS"
254
255         # libcurl settings
256         AC_PATH_PROG(CURL_CONFIG,curl-config)
257         AC_ARG_WITH(curl,
258             AC_HELP_STRING([--with-curl=PATH], [where curl-config is installed]),
259             [
260             CURL_CONFIG="${with_curl}"
261             if ! test -f "${CURL_CONFIG}" ; then
262                 CURL_CONFIG="${with_curl}/bin/curl-config"
263             fi
264             ])
265         if test -f "${CURL_CONFIG}" ; then
266             CPPFLAGS="`${CURL_CONFIG} --cflags` $CPPFLAGS"
267             XMLSEC_LIBS="`${CURL_CONFIG} --libs` $XMLSEC_LIBS"
268         else
269             AC_MSG_ERROR([curl-config not found, may need to use --with-curl option])
270         fi
271
272         # save and append master libs
273         save_LIBS="$LIBS"
274         LIBS="$XMLSEC_LIBS $LIBS"
275         
276         AC_CHECK_HEADER([curl/curl.h],,AC_MSG_ERROR([unable to find libcurl header files]))
277         AC_CHECK_LIB([curl],[curl_global_init],,AC_MSG_ERROR([unable to link with libcurl]))
278         AC_MSG_CHECKING([for CURLOPT_SSL_CTX_FUNCTION in curl.h])
279         AC_EGREP_HEADER([CURLOPT_SSL_CTX_FUNCTION], [curl/curl.h],
280                         [AC_MSG_RESULT(yes)],
281                         [AC_MSG_ERROR([need libcurl that supports CURLOPT_SSL_CTX_FUNCTION])])
282
283         # restore master libs
284         LIBS="$save_LIBS"
285
286         AC_SUBST(XMLSEC_LIBS)
287 else
288     AC_MSG_WARN([xmlsec disabled, building without signature/encryption support])
289     AC_DEFINE(XMLTOOLING_NO_XMLSEC,1,
290         [Define if you wish to disable XML-Security-dependent features.])
291 fi
292 AM_CONDITIONAL(BUILD_XMLSEC,test x_$with_xmlsec != x_no)
293
294 # Does the STL in use help or screw us?
295 AC_TRY_LINK(
296         [#include <string>],
297         [std::basic_string<unsigned short> foo; foo=foo+(unsigned short)65],
298         [AC_DEFINE(HAVE_GOOD_STL,1,
299             [Define if you have an STL implementation that supports useful string specialization.])],
300         )
301 AC_TRY_LINK(
302         [#include <vector>],
303         [std::iterator_traits<std::vector<int>::iterator>::value_type foo=0],
304         [AC_DEFINE(HAVE_ITERATOR_TRAITS,1,
305             [Define to 1 if you have an STL implementation that supports std::iterator_traits.])],
306         )
307
308 # Check for unit test support
309 CXXTEST="/usr/bin/cxxtestgen.pl"
310 CXXTESTFLAGS=""
311 AC_ARG_WITH(cxxtest,
312             AC_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
313             [if test x_$with_cxxtest != x_/usr; then
314                 CXXTEST="${with_cxxtest}/cxxtestgen.pl"
315                 CXXTESTFLAGS="-I${with_cxxtest}"
316             fi])
317 if ! test -f "${CXXTEST}"; then
318     AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
319 fi
320
321 AC_SUBST(CXXTEST)
322 AC_SUBST(CXXTESTFLAGS)
323 AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
324
325 LIBTOOL="$LIBTOOL --silent"
326
327 # output makefiles
328 AC_OUTPUT(Makefile xmltooling/Makefile xmltoolingtest/Makefile schemas/Makefile doc/Makefile)