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