Threading support.
[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(doxygen.m4)
8
9 # Docygen features
10 DX_HTML_FEATURE(ON)
11 DX_CHM_FEATURE(OFF)
12 DX_CHI_FEATURE(OFF)
13 DX_MAN_FEATURE(OFF)
14 DX_RTF_FEATURE(OFF)
15 DX_XML_FEATURE(OFF)
16 DX_PDF_FEATURE(OFF)
17 DX_PS_FEATURE(OFF)
18 DX_INIT_DOXYGEN(xmltooling, doxygen.cfg, doc/api)
19
20 AC_ARG_ENABLE(debug,
21     AC_HELP_STRING(--enable-debug, [Have GCC compile with symbols (Default = no)]),
22     enable_debug=$enableval, enable_debug=no)
23
24 if test "$enable_debug" = "yes" ; then
25     GCC_CFLAGS="$CFLAGS -Wall -g -D_DEBUG"
26     GCC_CXXFLAGS="$CXXFLAGS -Wall -g -D_DEBUG"
27 else
28     GCC_CFLAGS="$CFLAGS -Wall -O2 -DNDEBUG"
29     GCC_CXXFLAGS="$CXXFLAGS -Wall -O2 -DNDEBUG"
30 fi
31
32 AC_PROG_CC([gcc gcc3 cc])
33 AC_PROG_CXX([g++ g++3 c++ CC])
34
35 if test "$GCC" = "yes" ; then
36 #    AC_HAVE_GCC_VERSION(4,0,0,0,
37 #        [
38 #        AC_DEFINE(GCC_HASCLASSVISIBILITY,1,
39 #            [Define to enable class visibility control in gcc.])
40 #        GCC_CFLAGS="$GCC_CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
41 #        GCC_CXXFLAGS="$GCC_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
42 #        ])
43     CFLAGS="$GCC_CFLAGS"
44     CXXFLAGS="$GCC_CXXFLAGS"
45 fi
46
47 AC_DISABLE_STATIC
48 AC_PROG_LIBTOOL
49
50 # Checks for typedefs, structures, and compiler characteristics.
51 AC_C_CONST
52 AC_TYPE_SIZE_T
53
54 # Checks for library functions.
55 AC_CHECK_FUNCS([strchr strdup strstr])
56 AC_CHECK_HEADERS([dlfcn.h])
57 AC_CHECK_FUNC(dlclose, , [ AC_CHECK_LIB(dl, dlopen) ])
58
59 # checks for pthreads
60 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
61 if test $enable_threads != "pthread"; then
62     AC_MSG_ERROR([unable to find pthreads, currently this is required])
63 else
64     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
65         AM_CONDITIONAL(BUILD_PTHREAD,test "$enable_threads" = "pthread")
66     LIBS="$PTHREAD_LIBS $LIBS"
67     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
68     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
69 fi
70
71 AC_LANG(C++)
72
73 # C++ requirements
74 AC_CXX_REQUIRE_STL
75 AC_CXX_NAMESPACES
76
77 # log4cpp settings
78 AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
79 AC_ARG_WITH(log4cpp,
80     AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
81     [
82     LOG4CPP_CONFIG="${with_log4cpp}"
83     if ! test -f "${LOG4CPP_CONFIG}" ; then
84         LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
85     fi
86     ])
87 if test -f "${LOG4CPP_CONFIG}"; then
88     LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
89     CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
90 else
91     AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
92     LIBS="-llog4cpp $LIBS"
93 fi
94 AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
95 AC_CHECK_HEADER([log4cpp/PropertyConfigurator.hh],,AC_MSG_ERROR([you need at least log4cpp 0.3.x]))
96 AC_TRY_LINK(
97         [#include <log4cpp/Category.hh>],
98         [log4cpp::Category::getInstance("foo")],
99         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
100         [AC_MSG_ERROR([unable to link with log4cpp])])
101
102 # Xerces settings
103 AC_ARG_WITH(xerces, 
104             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
105             [if test x_$with_xerces != x_/usr; then
106                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
107                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
108             fi])
109 LIBS="-lxerces-c $LIBS"
110 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
111 AC_MSG_CHECKING([Xerces version])
112 AC_PREPROC_IFELSE(
113     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
114 [#if  _XERCES_VERSION != 20600
115 int i = 0;
116 #else
117 #error cannot use version 2.6.0
118 #endif])],
119     [AC_MSG_RESULT(OK)],
120     [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])])
121 AC_TRY_LINK(
122         [#include <xercesc/util/PlatformUtils.hpp>],
123         [xercesc::XMLPlatformUtils::Initialize()],
124         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
125         [AC_MSG_ERROR([unable to link with Xerces])])
126
127
128 # XML-Security settings
129 AC_ARG_WITH(xmlsec,
130             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
131             [with_xmlsec=/usr])
132
133 if test x_$with_xmlsec != x_no; then
134     if test x_$with_xmlsec != x_/usr; then
135         LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
136         CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
137     fi        
138     LIBS="-lxml-security-c $LIBS"
139     AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
140     AC_MSG_CHECKING([XML-Security version])
141     AC_PREPROC_IFELSE(
142             [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
143         [#if XSEC_VERSION_MAJOR > 1 || XSEC_VERSION_MEDIUM >2 
144 int i = 0;
145 #else
146 #error need version 1.3 or later
147 #endif])],
148         [AC_MSG_RESULT(OK)],
149         [AC_MSG_FAILURE([XML-Security version 1.3 or greater is required.])])
150     AC_TRY_LINK(
151             [#include <xsec/utils/XSECPlatformUtils.hpp>],
152             [XSECPlatformUtils::Initialise()],,
153             [AC_MSG_ERROR([unable to link with XML-Sec])])
154 else
155     AC_MSG_WARN([xmlsec disabled, building without signature/encryption support])
156     AC_DEFINE(XMLTOOLING_NO_XMLSEC,1,
157         [Define if you wish to disable XML-Security-dependent features.])
158 fi
159 AM_CONDITIONAL(BUILD_XMLSEC,test x_$with_xmlsec != x_no)
160
161 # Does the STL in use help or screw us?
162 AC_TRY_LINK(
163         [#include <string>],
164         [std::basic_string<unsigned short> foo; foo=foo+(unsigned short)65],
165         [AC_DEFINE(HAVE_GOOD_STL,1,
166             [Define if you have an STL implementation that supports useful string specialization.])],
167         )
168
169 # Check for unit test support
170 CXXTEST="/usr/bin/cxxtestgen.pl"
171 CXXTESTFLAGS=""
172 AC_ARG_WITH(cxxtest,
173             AC_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
174             [if test x_$with_cxxtest != x_/usr; then
175                 CXXTEST="${with_cxxtest}/cxxtestgen.pl"
176                 CXXTESTFLAGS="-I${with_cxxtest}"
177             fi])
178 if ! test -f "${CXXTEST}"; then
179     AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
180 fi
181
182 AC_SUBST(CXXTEST)
183 AC_SUBST(CXXTESTFLAGS)
184 AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
185
186 LIBTOOL="$LIBTOOL --silent"
187
188 # output makefiles
189 AC_OUTPUT(Makefile xmltooling/Makefile xmltoolingtest/Makefile schemas/Makefile)