Merge #11667: Add scripts to dumpwallet RPC
[bitcoinplatinum.git] / build-aux / m4 / ax_boost_unit_test_framework.m4
blob4efd1e2f18be12e19176f772ad41f07a823a0c85
1 # ================================================================================
2 #  http://www.gnu.org/software/autoconf-archive/ax_boost_unit_test_framework.html
3 # ================================================================================
5 # SYNOPSIS
7 #   AX_BOOST_UNIT_TEST_FRAMEWORK
9 # DESCRIPTION
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>.
15 #   This macro calls:
17 #     AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB)
19 #   And sets:
21 #     HAVE_BOOST_UNIT_TEST_FRAMEWORK
23 # LICENSE
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
30 #   warranty.
32 #serial 19
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 ]),
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         )
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
60                 LDFLAGS_SAVED="$LDFLAGS"
61                 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
62                 export LDFLAGS
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/@<:@^\/@:>@*//'`
77             if test "x$ax_boost_user_unit_test_framework_lib" = "x"; then
78                         saved_ldflags="${LDFLAGS}"
79                 ax_lib=
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"
85                     else
86                        link_unit_test_framework="no"
87                     fi
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)
92                                           break
93                                     fi
94                 done
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"])
101                                 done
102                 fi
103             else
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
108                       break;
109                    fi
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"
115                     else
116                        link_unit_test_framework="no"
117                     fi
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)
122                                             break
123                                     fi
124                   done
125                done
126             fi
127             if test "x$ax_lib" = "x"; then
128                 AC_MSG_ERROR(Could not find a version of the boost_unit_test_framework library!)
129             fi
130                         if test "x$link_unit_test_framework" != "xyes"; then
131                                 AC_MSG_ERROR(Could not link against $ax_lib !)
132                         fi
133                 fi
135                 CPPFLAGS="$CPPFLAGS_SAVED"
136         LDFLAGS="$LDFLAGS_SAVED"
137         fi