ax_boost_chrono.m4 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. # ===========================================================================
  2. # http://www.gnu.org/software/autoconf-archive/ax_boost_chrono.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_BOOST_CHRONO
  8. #
  9. # DESCRIPTION
  10. #
  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>.
  14. #
  15. # This macro calls:
  16. #
  17. # AC_SUBST(BOOST_CHRONO_LIB)
  18. #
  19. # And sets:
  20. #
  21. # HAVE_BOOST_CHRONO
  22. #
  23. # LICENSE
  24. #
  25. # Copyright (c) 2012 Xiyue Deng <manphiz@gmail.com>
  26. #
  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
  30. # warranty.
  31. #serial 1
  32. AC_DEFUN([AX_BOOST_CHRONO],
  33. [
  34. AC_ARG_WITH([boost-chrono],
  35. AS_HELP_STRING([--with-boost-chrono@<:@=special-lib@:>@],
  36. [use the Chrono library from boost - it is possible to specify a certain library for the linker
  37. e.g. --with-boost-chrono=boost_chrono-gcc-mt ]),
  38. [
  39. if test "$withval" = "no"; then
  40. want_boost="no"
  41. elif test "$withval" = "yes"; then
  42. want_boost="yes"
  43. ax_boost_user_chrono_lib=""
  44. else
  45. want_boost="yes"
  46. ax_boost_user_chrono_lib="$withval"
  47. fi
  48. ],
  49. [want_boost="yes"]
  50. )
  51. if test "x$want_boost" = "xyes"; then
  52. AC_REQUIRE([AC_PROG_CC])
  53. AC_REQUIRE([AC_CANONICAL_BUILD])
  54. CPPFLAGS_SAVED="$CPPFLAGS"
  55. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  56. export CPPFLAGS
  57. LDFLAGS_SAVED="$LDFLAGS"
  58. LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
  59. export LDFLAGS
  60. AC_CACHE_CHECK(whether the Boost::Chrono library is available,
  61. ax_cv_boost_chrono,
  62. [AC_LANG_PUSH([C++])
  63. CXXFLAGS_SAVE=$CXXFLAGS
  64. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/chrono.hpp>]],
  65. [[boost::chrono::system_clock::time_point time;]])],
  66. ax_cv_boost_chrono=yes, ax_cv_boost_chrono=no)
  67. CXXFLAGS=$CXXFLAGS_SAVE
  68. AC_LANG_POP([C++])
  69. ])
  70. if test "x$ax_cv_boost_chrono" = "xyes"; then
  71. AC_SUBST(BOOST_CPPFLAGS)
  72. AC_DEFINE(HAVE_BOOST_CHRONO,,[define if the Boost::Chrono library is available])
  73. BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
  74. LDFLAGS_SAVE=$LDFLAGS
  75. if test "x$ax_boost_user_chrono_lib" = "x"; then
  76. 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
  77. ax_lib=${libextension}
  78. AC_CHECK_LIB($ax_lib, exit,
  79. [BOOST_CHRONO_LIB="-l$ax_lib"; AC_SUBST(BOOST_CHRONO_LIB) link_chrono="yes"; break],
  80. [link_chrono="no"])
  81. done
  82. if test "x$link_chrono" != "xyes"; then
  83. 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
  84. ax_lib=${libextension}
  85. AC_CHECK_LIB($ax_lib, exit,
  86. [BOOST_CHRONO_LIB="-l$ax_lib"; AC_SUBST(BOOST_CHRONO_LIB) link_chrono="yes"; break],
  87. [link_chrono="no"])
  88. done
  89. fi
  90. else
  91. for ax_lib in $ax_boost_user_chrono_lib boost_chrono-$ax_boost_user_chrono_lib; do
  92. AC_CHECK_LIB($ax_lib, exit,
  93. [BOOST_CHRONO_LIB="-l$ax_lib"; AC_SUBST(BOOST_CHRONO_LIB) link_chrono="yes"; break],
  94. [link_chrono="no"])
  95. done
  96. fi
  97. if test "x$ax_lib" = "x"; then
  98. AC_MSG_ERROR(Could not find a version of the library!)
  99. fi
  100. if test "x$link_chrono" = "xno"; then
  101. AC_MSG_ERROR(Could not link against $ax_lib !)
  102. fi
  103. fi
  104. CPPFLAGS="$CPPFLAGS_SAVED"
  105. LDFLAGS="$LDFLAGS_SAVED"
  106. fi
  107. ])