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