doxygen autotools integration
[shibboleth/cpp-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(acx_pthread.m4)
8 sinclude(doxygen.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 -Wall -g -D_DEBUG"
27     GCC_CXXFLAGS="$CXXFLAGS -Wall -g -D_DEBUG"
28 else
29     GCC_CFLAGS="$CFLAGS -Wall -O2 -DNDEBUG"
30     GCC_CXXFLAGS="$CXXFLAGS -Wall -O2 -DNDEBUG"
31 fi
32
33 AC_PROG_CC([gcc gcc3 cc])
34 AC_PROG_CXX([g++ g++3 c++ CC])
35
36 if test "$GCC" = "yes" ; then
37     CFLAGS="$GCC_CFLAGS"
38     CXXFLAGS="$GCC_CXXFLAGS"
39 fi
40
41 AC_DISABLE_STATIC
42 AC_PROG_LIBTOOL
43
44 AC_LANG(C++)
45
46 # C++ requirements
47 AC_CXX_REQUIRE_STL
48 AC_CXX_NAMESPACES
49
50 AC_LANG(C)
51
52 # checks for pthreads
53 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
54 if test $enable_threads != "pthread"; then
55     AC_MSG_ERROR([unable to find pthreads, currently this is required])
56 else
57     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
58     LIBS="$PTHREAD_LIBS $LIBS"
59     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
60     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
61 fi
62
63 # Checks for typedefs, structures, and compiler characteristics.
64 AC_C_CONST
65 AC_TYPE_SIZE_T
66 AC_STRUCT_TM
67 AC_STRUCT_TIMEZONE
68
69 # Checks for library functions.
70 AC_FUNC_STRFTIME
71 AC_CHECK_FUNCS([strchr strdup strstr gmtime_r timegm])
72 AC_CHECK_HEADERS([dlfcn.h])
73
74 # OpenSSL settings
75 AC_PATH_PROG(PKG_CONFIG, pkg-config)
76 if test "x$PKG_CONFIG" = x || test "x$PKG_CONFIG" = "xno" ; then
77     AC_ARG_WITH(openssl, 
78             AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
79             [if test x_$with_openssl != x_/usr; then
80                 SSLLIBS="-L${with_openssl}/lib"
81                 SSLFLAGS="-I${with_openssl}/include"
82             fi])
83     SSLLIBS="$SSLLIBS -lssl -lcrypto"
84 else
85     SSLLIBS="`$PKG_CONFIG --libs openssl`"
86     SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
87 fi
88 AC_MSG_CHECKING(for OpenSSL libraries)
89 AC_MSG_RESULT($SSLLIBS)
90 LIBS="$LIBS $SSLLIBS"
91 AC_MSG_CHECKING(for OpenSSL cflags)
92 AC_MSG_RESULT($SSLFLAGS)
93 CPPFLAGS="$SSLFLAGS $CPPFLAGS"
94
95 AC_CHECK_HEADER([openssl/ssl.h],,
96                 AC_MSG_ERROR([unable to find openssl header files]))
97 AC_MSG_CHECKING(for ERR_load_CRYPTO_string)
98 AC_TRY_LINK_FUNC([ERR_load_CRYPTO_strings],,
99              AC_MSG_ERROR([unable to link with openssl libraries]))
100 AC_MSG_RESULT(yes)
101 AC_MSG_CHECKING(for SSL_library_init)
102 AC_TRY_LINK_FUNC([SSL_library_init],, 
103              AC_MSG_ERROR([unable to link with openssl libraries]))
104 AC_MSG_RESULT(yes)
105
106 # libcurl settings
107 AC_PATH_PROG(CURL_CONFIG,curl-config)
108 AC_ARG_WITH(curl,
109             AC_HELP_STRING([--with-curl=PATH], [where libcurl is installed]),
110             [CURL_CONFIG="${with_curl}/bin/curl-config"])
111 if test -f "${CURL_CONFIG}"; then
112     LDFLAGS="`${CURL_CONFIG} --libs` $LDFLAGS"
113     CPPFLAGS="`${CURL_CONFIG} --cflags` $CPPFLAGS"
114 else
115     AC_MSG_WARN([curl-config not found, guessing at libcurl build settings])
116 fi
117 AC_CHECK_HEADER([curl/curl.h],,AC_MSG_ERROR([unable to find libcurl header files]))
118 AC_CHECK_LIB([curl],[curl_global_init],,AC_MSG_ERROR([unable to link with libcurl]))
119 AC_MSG_CHECKING([for CURLOPT_SSL_CTX_FUNCTION in curl.h])
120 AC_EGREP_HEADER([CURLOPT_SSL_CTX_FUNCTION], [curl/curl.h],
121                 [AC_MSG_RESULT(yes)],
122                 [AC_MSG_ERROR([need libcurl that supports CURLOPT_SSL_CTX_FUNCTION])])
123
124 AC_LANG(C++)
125
126 # log4cpp settings
127 AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
128 AC_ARG_WITH(log4cpp,
129             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp is installed]),
130             [LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"])
131 if test -f "${LOG4CPP_CONFIG}"; then
132     LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
133     CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
134 else
135     AC_MSG_WARN([log4cpp-config not found, guessing at log4cpp build settings])
136     LIBS="-llog4cpp $LIBS"
137 fi
138 AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
139 AC_CHECK_HEADER([log4cpp/PropertyConfigurator.hh],,AC_MSG_ERROR([you need at least log4cpp 0.3.x]))
140 AC_TRY_LINK(
141         [#include <log4cpp/Category.hh>],
142         [log4cpp::Category::getInstance("foo")],
143         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
144         [AC_MSG_ERROR([unable to link with log4cpp])])
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 special 2.6.1 tarball provided by Shibboleth Project])])
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     if test x_$with_xmlsec != x_/usr; then
179         LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
180         CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
181     fi        
182     LIBS="-lxml-security-c $LIBS"
183     AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
184     AC_MSG_CHECKING([XML-Security version])
185     AC_PREPROC_IFELSE(
186             [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
187         [#if XSEC_VERSION_MAJOR > 1 || XSEC_VERSION_MEDIUM >2 
188 int i = 0;
189 #else
190 #error need version 1.3 or later
191 #endif])],
192         [AC_MSG_RESULT(OK)],
193         [AC_MSG_FAILURE([XML-Security version 1.3 or greater is required.])])
194     AC_TRY_LINK(
195             [#include <xsec/utils/XSECPlatformUtils.hpp>],
196             [XSECPlatformUtils::Initialise()],,
197             [AC_MSG_ERROR([unable to link with XML-Sec])])
198 else
199     AC_MSG_WARN([xmlsec disabled, building without signature/encryption support])
200     AC_DEFINE(XMLTOOLING_NO_XMLSEC,1,
201         [Define if you wish to disable XML-Security-dependent features.])
202 fi
203 AM_CONDITIONAL(BUILD_XMLSEC,test x_$with_xmlsec != x_no)
204
205 # Does the STL in use help or screw us?
206 AC_TRY_LINK(
207         [#include <string>],
208         [std::basic_string<unsigned short> foo; foo=foo+(unsigned short)65],
209         [AC_DEFINE(HAVE_GOOD_STL,1,
210             [Define if you have an STL implementation that supports useful string specialization.])],
211         )
212
213 # Check for unit test support
214 CXXTEST="/usr/bin/cxxtestgen.pl"
215 CXXTESTFLAGS=""
216 AC_ARG_WITH(cxxtest,
217             AC_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
218             [if test x_$with_cxxtest != x_/usr; then
219                 CXXTEST="${with_cxxtest}/cxxtestgen.pl"
220                 CXXTESTFLAGS="-I${with_cxxtest}"
221             fi])
222 if ! test -f "${CXXTEST}"; then
223     AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
224 fi
225
226 AC_SUBST(CXXTEST)
227 AC_SUBST(CXXTESTFLAGS)
228 AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
229
230 LIBTOOL="$LIBTOOL --silent"
231
232 # output makefiles
233 AC_OUTPUT(Makefile xmltooling/Makefile xmltoolingtest/Makefile schemas/Makefile)