monotone

monotone Mtn Source Tree

Root/m4/boost.m4

1dnl Grab-bag of checks related to boost.
2
3# We don't use threads, but some Boost libraries make locking calls
4# anyway. So we need to ensure that these symbols are available.
5# But it's okay if they're just stubs. This is technically incorrect
6# if Boost is for some reason compiled without threads on a system
7# that does provide threads; we'll end up compiling monotone with
8# thread support for no reason.
9AC_DEFUN([BOOST_THREAD_STUBS],
10[AC_CHECK_FUNC([pthread_mutex_lock], [],
11# But if there isn't even a stub, find the real threading library...
12 [ACX_PTHREAD(
13# ...and if it exists, use it:
14 [LIBS="$PTHREAD_LIBS $LIBS"
15 CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"],
16# ...but if it doesn't, oh well, maybe things will work out anyway:
17 [])])
18])
19
20# Check for suitably new version of boost.
21AC_DEFUN([BOOST_VERSION_CHECK],
22[AC_LANG_ASSERT([C++])
23 AC_CACHE_CHECK([boost version 1.33.0 or newer], ac_cv_boost_version_least_1_33_0,
24 [
25 AC_COMPILE_IFELSE(
26 [#include <boost/version.hpp>
27 #if BOOST_VERSION >= 103300
28 int main() { return 0; }
29 #else
30 #error boost version is too old
31 #endif
32 ],
33 ac_cv_boost_version_least_1_33_0=yes,
34 ac_cv_boost_version_least_1_33_0=no)
35 ])
36 if test x$ac_cv_boost_version_least_1_33_0 = xno; then
37AC_MSG_ERROR([boost 1.33.0 or newer required])
38 fi
39])
40
41# We currently don't need any checks for boost version-specific bugs,
42# but we have in the past and may again. They go in this macro.
43AC_DEFUN([BOOST_VERSION_SPECIFIC_BUGS],
44[AC_LANG_ASSERT([C++])
45])
46
47# Boost libraries have a string suffix that identifies the compiler
48# they were built with, among other details. For example, it can be
49# '-gcc', '-gcc-mt', '-gcc-mt-1_31', and many other combinations
50# depending on the build system. Some systems provide symlinks that
51# hide these suffixes, avoiding this mess. However, other systems
52# don't; we have to provide a way to let the user manually specify a
53# suffix. Guessing can be very difficult, given the variety of
54# possibilities. Note that you cannot expand a variable inside the
55# second argument to AC_ARG_VAR, so we're stuck listing it twice.
56AC_DEFUN([BOOST_SUFFIX_ARG],
57[AC_ARG_VAR([BOOST_SUFFIX],
58 [Space-separated list of suffixes to try appending to the names
59 of Boost libraries. "none" means no suffix. The default is:
60 "none -gcc -mipspro -mt -sunpro -sw -mgw -gcc-mt -gcc-mt-s"])
61if test x"$BOOST_SUFFIX" = x; then
62 BOOST_SUFFIX="none -gcc -mipspro -mt -sunpro -sw -mgw -gcc-mt -gcc-mt-s"
63fi
64])
65
66# Option to link statically against Boost.
67# FIXME: Decouple prefix for boost libraries from static/shared linkage?
68AC_DEFUN([BOOST_STATIC_LINK_OPTION],
69[AC_ARG_ENABLE(static-boost,
70 AS_HELP_STRING([--enable-static-boost@<:@=prefix@:>@],
71 [use static libs from boost]),
72 [], [enable_static_boost=no])
73 case "$enable_static_boost" in
74 # unconfuse emacs: ((((
75 ""|no) static_boost_prefixes="" ;;
76 yes) static_boost_prefixes="/ /usr /opt /usr/local" ;;
77 /*) static_boost_prefixes="$enable_static_boost" ;;
78 *) AC_MSG_ERROR([prefix argument to --enable-static-boost must be an absolute path]) ;;
79 esac
80 if test x"$static_boost_prefixes" != x; then
81 AC_MSG_CHECKING([location of static boost libraries])
82 for i in ${static_boost_prefixes}
83 do
84 for s in $BOOST_SUFFIX
85 do
86 if test "x$s" = xnone; then
87 s=''
88fi
89# FIXME: We should not be hardwiring /lib64/ nor should we be
90# unconditionally overriding it with /lib/ (if there are both
91# 32- and 64-bit static Boost libraries available, we must
92# pick the one that matches the code the compiler generates).
93# Fortunately, this is C++, so we'll get link errors if we get
94# it wrong.
95if test -f $i/lib64/libboost_regex${s}.a
96then
97BOOST_LIBDIR=$i/lib64
98fi
99if test -f $i/lib/libboost_regex${s}.a
100then
101BOOST_LIBDIR=$i/lib
102fi
103 done
104 done
105 if test "x${BOOST_LIBDIR}" = x
106 then
107 AC_MSG_RESULT([not found])
108AC_MSG_ERROR([cannot find boost libraries for static link])
109 else
110 AC_MSG_RESULT([${BOOST_LIBDIR}])
111 fi
112 fi
113])
114
115# BOOST_LIB_IFELSE(library, testprog, if_found, if_not_found)
116# This is tricksome, as we only want to process a list of suffixes
117# until we've selected one; once we've done that, it must be used for
118# all libraries. (But we need the shell loop in all uses, as previous
119# scans might be unsuccessful.)
120
121AC_DEFUN([BOOST_LIB_IFELSE],
122[AC_LANG_ASSERT(C++)
123 AC_REQUIRE([BOOST_SUFFIX_ARG])
124 AC_REQUIRE([BOOST_STATIC_LINK_OPTION])
125 found=no
126 OLD_LIBS="$LIBS"
127 for s in $BOOST_SUFFIX
128 do
129 if test "x$s" = xnone; then
130 s=''
131 fi
132 if test "x${BOOST_LIBDIR}" != x; then
133 lib="${BOOST_LIBDIR}/libboost_$1${s}.a"
134 else
135 lib="-lboost_$1$s"
136 fi
137
138 LIBS="$lib $OLD_LIBS"
139 cv=AS_TR_SH([ac_cv_boost_lib_$1${s}_${BOOST_LIBDIR}])
140 AC_CACHE_CHECK([for the boost_$1$s library],
141 $cv,
142 [AC_LINK_IFELSE([$2],
143 [eval $cv=yes],
144 [eval $cv=no])])
145 if eval "test \"\${$cv}\" = yes"; then
146 found=yes
147 break
148 fi
149 done
150 LIBS="$OLD_LIBS"
151 AS_IF([test $found = yes],
152 [BOOST_SUFFIX=${s:-none}
153 $3],
154 [$4])])
155
156# Checks for specific boost libraries.
157# These are named MTN_BOOST_* because their actions are monotone-specific.
158
159AC_DEFUN([MTN_NEED_BOOST_LIB],
160[BOOST_LIB_IFELSE([$1], [$2],
161 [BOOSTLIBS="$lib $BOOSTLIBS"],
162 [AC_MSG_FAILURE([the boost_$1 library is required])])
163 AC_SUBST(BOOSTLIBS)
164])
165
166AC_DEFUN([MTN_BOOST_LIB_REGEX],
167[MTN_NEED_BOOST_LIB([regex],
168 [AC_LANG_PROGRAM([[
169 #include <boost/regex.hpp>
170 using namespace boost;
171 ]],[[
172 regex expr("foo");
173 ]])])])

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status