fix hazptr_array move
[folly.git] / folly / m4 / ax_boost_context.m4
1 # ===========================================================================
2 #     http://www.gnu.org/software/autoconf-archive/ax_boost_context.html
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 #   AX_BOOST_CONTEXT
8 #
9 # DESCRIPTION
10 #
11 #   Test for Context library from the Boost C++ libraries. The macro
12 #   requires a preceding call to AX_BOOST_BASE. Further documentation is
13 #   available at <http://randspringer.de/boost/index.html>.
14 #
15 #   This macro calls:
16 #
17 #     AC_SUBST(BOOST_CONTEXT_LIB)
18 #
19 #   And sets:
20 #
21 #     HAVE_BOOST_CONTEXT
22 #
23 # LICENSE
24 #
25 #   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
26 #   Copyright (c) 2008 Michael Tindal
27 #   Copyright (c) 2013 Daniel Casimiro <dan.casimiro@gmail.com>
28 #
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.
33
34 #serial 1
35
36 AC_DEFUN([AX_BOOST_CONTEXT],
37 [
38         AC_ARG_WITH([boost-context],
39                 AS_HELP_STRING([--with-boost-context@<:@=special-lib@:>@],
40                 [use the Context library from boost - it is possible to specify a certain library for the linker
41                         e.g. --with-boost-context=boost_context-gcc-mt ]), [
42                 if test "$withval" = "no"; then
43                         want_boost="no"
44                 elif test "$withval" = "yes"; then
45                         want_boost="yes"
46                         ax_boost_user_context_lib=""
47                 else
48                         want_boost="yes"
49                         ax_boost_user_context_lib="$withval"
50                 fi
51                 ], [want_boost="yes"]
52         )
53
54         if test "x$want_boost" = "xyes"; then
55                 AC_REQUIRE([AC_PROG_CC])
56                 AC_REQUIRE([AC_CANONICAL_BUILD])
57
58                 CPPFLAGS_SAVED="$CPPFLAGS"
59                 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
60                 export CPPFLAGS
61
62                 LDFLAGS_SAVED="$LDFLAGS"
63                 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
64                 export LDFLAGS
65
66                 AC_CACHE_CHECK(whether the Boost::Context library is available,
67                         ax_cv_boost_context,
68                         [AC_LANG_PUSH([C++])
69                         CXXFLAGS_SAVE=$CXXFLAGS
70
71                         AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
72                                 [[@%:@include <boost/version.hpp>
73 #if BOOST_VERSION >= 106100
74 #include <boost/context/detail/fcontext.hpp>
75 #else
76 #include <boost/context/fcontext.hpp>
77 #endif
78 ]],
79                                 [[#if BOOST_VERSION >= 106100
80   boost::context::detail::fcontext_t fc = boost::context::detail::make_fcontext(0, 0, 0);
81 #elif BOOST_VERSION >= 105600
82   boost::context::fcontext_t fc = boost::context::make_fcontext(0, 0, 0);
83 #else
84   boost::context::fcontext_t* fc = boost::context::make_fcontext(0, 0, 0);
85 #endif
86 ]]
87                                 )],
88                                 ax_cv_boost_context=yes, ax_cv_boost_context=no)
89                                 CXXFLAGS=$CXXFLAGS_SAVE
90                         AC_LANG_POP([C++])
91                 ])
92
93                 if test "x$ax_cv_boost_context" = "xyes"; then
94                         AC_SUBST(BOOST_CPPFLAGS)
95
96                         AC_DEFINE(HAVE_BOOST_CONTEXT,,[define if the Boost::Context library is available])
97                         BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
98
99                         if test "x$ax_boost_user_context_lib" = "x"; then
100                                 for libextension in `ls $BOOSTLIBDIR/libboost_context*.so* $BOOSTLIBDIR/libboost_context*.dylib* $BOOSTLIBDIR/libboost_context*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_context.*\)\.so.*$;\1;' -e 's;^lib\(boost_context.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_context.*\)\.a.*$;\1;'` ; do
101                                         ax_lib=${libextension}
102                                         AC_CHECK_LIB($ax_lib, exit,
103                                                 [BOOST_CONTEXT_LIB="-l$ax_lib"; AC_SUBST(BOOST_CONTEXT_LIB) link_context="yes"; break],
104                                         [link_context="no"])
105                                 done
106
107                                 if test "x$link_context" != "xyes"; then
108                                         for libextension in `ls $BOOSTLIBDIR/boost_context*.dll* $BOOSTLIBDIR/boost_context*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_context.*\)\.dll.*$;\1;' -e 's;^\(boost_context.*\)\.a.*$;\1;'` ; do
109                                                 ax_lib=${libextension}
110                                                 AC_CHECK_LIB($ax_lib, exit,
111                                                         [BOOST_CONTEXT_LIB="-l$ax_lib"; AC_SUBST(BOOST_CONTEXT_LIB) link_context="yes"; break],
112                                                         [link_context="no"])
113                                         done
114                                 fi
115
116                         else
117                                 for ax_lib in $ax_boost_user_context_lib boost_context-$ax_boost_user_context_lib; do
118                                         AC_CHECK_LIB($ax_lib, exit,
119                                                 [BOOST_CONTEXT_LIB="-l$ax_lib"; AC_SUBST(BOOST_CONTEXT_LIB) link_context="yes"; break],
120                                                 [link_context="no"])
121                                 done
122                         fi
123
124                         if test "x$ax_lib" = "x"; then
125                                 AC_MSG_ERROR(Could not find a version of the library!)
126                         fi
127
128                         if test "x$link_context" = "xno"; then
129                                 AC_MSG_ERROR(Could not link against $ax_lib !)
130                         fi
131                 fi
132
133                 CPPFLAGS="$CPPFLAGS_SAVED"
134                 LDFLAGS="$LDFLAGS_SAVED"
135         fi
136 ])
137