Merge #12079: Improve prioritisetransaction test coverage
[bitcoinplatinum.git] / build-aux / m4 / ax_boost_system.m4
blob1c05450cbe1d5cc11a257f5c02284900890a973e
1 # ===========================================================================
2 #      http://www.gnu.org/software/autoconf-archive/ax_boost_system.html
3 # ===========================================================================
5 # SYNOPSIS
7 #   AX_BOOST_SYSTEM
9 # DESCRIPTION
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>.
15 #   This macro calls:
17 #     AC_SUBST(BOOST_SYSTEM_LIB)
19 #   And sets:
21 #     HAVE_BOOST_SYSTEM
23 # LICENSE
25 #   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
26 #   Copyright (c) 2008 Michael Tindal
27 #   Copyright (c) 2008 Daniel Casimiro <dan.casimiro@gmail.com>
29 #   Copying and distribution of this file, with or without modification, are
30 #   permitted in any medium without royalty provided the copyright notice
31 #   and this notice are preserved. This file is offered as-is, without any
32 #   warranty.
34 #serial 18
36 AC_DEFUN([AX_BOOST_SYSTEM],
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         )
56         if test "x$want_boost" = "xyes"; then
57         AC_REQUIRE([AC_PROG_CC])
58         AC_REQUIRE([AC_CANONICAL_BUILD])
59                 CPPFLAGS_SAVED="$CPPFLAGS"
60                 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
61                 export CPPFLAGS
63                 LDFLAGS_SAVED="$LDFLAGS"
64                 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
65                 export LDFLAGS
67         AC_CACHE_CHECK(whether the Boost::System library is available,
68                                            ax_cv_boost_system,
69         [AC_LANG_PUSH([C++])
70                          CXXFLAGS_SAVE=$CXXFLAGS
71                          CXXFLAGS=
73                          AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/system/error_code.hpp>]],
74                                     [[boost::system::error_category *a = 0;]])],
75                    ax_cv_boost_system=yes, ax_cv_boost_system=no)
76                          CXXFLAGS=$CXXFLAGS_SAVE
77              AC_LANG_POP([C++])
78                 ])
79                 if test "x$ax_cv_boost_system" = "xyes"; then
80                         AC_SUBST(BOOST_CPPFLAGS)
82                         AC_DEFINE(HAVE_BOOST_SYSTEM,,[define if the Boost::System library is available])
83             BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
85                         LDFLAGS_SAVE=$LDFLAGS
86             if test "x$ax_boost_user_system_lib" = "x"; then
87                 ax_lib=
88                 for libextension in `ls -r $BOOSTLIBDIR/libboost_system* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do
89                      ax_lib=${libextension}
90                                     AC_CHECK_LIB($ax_lib, exit,
91                                  [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
92                                  [link_system="no"])
93                                 done
94                 if test "x$link_system" != "xyes"; then
95                 for libextension in `ls -r $BOOSTLIBDIR/boost_system* 2>/dev/null | sed 's,.*/,,' | sed -e 's,\..*,,'` ; do
96                      ax_lib=${libextension}
97                                     AC_CHECK_LIB($ax_lib, exit,
98                                  [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
99                                  [link_system="no"])
100                                 done
101                 fi
103             else
104                for ax_lib in $ax_boost_user_system_lib boost_system-$ax_boost_user_system_lib; do
105                                       AC_CHECK_LIB($ax_lib, exit,
106                                    [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
107                                    [link_system="no"])
108                   done
110             fi
111             if test "x$ax_lib" = "x"; then
112                 AC_MSG_ERROR(Could not find a version of the boost_system library!)
113             fi
114                         if test "x$link_system" = "xno"; then
115                                 AC_MSG_ERROR(Could not link against $ax_lib !)
116                         fi
117                 fi
119                 CPPFLAGS="$CPPFLAGS_SAVED"
120         LDFLAGS="$LDFLAGS_SAVED"
121         fi