First working version of ID_BOOST macro.
authorAdam Dickmeiss <adam@indexdata.dk>
Sun, 13 Apr 2008 16:57:41 +0000 (18:57 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Sun, 13 Apr 2008 16:57:41 +0000 (18:57 +0200)
The ID_BOOST macro now allows components=test thread . It sets
BOOST_{CPPFLAGS,LIB} and BOOST_component_LIB . The component headers
are checked but macro does not test linking.

boost.m4

index 0ecf99d..084e36e 100644 (file)
--- a/boost.m4
+++ b/boost.m4
@@ -3,6 +3,9 @@
 # ID_BOOST([components],[libs])
 AC_DEFUN([ID_BOOST],
     [
+       AC_SUBST(BOOST_CPPFLAGS)
+       AC_SUBST(BOOST_LIB)
+       
        AC_MSG_CHECKING([for Boost])
        AC_LANG_PUSH([C++])
        oldCPPFLAGS="$CPPFLAGS"
@@ -11,23 +14,25 @@ AC_DEFUN([ID_BOOST],
        CPPFLAGS="$CPPFLAGS -DBOOST_REQ_VERSION=${BOOST_REQ_VERSION}"
 
        AC_ARG_WITH([boost],[[  --with-boost=DIR  use Boost in prefix DIR]])
-       if test "$with_boost" = "yes"; then
+       if test "$with_boost" = "yes" -o -z "$with_boost"; then
            BOOST_CPPFLAGS=""
-           BOOST_LIBS=""
+           BOOST_LIB=""
        else
            BOOST_CPPFLAGS="-I${with_boost}/include"
-           BOOST_LIBS=" -L${with_boost}/lib"
+           BOOST_LIB="-L${with_boost}/lib"
        fi
        if test "${with_boost}" = "no"; then
            AC_MSG_RESULT([disabled])
        else
            CPPFLAGS="${CPPFLAGS} ${BOOST_CPPFLAGS}"
-           LIBS="${LIBS} ${BOOST_LIBS}"
+           LIBS="${LIBS} ${BOOST_LIB}"
             AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <boost/version.hpp>
 ]],[[ 
 int x = BOOST_VERSION;
-]])],[AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])])
+]])],[AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])
+           AC_MSG_ERROR([Boost development libraries required])
+])
 
 
             AC_MSG_CHECKING([Boost version])
@@ -41,8 +46,42 @@ int x = BOOST_VERSION;
            AC_MSG_RESULT([ok])
 ],[
            AC_MSG_RESULT([version too old])
+           AC_MSG_ERROR([A newer version of Boost is required])
        ])
        fi
+       for c in $1; do
+           case $c in 
+               thread)
+                   AC_SUBST(BOOST_THREAD_LIB)
+                   BOOST_THREAD_LIB="-lboost_thread"
+                   AC_MSG_CHECKING([Boost threads])
+                   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <boost/version.hpp>
+#include <boost/thread/thread.hpp>
+]],[[ 
+int x = BOOST_VERSION;
+]])],[AC_MSG_RESULT([yes])],[
+AC_MSG_RESULT([no])
+AC_MSG_ERROR([Boost thread libraries required])
+])
+                    ;;
+               test)
+                   AC_SUBST(BOOST_TEST_LIB)
+                   BOOST_TEST_LIB="-lboost_unit_test_framework"
+                   AC_MSG_CHECKING([Boost unit test framework])
+                   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#define BOOST_TEST_DYN_LINK
+#include <boost/test/auto_unit_test.hpp>
+BOOST_AUTO_TEST_CASE( t ) 
+{
+    BOOST_CHECK(1);
+}
+]],[[ 
+]])],[AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])
+AC_MSG_ERROR([Boost unit test framework libraries required])])
+                    ;;
+               esac
+       done
        CPPFLAGS="$oldCPPFLAGS"
        LIBS="$oldLIBS"
        AC_LANG_POP([C++])