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