Alexander Afanasyev | fad679c | 2014-01-06 18:09:26 -0800 | [diff] [blame^] | 1 | # ================================================================================ |
| 2 | # http://www.gnu.org/software/autoconf-archive/ax_boost_unit_test_framework.html |
| 3 | # ================================================================================ |
| 4 | # |
| 5 | # SYNOPSIS |
| 6 | # |
| 7 | # AX_BOOST_UNIT_TEST_FRAMEWORK |
| 8 | # |
| 9 | # DESCRIPTION |
| 10 | # |
| 11 | # Test for Unit_Test_Framework library from the Boost C++ libraries. The |
| 12 | # macro requires a preceding call to AX_BOOST_BASE. Further documentation |
| 13 | # is available at <http://randspringer.de/boost/index.html>. |
| 14 | # |
| 15 | # This macro calls: |
| 16 | # |
| 17 | # AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB) |
| 18 | # |
| 19 | # And sets: |
| 20 | # |
| 21 | # HAVE_BOOST_UNIT_TEST_FRAMEWORK |
| 22 | # |
| 23 | # LICENSE |
| 24 | # |
| 25 | # Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de> |
| 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 | |
| 32 | #serial 19 |
| 33 | |
| 34 | AC_DEFUN([AX_BOOST_UNIT_TEST_FRAMEWORK], |
| 35 | [ |
| 36 | AC_ARG_WITH([boost-unit-test-framework], |
| 37 | AS_HELP_STRING([--with-boost-unit-test-framework@<:@=special-lib@:>@], |
| 38 | [use the Unit_Test_Framework library from boost - it is possible to specify a certain library for the linker |
| 39 | e.g. --with-boost-unit-test-framework=boost_unit_test_framework-gcc ]), |
| 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_unit_test_framework_lib="" |
| 46 | else |
| 47 | want_boost="yes" |
| 48 | ax_boost_user_unit_test_framework_lib="$withval" |
| 49 | fi |
| 50 | ], |
| 51 | [want_boost="yes"] |
| 52 | ) |
| 53 | |
| 54 | if test "x$want_boost" = "xyes"; then |
| 55 | AC_REQUIRE([AC_PROG_CC]) |
| 56 | CPPFLAGS_SAVED="$CPPFLAGS" |
| 57 | CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" |
| 58 | export CPPFLAGS |
| 59 | |
| 60 | LDFLAGS_SAVED="$LDFLAGS" |
| 61 | LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" |
| 62 | export LDFLAGS |
| 63 | |
| 64 | AC_CACHE_CHECK(whether the Boost::Unit_Test_Framework library is available, |
| 65 | ax_cv_boost_unit_test_framework, |
| 66 | [AC_LANG_PUSH([C++]) |
| 67 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/test/unit_test.hpp>]], |
| 68 | [[using boost::unit_test::test_suite; |
| 69 | test_suite* test= BOOST_TEST_SUITE( "Unit test example 1" ); return 0;]])], |
| 70 | ax_cv_boost_unit_test_framework=yes, ax_cv_boost_unit_test_framework=no) |
| 71 | AC_LANG_POP([C++]) |
| 72 | ]) |
| 73 | if test "x$ax_cv_boost_unit_test_framework" = "xyes"; then |
| 74 | AC_DEFINE(HAVE_BOOST_UNIT_TEST_FRAMEWORK,,[define if the Boost::Unit_Test_Framework library is available]) |
| 75 | BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` |
| 76 | |
| 77 | if test "x$ax_boost_user_unit_test_framework_lib" = "x"; then |
| 78 | saved_ldflags="${LDFLAGS}" |
| 79 | for monitor_library in `ls $BOOSTLIBDIR/libboost_unit_test_framework*.so* $BOOSTLIBDIR/libboost_unit_test_framework*.dylib* $BOOSTLIBDIR/libboost_unit_test_framework*.a* 2>/dev/null` ; do |
| 80 | if test -r $monitor_library ; then |
| 81 | libextension=`echo $monitor_library | sed 's,.*/,,' | sed -e 's;^lib\(boost_unit_test_framework.*\)\.so.*$;\1;' -e 's;^lib\(boost_unit_test_framework.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_unit_test_framework.*\)\.a.*$;\1;'` |
| 82 | ax_lib=${libextension} |
| 83 | link_unit_test_framework="yes" |
| 84 | else |
| 85 | link_unit_test_framework="no" |
| 86 | fi |
| 87 | |
| 88 | if test "x$link_unit_test_framework" = "xyes"; then |
| 89 | BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib" |
| 90 | AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB) |
| 91 | break |
| 92 | fi |
| 93 | done |
| 94 | if test "x$link_unit_test_framework" != "xyes"; then |
| 95 | for libextension in `ls $BOOSTLIBDIR/boost_unit_test_framework*.dll* $BOOSTLIBDIR/boost_unit_test_framework*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_unit_test_framework.*\)\.dll.*$;\1;' -e 's;^\(boost_unit_test_framework.*\)\.a.*$;\1;'` ; do |
| 96 | ax_lib=${libextension} |
| 97 | AC_CHECK_LIB($ax_lib, exit, |
| 98 | [BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib"; AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB) link_unit_test_framework="yes"; break], |
| 99 | [link_unit_test_framework="no"]) |
| 100 | done |
| 101 | fi |
| 102 | else |
| 103 | link_unit_test_framework="no" |
| 104 | saved_ldflags="${LDFLAGS}" |
| 105 | for ax_lib in boost_unit_test_framework-$ax_boost_user_unit_test_framework_lib $ax_boost_user_unit_test_framework_lib ; do |
| 106 | if test "x$link_unit_test_framework" = "xyes"; then |
| 107 | break; |
| 108 | fi |
| 109 | for unittest_library in `ls $BOOSTLIBDIR/lib${ax_lib}.so* $BOOSTLIBDIR/lib${ax_lib}.a* 2>/dev/null` ; do |
| 110 | if test -r $unittest_library ; then |
| 111 | libextension=`echo $unittest_library | sed 's,.*/,,' | sed -e 's;^lib\(boost_unit_test_framework.*\)\.so.*$;\1;' -e 's;^lib\(boost_unit_test_framework.*\)\.a*$;\1;'` |
| 112 | ax_lib=${libextension} |
| 113 | link_unit_test_framework="yes" |
| 114 | else |
| 115 | link_unit_test_framework="no" |
| 116 | fi |
| 117 | |
| 118 | if test "x$link_unit_test_framework" = "xyes"; then |
| 119 | BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib" |
| 120 | AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB) |
| 121 | break |
| 122 | fi |
| 123 | done |
| 124 | done |
| 125 | fi |
| 126 | if test "x$ax_lib" = "x"; then |
| 127 | AC_MSG_ERROR(Could not find a version of the library!) |
| 128 | fi |
| 129 | if test "x$link_unit_test_framework" != "xyes"; then |
| 130 | AC_MSG_ERROR(Could not link against $ax_lib !) |
| 131 | fi |
| 132 | fi |
| 133 | |
| 134 | CPPFLAGS="$CPPFLAGS_SAVED" |
| 135 | LDFLAGS="$LDFLAGS_SAVED" |
| 136 | fi |
| 137 | ]) |