029d1fd8ef3de1281094c06f428d27c11af76c3d
[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
36 if test "$GCC" = "yes" ; then
37 #    AC_HAVE_GCC_VERSION(4,0,0,0,
38 #        [
39 #        AC_DEFINE(GCC_HASCLASSVISIBILITY,1,
40 #            [Define to enable class visibility control in gcc.])
41 #        GCC_CFLAGS="$GCC_CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
42 #        GCC_CXXFLAGS="$GCC_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
43 #        ])
44     CFLAGS="$GCC_CFLAGS"
45     CXXFLAGS="$GCC_CXXFLAGS"
46 fi
47
48 AC_DISABLE_STATIC
49 AC_PROG_LIBTOOL
50
51 # Checks for typedefs, structures, and compiler characteristics.
52 AC_C_CONST
53 AC_TYPE_SIZE_T
54
55 # Checks for library functions.
56 AC_CHECK_FUNCS([strchr strdup strstr])
57
58 # libcurl settings
59 AC_PATH_PROG(CURL_CONFIG,curl-config)
60 AC_ARG_WITH(curl,
61     AC_HELP_STRING([--with-curl=PATH], [where curl-config is installed]),
62     [
63     CURL_CONFIG="${with_curl}"
64     if ! test -f "${CURL_CONFIG}" ; then
65         CURL_CONFIG="${with_curl}/bin/curl-config"
66     fi
67     ])
68 if test -f "${CURL_CONFIG}" ; then
69     LDFLAGS="`${CURL_CONFIG} --libs` $LDFLAGS"
70     CPPFLAGS="`${CURL_CONFIG} --cflags` $CPPFLAGS"
71 else
72     AC_MSG_ERROR([curl-config not found, may need to use --with-curl option])
73 fi
74 AC_CHECK_HEADER([curl/curl.h],,AC_MSG_ERROR([unable to find libcurl header files]))
75 AC_CHECK_LIB([curl],[curl_global_init],,AC_MSG_ERROR([unable to link with libcurl]))
76 AC_MSG_CHECKING([for CURLOPT_SSL_CTX_FUNCTION in curl.h])
77 AC_EGREP_HEADER([CURLOPT_SSL_CTX_FUNCTION], [curl/curl.h],
78                 [AC_MSG_RESULT(yes)],
79                 [AC_MSG_ERROR([need libcurl that supports CURLOPT_SSL_CTX_FUNCTION])])
80
81 AC_LANG(C++)
82
83 # C++ requirements
84 AC_CXX_REQUIRE_STL
85 AC_CXX_NAMESPACES
86
87 # log4cpp settings
88 AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
89 AC_ARG_WITH(log4cpp,
90     AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
91     [
92     LOG4CPP_CONFIG="${with_log4cpp}"
93     if ! test -f "${LOG4CPP_CONFIG}" ; then
94         LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
95     fi
96     ])
97 if test -f "${LOG4CPP_CONFIG}"; then
98     LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
99     CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
100 else
101     AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
102     LIBS="-llog4cpp $LIBS"
103 fi
104 AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
105 AC_CHECK_HEADER([log4cpp/PropertyConfigurator.hh],,AC_MSG_ERROR([you need at least log4cpp 0.3.x]))
106 AC_TRY_LINK(
107         [#include <log4cpp/Category.hh>],
108         [log4cpp::Category::getInstance("foo")],
109         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
110         [AC_MSG_ERROR([unable to link with log4cpp])])
111
112 # Xerces settings
113 AC_ARG_WITH(xerces, 
114             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
115             [if test x_$with_xerces != x_/usr; then
116                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
117                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
118             fi])
119 LIBS="-lxerces-c $LIBS"
120 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
121 AC_MSG_CHECKING([Xerces version])
122 AC_PREPROC_IFELSE(
123     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
124 [#if  _XERCES_VERSION != 20600
125 int i = 0;
126 #else
127 #error cannot use version 2.6.0
128 #endif])],
129     [AC_MSG_RESULT(OK)],
130     [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])])
131 AC_TRY_LINK(
132     [#include <xercesc/util/PlatformUtils.hpp>],
133     [xercesc::XMLPlatformUtils::Initialize()],
134     [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
135     [AC_MSG_ERROR([unable to link with Xerces])])
136
137
138 # XML-Security settings
139 AC_ARG_WITH(xmlsec,
140     AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),
141     [if test x_$with_xmlsec != x_/usr; then
142         LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
143         CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
144     fi])
145 LIBS="-lxml-security-c $LIBS"
146 AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find xmlsec header files]))
147 AC_TRY_LINK(
148     [#include <xsec/utils/XSECPlatformUtils.hpp>],
149     [XSECPlatformUtils::Initialise()],
150     [AC_DEFINE(HAVE_LIBXSEC,1,[Define if XML-Sec library was found])],
151     [AC_MSG_ERROR([unable to link with xmlsec library])]
152     )
153
154 # XML-Tooling settings
155 AC_ARG_WITH(xmltooling,
156     AC_HELP_STRING([--with-xmltooling=PATH], [where xmltooling is installed]),
157     [if test x_$with_xmltooling != x_/usr; then
158         LDFLAGS="-L${with_xmltooling}/lib $LDFLAGS"
159         CPPFLAGS="-I${with_xmltooling}/include $CPPFLAGS"
160         DX_INCLUDE="${with_xmltooling}/include"
161     fi])
162 LIBS="-lxmltooling $LIBS"
163 AC_CHECK_HEADER([xmltooling/XMLToolingConfig.h],,AC_MSG_ERROR([unable to find xmltooling header files]))
164 AC_TRY_LINK(
165     [#include <xmltooling/XMLToolingConfig.h>],
166     [xmltooling::XMLToolingConfig::getConfig().init()],
167     [AC_DEFINE(HAVE_LIBXMLTOOLING,1,[Define if XML-Tooling library was found])],
168     [AC_MSG_ERROR([unable to link with xmltooling library])]
169     )
170
171 # Does the STL in use help or screw us?
172 AC_TRY_LINK(
173     [#include <string>],
174     [std::basic_string<unsigned short> foo; foo=foo+(unsigned short)65],
175     [AC_DEFINE(HAVE_GOOD_STL,1,
176         [Define if you have an STL implementation that supports useful string specialization.])],
177     )
178
179 # Check for unit test support
180 CXXTEST="/usr/bin/cxxtestgen.pl"
181 CXXTESTFLAGS=""
182 AC_ARG_WITH(cxxtest,
183             AC_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
184             [if test x_$with_cxxtest != x_/usr; then
185                 CXXTEST="${with_cxxtest}/cxxtestgen.pl"
186                 CXXTESTFLAGS="-I${with_cxxtest}"
187             fi])
188 if ! test -f "${CXXTEST}"; then
189     AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
190 fi
191
192 AC_SUBST(CXXTEST)
193 AC_SUBST(CXXTESTFLAGS)
194 AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
195
196 AC_SUBST(DX_INCLUDE)
197 LIBTOOL="$LIBTOOL --silent"
198
199 # output makefiles
200 AC_OUTPUT(Makefile saml/Makefile samltest/Makefile schemas/Makefile)