Prelims for symbol hiding, doesn't work yet
[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 AC_LANG(C++)
51
52 # C++ requirements
53 AC_CXX_REQUIRE_STL
54 AC_CXX_NAMESPACES
55
56 AC_LANG(C)
57
58 # Checks for typedefs, structures, and compiler characteristics.
59 AC_C_CONST
60 AC_TYPE_SIZE_T
61
62 # Checks for library functions.
63 AC_CHECK_FUNCS([strchr strdup strstr])
64 AC_CHECK_HEADERS([dlfcn.h])
65 AC_CHECK_FUNC(dlclose, , [ AC_CHECK_LIB(dl, dlopen) ])
66
67 AC_LANG(C++)
68
69 # log4cpp settings
70 AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
71 AC_ARG_WITH(log4cpp,
72     AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
73     [
74     LOG4CPP_CONFIG="${with_log4cpp}"
75     if ! test -f "${LOG4CPP_CONFIG}" ; then
76         LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
77     fi
78     ])
79 if test -f "${LOG4CPP_CONFIG}"; then
80     LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
81     CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
82 else
83     AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
84     LIBS="-llog4cpp $LIBS"
85 fi
86 AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
87 AC_CHECK_HEADER([log4cpp/PropertyConfigurator.hh],,AC_MSG_ERROR([you need at least log4cpp 0.3.x]))
88 AC_TRY_LINK(
89         [#include <log4cpp/Category.hh>],
90         [log4cpp::Category::getInstance("foo")],
91         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
92         [AC_MSG_ERROR([unable to link with log4cpp])])
93
94 # Xerces settings
95 AC_ARG_WITH(xerces, 
96             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
97             [if test x_$with_xerces != x_/usr; then
98                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
99                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
100             fi])
101 LIBS="-lxerces-c $LIBS"
102 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
103 AC_MSG_CHECKING([Xerces version])
104 AC_PREPROC_IFELSE(
105     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
106 [#if  _XERCES_VERSION != 20600
107 int i = 0;
108 #else
109 #error cannot use version 2.6.0
110 #endif])],
111     [AC_MSG_RESULT(OK)],
112     [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])])
113 AC_TRY_LINK(
114         [#include <xercesc/util/PlatformUtils.hpp>],
115         [xercesc::XMLPlatformUtils::Initialize()],
116         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
117         [AC_MSG_ERROR([unable to link with Xerces])])
118
119
120 # XML-Security settings
121 AC_ARG_WITH(xmlsec,
122             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
123             [with_xmlsec=/usr])
124
125 if test x_$with_xmlsec != x_no; then
126     if test x_$with_xmlsec != x_/usr; then
127         LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
128         CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
129     fi        
130     LIBS="-lxml-security-c $LIBS"
131     AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
132     AC_MSG_CHECKING([XML-Security version])
133     AC_PREPROC_IFELSE(
134             [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
135         [#if XSEC_VERSION_MAJOR > 1 || XSEC_VERSION_MEDIUM >2 
136 int i = 0;
137 #else
138 #error need version 1.3 or later
139 #endif])],
140         [AC_MSG_RESULT(OK)],
141         [AC_MSG_FAILURE([XML-Security version 1.3 or greater is required.])])
142     AC_TRY_LINK(
143             [#include <xsec/utils/XSECPlatformUtils.hpp>],
144             [XSECPlatformUtils::Initialise()],,
145             [AC_MSG_ERROR([unable to link with XML-Sec])])
146 else
147     AC_MSG_WARN([xmlsec disabled, building without signature/encryption support])
148     AC_DEFINE(XMLTOOLING_NO_XMLSEC,1,
149         [Define if you wish to disable XML-Security-dependent features.])
150 fi
151 AM_CONDITIONAL(BUILD_XMLSEC,test x_$with_xmlsec != x_no)
152
153 # Does the STL in use help or screw us?
154 AC_TRY_LINK(
155         [#include <string>],
156         [std::basic_string<unsigned short> foo; foo=foo+(unsigned short)65],
157         [AC_DEFINE(HAVE_GOOD_STL,1,
158             [Define if you have an STL implementation that supports useful string specialization.])],
159         )
160
161 # Check for unit test support
162 CXXTEST="/usr/bin/cxxtestgen.pl"
163 CXXTESTFLAGS=""
164 AC_ARG_WITH(cxxtest,
165             AC_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
166             [if test x_$with_cxxtest != x_/usr; then
167                 CXXTEST="${with_cxxtest}/cxxtestgen.pl"
168                 CXXTESTFLAGS="-I${with_cxxtest}"
169             fi])
170 if ! test -f "${CXXTEST}"; then
171     AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
172 fi
173
174 AC_SUBST(CXXTEST)
175 AC_SUBST(CXXTESTFLAGS)
176 AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
177
178 LIBTOOL="$LIBTOOL --silent"
179
180 # output makefiles
181 AC_OUTPUT(Makefile xmltooling/Makefile xmltoolingtest/Makefile schemas/Makefile)