Merge branch 'new_boost'
[m4-moved-to-github.git] / boost.m4
1 # configure for Boost libs
2 #
3 # ID_BOOST([components],[libs])
4 AC_DEFUN([ID_BOOST],
5     [
6         AC_SUBST(BOOST_CPPFLAGS)
7         AC_SUBST(BOOST_LIB)
8         
9         AC_MSG_CHECKING([for Boost])
10         AC_LANG_PUSH([C++])
11         oldCPPFLAGS="$CPPFLAGS"
12         oldLIBS="$LIBS"
13         BOOST_REQ_VERSION=`echo "$2" | awk 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 1000 + [$]2) * 100 + [$]3;}'`
14         CPPFLAGS="$CPPFLAGS -DBOOST_REQ_VERSION=${BOOST_REQ_VERSION}"
15
16         AC_ARG_WITH([boost],[[  --with-boost=DIR  use Boost in prefix DIR]])
17         if test "$with_boost" = "yes" -o -z "$with_boost"; then
18             BOOST_CPPFLAGS=""
19             BOOST_LIB=""
20         else
21             BOOST_CPPFLAGS="-I${with_boost}/include"
22             BOOST_LIB="-L${with_boost}/lib"
23         fi
24         if test "${with_boost}" = "no"; then
25             AC_MSG_RESULT([disabled])
26         else
27             CPPFLAGS="${CPPFLAGS} ${BOOST_CPPFLAGS}"
28             LIBS="${LIBS} ${BOOST_LIB}"
29             AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
30 #include <boost/version.hpp>
31 ]],[[ 
32 int x = BOOST_VERSION;
33 ]])],[AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])
34             AC_MSG_ERROR([Boost development libraries required])
35 ])
36
37
38             AC_MSG_CHECKING([Boost version])
39             AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
40 #include <boost/version.hpp>
41 ]],[[
42 #if BOOST_VERSION < BOOST_REQ_VERSION
43 #error Version too old
44 #endif
45 ]])],[
46             AC_MSG_RESULT([ok])
47 ],[
48             AC_MSG_RESULT([version too old])
49             AC_MSG_ERROR([A newer version of Boost is required])
50         ])
51         fi
52         for c in $1; do
53             case $c in 
54                 thread)
55                     AC_SUBST(BOOST_THREAD_LIB)
56                     BOOST_THREAD_LIB="-lboost_thread"
57                     AC_MSG_CHECKING([Boost threads])
58                     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
59 #include <boost/version.hpp>
60 #include <boost/thread/thread.hpp>
61 ]],[[ 
62 int x = BOOST_VERSION;
63 ]])],[AC_MSG_RESULT([yes])],[
64 AC_MSG_RESULT([no])
65 AC_MSG_ERROR([Boost thread libraries required])
66 ])
67                     ;;
68                 test)
69                     AC_SUBST(BOOST_TEST_LIB)
70                     BOOST_TEST_LIB="-lboost_unit_test_framework"
71                     AC_MSG_CHECKING([Boost unit test framework])
72                     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
73 #define BOOST_TEST_DYN_LINK
74 #include <boost/test/auto_unit_test.hpp>
75 BOOST_AUTO_TEST_CASE( t ) 
76 {
77     BOOST_CHECK(1);
78 }
79 ]],[[ 
80 ]])],[AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])
81 AC_MSG_ERROR([Boost unit test framework libraries required])])
82                     ;;
83                 esac
84         done
85         CPPFLAGS="$oldCPPFLAGS"
86         LIBS="$oldLIBS"
87         AC_LANG_POP([C++])
88     ])
89  
90