1 | # boost.m4: Locate Boost headers and libraries for autoconf-based projects.
|
---|
2 | # Copyright (C) 2007, 2008, 2009, 2010, 2011 Benoit Sigoure <tsuna@lrde.epita.fr>
|
---|
3 | #
|
---|
4 | # This program is free software: you can redistribute it and/or modify
|
---|
5 | # it under the terms of the GNU General Public License as published by
|
---|
6 | # the Free Software Foundation, either version 3 of the License, or
|
---|
7 | # (at your option) any later version.
|
---|
8 | #
|
---|
9 | # Additional permission under section 7 of the GNU General Public
|
---|
10 | # License, version 3 ("GPLv3"):
|
---|
11 | #
|
---|
12 | # If you convey this file as part of a work that contains a
|
---|
13 | # configuration script generated by Autoconf, you may do so under
|
---|
14 | # terms of your choice.
|
---|
15 | #
|
---|
16 | # This program is distributed in the hope that it will be useful,
|
---|
17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | # GNU General Public License for more details.
|
---|
20 | #
|
---|
21 | # You should have received a copy of the GNU General Public License
|
---|
22 | # along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
23 |
|
---|
24 | m4_define([_BOOST_SERIAL], [m4_translit([
|
---|
25 | # serial 16
|
---|
26 | ], [#
|
---|
27 | ], [])])
|
---|
28 |
|
---|
29 | # Original sources can be found at http://github.com/tsuna/boost.m4
|
---|
30 | # You can fetch the latest version of the script by doing:
|
---|
31 | # wget http://github.com/tsuna/boost.m4/raw/master/build-aux/boost.m4
|
---|
32 |
|
---|
33 | # ------ #
|
---|
34 | # README #
|
---|
35 | # ------ #
|
---|
36 |
|
---|
37 | # This file provides several macros to use the various Boost libraries.
|
---|
38 | # The first macro is BOOST_REQUIRE. It will simply check if it's possible to
|
---|
39 | # find the Boost headers of a given (optional) minimum version and it will
|
---|
40 | # define BOOST_CPPFLAGS accordingly. It will add an option --with-boost to
|
---|
41 | # your configure so that users can specify non standard locations.
|
---|
42 | # If the user's environment contains BOOST_ROOT and --with-boost was not
|
---|
43 | # specified, --with-boost=$BOOST_ROOT is implicitly used.
|
---|
44 | # For more README and documentation, go to http://github.com/tsuna/boost.m4
|
---|
45 | # Note: THESE MACROS ASSUME THAT YOU USE LIBTOOL. If you don't, don't worry,
|
---|
46 | # simply read the README, it will show you what to do step by step.
|
---|
47 |
|
---|
48 | m4_pattern_forbid([^_?(BOOST|Boost)_])
|
---|
49 |
|
---|
50 |
|
---|
51 | # _BOOST_SED_CPP(SED-PROGRAM, PROGRAM,
|
---|
52 | # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
|
---|
53 | # --------------------------------------------------------
|
---|
54 | # Same as AC_EGREP_CPP, but leave the result in conftest.i.
|
---|
55 | #
|
---|
56 | # SED-PROGRAM is *not* overquoted, as in AC_EGREP_CPP. It is expanded
|
---|
57 | # in double-quotes, so escape your double quotes.
|
---|
58 | #
|
---|
59 | # It could be useful to turn this into a macro which extracts the
|
---|
60 | # value of any macro.
|
---|
61 | m4_define([_BOOST_SED_CPP],
|
---|
62 | [AC_LANG_PREPROC_REQUIRE()dnl
|
---|
63 | AC_REQUIRE([AC_PROG_SED])dnl
|
---|
64 | AC_LANG_CONFTEST([AC_LANG_SOURCE([[$2]])])
|
---|
65 | AS_IF([dnl eval is necessary to expand ac_cpp.
|
---|
66 | dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
|
---|
67 | dnl Beware of Windows end-of-lines, for instance if we are running
|
---|
68 | dnl some Windows programs under Wine. In that case, boost/version.hpp
|
---|
69 | dnl is certainly using "\r\n", but the regular Unix shell will only
|
---|
70 | dnl strip `\n' with backquotes, not the `\r'. This results in
|
---|
71 | dnl boost_cv_lib_version='1_37\r' for instance, which breaks
|
---|
72 | dnl everything else.
|
---|
73 | dnl Cannot use 'dnl' after [$4] because a trailing dnl may break AC_CACHE_CHECK
|
---|
74 | (eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
|
---|
75 | tr -d '\r' |
|
---|
76 | $SED -n -e "$1" >conftest.i 2>&1],
|
---|
77 | [$3],
|
---|
78 | [$4])
|
---|
79 | rm -rf conftest*
|
---|
80 | ])# AC_EGREP_CPP
|
---|
81 |
|
---|
82 |
|
---|
83 |
|
---|
84 | # BOOST_REQUIRE([VERSION], [ACTION-IF-NOT-FOUND])
|
---|
85 | # -----------------------------------------------
|
---|
86 | # Look for Boost. If version is given, it must either be a literal of the form
|
---|
87 | # "X.Y.Z" where X, Y and Z are integers (the ".Z" part being optional) or a
|
---|
88 | # variable "$var".
|
---|
89 | # Defines the value BOOST_CPPFLAGS. This macro only checks for headers with
|
---|
90 | # the required version, it does not check for any of the Boost libraries.
|
---|
91 | # On # success, defines HAVE_BOOST. On failure, calls the optional
|
---|
92 | # ACTION-IF-NOT-FOUND action if one was supplied.
|
---|
93 | # Otherwise aborts with an error message.
|
---|
94 | AC_DEFUN([BOOST_REQUIRE],
|
---|
95 | [AC_REQUIRE([AC_PROG_CXX])dnl
|
---|
96 | AC_REQUIRE([AC_PROG_GREP])dnl
|
---|
97 | echo "$as_me: this is boost.m4[]_BOOST_SERIAL" >&AS_MESSAGE_LOG_FD
|
---|
98 | boost_save_IFS=$IFS
|
---|
99 | boost_version_req=$1
|
---|
100 | IFS=.
|
---|
101 | set x $boost_version_req 0 0 0
|
---|
102 | IFS=$boost_save_IFS
|
---|
103 | shift
|
---|
104 | boost_version_req=`expr "$[1]" '*' 100000 + "$[2]" '*' 100 + "$[3]"`
|
---|
105 | boost_version_req_string=$[1].$[2].$[3]
|
---|
106 | AC_ARG_WITH([boost],
|
---|
107 | [AS_HELP_STRING([--with-boost=DIR],
|
---|
108 | [prefix of Boost $1 @<:@guess@:>@])])dnl
|
---|
109 | AC_ARG_VAR([BOOST_ROOT],[Location of Boost installation])dnl
|
---|
110 | # If BOOST_ROOT is set and the user has not provided a value to
|
---|
111 | # --with-boost, then treat BOOST_ROOT as if it the user supplied it.
|
---|
112 | if test x"$BOOST_ROOT" != x; then
|
---|
113 | if test x"$with_boost" = x; then
|
---|
114 | AC_MSG_NOTICE([Detected BOOST_ROOT; continuing with --with-boost=$BOOST_ROOT])
|
---|
115 | with_boost=$BOOST_ROOT
|
---|
116 | else
|
---|
117 | AC_MSG_NOTICE([Detected BOOST_ROOT=$BOOST_ROOT, but overridden by --with-boost=$with_boost])
|
---|
118 | fi
|
---|
119 | fi
|
---|
120 | AC_SUBST([DISTCHECK_CONFIGURE_FLAGS],
|
---|
121 | ["$DISTCHECK_CONFIGURE_FLAGS '--with-boost=$with_boost'"])dnl
|
---|
122 | boost_save_CPPFLAGS=$CPPFLAGS
|
---|
123 | AC_CACHE_CHECK([for Boost headers version >= $boost_version_req_string],
|
---|
124 | [boost_cv_inc_path],
|
---|
125 | [boost_cv_inc_path=no
|
---|
126 | AC_LANG_PUSH([C++])dnl
|
---|
127 | m4_pattern_allow([^BOOST_VERSION$])dnl
|
---|
128 | AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#include <boost/version.hpp>
|
---|
129 | #if !defined BOOST_VERSION
|
---|
130 | # error BOOST_VERSION is not defined
|
---|
131 | #elif BOOST_VERSION < $boost_version_req
|
---|
132 | # error Boost headers version < $boost_version_req
|
---|
133 | #endif
|
---|
134 | ]])])
|
---|
135 | # If the user provided a value to --with-boost, use it and only it.
|
---|
136 | case $with_boost in #(
|
---|
137 | ''|yes) set x '' /opt/local/include /usr/local/include /opt/include \
|
---|
138 | /usr/include C:/Boost/include;; #(
|
---|
139 | *) set x "$with_boost/include" "$with_boost";;
|
---|
140 | esac
|
---|
141 | shift
|
---|
142 | for boost_dir
|
---|
143 | do
|
---|
144 | # Without --layout=system, Boost (or at least some versions) installs
|
---|
145 | # itself in <prefix>/include/boost-<version>. This inner loop helps to
|
---|
146 | # find headers in such directories.
|
---|
147 | #
|
---|
148 | # Any ${boost_dir}/boost-x_xx directories are searched in reverse version
|
---|
149 | # order followed by ${boost_dir}. The final '.' is a sentinel for
|
---|
150 | # searching $boost_dir" itself. Entries are whitespace separated.
|
---|
151 | #
|
---|
152 | # I didn't indent this loop on purpose (to avoid over-indented code)
|
---|
153 | boost_layout_system_search_list=`cd "$boost_dir" 2>/dev/null \
|
---|
154 | && ls -1 | "${GREP}" '^boost-' | sort -rn -t- -k2 \
|
---|
155 | && echo .`
|
---|
156 | for boost_inc in $boost_layout_system_search_list
|
---|
157 | do
|
---|
158 | if test x"$boost_inc" != x.; then
|
---|
159 | boost_inc="$boost_dir/$boost_inc"
|
---|
160 | else
|
---|
161 | boost_inc="$boost_dir" # Uses sentinel in boost_layout_system_search_list
|
---|
162 | fi
|
---|
163 | if test x"$boost_inc" != x; then
|
---|
164 | # We are going to check whether the version of Boost installed
|
---|
165 | # in $boost_inc is usable by running a compilation that
|
---|
166 | # #includes it. But if we pass a -I/some/path in which Boost
|
---|
167 | # is not installed, the compiler will just skip this -I and
|
---|
168 | # use other locations (either from CPPFLAGS, or from its list
|
---|
169 | # of system include directories). As a result we would use
|
---|
170 | # header installed on the machine instead of the /some/path
|
---|
171 | # specified by the user. So in that precise case (trying
|
---|
172 | # $boost_inc), make sure the version.hpp exists.
|
---|
173 | #
|
---|
174 | # Use test -e as there can be symlinks.
|
---|
175 | test -e "$boost_inc/boost/version.hpp" || continue
|
---|
176 | CPPFLAGS="$CPPFLAGS -I$boost_inc"
|
---|
177 | fi
|
---|
178 | AC_COMPILE_IFELSE([], [boost_cv_inc_path=yes], [boost_cv_version=no])
|
---|
179 | if test x"$boost_cv_inc_path" = xyes; then
|
---|
180 | if test x"$boost_inc" != x; then
|
---|
181 | boost_cv_inc_path=$boost_inc
|
---|
182 | fi
|
---|
183 | break 2
|
---|
184 | fi
|
---|
185 | done
|
---|
186 | done
|
---|
187 | AC_LANG_POP([C++])dnl
|
---|
188 | ])
|
---|
189 | case $boost_cv_inc_path in #(
|
---|
190 | no)
|
---|
191 | boost_errmsg="cannot find Boost headers version >= $boost_version_req_string"
|
---|
192 | m4_if([$2], [], [AC_MSG_ERROR([$boost_errmsg])],
|
---|
193 | [AC_MSG_NOTICE([$boost_errmsg])])
|
---|
194 | $2
|
---|
195 | ;;#(
|
---|
196 | yes)
|
---|
197 | BOOST_CPPFLAGS=
|
---|
198 | ;;#(
|
---|
199 | *)
|
---|
200 | AC_SUBST([BOOST_CPPFLAGS], ["-I$boost_cv_inc_path"])dnl
|
---|
201 | ;;
|
---|
202 | esac
|
---|
203 | if test x"$boost_cv_inc_path" != xno; then
|
---|
204 | AC_DEFINE([HAVE_BOOST], [1],
|
---|
205 | [Defined if the requested minimum BOOST version is satisfied])
|
---|
206 | AC_CACHE_CHECK([for Boost's header version],
|
---|
207 | [boost_cv_lib_version],
|
---|
208 | [m4_pattern_allow([^BOOST_LIB_VERSION$])dnl
|
---|
209 | _BOOST_SED_CPP([/^boost-lib-version = /{s///;s/\"//g;p;q;}],
|
---|
210 | [#include <boost/version.hpp>
|
---|
211 | boost-lib-version = BOOST_LIB_VERSION],
|
---|
212 | [boost_cv_lib_version=`cat conftest.i`])])
|
---|
213 | # e.g. "134" for 1_34_1 or "135" for 1_35
|
---|
214 | boost_major_version=`echo "$boost_cv_lib_version" | sed 's/_//;s/_.*//'`
|
---|
215 | case $boost_major_version in #(
|
---|
216 | '' | *[[!0-9]]*)
|
---|
217 | AC_MSG_ERROR([invalid value: boost_major_version=$boost_major_version])
|
---|
218 | ;;
|
---|
219 | esac
|
---|
220 | fi
|
---|
221 | CPPFLAGS=$boost_save_CPPFLAGS
|
---|
222 | ])# BOOST_REQUIRE
|
---|
223 |
|
---|
224 | # BOOST_STATIC()
|
---|
225 | # --------------
|
---|
226 | # Add the "--enable-static-boost" configure argument. If this argument is given
|
---|
227 | # on the command line, static versions of the libraries will be looked up.
|
---|
228 | AC_DEFUN([BOOST_STATIC],
|
---|
229 | [AC_ARG_ENABLE([static-boost],
|
---|
230 | [AC_HELP_STRING([--enable-static-boost],
|
---|
231 | [Prefer the static boost libraries over the shared ones [no]])],
|
---|
232 | [enable_static_boost=yes],
|
---|
233 | [enable_static_boost=no])])# BOOST_STATIC
|
---|
234 |
|
---|
235 | # BOOST_FIND_HEADER([HEADER-NAME], [ACTION-IF-NOT-FOUND], [ACTION-IF-FOUND])
|
---|
236 | # --------------------------------------------------------------------------
|
---|
237 | # Wrapper around AC_CHECK_HEADER for Boost headers. Useful to check for
|
---|
238 | # some parts of the Boost library which are only made of headers and don't
|
---|
239 | # require linking (such as Boost.Foreach).
|
---|
240 | #
|
---|
241 | # Default ACTION-IF-NOT-FOUND: Fail with a fatal error unless Boost couldn't be
|
---|
242 | # found in the first place, in which case by default a notice is issued to the
|
---|
243 | # user. Presumably if we haven't died already it's because it's OK to not have
|
---|
244 | # Boost, which is why only a notice is issued instead of a hard error.
|
---|
245 | #
|
---|
246 | # Default ACTION-IF-FOUND: define the preprocessor symbol HAVE_<HEADER-NAME> in
|
---|
247 | # case of success # (where HEADER-NAME is written LIKE_THIS, e.g.,
|
---|
248 | # HAVE_BOOST_FOREACH_HPP).
|
---|
249 | AC_DEFUN([BOOST_FIND_HEADER],
|
---|
250 | [AC_REQUIRE([BOOST_REQUIRE])dnl
|
---|
251 | if test x"$boost_cv_inc_path" = xno; then
|
---|
252 | m4_default([$2], [AC_MSG_NOTICE([Boost not available, not searching for $1])])
|
---|
253 | else
|
---|
254 | AC_LANG_PUSH([C++])dnl
|
---|
255 | boost_save_CPPFLAGS=$CPPFLAGS
|
---|
256 | CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
---|
257 | AC_CHECK_HEADER([$1],
|
---|
258 | [m4_default([$3], [AC_DEFINE(AS_TR_CPP([HAVE_$1]), [1],
|
---|
259 | [Define to 1 if you have <$1>])])],
|
---|
260 | [m4_default([$2], [AC_MSG_ERROR([cannot find $1])])])
|
---|
261 | CPPFLAGS=$boost_save_CPPFLAGS
|
---|
262 | AC_LANG_POP([C++])dnl
|
---|
263 | fi
|
---|
264 | ])# BOOST_FIND_HEADER
|
---|
265 |
|
---|
266 |
|
---|
267 | # BOOST_FIND_LIB([LIB-NAME], [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST],
|
---|
268 | # [CXX-PROLOGUE])
|
---|
269 | # -------------------------------------------------------------------------
|
---|
270 | # Look for the Boost library LIB-NAME (e.g., LIB-NAME = `thread', for
|
---|
271 | # libboost_thread). Check that HEADER-NAME works and check that
|
---|
272 | # libboost_LIB-NAME can link with the code CXX-TEST. The optional argument
|
---|
273 | # CXX-PROLOGUE can be used to include some C++ code before the `main'
|
---|
274 | # function.
|
---|
275 | #
|
---|
276 | # Invokes BOOST_FIND_HEADER([HEADER-NAME]) (see above).
|
---|
277 | #
|
---|
278 | # Boost libraries typically come compiled with several flavors (with different
|
---|
279 | # runtime options) so PREFERRED-RT-OPT is the preferred suffix. A suffix is one
|
---|
280 | # or more of the following letters: sgdpn (in that order). s = static
|
---|
281 | # runtime, d = debug build, g = debug/diagnostic runtime, p = STLPort build,
|
---|
282 | # n = (unsure) STLPort build without iostreams from STLPort (it looks like `n'
|
---|
283 | # must always be used along with `p'). Additionally, PREFERRED-RT-OPT can
|
---|
284 | # start with `mt-' to indicate that there is a preference for multi-thread
|
---|
285 | # builds. Some sample values for PREFERRED-RT-OPT: (nothing), mt, d, mt-d, gdp
|
---|
286 | # ... If you want to make sure you have a specific version of Boost
|
---|
287 | # (eg, >= 1.33) you *must* invoke BOOST_REQUIRE before this macro.
|
---|
288 | AC_DEFUN([BOOST_FIND_LIB],
|
---|
289 | [AC_REQUIRE([BOOST_REQUIRE])dnl
|
---|
290 | AC_REQUIRE([_BOOST_FIND_COMPILER_TAG])dnl
|
---|
291 | AC_REQUIRE([BOOST_STATIC])dnl
|
---|
292 | AC_REQUIRE([_BOOST_GUESS_WHETHER_TO_USE_MT])dnl
|
---|
293 | if test x"$boost_cv_inc_path" = xno; then
|
---|
294 | AC_MSG_NOTICE([Boost not available, not searching for the Boost $1 library])
|
---|
295 | else
|
---|
296 | dnl The else branch is huge and wasn't intended on purpose.
|
---|
297 | AC_LANG_PUSH([C++])dnl
|
---|
298 | AS_VAR_PUSHDEF([Boost_lib], [boost_cv_lib_$1])dnl
|
---|
299 | AS_VAR_PUSHDEF([Boost_lib_LDFLAGS], [boost_cv_lib_$1_LDFLAGS])dnl
|
---|
300 | AS_VAR_PUSHDEF([Boost_lib_LDPATH], [boost_cv_lib_$1_LDPATH])dnl
|
---|
301 | AS_VAR_PUSHDEF([Boost_lib_LIBS], [boost_cv_lib_$1_LIBS])dnl
|
---|
302 | BOOST_FIND_HEADER([$3])
|
---|
303 | boost_save_CPPFLAGS=$CPPFLAGS
|
---|
304 | CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
---|
305 | # Now let's try to find the library. The algorithm is as follows: first look
|
---|
306 | # for a given library name according to the user's PREFERRED-RT-OPT. For each
|
---|
307 | # library name, we prefer to use the ones that carry the tag (toolset name).
|
---|
308 | # Each library is searched through the various standard paths were Boost is
|
---|
309 | # usually installed. If we can't find the standard variants, we try to
|
---|
310 | # enforce -mt (for instance on MacOSX, libboost_threads.dylib doesn't exist
|
---|
311 | # but there's -obviously- libboost_threads-mt.dylib).
|
---|
312 | AC_CACHE_CHECK([for the Boost $1 library], [Boost_lib],
|
---|
313 | [Boost_lib=no
|
---|
314 | case "$2" in #(
|
---|
315 | mt | mt-) boost_mt=-mt; boost_rtopt=;; #(
|
---|
316 | mt* | mt-*) boost_mt=-mt; boost_rtopt=`expr "X$2" : 'Xmt-*\(.*\)'`;; #(
|
---|
317 | *) boost_mt=; boost_rtopt=$2;;
|
---|
318 | esac
|
---|
319 | if test $enable_static_boost = yes; then
|
---|
320 | boost_rtopt="s$boost_rtopt"
|
---|
321 | fi
|
---|
322 | # Find the proper debug variant depending on what we've been asked to find.
|
---|
323 | case $boost_rtopt in #(
|
---|
324 | *d*) boost_rt_d=$boost_rtopt;; #(
|
---|
325 | *[[sgpn]]*) # Insert the `d' at the right place (in between `sg' and `pn')
|
---|
326 | boost_rt_d=`echo "$boost_rtopt" | sed 's/\(s*g*\)\(p*n*\)/\1\2/'`;; #(
|
---|
327 | *) boost_rt_d='-d';;
|
---|
328 | esac
|
---|
329 | # If the PREFERRED-RT-OPT are not empty, prepend a `-'.
|
---|
330 | test -n "$boost_rtopt" && boost_rtopt="-$boost_rtopt"
|
---|
331 | $boost_guess_use_mt && boost_mt=-mt
|
---|
332 | # Look for the abs path the static archive.
|
---|
333 | # $libext is computed by Libtool but let's make sure it's non empty.
|
---|
334 | test -z "$libext" &&
|
---|
335 | AC_MSG_ERROR([the libext variable is empty, did you invoke Libtool?])
|
---|
336 | boost_save_ac_objext=$ac_objext
|
---|
337 | # Generate the test file.
|
---|
338 | AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <$3>
|
---|
339 | $5], [$4])])
|
---|
340 | dnl Optimization hacks: compiling C++ is slow, especially with Boost. What
|
---|
341 | dnl we're trying to do here is guess the right combination of link flags
|
---|
342 | dnl (LIBS / LDFLAGS) to use a given library. This can take several
|
---|
343 | dnl iterations before it succeeds and is thus *very* slow. So what we do
|
---|
344 | dnl instead is that we compile the code first (and thus get an object file,
|
---|
345 | dnl typically conftest.o). Then we try various combinations of link flags
|
---|
346 | dnl until we succeed to link conftest.o in an executable. The problem is
|
---|
347 | dnl that the various TRY_LINK / COMPILE_IFELSE macros of Autoconf always
|
---|
348 | dnl remove all the temporary files including conftest.o. So the trick here
|
---|
349 | dnl is to temporarily change the value of ac_objext so that conftest.o is
|
---|
350 | dnl preserved accross tests. This is obviously fragile and I will burn in
|
---|
351 | dnl hell for not respecting Autoconf's documented interfaces, but in the
|
---|
352 | dnl mean time, it optimizes the macro by a factor of 5 to 30.
|
---|
353 | dnl Another small optimization: the first argument of AC_COMPILE_IFELSE left
|
---|
354 | dnl empty because the test file is generated only once above (before we
|
---|
355 | dnl start the for loops).
|
---|
356 | AC_COMPILE_IFELSE([],
|
---|
357 | [ac_objext=do_not_rm_me_plz],
|
---|
358 | [AC_MSG_ERROR([cannot compile a test that uses Boost $1])])
|
---|
359 | ac_objext=$boost_save_ac_objext
|
---|
360 | boost_failed_libs=
|
---|
361 | # Don't bother to ident the 6 nested for loops, only the 2 innermost ones
|
---|
362 | # matter.
|
---|
363 | for boost_tag_ in -$boost_cv_lib_tag ''; do
|
---|
364 | for boost_ver_ in -$boost_cv_lib_version ''; do
|
---|
365 | for boost_mt_ in $boost_mt -mt ''; do
|
---|
366 | for boost_rtopt_ in $boost_rtopt '' -d; do
|
---|
367 | for boost_lib in \
|
---|
368 | boost_$1$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_ \
|
---|
369 | boost_$1$boost_tag_$boost_rtopt_$boost_ver_ \
|
---|
370 | boost_$1$boost_tag_$boost_mt_$boost_ver_ \
|
---|
371 | boost_$1$boost_tag_$boost_ver_
|
---|
372 | do
|
---|
373 | # Avoid testing twice the same lib
|
---|
374 | case $boost_failed_libs in #(
|
---|
375 | *@$boost_lib@*) continue;;
|
---|
376 | esac
|
---|
377 | # If with_boost is empty, we'll search in /lib first, which is not quite
|
---|
378 | # right so instead we'll try to a location based on where the headers are.
|
---|
379 | boost_tmp_lib=$with_boost
|
---|
380 | test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include}
|
---|
381 | for boost_ldpath in "$boost_tmp_lib/lib" '' \
|
---|
382 | /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \
|
---|
383 | "$with_boost" C:/Boost/lib /lib*
|
---|
384 | do
|
---|
385 | test -e "$boost_ldpath" || continue
|
---|
386 | boost_save_LDFLAGS=$LDFLAGS
|
---|
387 | # Are we looking for a static library?
|
---|
388 | case $boost_ldpath:$boost_rtopt_ in #(
|
---|
389 | *?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt)
|
---|
390 | Boost_lib_LIBS="$boost_ldpath/lib$boost_lib.$libext"
|
---|
391 | test -e "$Boost_lib_LIBS" || continue;; #(
|
---|
392 | *) # No: use -lboost_foo to find the shared library.
|
---|
393 | Boost_lib_LIBS="-l$boost_lib";;
|
---|
394 | esac
|
---|
395 | boost_save_LIBS=$LIBS
|
---|
396 | LIBS="$Boost_lib_LIBS $LIBS"
|
---|
397 | test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath"
|
---|
398 | dnl First argument of AC_LINK_IFELSE left empty because the test file is
|
---|
399 | dnl generated only once above (before we start the for loops).
|
---|
400 | _BOOST_AC_LINK_IFELSE([],
|
---|
401 | [Boost_lib=yes], [Boost_lib=no])
|
---|
402 | ac_objext=$boost_save_ac_objext
|
---|
403 | LDFLAGS=$boost_save_LDFLAGS
|
---|
404 | LIBS=$boost_save_LIBS
|
---|
405 | if test x"$Boost_lib" = xyes; then
|
---|
406 | Boost_lib_LDFLAGS="-L$boost_ldpath -Wl,-R$boost_ldpath"
|
---|
407 | Boost_lib_LDPATH="$boost_ldpath"
|
---|
408 | break 6
|
---|
409 | else
|
---|
410 | boost_failed_libs="$boost_failed_libs@$boost_lib@"
|
---|
411 | fi
|
---|
412 | done
|
---|
413 | done
|
---|
414 | done
|
---|
415 | done
|
---|
416 | done
|
---|
417 | done
|
---|
418 | rm -f conftest.$ac_objext
|
---|
419 | ])
|
---|
420 | case $Boost_lib in #(
|
---|
421 | no) _AC_MSG_LOG_CONFTEST
|
---|
422 | AC_MSG_ERROR([cannot find the flags to link with Boost $1])
|
---|
423 | ;;
|
---|
424 | esac
|
---|
425 | AC_SUBST(AS_TR_CPP([BOOST_$1_LDFLAGS]), [$Boost_lib_LDFLAGS])dnl
|
---|
426 | AC_SUBST(AS_TR_CPP([BOOST_$1_LDPATH]), [$Boost_lib_LDPATH])dnl
|
---|
427 | AC_SUBST([BOOST_LDPATH], [$Boost_lib_LDPATH])dnl
|
---|
428 | AC_SUBST(AS_TR_CPP([BOOST_$1_LIBS]), [$Boost_lib_LIBS])dnl
|
---|
429 | CPPFLAGS=$boost_save_CPPFLAGS
|
---|
430 | AS_VAR_POPDEF([Boost_lib])dnl
|
---|
431 | AS_VAR_POPDEF([Boost_lib_LDFLAGS])dnl
|
---|
432 | AS_VAR_POPDEF([Boost_lib_LDPATH])dnl
|
---|
433 | AS_VAR_POPDEF([Boost_lib_LIBS])dnl
|
---|
434 | AC_LANG_POP([C++])dnl
|
---|
435 | fi
|
---|
436 | ])# BOOST_FIND_LIB
|
---|
437 |
|
---|
438 |
|
---|
439 | # --------------------------------------- #
|
---|
440 | # Checks for the various Boost libraries. #
|
---|
441 | # --------------------------------------- #
|
---|
442 |
|
---|
443 | # List of boost libraries: http://www.boost.org/libs/libraries.htm
|
---|
444 | # The page http://beta.boost.org/doc/libs is useful: it gives the first release
|
---|
445 | # version of each library (among other things).
|
---|
446 |
|
---|
447 | # BOOST_DEFUN(LIBRARY, CODE)
|
---|
448 | # --------------------------
|
---|
449 | # Define BOOST_<LIBRARY-UPPERCASE> as a macro that runs CODE.
|
---|
450 | #
|
---|
451 | # Use indir to avoid the warning on underquoted macro name given to AC_DEFUN.
|
---|
452 | m4_define([BOOST_DEFUN],
|
---|
453 | [m4_indir([AC_DEFUN],
|
---|
454 | m4_toupper([BOOST_$1]),
|
---|
455 | [m4_pushdef([BOOST_Library], [$1])dnl
|
---|
456 | $2
|
---|
457 | m4_popdef([BOOST_Library])dnl
|
---|
458 | ])
|
---|
459 | ])
|
---|
460 |
|
---|
461 | # BOOST_ARRAY()
|
---|
462 | # -------------
|
---|
463 | # Look for Boost.Array
|
---|
464 | BOOST_DEFUN([Array],
|
---|
465 | [BOOST_FIND_HEADER([boost/array.hpp])])
|
---|
466 |
|
---|
467 |
|
---|
468 | # BOOST_ASIO()
|
---|
469 | # ------------
|
---|
470 | # Look for Boost.Asio (new in Boost 1.35).
|
---|
471 | BOOST_DEFUN([Asio],
|
---|
472 | [AC_REQUIRE([BOOST_SYSTEM])dnl
|
---|
473 | BOOST_FIND_HEADER([boost/asio.hpp])])
|
---|
474 |
|
---|
475 |
|
---|
476 | # BOOST_BIND()
|
---|
477 | # ------------
|
---|
478 | # Look for Boost.Bind
|
---|
479 | BOOST_DEFUN([Bind],
|
---|
480 | [BOOST_FIND_HEADER([boost/bind.hpp])])
|
---|
481 |
|
---|
482 |
|
---|
483 | # BOOST_CONVERSION()
|
---|
484 | # ------------------
|
---|
485 | # Look for Boost.Conversion (cast / lexical_cast)
|
---|
486 | BOOST_DEFUN([Conversion],
|
---|
487 | [BOOST_FIND_HEADER([boost/cast.hpp])
|
---|
488 | BOOST_FIND_HEADER([boost/lexical_cast.hpp])
|
---|
489 | ])# BOOST_CONVERSION
|
---|
490 |
|
---|
491 |
|
---|
492 | # BOOST_DATE_TIME([PREFERRED-RT-OPT])
|
---|
493 | # -----------------------------------
|
---|
494 | # Look for Boost.Date_Time. For the documentation of PREFERRED-RT-OPT, see the
|
---|
495 | # documentation of BOOST_FIND_LIB above.
|
---|
496 | BOOST_DEFUN([Date_Time],
|
---|
497 | [BOOST_FIND_LIB([date_time], [$1],
|
---|
498 | [boost/date_time/posix_time/posix_time.hpp],
|
---|
499 | [boost::posix_time::ptime t;])
|
---|
500 | ])# BOOST_DATE_TIME
|
---|
501 |
|
---|
502 |
|
---|
503 | # BOOST_FILESYSTEM([PREFERRED-RT-OPT])
|
---|
504 | # ------------------------------------
|
---|
505 | # Look for Boost.Filesystem. For the documentation of PREFERRED-RT-OPT, see
|
---|
506 | # the documentation of BOOST_FIND_LIB above.
|
---|
507 | # Do not check for boost/filesystem.hpp because this file was introduced in
|
---|
508 | # 1.34.
|
---|
509 | BOOST_DEFUN([Filesystem],
|
---|
510 | [# Do we have to check for Boost.System? This link-time dependency was
|
---|
511 | # added as of 1.35.0. If we have a version <1.35, we must not attempt to
|
---|
512 | # find Boost.System as it didn't exist by then.
|
---|
513 | if test $boost_major_version -ge 135; then
|
---|
514 | BOOST_SYSTEM([$1])
|
---|
515 | fi # end of the Boost.System check.
|
---|
516 | boost_filesystem_save_LIBS=$LIBS
|
---|
517 | boost_filesystem_save_LDFLAGS=$LDFLAGS
|
---|
518 | m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
|
---|
519 | LIBS="$LIBS $BOOST_SYSTEM_LIBS"
|
---|
520 | LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
|
---|
521 | BOOST_FIND_LIB([filesystem], [$1],
|
---|
522 | [boost/filesystem/path.hpp], [boost::filesystem::path p;])
|
---|
523 | if test $enable_static_boost = yes && test $boost_major_version -ge 135; then
|
---|
524 | AC_SUBST([BOOST_FILESYSTEM_LIBS], ["$BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS"])
|
---|
525 | fi
|
---|
526 | LIBS=$boost_filesystem_save_LIBS
|
---|
527 | LDFLAGS=$boost_filesystem_save_LDFLAGS
|
---|
528 | ])# BOOST_FILESYSTEM
|
---|
529 |
|
---|
530 |
|
---|
531 | # BOOST_FOREACH()
|
---|
532 | # ---------------
|
---|
533 | # Look for Boost.Foreach
|
---|
534 | BOOST_DEFUN([Foreach],
|
---|
535 | [BOOST_FIND_HEADER([boost/foreach.hpp])])
|
---|
536 |
|
---|
537 |
|
---|
538 | # BOOST_FORMAT()
|
---|
539 | # --------------
|
---|
540 | # Look for Boost.Format
|
---|
541 | # Note: we can't check for boost/format/format_fwd.hpp because the header isn't
|
---|
542 | # standalone. It can't be compiled because it triggers the following error:
|
---|
543 | # boost/format/detail/config_macros.hpp:88: error: 'locale' in namespace 'std'
|
---|
544 | # does not name a type
|
---|
545 | BOOST_DEFUN([Format],
|
---|
546 | [BOOST_FIND_HEADER([boost/format.hpp])])
|
---|
547 |
|
---|
548 |
|
---|
549 | # BOOST_FUNCTION()
|
---|
550 | # ----------------
|
---|
551 | # Look for Boost.Function
|
---|
552 | BOOST_DEFUN([Function],
|
---|
553 | [BOOST_FIND_HEADER([boost/function.hpp])])
|
---|
554 |
|
---|
555 |
|
---|
556 | # BOOST_GRAPH([PREFERRED-RT-OPT])
|
---|
557 | # -------------------------------
|
---|
558 | # Look for Boost.Graphs. For the documentation of PREFERRED-RT-OPT, see the
|
---|
559 | # documentation of BOOST_FIND_LIB above.
|
---|
560 | BOOST_DEFUN([Graph],
|
---|
561 | [BOOST_FIND_LIB([graph], [$1],
|
---|
562 | [boost/graph/adjacency_list.hpp], [boost::adjacency_list<> g;])
|
---|
563 | ])# BOOST_GRAPH
|
---|
564 |
|
---|
565 |
|
---|
566 | # BOOST_IOSTREAMS([PREFERRED-RT-OPT])
|
---|
567 | # -----------------------------------
|
---|
568 | # Look for Boost.IOStreams. For the documentation of PREFERRED-RT-OPT, see the
|
---|
569 | # documentation of BOOST_FIND_LIB above.
|
---|
570 | BOOST_DEFUN([IOStreams],
|
---|
571 | [BOOST_FIND_LIB([iostreams], [$1],
|
---|
572 | [boost/iostreams/device/file_descriptor.hpp],
|
---|
573 | [boost::iostreams::file_descriptor fd; fd.close();])
|
---|
574 | ])# BOOST_IOSTREAMS
|
---|
575 |
|
---|
576 |
|
---|
577 | # BOOST_HASH()
|
---|
578 | # ------------
|
---|
579 | # Look for Boost.Functional/Hash
|
---|
580 | BOOST_DEFUN([Hash],
|
---|
581 | [BOOST_FIND_HEADER([boost/functional/hash.hpp])])
|
---|
582 |
|
---|
583 |
|
---|
584 | # BOOST_LAMBDA()
|
---|
585 | # --------------
|
---|
586 | # Look for Boost.Lambda
|
---|
587 | BOOST_DEFUN([Lambda],
|
---|
588 | [BOOST_FIND_HEADER([boost/lambda/lambda.hpp])])
|
---|
589 |
|
---|
590 |
|
---|
591 | # BOOST_LOG([PREFERRED-RT-OPT])
|
---|
592 | # -----------------------------
|
---|
593 | # Look for Boost.Log For the documentation of PREFERRED-RT-OPT, see the
|
---|
594 | # documentation of BOOST_FIND_LIB above.
|
---|
595 | BOOST_DEFUN([Log],
|
---|
596 | [BOOST_FIND_LIB([log], [$1],
|
---|
597 | [boost/log/core/core.hpp],
|
---|
598 | [boost::log::attribute a; a.get_value();])
|
---|
599 | ])# BOOST_LOG
|
---|
600 |
|
---|
601 |
|
---|
602 | # BOOST_LOG_SETUP([PREFERRED-RT-OPT])
|
---|
603 | # -----------------------------------
|
---|
604 | # Look for Boost.Log For the documentation of PREFERRED-RT-OPT, see the
|
---|
605 | # documentation of BOOST_FIND_LIB above.
|
---|
606 | BOOST_DEFUN([Log_Setup],
|
---|
607 | [AC_REQUIRE([BOOST_LOG])dnl
|
---|
608 | BOOST_FIND_LIB([log_setup], [$1],
|
---|
609 | [boost/log/utility/init/from_settings.hpp],
|
---|
610 | [boost::log::basic_settings<char> bs; bs.empty();])
|
---|
611 | ])# BOOST_LOG_SETUP
|
---|
612 |
|
---|
613 |
|
---|
614 | # BOOST_MATH()
|
---|
615 | # ------------
|
---|
616 | # Look for Boost.Math
|
---|
617 | # TODO: This library isn't header-only but it comes in multiple different
|
---|
618 | # flavors that don't play well with BOOST_FIND_LIB (e.g, libboost_math_c99,
|
---|
619 | # libboost_math_c99f, libboost_math_c99l, libboost_math_tr1,
|
---|
620 | # libboost_math_tr1f, libboost_math_tr1l). This macro must be fixed to do the
|
---|
621 | # right thing anyway.
|
---|
622 | BOOST_DEFUN([Math],
|
---|
623 | [BOOST_FIND_HEADER([boost/math/special_functions.hpp])])
|
---|
624 |
|
---|
625 |
|
---|
626 | # BOOST_MULTIARRAY()
|
---|
627 | # ------------------
|
---|
628 | # Look for Boost.MultiArray
|
---|
629 | BOOST_DEFUN([MultiArray],
|
---|
630 | [BOOST_FIND_HEADER([boost/multi_array.hpp])])
|
---|
631 |
|
---|
632 |
|
---|
633 | # BOOST_NUMERIC_CONVERSION()
|
---|
634 | # --------------------------
|
---|
635 | # Look for Boost.NumericConversion (policy-based numeric conversion)
|
---|
636 | BOOST_DEFUN([Numeric_Conversion],
|
---|
637 | [BOOST_FIND_HEADER([boost/numeric/conversion/converter.hpp])
|
---|
638 | ])# BOOST_NUMERIC_CONVERSION
|
---|
639 |
|
---|
640 |
|
---|
641 | # BOOST_OPTIONAL()
|
---|
642 | # ----------------
|
---|
643 | # Look for Boost.Optional
|
---|
644 | BOOST_DEFUN([Optional],
|
---|
645 | [BOOST_FIND_HEADER([boost/optional.hpp])])
|
---|
646 |
|
---|
647 |
|
---|
648 | # BOOST_PREPROCESSOR()
|
---|
649 | # --------------------
|
---|
650 | # Look for Boost.Preprocessor
|
---|
651 | BOOST_DEFUN([Preprocessor],
|
---|
652 | [BOOST_FIND_HEADER([boost/preprocessor/repeat.hpp])])
|
---|
653 |
|
---|
654 |
|
---|
655 | # BOOST_UNORDERED()
|
---|
656 | # -----------------
|
---|
657 | # Look for Boost.Unordered
|
---|
658 | BOOST_DEFUN([Unordered],
|
---|
659 | [BOOST_FIND_HEADER([boost/unordered_map.hpp])])
|
---|
660 |
|
---|
661 |
|
---|
662 | # BOOST_UUID()
|
---|
663 | # ------------
|
---|
664 | # Look for Boost.Uuid
|
---|
665 | BOOST_DEFUN([Uuid],
|
---|
666 | [BOOST_FIND_HEADER([boost/uuid/uuid.hpp])])
|
---|
667 |
|
---|
668 |
|
---|
669 | # BOOST_PROGRAM_OPTIONS([PREFERRED-RT-OPT])
|
---|
670 | # -----------------------------------------
|
---|
671 | # Look for Boost.Program_options. For the documentation of PREFERRED-RT-OPT,
|
---|
672 | # see the documentation of BOOST_FIND_LIB above.
|
---|
673 | BOOST_DEFUN([Program_Options],
|
---|
674 | [BOOST_FIND_LIB([program_options], [$1],
|
---|
675 | [boost/program_options.hpp],
|
---|
676 | [boost::program_options::options_description d("test");])
|
---|
677 | ])# BOOST_PROGRAM_OPTIONS
|
---|
678 |
|
---|
679 |
|
---|
680 |
|
---|
681 | # _BOOST_PYTHON_CONFIG(VARIABLE, FLAG)
|
---|
682 | # ------------------------------------
|
---|
683 | # Save VARIABLE, and define it via `python-config --FLAG`.
|
---|
684 | # Substitute BOOST_PYTHON_VARIABLE.
|
---|
685 | m4_define([_BOOST_PYTHON_CONFIG],
|
---|
686 | [AC_SUBST([BOOST_PYTHON_$1],
|
---|
687 | [`python-config --$2 2>/dev/null`])dnl
|
---|
688 | boost_python_save_$1=$$1
|
---|
689 | $1="$$1 $BOOST_PYTHON_$1"])
|
---|
690 |
|
---|
691 |
|
---|
692 | # BOOST_PYTHON([PREFERRED-RT-OPT])
|
---|
693 | # --------------------------------
|
---|
694 | # Look for Boost.Python. For the documentation of PREFERRED-RT-OPT,
|
---|
695 | # see the documentation of BOOST_FIND_LIB above.
|
---|
696 | BOOST_DEFUN([Python],
|
---|
697 | [_BOOST_PYTHON_CONFIG([CPPFLAGS], [includes])
|
---|
698 | _BOOST_PYTHON_CONFIG([LDFLAGS], [ldflags])
|
---|
699 | _BOOST_PYTHON_CONFIG([LIBS], [libs])
|
---|
700 | m4_pattern_allow([^BOOST_PYTHON_MODULE$])dnl
|
---|
701 | BOOST_FIND_LIB([python], [$1],
|
---|
702 | [boost/python.hpp],
|
---|
703 | [], [BOOST_PYTHON_MODULE(empty) {}])
|
---|
704 | CPPFLAGS=$boost_python_save_CPPFLAGS
|
---|
705 | LDFLAGS=$boost_python_save_LDFLAGS
|
---|
706 | LIBS=$boost_python_save_LIBS
|
---|
707 | ])# BOOST_PYTHON
|
---|
708 |
|
---|
709 |
|
---|
710 | # BOOST_REF()
|
---|
711 | # -----------
|
---|
712 | # Look for Boost.Ref
|
---|
713 | BOOST_DEFUN([Ref],
|
---|
714 | [BOOST_FIND_HEADER([boost/ref.hpp])])
|
---|
715 |
|
---|
716 |
|
---|
717 | # BOOST_REGEX([PREFERRED-RT-OPT])
|
---|
718 | # -------------------------------
|
---|
719 | # Look for Boost.Regex. For the documentation of PREFERRED-RT-OPT, see the
|
---|
720 | # documentation of BOOST_FIND_LIB above.
|
---|
721 | BOOST_DEFUN([Regex],
|
---|
722 | [BOOST_FIND_LIB([regex], [$1],
|
---|
723 | [boost/regex.hpp],
|
---|
724 | [boost::regex exp("*"); boost::regex_match("foo", exp);])
|
---|
725 | ])# BOOST_REGEX
|
---|
726 |
|
---|
727 |
|
---|
728 | # BOOST_SERIALIZATION([PREFERRED-RT-OPT])
|
---|
729 | # ---------------------------------------
|
---|
730 | # Look for Boost.Serialization. For the documentation of PREFERRED-RT-OPT, see
|
---|
731 | # the documentation of BOOST_FIND_LIB above.
|
---|
732 | BOOST_DEFUN([Serialization],
|
---|
733 | [BOOST_FIND_LIB([serialization], [$1],
|
---|
734 | [boost/archive/text_oarchive.hpp],
|
---|
735 | [std::ostream* o = 0; // Cheap way to get an ostream...
|
---|
736 | boost::archive::text_oarchive t(*o);])
|
---|
737 | ])# BOOST_SERIALIZATION
|
---|
738 |
|
---|
739 |
|
---|
740 | # BOOST_SIGNALS([PREFERRED-RT-OPT])
|
---|
741 | # ---------------------------------
|
---|
742 | # Look for Boost.Signals. For the documentation of PREFERRED-RT-OPT, see the
|
---|
743 | # documentation of BOOST_FIND_LIB above.
|
---|
744 | BOOST_DEFUN([Signals],
|
---|
745 | [BOOST_FIND_LIB([signals], [$1],
|
---|
746 | [boost/signal.hpp],
|
---|
747 | [boost::signal<void ()> s;])
|
---|
748 | ])# BOOST_SIGNALS
|
---|
749 |
|
---|
750 |
|
---|
751 | # BOOST_SMART_PTR()
|
---|
752 | # -----------------
|
---|
753 | # Look for Boost.SmartPtr
|
---|
754 | BOOST_DEFUN([Smart_Ptr],
|
---|
755 | [BOOST_FIND_HEADER([boost/scoped_ptr.hpp])
|
---|
756 | BOOST_FIND_HEADER([boost/shared_ptr.hpp])
|
---|
757 | ])
|
---|
758 |
|
---|
759 |
|
---|
760 | # BOOST_STATICASSERT()
|
---|
761 | # --------------------
|
---|
762 | # Look for Boost.StaticAssert
|
---|
763 | BOOST_DEFUN([StaticAssert],
|
---|
764 | [BOOST_FIND_HEADER([boost/static_assert.hpp])])
|
---|
765 |
|
---|
766 |
|
---|
767 | # BOOST_STRING_ALGO()
|
---|
768 | # -------------------
|
---|
769 | # Look for Boost.StringAlgo
|
---|
770 | BOOST_DEFUN([String_Algo],
|
---|
771 | [BOOST_FIND_HEADER([boost/algorithm/string.hpp])
|
---|
772 | ])
|
---|
773 |
|
---|
774 |
|
---|
775 | # BOOST_SYSTEM([PREFERRED-RT-OPT])
|
---|
776 | # --------------------------------
|
---|
777 | # Look for Boost.System. For the documentation of PREFERRED-RT-OPT, see the
|
---|
778 | # documentation of BOOST_FIND_LIB above. This library was introduced in Boost
|
---|
779 | # 1.35.0.
|
---|
780 | BOOST_DEFUN([System],
|
---|
781 | [BOOST_FIND_LIB([system], [$1],
|
---|
782 | [boost/system/error_code.hpp],
|
---|
783 | [boost::system::error_code e; e.clear();])
|
---|
784 | ])# BOOST_SYSTEM
|
---|
785 |
|
---|
786 |
|
---|
787 | # BOOST_TEST([PREFERRED-RT-OPT])
|
---|
788 | # ------------------------------
|
---|
789 | # Look for Boost.Test. For the documentation of PREFERRED-RT-OPT, see the
|
---|
790 | # documentation of BOOST_FIND_LIB above.
|
---|
791 | BOOST_DEFUN([Test],
|
---|
792 | [m4_pattern_allow([^BOOST_CHECK$])dnl
|
---|
793 | BOOST_FIND_LIB([unit_test_framework], [$1],
|
---|
794 | [boost/test/unit_test.hpp], [BOOST_CHECK(2 == 2);],
|
---|
795 | [using boost::unit_test::test_suite;
|
---|
796 | test_suite* init_unit_test_suite(int argc, char ** argv)
|
---|
797 | { return NULL; }])
|
---|
798 | ])# BOOST_TEST
|
---|
799 |
|
---|
800 |
|
---|
801 | # BOOST_THREADS([PREFERRED-RT-OPT])
|
---|
802 | # ---------------------------------
|
---|
803 | # Look for Boost.Thread. For the documentation of PREFERRED-RT-OPT, see the
|
---|
804 | # documentation of BOOST_FIND_LIB above.
|
---|
805 | # FIXME: Provide an alias "BOOST_THREAD".
|
---|
806 | BOOST_DEFUN([Threads],
|
---|
807 | [dnl Having the pthread flag is required at least on GCC3 where
|
---|
808 | dnl boost/thread.hpp would complain if we try to compile without
|
---|
809 | dnl -pthread on GNU/Linux.
|
---|
810 | AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl
|
---|
811 | boost_threads_save_LIBS=$LIBS
|
---|
812 | boost_threads_save_CPPFLAGS=$CPPFLAGS
|
---|
813 | LIBS="$LIBS $boost_cv_pthread_flag"
|
---|
814 | # Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3,
|
---|
815 | # boost/thread.hpp will trigger a #error if -pthread isn't used:
|
---|
816 | # boost/config/requires_threads.hpp:47:5: #error "Compiler threading support
|
---|
817 | # is not turned on. Please set the correct command line options for
|
---|
818 | # threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
|
---|
819 | CPPFLAGS="$CPPFLAGS $boost_cv_pthread_flag"
|
---|
820 | BOOST_FIND_LIB([thread], [$1],
|
---|
821 | [boost/thread.hpp], [boost::thread t; boost::mutex m;])
|
---|
822 | BOOST_THREAD_LIBS="$BOOST_THREAD_LIBS $boost_cv_pthread_flag"
|
---|
823 | BOOST_CPPFLAGS="$BOOST_CPPFLAGS $boost_cv_pthread_flag"
|
---|
824 | LIBS=$boost_threads_save_LIBS
|
---|
825 | CPPFLAGS=$boost_threads_save_CPPFLAGS
|
---|
826 | ])# BOOST_THREADS
|
---|
827 |
|
---|
828 |
|
---|
829 | # BOOST_TOKENIZER()
|
---|
830 | # -----------------
|
---|
831 | # Look for Boost.Tokenizer
|
---|
832 | BOOST_DEFUN([Tokenizer],
|
---|
833 | [BOOST_FIND_HEADER([boost/tokenizer.hpp])])
|
---|
834 |
|
---|
835 |
|
---|
836 | # BOOST_TRIBOOL()
|
---|
837 | # ---------------
|
---|
838 | # Look for Boost.Tribool
|
---|
839 | BOOST_DEFUN([Tribool],
|
---|
840 | [BOOST_FIND_HEADER([boost/logic/tribool_fwd.hpp])
|
---|
841 | BOOST_FIND_HEADER([boost/logic/tribool.hpp])
|
---|
842 | ])
|
---|
843 |
|
---|
844 |
|
---|
845 | # BOOST_TUPLE()
|
---|
846 | # -------------
|
---|
847 | # Look for Boost.Tuple
|
---|
848 | BOOST_DEFUN([Tuple],
|
---|
849 | [BOOST_FIND_HEADER([boost/tuple/tuple.hpp])])
|
---|
850 |
|
---|
851 |
|
---|
852 | # BOOST_TYPETRAITS()
|
---|
853 | # --------------------
|
---|
854 | # Look for Boost.TypeTraits
|
---|
855 | BOOST_DEFUN([TypeTraits],
|
---|
856 | [BOOST_FIND_HEADER([boost/type_traits.hpp])])
|
---|
857 |
|
---|
858 |
|
---|
859 | # BOOST_UTILITY()
|
---|
860 | # ---------------
|
---|
861 | # Look for Boost.Utility (noncopyable, result_of, base-from-member idiom,
|
---|
862 | # etc.)
|
---|
863 | BOOST_DEFUN([Utility],
|
---|
864 | [BOOST_FIND_HEADER([boost/utility.hpp])])
|
---|
865 |
|
---|
866 |
|
---|
867 | # BOOST_VARIANT()
|
---|
868 | # ---------------
|
---|
869 | # Look for Boost.Variant.
|
---|
870 | BOOST_DEFUN([Variant],
|
---|
871 | [BOOST_FIND_HEADER([boost/variant/variant_fwd.hpp])
|
---|
872 | BOOST_FIND_HEADER([boost/variant.hpp])])
|
---|
873 |
|
---|
874 |
|
---|
875 | # BOOST_WAVE([PREFERRED-RT-OPT])
|
---|
876 | # ------------------------------
|
---|
877 | # NOTE: If you intend to use Wave/Spirit with thread support, make sure you
|
---|
878 | # call BOOST_THREADS first.
|
---|
879 | # Look for Boost.Wave. For the documentation of PREFERRED-RT-OPT, see the
|
---|
880 | # documentation of BOOST_FIND_LIB above.
|
---|
881 | BOOST_DEFUN([Wave],
|
---|
882 | [AC_REQUIRE([BOOST_FILESYSTEM])dnl
|
---|
883 | AC_REQUIRE([BOOST_DATE_TIME])dnl
|
---|
884 | boost_wave_save_LIBS=$LIBS
|
---|
885 | boost_wave_save_LDFLAGS=$LDFLAGS
|
---|
886 | m4_pattern_allow([^BOOST_((FILE)?SYSTEM|DATE_TIME|THREAD)_(LIBS|LDFLAGS)$])dnl
|
---|
887 | LIBS="$LIBS $BOOST_SYSTEM_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_DATE_TIME_LIBS\
|
---|
888 | $BOOST_THREAD_LIBS"
|
---|
889 | LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS\
|
---|
890 | $BOOST_DATE_TIME_LDFLAGS $BOOST_THREAD_LDFLAGS"
|
---|
891 | BOOST_FIND_LIB([wave], [$1],
|
---|
892 | [boost/wave.hpp],
|
---|
893 | [boost::wave::token_id id; get_token_name(id);])
|
---|
894 | LIBS=$boost_wave_save_LIBS
|
---|
895 | LDFLAGS=$boost_wave_save_LDFLAGS
|
---|
896 | ])# BOOST_WAVE
|
---|
897 |
|
---|
898 |
|
---|
899 | # BOOST_XPRESSIVE()
|
---|
900 | # -----------------
|
---|
901 | # Look for Boost.Xpressive (new since 1.36.0).
|
---|
902 | BOOST_DEFUN([Xpressive],
|
---|
903 | [BOOST_FIND_HEADER([boost/xpressive/xpressive.hpp])])
|
---|
904 |
|
---|
905 |
|
---|
906 | # ----------------- #
|
---|
907 | # Internal helpers. #
|
---|
908 | # ----------------- #
|
---|
909 |
|
---|
910 |
|
---|
911 | # _BOOST_PTHREAD_FLAG()
|
---|
912 | # ---------------------
|
---|
913 | # Internal helper for BOOST_THREADS. Based on ACX_PTHREAD:
|
---|
914 | # http://autoconf-archive.cryp.to/acx_pthread.html
|
---|
915 | AC_DEFUN([_BOOST_PTHREAD_FLAG],
|
---|
916 | [AC_REQUIRE([AC_PROG_CXX])dnl
|
---|
917 | AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
---|
918 | AC_LANG_PUSH([C++])dnl
|
---|
919 | AC_CACHE_CHECK([for the flags needed to use pthreads], [boost_cv_pthread_flag],
|
---|
920 | [ boost_cv_pthread_flag=
|
---|
921 | # The ordering *is* (sometimes) important. Some notes on the
|
---|
922 | # individual items follow:
|
---|
923 | # (none): in case threads are in libc; should be tried before -Kthread and
|
---|
924 | # other compiler flags to prevent continual compiler warnings
|
---|
925 | # -lpthreads: AIX (must check this before -lpthread)
|
---|
926 | # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
|
---|
927 | # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
|
---|
928 | # -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
|
---|
929 | # -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads)
|
---|
930 | # -pthreads: Solaris/GCC
|
---|
931 | # -mthreads: MinGW32/GCC, Lynx/GCC
|
---|
932 | # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
|
---|
933 | # doesn't hurt to check since this sometimes defines pthreads too;
|
---|
934 | # also defines -D_REENTRANT)
|
---|
935 | # ... -mt is also the pthreads flag for HP/aCC
|
---|
936 | # -lpthread: GNU Linux, etc.
|
---|
937 | # --thread-safe: KAI C++
|
---|
938 | case $host_os in #(
|
---|
939 | *solaris*)
|
---|
940 | # On Solaris (at least, for some versions), libc contains stubbed
|
---|
941 | # (non-functional) versions of the pthreads routines, so link-based
|
---|
942 | # tests will erroneously succeed. (We need to link with -pthreads/-mt/
|
---|
943 | # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
|
---|
944 | # a function called by this macro, so we could check for that, but
|
---|
945 | # who knows whether they'll stub that too in a future libc.) So,
|
---|
946 | # we'll just look for -pthreads and -lpthread first:
|
---|
947 | boost_pthread_flags="-pthreads -lpthread -mt -pthread";; #(
|
---|
948 | *)
|
---|
949 | boost_pthread_flags="-lpthreads -Kthread -kthread -llthread -pthread \
|
---|
950 | -pthreads -mthreads -lpthread --thread-safe -mt";;
|
---|
951 | esac
|
---|
952 | # Generate the test file.
|
---|
953 | AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <pthread.h>],
|
---|
954 | [pthread_t th; pthread_join(th, 0);
|
---|
955 | pthread_attr_init(0); pthread_cleanup_push(0, 0);
|
---|
956 | pthread_create(0,0,0,0); pthread_cleanup_pop(0);])])
|
---|
957 | for boost_pthread_flag in '' $boost_pthread_flags; do
|
---|
958 | boost_pthread_ok=false
|
---|
959 | dnl Re-use the test file already generated.
|
---|
960 | boost_pthreads__save_LIBS=$LIBS
|
---|
961 | LIBS="$LIBS $boost_pthread_flag"
|
---|
962 | AC_LINK_IFELSE([],
|
---|
963 | [if grep ".*$boost_pthread_flag" conftest.err; then
|
---|
964 | echo "This flag seems to have triggered warnings" >&AS_MESSAGE_LOG_FD
|
---|
965 | else
|
---|
966 | boost_pthread_ok=:; boost_cv_pthread_flag=$boost_pthread_flag
|
---|
967 | fi])
|
---|
968 | LIBS=$boost_pthreads__save_LIBS
|
---|
969 | $boost_pthread_ok && break
|
---|
970 | done
|
---|
971 | ])
|
---|
972 | AC_LANG_POP([C++])dnl
|
---|
973 | ])# _BOOST_PTHREAD_FLAG
|
---|
974 |
|
---|
975 |
|
---|
976 | # _BOOST_gcc_test(MAJOR, MINOR)
|
---|
977 | # -----------------------------
|
---|
978 | # Internal helper for _BOOST_FIND_COMPILER_TAG.
|
---|
979 | m4_define([_BOOST_gcc_test],
|
---|
980 | ["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC @ gcc$1$2"])dnl
|
---|
981 |
|
---|
982 |
|
---|
983 | # _BOOST_FIND_COMPILER_TAG()
|
---|
984 | # --------------------------
|
---|
985 | # Internal. When Boost is installed without --layout=system, each library
|
---|
986 | # filename will hold a suffix that encodes the compiler used during the
|
---|
987 | # build. The Boost build system seems to call this a `tag'.
|
---|
988 | AC_DEFUN([_BOOST_FIND_COMPILER_TAG],
|
---|
989 | [AC_REQUIRE([AC_PROG_CXX])dnl
|
---|
990 | AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
---|
991 | AC_CACHE_CHECK([for the toolset name used by Boost for $CXX], [boost_cv_lib_tag],
|
---|
992 | [boost_cv_lib_tag=unknown
|
---|
993 | if test x$boost_cv_inc_path != xno; then
|
---|
994 | AC_LANG_PUSH([C++])dnl
|
---|
995 | # The following tests are mostly inspired by boost/config/auto_link.hpp
|
---|
996 | # The list is sorted to most recent/common to oldest compiler (in order
|
---|
997 | # to increase the likelihood of finding the right compiler with the
|
---|
998 | # least number of compilation attempt).
|
---|
999 | # Beware that some tests are sensible to the order (for instance, we must
|
---|
1000 | # look for MinGW before looking for GCC3).
|
---|
1001 | # I used one compilation test per compiler with a #error to recognize
|
---|
1002 | # each compiler so that it works even when cross-compiling (let me know
|
---|
1003 | # if you know a better approach).
|
---|
1004 | # Known missing tags (known from Boost's tools/build/v2/tools/common.jam):
|
---|
1005 | # como, edg, kcc, bck, mp, sw, tru, xlc
|
---|
1006 | # I'm not sure about my test for `il' (be careful: Intel's ICC pre-defines
|
---|
1007 | # the same defines as GCC's).
|
---|
1008 | for i in \
|
---|
1009 | _BOOST_gcc_test(4, 6) \
|
---|
1010 | _BOOST_gcc_test(4, 5) \
|
---|
1011 | _BOOST_gcc_test(4, 4) \
|
---|
1012 | _BOOST_gcc_test(4, 3) \
|
---|
1013 | _BOOST_gcc_test(4, 2) \
|
---|
1014 | _BOOST_gcc_test(4, 1) \
|
---|
1015 | _BOOST_gcc_test(4, 0) \
|
---|
1016 | "defined __GNUC__ && __GNUC__ == 3 && !defined __ICC \
|
---|
1017 | && (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \
|
---|
1018 | || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw" \
|
---|
1019 | _BOOST_gcc_test(3, 4) \
|
---|
1020 | _BOOST_gcc_test(3, 3) \
|
---|
1021 | "defined _MSC_VER && _MSC_VER >= 1500 @ vc90" \
|
---|
1022 | "defined _MSC_VER && _MSC_VER == 1400 @ vc80" \
|
---|
1023 | _BOOST_gcc_test(3, 2) \
|
---|
1024 | "defined _MSC_VER && _MSC_VER == 1310 @ vc71" \
|
---|
1025 | _BOOST_gcc_test(3, 1) \
|
---|
1026 | _BOOST_gcc_test(3, 0) \
|
---|
1027 | "defined __BORLANDC__ @ bcb" \
|
---|
1028 | "defined __ICC && (defined __unix || defined __unix__) @ il" \
|
---|
1029 | "defined __ICL @ iw" \
|
---|
1030 | "defined _MSC_VER && _MSC_VER == 1300 @ vc7" \
|
---|
1031 | _BOOST_gcc_test(2, 95) \
|
---|
1032 | "defined __MWERKS__ && __MWERKS__ <= 0x32FF @ cw9" \
|
---|
1033 | "defined _MSC_VER && _MSC_VER < 1300 && !defined UNDER_CE @ vc6" \
|
---|
1034 | "defined _MSC_VER && _MSC_VER < 1300 && defined UNDER_CE @ evc4" \
|
---|
1035 | "defined __MWERKS__ && __MWERKS__ <= 0x31FF @ cw8"
|
---|
1036 | do
|
---|
1037 | boost_tag_test=`expr "X$i" : 'X\([[^@]]*\) @ '`
|
---|
1038 | boost_tag=`expr "X$i" : 'X[[^@]]* @ \(.*\)'`
|
---|
1039 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
---|
1040 | #if $boost_tag_test
|
---|
1041 | /* OK */
|
---|
1042 | #else
|
---|
1043 | # error $boost_tag_test
|
---|
1044 | #endif
|
---|
1045 | ]])], [boost_cv_lib_tag=$boost_tag; break], [])
|
---|
1046 | done
|
---|
1047 | AC_LANG_POP([C++])dnl
|
---|
1048 | case $boost_cv_lib_tag in #(
|
---|
1049 | # Some newer (>= 1.35?) versions of Boost seem to only use "gcc" as opposed
|
---|
1050 | # to "gcc41" for instance.
|
---|
1051 | *-gcc | *'-gcc ') :;; #( Don't re-add -gcc: it's already in there.
|
---|
1052 | gcc*)
|
---|
1053 | boost_tag_x=
|
---|
1054 | case $host_os in #(
|
---|
1055 | darwin*)
|
---|
1056 | if test $boost_major_version -ge 136; then
|
---|
1057 | # The `x' added in r46793 of Boost.
|
---|
1058 | boost_tag_x=x
|
---|
1059 | fi;;
|
---|
1060 | esac
|
---|
1061 | # We can specify multiple tags in this variable because it's used by
|
---|
1062 | # BOOST_FIND_LIB that does a `for tag in -$boost_cv_lib_tag' ...
|
---|
1063 | boost_cv_lib_tag="$boost_tag_x$boost_cv_lib_tag -${boost_tag_x}gcc"
|
---|
1064 | ;; #(
|
---|
1065 | unknown)
|
---|
1066 | AC_MSG_WARN([[could not figure out which toolset name to use for $CXX]])
|
---|
1067 | boost_cv_lib_tag=
|
---|
1068 | ;;
|
---|
1069 | esac
|
---|
1070 | fi])dnl end of AC_CACHE_CHECK
|
---|
1071 | ])# _BOOST_FIND_COMPILER_TAG
|
---|
1072 |
|
---|
1073 |
|
---|
1074 | # _BOOST_GUESS_WHETHER_TO_USE_MT()
|
---|
1075 | # --------------------------------
|
---|
1076 | # Compile a small test to try to guess whether we should favor MT (Multi
|
---|
1077 | # Thread) flavors of Boost. Sets boost_guess_use_mt accordingly.
|
---|
1078 | AC_DEFUN([_BOOST_GUESS_WHETHER_TO_USE_MT],
|
---|
1079 | [# Check whether we do better use `mt' even though we weren't ask to.
|
---|
1080 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
---|
1081 | #if defined _REENTRANT || defined _MT || defined __MT__
|
---|
1082 | /* use -mt */
|
---|
1083 | #else
|
---|
1084 | # error MT not needed
|
---|
1085 | #endif
|
---|
1086 | ]])], [boost_guess_use_mt=:], [boost_guess_use_mt=false])
|
---|
1087 | ])
|
---|
1088 |
|
---|
1089 | # _BOOST_AC_LINK_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
|
---|
1090 | # -------------------------------------------------------------------
|
---|
1091 | # Fork of _AC_LINK_IFELSE that preserves conftest.o across calls. Fragile,
|
---|
1092 | # will break when Autoconf changes its internals. Requires that you manually
|
---|
1093 | # rm -f conftest.$ac_objext in between to really different tests, otherwise
|
---|
1094 | # you will try to link a conftest.o left behind by a previous test.
|
---|
1095 | # Used to aggressively optimize BOOST_FIND_LIB (see the big comment in this
|
---|
1096 | # macro).
|
---|
1097 | #
|
---|
1098 | # Don't use "break" in the actions, as it would short-circuit some code
|
---|
1099 | # this macro runs after the actions.
|
---|
1100 | m4_define([_BOOST_AC_LINK_IFELSE],
|
---|
1101 | [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
|
---|
1102 | rm -f conftest$ac_exeext
|
---|
1103 | boost_save_ac_ext=$ac_ext
|
---|
1104 | boost_use_source=:
|
---|
1105 | # If we already have a .o, re-use it. We change $ac_ext so that $ac_link
|
---|
1106 | # tries to link the existing object file instead of compiling from source.
|
---|
1107 | test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false &&
|
---|
1108 | _AS_ECHO_LOG([re-using the existing conftest.$ac_objext])
|
---|
1109 | AS_IF([_AC_DO_STDERR($ac_link) && {
|
---|
1110 | test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" ||
|
---|
1111 | test ! -s conftest.err
|
---|
1112 | } && test -s conftest$ac_exeext && {
|
---|
1113 | test "$cross_compiling" = yes ||
|
---|
1114 | $as_executable_p conftest$ac_exeext
|
---|
1115 | dnl FIXME: use AS_TEST_X instead when 2.61 is widespread enough.
|
---|
1116 | }],
|
---|
1117 | [$2],
|
---|
1118 | [if $boost_use_source; then
|
---|
1119 | _AC_MSG_LOG_CONFTEST
|
---|
1120 | fi
|
---|
1121 | $3])
|
---|
1122 | ac_objext=$boost_save_ac_objext
|
---|
1123 | ac_ext=$boost_save_ac_ext
|
---|
1124 | dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization)
|
---|
1125 | dnl information created by the PGI compiler (conftest_ipa8_conftest.oo),
|
---|
1126 | dnl as it would interfere with the next link command.
|
---|
1127 | rm -f core conftest.err conftest_ipa8_conftest.oo \
|
---|
1128 | conftest$ac_exeext m4_ifval([$1], [conftest.$ac_ext])[]dnl
|
---|
1129 | ])# _BOOST_AC_LINK_IFELSE
|
---|
1130 |
|
---|
1131 | # Local Variables:
|
---|
1132 | # mode: autoconf
|
---|
1133 | # End:
|
---|