Make ID_BOOST determine Boost version (by the use of cpp).
authorAdam Dickmeiss <adam@indexdata.dk>
Sun, 20 Apr 2008 14:00:17 +0000 (16:00 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Sun, 20 Apr 2008 14:00:17 +0000 (16:00 +0200)
boost.m4

index 961797a..bd0ca60 100644 (file)
--- a/boost.m4
+++ b/boost.m4
@@ -13,8 +13,8 @@
 
 AC_DEFUN([ID_BOOST],
     [
-       AC_SUBST(BOOST_CPPFLAGS)
-       AC_SUBST(BOOST_LIB)
+       AC_SUBST([BOOST_CPPFLAGS])
+       AC_SUBST([BOOST_LIB])
        
        AC_MSG_CHECKING([for Boost])
        AC_LANG_PUSH([C++])
@@ -36,37 +36,28 @@ AC_DEFUN([ID_BOOST],
        else
            CPPFLAGS="${CPPFLAGS} ${BOOST_CPPFLAGS}"
            LIBS="${LIBS} ${BOOST_LIB}"
-            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+           AC_LANG_CONFTEST(
+               [AC_LANG_SOURCE([[
 #include <boost/version.hpp>
-]],[[ 
-int x = BOOST_VERSION;
-]])],[AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])
-           AC_MSG_ERROR([Boost development libraries required])
-])
-
-
-            AC_MSG_CHECKING([Boost version])
-           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <boost/version.hpp>
-]],[[
-#if BOOST_VERSION < BOOST_REQ_VERSION
-#error Version too old
-#endif
-]])],[
-           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-mt"
-                   LIBS="${LIBS} ${BOOST_THREAD_LIB}"
-                   AC_MSG_CHECKING([Boost threads])
-                   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+version_is:BOOST_VERSION
+]])])
+           BOOST_GOT_VERSION=`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | $EGREP version_is 2>/dev/null | cut -d ":" -f2`
+           if test $BOOST_GOT_VERSION = "BOOST_VERSION"; then
+               AC_MSG_RESULT([no])
+               AC_MSG_ERROR([Boost development libraries required])
+           fi
+           AC_MSG_RESULT([yes ($BOOST_GOT_VERSION)])
+           if test $BOOST_GOT_VERSION -lt $BOOST_REQ_VERSION; then
+               AC_MSG_ERROR([Boost version $BOOST_REQ_VERSION required])
+           fi
+           for c in $1; do
+               case $c in 
+                   thread)
+                       AC_SUBST([BOOST_THREAD_LIB])
+                       BOOST_THREAD_LIB="-lboost_thread-mt"
+                       LIBS="${LIBS} ${BOOST_THREAD_LIB}"
+                       AC_MSG_CHECKING([Boost threads])
+                       AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 #include <boost/version.hpp>
 #include <boost/thread/thread.hpp>
 ]],[[ 
@@ -74,15 +65,15 @@ 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)
-                   saveLIBS="${LIBS}"
-                   BOOST_TEST_LIB="-lboost_unit_test_framework-mt"
-                   LIBS="${LIBS} ${BOOST_TEST_LIB}"
-                   AC_MSG_CHECKING([Boost unit test framework])
-                   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+                           ])
+                       ;;
+                   test)
+                       AC_SUBST([BOOST_TEST_LIB])
+                       saveLIBS="${LIBS}"
+                       BOOST_TEST_LIB="-lboost_unit_test_framework-mt"
+                       LIBS="${LIBS} ${BOOST_TEST_LIB}"
+                       AC_MSG_CHECKING([Boost unit test framework])
+                       AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 #define BOOST_TEST_DYN_LINK
 #include <boost/test/auto_unit_test.hpp>
 BOOST_AUTO_TEST_CASE( t ) 
@@ -92,10 +83,11 @@ BOOST_AUTO_TEST_CASE( t )
 ]],[[ 
 ]])],[AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])
 AC_MSG_ERROR([Boost unit test framework libraries required])])
-                   LIBS="${saveLIBS}"
-                    ;;
+                       LIBS="${saveLIBS}"
+                       ;;
                esac
-       done
+           done
+       fi
        CPPFLAGS="$oldCPPFLAGS"
        LIBS="$oldLIBS"
        AC_LANG_POP([C++])