Obsolete libgettext
[libi2ncommon] / m4 / ax_boost_unit_test_framework.m4
CommitLineData
9fe0853b
TJ
1# ===========================================================================
2# http://www.nongnu.org/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.
30
31AC_DEFUN([AX_BOOST_UNIT_TEST_FRAMEWORK],
32[
33 AC_ARG_WITH([boost-unit-test-framework],
34 AS_HELP_STRING([--with-boost-unit-test-framework@<:@=special-lib@:>@],
35 [use the Unit_Test_Framework library from boost - it is possible to specify a certain library for the linker
36 e.g. --with-boost-unit-test-framework=boost_unit_test_framework-gcc ]),
37 [
38 if test "$withval" = "no"; then
39 want_boost="no"
40 elif test "$withval" = "yes"; then
41 want_boost="yes"
42 ax_boost_user_unit_test_framework_lib=""
43 else
44 want_boost="yes"
45 ax_boost_user_unit_test_framework_lib="$withval"
46 fi
47 ],
48 [want_boost="yes"]
49 )
50
51 if test "x$want_boost" = "xyes"; then
52 AC_REQUIRE([AC_PROG_CC])
53 CPPFLAGS_SAVED="$CPPFLAGS"
54 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
55 export CPPFLAGS
56
57 LDFLAGS_SAVED="$LDFLAGS"
58 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
59 export LDFLAGS
60
61 AC_CACHE_CHECK(whether the Boost::Unit_Test_Framework library is available,
62 ax_cv_boost_unit_test_framework,
63 [AC_LANG_PUSH([C++])
64 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/test/unit_test.hpp>]],
65 [[using boost::unit_test::test_suite;
66 test_suite* test= BOOST_TEST_SUITE( "Unit test example 1" ); return 0;]]),
67 ax_cv_boost_unit_test_framework=yes, ax_cv_boost_unit_test_framework=no)
68 AC_LANG_POP([C++])
69 ])
70 if test "x$ax_cv_boost_unit_test_framework" = "xyes"; then
71 AC_DEFINE(HAVE_BOOST_UNIT_TEST_FRAMEWORK,,[define if the Boost::Unit_Test_Framework library is available])
72 BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
73
74 if test "x$ax_boost_user_unit_test_framework_lib" = "x"; then
75 saved_ldflags="${LDFLAGS}"
76 for monitor_library in `ls $BOOSTLIBDIR/libboost_unit_test_framework*.{so,a}* 2>/dev/null` ; do
77 if test -r $monitor_library ; then
78 libextension=`echo $monitor_library | sed 's,.*/,,' | sed -e 's;^lib\(boost_unit_test_framework.*\)\.so.*$;\1;' -e 's;^lib\(boost_unit_test_framework.*\)\.a*$;\1;'`
79 ax_lib=${libextension}
80 link_unit_test_framework="yes"
81 else
82 link_unit_test_framework="no"
83 fi
84
85 if test "x$link_unit_test_framework" = "xyes"; then
86 BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib"
87 AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB)
88 break
89 fi
90 done
91 if test "x$link_unit_test_framework" != "xyes"; then
92 for libextension in `ls $BOOSTLIBDIR/boost_unit_test_framework*.{dll,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_unit_test_framework.*\)\.dll.*$;\1;' -e 's;^\(boost_unit_test_framework.*\)\.a*$;\1;'` ; do
93 ax_lib=${libextension}
94 AC_CHECK_LIB($ax_lib, exit,
95 [BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib"; AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB) link_unit_test_framework="yes"; break],
96 [link_unit_test_framework="no"])
97 done
98 fi
99 else
100 link_unit_test_framework="no"
101 saved_ldflags="${LDFLAGS}"
102 for ax_lib in boost_unit_test_framework-$ax_boost_user_unit_test_framework_lib $ax_boost_user_unit_test_framework_lib ; do
103 if test "x$link_unit_test_framework" = "xyes"; then
104 break;
105 fi
106 for unittest_library in `ls $BOOSTLIBDIR/lib${ax_lib}.{so,a}* 2>/dev/null` ; do
107 if test -r $unittest_library ; then
108 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;'`
109 ax_lib=${libextension}
110 link_unit_test_framework="yes"
111 else
112 link_unit_test_framework="no"
113 fi
114
115 if test "x$link_unit_test_framework" = "xyes"; then
116 BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib"
117 AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB)
118 break
119 fi
120 done
121 done
122 fi
123 if test "x$link_unit_test_framework" != "xyes"; then
124 AC_MSG_ERROR(Could not link against $ax_lib !)
125 fi
126 fi
127
128 CPPFLAGS="$CPPFLAGS_SAVED"
129 LDFLAGS="$LDFLAGS_SAVED"
130 fi
131])