ax_boost_system.m4 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. # ===========================================================================
  2. # http://www.gnu.org/software/autoconf-archive/ax_boost_system.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_BOOST_SYSTEM
  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_SYSTEM_LIB)
  18. #
  19. # And sets:
  20. #
  21. # HAVE_BOOST_SYSTEM
  22. #
  23. # LICENSE
  24. #
  25. # Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
  26. # Copyright (c) 2008 Michael Tindal
  27. # Copyright (c) 2008 Daniel Casimiro <dan.casimiro@gmail.com>
  28. #
  29. # Copying and distribution of this file, with or without modification, are
  30. # permitted in any medium without royalty provided the copyright notice
  31. # and this notice are preserved. This file is offered as-is, without any
  32. # warranty.
  33. #serial 17
  34. AC_DEFUN([AX_BOOST_SYSTEM],
  35. [
  36. AC_ARG_WITH([boost-system],
  37. AS_HELP_STRING([--with-boost-system@<:@=special-lib@:>@],
  38. [use the System library from boost - it is possible to specify a certain library for the linker
  39. e.g. --with-boost-system=boost_system-gcc-mt ]),
  40. [
  41. if test "$withval" = "no"; then
  42. want_boost="no"
  43. elif test "$withval" = "yes"; then
  44. want_boost="yes"
  45. ax_boost_user_system_lib=""
  46. else
  47. want_boost="yes"
  48. ax_boost_user_system_lib="$withval"
  49. fi
  50. ],
  51. [want_boost="yes"]
  52. )
  53. if test "x$want_boost" = "xyes"; then
  54. AC_REQUIRE([AC_PROG_CC])
  55. AC_REQUIRE([AC_CANONICAL_BUILD])
  56. CPPFLAGS_SAVED="$CPPFLAGS"
  57. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  58. export CPPFLAGS
  59. LDFLAGS_SAVED="$LDFLAGS"
  60. LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
  61. export LDFLAGS
  62. AC_CACHE_CHECK(whether the Boost::System library is available,
  63. ax_cv_boost_system,
  64. [AC_LANG_PUSH([C++])
  65. CXXFLAGS_SAVE=$CXXFLAGS
  66. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/system/error_code.hpp>]],
  67. [[boost::system::system_category]])],
  68. ax_cv_boost_system=yes, ax_cv_boost_system=no)
  69. CXXFLAGS=$CXXFLAGS_SAVE
  70. AC_LANG_POP([C++])
  71. ])
  72. if test "x$ax_cv_boost_system" = "xyes"; then
  73. AC_SUBST(BOOST_CPPFLAGS)
  74. AC_DEFINE(HAVE_BOOST_SYSTEM,,[define if the Boost::System library is available])
  75. BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
  76. LDFLAGS_SAVE=$LDFLAGS
  77. if test "x$ax_boost_user_system_lib" = "x"; then
  78. for libextension in `ls -r $BOOSTLIBDIR/libboost_system* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do
  79. ax_lib=${libextension}
  80. AC_CHECK_LIB($ax_lib, exit,
  81. [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
  82. [link_system="no"])
  83. done
  84. if test "x$link_system" != "xyes"; then
  85. for libextension in `ls -r $BOOSTLIBDIR/boost_system* 2>/dev/null | sed 's,.*/,,' | sed -e 's,\..*,,'` ; do
  86. ax_lib=${libextension}
  87. AC_CHECK_LIB($ax_lib, exit,
  88. [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
  89. [link_system="no"])
  90. done
  91. fi
  92. else
  93. for ax_lib in $ax_boost_user_system_lib boost_system-$ax_boost_user_system_lib; do
  94. AC_CHECK_LIB($ax_lib, exit,
  95. [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
  96. [link_system="no"])
  97. done
  98. fi
  99. if test "x$ax_lib" = "x"; then
  100. AC_MSG_ERROR(Could not find a version of the library!)
  101. fi
  102. if test "x$link_system" = "xno"; then
  103. AC_MSG_ERROR(Could not link against $ax_lib !)
  104. fi
  105. fi
  106. CPPFLAGS="$CPPFLAGS_SAVED"
  107. LDFLAGS="$LDFLAGS_SAVED"
  108. fi
  109. ])