Two phase test for libboost-test-dev
[metaproxy-moved-to-github.git] / configure.ac
1 ## -*- Autoconf -*-
2 ## Process this file with autoconf to produce a configure script.
3
4 # Autoconf and automake setup
5 AC_PREREQ(2.57)
6 AC_INIT(yp2, 0.0.1, marc@indexdata.dk)
7
8 AC_CONFIG_HEADERS(src/config.hpp)
9
10 AC_CONFIG_SRCDIR(configure.ac) 
11 AC_CONFIG_AUX_DIR(config)
12 AC_CANONICAL_SYSTEM
13 ##AC_PREFIX_DEFAULT(`pwd`/install) 
14
15 AM_INIT_AUTOMAKE(1.8)
16
17 # Checks for programs.
18 AC_PROG_CXX
19 AC_PROG_CXXCPP
20 AC_PROG_INSTALL
21 AC_PROG_LN_S
22 AC_PROG_MAKE_SET
23 AC_PROG_RANLIB
24 AM_PROG_LIBTOOL
25
26 # Use C++ compilers only for tests
27 AC_LANG(C++)
28
29 # Checks for libraries.
30 AC_CHECK_LIB(boost_thread, main, [],[
31         AC_MSG_NOTICE([boost thread library not found.])
32         AC_MSG_ERROR([Install libboost-thread-dev (or similar)])
33 ])
34
35 AC_CHECK_LIB(boost_date_time, main, [],[
36         AC_MSG_NOTICE([boost date_time library not found.])
37         AC_MSG_ERROR([Install libboost-date-time-dev (or similar)])
38 ])
39
40 AC_CHECK_LIB(boost_program_options, main, [],[
41         AC_MSG_NOTICE([boost program options library not found.])
42         AC_MSG_ERROR([Install libboost-program-options-dev (or similar)])
43 ])
44
45 AC_CHECK_HEADER(boost/test/auto_unit_test.hpp,,[
46         AC_MSG_NOTICE([boost test unit header not found.])
47         AC_MSG_ERROR([Install libboost-test-dev (or similar)])
48 ])
49
50 AC_MSG_CHECKING([whether boost_unit_test_framework works])
51 OLIBS=$LIBS
52 LIBS="$LIBS -lboost_unit_test_framework"
53 AC_TRY_LINK([
54 #define BOOST_AUTO_TEST_MAIN
55 #include <boost/test/auto_unit_test.hpp> 
56 BOOST_AUTO_TEST_CASE( test )
57 {
58  BOOST_CHECK(true);
59 }
60 ],[],
61 [
62         AC_MSG_RESULT([yes])
63         LIBS=$OLIBS
64 ],
65 [
66         AC_MSG_RESULT([no])
67         AC_MSG_NOTICE([Boost unit test framework does not appear to work])
68         AC_MSG_ERROR([Consult config.log for details])
69 ])
70
71 ## YAZPP checks
72 YAZPP_INIT(threads,1.0)
73 if test -z "$YAZPPLIB"; then
74         AC_MSG_ERROR([YAZ++ development libraries missing])
75 fi
76 ##YAZ_DOC
77
78 ## libxslt checks
79 AC_SUBST(XSLT_LIBS)
80 AC_SUBST(XSLT_CFLAGS)
81 xsltdir=default
82 AC_ARG_WITH(xslt,[[  --with-xslt[=PREFIX]    use libxslt in PREFIX]],xsltdir=$withval)
83 if test "$xsltdir" = "yes" -o "$xsltdir" = "default"; then
84         for d in /usr /usr/local; do
85                 if test -x $d/bin/xslt-config; then
86                         xsltdir=$d
87                 fi
88         done
89 fi
90 if test "$xsltdir" != "no"; then
91         AC_MSG_CHECKING(for libXSLT)
92         if test -x $xsltdir/bin/xslt-config; then
93                 XSLT_LIBS=`$xsltdir/bin/xslt-config --libs`
94                 XSLT_CFLAGS=`$xsltdir/bin/xslt-config --cflags`
95                 XSLT_VER=`$xsltdir/bin/xslt-config --version`
96                 AC_MSG_RESULT($XSLT_VER)
97                 AC_DEFINE([HAVE_XSLT],[1],
98                 [Define to 1 if you have libxslt installed])
99         else
100                 AC_MSG_RESULT(Not found)
101                 if test "$xsltdir" = "default"; then
102                         AC_MSG_WARN([Libxslt development libraries not found.])
103                 else
104                         AC_MSG_ERROR([libxslt development libraries not found.])                fi
105         fi
106 fi
107
108
109 # Checks for header files.
110 ##AC_HEADER_STDC
111 ##AC_HEADER_SYS_WAIT
112 ##AC_HEADER_TIME 
113 AC_CHECK_HEADERS(sys/select.h sys/socket.h iostream list vector stdexcept)
114 AC_CHECK_HEADERS(boost/thread/mutex.hpp \ 
115                  boost/date_time/posix_time/posix_time.hpp \
116                  boost/test/auto_unit_test.hpp)
117
118 # Checks for typedefs, structures, and compiler characteristics.
119 ##AC_TYPE_SIZE_T 
120 ##AC_CHECK_SIZEOF(int)
121 ##AC_CHECK_SIZEOF(long int)
122
123
124 # Checks for library functions.
125
126 AC_CONFIG_FILES([
127         Doxyfile
128         Makefile
129         src/Makefile
130         src/Jamfile
131 ])
132
133 AC_OUTPUT
134
135
136 # postamble
137
138 echo \
139 "------------------------------------------------------------------------
140 Configuration:
141
142   Source code location:       ${srcdir}
143   CPP Preprocessor flags:     ${CPPFLAGS}
144   CXX Compiler:               ${CXX}
145   CXX Compiler flags:         ${CXXFLAGS}
146   Linker flags:               ${LDFLAGS}
147   Linked libs:                ${LIBS}
148   Host System Type:           ${host}
149   Install path:               ${prefix}
150   Automake:                   ${AUTOMAKE}
151
152 ------------------------------------------------------------------------"