1 # ===========================================================================
2 # http://www.gnu.org/software/autoconf-archive/ax_boost_chrono.html
3 # ===========================================================================
11 # Test for System library from the Boost C++ libraries. The macro requires
12 # a preceding call to AX_BOOST_BASE. Further documentation is available at
13 # <http://randspringer.de/boost/index.html>.
17 # AC_SUBST(BOOST_CHRONO_LIB)
25 # Copyright (c) 2012 Xiyue Deng <manphiz@gmail.com>
27 # Copying and distribution of this file, with or without modification, are
28 # permitted in any medium without royalty provided the copyright notice
29 # and this notice are preserved. This file is offered as-is, without any
34 AC_DEFUN([AX_BOOST_CHRONO],
36 AC_ARG_WITH([boost-chrono],
37 AS_HELP_STRING([--with-boost-chrono@<:@=special-lib@:>@],
38 [use the Chrono library from boost - it is possible to specify a certain library for the linker
39 e.g. --with-boost-chrono=boost_chrono-gcc-mt ]),
41 if test "$withval" = "no"; then
43 elif test "$withval" = "yes"; then
45 ax_boost_user_chrono_lib=""
48 ax_boost_user_chrono_lib="$withval"
54 if test "x$want_boost" = "xyes"; then
55 AC_REQUIRE([AC_PROG_CC])
56 AC_REQUIRE([AC_CANONICAL_BUILD])
57 CPPFLAGS_SAVED="$CPPFLAGS"
58 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
61 LDFLAGS_SAVED="$LDFLAGS"
62 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
65 AC_CACHE_CHECK(whether the Boost::Chrono library is available,
68 CXXFLAGS_SAVE=$CXXFLAGS
70 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/chrono.hpp>]],
71 [[boost::chrono::system_clock::time_point time;]])],
72 ax_cv_boost_chrono=yes, ax_cv_boost_chrono=no)
73 CXXFLAGS=$CXXFLAGS_SAVE
76 if test "x$ax_cv_boost_chrono" = "xyes"; then
77 AC_SUBST(BOOST_CPPFLAGS)
79 AC_DEFINE(HAVE_BOOST_CHRONO,,[define if the Boost::Chrono library is available])
80 BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
83 if test "x$ax_boost_user_chrono_lib" = "x"; then
84 for libextension in `ls $BOOSTLIBDIR/libboost_chrono*.so* $BOOSTLIBDIR/libboost_chrono*.dylib* $BOOSTLIBDIR/libboost_chrono*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_chrono.*\)\.so.*$;\1;' -e 's;^lib\(boost_chrono.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_chrono.*\)\.a.*$;\1;'` ; do
85 ax_lib=${libextension}
86 AC_CHECK_LIB($ax_lib, exit,
87 [BOOST_CHRONO_LIB="-l$ax_lib"; AC_SUBST(BOOST_CHRONO_LIB) link_chrono="yes"; break],
90 if test "x$link_chrono" != "xyes"; then
91 for libextension in `ls $BOOSTLIBDIR/boost_chrono*.dll* $BOOSTLIBDIR/boost_chrono*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_chrono.*\)\.dll.*$;\1;' -e 's;^\(boost_chrono.*\)\.a.*$;\1;'` ; do
92 ax_lib=${libextension}
93 AC_CHECK_LIB($ax_lib, exit,
94 [BOOST_CHRONO_LIB="-l$ax_lib"; AC_SUBST(BOOST_CHRONO_LIB) link_chrono="yes"; break],
100 for ax_lib in $ax_boost_user_chrono_lib boost_chrono-$ax_boost_user_chrono_lib; do
101 AC_CHECK_LIB($ax_lib, exit,
102 [BOOST_CHRONO_LIB="-l$ax_lib"; AC_SUBST(BOOST_CHRONO_LIB) link_chrono="yes"; break],
107 if test "x$ax_lib" = "x"; then
108 AC_MSG_ERROR(Could not find a version of the library!)
110 if test "x$link_chrono" = "xno"; then
111 AC_MSG_ERROR(Could not link against $ax_lib !)
115 CPPFLAGS="$CPPFLAGS_SAVED"
116 LDFLAGS="$LDFLAGS_SAVED"