1 # boost.m4: Locate Boost headers and libraries for autoconf-based projects.
2 # Copyright (C) 2007-2011, 2014 Benoit Sigoure <tsuna@lrde.epita.fr>
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.
9 # Additional permission under section 7 of the GNU General Public
10 # License, version 3 ("GPLv3"):
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.
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.
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/>.
24 m4_define([_BOOST_SERIAL], [m4_translit([
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
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.
48 m4_pattern_forbid([^_?(BOOST|Boost)_])
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.
56 # SED-PROGRAM is *not* overquoted, as in AC_EGREP_CPP. It is expanded
57 # in double-quotes, so escape your double quotes.
59 # It could be useful to turn this into a macro which extracts the
61 m4_define([_BOOST_SED_CPP],
62 [AC_LANG_PUSH([C++])dnl
63 AC_LANG_PREPROC_REQUIRE()dnl
64 AC_REQUIRE([AC_PROG_SED])dnl
65 AC_LANG_CONFTEST([AC_LANG_SOURCE([[$2]])])
66 AS_IF([dnl eval is necessary to expand ac_cpp.
67 dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
68 dnl Beware of Windows end-of-lines, for instance if we are running
69 dnl some Windows programs under Wine. In that case, boost/version.hpp
70 dnl is certainly using "\r\n", but the regular Unix shell will only
71 dnl strip `\n' with backquotes, not the `\r'. This results in
72 dnl boost_cv_lib_version='1_37\r' for instance, which breaks
74 dnl Cannot use 'dnl' after [$4] because a trailing dnl may break AC_CACHE_CHECK
76 dnl Beware that GCC 5, when expanding macros, may embed # line directives
77 dnl a within single line:
81 dnl # 1 "<command-line>"
83 dnl # 1 "/opt/local/include/boost/version.hpp" 1 3
84 dnl # 2 "conftest.cc" 2
85 dnl boost-lib-version =
86 dnl # 2 "conftest.cc" 3
89 dnl So get rid of the # and empty lines, and glue the remaining ones together.
90 (eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
92 grep -v '^[[[:space:]]]*$' |
95 $SED -n -e "$1" >conftest.i 2>&1],
104 # BOOST_REQUIRE([VERSION], [ACTION-IF-NOT-FOUND])
105 # -----------------------------------------------
106 # Look for Boost. If version is given, it must either be a literal of the form
107 # "X.Y.Z" where X, Y and Z are integers (the ".Z" part being optional) or a
109 # Defines the value BOOST_CPPFLAGS. This macro only checks for headers with
110 # the required version, it does not check for any of the Boost libraries.
111 # On # success, defines HAVE_BOOST. On failure, calls the optional
112 # ACTION-IF-NOT-FOUND action if one was supplied.
113 # Otherwise aborts with an error message.
114 AC_DEFUN_ONCE([BOOST_REQUIRE],
115 [AC_REQUIRE([AC_PROG_CXX])dnl
116 AC_REQUIRE([AC_PROG_GREP])dnl
117 echo "$as_me: this is boost.m4[]_BOOST_SERIAL" >&AS_MESSAGE_LOG_FD
121 set x $boost_version_req 0 0 0
124 boost_version_req=`expr "$[1]" '*' 100000 + "$[2]" '*' 100 + "$[3]"`
125 boost_version_req_string=$[1].$[2].$[3]
127 [AS_HELP_STRING([--with-boost=DIR],
128 [prefix of Boost $1 @<:@guess@:>@])])dnl
129 AC_ARG_VAR([BOOST_ROOT],[Location of Boost installation])dnl
130 # If BOOST_ROOT is set and the user has not provided a value to
131 # --with-boost, then treat BOOST_ROOT as if it the user supplied it.
132 if test x"$BOOST_ROOT" != x; then
133 if test x"$with_boost" = x; then
134 AC_MSG_NOTICE([Detected BOOST_ROOT; continuing with --with-boost=$BOOST_ROOT])
135 with_boost=$BOOST_ROOT
137 AC_MSG_NOTICE([Detected BOOST_ROOT=$BOOST_ROOT, but overridden by --with-boost=$with_boost])
140 AC_SUBST([DISTCHECK_CONFIGURE_FLAGS],
141 ["$DISTCHECK_CONFIGURE_FLAGS '--with-boost=$with_boost'"])dnl
142 boost_save_CPPFLAGS=$CPPFLAGS
143 AC_CACHE_CHECK([for Boost headers version >= $boost_version_req_string],
145 [boost_cv_inc_path=no
146 AC_LANG_PUSH([C++])dnl
147 m4_pattern_allow([^BOOST_VERSION$])dnl
148 AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#include <boost/version.hpp>
149 #if !defined BOOST_VERSION
150 # error BOOST_VERSION is not defined
151 #elif BOOST_VERSION < $boost_version_req
152 # error Boost headers version < $boost_version_req
155 # If the user provided a value to --with-boost, use it and only it.
156 case $with_boost in #(
157 ''|yes) set x '' /opt/local/include /usr/local/include /opt/include \
158 /usr/include C:/Boost/include;; #(
159 *) set x "$with_boost/include" "$with_boost";;
164 # Without --layout=system, Boost (or at least some versions) installs
165 # itself in <prefix>/include/boost-<version>. This inner loop helps to
166 # find headers in such directories.
168 # Any ${boost_dir}/boost-x_xx directories are searched in reverse version
169 # order followed by ${boost_dir}. The final '.' is a sentinel for
170 # searching $boost_dir" itself. Entries are whitespace separated.
172 # I didn't indent this loop on purpose (to avoid over-indented code)
173 boost_layout_system_search_list=`cd "$boost_dir" 2>/dev/null \
174 && ls -1 | "${GREP}" '^boost-' | sort -rn -t- -k2 \
176 for boost_inc in $boost_layout_system_search_list
178 if test x"$boost_inc" != x.; then
179 boost_inc="$boost_dir/$boost_inc"
181 boost_inc="$boost_dir" # Uses sentinel in boost_layout_system_search_list
183 if test x"$boost_inc" != x; then
184 # We are going to check whether the version of Boost installed
185 # in $boost_inc is usable by running a compilation that
186 # #includes it. But if we pass a -I/some/path in which Boost
187 # is not installed, the compiler will just skip this -I and
188 # use other locations (either from CPPFLAGS, or from its list
189 # of system include directories). As a result we would use
190 # header installed on the machine instead of the /some/path
191 # specified by the user. So in that precise case (trying
192 # $boost_inc), make sure the version.hpp exists.
194 # Use test -e as there can be symlinks.
195 test -e "$boost_inc/boost/version.hpp" || continue
196 CPPFLAGS="$CPPFLAGS -I$boost_inc"
198 AC_COMPILE_IFELSE([], [boost_cv_inc_path=yes], [boost_cv_version=no])
199 if test x"$boost_cv_inc_path" = xyes; then
200 if test x"$boost_inc" != x; then
201 boost_cv_inc_path=$boost_inc
207 AC_LANG_POP([C++])dnl
209 case $boost_cv_inc_path in #(
211 boost_errmsg="cannot find Boost headers version >= $boost_version_req_string"
212 m4_if([$2], [], [AC_MSG_ERROR([$boost_errmsg])],
213 [AC_MSG_NOTICE([$boost_errmsg])])
220 AC_SUBST([BOOST_CPPFLAGS], ["-I$boost_cv_inc_path"])dnl
223 if test x"$boost_cv_inc_path" != xno; then
224 AC_DEFINE([HAVE_BOOST], [1],
225 [Defined if the requested minimum BOOST version is satisfied])
226 AC_CACHE_CHECK([for Boost's header version],
227 [boost_cv_lib_version],
228 [m4_pattern_allow([^BOOST_LIB_VERSION$])dnl
229 _BOOST_SED_CPP([[/^boost-lib-version = /{s///;s/[\" ]//g;p;q;}]],
230 [#include <boost/version.hpp>
231 boost-lib-version = BOOST_LIB_VERSION],
232 [boost_cv_lib_version=`cat conftest.i`])])
233 # e.g. "134" for 1_34_1 or "135" for 1_35
234 boost_major_version=`echo "$boost_cv_lib_version" | sed 's/_//;s/_.*//'`
235 case $boost_major_version in #(
237 AC_MSG_ERROR([invalid value: boost_major_version='$boost_major_version'])
241 CPPFLAGS=$boost_save_CPPFLAGS
247 # Add the "--enable-static-boost" configure argument. If this argument is given
248 # on the command line, static versions of the libraries will be looked up.
249 AC_DEFUN([BOOST_STATIC],
250 [AC_ARG_ENABLE([static-boost],
251 [AS_HELP_STRING([--enable-static-boost],
252 [Prefer the static boost libraries over the shared ones [no]])],
253 [enable_static_boost=yes],
254 [enable_static_boost=no])])# BOOST_STATIC
257 # BOOST_FIND_HEADER([HEADER-NAME], [ACTION-IF-NOT-FOUND], [ACTION-IF-FOUND])
258 # --------------------------------------------------------------------------
259 # Wrapper around AC_CHECK_HEADER for Boost headers. Useful to check for
260 # some parts of the Boost library which are only made of headers and don't
261 # require linking (such as Boost.Foreach).
263 # Default ACTION-IF-NOT-FOUND: Fail with a fatal error unless Boost couldn't be
264 # found in the first place, in which case by default a notice is issued to the
265 # user. Presumably if we haven't died already it's because it's OK to not have
266 # Boost, which is why only a notice is issued instead of a hard error.
268 # Default ACTION-IF-FOUND: define the preprocessor symbol HAVE_<HEADER-NAME> in
269 # case of success # (where HEADER-NAME is written LIKE_THIS, e.g.,
270 # HAVE_BOOST_FOREACH_HPP).
271 AC_DEFUN([BOOST_FIND_HEADER],
272 [AC_REQUIRE([BOOST_REQUIRE])dnl
273 if test x"$boost_cv_inc_path" = xno; then
274 m4_default([$2], [AC_MSG_NOTICE([Boost not available, not searching for $1])])
276 AC_LANG_PUSH([C++])dnl
277 boost_save_CPPFLAGS=$CPPFLAGS
278 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
279 AC_CHECK_HEADER([$1],
280 [m4_default([$3], [AC_DEFINE(AS_TR_CPP([HAVE_$1]), [1],
281 [Define to 1 if you have <$1>])])],
282 [m4_default([$2], [AC_MSG_ERROR([cannot find $1])])])
283 CPPFLAGS=$boost_save_CPPFLAGS
284 AC_LANG_POP([C++])dnl
286 ])# BOOST_FIND_HEADER
289 # BOOST_FIND_LIBS([COMPONENT-NAME], [CANDIDATE-LIB-NAMES],
290 # [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST],
292 # --------------------------------------------------------------
293 # Look for the Boost library COMPONENT-NAME (e.g., `thread', for
294 # libboost_thread) under the possible CANDIDATE-LIB-NAMES (e.g.,
295 # "thread_win32 thread"). Check that HEADER-NAME works and check that
296 # libboost_LIB-NAME can link with the code CXX-TEST. The optional
297 # argument CXX-PROLOGUE can be used to include some C++ code before
298 # the `main' function.
300 # Invokes BOOST_FIND_HEADER([HEADER-NAME]) (see above).
302 # Boost libraries typically come compiled with several flavors (with different
303 # runtime options) so PREFERRED-RT-OPT is the preferred suffix. A suffix is one
304 # or more of the following letters: sgdpn (in that order). s = static
305 # runtime, d = debug build, g = debug/diagnostic runtime, p = STLPort build,
306 # n = (unsure) STLPort build without iostreams from STLPort (it looks like `n'
307 # must always be used along with `p'). Additionally, PREFERRED-RT-OPT can
308 # start with `mt-' to indicate that there is a preference for multi-thread
309 # builds. Some sample values for PREFERRED-RT-OPT: (nothing), mt, d, mt-d, gdp
310 # ... If you want to make sure you have a specific version of Boost
311 # (eg, >= 1.33) you *must* invoke BOOST_REQUIRE before this macro.
312 AC_DEFUN([BOOST_FIND_LIBS],
313 [AC_REQUIRE([BOOST_REQUIRE])dnl
314 AC_REQUIRE([_BOOST_FIND_COMPILER_TAG])dnl
315 AC_REQUIRE([BOOST_STATIC])dnl
316 AC_REQUIRE([_BOOST_GUESS_WHETHER_TO_USE_MT])dnl
317 if test x"$boost_cv_inc_path" = xno; then
318 AC_MSG_NOTICE([Boost not available, not searching for the Boost $1 library])
320 dnl The else branch is huge and wasn't intended on purpose.
321 AC_LANG_PUSH([C++])dnl
322 AS_VAR_PUSHDEF([Boost_lib], [boost_cv_lib_$1])dnl
323 AS_VAR_PUSHDEF([Boost_lib_LDFLAGS], [boost_cv_lib_$1_LDFLAGS])dnl
324 AS_VAR_PUSHDEF([Boost_lib_LDPATH], [boost_cv_lib_$1_LDPATH])dnl
325 AS_VAR_PUSHDEF([Boost_lib_LIBS], [boost_cv_lib_$1_LIBS])dnl
326 BOOST_FIND_HEADER([$4])
327 boost_save_CPPFLAGS=$CPPFLAGS
328 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
329 AC_CACHE_CHECK([for the Boost $1 library], [Boost_lib],
330 [_BOOST_FIND_LIBS($@)])
331 case $Boost_lib in #(
332 (no) _AC_MSG_LOG_CONFTEST
333 AC_MSG_ERROR([cannot find the flags to link with Boost $1])
336 AC_SUBST(AS_TR_CPP([BOOST_$1_LDFLAGS]), [$Boost_lib_LDFLAGS])dnl
337 AC_SUBST(AS_TR_CPP([BOOST_$1_LDPATH]), [$Boost_lib_LDPATH])dnl
338 AC_SUBST([BOOST_LDPATH], [$Boost_lib_LDPATH])dnl
339 AC_SUBST(AS_TR_CPP([BOOST_$1_LIBS]), [$Boost_lib_LIBS])dnl
340 CPPFLAGS=$boost_save_CPPFLAGS
341 AS_VAR_POPDEF([Boost_lib])dnl
342 AS_VAR_POPDEF([Boost_lib_LDFLAGS])dnl
343 AS_VAR_POPDEF([Boost_lib_LDPATH])dnl
344 AS_VAR_POPDEF([Boost_lib_LIBS])dnl
345 AC_LANG_POP([C++])dnl
350 # BOOST_FIND_LIB([LIB-NAME],
351 # [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST],
353 # --------------------------------------------------------------
354 # Backward compatibility wrapper for BOOST_FIND_LIBS.
355 AC_DEFUN([BOOST_FIND_LIB],
356 [BOOST_FIND_LIBS([$1], $@)])
359 # _BOOST_FIND_LIBS([LIB-NAME], [CANDIDATE-LIB-NAMES],
360 # [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST],
362 # --------------------------------------------------------------
363 # Real implementation of BOOST_FIND_LIBS: rely on these local macros:
364 # Boost_lib, Boost_lib_LDFLAGS, Boost_lib_LDPATH, Boost_lib_LIBS
366 # The algorithm is as follows: first look for a given library name
367 # according to the user's PREFERRED-RT-OPT. For each library name, we
368 # prefer to use the ones that carry the tag (toolset name). Each
369 # library is searched through the various standard paths were Boost is
370 # usually installed. If we can't find the standard variants, we try
371 # to enforce -mt (for instance on MacOSX, libboost_thread.dylib
372 # doesn't exist but there's -obviously- libboost_thread-mt.dylib).
373 AC_DEFUN([_BOOST_FIND_LIBS],
376 (mt | mt-) boost_mt=-mt; boost_rtopt=;; #(
377 (mt* | mt-*) boost_mt=-mt; boost_rtopt=`expr "X$3" : 'Xmt-*\(.*\)'`;; #(
378 (*) boost_mt=; boost_rtopt=$3;;
380 if test $enable_static_boost = yes; then
381 boost_rtopt="s$boost_rtopt"
383 # Find the proper debug variant depending on what we've been asked to find.
384 case $boost_rtopt in #(
385 (*d*) boost_rt_d=$boost_rtopt;; #(
386 (*[[sgpn]]*) # Insert the `d' at the right place (in between `sg' and `pn')
387 boost_rt_d=`echo "$boost_rtopt" | sed 's/\(s*g*\)\(p*n*\)/\1\2/'`;; #(
388 (*) boost_rt_d='-d';;
390 # If the PREFERRED-RT-OPT are not empty, prepend a `-'.
391 test -n "$boost_rtopt" && boost_rtopt="-$boost_rtopt"
392 $boost_guess_use_mt && boost_mt=-mt
393 # Look for the abs path the static archive.
394 # $libext is computed by Libtool but let's make sure it's non empty.
396 AC_MSG_ERROR([the libext variable is empty, did you invoke Libtool?])
397 boost_save_ac_objext=$ac_objext
398 # Generate the test file.
399 AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <$4>
401 dnl Optimization hacks: compiling C++ is slow, especially with Boost. What
402 dnl we're trying to do here is guess the right combination of link flags
403 dnl (LIBS / LDFLAGS) to use a given library. This can take several
404 dnl iterations before it succeeds and is thus *very* slow. So what we do
405 dnl instead is that we compile the code first (and thus get an object file,
406 dnl typically conftest.o). Then we try various combinations of link flags
407 dnl until we succeed to link conftest.o in an executable. The problem is
408 dnl that the various TRY_LINK / COMPILE_IFELSE macros of Autoconf always
409 dnl remove all the temporary files including conftest.o. So the trick here
410 dnl is to temporarily change the value of ac_objext so that conftest.o is
411 dnl preserved accross tests. This is obviously fragile and I will burn in
412 dnl hell for not respecting Autoconf's documented interfaces, but in the
413 dnl mean time, it optimizes the macro by a factor of 5 to 30.
414 dnl Another small optimization: the first argument of AC_COMPILE_IFELSE left
415 dnl empty because the test file is generated only once above (before we
416 dnl start the for loops).
417 AC_COMPILE_IFELSE([],
418 [ac_objext=do_not_rm_me_plz],
419 [AC_MSG_ERROR([cannot compile a test that uses Boost $1])])
420 ac_objext=$boost_save_ac_objext
422 # Don't bother to ident the following nested for loops, only the 2
423 # innermost ones matter.
424 for boost_lib_ in $2; do
425 for boost_tag_ in -$boost_cv_lib_tag ''; do
426 for boost_ver_ in -$boost_cv_lib_version ''; do
427 for boost_mt_ in $boost_mt -mt ''; do
428 for boost_rtopt_ in $boost_rtopt '' -d; do
430 boost_$boost_lib_$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_ \
431 boost_$boost_lib_$boost_tag_$boost_rtopt_$boost_ver_ \
432 boost_$boost_lib_$boost_tag_$boost_mt_$boost_ver_ \
433 boost_$boost_lib_$boost_tag_$boost_ver_
435 # Avoid testing twice the same lib
436 case $boost_failed_libs in #(
437 (*@$boost_lib@*) continue;;
439 # If with_boost is empty, we'll search in /lib first, which is not quite
440 # right so instead we'll try to a location based on where the headers are.
441 boost_tmp_lib=$with_boost
442 test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include}
443 for boost_ldpath in "$boost_tmp_lib/lib" '' \
444 /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \
445 "$with_boost" C:/Boost/lib /lib*
447 # Don't waste time with directories that don't exist.
448 if test x"$boost_ldpath" != x && test ! -e "$boost_ldpath"; then
451 boost_save_LDFLAGS=$LDFLAGS
452 # Are we looking for a static library?
453 case $boost_ldpath:$boost_rtopt_ in #(
454 (*?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt)
455 Boost_lib_LIBS="$boost_ldpath/lib$boost_lib.$libext"
456 test -e "$Boost_lib_LIBS" || continue;; #(
457 (*) # No: use -lboost_foo to find the shared library.
458 Boost_lib_LIBS="-l$boost_lib";;
460 boost_save_LIBS=$LIBS
461 LIBS="$Boost_lib_LIBS $LIBS"
462 test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath"
463 dnl First argument of AC_LINK_IFELSE left empty because the test file is
464 dnl generated only once above (before we start the for loops).
465 _BOOST_AC_LINK_IFELSE([],
466 [Boost_lib=yes], [Boost_lib=no])
467 ac_objext=$boost_save_ac_objext
468 LDFLAGS=$boost_save_LDFLAGS
469 LIBS=$boost_save_LIBS
470 if test x"$Boost_lib" = xyes; then
471 # Check or used cached result of whether or not using -R or
472 # -rpath makes sense. Some implementations of ld, such as for
473 # Mac OSX, require -rpath but -R is the flag known to work on
474 # other systems. https://github.com/tsuna/boost.m4/issues/19
475 AC_CACHE_VAL([boost_cv_rpath_link_ldflag],
476 [case $boost_ldpath in
478 boost_cv_rpath_link_ldflag=
479 boost_rpath_link_ldflag_found=yes;;
481 for boost_cv_rpath_link_ldflag in -Wl,-R, -Wl,-rpath,; do
482 LDFLAGS="$boost_save_LDFLAGS -L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath"
483 LIBS="$boost_save_LIBS $Boost_lib_LIBS"
484 _BOOST_AC_LINK_IFELSE([],
485 [boost_rpath_link_ldflag_found=yes
487 [boost_rpath_link_ldflag_found=no])
491 AS_IF([test "x$boost_rpath_link_ldflag_found" != "xyes"],
492 [AC_MSG_ERROR([Unable to determine whether to use -R or -rpath])])
493 LDFLAGS=$boost_save_LDFLAGS
494 LIBS=$boost_save_LIBS
496 test x"$boost_ldpath" != x &&
497 Boost_lib_LDFLAGS="-L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath"
498 Boost_lib_LDPATH="$boost_ldpath"
501 boost_failed_libs="$boost_failed_libs@$boost_lib@"
510 rm -f conftest.$ac_objext
515 # --------------------------------------- #
516 # Checks for the various Boost libraries. #
517 # --------------------------------------- #
519 # List of boost libraries: http://www.boost.org/libs/libraries.htm
520 # The page http://beta.boost.org/doc/libs is useful: it gives the first release
521 # version of each library (among other things).
523 # BOOST_DEFUN(LIBRARY, CODE)
524 # --------------------------
525 # Define BOOST_<LIBRARY-UPPERCASE> as a macro that runs CODE.
527 # Use indir to avoid the warning on underquoted macro name given to AC_DEFUN.
528 m4_define([BOOST_DEFUN],
529 [m4_indir([AC_DEFUN],
530 m4_toupper([BOOST_$1]),
531 [m4_pushdef([BOOST_Library], [$1])dnl
533 m4_popdef([BOOST_Library])dnl
539 # Look for Boost.Array
541 [BOOST_FIND_HEADER([boost/array.hpp])])
546 # Look for Boost.Asio (new in Boost 1.35).
548 [AC_REQUIRE([BOOST_SYSTEM])dnl
549 BOOST_FIND_HEADER([boost/asio.hpp])])
554 # Look for Boost.Assign
555 BOOST_DEFUN([Assign],
556 [BOOST_FIND_HEADER([boost/assign.hpp])])
561 # Look for Boost.Bind.
563 [BOOST_FIND_HEADER([boost/bind.hpp])])
568 # Look for Boost.Chrono.
569 BOOST_DEFUN([Chrono],
570 [# Do we have to check for Boost.System? This link-time dependency was
571 # added as of 1.35.0. If we have a version <1.35, we must not attempt to
572 # find Boost.System as it didn't exist by then.
573 if test $boost_major_version -ge 135; then
575 fi # end of the Boost.System check.
576 boost_filesystem_save_LIBS=$LIBS
577 boost_filesystem_save_LDFLAGS=$LDFLAGS
578 m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
579 LIBS="$LIBS $BOOST_SYSTEM_LIBS"
580 LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
581 BOOST_FIND_LIB([chrono], [$1],
583 [boost::chrono::thread_clock d;])
584 if test $enable_static_boost = yes && test $boost_major_version -ge 135; then
585 BOOST_CHRONO_LIBS="$BOOST_CHRONO_LIBS $BOOST_SYSTEM_LIBS"
587 LIBS=$boost_filesystem_save_LIBS
588 LDFLAGS=$boost_filesystem_save_LDFLAGS
592 # BOOST_CONTEXT([PREFERRED-RT-OPT])
593 # -----------------------------------
594 # Look for Boost.Context. For the documentation of PREFERRED-RT-OPT, see the
595 # documentation of BOOST_FIND_LIB above.
597 # * This library was introduced in Boost 1.51.0
598 # * The signatures of make_fcontext() and jump_fcontext were changed in 1.56.0
599 # * A dependency on boost_thread appears in 1.57.0
600 BOOST_DEFUN([Context],
601 [boost_context_save_LIBS=$LIBS
602 boost_context_save_LDFLAGS=$LDFLAGS
603 if test $boost_major_version -ge 157; then
605 m4_pattern_allow([^BOOST_THREAD_(LIBS|LDFLAGS)$])dnl
606 LIBS="$LIBS $BOOST_THREAD_LIBS"
607 LDFLAGS="$LDFLAGS $BOOST_THREAD_LDFLAGS"
609 BOOST_FIND_LIB([context], [$1],
610 [boost/context/all.hpp],[[
613 void * stack_pointer = new void*[4096];
614 std::size_t const size = sizeof(void*[4096]);
616 #if BOOST_VERSION <= 105100
617 ctx::make_fcontext(&fc, f);
618 return ctx::jump_fcontext(&fcm, &fc, 3) == 6;
622 fc = ctx::make_fcontext(stack_pointer, size, f);
623 return ctx::jump_fcontext(&fcm, fc, 3) == 6;
630 #include <boost/version.hpp>
631 #if BOOST_VERSION <= 105100
633 namespace ctx = boost::ctx;
635 static ctx::fcontext_t fcm, fc;
637 static void f(intptr_t i) {
638 ctx::jump_fcontext(&fc, &fcm, i * 2);
641 #elif BOOST_VERSION <= 105500
643 namespace ctx = boost::context;
646 static ctx::fcontext_t fcm, *fc;
649 static void f(intptr_t i) {
650 ctx::jump_fcontext(fc, &fcm, i * 2);
655 namespace ctx = boost::context;
658 static ctx::fcontext_t fcm, fc;
661 static void f(intptr_t i) {
662 ctx::jump_fcontext(&fc, fcm, i * 2);
666 LIBS=$boost_context_save_LIBS
667 LDFLAGS=$boost_context_save_LDFLAGS
673 # Look for Boost.Conversion (cast / lexical_cast)
674 BOOST_DEFUN([Conversion],
675 [BOOST_FIND_HEADER([boost/cast.hpp])
676 BOOST_FIND_HEADER([boost/lexical_cast.hpp])
680 # BOOST_COROUTINE([PREFERRED-RT-OPT])
681 # -----------------------------------
682 # Look for Boost.Coroutine. For the documentation of PREFERRED-RT-OPT, see the
683 # documentation of BOOST_FIND_LIB above. This library was introduced in Boost
685 BOOST_DEFUN([Coroutine],
687 boost_coroutine_save_LIBS=$LIBS
688 boost_coroutine_save_LDFLAGS=$LDFLAGS
689 # Link-time dependency from coroutine to context
691 # Starting from Boost 1.55 a dependency on Boost.System is added
692 if test $boost_major_version -ge 155; then
695 m4_pattern_allow([^BOOST_(CONTEXT|SYSTEM)_(LIBS|LDFLAGS)])
696 LIBS="$LIBS $BOOST_CONTEXT_LIBS $BOOST_SYSTEM_LIBS"
697 LDFLAGS="$LDFLAGS $BOOST_CONTEXT_LDFLAGS"
699 # in 1.53 coroutine was a header only library
700 if test $boost_major_version -eq 153; then
701 BOOST_FIND_HEADER([boost/coroutine/coroutine.hpp])
703 BOOST_FIND_LIB([coroutine], [$1],
704 [boost/coroutine/coroutine.hpp],
706 #include <boost/version.hpp>
707 #if BOOST_VERSION <= 105500
708 boost::coroutines::coroutine<int(int)> coro; coro.get();
710 boost::coroutines::asymmetric_coroutine<int>::pull_type coro; coro.get();
714 # Link-time dependency from coroutine to context, existed only in 1.53, in 1.54
715 # coroutine doesn't use context from its headers but from its library.
716 if test $boost_major_version -eq 153 || test $enable_static_boost = yes && test $boost_major_version -ge 154; then
717 BOOST_COROUTINE_LIBS="$BOOST_COROUTINE_LIBS $BOOST_CONTEXT_LIBS"
718 BOOST_COROUTINE_LDFLAGS="$BOOST_COROUTINE_LDFLAGS $BOOST_CONTEXT_LDFLAGS"
720 if test $enable_static_boost = yes && test $boost_major_version -ge 155; then
721 BOOST_COROUTINE_LIBS="$BOOST_COROUTINE_LIBS $BOOST_SYSTEM_LIBS"
722 BOOST_COROUTINE_LDFLAGS="$BOOST_COROUTINE_LDFLAGS $BOOST_SYSTEM_LDFLAGS"
724 LIBS=$boost_coroutine_save_LIBS
725 LDFLAGS=$boost_coroutine_save_LDFLAGS
733 [BOOST_FIND_HEADER([boost/crc.hpp])
737 # BOOST_DATE_TIME([PREFERRED-RT-OPT])
738 # -----------------------------------
739 # Look for Boost.Date_Time. For the documentation of PREFERRED-RT-OPT, see the
740 # documentation of BOOST_FIND_LIB above.
741 BOOST_DEFUN([Date_Time],
742 [BOOST_FIND_LIB([date_time], [$1],
743 [boost/date_time/posix_time/posix_time.hpp],
744 [boost::posix_time::ptime t;])
748 # BOOST_FILESYSTEM([PREFERRED-RT-OPT])
749 # ------------------------------------
750 # Look for Boost.Filesystem. For the documentation of PREFERRED-RT-OPT, see
751 # the documentation of BOOST_FIND_LIB above.
752 # Do not check for boost/filesystem.hpp because this file was introduced in
754 BOOST_DEFUN([Filesystem],
755 [# Do we have to check for Boost.System? This link-time dependency was
756 # added as of 1.35.0. If we have a version <1.35, we must not attempt to
757 # find Boost.System as it didn't exist by then.
758 if test $boost_major_version -ge 135; then
760 fi # end of the Boost.System check.
761 boost_filesystem_save_LIBS=$LIBS
762 boost_filesystem_save_LDFLAGS=$LDFLAGS
763 m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
764 LIBS="$LIBS $BOOST_SYSTEM_LIBS"
765 LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
766 BOOST_FIND_LIB([filesystem], [$1],
767 [boost/filesystem/path.hpp], [boost::filesystem::path p;])
768 if test $enable_static_boost = yes && test $boost_major_version -ge 135; then
769 BOOST_FILESYSTEM_LIBS="$BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS"
771 LIBS=$boost_filesystem_save_LIBS
772 LDFLAGS=$boost_filesystem_save_LDFLAGS
778 # Look for Boost.Flyweight.
779 BOOST_DEFUN([Flyweight],
780 [dnl There's a hidden dependency on pthreads.
781 AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl
782 BOOST_FIND_HEADER([boost/flyweight.hpp])
783 AC_SUBST([BOOST_FLYWEIGHT_LIBS], [$boost_cv_pthread_flag])
789 # Look for Boost.Foreach.
790 BOOST_DEFUN([Foreach],
791 [BOOST_FIND_HEADER([boost/foreach.hpp])])
796 # Look for Boost.Format.
797 # Note: we can't check for boost/format/format_fwd.hpp because the header isn't
798 # standalone. It can't be compiled because it triggers the following error:
799 # boost/format/detail/config_macros.hpp:88: error: 'locale' in namespace 'std'
800 # does not name a type
801 BOOST_DEFUN([Format],
802 [BOOST_FIND_HEADER([boost/format.hpp])])
807 # Look for Boost.Function
808 BOOST_DEFUN([Function],
809 [BOOST_FIND_HEADER([boost/function.hpp])])
814 # Look for Boost.Geometry (new since 1.47.0).
815 BOOST_DEFUN([Geometry],
816 [BOOST_FIND_HEADER([boost/geometry.hpp])
820 # BOOST_GRAPH([PREFERRED-RT-OPT])
821 # -------------------------------
822 # Look for Boost.Graphs. For the documentation of PREFERRED-RT-OPT, see the
823 # documentation of BOOST_FIND_LIB above.
825 [boost_graph_save_LIBS=$LIBS
826 boost_graph_save_LDFLAGS=$LDFLAGS
827 # Link-time dependency from graph to regex was added as of 1.40.0.
828 if test $boost_major_version -ge 140; then
830 m4_pattern_allow([^BOOST_REGEX_(LIBS|LDFLAGS)$])dnl
831 LIBS="$LIBS $BOOST_REGEX_LIBS"
832 LDFLAGS="$LDFLAGS $BOOST_REGEX_LDFLAGS"
834 BOOST_FIND_LIB([graph], [$1],
835 [boost/graph/adjacency_list.hpp], [boost::adjacency_list<> g;])
836 LIBS=$boost_graph_save_LIBS
837 LDFLAGS=$boost_graph_save_LDFLAGS
841 # BOOST_IOSTREAMS([PREFERRED-RT-OPT])
842 # -----------------------------------
843 # Look for Boost.IOStreams. For the documentation of PREFERRED-RT-OPT, see the
844 # documentation of BOOST_FIND_LIB above.
845 BOOST_DEFUN([IOStreams],
846 [BOOST_FIND_LIB([iostreams], [$1],
847 [boost/iostreams/device/file_descriptor.hpp],
848 [boost::iostreams::file_descriptor fd; fd.close();])
854 # Look for Boost.Functional/Hash
856 [BOOST_FIND_HEADER([boost/functional/hash.hpp])])
861 # Look for Boost.Lambda
862 BOOST_DEFUN([Lambda],
863 [BOOST_FIND_HEADER([boost/lambda/lambda.hpp])])
868 # Look for Boost.Locale
869 BOOST_DEFUN([Locale],
871 boost_locale_save_LIBS=$LIBS
872 boost_locale_save_LDFLAGS=$LDFLAGS
873 # require SYSTEM for boost-1.50.0 and up
874 if test $boost_major_version -ge 150; then
876 m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
877 LIBS="$LIBS $BOOST_SYSTEM_LIBS"
878 LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
879 fi # end of the Boost.System check.
880 BOOST_FIND_LIB([locale], [$1],
882 [[boost::locale::generator gen; std::locale::global(gen(""));]])
883 LIBS=$boost_locale_save_LIBS
884 LDFLAGS=$boost_locale_save_LDFLAGS
887 # BOOST_LOG([PREFERRED-RT-OPT])
888 # -----------------------------
889 # Look for Boost.Log. For the documentation of PREFERRED-RT-OPT, see the
890 # documentation of BOOST_FIND_LIB above.
892 [boost_log_save_LIBS=$LIBS
893 boost_log_save_LDFLAGS=$LDFLAGS
895 BOOST_FILESYSTEM([$1])
896 BOOST_DATE_TIME([$1])
897 m4_pattern_allow([^BOOST_(SYSTEM|FILESYSTEM|DATE_TIME)_(LIBS|LDFLAGS)$])dnl
898 LIBS="$LIBS $BOOST_DATE_TIME_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS"
899 LDFLAGS="$LDFLAGS $BOOST_DATE_TIME_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS $BOOST_SYSTEM_LDFLAGS"
900 BOOST_FIND_LIB([log], [$1],
901 [boost/log/core/core.hpp],
902 [boost::log::attribute a; a.get_value();])
903 LIBS=$boost_log_save_LIBS
904 LDFLAGS=$boost_log_save_LDFLAGS
908 # BOOST_LOG_SETUP([PREFERRED-RT-OPT])
909 # -----------------------------------
910 # Look for Boost.Log. For the documentation of PREFERRED-RT-OPT, see the
911 # documentation of BOOST_FIND_LIB above.
912 BOOST_DEFUN([Log_Setup],
913 [boost_log_setup_save_LIBS=$LIBS
914 boost_log_setup_save_LDFLAGS=$LDFLAGS
916 m4_pattern_allow([^BOOST_LOG_(LIBS|LDFLAGS)$])dnl
917 LIBS="$LIBS $BOOST_LOG_LIBS"
918 LDFLAGS="$LDFLAGS $BOOST_LOG_LDFLAGS"
919 BOOST_FIND_LIB([log_setup], [$1],
920 [boost/log/utility/setup/from_settings.hpp],
921 [boost::log::basic_settings<char> bs; bs.empty();])
922 LIBS=$boost_log_setup_save_LIBS
923 LDFLAGS=$boost_log_setup_save_LDFLAGS
929 # Look for Boost.Math
930 # TODO: This library isn't header-only but it comes in multiple different
931 # flavors that don't play well with BOOST_FIND_LIB (e.g, libboost_math_c99,
932 # libboost_math_c99f, libboost_math_c99l, libboost_math_tr1,
933 # libboost_math_tr1f, libboost_math_tr1l). This macro must be fixed to do the
934 # right thing anyway.
936 [BOOST_FIND_HEADER([boost/math/special_functions.hpp])])
939 # BOOST_MPI([PREFERRED-RT-OPT])
940 # -------------------------------
941 # Look for Boost MPI. For the documentation of PREFERRED-RT-OPT, see the
942 # documentation of BOOST_FIND_LIB above. Uses MPICXX variable if it is
943 # set, otherwise tries CXX
946 [boost_save_CXX=${CXX}
947 boost_save_CXXCPP=${CXXCPP}
948 if test x"${MPICXX}" != x; then
950 CXXCPP="${MPICXX} -E"
952 BOOST_FIND_LIB([mpi], [$1],
956 boost::mpi::environment env(argc,argv);])
957 CXX=${boost_save_CXX}
958 CXXCPP=${boost_save_CXXCPP}
964 # Look for Boost.MultiArray
965 BOOST_DEFUN([MultiArray],
966 [BOOST_FIND_HEADER([boost/multi_array.hpp])])
969 # BOOST_NUMERIC_UBLAS()
970 # --------------------------
971 # Look for Boost.NumericUblas (Basic Linear Algebra)
972 BOOST_DEFUN([Numeric_Ublas],
973 [BOOST_FIND_HEADER([boost/numeric/ublas/vector.hpp])
974 ])# BOOST_NUMERIC_UBLAS
977 # BOOST_NUMERIC_CONVERSION()
978 # --------------------------
979 # Look for Boost.NumericConversion (policy-based numeric conversion)
980 BOOST_DEFUN([Numeric_Conversion],
981 [BOOST_FIND_HEADER([boost/numeric/conversion/converter.hpp])
982 ])# BOOST_NUMERIC_CONVERSION
987 # Look for Boost.Optional
988 BOOST_DEFUN([Optional],
989 [BOOST_FIND_HEADER([boost/optional.hpp])])
992 # BOOST_PREPROCESSOR()
993 # --------------------
994 # Look for Boost.Preprocessor
995 BOOST_DEFUN([Preprocessor],
996 [BOOST_FIND_HEADER([boost/preprocessor/repeat.hpp])])
1000 # --------------------
1001 # Look for Boost.Range
1002 BOOST_DEFUN([Range],
1003 [BOOST_FIND_HEADER([boost/range/adaptors.hpp])])
1007 # Look for Boost.Unordered
1008 BOOST_DEFUN([Unordered],
1009 [BOOST_FIND_HEADER([boost/unordered_map.hpp])])
1014 # Look for Boost.Uuid
1016 [BOOST_FIND_HEADER([boost/uuid/uuid.hpp])])
1019 # BOOST_PROGRAM_OPTIONS([PREFERRED-RT-OPT])
1020 # -----------------------------------------
1021 # Look for Boost.Program_options. For the documentation of PREFERRED-RT-OPT,
1022 # see the documentation of BOOST_FIND_LIB above.
1023 BOOST_DEFUN([Program_Options],
1024 [BOOST_FIND_LIB([program_options], [$1],
1025 [boost/program_options.hpp],
1026 [boost::program_options::options_description d("test");])
1027 ])# BOOST_PROGRAM_OPTIONS
1031 # _BOOST_PYTHON_CONFIG(VARIABLE, FLAG)
1032 # ------------------------------------
1033 # Save VARIABLE, and define it via `python-config --FLAG`.
1034 # Substitute BOOST_PYTHON_VARIABLE.
1035 m4_define([_BOOST_PYTHON_CONFIG],
1036 [AC_SUBST([BOOST_PYTHON_$1],
1037 [`python-config --$2 2>/dev/null`])dnl
1038 boost_python_save_$1=$$1
1039 $1="$$1 $BOOST_PYTHON_$1"])
1042 # BOOST_PYTHON([PREFERRED-RT-OPT])
1043 # --------------------------------
1044 # Look for Boost.Python. For the documentation of PREFERRED-RT-OPT,
1045 # see the documentation of BOOST_FIND_LIB above.
1046 BOOST_DEFUN([Python],
1047 [_BOOST_PYTHON_CONFIG([CPPFLAGS], [includes])
1048 _BOOST_PYTHON_CONFIG([LDFLAGS], [ldflags])
1049 _BOOST_PYTHON_CONFIG([LIBS], [libs])
1050 m4_pattern_allow([^BOOST_PYTHON_MODULE$])dnl
1051 BOOST_FIND_LIBS([python], [python python3], [$1],
1053 [], [BOOST_PYTHON_MODULE(empty) {}])
1054 CPPFLAGS=$boost_python_save_CPPFLAGS
1055 LDFLAGS=$boost_python_save_LDFLAGS
1056 LIBS=$boost_python_save_LIBS
1062 # Look for Boost.Ref
1064 [BOOST_FIND_HEADER([boost/ref.hpp])])
1067 # BOOST_REGEX([PREFERRED-RT-OPT])
1068 # -------------------------------
1069 # Look for Boost.Regex. For the documentation of PREFERRED-RT-OPT, see the
1070 # documentation of BOOST_FIND_LIB above.
1071 BOOST_DEFUN([Regex],
1072 [BOOST_FIND_LIB([regex], [$1],
1074 [boost::regex exp("*"); boost::regex_match("foo", exp);])
1078 # BOOST_SERIALIZATION([PREFERRED-RT-OPT])
1079 # ---------------------------------------
1080 # Look for Boost.Serialization. For the documentation of PREFERRED-RT-OPT, see
1081 # the documentation of BOOST_FIND_LIB above.
1082 BOOST_DEFUN([Serialization],
1083 [BOOST_FIND_LIB([serialization], [$1],
1084 [boost/archive/text_oarchive.hpp],
1085 [std::ostream* o = 0; // Cheap way to get an ostream...
1086 boost::archive::text_oarchive t(*o);])
1087 ])# BOOST_SERIALIZATION
1090 # BOOST_SIGNALS([PREFERRED-RT-OPT])
1091 # ---------------------------------
1092 # Look for Boost.Signals. For the documentation of PREFERRED-RT-OPT, see the
1093 # documentation of BOOST_FIND_LIB above.
1094 BOOST_DEFUN([Signals],
1095 [BOOST_FIND_LIB([signals], [$1],
1097 [boost::signal<void ()> s;])
1103 # Look for Boost.Signals2 (new since 1.39.0).
1104 BOOST_DEFUN([Signals2],
1105 [BOOST_FIND_HEADER([boost/signals2.hpp])
1111 # Look for Boost.SmartPtr
1112 BOOST_DEFUN([Smart_Ptr],
1113 [BOOST_FIND_HEADER([boost/scoped_ptr.hpp])
1114 BOOST_FIND_HEADER([boost/shared_ptr.hpp])
1118 # BOOST_STATICASSERT()
1119 # --------------------
1120 # Look for Boost.StaticAssert
1121 BOOST_DEFUN([StaticAssert],
1122 [BOOST_FIND_HEADER([boost/static_assert.hpp])])
1125 # BOOST_STRING_ALGO()
1126 # -------------------
1127 # Look for Boost.StringAlgo
1128 BOOST_DEFUN([String_Algo],
1129 [BOOST_FIND_HEADER([boost/algorithm/string.hpp])
1133 # BOOST_SYSTEM([PREFERRED-RT-OPT])
1134 # --------------------------------
1135 # Look for Boost.System. For the documentation of PREFERRED-RT-OPT, see the
1136 # documentation of BOOST_FIND_LIB above. This library was introduced in Boost
1138 BOOST_DEFUN([System],
1139 [BOOST_FIND_LIB([system], [$1],
1140 [boost/system/error_code.hpp],
1141 [boost::system::error_code e; e.clear();])
1145 # BOOST_TEST([PREFERRED-RT-OPT])
1146 # ------------------------------
1147 # Look for Boost.Test. For the documentation of PREFERRED-RT-OPT, see the
1148 # documentation of BOOST_FIND_LIB above.
1150 [m4_pattern_allow([^BOOST_CHECK$])dnl
1151 BOOST_FIND_LIB([unit_test_framework], [$1],
1152 [boost/test/unit_test.hpp], [BOOST_CHECK(2 == 2);],
1153 [using boost::unit_test::test_suite;
1154 test_suite* init_unit_test_suite(int argc, char ** argv)
1159 # BOOST_THREAD([PREFERRED-RT-OPT])
1160 # ---------------------------------
1161 # Look for Boost.Thread. For the documentation of PREFERRED-RT-OPT, see the
1162 # documentation of BOOST_FIND_LIB above.
1163 BOOST_DEFUN([Thread],
1164 [dnl Having the pthread flag is required at least on GCC3 where
1165 dnl boost/thread.hpp would complain if we try to compile without
1166 dnl -pthread on GNU/Linux.
1167 AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl
1168 boost_thread_save_LIBS=$LIBS
1169 boost_thread_save_LDFLAGS=$LDFLAGS
1170 boost_thread_save_CPPFLAGS=$CPPFLAGS
1171 # Link-time dependency from thread to system was added as of 1.49.0.
1172 if test $boost_major_version -ge 149; then
1174 fi # end of the Boost.System check.
1175 m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
1176 LIBS="$LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag"
1177 LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
1178 CPPFLAGS="$CPPFLAGS $boost_cv_pthread_flag"
1180 # When compiling for the Windows platform, the threads library is named
1181 # differently. This suffix doesn't exist in new versions of Boost, or
1182 # possibly new versions of GCC on mingw I am assuming it's Boost's change for
1183 # now and I am setting version to 1.48, for lack of knowledge as to when this
1185 if test $boost_major_version -lt 148; then
1187 (*mingw*) boost_thread_lib_ext=_win32;;
1190 BOOST_FIND_LIBS([thread], [thread$boost_thread_lib_ext],
1192 [boost/thread.hpp], [boost::thread t; boost::mutex m;])
1195 (*mingw*) boost_thread_w32_socket_link=-lws2_32;;
1198 BOOST_THREAD_LIBS="$BOOST_THREAD_LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag $boost_thread_w32_socket_link"
1199 BOOST_THREAD_LDFLAGS="$BOOST_SYSTEM_LDFLAGS"
1200 BOOST_CPPFLAGS="$BOOST_CPPFLAGS $boost_cv_pthread_flag"
1201 LIBS=$boost_thread_save_LIBS
1202 LDFLAGS=$boost_thread_save_LDFLAGS
1203 CPPFLAGS=$boost_thread_save_CPPFLAGS
1206 AU_ALIAS([BOOST_THREADS], [BOOST_THREAD])
1211 # Look for Boost.Tokenizer
1212 BOOST_DEFUN([Tokenizer],
1213 [BOOST_FIND_HEADER([boost/tokenizer.hpp])])
1218 # Look for Boost.Tribool
1219 BOOST_DEFUN([Tribool],
1220 [BOOST_FIND_HEADER([boost/logic/tribool_fwd.hpp])
1221 BOOST_FIND_HEADER([boost/logic/tribool.hpp])
1227 # Look for Boost.Tuple
1228 BOOST_DEFUN([Tuple],
1229 [BOOST_FIND_HEADER([boost/tuple/tuple.hpp])])
1232 # BOOST_TYPETRAITS()
1233 # --------------------
1234 # Look for Boost.TypeTraits
1235 BOOST_DEFUN([TypeTraits],
1236 [BOOST_FIND_HEADER([boost/type_traits.hpp])])
1241 # Look for Boost.Utility (noncopyable, result_of, base-from-member idiom,
1243 BOOST_DEFUN([Utility],
1244 [BOOST_FIND_HEADER([boost/utility.hpp])])
1249 # Look for Boost.Variant.
1250 BOOST_DEFUN([Variant],
1251 [BOOST_FIND_HEADER([boost/variant/variant_fwd.hpp])
1252 BOOST_FIND_HEADER([boost/variant.hpp])])
1255 # BOOST_POINTER_CONTAINER()
1256 # ------------------------
1257 # Look for Boost.PointerContainer
1258 BOOST_DEFUN([Pointer_Container],
1259 [BOOST_FIND_HEADER([boost/ptr_container/ptr_deque.hpp])
1260 BOOST_FIND_HEADER([boost/ptr_container/ptr_list.hpp])
1261 BOOST_FIND_HEADER([boost/ptr_container/ptr_vector.hpp])
1262 BOOST_FIND_HEADER([boost/ptr_container/ptr_array.hpp])
1263 BOOST_FIND_HEADER([boost/ptr_container/ptr_set.hpp])
1264 BOOST_FIND_HEADER([boost/ptr_container/ptr_map.hpp])
1265 ])# BOOST_POINTER_CONTAINER
1268 # BOOST_WAVE([PREFERRED-RT-OPT])
1269 # ------------------------------
1270 # NOTE: If you intend to use Wave/Spirit with thread support, make sure you
1271 # call BOOST_THREAD first.
1272 # Look for Boost.Wave. For the documentation of PREFERRED-RT-OPT, see the
1273 # documentation of BOOST_FIND_LIB above.
1275 [AC_REQUIRE([BOOST_FILESYSTEM])dnl
1276 AC_REQUIRE([BOOST_DATE_TIME])dnl
1277 boost_wave_save_LIBS=$LIBS
1278 boost_wave_save_LDFLAGS=$LDFLAGS
1279 m4_pattern_allow([^BOOST_((FILE)?SYSTEM|DATE_TIME|THREAD)_(LIBS|LDFLAGS)$])dnl
1280 LIBS="$LIBS $BOOST_SYSTEM_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_DATE_TIME_LIBS \
1282 LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS \
1283 $BOOST_DATE_TIME_LDFLAGS $BOOST_THREAD_LDFLAGS"
1284 BOOST_FIND_LIB([wave], [$1],
1286 [boost::wave::token_id id; get_token_name(id);])
1287 LIBS=$boost_wave_save_LIBS
1288 LDFLAGS=$boost_wave_save_LDFLAGS
1294 # Look for Boost.Xpressive (new since 1.36.0).
1295 BOOST_DEFUN([Xpressive],
1296 [BOOST_FIND_HEADER([boost/xpressive/xpressive.hpp])])
1299 # ----------------- #
1300 # Internal helpers. #
1301 # ----------------- #
1304 # _BOOST_PTHREAD_FLAG()
1305 # ---------------------
1306 # Internal helper for BOOST_THREAD. Computes boost_cv_pthread_flag
1307 # which must be used in CPPFLAGS and LIBS.
1309 # Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3,
1310 # boost/thread.hpp will trigger a #error if -pthread isn't used:
1311 # boost/config/requires_threads.hpp:47:5: #error "Compiler threading support
1312 # is not turned on. Please set the correct command line options for
1313 # threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
1315 # Based on ACX_PTHREAD: http://autoconf-archive.cryp.to/acx_pthread.html
1316 AC_DEFUN([_BOOST_PTHREAD_FLAG],
1317 [AC_REQUIRE([AC_PROG_CXX])dnl
1318 AC_REQUIRE([AC_CANONICAL_HOST])dnl
1319 AC_LANG_PUSH([C++])dnl
1320 AC_CACHE_CHECK([for the flags needed to use pthreads], [boost_cv_pthread_flag],
1321 [ boost_cv_pthread_flag=
1322 # The ordering *is* (sometimes) important. Some notes on the
1323 # individual items follow:
1324 # (none): in case threads are in libc; should be tried before -Kthread and
1325 # other compiler flags to prevent continual compiler warnings
1326 # -lpthreads: AIX (must check this before -lpthread)
1327 # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
1328 # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
1329 # -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
1330 # -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads)
1331 # -pthreads: Solaris/GCC
1332 # -mthreads: MinGW32/GCC, Lynx/GCC
1333 # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
1334 # doesn't hurt to check since this sometimes defines pthreads too;
1335 # also defines -D_REENTRANT)
1336 # ... -mt is also the pthreads flag for HP/aCC
1337 # -lpthread: GNU Linux, etc.
1338 # --thread-safe: KAI C++
1341 # On Solaris (at least, for some versions), libc contains stubbed
1342 # (non-functional) versions of the pthreads routines, so link-based
1343 # tests will erroneously succeed. (We need to link with -pthreads/-mt/
1344 # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
1345 # a function called by this macro, so we could check for that, but
1346 # who knows whether they'll stub that too in a future libc.) So,
1347 # we'll just look for -pthreads and -lpthread first:
1348 boost_pthread_flags="-pthreads -lpthread -mt -pthread";; #(
1350 boost_pthread_flags="-lpthreads -Kthread -kthread -llthread -pthread \
1351 -pthreads -mthreads -lpthread --thread-safe -mt";;
1353 # Generate the test file.
1354 AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <pthread.h>],
1355 [pthread_t th; pthread_join(th, 0);
1356 pthread_attr_init(0); pthread_cleanup_push(0, 0);
1357 pthread_create(0,0,0,0); pthread_cleanup_pop(0);])])
1358 for boost_pthread_flag in '' $boost_pthread_flags; do
1359 boost_pthread_ok=false
1360 dnl Re-use the test file already generated.
1361 boost_pthreads__save_LIBS=$LIBS
1362 LIBS="$LIBS $boost_pthread_flag"
1364 [if grep ".*$boost_pthread_flag" conftest.err; then
1365 echo "This flag seems to have triggered warnings" >&AS_MESSAGE_LOG_FD
1367 boost_pthread_ok=:; boost_cv_pthread_flag=$boost_pthread_flag
1369 LIBS=$boost_pthreads__save_LIBS
1370 $boost_pthread_ok && break
1373 AC_LANG_POP([C++])dnl
1374 ])# _BOOST_PTHREAD_FLAG
1377 # _BOOST_gcc_test(MAJOR, MINOR)
1378 # -----------------------------
1379 # Internal helper for _BOOST_FIND_COMPILER_TAG.
1380 m4_define([_BOOST_gcc_test],
1381 ["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC @ gcc$1$2"])dnl
1383 # _BOOST_mingw_test(MAJOR, MINOR)
1384 # -----------------------------
1385 # Internal helper for _BOOST_FIND_COMPILER_TAG.
1386 m4_define([_BOOST_mingw_test],
1387 ["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC && \
1388 (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \
1389 || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw$1$2"])dnl
1392 # _BOOST_FIND_COMPILER_TAG()
1393 # --------------------------
1394 # Internal. When Boost is installed without --layout=system, each library
1395 # filename will hold a suffix that encodes the compiler used during the
1396 # build. The Boost build system seems to call this a `tag'.
1397 AC_DEFUN([_BOOST_FIND_COMPILER_TAG],
1398 [AC_REQUIRE([AC_PROG_CXX])dnl
1399 AC_REQUIRE([AC_CANONICAL_HOST])dnl
1400 AC_CACHE_CHECK([for the toolset name used by Boost for $CXX],
1402 [boost_cv_lib_tag=unknown
1403 if test x$boost_cv_inc_path != xno; then
1404 AC_LANG_PUSH([C++])dnl
1405 # The following tests are mostly inspired by boost/config/auto_link.hpp
1406 # The list is sorted to most recent/common to oldest compiler (in order
1407 # to increase the likelihood of finding the right compiler with the
1408 # least number of compilation attempt).
1409 # Beware that some tests are sensible to the order (for instance, we must
1410 # look for MinGW before looking for GCC3).
1411 # I used one compilation test per compiler with a #error to recognize
1412 # each compiler so that it works even when cross-compiling (let me know
1413 # if you know a better approach).
1414 # Known missing tags (known from Boost's tools/build/v2/tools/common.jam):
1415 # como, edg, kcc, bck, mp, sw, tru, xlc
1416 # I'm not sure about my test for `il' (be careful: Intel's ICC pre-defines
1417 # the same defines as GCC's).
1419 _BOOST_mingw_test(6, 2) \
1420 _BOOST_gcc_test(6, 2) \
1421 _BOOST_mingw_test(6, 1) \
1422 _BOOST_gcc_test(6, 1) \
1423 _BOOST_mingw_test(6, 0) \
1424 _BOOST_gcc_test(6, 0) \
1425 _BOOST_mingw_test(5, 3) \
1426 _BOOST_gcc_test(5, 3) \
1427 _BOOST_mingw_test(5, 2) \
1428 _BOOST_gcc_test(5, 2) \
1429 _BOOST_mingw_test(5, 1) \
1430 _BOOST_gcc_test(5, 1) \
1431 _BOOST_mingw_test(5, 0) \
1432 _BOOST_gcc_test(5, 0) \
1433 _BOOST_mingw_test(4, 10) \
1434 _BOOST_gcc_test(4, 10) \
1435 _BOOST_mingw_test(4, 9) \
1436 _BOOST_gcc_test(4, 9) \
1437 _BOOST_mingw_test(4, 8) \
1438 _BOOST_gcc_test(4, 8) \
1439 _BOOST_mingw_test(4, 7) \
1440 _BOOST_gcc_test(4, 7) \
1441 _BOOST_mingw_test(4, 6) \
1442 _BOOST_gcc_test(4, 6) \
1443 _BOOST_mingw_test(4, 5) \
1444 _BOOST_gcc_test(4, 5) \
1445 _BOOST_mingw_test(4, 4) \
1446 _BOOST_gcc_test(4, 4) \
1447 _BOOST_mingw_test(4, 3) \
1448 _BOOST_gcc_test(4, 3) \
1449 _BOOST_mingw_test(4, 2) \
1450 _BOOST_gcc_test(4, 2) \
1451 _BOOST_mingw_test(4, 1) \
1452 _BOOST_gcc_test(4, 1) \
1453 _BOOST_mingw_test(4, 0) \
1454 _BOOST_gcc_test(4, 0) \
1455 "defined __GNUC__ && __GNUC__ == 3 && !defined __ICC \
1456 && (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \
1457 || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw" \
1458 _BOOST_gcc_test(3, 4) \
1459 _BOOST_gcc_test(3, 3) \
1460 "defined _MSC_VER && _MSC_VER >= 1500 @ vc90" \
1461 "defined _MSC_VER && _MSC_VER == 1400 @ vc80" \
1462 _BOOST_gcc_test(3, 2) \
1463 "defined _MSC_VER && _MSC_VER == 1310 @ vc71" \
1464 _BOOST_gcc_test(3, 1) \
1465 _BOOST_gcc_test(3, 0) \
1466 "defined __BORLANDC__ @ bcb" \
1467 "defined __ICC && (defined __unix || defined __unix__) @ il" \
1468 "defined __ICL @ iw" \
1469 "defined _MSC_VER && _MSC_VER == 1300 @ vc7" \
1470 _BOOST_gcc_test(2, 95) \
1471 "defined __MWERKS__ && __MWERKS__ <= 0x32FF @ cw9" \
1472 "defined _MSC_VER && _MSC_VER < 1300 && !defined UNDER_CE @ vc6" \
1473 "defined _MSC_VER && _MSC_VER < 1300 && defined UNDER_CE @ evc4" \
1474 "defined __MWERKS__ && __MWERKS__ <= 0x31FF @ cw8"
1476 boost_tag_test=`expr "X$i" : 'X\([[^@]]*\) @ '`
1477 boost_tag=`expr "X$i" : 'X[[^@]]* @ \(.*\)'`
1478 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1482 # error $boost_tag_test
1484 ]])], [boost_cv_lib_tag=$boost_tag; break], [])
1486 AC_LANG_POP([C++])dnl
1487 case $boost_cv_lib_tag in #(
1488 # Some newer (>= 1.35?) versions of Boost seem to only use "gcc" as opposed
1489 # to "gcc41" for instance.
1490 *-gcc | *'-gcc ') :;; #( Don't re-add -gcc: it's already in there.
1495 if test $boost_major_version -ge 136; then
1496 # The `x' added in r46793 of Boost.
1500 # We can specify multiple tags in this variable because it's used by
1501 # BOOST_FIND_LIB that does a `for tag in -$boost_cv_lib_tag' ...
1502 boost_cv_lib_tag="$boost_tag_x$boost_cv_lib_tag -${boost_tag_x}gcc"
1505 AC_MSG_WARN([[could not figure out which toolset name to use for $CXX]])
1509 fi])dnl end of AC_CACHE_CHECK
1510 ])# _BOOST_FIND_COMPILER_TAG
1513 # _BOOST_GUESS_WHETHER_TO_USE_MT()
1514 # --------------------------------
1515 # Compile a small test to try to guess whether we should favor MT (Multi
1516 # Thread) flavors of Boost. Sets boost_guess_use_mt accordingly.
1517 AC_DEFUN([_BOOST_GUESS_WHETHER_TO_USE_MT],
1518 [# Check whether we do better use `mt' even though we weren't ask to.
1519 AC_LANG_PUSH([C++])dnl
1520 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1521 #if defined _REENTRANT || defined _MT || defined __MT__
1524 # error MT not needed
1526 ]])], [boost_guess_use_mt=:], [boost_guess_use_mt=false])
1527 AC_LANG_POP([C++])dnl
1530 # _BOOST_AC_LINK_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
1531 # -------------------------------------------------------------------
1532 # Fork of _AC_LINK_IFELSE that preserves conftest.o across calls. Fragile,
1533 # will break when Autoconf changes its internals. Requires that you manually
1534 # rm -f conftest.$ac_objext in between to really different tests, otherwise
1535 # you will try to link a conftest.o left behind by a previous test.
1536 # Used to aggressively optimize BOOST_FIND_LIB (see the big comment in this
1539 # Don't use "break" in the actions, as it would short-circuit some code
1540 # this macro runs after the actions.
1541 m4_define([_BOOST_AC_LINK_IFELSE],
1542 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
1543 rm -f conftest$ac_exeext
1544 boost_save_ac_ext=$ac_ext
1546 # If we already have a .o, re-use it. We change $ac_ext so that $ac_link
1547 # tries to link the existing object file instead of compiling from source.
1548 test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false &&
1549 _AS_ECHO_LOG([re-using the existing conftest.$ac_objext])
1550 AS_IF([_AC_DO_STDERR($ac_link) && {
1551 test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" ||
1552 test ! -s conftest.err
1553 } && test -s conftest$ac_exeext && {
1554 test "$cross_compiling" = yes ||
1555 $as_executable_p conftest$ac_exeext
1556 dnl FIXME: use AS_TEST_X instead when 2.61 is widespread enough.
1559 [if $boost_use_source; then
1560 _AC_MSG_LOG_CONFTEST
1563 ac_objext=$boost_save_ac_objext
1564 ac_ext=$boost_save_ac_ext
1565 dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization)
1566 dnl information created by the PGI compiler (conftest_ipa8_conftest.oo),
1567 dnl as it would interfere with the next link command.
1568 rm -f core conftest.err conftest_ipa8_conftest.oo \
1569 conftest$ac_exeext m4_ifval([$1], [conftest.$ac_ext])[]dnl
1570 ])# _BOOST_AC_LINK_IFELSE