Try to patch around Sun compiler bug.
[shibboleth/cpp-opensaml.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([opensaml], [2.0], [mace-opensaml-users@internet2.edu], [saml])
3 AM_CONFIG_HEADER(config.h)
4 #AM_CONFIG_HEADER(saml/config_pub.h)
5 AM_INIT_AUTOMAKE([opensaml], [2.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(opensaml, doxygen.cfg, doc/api)
19 DX_INCLUDE=
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 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="$GCC_CFLAGS"
46     CXXFLAGS="$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])
67
68 AC_CHECK_SIZEOF(time_t)
69
70 # zlib settings
71 AC_ARG_WITH(zlib,
72         AC_HELP_STRING([--with-zlib=PATH], [where zlib is installed]),
73         [
74                 if test -d "$withval"; then
75                         CPPFLAGS="${CPPFLAGS} -I$withval/include"
76                         LDFLAGS="${LDFLAGS} -L$withval/lib"
77                 fi
78         ]
79 )
80 AC_CHECK_HEADER([zlib.h],,AC_MSG_ERROR([unable to find zlib header files]))
81 AC_CHECK_LIB([z],[deflateInit2_],,AC_MSG_ERROR([unable to link with zlib library]))
82
83 AC_LANG(C++)
84
85 # C++ requirements
86 AC_CXX_REQUIRE_STL
87 AC_CXX_NAMESPACES
88
89 # log4cpp settings
90 AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
91 AC_ARG_WITH(log4cpp,
92     AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
93     [
94     LOG4CPP_CONFIG="${with_log4cpp}"
95     if ! test -f "${LOG4CPP_CONFIG}" ; then
96         LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
97     fi
98     ])
99 if test -f "${LOG4CPP_CONFIG}"; then
100     LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
101     CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
102 else
103     AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
104     LIBS="-llog4cpp $LIBS"
105 fi
106 AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
107 AC_CHECK_HEADER([log4cpp/PropertyConfigurator.hh],,AC_MSG_ERROR([you need at least log4cpp 0.3.x]))
108 AC_TRY_LINK(
109         [#include <log4cpp/Category.hh>],
110         [log4cpp::Category::getInstance("foo")],
111         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
112         [AC_MSG_ERROR([unable to link with log4cpp])])
113
114 # Xerces settings
115 AC_ARG_WITH(xerces, 
116             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
117             [if test x_$with_xerces != x_/usr; then
118                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
119                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
120             fi])
121 LIBS="-lxerces-c $LIBS"
122 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
123 AC_MSG_CHECKING([Xerces version])
124 AC_PREPROC_IFELSE(
125     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
126 [#if  _XERCES_VERSION != 20600
127 int i = 0;
128 #else
129 #error cannot use version 2.6.0
130 #endif])],
131     [AC_MSG_RESULT(OK)],
132     [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])])
133 AC_TRY_LINK(
134     [#include <xercesc/util/PlatformUtils.hpp>],
135     [xercesc::XMLPlatformUtils::Initialize()],
136     [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
137     [AC_MSG_ERROR([unable to link with Xerces])])
138
139
140 # XML-Security settings
141 AC_ARG_WITH(xmlsec,
142     AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),
143     [if test x_$with_xmlsec != x_/usr; then
144         LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
145         CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
146     fi])
147 LIBS="-lxml-security-c $LIBS"
148 AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find xmlsec header files]))
149 AC_MSG_CHECKING([XML-Security version])
150 AC_PREPROC_IFELSE(
151     [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
152     [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3) || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM == 3 && XSEC_VERSION_MINOR > 0)
153 int i = 0;
154 #else
155 #error need version 1.3.1 or later
156 #endif])],
157     [AC_MSG_RESULT(OK)],
158     [AC_MSG_FAILURE([XML-Security version 1.3.1 or greater is required.])])
159 AC_TRY_LINK(
160     [#include <xsec/utils/XSECPlatformUtils.hpp>],
161     [XSECPlatformUtils::Initialise()],
162     [AC_DEFINE(HAVE_LIBXSEC,1,[Define if XML-Sec library was found])],
163     [AC_MSG_ERROR([unable to link with xmlsec library])]
164     )
165
166 # XML-Tooling settings
167 AC_ARG_WITH(xmltooling,
168     AC_HELP_STRING([--with-xmltooling=PATH], [where xmltooling is installed]),
169     [if test x_$with_xmltooling != x_/usr; then
170         LDFLAGS="-L${with_xmltooling}/lib $LDFLAGS"
171         CPPFLAGS="-I${with_xmltooling}/include $CPPFLAGS"
172         DX_INCLUDE="${with_xmltooling}/include"
173     fi])
174 LIBS="-lxmltooling $LIBS"
175 AC_CHECK_HEADER([xmltooling/XMLToolingConfig.h],,AC_MSG_ERROR([unable to find xmltooling header files]))
176 AC_TRY_LINK(
177     [#include <xmltooling/XMLToolingConfig.h>],
178     [xmltooling::XMLToolingConfig::getConfig().init()],
179     [AC_DEFINE(HAVE_LIBXMLTOOLING,1,[Define if XML-Tooling library was found])],
180     [AC_MSG_ERROR([unable to link with xmltooling library])]
181     )
182
183 # Does the STL in use help or screw us?
184 AC_TRY_LINK(
185     [#include <string>],
186     [std::basic_string<unsigned short> foo; foo=foo+(unsigned short)65],
187     [AC_DEFINE(HAVE_GOOD_STL,1,
188         [Define if you have an STL implementation that supports useful string specialization.])],
189     )
190
191 # Check for unit test support
192 CXXTEST="/usr/bin/cxxtestgen.pl"
193 CXXTESTFLAGS=""
194 AC_ARG_WITH(cxxtest,
195             AC_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
196             [if test x_$with_cxxtest != x_/usr; then
197                 CXXTEST="${with_cxxtest}/cxxtestgen.pl"
198                 CXXTESTFLAGS="-I${with_cxxtest}"
199             fi])
200 if ! test -f "${CXXTEST}"; then
201     AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
202 fi
203
204 AC_SUBST(CXXTEST)
205 AC_SUBST(CXXTESTFLAGS)
206 AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
207
208 AC_SUBST(DX_INCLUDE)
209 LIBTOOL="$LIBTOOL --silent"
210
211 # output makefiles
212 AC_OUTPUT(Makefile saml/Makefile samltest/Makefile schemas/Makefile)