1 # ================================================================================
2 # http://www.gnu.org/software/autoconf-archive/ax_boost_unit_test_framework.html
3 # ================================================================================
7 # AX_BOOST_UNIT_TEST_FRAMEWORK
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>.
17 # AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB)
21 # HAVE_BOOST_UNIT_TEST_FRAMEWORK
25 # Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
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_UNIT_TEST_FRAMEWORK],
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 ]),
41 if test "$withval" = "no"; then
43 elif test "$withval" = "yes"; then
45 ax_boost_user_unit_test_framework_lib=""
48 ax_boost_user_unit_test_framework_lib="$withval"
54 if test "x$want_boost" = "xyes"; then
55 AC_REQUIRE([AC_PROG_CC])
56 CPPFLAGS_SAVED="$CPPFLAGS"
57 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
60 LDFLAGS_SAVED="$LDFLAGS"
61 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
64 AC_CACHE_CHECK(whether the Boost::Unit_Test_Framework library is available,
65 ax_cv_boost_unit_test_framework,
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)
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/@<:@^\/@:>@*//'`
77 if test "x$ax_boost_user_unit_test_framework_lib" = "x"; then
78 saved_ldflags="${LDFLAGS}"
80 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
81 if test -r $monitor_library ; then
82 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;'`
83 ax_lib=${libextension}
84 link_unit_test_framework="yes"
86 link_unit_test_framework="no"
89 if test "x$link_unit_test_framework" = "xyes"; then
90 BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib"
91 AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB)
95 if test "x$link_unit_test_framework" != "xyes"; then
96 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
97 ax_lib=${libextension}
98 AC_CHECK_LIB($ax_lib, exit,
99 [BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib"; AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB) link_unit_test_framework="yes"; break],
100 [link_unit_test_framework="no"])
104 link_unit_test_framework="no"
105 saved_ldflags="${LDFLAGS}"
106 for ax_lib in boost_unit_test_framework-$ax_boost_user_unit_test_framework_lib $ax_boost_user_unit_test_framework_lib ; do
107 if test "x$link_unit_test_framework" = "xyes"; then
110 for unittest_library in `ls $BOOSTLIBDIR/lib${ax_lib}.so* $BOOSTLIBDIR/lib${ax_lib}.a* 2>/dev/null` ; do
111 if test -r $unittest_library ; then
112 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;'`
113 ax_lib=${libextension}
114 link_unit_test_framework="yes"
116 link_unit_test_framework="no"
119 if test "x$link_unit_test_framework" = "xyes"; then
120 BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib"
121 AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB)
127 if test "x$ax_lib" = "x"; then
128 AC_MSG_ERROR(Could not find a version of the boost_unit_test_framework library!)
130 if test "x$link_unit_test_framework" != "xyes"; then
131 AC_MSG_ERROR(Could not link against $ax_lib !)
135 CPPFLAGS="$CPPFLAGS_SAVED"
136 LDFLAGS="$LDFLAGS_SAVED"