[mathicgb] 230/393: Changes to build system intended to detect if linking with librt is necessary.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:59:08 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch upstream
in repository mathicgb.

commit daa0287559b9d4457550d4b844f2f7d025380c0c
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date:   Thu Apr 11 13:47:26 2013 -0400

    Changes to build system intended to detect if linking with librt is necessary.
---
 Makefile.am  |  9 +--------
 configure.ac | 58 +++++++++++++++++++++++++++++++++++++++++-----------------
 2 files changed, 42 insertions(+), 25 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index f754beb..8fda182 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,15 +3,11 @@
 ACLOCAL_AMFLAGS = -I build/autotools/m4
 
 # Options passed to the C and C++ PreProcessor (CPP) and compiler
-AM_CPPFLAGS = -I${top_srcdir}/
-libmathicgb_la_CPPFLAGS = $(DEPS_CFLAGS)
+AM_CPPFLAGS = -I${top_srcdir}/ -I$(top_srcdir)/src/ $(DEPS_CFLAGS)
 
 # tell Libtool what the name of the library is.
 lib_LTLIBRARIES = libmathicgb.la
 
-# set the C++ compiler to include src/
-AM_CXXFLAGS=-I$(top_srcdir)/src/ -std=gnu++0x
-
 # libraries that are needed by this library
 libmathicgb_la_LIBADD= $(DEPS_LIBS)
 
@@ -89,7 +85,6 @@ bin_PROGRAMS = mgb
 
 # set up the console program. Listing the headers in sources ensure that
 # those files are included in distributions.
-mgb_CPPFLAGS = $(DEPS_CFLAGS)
 mgb_SOURCES = src/cli/GBMain.cpp src/cli/CommonParams.hpp				\
   src/cli/CommonParams.cpp src/cli/GBAction.hpp src/cli/GBAction.cpp	\
   src/cli/GBCommonParams.hpp src/cli/GBCommonParams.cpp					\
@@ -104,8 +99,6 @@ if with_gtest
 TESTS=unittest
 check_PROGRAMS=$(TESTS)
 
-unittest_CPPFLAGS = $(DEPS_CFLAGS)
-unittest_CXXFLAGS = -I$(top_srcdir)/src/ -std=gnu++0x
 unittest_LDADD = $(DEPS_LIBS)
 unittest_LDFLAGS= $(top_builddir)/libmathicgb.la
 
diff --git a/configure.ac b/configure.ac
index 5c78b4d..205dbf3 100755
--- a/configure.ac
+++ b/configure.ac
@@ -5,22 +5,12 @@ AC_INIT([mathicgb], [1.0]) # package, version, bug-report-email
 PKG_CHECK_MODULES([MEMTAILOR], [memtailor])
 PKG_CHECK_MODULES([MATHIC], [mathic])
 
+# Locate the C++ compiler.
+AC_PROG_CXX
 AC_LANG([C++])
-dnl the first AC_LINK_IFELSE causes tests for lots of C++ related things,
-dnl and these print out messages. So to avoid those messages appearing
-dnl after "if librt..." and before the result for that test, we do an
-dnl empty AC_LINK_IFELSE. Probably there is a better way.
-AC_LINK_IFELSE([AC_LANG_SOURCE([[]])], [], [])
 
-AC_MSG_CHECKING([if librt is needed on this platform])
-AC_LINK_IFELSE(
-  [AC_LANG_PROGRAM(
-    [[#]include [<]ctime[>]],
-    [[std::clock();]]
-   )],
-  [AC_MSG_RESULT([no]); RT_LIBS=""],
-  [AC_MSG_RESULT([yes]); RT_LIBS="-lrt"]
-)
+# Require C++11 support
+AX_CXX_COMPILE_STDCXX_11(, [mandatory])
 
 
 dnl ----- The gtest dependency
@@ -92,8 +82,45 @@ AS_IF(
   [AC_MSG_ERROR([invalid value $with_tbb for with_tbb.])]
 )
 
+dnl ----- The librt dependency
+dnl On Linux TBB calls clock_gettime, which requires librt, but librt is not
+dnl linked in automatically. So we need to check for that.
+
+dnl the first AC_LINK_IFELSE causes tests for lots of C++ related things,
+dnl and these print out messages. So to avoid those messages appearing
+dnl after "if librt..." and before the result for that test, we do an
+dnl empty AC_LINK_IFELSE. Probably there is a better way.
+AC_LINK_IFELSE([AC_LANG_SOURCE([[]])], [], [])
+
+dnl We check if -lrt is necessary. We need librt if we are building with TBB,
+dnl if linking and compiling works when linking with librt but it doesn't
+dnl without linking with librt.
+AS_IF([test "x$with_tbb" == "xyes"],
+  [AC_MSG_CHECKING([if librt is needed to support TBB on this platform]);
+  oldLIBS=$LIBS;
+  LIBS="$TBB_LIBS -lrt $LIBS";
+  oldCFLAGS=$CFLAGS;
+  CFLAGS="$CFLAGS $TBB_CFLAGS";
+  AC_LINK_IFELSE(
+    [AC_LANG_PROGRAM(
+      [[#]include [<]tbb/tbb.h[>]], [[tbb::tick_count::now();]]
+    )],
+    [LIBS=$oldLibs; AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM(
+        [[#]include [<]tbb/tbb.h[>]], [[tbb::tick_count::now();]]
+      )],
+      [AC_MSG_RESULT([no])],
+      [AC_MSG_RESULT([yes]); RT_LIBS="-lrt"]
+    )],
+    [AC_MSG_WARN([AC_MSG_RESULT([no])])]
+  )];
+  LIBS=$oldLIBS;
+  CFLAGS=$oldCFLAGS;
+)
+
 DEPS_CFLAGS="$MEMTAILOR_CFLAGS $MATHIC_CFLAGS $TBB_CFLAGS $GTEST_CFLAGS"
 DEPS_LIBS="$MEMTAILOR_LIBS $MATHIC_LIBS $TBB_LIBS $GTEST_LIBS $RT_LIBS"
+
 AC_SUBST(DEPS_CFLAGS)
 AC_SUBST(DEPS_LIBS)
 
@@ -146,9 +173,6 @@ AC_PROG_LN_S
 # the fallback is not used.
 AC_PROG_INSTALL
 
-# Locate the C++ compiler.
-AC_PROG_CXX
-
 # Set up LibTool
 LT_INIT
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mathicgb.git



More information about the debian-science-commits mailing list