ax_boost_system.m4 4.1 KB

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