]> git.ipfire.org Git - thirdparty/pdns.git/blame - m4/boost.m4
Merge pull request #8858 from Habbie/soa-autofill-4.4
[thirdparty/pdns.git] / m4 / boost.m4
CommitLineData
94ac5f34 1# boost.m4: Locate Boost headers and libraries for autoconf-based projects.
2187934a 2# Copyright (C) 2007-2011, 2014 Benoit Sigoure <tsuna@lrde.epita.fr>
94ac5f34
PD
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
24m4_define([_BOOST_SERIAL], [m4_translit([
c54133a4 25# serial 31
94ac5f34
PD
26], [#
27], [])])
28
0b59e24e 29# Original sources can be found at http://github.com/tsuna/boost.m4
94ac5f34 30# You can fetch the latest version of the script by doing:
0b59e24e 31# wget http://github.com/tsuna/boost.m4/raw/master/build-aux/boost.m4
94ac5f34
PD
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
48m4_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.
61m4_define([_BOOST_SED_CPP],
2187934a
RK
62[AC_LANG_PUSH([C++])dnl
63AC_LANG_PREPROC_REQUIRE()dnl
94ac5f34
PD
64AC_REQUIRE([AC_PROG_SED])dnl
65AC_LANG_CONFTEST([AC_LANG_SOURCE([[$2]])])
66AS_IF([dnl eval is necessary to expand ac_cpp.
67dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
68dnl Beware of Windows end-of-lines, for instance if we are running
69dnl some Windows programs under Wine. In that case, boost/version.hpp
70dnl is certainly using "\r\n", but the regular Unix shell will only
71dnl strip `\n' with backquotes, not the `\r'. This results in
72dnl boost_cv_lib_version='1_37\r' for instance, which breaks
73dnl everything else.
74dnl Cannot use 'dnl' after [$4] because a trailing dnl may break AC_CACHE_CHECK
2187934a
RK
75dnl
76dnl Beware that GCC 5, when expanding macros, may embed # line directives
77dnl a within single line:
78dnl
79dnl # 1 "conftest.cc"
80dnl # 1 "<built-in>"
81dnl # 1 "<command-line>"
82dnl # 1 "conftest.cc"
83dnl # 1 "/opt/local/include/boost/version.hpp" 1 3
84dnl # 2 "conftest.cc" 2
85dnl boost-lib-version =
86dnl # 2 "conftest.cc" 3
87dnl "1_56"
88dnl
a0e4992b 89dnl So get rid of the # and empty lines, and glue the remaining ones together.
94ac5f34 90(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
2187934a 91 grep -v '#' |
a0e4992b 92 grep -v '^[[[:space:]]]*$' |
94ac5f34 93 tr -d '\r' |
2187934a 94 tr -s '\n' ' ' |
94ac5f34
PD
95 $SED -n -e "$1" >conftest.i 2>&1],
96 [$3],
97 [$4])
98rm -rf conftest*
2187934a
RK
99AC_LANG_POP([C++])dnl
100])# _BOOST_SED_CPP
94ac5f34
PD
101
102
103
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
108# variable "$var".
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.
b0d6e9e6 114AC_DEFUN_ONCE([BOOST_REQUIRE],
94ac5f34
PD
115[AC_REQUIRE([AC_PROG_CXX])dnl
116AC_REQUIRE([AC_PROG_GREP])dnl
117echo "$as_me: this is boost.m4[]_BOOST_SERIAL" >&AS_MESSAGE_LOG_FD
118boost_save_IFS=$IFS
119boost_version_req=$1
120IFS=.
121set x $boost_version_req 0 0 0
122IFS=$boost_save_IFS
123shift
124boost_version_req=`expr "$[1]" '*' 100000 + "$[2]" '*' 100 + "$[3]"`
125boost_version_req_string=$[1].$[2].$[3]
126AC_ARG_WITH([boost],
127 [AS_HELP_STRING([--with-boost=DIR],
128 [prefix of Boost $1 @<:@guess@:>@])])dnl
129AC_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.
132if 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
136 else
137 AC_MSG_NOTICE([Detected BOOST_ROOT=$BOOST_ROOT, but overridden by --with-boost=$with_boost])
138 fi
139fi
140AC_SUBST([DISTCHECK_CONFIGURE_FLAGS],
141 ["$DISTCHECK_CONFIGURE_FLAGS '--with-boost=$with_boost'"])dnl
142boost_save_CPPFLAGS=$CPPFLAGS
143 AC_CACHE_CHECK([for Boost headers version >= $boost_version_req_string],
144 [boost_cv_inc_path],
145 [boost_cv_inc_path=no
146AC_LANG_PUSH([C++])dnl
147m4_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
153#endif
154]])])
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";;
160 esac
161 shift
162 for boost_dir
163 do
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.
167 #
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.
171 #
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 \
175 && echo .`
176 for boost_inc in $boost_layout_system_search_list
177 do
178 if test x"$boost_inc" != x.; then
179 boost_inc="$boost_dir/$boost_inc"
180 else
181 boost_inc="$boost_dir" # Uses sentinel in boost_layout_system_search_list
182 fi
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.
193 #
194 # Use test -e as there can be symlinks.
195 test -e "$boost_inc/boost/version.hpp" || continue
196 CPPFLAGS="$CPPFLAGS -I$boost_inc"
197 fi
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
202 fi
203 break 2
204 fi
205 done
206 done
207AC_LANG_POP([C++])dnl
208 ])
209 case $boost_cv_inc_path in #(
210 no)
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])])
214 $2
215 ;;#(
216 yes)
217 BOOST_CPPFLAGS=
218 ;;#(
219 *)
220 AC_SUBST([BOOST_CPPFLAGS], ["-I$boost_cv_inc_path"])dnl
221 ;;
222 esac
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
2187934a 229 _BOOST_SED_CPP([[/^boost-lib-version = /{s///;s/[\" ]//g;p;q;}]],
94ac5f34
PD
230 [#include <boost/version.hpp>
231boost-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 #(
236 '' | *[[!0-9]]*)
2187934a 237 AC_MSG_ERROR([invalid value: boost_major_version='$boost_major_version'])
94ac5f34
PD
238 ;;
239 esac
240fi
241CPPFLAGS=$boost_save_CPPFLAGS
242])# BOOST_REQUIRE
243
2187934a 244
94ac5f34
PD
245# BOOST_STATIC()
246# --------------
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.
249AC_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
255
2187934a 256
94ac5f34
PD
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).
262#
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.
267#
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).
271AC_DEFUN([BOOST_FIND_HEADER],
272[AC_REQUIRE([BOOST_REQUIRE])dnl
273if test x"$boost_cv_inc_path" = xno; then
274 m4_default([$2], [AC_MSG_NOTICE([Boost not available, not searching for $1])])
275else
276AC_LANG_PUSH([C++])dnl
277boost_save_CPPFLAGS=$CPPFLAGS
278CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
279AC_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])])])
283CPPFLAGS=$boost_save_CPPFLAGS
284AC_LANG_POP([C++])dnl
285fi
286])# BOOST_FIND_HEADER
287
288
2187934a
RK
289# BOOST_FIND_LIBS([COMPONENT-NAME], [CANDIDATE-LIB-NAMES],
290# [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST],
1b88fc23
PL
291# [CXX-PROLOGUE], [CXX-POST-INCLUDE-PROLOGUE],
292# [ERROR_ON_UNUSABLE])
2187934a
RK
293# --------------------------------------------------------------
294# Look for the Boost library COMPONENT-NAME (e.g., `thread', for
295# libboost_thread) under the possible CANDIDATE-LIB-NAMES (e.g.,
296# "thread_win32 thread"). Check that HEADER-NAME works and check that
297# libboost_LIB-NAME can link with the code CXX-TEST. The optional
298# argument CXX-PROLOGUE can be used to include some C++ code before
1b88fc23
PL
299# the `main' function. The CXX-POST-INCLUDE-PROLOGUE can be used to
300# include some code before the `main' function, but after the
301# `#include <HEADER-NAME>'.
94ac5f34
PD
302#
303# Invokes BOOST_FIND_HEADER([HEADER-NAME]) (see above).
304#
305# Boost libraries typically come compiled with several flavors (with different
306# runtime options) so PREFERRED-RT-OPT is the preferred suffix. A suffix is one
307# or more of the following letters: sgdpn (in that order). s = static
308# runtime, d = debug build, g = debug/diagnostic runtime, p = STLPort build,
309# n = (unsure) STLPort build without iostreams from STLPort (it looks like `n'
310# must always be used along with `p'). Additionally, PREFERRED-RT-OPT can
311# start with `mt-' to indicate that there is a preference for multi-thread
312# builds. Some sample values for PREFERRED-RT-OPT: (nothing), mt, d, mt-d, gdp
313# ... If you want to make sure you have a specific version of Boost
314# (eg, >= 1.33) you *must* invoke BOOST_REQUIRE before this macro.
1b88fc23
PL
315#
316# ERROR_ON_UNUSABLE can be set to "no" if the caller does not want their
317# configure to fail
2187934a 318AC_DEFUN([BOOST_FIND_LIBS],
94ac5f34
PD
319[AC_REQUIRE([BOOST_REQUIRE])dnl
320AC_REQUIRE([_BOOST_FIND_COMPILER_TAG])dnl
321AC_REQUIRE([BOOST_STATIC])dnl
322AC_REQUIRE([_BOOST_GUESS_WHETHER_TO_USE_MT])dnl
323if test x"$boost_cv_inc_path" = xno; then
324 AC_MSG_NOTICE([Boost not available, not searching for the Boost $1 library])
325else
0b59e24e 326dnl The else branch is huge and wasn't indented on purpose.
94ac5f34
PD
327AC_LANG_PUSH([C++])dnl
328AS_VAR_PUSHDEF([Boost_lib], [boost_cv_lib_$1])dnl
329AS_VAR_PUSHDEF([Boost_lib_LDFLAGS], [boost_cv_lib_$1_LDFLAGS])dnl
330AS_VAR_PUSHDEF([Boost_lib_LDPATH], [boost_cv_lib_$1_LDPATH])dnl
331AS_VAR_PUSHDEF([Boost_lib_LIBS], [boost_cv_lib_$1_LIBS])dnl
1b88fc23
PL
332AS_IF([test x"$8" = "xno"], [not_found_header='true'])
333BOOST_FIND_HEADER([$4], [$not_found_header])
94ac5f34
PD
334boost_save_CPPFLAGS=$CPPFLAGS
335CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
94ac5f34 336AC_CACHE_CHECK([for the Boost $1 library], [Boost_lib],
2187934a
RK
337 [_BOOST_FIND_LIBS($@)])
338case $Boost_lib in #(
e512f4f9
AN
339 (yes) _AC_MSG_LOG_CONFTEST
340 AC_DEFINE(AS_TR_CPP([HAVE_BOOST_$1]), [1], [Defined if the Boost $1 library is available])dnl
341 AC_SUBST(AS_TR_CPP([BOOST_$1_LDFLAGS]), [$Boost_lib_LDFLAGS])dnl
342 AC_SUBST(AS_TR_CPP([BOOST_$1_LDPATH]), [$Boost_lib_LDPATH])dnl
343 AC_SUBST([BOOST_LDPATH], [$Boost_lib_LDPATH])dnl
344 AC_SUBST(AS_TR_CPP([BOOST_$1_LIBS]), [$Boost_lib_LIBS])dnl
2187934a 345 ;;
0b59e24e 346 (no) _AC_MSG_LOG_CONFTEST
1b88fc23
PL
347 AS_IF([test x"$8" != "xno"], [
348 AC_MSG_ERROR([cannot find flags to link with the Boost $1 library (libboost-$1)])
349 ])
0b59e24e 350 ;;
2187934a 351esac
2187934a
RK
352CPPFLAGS=$boost_save_CPPFLAGS
353AS_VAR_POPDEF([Boost_lib])dnl
354AS_VAR_POPDEF([Boost_lib_LDFLAGS])dnl
355AS_VAR_POPDEF([Boost_lib_LDPATH])dnl
356AS_VAR_POPDEF([Boost_lib_LIBS])dnl
357AC_LANG_POP([C++])dnl
358fi
359])
360
361
362# BOOST_FIND_LIB([LIB-NAME],
363# [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST],
1b88fc23
PL
364# [CXX-PROLOGUE], [CXX-POST-INCLUDE-PROLOGUE],
365# [ERROR_ON_UNUSABLE])
2187934a
RK
366# --------------------------------------------------------------
367# Backward compatibility wrapper for BOOST_FIND_LIBS.
1b88fc23
PL
368# ERROR_ON_UNUSABLE can be set to "no" if the caller does not want their
369# configure to fail
2187934a
RK
370AC_DEFUN([BOOST_FIND_LIB],
371[BOOST_FIND_LIBS([$1], $@)])
372
373
374# _BOOST_FIND_LIBS([LIB-NAME], [CANDIDATE-LIB-NAMES],
375# [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST],
1b88fc23
PL
376# [CXX-PROLOGUE], [CXX-POST-INCLUDE-PROLOGUE],
377# [ERROR_ON_UNUSABLE])
2187934a
RK
378# --------------------------------------------------------------
379# Real implementation of BOOST_FIND_LIBS: rely on these local macros:
380# Boost_lib, Boost_lib_LDFLAGS, Boost_lib_LDPATH, Boost_lib_LIBS
381#
382# The algorithm is as follows: first look for a given library name
383# according to the user's PREFERRED-RT-OPT. For each library name, we
384# prefer to use the ones that carry the tag (toolset name). Each
385# library is searched through the various standard paths were Boost is
386# usually installed. If we can't find the standard variants, we try
387# to enforce -mt (for instance on MacOSX, libboost_thread.dylib
388# doesn't exist but there's -obviously- libboost_thread-mt.dylib).
1b88fc23
PL
389#
390# ERROR_ON_UNUSABLE can be set to "no" if the caller does not want their
391# configure to fail
2187934a
RK
392AC_DEFUN([_BOOST_FIND_LIBS],
393[Boost_lib=no
394 case "$3" in #(
395 (mt | mt-) boost_mt=-mt; boost_rtopt=;; #(
396 (mt* | mt-*) boost_mt=-mt; boost_rtopt=`expr "X$3" : 'Xmt-*\(.*\)'`;; #(
397 (*) boost_mt=; boost_rtopt=$3;;
94ac5f34
PD
398 esac
399 if test $enable_static_boost = yes; then
400 boost_rtopt="s$boost_rtopt"
401 fi
402 # Find the proper debug variant depending on what we've been asked to find.
403 case $boost_rtopt in #(
2187934a
RK
404 (*d*) boost_rt_d=$boost_rtopt;; #(
405 (*[[sgpn]]*) # Insert the `d' at the right place (in between `sg' and `pn')
94ac5f34 406 boost_rt_d=`echo "$boost_rtopt" | sed 's/\(s*g*\)\(p*n*\)/\1\2/'`;; #(
2187934a 407 (*) boost_rt_d='-d';;
94ac5f34
PD
408 esac
409 # If the PREFERRED-RT-OPT are not empty, prepend a `-'.
410 test -n "$boost_rtopt" && boost_rtopt="-$boost_rtopt"
411 $boost_guess_use_mt && boost_mt=-mt
412 # Look for the abs path the static archive.
413 # $libext is computed by Libtool but let's make sure it's non empty.
414 test -z "$libext" &&
415 AC_MSG_ERROR([the libext variable is empty, did you invoke Libtool?])
416 boost_save_ac_objext=$ac_objext
417 # Generate the test file.
0b59e24e
PL
418 AC_LANG_CONFTEST([AC_LANG_PROGRAM([$7
419#include <$4>
2187934a 420$6], [$5])])
94ac5f34
PD
421dnl Optimization hacks: compiling C++ is slow, especially with Boost. What
422dnl we're trying to do here is guess the right combination of link flags
423dnl (LIBS / LDFLAGS) to use a given library. This can take several
424dnl iterations before it succeeds and is thus *very* slow. So what we do
425dnl instead is that we compile the code first (and thus get an object file,
426dnl typically conftest.o). Then we try various combinations of link flags
427dnl until we succeed to link conftest.o in an executable. The problem is
428dnl that the various TRY_LINK / COMPILE_IFELSE macros of Autoconf always
429dnl remove all the temporary files including conftest.o. So the trick here
430dnl is to temporarily change the value of ac_objext so that conftest.o is
431dnl preserved accross tests. This is obviously fragile and I will burn in
432dnl hell for not respecting Autoconf's documented interfaces, but in the
433dnl mean time, it optimizes the macro by a factor of 5 to 30.
434dnl Another small optimization: the first argument of AC_COMPILE_IFELSE left
435dnl empty because the test file is generated only once above (before we
436dnl start the for loops).
437 AC_COMPILE_IFELSE([],
438 [ac_objext=do_not_rm_me_plz],
1b88fc23
PL
439 [AS_IF([test x"$8" != x"no"], [
440 AC_MSG_ERROR([cannot compile a test that uses Boost $1])
441 ])
442 ])
94ac5f34
PD
443 ac_objext=$boost_save_ac_objext
444 boost_failed_libs=
2187934a
RK
445# Don't bother to ident the following nested for loops, only the 2
446# innermost ones matter.
447for boost_lib_ in $2; do
94ac5f34
PD
448for boost_tag_ in -$boost_cv_lib_tag ''; do
449for boost_ver_ in -$boost_cv_lib_version ''; do
450for boost_mt_ in $boost_mt -mt ''; do
451for boost_rtopt_ in $boost_rtopt '' -d; do
0b59e24e
PL
452 for boost_full_suffix in \
453 $boost_last_suffix \
454 x$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_ \
455 x$boost_tag_$boost_rtopt_$boost_ver_ \
456 x$boost_tag_$boost_mt_$boost_ver_ \
457 x$boost_tag_$boost_ver_
94ac5f34 458 do
0b59e24e
PL
459 boost_real_suffix=`echo "$boost_full_suffix" | sed 's/^x//'`
460 boost_lib="boost_$boost_lib_$boost_real_suffix"
94ac5f34
PD
461 # Avoid testing twice the same lib
462 case $boost_failed_libs in #(
2187934a 463 (*@$boost_lib@*) continue;;
94ac5f34
PD
464 esac
465 # If with_boost is empty, we'll search in /lib first, which is not quite
466 # right so instead we'll try to a location based on where the headers are.
467 boost_tmp_lib=$with_boost
468 test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include}
469 for boost_ldpath in "$boost_tmp_lib/lib" '' \
470 /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \
471 "$with_boost" C:/Boost/lib /lib*
472 do
2187934a
RK
473 # Don't waste time with directories that don't exist.
474 if test x"$boost_ldpath" != x && test ! -e "$boost_ldpath"; then
475 continue
476 fi
94ac5f34
PD
477 boost_save_LDFLAGS=$LDFLAGS
478 # Are we looking for a static library?
479 case $boost_ldpath:$boost_rtopt_ in #(
2187934a 480 (*?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt)
94ac5f34
PD
481 Boost_lib_LIBS="$boost_ldpath/lib$boost_lib.$libext"
482 test -e "$Boost_lib_LIBS" || continue;; #(
2187934a 483 (*) # No: use -lboost_foo to find the shared library.
94ac5f34
PD
484 Boost_lib_LIBS="-l$boost_lib";;
485 esac
486 boost_save_LIBS=$LIBS
487 LIBS="$Boost_lib_LIBS $LIBS"
488 test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath"
489dnl First argument of AC_LINK_IFELSE left empty because the test file is
490dnl generated only once above (before we start the for loops).
491 _BOOST_AC_LINK_IFELSE([],
492 [Boost_lib=yes], [Boost_lib=no])
493 ac_objext=$boost_save_ac_objext
494 LDFLAGS=$boost_save_LDFLAGS
495 LIBS=$boost_save_LIBS
496 if test x"$Boost_lib" = xyes; then
2187934a
RK
497 # Check or used cached result of whether or not using -R or
498 # -rpath makes sense. Some implementations of ld, such as for
499 # Mac OSX, require -rpath but -R is the flag known to work on
500 # other systems. https://github.com/tsuna/boost.m4/issues/19
94ac5f34 501 AC_CACHE_VAL([boost_cv_rpath_link_ldflag],
2187934a
RK
502 [case $boost_ldpath in
503 '') # Nothing to do.
504 boost_cv_rpath_link_ldflag=
505 boost_rpath_link_ldflag_found=yes;;
506 *)
507 for boost_cv_rpath_link_ldflag in -Wl,-R, -Wl,-rpath,; do
508 LDFLAGS="$boost_save_LDFLAGS -L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath"
0b59e24e 509 LIBS="$Boost_lib_LIBS $boost_save_LIBS"
2187934a
RK
510 _BOOST_AC_LINK_IFELSE([],
511 [boost_rpath_link_ldflag_found=yes
512 break],
513 [boost_rpath_link_ldflag_found=no])
514 done
515 ;;
516 esac
94ac5f34
PD
517 AS_IF([test "x$boost_rpath_link_ldflag_found" != "xyes"],
518 [AC_MSG_ERROR([Unable to determine whether to use -R or -rpath])])
519 LDFLAGS=$boost_save_LDFLAGS
520 LIBS=$boost_save_LIBS
521 ])
2187934a
RK
522 test x"$boost_ldpath" != x &&
523 Boost_lib_LDFLAGS="-L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath"
94ac5f34 524 Boost_lib_LDPATH="$boost_ldpath"
0b59e24e 525 boost_last_suffix="$boost_full_suffix"
2187934a 526 break 7
94ac5f34
PD
527 else
528 boost_failed_libs="$boost_failed_libs@$boost_lib@"
529 fi
530 done
531 done
532done
533done
534done
535done
2187934a 536done # boost_lib_
94ac5f34
PD
537rm -f conftest.$ac_objext
538])
2187934a 539
94ac5f34
PD
540
541
542# --------------------------------------- #
543# Checks for the various Boost libraries. #
544# --------------------------------------- #
545
546# List of boost libraries: http://www.boost.org/libs/libraries.htm
547# The page http://beta.boost.org/doc/libs is useful: it gives the first release
548# version of each library (among other things).
549
550# BOOST_DEFUN(LIBRARY, CODE)
551# --------------------------
552# Define BOOST_<LIBRARY-UPPERCASE> as a macro that runs CODE.
553#
554# Use indir to avoid the warning on underquoted macro name given to AC_DEFUN.
555m4_define([BOOST_DEFUN],
556[m4_indir([AC_DEFUN],
557 m4_toupper([BOOST_$1]),
558[m4_pushdef([BOOST_Library], [$1])dnl
559$2
560m4_popdef([BOOST_Library])dnl
561])
562])
563
0b59e24e
PL
564
565# BOOST_ANY()
566# ------------
567# Look for Boost.Any
568BOOST_DEFUN([Any],
569[BOOST_FIND_HEADER([boost/any.hpp])])
570
571
94ac5f34
PD
572# BOOST_ARRAY()
573# -------------
574# Look for Boost.Array
575BOOST_DEFUN([Array],
576[BOOST_FIND_HEADER([boost/array.hpp])])
577
578
579# BOOST_ASIO()
580# ------------
581# Look for Boost.Asio (new in Boost 1.35).
582BOOST_DEFUN([Asio],
583[AC_REQUIRE([BOOST_SYSTEM])dnl
584BOOST_FIND_HEADER([boost/asio.hpp])])
585
0b59e24e
PL
586# BOOST_BIMAP()
587# ------------
588# Look for Boost.Bimap
589BOOST_DEFUN([Bimap],
590[BOOST_FIND_HEADER([boost/bimap.hpp])])
591
94ac5f34 592
a0e4992b
KM
593# BOOST_ASSIGN()
594# -------------
595# Look for Boost.Assign
596BOOST_DEFUN([Assign],
597[BOOST_FIND_HEADER([boost/assign.hpp])])
598
599
1b88fc23 600# BOOST_ATOMIC([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
0b59e24e
PL
601# -------------------------------
602# Look for Boost.Atomic. For the documentation of PREFERRED-RT-OPT, see the
603# documentation of BOOST_FIND_LIB above.
604BOOST_DEFUN([Atomic],
605[BOOST_FIND_LIB([atomic], [$1],
606 [boost/atomic.hpp],
607 [boost::atomic<int> a;],
608 [ ],
609 [#ifdef HAVE_UNISTD_H
610#include <unistd.h>
611#endif
612#ifdef HAVE_STDINT_H
613#include <stdint.h>
1b88fc23 614#endif], [$2])
0b59e24e
PL
615])# BOOST_ATOMIC
616
617
94ac5f34
PD
618# BOOST_BIND()
619# ------------
2187934a 620# Look for Boost.Bind.
94ac5f34
PD
621BOOST_DEFUN([Bind],
622[BOOST_FIND_HEADER([boost/bind.hpp])])
623
624
0b59e24e
PL
625# BOOST_CAST()
626# ------------
627# Look for Boost.Cast
628BOOST_DEFUN([Cast],
629[BOOST_FIND_HEADER([boost/cast.hpp])])
630
631
1b88fc23 632# BOOST_CHRONO([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
2187934a
RK
633# --------------
634# Look for Boost.Chrono.
94ac5f34
PD
635BOOST_DEFUN([Chrono],
636[# Do we have to check for Boost.System? This link-time dependency was
637# added as of 1.35.0. If we have a version <1.35, we must not attempt to
638# find Boost.System as it didn't exist by then.
639if test $boost_major_version -ge 135; then
1b88fc23 640 BOOST_SYSTEM([$1], [$2])
94ac5f34
PD
641fi # end of the Boost.System check.
642boost_filesystem_save_LIBS=$LIBS
643boost_filesystem_save_LDFLAGS=$LDFLAGS
644m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
645LIBS="$LIBS $BOOST_SYSTEM_LIBS"
646LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
647BOOST_FIND_LIB([chrono], [$1],
648 [boost/chrono.hpp],
1b88fc23 649 [boost::chrono::thread_clock d;], [], [], [$2])
94ac5f34 650if test $enable_static_boost = yes && test $boost_major_version -ge 135; then
b0d6e9e6 651 BOOST_CHRONO_LIBS="$BOOST_CHRONO_LIBS $BOOST_SYSTEM_LIBS"
94ac5f34
PD
652fi
653LIBS=$boost_filesystem_save_LIBS
654LDFLAGS=$boost_filesystem_save_LDFLAGS
94ac5f34
PD
655])# BOOST_CHRONO
656
657
1b88fc23 658# BOOST_CONTEXT([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
2187934a
RK
659# -----------------------------------
660# Look for Boost.Context. For the documentation of PREFERRED-RT-OPT, see the
afdd465f
PL
661# documentation of BOOST_FIND_LIB above.
662#
663# * This library was introduced in Boost 1.51.0
664# * The signatures of make_fcontext() and jump_fcontext were changed in 1.56.0
665# * A dependency on boost_thread appears in 1.57.0
15875dd8 666# * The implementation details were moved to boost::context::detail in 1.61.0
c54133a4
PL
667# * 1.61 also introduces execution_context_v2, which is the "lowest common
668# denominator" for boost::context presence since then.
2187934a 669BOOST_DEFUN([Context],
afdd465f
PL
670[boost_context_save_LIBS=$LIBS
671 boost_context_save_LDFLAGS=$LDFLAGS
672if test $boost_major_version -ge 157; then
1b88fc23 673 BOOST_THREAD([$1], [$2])
afdd465f
PL
674 m4_pattern_allow([^BOOST_THREAD_(LIBS|LDFLAGS)$])dnl
675 LIBS="$LIBS $BOOST_THREAD_LIBS"
676 LDFLAGS="$LDFLAGS $BOOST_THREAD_LDFLAGS"
677fi
15875dd8
PL
678
679if test $boost_major_version -ge 161; then
680BOOST_FIND_LIB([context], [$1],
c54133a4 681 [boost/context/execution_context_v2.hpp], [[
15875dd8 682namespace ctx=boost::context;
c54133a4
PL
683int res=0;
684int n=35;
685ctx::execution_context<int> source(
686 [n, &res](ctx::execution_context<int> sink, int) mutable {
687 int a=0;
15875dd8 688 int b=1;
c54133a4
PL
689 while(n-->0){
690 auto result=sink(a);
691 sink=std::move(std::get<0>(result));
692 auto next=a+b;
15875dd8
PL
693 a=b;
694 b=next;
695 }
c54133a4 696 return sink;
15875dd8 697 });
c54133a4
PL
698for(int i=0;i<10;++i){
699 auto result=source(i);
700 source=std::move(std::get<0>(result));
701 res = std::get<1>(result);
15875dd8 702}
c54133a4 703return res == 34;
1b88fc23 704]], [], [], [$2])
15875dd8
PL
705
706else
707
afdd465f 708BOOST_FIND_LIB([context], [$1],
0b59e24e 709 [boost/context/fcontext.hpp],[[
afdd465f 710
2187934a
RK
711// creates a stack
712void * stack_pointer = new void*[4096];
713std::size_t const size = sizeof(void*[4096]);
714
afdd465f
PL
715#if BOOST_VERSION <= 105100
716ctx::make_fcontext(&fc, f);
717return ctx::jump_fcontext(&fcm, &fc, 3) == 6;
718
719#else
720
2187934a 721fc = ctx::make_fcontext(stack_pointer, size, f);
afdd465f
PL
722return ctx::jump_fcontext(&fcm, fc, 3) == 6;
723
724#endif
725
726
727]],[dnl
728
729#include <boost/version.hpp>
730#if BOOST_VERSION <= 105100
731
732namespace ctx = boost::ctx;
733
734static ctx::fcontext_t fcm, fc;
735
736static void f(intptr_t i) {
737 ctx::jump_fcontext(&fc, &fcm, i * 2);
738}
739
740#elif BOOST_VERSION <= 105500
741
2187934a 742namespace ctx = boost::context;
afdd465f 743
2187934a
RK
744// context
745static ctx::fcontext_t fcm, *fc;
afdd465f 746
2187934a
RK
747// context-function
748static void f(intptr_t i) {
749 ctx::jump_fcontext(fc, &fcm, i * 2);
afdd465f
PL
750}
751
752#else
753
754namespace ctx = boost::context;
755
756// context
757static ctx::fcontext_t fcm, fc;
758
759// context-function
760static void f(intptr_t i) {
761 ctx::jump_fcontext(&fc, fcm, i * 2);
762}
763#endif
1b88fc23 764], [], [], [$2])
15875dd8
PL
765
766fi
767
afdd465f
PL
768LIBS=$boost_context_save_LIBS
769LDFLAGS=$boost_context_save_LDFLAGS
2187934a
RK
770])# BOOST_CONTEXT
771
772
94ac5f34
PD
773# BOOST_CONVERSION()
774# ------------------
775# Look for Boost.Conversion (cast / lexical_cast)
776BOOST_DEFUN([Conversion],
777[BOOST_FIND_HEADER([boost/cast.hpp])
778BOOST_FIND_HEADER([boost/lexical_cast.hpp])
779])# BOOST_CONVERSION
780
781
1b88fc23 782# BOOST_COROUTINE([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
2187934a
RK
783# -----------------------------------
784# Look for Boost.Coroutine. For the documentation of PREFERRED-RT-OPT, see the
785# documentation of BOOST_FIND_LIB above. This library was introduced in Boost
786# 1.53.0
787BOOST_DEFUN([Coroutine],
788[
789boost_coroutine_save_LIBS=$LIBS
790boost_coroutine_save_LDFLAGS=$LDFLAGS
791# Link-time dependency from coroutine to context
1b88fc23 792BOOST_CONTEXT([$1], [$2])
2187934a
RK
793# Starting from Boost 1.55 a dependency on Boost.System is added
794if test $boost_major_version -ge 155; then
1b88fc23 795 BOOST_SYSTEM([$1], [$2])
2187934a
RK
796fi
797m4_pattern_allow([^BOOST_(CONTEXT|SYSTEM)_(LIBS|LDFLAGS)])
798LIBS="$LIBS $BOOST_CONTEXT_LIBS $BOOST_SYSTEM_LIBS"
799LDFLAGS="$LDFLAGS $BOOST_CONTEXT_LDFLAGS"
800
afdd465f
PL
801# in 1.53 coroutine was a header only library
802if test $boost_major_version -eq 153; then
1b88fc23
PL
803 AS_IF([test x"$2" = "xno"], [not_found_header='true'])
804 BOOST_FIND_HEADER([boost/coroutine/coroutine.hpp], [$not_found_header])
afdd465f
PL
805else
806 BOOST_FIND_LIB([coroutine], [$1],
807 [boost/coroutine/coroutine.hpp],
808 [
809 #include <boost/version.hpp>
810 #if BOOST_VERSION <= 105500
811 boost::coroutines::coroutine<int(int)> coro; coro.get();
812 #else
813 boost::coroutines::asymmetric_coroutine<int>::pull_type coro; coro.get();
814 #endif
1b88fc23 815 ], [], [], [$2])
afdd465f 816fi
2187934a
RK
817# Link-time dependency from coroutine to context, existed only in 1.53, in 1.54
818# coroutine doesn't use context from its headers but from its library.
819if test $boost_major_version -eq 153 || test $enable_static_boost = yes && test $boost_major_version -ge 154; then
820 BOOST_COROUTINE_LIBS="$BOOST_COROUTINE_LIBS $BOOST_CONTEXT_LIBS"
821 BOOST_COROUTINE_LDFLAGS="$BOOST_COROUTINE_LDFLAGS $BOOST_CONTEXT_LDFLAGS"
822fi
823if test $enable_static_boost = yes && test $boost_major_version -ge 155; then
824 BOOST_COROUTINE_LIBS="$BOOST_COROUTINE_LIBS $BOOST_SYSTEM_LIBS"
825 BOOST_COROUTINE_LDFLAGS="$BOOST_COROUTINE_LDFLAGS $BOOST_SYSTEM_LDFLAGS"
826fi
827LIBS=$boost_coroutine_save_LIBS
828LDFLAGS=$boost_coroutine_save_LDFLAGS
829])# BOOST_COROUTINE
830
831
94ac5f34
PD
832# BOOST_CRC()
833# -----------
834# Look for Boost.CRC
835BOOST_DEFUN([CRC],
836[BOOST_FIND_HEADER([boost/crc.hpp])
837])# BOOST_CRC
838
839
1b88fc23 840# BOOST_DATE_TIME([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
94ac5f34
PD
841# -----------------------------------
842# Look for Boost.Date_Time. For the documentation of PREFERRED-RT-OPT, see the
843# documentation of BOOST_FIND_LIB above.
844BOOST_DEFUN([Date_Time],
845[BOOST_FIND_LIB([date_time], [$1],
846 [boost/date_time/posix_time/posix_time.hpp],
1b88fc23 847 [boost::posix_time::ptime t;], [], [], [$2])
94ac5f34
PD
848])# BOOST_DATE_TIME
849
850
0b59e24e
PL
851# BOOST_EXCEPTION()
852# ------------
853# Look for Boost.Exception
854BOOST_DEFUN([Exception],
855[BOOST_FIND_HEADER([boost/exception/all.hpp])])
856
857
1b88fc23 858# BOOST_FILESYSTEM([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
94ac5f34
PD
859# ------------------------------------
860# Look for Boost.Filesystem. For the documentation of PREFERRED-RT-OPT, see
861# the documentation of BOOST_FIND_LIB above.
862# Do not check for boost/filesystem.hpp because this file was introduced in
863# 1.34.
864BOOST_DEFUN([Filesystem],
865[# Do we have to check for Boost.System? This link-time dependency was
866# added as of 1.35.0. If we have a version <1.35, we must not attempt to
867# find Boost.System as it didn't exist by then.
868if test $boost_major_version -ge 135; then
1b88fc23 869 BOOST_SYSTEM([$1], [$2])
94ac5f34
PD
870fi # end of the Boost.System check.
871boost_filesystem_save_LIBS=$LIBS
872boost_filesystem_save_LDFLAGS=$LDFLAGS
873m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
874LIBS="$LIBS $BOOST_SYSTEM_LIBS"
875LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
876BOOST_FIND_LIB([filesystem], [$1],
1b88fc23
PL
877 [boost/filesystem/path.hpp], [boost::filesystem::path p;],
878 [], [], [$2])
94ac5f34 879if test $enable_static_boost = yes && test $boost_major_version -ge 135; then
2187934a 880 BOOST_FILESYSTEM_LIBS="$BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS"
94ac5f34
PD
881fi
882LIBS=$boost_filesystem_save_LIBS
883LDFLAGS=$boost_filesystem_save_LDFLAGS
884])# BOOST_FILESYSTEM
885
886
2187934a
RK
887# BOOST_FLYWEIGHT()
888# -----------------
889# Look for Boost.Flyweight.
890BOOST_DEFUN([Flyweight],
891[dnl There's a hidden dependency on pthreads.
892AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl
893BOOST_FIND_HEADER([boost/flyweight.hpp])
894AC_SUBST([BOOST_FLYWEIGHT_LIBS], [$boost_cv_pthread_flag])
895])
896
897
94ac5f34
PD
898# BOOST_FOREACH()
899# ---------------
2187934a 900# Look for Boost.Foreach.
94ac5f34
PD
901BOOST_DEFUN([Foreach],
902[BOOST_FIND_HEADER([boost/foreach.hpp])])
903
904
905# BOOST_FORMAT()
906# --------------
2187934a 907# Look for Boost.Format.
94ac5f34
PD
908# Note: we can't check for boost/format/format_fwd.hpp because the header isn't
909# standalone. It can't be compiled because it triggers the following error:
910# boost/format/detail/config_macros.hpp:88: error: 'locale' in namespace 'std'
911# does not name a type
912BOOST_DEFUN([Format],
913[BOOST_FIND_HEADER([boost/format.hpp])])
914
915
916# BOOST_FUNCTION()
917# ----------------
918# Look for Boost.Function
919BOOST_DEFUN([Function],
920[BOOST_FIND_HEADER([boost/function.hpp])])
921
922
0b59e24e
PL
923# BOOST_FUSION()
924# -----------------
925# Look for Boost.Fusion
926BOOST_DEFUN([Fusion],
927[BOOST_FIND_HEADER([boost/fusion/sequence.hpp])])
928
929
94ac5f34
PD
930# BOOST_GEOMETRY()
931# ----------------
932# Look for Boost.Geometry (new since 1.47.0).
933BOOST_DEFUN([Geometry],
934[BOOST_FIND_HEADER([boost/geometry.hpp])
935])# BOOST_GEOMETRY
936
937
1b88fc23 938# BOOST_GRAPH([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
94ac5f34
PD
939# -------------------------------
940# Look for Boost.Graphs. For the documentation of PREFERRED-RT-OPT, see the
941# documentation of BOOST_FIND_LIB above.
942BOOST_DEFUN([Graph],
afdd465f
PL
943[boost_graph_save_LIBS=$LIBS
944boost_graph_save_LDFLAGS=$LDFLAGS
945# Link-time dependency from graph to regex was added as of 1.40.0.
946if test $boost_major_version -ge 140; then
1b88fc23 947 BOOST_REGEX([$1], [$2])
afdd465f
PL
948 m4_pattern_allow([^BOOST_REGEX_(LIBS|LDFLAGS)$])dnl
949 LIBS="$LIBS $BOOST_REGEX_LIBS"
950 LDFLAGS="$LDFLAGS $BOOST_REGEX_LDFLAGS"
951fi
952BOOST_FIND_LIB([graph], [$1],
1b88fc23
PL
953 [boost/graph/adjacency_list.hpp], [boost::adjacency_list<> g;],
954 [], [], [$2])
afdd465f
PL
955LIBS=$boost_graph_save_LIBS
956LDFLAGS=$boost_graph_save_LDFLAGS
94ac5f34
PD
957])# BOOST_GRAPH
958
959
0b59e24e
PL
960# BOOST_HASH()
961# ------------
962# Look for Boost.Functional/Hash
963BOOST_DEFUN([Hash],
964[BOOST_FIND_HEADER([boost/functional/hash.hpp])])
965
966
1b88fc23 967# BOOST_IOSTREAMS([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
94ac5f34
PD
968# -----------------------------------
969# Look for Boost.IOStreams. For the documentation of PREFERRED-RT-OPT, see the
970# documentation of BOOST_FIND_LIB above.
971BOOST_DEFUN([IOStreams],
972[BOOST_FIND_LIB([iostreams], [$1],
973 [boost/iostreams/device/file_descriptor.hpp],
1b88fc23
PL
974 [boost::iostreams::file_descriptor fd; fd.close();],
975 [], [], [$2])
94ac5f34
PD
976])# BOOST_IOSTREAMS
977
978
0b59e24e 979# BOOST_ITERATOR()
94ac5f34 980# ------------
0b59e24e
PL
981# Look for Boost.Iterator
982BOOST_DEFUN([Iterator],
983[BOOST_FIND_HEADER([boost/iterator/iterator_adaptor.hpp])])
94ac5f34
PD
984
985
986# BOOST_LAMBDA()
987# --------------
988# Look for Boost.Lambda
989BOOST_DEFUN([Lambda],
990[BOOST_FIND_HEADER([boost/lambda/lambda.hpp])])
991
992
1b88fc23 993# BOOST_LOCALE([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
2187934a
RK
994# --------------
995# Look for Boost.Locale
996BOOST_DEFUN([Locale],
afdd465f
PL
997[
998boost_locale_save_LIBS=$LIBS
999boost_locale_save_LDFLAGS=$LDFLAGS
1000# require SYSTEM for boost-1.50.0 and up
1001if test $boost_major_version -ge 150; then
1b88fc23 1002 BOOST_SYSTEM([$1], [$2])
afdd465f
PL
1003 m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
1004 LIBS="$LIBS $BOOST_SYSTEM_LIBS"
1005 LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
1006fi # end of the Boost.System check.
1007BOOST_FIND_LIB([locale], [$1],
2187934a 1008 [boost/locale.hpp],
1b88fc23 1009 [[boost::locale::generator gen; std::locale::global(gen(""));]], [], [], [$2])
afdd465f
PL
1010LIBS=$boost_locale_save_LIBS
1011LDFLAGS=$boost_locale_save_LDFLAGS
2187934a
RK
1012])# BOOST_LOCALE
1013
1b88fc23 1014# BOOST_LOG([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
94ac5f34 1015# -----------------------------
2187934a 1016# Look for Boost.Log. For the documentation of PREFERRED-RT-OPT, see the
94ac5f34
PD
1017# documentation of BOOST_FIND_LIB above.
1018BOOST_DEFUN([Log],
afdd465f
PL
1019[boost_log_save_LIBS=$LIBS
1020boost_log_save_LDFLAGS=$LDFLAGS
1b88fc23
PL
1021BOOST_SYSTEM([$1], [$2])
1022BOOST_FILESYSTEM([$1], [$2])
1023BOOST_DATE_TIME([$1], [$2])
afdd465f
PL
1024m4_pattern_allow([^BOOST_(SYSTEM|FILESYSTEM|DATE_TIME)_(LIBS|LDFLAGS)$])dnl
1025LIBS="$LIBS $BOOST_DATE_TIME_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS"
1026LDFLAGS="$LDFLAGS $BOOST_DATE_TIME_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS $BOOST_SYSTEM_LDFLAGS"
1027BOOST_FIND_LIB([log], [$1],
94ac5f34 1028 [boost/log/core/core.hpp],
1b88fc23 1029 [boost::log::attribute a; a.get_value();], [], [], [$2])
afdd465f
PL
1030LIBS=$boost_log_save_LIBS
1031LDFLAGS=$boost_log_save_LDFLAGS
94ac5f34
PD
1032])# BOOST_LOG
1033
1034
1b88fc23 1035# BOOST_LOG_SETUP([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
94ac5f34 1036# -----------------------------------
2187934a 1037# Look for Boost.Log. For the documentation of PREFERRED-RT-OPT, see the
94ac5f34
PD
1038# documentation of BOOST_FIND_LIB above.
1039BOOST_DEFUN([Log_Setup],
afdd465f
PL
1040[boost_log_setup_save_LIBS=$LIBS
1041boost_log_setup_save_LDFLAGS=$LDFLAGS
1042BOOST_LOG([$1])
1043m4_pattern_allow([^BOOST_LOG_(LIBS|LDFLAGS)$])dnl
1044LIBS="$LIBS $BOOST_LOG_LIBS"
1045LDFLAGS="$LDFLAGS $BOOST_LOG_LDFLAGS"
94ac5f34 1046BOOST_FIND_LIB([log_setup], [$1],
2187934a 1047 [boost/log/utility/setup/from_settings.hpp],
1b88fc23 1048 [boost::log::basic_settings<char> bs; bs.empty();], [], [], [$2])
afdd465f
PL
1049LIBS=$boost_log_setup_save_LIBS
1050LDFLAGS=$boost_log_setup_save_LDFLAGS
94ac5f34
PD
1051])# BOOST_LOG_SETUP
1052
1053
1054# BOOST_MATH()
1055# ------------
1056# Look for Boost.Math
1057# TODO: This library isn't header-only but it comes in multiple different
1058# flavors that don't play well with BOOST_FIND_LIB (e.g, libboost_math_c99,
1059# libboost_math_c99f, libboost_math_c99l, libboost_math_tr1,
1060# libboost_math_tr1f, libboost_math_tr1l). This macro must be fixed to do the
1061# right thing anyway.
1062BOOST_DEFUN([Math],
1063[BOOST_FIND_HEADER([boost/math/special_functions.hpp])])
1064
1065
1b88fc23 1066# BOOST_MPI([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
2187934a
RK
1067# -------------------------------
1068# Look for Boost MPI. For the documentation of PREFERRED-RT-OPT, see the
1069# documentation of BOOST_FIND_LIB above. Uses MPICXX variable if it is
1070# set, otherwise tries CXX
1071#
1072BOOST_DEFUN([MPI],
1073[boost_save_CXX=${CXX}
1074boost_save_CXXCPP=${CXXCPP}
1075if test x"${MPICXX}" != x; then
1076 CXX=${MPICXX}
1077 CXXCPP="${MPICXX} -E"
1078fi
1079BOOST_FIND_LIB([mpi], [$1],
1080 [boost/mpi.hpp],
1081 [int argc = 0;
1082 char **argv = 0;
1b88fc23
PL
1083 boost::mpi::environment env(argc,argv);],
1084 [], [], [$2])
2187934a
RK
1085CXX=${boost_save_CXX}
1086CXXCPP=${boost_save_CXXCPP}
1087])# BOOST_MPI
1088
1089
0b59e24e
PL
1090# BOOST_MPL()
1091# ------------------
1092# Look for Boost.MPL
1093BOOST_DEFUN([MPL],
1094[BOOST_FIND_HEADER([boost/mpl/for_each.hpp])])
1095
1096
94ac5f34
PD
1097# BOOST_MULTIARRAY()
1098# ------------------
1099# Look for Boost.MultiArray
1100BOOST_DEFUN([MultiArray],
1101[BOOST_FIND_HEADER([boost/multi_array.hpp])])
1102
1103
0b59e24e
PL
1104# BOOST_MULTIINDEXCCONTAINER()
1105# ------------------
1106# Look for Boost.MultiIndexContainer
1107BOOST_DEFUN([MultiIndexContainer],
1108[BOOST_FIND_HEADER([boost/multi_index_container.hpp])])
1109
1110
2187934a
RK
1111# BOOST_NUMERIC_UBLAS()
1112# --------------------------
1113# Look for Boost.NumericUblas (Basic Linear Algebra)
1114BOOST_DEFUN([Numeric_Ublas],
1115[BOOST_FIND_HEADER([boost/numeric/ublas/vector.hpp])
1116])# BOOST_NUMERIC_UBLAS
1117
1118
94ac5f34
PD
1119# BOOST_NUMERIC_CONVERSION()
1120# --------------------------
1121# Look for Boost.NumericConversion (policy-based numeric conversion)
1122BOOST_DEFUN([Numeric_Conversion],
1123[BOOST_FIND_HEADER([boost/numeric/conversion/converter.hpp])
1124])# BOOST_NUMERIC_CONVERSION
1125
1126
1127# BOOST_OPTIONAL()
1128# ----------------
1129# Look for Boost.Optional
1130BOOST_DEFUN([Optional],
1131[BOOST_FIND_HEADER([boost/optional.hpp])])
1132
1133
1134# BOOST_PREPROCESSOR()
1135# --------------------
1136# Look for Boost.Preprocessor
1137BOOST_DEFUN([Preprocessor],
1138[BOOST_FIND_HEADER([boost/preprocessor/repeat.hpp])])
1139
1140
1b88fc23 1141# BOOST_PROPERTY_TREE([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
0b59e24e
PL
1142# -----------------------------------------
1143# Look for Boost.Property_Tree. For the documentation of PREFERRED-RT-OPT,
1144# see the documentation of BOOST_FIND_LIB above.
1145BOOST_DEFUN([Property_Tree],
1146[BOOST_FIND_LIB([property_tree], [$1],
1147 [boost/property_tree/ptree.hpp],
1b88fc23
PL
1148 [boost::property_tree::ptree pt; boost::property_tree::read_xml d("test", pt);],
1149 [], [], [$2])
0b59e24e
PL
1150])# BOOST_PROPERTY_TREE
1151
1152
1153# BOOST_RANDOM()
1154# --------------------
1155# Look for Boost.Random
1156BOOST_DEFUN([Random],
1157[BOOST_FIND_HEADER([boost/random/random_number_generator.hpp])])
1158
1159
2187934a
RK
1160# BOOST_RANGE()
1161# --------------------
1162# Look for Boost.Range
1163BOOST_DEFUN([Range],
1164[BOOST_FIND_HEADER([boost/range/adaptors.hpp])])
1165
94ac5f34
PD
1166# BOOST_UNORDERED()
1167# -----------------
1168# Look for Boost.Unordered
1169BOOST_DEFUN([Unordered],
1170[BOOST_FIND_HEADER([boost/unordered_map.hpp])])
1171
1172
1173# BOOST_UUID()
1174# ------------
1175# Look for Boost.Uuid
1176BOOST_DEFUN([Uuid],
1177[BOOST_FIND_HEADER([boost/uuid/uuid.hpp])])
1178
1179
1b88fc23 1180# BOOST_PROGRAM_OPTIONS([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
94ac5f34
PD
1181# -----------------------------------------
1182# Look for Boost.Program_options. For the documentation of PREFERRED-RT-OPT,
1183# see the documentation of BOOST_FIND_LIB above.
1184BOOST_DEFUN([Program_Options],
1185[BOOST_FIND_LIB([program_options], [$1],
1186 [boost/program_options.hpp],
1b88fc23
PL
1187 [boost::program_options::options_description d("test");],
1188 [], [], [$2])
94ac5f34
PD
1189])# BOOST_PROGRAM_OPTIONS
1190
1191
1192
1193# _BOOST_PYTHON_CONFIG(VARIABLE, FLAG)
1194# ------------------------------------
1195# Save VARIABLE, and define it via `python-config --FLAG`.
1196# Substitute BOOST_PYTHON_VARIABLE.
1197m4_define([_BOOST_PYTHON_CONFIG],
1198[AC_SUBST([BOOST_PYTHON_$1],
1199 [`python-config --$2 2>/dev/null`])dnl
1200boost_python_save_$1=$$1
1201$1="$$1 $BOOST_PYTHON_$1"])
1202
1203
1b88fc23 1204# BOOST_PYTHON([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
94ac5f34
PD
1205# --------------------------------
1206# Look for Boost.Python. For the documentation of PREFERRED-RT-OPT,
1207# see the documentation of BOOST_FIND_LIB above.
1208BOOST_DEFUN([Python],
1209[_BOOST_PYTHON_CONFIG([CPPFLAGS], [includes])
1210_BOOST_PYTHON_CONFIG([LDFLAGS], [ldflags])
1211_BOOST_PYTHON_CONFIG([LIBS], [libs])
1212m4_pattern_allow([^BOOST_PYTHON_MODULE$])dnl
2187934a
RK
1213BOOST_FIND_LIBS([python], [python python3], [$1],
1214 [boost/python.hpp],
1b88fc23 1215 [], [BOOST_PYTHON_MODULE(empty) {}], [], [$2])
94ac5f34
PD
1216CPPFLAGS=$boost_python_save_CPPFLAGS
1217LDFLAGS=$boost_python_save_LDFLAGS
1218LIBS=$boost_python_save_LIBS
1219])# BOOST_PYTHON
1220
1221
1222# BOOST_REF()
1223# -----------
1224# Look for Boost.Ref
1225BOOST_DEFUN([Ref],
1226[BOOST_FIND_HEADER([boost/ref.hpp])])
1227
1228
1b88fc23 1229# BOOST_REGEX([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
94ac5f34
PD
1230# -------------------------------
1231# Look for Boost.Regex. For the documentation of PREFERRED-RT-OPT, see the
1232# documentation of BOOST_FIND_LIB above.
1233BOOST_DEFUN([Regex],
1234[BOOST_FIND_LIB([regex], [$1],
1235 [boost/regex.hpp],
1b88fc23
PL
1236 [boost::regex exp("*"); boost::regex_match("foo", exp);],
1237 [], [], [$2])
94ac5f34
PD
1238])# BOOST_REGEX
1239
1240
d7a2a52f
PL
1241# BOOST_SCOPE_EXIT()
1242# ------------
1243# Look for Boost.ScopeExit.
1244BOOST_DEFUN([SCOPE_EXIT],
1245[BOOST_FIND_HEADER([boost/scope_exit.hpp])])
1246
1247
1b88fc23 1248# BOOST_SERIALIZATION([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
94ac5f34
PD
1249# ---------------------------------------
1250# Look for Boost.Serialization. For the documentation of PREFERRED-RT-OPT, see
1251# the documentation of BOOST_FIND_LIB above.
1252BOOST_DEFUN([Serialization],
1253[BOOST_FIND_LIB([serialization], [$1],
1254 [boost/archive/text_oarchive.hpp],
1255 [std::ostream* o = 0; // Cheap way to get an ostream...
1b88fc23
PL
1256 boost::archive::text_oarchive t(*o);],
1257 [], [], [$2])
94ac5f34
PD
1258])# BOOST_SERIALIZATION
1259
1260
1b88fc23 1261# BOOST_SIGNALS([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
94ac5f34
PD
1262# ---------------------------------
1263# Look for Boost.Signals. For the documentation of PREFERRED-RT-OPT, see the
1264# documentation of BOOST_FIND_LIB above.
1265BOOST_DEFUN([Signals],
1266[BOOST_FIND_LIB([signals], [$1],
1267 [boost/signal.hpp],
1b88fc23
PL
1268 [boost::signal<void ()> s;],
1269 [], [], [$2])
94ac5f34
PD
1270])# BOOST_SIGNALS
1271
1272
1273# BOOST_SIGNALS2()
1274# ----------------
1275# Look for Boost.Signals2 (new since 1.39.0).
1276BOOST_DEFUN([Signals2],
1277[BOOST_FIND_HEADER([boost/signals2.hpp])
1278])# BOOST_SIGNALS2
1279
1280
1281# BOOST_SMART_PTR()
1282# -----------------
1283# Look for Boost.SmartPtr
1284BOOST_DEFUN([Smart_Ptr],
1285[BOOST_FIND_HEADER([boost/scoped_ptr.hpp])
1286BOOST_FIND_HEADER([boost/shared_ptr.hpp])
1287])
1288
1289
1290# BOOST_STATICASSERT()
1291# --------------------
1292# Look for Boost.StaticAssert
1293BOOST_DEFUN([StaticAssert],
1294[BOOST_FIND_HEADER([boost/static_assert.hpp])])
1295
1296
1297# BOOST_STRING_ALGO()
1298# -------------------
1299# Look for Boost.StringAlgo
1300BOOST_DEFUN([String_Algo],
1301[BOOST_FIND_HEADER([boost/algorithm/string.hpp])
1302])
1303
1304
1b88fc23 1305# BOOST_SYSTEM([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
94ac5f34
PD
1306# --------------------------------
1307# Look for Boost.System. For the documentation of PREFERRED-RT-OPT, see the
1308# documentation of BOOST_FIND_LIB above. This library was introduced in Boost
1309# 1.35.0.
1310BOOST_DEFUN([System],
1311[BOOST_FIND_LIB([system], [$1],
1312 [boost/system/error_code.hpp],
1b88fc23 1313 [boost::system::error_code e; e.clear();], [], [], [$2])
94ac5f34
PD
1314])# BOOST_SYSTEM
1315
1316
1b88fc23 1317# BOOST_TEST([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
94ac5f34
PD
1318# ------------------------------
1319# Look for Boost.Test. For the documentation of PREFERRED-RT-OPT, see the
1320# documentation of BOOST_FIND_LIB above.
1321BOOST_DEFUN([Test],
1322[m4_pattern_allow([^BOOST_CHECK$])dnl
1323BOOST_FIND_LIB([unit_test_framework], [$1],
1324 [boost/test/unit_test.hpp], [BOOST_CHECK(2 == 2);],
1325 [using boost::unit_test::test_suite;
1326 test_suite* init_unit_test_suite(int argc, char ** argv)
1b88fc23 1327 { return NULL; }], [], [$2])
94ac5f34
PD
1328])# BOOST_TEST
1329
1330
1b88fc23 1331# BOOST_THREAD([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
94ac5f34
PD
1332# ---------------------------------
1333# Look for Boost.Thread. For the documentation of PREFERRED-RT-OPT, see the
1334# documentation of BOOST_FIND_LIB above.
2187934a 1335BOOST_DEFUN([Thread],
94ac5f34
PD
1336[dnl Having the pthread flag is required at least on GCC3 where
1337dnl boost/thread.hpp would complain if we try to compile without
1338dnl -pthread on GNU/Linux.
1339AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl
2187934a
RK
1340boost_thread_save_LIBS=$LIBS
1341boost_thread_save_LDFLAGS=$LDFLAGS
1342boost_thread_save_CPPFLAGS=$CPPFLAGS
94ac5f34
PD
1343# Link-time dependency from thread to system was added as of 1.49.0.
1344if test $boost_major_version -ge 149; then
1b88fc23 1345BOOST_SYSTEM([$1], [$2])
94ac5f34
PD
1346fi # end of the Boost.System check.
1347m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
1348LIBS="$LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag"
1349LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
94ac5f34
PD
1350CPPFLAGS="$CPPFLAGS $boost_cv_pthread_flag"
1351
1352# When compiling for the Windows platform, the threads library is named
b0d6e9e6
KM
1353# differently. This suffix doesn't exist in new versions of Boost, or
1354# possibly new versions of GCC on mingw I am assuming it's Boost's change for
1355# now and I am setting version to 1.48, for lack of knowledge as to when this
1356# change occurred.
1357if test $boost_major_version -lt 148; then
1358 case $host_os in
1359 (*mingw*) boost_thread_lib_ext=_win32;;
1360 esac
1361fi
2187934a
RK
1362BOOST_FIND_LIBS([thread], [thread$boost_thread_lib_ext],
1363 [$1],
1b88fc23 1364 [boost/thread.hpp], [boost::thread t; boost::mutex m;], [], [], [$2])
94ac5f34 1365
b0d6e9e6
KM
1366case $host_os in
1367 (*mingw*) boost_thread_w32_socket_link=-lws2_32;;
1368esac
1369
1370BOOST_THREAD_LIBS="$BOOST_THREAD_LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag $boost_thread_w32_socket_link"
94ac5f34
PD
1371BOOST_THREAD_LDFLAGS="$BOOST_SYSTEM_LDFLAGS"
1372BOOST_CPPFLAGS="$BOOST_CPPFLAGS $boost_cv_pthread_flag"
2187934a
RK
1373LIBS=$boost_thread_save_LIBS
1374LDFLAGS=$boost_thread_save_LDFLAGS
1375CPPFLAGS=$boost_thread_save_CPPFLAGS
1376])# BOOST_THREAD
1377
1378AU_ALIAS([BOOST_THREADS], [BOOST_THREAD])
94ac5f34
PD
1379
1380
1381# BOOST_TOKENIZER()
1382# -----------------
1383# Look for Boost.Tokenizer
1384BOOST_DEFUN([Tokenizer],
1385[BOOST_FIND_HEADER([boost/tokenizer.hpp])])
1386
1387
1388# BOOST_TRIBOOL()
1389# ---------------
1390# Look for Boost.Tribool
1391BOOST_DEFUN([Tribool],
1392[BOOST_FIND_HEADER([boost/logic/tribool_fwd.hpp])
1393BOOST_FIND_HEADER([boost/logic/tribool.hpp])
1394])
1395
1396
1397# BOOST_TUPLE()
1398# -------------
1399# Look for Boost.Tuple
1400BOOST_DEFUN([Tuple],
1401[BOOST_FIND_HEADER([boost/tuple/tuple.hpp])])
1402
1403
1404# BOOST_TYPETRAITS()
1405# --------------------
1406# Look for Boost.TypeTraits
1407BOOST_DEFUN([TypeTraits],
1408[BOOST_FIND_HEADER([boost/type_traits.hpp])])
1409
1410
1411# BOOST_UTILITY()
1412# ---------------
1413# Look for Boost.Utility (noncopyable, result_of, base-from-member idiom,
1414# etc.)
1415BOOST_DEFUN([Utility],
1416[BOOST_FIND_HEADER([boost/utility.hpp])])
1417
1418
1419# BOOST_VARIANT()
1420# ---------------
1421# Look for Boost.Variant.
1422BOOST_DEFUN([Variant],
1423[BOOST_FIND_HEADER([boost/variant/variant_fwd.hpp])
1424BOOST_FIND_HEADER([boost/variant.hpp])])
1425
2187934a
RK
1426
1427# BOOST_POINTER_CONTAINER()
94ac5f34
PD
1428# ------------------------
1429# Look for Boost.PointerContainer
1430BOOST_DEFUN([Pointer_Container],
1431[BOOST_FIND_HEADER([boost/ptr_container/ptr_deque.hpp])
1432BOOST_FIND_HEADER([boost/ptr_container/ptr_list.hpp])
1433BOOST_FIND_HEADER([boost/ptr_container/ptr_vector.hpp])
1434BOOST_FIND_HEADER([boost/ptr_container/ptr_array.hpp])
1435BOOST_FIND_HEADER([boost/ptr_container/ptr_set.hpp])
1436BOOST_FIND_HEADER([boost/ptr_container/ptr_map.hpp])
2187934a
RK
1437])# BOOST_POINTER_CONTAINER
1438
94ac5f34 1439
1b88fc23 1440# BOOST_WAVE([PREFERRED-RT-OPT], [ERROR_ON_UNUSABLE])
94ac5f34
PD
1441# ------------------------------
1442# NOTE: If you intend to use Wave/Spirit with thread support, make sure you
2187934a 1443# call BOOST_THREAD first.
94ac5f34
PD
1444# Look for Boost.Wave. For the documentation of PREFERRED-RT-OPT, see the
1445# documentation of BOOST_FIND_LIB above.
1446BOOST_DEFUN([Wave],
1447[AC_REQUIRE([BOOST_FILESYSTEM])dnl
1448AC_REQUIRE([BOOST_DATE_TIME])dnl
1449boost_wave_save_LIBS=$LIBS
1450boost_wave_save_LDFLAGS=$LDFLAGS
1451m4_pattern_allow([^BOOST_((FILE)?SYSTEM|DATE_TIME|THREAD)_(LIBS|LDFLAGS)$])dnl
1452LIBS="$LIBS $BOOST_SYSTEM_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_DATE_TIME_LIBS \
1453$BOOST_THREAD_LIBS"
1454LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS \
1455$BOOST_DATE_TIME_LDFLAGS $BOOST_THREAD_LDFLAGS"
1456BOOST_FIND_LIB([wave], [$1],
1457 [boost/wave.hpp],
1b88fc23 1458 [boost::wave::token_id id; get_token_name(id);], [], [], [$2])
94ac5f34
PD
1459LIBS=$boost_wave_save_LIBS
1460LDFLAGS=$boost_wave_save_LDFLAGS
1461])# BOOST_WAVE
1462
1463
1464# BOOST_XPRESSIVE()
1465# -----------------
1466# Look for Boost.Xpressive (new since 1.36.0).
1467BOOST_DEFUN([Xpressive],
1468[BOOST_FIND_HEADER([boost/xpressive/xpressive.hpp])])
1469
1470
1471# ----------------- #
1472# Internal helpers. #
1473# ----------------- #
1474
1475
1476# _BOOST_PTHREAD_FLAG()
1477# ---------------------
2187934a
RK
1478# Internal helper for BOOST_THREAD. Computes boost_cv_pthread_flag
1479# which must be used in CPPFLAGS and LIBS.
1480#
1481# Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3,
1482# boost/thread.hpp will trigger a #error if -pthread isn't used:
1483# boost/config/requires_threads.hpp:47:5: #error "Compiler threading support
1484# is not turned on. Please set the correct command line options for
1485# threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
1486#
1487# Based on ACX_PTHREAD: http://autoconf-archive.cryp.to/acx_pthread.html
94ac5f34
PD
1488AC_DEFUN([_BOOST_PTHREAD_FLAG],
1489[AC_REQUIRE([AC_PROG_CXX])dnl
1490AC_REQUIRE([AC_CANONICAL_HOST])dnl
1491AC_LANG_PUSH([C++])dnl
1492AC_CACHE_CHECK([for the flags needed to use pthreads], [boost_cv_pthread_flag],
1493[ boost_cv_pthread_flag=
1494 # The ordering *is* (sometimes) important. Some notes on the
1495 # individual items follow:
1496 # (none): in case threads are in libc; should be tried before -Kthread and
1497 # other compiler flags to prevent continual compiler warnings
1498 # -lpthreads: AIX (must check this before -lpthread)
1499 # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
1500 # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
1501 # -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
1502 # -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads)
1503 # -pthreads: Solaris/GCC
1504 # -mthreads: MinGW32/GCC, Lynx/GCC
1505 # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
1506 # doesn't hurt to check since this sometimes defines pthreads too;
1507 # also defines -D_REENTRANT)
1508 # ... -mt is also the pthreads flag for HP/aCC
1509 # -lpthread: GNU Linux, etc.
1510 # --thread-safe: KAI C++
1511 case $host_os in #(
1512 *solaris*)
1513 # On Solaris (at least, for some versions), libc contains stubbed
1514 # (non-functional) versions of the pthreads routines, so link-based
1515 # tests will erroneously succeed. (We need to link with -pthreads/-mt/
1516 # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
1517 # a function called by this macro, so we could check for that, but
1518 # who knows whether they'll stub that too in a future libc.) So,
1519 # we'll just look for -pthreads and -lpthread first:
1520 boost_pthread_flags="-pthreads -lpthread -mt -pthread";; #(
1521 *)
1522 boost_pthread_flags="-lpthreads -Kthread -kthread -llthread -pthread \
1523 -pthreads -mthreads -lpthread --thread-safe -mt";;
1524 esac
1525 # Generate the test file.
1526 AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <pthread.h>],
1527 [pthread_t th; pthread_join(th, 0);
1528 pthread_attr_init(0); pthread_cleanup_push(0, 0);
1529 pthread_create(0,0,0,0); pthread_cleanup_pop(0);])])
1530 for boost_pthread_flag in '' $boost_pthread_flags; do
1531 boost_pthread_ok=false
1532dnl Re-use the test file already generated.
1533 boost_pthreads__save_LIBS=$LIBS
1534 LIBS="$LIBS $boost_pthread_flag"
1535 AC_LINK_IFELSE([],
1536 [if grep ".*$boost_pthread_flag" conftest.err; then
1537 echo "This flag seems to have triggered warnings" >&AS_MESSAGE_LOG_FD
1538 else
1539 boost_pthread_ok=:; boost_cv_pthread_flag=$boost_pthread_flag
1540 fi])
1541 LIBS=$boost_pthreads__save_LIBS
1542 $boost_pthread_ok && break
1543 done
1544])
1545AC_LANG_POP([C++])dnl
1546])# _BOOST_PTHREAD_FLAG
1547
1548
1549# _BOOST_gcc_test(MAJOR, MINOR)
1550# -----------------------------
1551# Internal helper for _BOOST_FIND_COMPILER_TAG.
1552m4_define([_BOOST_gcc_test],
1553["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC @ gcc$1$2"])dnl
1554
2187934a
RK
1555# _BOOST_mingw_test(MAJOR, MINOR)
1556# -----------------------------
1557# Internal helper for _BOOST_FIND_COMPILER_TAG.
1558m4_define([_BOOST_mingw_test],
1559["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC && \
1560 (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \
1561 || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw$1$2"])dnl
1562
94ac5f34
PD
1563
1564# _BOOST_FIND_COMPILER_TAG()
1565# --------------------------
1566# Internal. When Boost is installed without --layout=system, each library
1567# filename will hold a suffix that encodes the compiler used during the
1568# build. The Boost build system seems to call this a `tag'.
1569AC_DEFUN([_BOOST_FIND_COMPILER_TAG],
1570[AC_REQUIRE([AC_PROG_CXX])dnl
1571AC_REQUIRE([AC_CANONICAL_HOST])dnl
2187934a
RK
1572AC_CACHE_CHECK([for the toolset name used by Boost for $CXX],
1573 [boost_cv_lib_tag],
94ac5f34
PD
1574[boost_cv_lib_tag=unknown
1575if test x$boost_cv_inc_path != xno; then
1576 AC_LANG_PUSH([C++])dnl
1577 # The following tests are mostly inspired by boost/config/auto_link.hpp
1578 # The list is sorted to most recent/common to oldest compiler (in order
1579 # to increase the likelihood of finding the right compiler with the
1580 # least number of compilation attempt).
1581 # Beware that some tests are sensible to the order (for instance, we must
1582 # look for MinGW before looking for GCC3).
1583 # I used one compilation test per compiler with a #error to recognize
1584 # each compiler so that it works even when cross-compiling (let me know
1585 # if you know a better approach).
1586 # Known missing tags (known from Boost's tools/build/v2/tools/common.jam):
1587 # como, edg, kcc, bck, mp, sw, tru, xlc
1588 # I'm not sure about my test for `il' (be careful: Intel's ICC pre-defines
1589 # the same defines as GCC's).
1590 for i in \
d7a2a52f
PL
1591 "defined __clang__ && __clang_major__ == 8 && __clang_minor__ == 0 @ clang80" \
1592 "defined __clang__ && __clang_major__ == 7 && __clang_minor__ == 0 @ clang70" \
1593 "defined __clang__ && __clang_major__ == 6 && __clang_minor__ == 0 @ clang60" \
1594 "defined __clang__ && __clang_major__ == 5 && __clang_minor__ == 0 @ clang50" \
1595 "defined __clang__ && __clang_major__ == 4 && __clang_minor__ == 0 @ clang40" \
1596 "defined __clang__ && __clang_major__ == 3 && __clang_minor__ == 9 @ clang39" \
1597 "defined __clang__ && __clang_major__ == 3 && __clang_minor__ == 8 @ clang38" \
1598 "defined __clang__ && __clang_major__ == 3 && __clang_minor__ == 7 @ clang37" \
1599 _BOOST_mingw_test(9, 1) \
1600 _BOOST_gcc_test(9, 1) \
1601 _BOOST_mingw_test(9, 0) \
1602 _BOOST_gcc_test(9, 0) \
15875dd8
PL
1603 _BOOST_mingw_test(8, 3) \
1604 _BOOST_gcc_test(8, 3) \
0b59e24e
PL
1605 _BOOST_mingw_test(8, 2) \
1606 _BOOST_gcc_test(8, 2) \
1607 _BOOST_mingw_test(8, 1) \
1608 _BOOST_gcc_test(8, 1) \
1609 _BOOST_mingw_test(8, 0) \
1610 _BOOST_gcc_test(8, 0) \
1611 _BOOST_mingw_test(7, 3) \
1612 _BOOST_gcc_test(7, 3) \
e2a91983
PL
1613 _BOOST_mingw_test(7, 2) \
1614 _BOOST_gcc_test(7, 2) \
7364056a
KM
1615 _BOOST_mingw_test(7, 1) \
1616 _BOOST_gcc_test(7, 1) \
1617 _BOOST_mingw_test(7, 0) \
1618 _BOOST_gcc_test(7, 0) \
0b59e24e
PL
1619 _BOOST_mingw_test(6, 4) \
1620 _BOOST_gcc_test(6, 4) \
bfafc642
PL
1621 _BOOST_mingw_test(6, 3) \
1622 _BOOST_gcc_test(6, 3) \
d593e741
KM
1623 _BOOST_mingw_test(6, 2) \
1624 _BOOST_gcc_test(6, 2) \
089bc1c5
KM
1625 _BOOST_mingw_test(6, 1) \
1626 _BOOST_gcc_test(6, 1) \
3b6c745f
KM
1627 _BOOST_mingw_test(6, 0) \
1628 _BOOST_gcc_test(6, 0) \
0b59e24e
PL
1629 _BOOST_mingw_test(5, 5) \
1630 _BOOST_gcc_test(5, 5) \
cabf3aa7
PD
1631 _BOOST_mingw_test(5, 4) \
1632 _BOOST_gcc_test(5, 4) \
afdd465f
PL
1633 _BOOST_mingw_test(5, 3) \
1634 _BOOST_gcc_test(5, 3) \
fe6a830f
PL
1635 _BOOST_mingw_test(5, 2) \
1636 _BOOST_gcc_test(5, 2) \
016ed2c1
RK
1637 _BOOST_mingw_test(5, 1) \
1638 _BOOST_gcc_test(5, 1) \
2187934a
RK
1639 _BOOST_mingw_test(5, 0) \
1640 _BOOST_gcc_test(5, 0) \
1641 _BOOST_mingw_test(4, 10) \
1642 _BOOST_gcc_test(4, 10) \
1643 _BOOST_mingw_test(4, 9) \
94ac5f34 1644 _BOOST_gcc_test(4, 9) \
2187934a 1645 _BOOST_mingw_test(4, 8) \
94ac5f34 1646 _BOOST_gcc_test(4, 8) \
2187934a 1647 _BOOST_mingw_test(4, 7) \
94ac5f34 1648 _BOOST_gcc_test(4, 7) \
2187934a 1649 _BOOST_mingw_test(4, 6) \
94ac5f34 1650 _BOOST_gcc_test(4, 6) \
2187934a 1651 _BOOST_mingw_test(4, 5) \
94ac5f34 1652 _BOOST_gcc_test(4, 5) \
2187934a 1653 _BOOST_mingw_test(4, 4) \
94ac5f34 1654 _BOOST_gcc_test(4, 4) \
2187934a 1655 _BOOST_mingw_test(4, 3) \
94ac5f34 1656 _BOOST_gcc_test(4, 3) \
2187934a 1657 _BOOST_mingw_test(4, 2) \
94ac5f34 1658 _BOOST_gcc_test(4, 2) \
2187934a 1659 _BOOST_mingw_test(4, 1) \
94ac5f34 1660 _BOOST_gcc_test(4, 1) \
2187934a 1661 _BOOST_mingw_test(4, 0) \
94ac5f34
PD
1662 _BOOST_gcc_test(4, 0) \
1663 "defined __GNUC__ && __GNUC__ == 3 && !defined __ICC \
1664 && (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \
1665 || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw" \
1666 _BOOST_gcc_test(3, 4) \
1667 _BOOST_gcc_test(3, 3) \
1668 "defined _MSC_VER && _MSC_VER >= 1500 @ vc90" \
1669 "defined _MSC_VER && _MSC_VER == 1400 @ vc80" \
1670 _BOOST_gcc_test(3, 2) \
1671 "defined _MSC_VER && _MSC_VER == 1310 @ vc71" \
1672 _BOOST_gcc_test(3, 1) \
1673 _BOOST_gcc_test(3, 0) \
1674 "defined __BORLANDC__ @ bcb" \
1675 "defined __ICC && (defined __unix || defined __unix__) @ il" \
1676 "defined __ICL @ iw" \
1677 "defined _MSC_VER && _MSC_VER == 1300 @ vc7" \
1678 _BOOST_gcc_test(2, 95) \
1679 "defined __MWERKS__ && __MWERKS__ <= 0x32FF @ cw9" \
1680 "defined _MSC_VER && _MSC_VER < 1300 && !defined UNDER_CE @ vc6" \
1681 "defined _MSC_VER && _MSC_VER < 1300 && defined UNDER_CE @ evc4" \
1682 "defined __MWERKS__ && __MWERKS__ <= 0x31FF @ cw8"
1683 do
1684 boost_tag_test=`expr "X$i" : 'X\([[^@]]*\) @ '`
1685 boost_tag=`expr "X$i" : 'X[[^@]]* @ \(.*\)'`
1686 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1687#if $boost_tag_test
1688/* OK */
1689#else
1690# error $boost_tag_test
1691#endif
1692]])], [boost_cv_lib_tag=$boost_tag; break], [])
1693 done
1694AC_LANG_POP([C++])dnl
1695 case $boost_cv_lib_tag in #(
1696 # Some newer (>= 1.35?) versions of Boost seem to only use "gcc" as opposed
1697 # to "gcc41" for instance.
1698 *-gcc | *'-gcc ') :;; #( Don't re-add -gcc: it's already in there.
1699 gcc*)
1700 boost_tag_x=
1701 case $host_os in #(
1702 darwin*)
1703 if test $boost_major_version -ge 136; then
1704 # The `x' added in r46793 of Boost.
1705 boost_tag_x=x
1706 fi;;
1707 esac
1708 # We can specify multiple tags in this variable because it's used by
1709 # BOOST_FIND_LIB that does a `for tag in -$boost_cv_lib_tag' ...
1710 boost_cv_lib_tag="$boost_tag_x$boost_cv_lib_tag -${boost_tag_x}gcc"
1711 ;; #(
1712 unknown)
1713 AC_MSG_WARN([[could not figure out which toolset name to use for $CXX]])
1714 boost_cv_lib_tag=
1715 ;;
1716 esac
1717fi])dnl end of AC_CACHE_CHECK
1718])# _BOOST_FIND_COMPILER_TAG
1719
1720
1721# _BOOST_GUESS_WHETHER_TO_USE_MT()
1722# --------------------------------
1723# Compile a small test to try to guess whether we should favor MT (Multi
1724# Thread) flavors of Boost. Sets boost_guess_use_mt accordingly.
1725AC_DEFUN([_BOOST_GUESS_WHETHER_TO_USE_MT],
1726[# Check whether we do better use `mt' even though we weren't ask to.
2187934a 1727AC_LANG_PUSH([C++])dnl
94ac5f34
PD
1728AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1729#if defined _REENTRANT || defined _MT || defined __MT__
1730/* use -mt */
1731#else
1732# error MT not needed
1733#endif
1734]])], [boost_guess_use_mt=:], [boost_guess_use_mt=false])
2187934a 1735AC_LANG_POP([C++])dnl
94ac5f34
PD
1736])
1737
1738# _BOOST_AC_LINK_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
1739# -------------------------------------------------------------------
1740# Fork of _AC_LINK_IFELSE that preserves conftest.o across calls. Fragile,
1741# will break when Autoconf changes its internals. Requires that you manually
1742# rm -f conftest.$ac_objext in between to really different tests, otherwise
1743# you will try to link a conftest.o left behind by a previous test.
1744# Used to aggressively optimize BOOST_FIND_LIB (see the big comment in this
1745# macro).
1746#
1747# Don't use "break" in the actions, as it would short-circuit some code
1748# this macro runs after the actions.
1749m4_define([_BOOST_AC_LINK_IFELSE],
1750[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
1751rm -f conftest$ac_exeext
1752boost_save_ac_ext=$ac_ext
1753boost_use_source=:
1754# If we already have a .o, re-use it. We change $ac_ext so that $ac_link
1755# tries to link the existing object file instead of compiling from source.
1756test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false &&
1757 _AS_ECHO_LOG([re-using the existing conftest.$ac_objext])
1758AS_IF([_AC_DO_STDERR($ac_link) && {
2187934a
RK
1759 test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" ||
1760 test ! -s conftest.err
94ac5f34 1761 } && test -s conftest$ac_exeext && {
2187934a
RK
1762 test "$cross_compiling" = yes ||
1763 $as_executable_p conftest$ac_exeext
94ac5f34
PD
1764dnl FIXME: use AS_TEST_X instead when 2.61 is widespread enough.
1765 }],
1766 [$2],
1767 [if $boost_use_source; then
1768 _AC_MSG_LOG_CONFTEST
1769 fi
1770 $3])
1771ac_objext=$boost_save_ac_objext
1772ac_ext=$boost_save_ac_ext
1773dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization)
1774dnl information created by the PGI compiler (conftest_ipa8_conftest.oo),
1775dnl as it would interfere with the next link command.
1776rm -f core conftest.err conftest_ipa8_conftest.oo \
1777 conftest$ac_exeext m4_ifval([$1], [conftest.$ac_ext])[]dnl
1778])# _BOOST_AC_LINK_IFELSE
1779
1780# Local Variables:
1781# mode: autoconf
1782# End: