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