]> git.ipfire.org Git - thirdparty/pdns.git/blame - m4/boost.m4
implement delta() to show changes versus configuration, so you can store your 'just...
[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([
016ed2c1 25# serial 25
94ac5f34
PD
26], [#
27], [])])
28
29# Original sources can be found at http://github.com/tsuna/boost.m4
30# You can fetch the latest version of the script by doing:
31# wget http://github.com/tsuna/boost.m4/raw/master/build-aux/boost.m4
32
33# ------ #
34# README #
35# ------ #
36
37# This file provides several macros to use the various Boost libraries.
38# The first macro is BOOST_REQUIRE. It will simply check if it's possible to
39# find the Boost headers of a given (optional) minimum version and it will
40# define BOOST_CPPFLAGS accordingly. It will add an option --with-boost to
41# your configure so that users can specify non standard locations.
42# If the user's environment contains BOOST_ROOT and --with-boost was not
43# specified, --with-boost=$BOOST_ROOT is implicitly used.
44# For more README and documentation, go to http://github.com/tsuna/boost.m4
45# Note: THESE MACROS ASSUME THAT YOU USE LIBTOOL. If you don't, don't worry,
46# simply read the README, it will show you what to do step by step.
47
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
89dnl So get rid of the # lines, and glue the remaining ones together.
94ac5f34 90(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
2187934a 91 grep -v '#' |
94ac5f34 92 tr -d '\r' |
2187934a 93 tr -s '\n' ' ' |
94ac5f34
PD
94 $SED -n -e "$1" >conftest.i 2>&1],
95 [$3],
96 [$4])
97rm -rf conftest*
2187934a
RK
98AC_LANG_POP([C++])dnl
99])# _BOOST_SED_CPP
94ac5f34
PD
100
101
102
103# BOOST_REQUIRE([VERSION], [ACTION-IF-NOT-FOUND])
104# -----------------------------------------------
105# Look for Boost. If version is given, it must either be a literal of the form
106# "X.Y.Z" where X, Y and Z are integers (the ".Z" part being optional) or a
107# variable "$var".
108# Defines the value BOOST_CPPFLAGS. This macro only checks for headers with
109# the required version, it does not check for any of the Boost libraries.
110# On # success, defines HAVE_BOOST. On failure, calls the optional
111# ACTION-IF-NOT-FOUND action if one was supplied.
112# Otherwise aborts with an error message.
b0d6e9e6 113AC_DEFUN_ONCE([BOOST_REQUIRE],
94ac5f34
PD
114[AC_REQUIRE([AC_PROG_CXX])dnl
115AC_REQUIRE([AC_PROG_GREP])dnl
116echo "$as_me: this is boost.m4[]_BOOST_SERIAL" >&AS_MESSAGE_LOG_FD
117boost_save_IFS=$IFS
118boost_version_req=$1
119IFS=.
120set x $boost_version_req 0 0 0
121IFS=$boost_save_IFS
122shift
123boost_version_req=`expr "$[1]" '*' 100000 + "$[2]" '*' 100 + "$[3]"`
124boost_version_req_string=$[1].$[2].$[3]
125AC_ARG_WITH([boost],
126 [AS_HELP_STRING([--with-boost=DIR],
127 [prefix of Boost $1 @<:@guess@:>@])])dnl
128AC_ARG_VAR([BOOST_ROOT],[Location of Boost installation])dnl
129# If BOOST_ROOT is set and the user has not provided a value to
130# --with-boost, then treat BOOST_ROOT as if it the user supplied it.
131if test x"$BOOST_ROOT" != x; then
132 if test x"$with_boost" = x; then
133 AC_MSG_NOTICE([Detected BOOST_ROOT; continuing with --with-boost=$BOOST_ROOT])
134 with_boost=$BOOST_ROOT
135 else
136 AC_MSG_NOTICE([Detected BOOST_ROOT=$BOOST_ROOT, but overridden by --with-boost=$with_boost])
137 fi
138fi
139AC_SUBST([DISTCHECK_CONFIGURE_FLAGS],
140 ["$DISTCHECK_CONFIGURE_FLAGS '--with-boost=$with_boost'"])dnl
141boost_save_CPPFLAGS=$CPPFLAGS
142 AC_CACHE_CHECK([for Boost headers version >= $boost_version_req_string],
143 [boost_cv_inc_path],
144 [boost_cv_inc_path=no
145AC_LANG_PUSH([C++])dnl
146m4_pattern_allow([^BOOST_VERSION$])dnl
147 AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#include <boost/version.hpp>
148#if !defined BOOST_VERSION
149# error BOOST_VERSION is not defined
150#elif BOOST_VERSION < $boost_version_req
151# error Boost headers version < $boost_version_req
152#endif
153]])])
154 # If the user provided a value to --with-boost, use it and only it.
155 case $with_boost in #(
156 ''|yes) set x '' /opt/local/include /usr/local/include /opt/include \
157 /usr/include C:/Boost/include;; #(
158 *) set x "$with_boost/include" "$with_boost";;
159 esac
160 shift
161 for boost_dir
162 do
163 # Without --layout=system, Boost (or at least some versions) installs
164 # itself in <prefix>/include/boost-<version>. This inner loop helps to
165 # find headers in such directories.
166 #
167 # Any ${boost_dir}/boost-x_xx directories are searched in reverse version
168 # order followed by ${boost_dir}. The final '.' is a sentinel for
169 # searching $boost_dir" itself. Entries are whitespace separated.
170 #
171 # I didn't indent this loop on purpose (to avoid over-indented code)
172 boost_layout_system_search_list=`cd "$boost_dir" 2>/dev/null \
173 && ls -1 | "${GREP}" '^boost-' | sort -rn -t- -k2 \
174 && echo .`
175 for boost_inc in $boost_layout_system_search_list
176 do
177 if test x"$boost_inc" != x.; then
178 boost_inc="$boost_dir/$boost_inc"
179 else
180 boost_inc="$boost_dir" # Uses sentinel in boost_layout_system_search_list
181 fi
182 if test x"$boost_inc" != x; then
183 # We are going to check whether the version of Boost installed
184 # in $boost_inc is usable by running a compilation that
185 # #includes it. But if we pass a -I/some/path in which Boost
186 # is not installed, the compiler will just skip this -I and
187 # use other locations (either from CPPFLAGS, or from its list
188 # of system include directories). As a result we would use
189 # header installed on the machine instead of the /some/path
190 # specified by the user. So in that precise case (trying
191 # $boost_inc), make sure the version.hpp exists.
192 #
193 # Use test -e as there can be symlinks.
194 test -e "$boost_inc/boost/version.hpp" || continue
195 CPPFLAGS="$CPPFLAGS -I$boost_inc"
196 fi
197 AC_COMPILE_IFELSE([], [boost_cv_inc_path=yes], [boost_cv_version=no])
198 if test x"$boost_cv_inc_path" = xyes; then
199 if test x"$boost_inc" != x; then
200 boost_cv_inc_path=$boost_inc
201 fi
202 break 2
203 fi
204 done
205 done
206AC_LANG_POP([C++])dnl
207 ])
208 case $boost_cv_inc_path in #(
209 no)
210 boost_errmsg="cannot find Boost headers version >= $boost_version_req_string"
211 m4_if([$2], [], [AC_MSG_ERROR([$boost_errmsg])],
212 [AC_MSG_NOTICE([$boost_errmsg])])
213 $2
214 ;;#(
215 yes)
216 BOOST_CPPFLAGS=
217 ;;#(
218 *)
219 AC_SUBST([BOOST_CPPFLAGS], ["-I$boost_cv_inc_path"])dnl
220 ;;
221 esac
222 if test x"$boost_cv_inc_path" != xno; then
223 AC_DEFINE([HAVE_BOOST], [1],
224 [Defined if the requested minimum BOOST version is satisfied])
225 AC_CACHE_CHECK([for Boost's header version],
226 [boost_cv_lib_version],
227 [m4_pattern_allow([^BOOST_LIB_VERSION$])dnl
2187934a 228 _BOOST_SED_CPP([[/^boost-lib-version = /{s///;s/[\" ]//g;p;q;}]],
94ac5f34
PD
229 [#include <boost/version.hpp>
230boost-lib-version = BOOST_LIB_VERSION],
231 [boost_cv_lib_version=`cat conftest.i`])])
232 # e.g. "134" for 1_34_1 or "135" for 1_35
233 boost_major_version=`echo "$boost_cv_lib_version" | sed 's/_//;s/_.*//'`
234 case $boost_major_version in #(
235 '' | *[[!0-9]]*)
2187934a 236 AC_MSG_ERROR([invalid value: boost_major_version='$boost_major_version'])
94ac5f34
PD
237 ;;
238 esac
239fi
240CPPFLAGS=$boost_save_CPPFLAGS
241])# BOOST_REQUIRE
242
2187934a 243
94ac5f34
PD
244# BOOST_STATIC()
245# --------------
246# Add the "--enable-static-boost" configure argument. If this argument is given
247# on the command line, static versions of the libraries will be looked up.
248AC_DEFUN([BOOST_STATIC],
249 [AC_ARG_ENABLE([static-boost],
250 [AS_HELP_STRING([--enable-static-boost],
251 [Prefer the static boost libraries over the shared ones [no]])],
252 [enable_static_boost=yes],
253 [enable_static_boost=no])])# BOOST_STATIC
254
2187934a 255
94ac5f34
PD
256# BOOST_FIND_HEADER([HEADER-NAME], [ACTION-IF-NOT-FOUND], [ACTION-IF-FOUND])
257# --------------------------------------------------------------------------
258# Wrapper around AC_CHECK_HEADER for Boost headers. Useful to check for
259# some parts of the Boost library which are only made of headers and don't
260# require linking (such as Boost.Foreach).
261#
262# Default ACTION-IF-NOT-FOUND: Fail with a fatal error unless Boost couldn't be
263# found in the first place, in which case by default a notice is issued to the
264# user. Presumably if we haven't died already it's because it's OK to not have
265# Boost, which is why only a notice is issued instead of a hard error.
266#
267# Default ACTION-IF-FOUND: define the preprocessor symbol HAVE_<HEADER-NAME> in
268# case of success # (where HEADER-NAME is written LIKE_THIS, e.g.,
269# HAVE_BOOST_FOREACH_HPP).
270AC_DEFUN([BOOST_FIND_HEADER],
271[AC_REQUIRE([BOOST_REQUIRE])dnl
272if test x"$boost_cv_inc_path" = xno; then
273 m4_default([$2], [AC_MSG_NOTICE([Boost not available, not searching for $1])])
274else
275AC_LANG_PUSH([C++])dnl
276boost_save_CPPFLAGS=$CPPFLAGS
277CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
278AC_CHECK_HEADER([$1],
279 [m4_default([$3], [AC_DEFINE(AS_TR_CPP([HAVE_$1]), [1],
280 [Define to 1 if you have <$1>])])],
281 [m4_default([$2], [AC_MSG_ERROR([cannot find $1])])])
282CPPFLAGS=$boost_save_CPPFLAGS
283AC_LANG_POP([C++])dnl
284fi
285])# BOOST_FIND_HEADER
286
287
2187934a
RK
288# BOOST_FIND_LIBS([COMPONENT-NAME], [CANDIDATE-LIB-NAMES],
289# [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST],
290# [CXX-PROLOGUE])
291# --------------------------------------------------------------
292# Look for the Boost library COMPONENT-NAME (e.g., `thread', for
293# libboost_thread) under the possible CANDIDATE-LIB-NAMES (e.g.,
294# "thread_win32 thread"). Check that HEADER-NAME works and check that
295# libboost_LIB-NAME can link with the code CXX-TEST. The optional
296# argument CXX-PROLOGUE can be used to include some C++ code before
297# the `main' function.
94ac5f34
PD
298#
299# Invokes BOOST_FIND_HEADER([HEADER-NAME]) (see above).
300#
301# Boost libraries typically come compiled with several flavors (with different
302# runtime options) so PREFERRED-RT-OPT is the preferred suffix. A suffix is one
303# or more of the following letters: sgdpn (in that order). s = static
304# runtime, d = debug build, g = debug/diagnostic runtime, p = STLPort build,
305# n = (unsure) STLPort build without iostreams from STLPort (it looks like `n'
306# must always be used along with `p'). Additionally, PREFERRED-RT-OPT can
307# start with `mt-' to indicate that there is a preference for multi-thread
308# builds. Some sample values for PREFERRED-RT-OPT: (nothing), mt, d, mt-d, gdp
309# ... If you want to make sure you have a specific version of Boost
310# (eg, >= 1.33) you *must* invoke BOOST_REQUIRE before this macro.
2187934a 311AC_DEFUN([BOOST_FIND_LIBS],
94ac5f34
PD
312[AC_REQUIRE([BOOST_REQUIRE])dnl
313AC_REQUIRE([_BOOST_FIND_COMPILER_TAG])dnl
314AC_REQUIRE([BOOST_STATIC])dnl
315AC_REQUIRE([_BOOST_GUESS_WHETHER_TO_USE_MT])dnl
316if test x"$boost_cv_inc_path" = xno; then
317 AC_MSG_NOTICE([Boost not available, not searching for the Boost $1 library])
318else
319dnl The else branch is huge and wasn't intended on purpose.
320AC_LANG_PUSH([C++])dnl
321AS_VAR_PUSHDEF([Boost_lib], [boost_cv_lib_$1])dnl
322AS_VAR_PUSHDEF([Boost_lib_LDFLAGS], [boost_cv_lib_$1_LDFLAGS])dnl
323AS_VAR_PUSHDEF([Boost_lib_LDPATH], [boost_cv_lib_$1_LDPATH])dnl
324AS_VAR_PUSHDEF([Boost_lib_LIBS], [boost_cv_lib_$1_LIBS])dnl
2187934a 325BOOST_FIND_HEADER([$4])
94ac5f34
PD
326boost_save_CPPFLAGS=$CPPFLAGS
327CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
94ac5f34 328AC_CACHE_CHECK([for the Boost $1 library], [Boost_lib],
2187934a
RK
329 [_BOOST_FIND_LIBS($@)])
330case $Boost_lib in #(
331 (no) _AC_MSG_LOG_CONFTEST
332 AC_MSG_ERROR([cannot find the flags to link with Boost $1])
333 ;;
334esac
335AC_SUBST(AS_TR_CPP([BOOST_$1_LDFLAGS]), [$Boost_lib_LDFLAGS])dnl
336AC_SUBST(AS_TR_CPP([BOOST_$1_LDPATH]), [$Boost_lib_LDPATH])dnl
337AC_SUBST([BOOST_LDPATH], [$Boost_lib_LDPATH])dnl
338AC_SUBST(AS_TR_CPP([BOOST_$1_LIBS]), [$Boost_lib_LIBS])dnl
339CPPFLAGS=$boost_save_CPPFLAGS
340AS_VAR_POPDEF([Boost_lib])dnl
341AS_VAR_POPDEF([Boost_lib_LDFLAGS])dnl
342AS_VAR_POPDEF([Boost_lib_LDPATH])dnl
343AS_VAR_POPDEF([Boost_lib_LIBS])dnl
344AC_LANG_POP([C++])dnl
345fi
346])
347
348
349# BOOST_FIND_LIB([LIB-NAME],
350# [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST],
351# [CXX-PROLOGUE])
352# --------------------------------------------------------------
353# Backward compatibility wrapper for BOOST_FIND_LIBS.
354AC_DEFUN([BOOST_FIND_LIB],
355[BOOST_FIND_LIBS([$1], $@)])
356
357
358# _BOOST_FIND_LIBS([LIB-NAME], [CANDIDATE-LIB-NAMES],
359# [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST],
360# [CXX-PROLOGUE])
361# --------------------------------------------------------------
362# Real implementation of BOOST_FIND_LIBS: rely on these local macros:
363# Boost_lib, Boost_lib_LDFLAGS, Boost_lib_LDPATH, Boost_lib_LIBS
364#
365# The algorithm is as follows: first look for a given library name
366# according to the user's PREFERRED-RT-OPT. For each library name, we
367# prefer to use the ones that carry the tag (toolset name). Each
368# library is searched through the various standard paths were Boost is
369# usually installed. If we can't find the standard variants, we try
370# to enforce -mt (for instance on MacOSX, libboost_thread.dylib
371# doesn't exist but there's -obviously- libboost_thread-mt.dylib).
372AC_DEFUN([_BOOST_FIND_LIBS],
373[Boost_lib=no
374 case "$3" in #(
375 (mt | mt-) boost_mt=-mt; boost_rtopt=;; #(
376 (mt* | mt-*) boost_mt=-mt; boost_rtopt=`expr "X$3" : 'Xmt-*\(.*\)'`;; #(
377 (*) boost_mt=; boost_rtopt=$3;;
94ac5f34
PD
378 esac
379 if test $enable_static_boost = yes; then
380 boost_rtopt="s$boost_rtopt"
381 fi
382 # Find the proper debug variant depending on what we've been asked to find.
383 case $boost_rtopt in #(
2187934a
RK
384 (*d*) boost_rt_d=$boost_rtopt;; #(
385 (*[[sgpn]]*) # Insert the `d' at the right place (in between `sg' and `pn')
94ac5f34 386 boost_rt_d=`echo "$boost_rtopt" | sed 's/\(s*g*\)\(p*n*\)/\1\2/'`;; #(
2187934a 387 (*) boost_rt_d='-d';;
94ac5f34
PD
388 esac
389 # If the PREFERRED-RT-OPT are not empty, prepend a `-'.
390 test -n "$boost_rtopt" && boost_rtopt="-$boost_rtopt"
391 $boost_guess_use_mt && boost_mt=-mt
392 # Look for the abs path the static archive.
393 # $libext is computed by Libtool but let's make sure it's non empty.
394 test -z "$libext" &&
395 AC_MSG_ERROR([the libext variable is empty, did you invoke Libtool?])
396 boost_save_ac_objext=$ac_objext
397 # Generate the test file.
2187934a
RK
398 AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <$4>
399$6], [$5])])
94ac5f34
PD
400dnl Optimization hacks: compiling C++ is slow, especially with Boost. What
401dnl we're trying to do here is guess the right combination of link flags
402dnl (LIBS / LDFLAGS) to use a given library. This can take several
403dnl iterations before it succeeds and is thus *very* slow. So what we do
404dnl instead is that we compile the code first (and thus get an object file,
405dnl typically conftest.o). Then we try various combinations of link flags
406dnl until we succeed to link conftest.o in an executable. The problem is
407dnl that the various TRY_LINK / COMPILE_IFELSE macros of Autoconf always
408dnl remove all the temporary files including conftest.o. So the trick here
409dnl is to temporarily change the value of ac_objext so that conftest.o is
410dnl preserved accross tests. This is obviously fragile and I will burn in
411dnl hell for not respecting Autoconf's documented interfaces, but in the
412dnl mean time, it optimizes the macro by a factor of 5 to 30.
413dnl Another small optimization: the first argument of AC_COMPILE_IFELSE left
414dnl empty because the test file is generated only once above (before we
415dnl start the for loops).
416 AC_COMPILE_IFELSE([],
417 [ac_objext=do_not_rm_me_plz],
418 [AC_MSG_ERROR([cannot compile a test that uses Boost $1])])
419 ac_objext=$boost_save_ac_objext
420 boost_failed_libs=
2187934a
RK
421# Don't bother to ident the following nested for loops, only the 2
422# innermost ones matter.
423for boost_lib_ in $2; do
94ac5f34
PD
424for boost_tag_ in -$boost_cv_lib_tag ''; do
425for boost_ver_ in -$boost_cv_lib_version ''; do
426for boost_mt_ in $boost_mt -mt ''; do
427for boost_rtopt_ in $boost_rtopt '' -d; do
428 for boost_lib in \
2187934a
RK
429 boost_$boost_lib_$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_ \
430 boost_$boost_lib_$boost_tag_$boost_rtopt_$boost_ver_ \
431 boost_$boost_lib_$boost_tag_$boost_mt_$boost_ver_ \
432 boost_$boost_lib_$boost_tag_$boost_ver_
94ac5f34
PD
433 do
434 # Avoid testing twice the same lib
435 case $boost_failed_libs in #(
2187934a 436 (*@$boost_lib@*) continue;;
94ac5f34
PD
437 esac
438 # If with_boost is empty, we'll search in /lib first, which is not quite
439 # right so instead we'll try to a location based on where the headers are.
440 boost_tmp_lib=$with_boost
441 test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include}
442 for boost_ldpath in "$boost_tmp_lib/lib" '' \
443 /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \
444 "$with_boost" C:/Boost/lib /lib*
445 do
2187934a
RK
446 # Don't waste time with directories that don't exist.
447 if test x"$boost_ldpath" != x && test ! -e "$boost_ldpath"; then
448 continue
449 fi
94ac5f34
PD
450 boost_save_LDFLAGS=$LDFLAGS
451 # Are we looking for a static library?
452 case $boost_ldpath:$boost_rtopt_ in #(
2187934a 453 (*?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt)
94ac5f34
PD
454 Boost_lib_LIBS="$boost_ldpath/lib$boost_lib.$libext"
455 test -e "$Boost_lib_LIBS" || continue;; #(
2187934a 456 (*) # No: use -lboost_foo to find the shared library.
94ac5f34
PD
457 Boost_lib_LIBS="-l$boost_lib";;
458 esac
459 boost_save_LIBS=$LIBS
460 LIBS="$Boost_lib_LIBS $LIBS"
461 test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath"
462dnl First argument of AC_LINK_IFELSE left empty because the test file is
463dnl generated only once above (before we start the for loops).
464 _BOOST_AC_LINK_IFELSE([],
465 [Boost_lib=yes], [Boost_lib=no])
466 ac_objext=$boost_save_ac_objext
467 LDFLAGS=$boost_save_LDFLAGS
468 LIBS=$boost_save_LIBS
469 if test x"$Boost_lib" = xyes; then
2187934a
RK
470 # Check or used cached result of whether or not using -R or
471 # -rpath makes sense. Some implementations of ld, such as for
472 # Mac OSX, require -rpath but -R is the flag known to work on
473 # other systems. https://github.com/tsuna/boost.m4/issues/19
94ac5f34 474 AC_CACHE_VAL([boost_cv_rpath_link_ldflag],
2187934a
RK
475 [case $boost_ldpath in
476 '') # Nothing to do.
477 boost_cv_rpath_link_ldflag=
478 boost_rpath_link_ldflag_found=yes;;
479 *)
480 for boost_cv_rpath_link_ldflag in -Wl,-R, -Wl,-rpath,; do
481 LDFLAGS="$boost_save_LDFLAGS -L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath"
482 LIBS="$boost_save_LIBS $Boost_lib_LIBS"
483 _BOOST_AC_LINK_IFELSE([],
484 [boost_rpath_link_ldflag_found=yes
485 break],
486 [boost_rpath_link_ldflag_found=no])
487 done
488 ;;
489 esac
94ac5f34
PD
490 AS_IF([test "x$boost_rpath_link_ldflag_found" != "xyes"],
491 [AC_MSG_ERROR([Unable to determine whether to use -R or -rpath])])
492 LDFLAGS=$boost_save_LDFLAGS
493 LIBS=$boost_save_LIBS
494 ])
2187934a
RK
495 test x"$boost_ldpath" != x &&
496 Boost_lib_LDFLAGS="-L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath"
94ac5f34 497 Boost_lib_LDPATH="$boost_ldpath"
2187934a 498 break 7
94ac5f34
PD
499 else
500 boost_failed_libs="$boost_failed_libs@$boost_lib@"
501 fi
502 done
503 done
504done
505done
506done
507done
2187934a 508done # boost_lib_
94ac5f34
PD
509rm -f conftest.$ac_objext
510])
2187934a 511
94ac5f34
PD
512
513
514# --------------------------------------- #
515# Checks for the various Boost libraries. #
516# --------------------------------------- #
517
518# List of boost libraries: http://www.boost.org/libs/libraries.htm
519# The page http://beta.boost.org/doc/libs is useful: it gives the first release
520# version of each library (among other things).
521
522# BOOST_DEFUN(LIBRARY, CODE)
523# --------------------------
524# Define BOOST_<LIBRARY-UPPERCASE> as a macro that runs CODE.
525#
526# Use indir to avoid the warning on underquoted macro name given to AC_DEFUN.
527m4_define([BOOST_DEFUN],
528[m4_indir([AC_DEFUN],
529 m4_toupper([BOOST_$1]),
530[m4_pushdef([BOOST_Library], [$1])dnl
531$2
532m4_popdef([BOOST_Library])dnl
533])
534])
535
536# BOOST_ARRAY()
537# -------------
538# Look for Boost.Array
539BOOST_DEFUN([Array],
540[BOOST_FIND_HEADER([boost/array.hpp])])
541
542
543# BOOST_ASIO()
544# ------------
545# Look for Boost.Asio (new in Boost 1.35).
546BOOST_DEFUN([Asio],
547[AC_REQUIRE([BOOST_SYSTEM])dnl
548BOOST_FIND_HEADER([boost/asio.hpp])])
549
550
551# BOOST_BIND()
552# ------------
2187934a 553# Look for Boost.Bind.
94ac5f34
PD
554BOOST_DEFUN([Bind],
555[BOOST_FIND_HEADER([boost/bind.hpp])])
556
557
558# BOOST_CHRONO()
2187934a
RK
559# --------------
560# Look for Boost.Chrono.
94ac5f34
PD
561BOOST_DEFUN([Chrono],
562[# Do we have to check for Boost.System? This link-time dependency was
563# added as of 1.35.0. If we have a version <1.35, we must not attempt to
564# find Boost.System as it didn't exist by then.
565if test $boost_major_version -ge 135; then
2187934a 566 BOOST_SYSTEM([$1])
94ac5f34
PD
567fi # end of the Boost.System check.
568boost_filesystem_save_LIBS=$LIBS
569boost_filesystem_save_LDFLAGS=$LDFLAGS
570m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
571LIBS="$LIBS $BOOST_SYSTEM_LIBS"
572LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
573BOOST_FIND_LIB([chrono], [$1],
574 [boost/chrono.hpp],
575 [boost::chrono::thread_clock d;])
576if test $enable_static_boost = yes && test $boost_major_version -ge 135; then
b0d6e9e6 577 BOOST_CHRONO_LIBS="$BOOST_CHRONO_LIBS $BOOST_SYSTEM_LIBS"
94ac5f34
PD
578fi
579LIBS=$boost_filesystem_save_LIBS
580LDFLAGS=$boost_filesystem_save_LDFLAGS
94ac5f34
PD
581])# BOOST_CHRONO
582
583
2187934a
RK
584# BOOST_CONTEXT([PREFERRED-RT-OPT])
585# -----------------------------------
586# Look for Boost.Context. For the documentation of PREFERRED-RT-OPT, see the
587# documentation of BOOST_FIND_LIB above. This library was introduced in Boost
588# 1.51.0
589BOOST_DEFUN([Context],
590[BOOST_FIND_LIB([context], [$1],
591 [boost/context/all.hpp],[[
592// creates a stack
593void * stack_pointer = new void*[4096];
594std::size_t const size = sizeof(void*[4096]);
595
596// context fc uses f() as context function
597// fcontext_t is placed on top of context stack
598// a pointer to fcontext_t is returned
599fc = ctx::make_fcontext(stack_pointer, size, f);
600return ctx::jump_fcontext(&fcm, fc, 3) == 6;]],[dnl
601namespace ctx = boost::context;
602// context
603static ctx::fcontext_t fcm, *fc;
604// context-function
605static void f(intptr_t i) {
606 ctx::jump_fcontext(fc, &fcm, i * 2);
607}])
608])# BOOST_CONTEXT
609
610
94ac5f34
PD
611# BOOST_CONVERSION()
612# ------------------
613# Look for Boost.Conversion (cast / lexical_cast)
614BOOST_DEFUN([Conversion],
615[BOOST_FIND_HEADER([boost/cast.hpp])
616BOOST_FIND_HEADER([boost/lexical_cast.hpp])
617])# BOOST_CONVERSION
618
619
2187934a
RK
620# BOOST_COROUTINE([PREFERRED-RT-OPT])
621# -----------------------------------
622# Look for Boost.Coroutine. For the documentation of PREFERRED-RT-OPT, see the
623# documentation of BOOST_FIND_LIB above. This library was introduced in Boost
624# 1.53.0
625BOOST_DEFUN([Coroutine],
626[
627boost_coroutine_save_LIBS=$LIBS
628boost_coroutine_save_LDFLAGS=$LDFLAGS
629# Link-time dependency from coroutine to context
630BOOST_CONTEXT([$1])
631# Starting from Boost 1.55 a dependency on Boost.System is added
632if test $boost_major_version -ge 155; then
633 BOOST_SYSTEM([$1])
634fi
635m4_pattern_allow([^BOOST_(CONTEXT|SYSTEM)_(LIBS|LDFLAGS)])
636LIBS="$LIBS $BOOST_CONTEXT_LIBS $BOOST_SYSTEM_LIBS"
637LDFLAGS="$LDFLAGS $BOOST_CONTEXT_LDFLAGS"
638
639BOOST_FIND_LIB([coroutine], [$1],
640 [boost/coroutine/coroutine.hpp],
641 [boost::coroutines::coroutine< int(int) > coro; coro.empty();])
642
643# Link-time dependency from coroutine to context, existed only in 1.53, in 1.54
644# coroutine doesn't use context from its headers but from its library.
645if test $boost_major_version -eq 153 || test $enable_static_boost = yes && test $boost_major_version -ge 154; then
646 BOOST_COROUTINE_LIBS="$BOOST_COROUTINE_LIBS $BOOST_CONTEXT_LIBS"
647 BOOST_COROUTINE_LDFLAGS="$BOOST_COROUTINE_LDFLAGS $BOOST_CONTEXT_LDFLAGS"
648fi
649if test $enable_static_boost = yes && test $boost_major_version -ge 155; then
650 BOOST_COROUTINE_LIBS="$BOOST_COROUTINE_LIBS $BOOST_SYSTEM_LIBS"
651 BOOST_COROUTINE_LDFLAGS="$BOOST_COROUTINE_LDFLAGS $BOOST_SYSTEM_LDFLAGS"
652fi
653LIBS=$boost_coroutine_save_LIBS
654LDFLAGS=$boost_coroutine_save_LDFLAGS
655])# BOOST_COROUTINE
656
657
94ac5f34
PD
658# BOOST_CRC()
659# -----------
660# Look for Boost.CRC
661BOOST_DEFUN([CRC],
662[BOOST_FIND_HEADER([boost/crc.hpp])
663])# BOOST_CRC
664
665
666# BOOST_DATE_TIME([PREFERRED-RT-OPT])
667# -----------------------------------
668# Look for Boost.Date_Time. For the documentation of PREFERRED-RT-OPT, see the
669# documentation of BOOST_FIND_LIB above.
670BOOST_DEFUN([Date_Time],
671[BOOST_FIND_LIB([date_time], [$1],
672 [boost/date_time/posix_time/posix_time.hpp],
673 [boost::posix_time::ptime t;])
674])# BOOST_DATE_TIME
675
676
677# BOOST_FILESYSTEM([PREFERRED-RT-OPT])
678# ------------------------------------
679# Look for Boost.Filesystem. For the documentation of PREFERRED-RT-OPT, see
680# the documentation of BOOST_FIND_LIB above.
681# Do not check for boost/filesystem.hpp because this file was introduced in
682# 1.34.
683BOOST_DEFUN([Filesystem],
684[# Do we have to check for Boost.System? This link-time dependency was
685# added as of 1.35.0. If we have a version <1.35, we must not attempt to
686# find Boost.System as it didn't exist by then.
687if test $boost_major_version -ge 135; then
2187934a 688 BOOST_SYSTEM([$1])
94ac5f34
PD
689fi # end of the Boost.System check.
690boost_filesystem_save_LIBS=$LIBS
691boost_filesystem_save_LDFLAGS=$LDFLAGS
692m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
693LIBS="$LIBS $BOOST_SYSTEM_LIBS"
694LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
695BOOST_FIND_LIB([filesystem], [$1],
696 [boost/filesystem/path.hpp], [boost::filesystem::path p;])
697if test $enable_static_boost = yes && test $boost_major_version -ge 135; then
2187934a 698 BOOST_FILESYSTEM_LIBS="$BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS"
94ac5f34
PD
699fi
700LIBS=$boost_filesystem_save_LIBS
701LDFLAGS=$boost_filesystem_save_LDFLAGS
702])# BOOST_FILESYSTEM
703
704
2187934a
RK
705# BOOST_FLYWEIGHT()
706# -----------------
707# Look for Boost.Flyweight.
708BOOST_DEFUN([Flyweight],
709[dnl There's a hidden dependency on pthreads.
710AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl
711BOOST_FIND_HEADER([boost/flyweight.hpp])
712AC_SUBST([BOOST_FLYWEIGHT_LIBS], [$boost_cv_pthread_flag])
713])
714
715
94ac5f34
PD
716# BOOST_FOREACH()
717# ---------------
2187934a 718# Look for Boost.Foreach.
94ac5f34
PD
719BOOST_DEFUN([Foreach],
720[BOOST_FIND_HEADER([boost/foreach.hpp])])
721
722
723# BOOST_FORMAT()
724# --------------
2187934a 725# Look for Boost.Format.
94ac5f34
PD
726# Note: we can't check for boost/format/format_fwd.hpp because the header isn't
727# standalone. It can't be compiled because it triggers the following error:
728# boost/format/detail/config_macros.hpp:88: error: 'locale' in namespace 'std'
729# does not name a type
730BOOST_DEFUN([Format],
731[BOOST_FIND_HEADER([boost/format.hpp])])
732
733
734# BOOST_FUNCTION()
735# ----------------
736# Look for Boost.Function
737BOOST_DEFUN([Function],
738[BOOST_FIND_HEADER([boost/function.hpp])])
739
740
741# BOOST_GEOMETRY()
742# ----------------
743# Look for Boost.Geometry (new since 1.47.0).
744BOOST_DEFUN([Geometry],
745[BOOST_FIND_HEADER([boost/geometry.hpp])
746])# BOOST_GEOMETRY
747
748
749# BOOST_GRAPH([PREFERRED-RT-OPT])
750# -------------------------------
751# Look for Boost.Graphs. For the documentation of PREFERRED-RT-OPT, see the
752# documentation of BOOST_FIND_LIB above.
753BOOST_DEFUN([Graph],
754[BOOST_FIND_LIB([graph], [$1],
755 [boost/graph/adjacency_list.hpp], [boost::adjacency_list<> g;])
756])# BOOST_GRAPH
757
758
759# BOOST_IOSTREAMS([PREFERRED-RT-OPT])
760# -----------------------------------
761# Look for Boost.IOStreams. For the documentation of PREFERRED-RT-OPT, see the
762# documentation of BOOST_FIND_LIB above.
763BOOST_DEFUN([IOStreams],
764[BOOST_FIND_LIB([iostreams], [$1],
765 [boost/iostreams/device/file_descriptor.hpp],
766 [boost::iostreams::file_descriptor fd; fd.close();])
767])# BOOST_IOSTREAMS
768
769
770# BOOST_HASH()
771# ------------
772# Look for Boost.Functional/Hash
773BOOST_DEFUN([Hash],
774[BOOST_FIND_HEADER([boost/functional/hash.hpp])])
775
776
777# BOOST_LAMBDA()
778# --------------
779# Look for Boost.Lambda
780BOOST_DEFUN([Lambda],
781[BOOST_FIND_HEADER([boost/lambda/lambda.hpp])])
782
783
2187934a
RK
784# BOOST_LOCALE()
785# --------------
786# Look for Boost.Locale
787BOOST_DEFUN([Locale],
788[BOOST_FIND_LIB([locale], [$1],
789 [boost/locale.hpp],
790 [[boost::locale::generator gen; std::locale::global(gen(""));]])
791])# BOOST_LOCALE
792
94ac5f34
PD
793# BOOST_LOG([PREFERRED-RT-OPT])
794# -----------------------------
2187934a 795# Look for Boost.Log. For the documentation of PREFERRED-RT-OPT, see the
94ac5f34
PD
796# documentation of BOOST_FIND_LIB above.
797BOOST_DEFUN([Log],
798[BOOST_FIND_LIB([log], [$1],
799 [boost/log/core/core.hpp],
800 [boost::log::attribute a; a.get_value();])
801])# BOOST_LOG
802
803
804# BOOST_LOG_SETUP([PREFERRED-RT-OPT])
805# -----------------------------------
2187934a 806# Look for Boost.Log. For the documentation of PREFERRED-RT-OPT, see the
94ac5f34
PD
807# documentation of BOOST_FIND_LIB above.
808BOOST_DEFUN([Log_Setup],
809[AC_REQUIRE([BOOST_LOG])dnl
810BOOST_FIND_LIB([log_setup], [$1],
2187934a 811 [boost/log/utility/setup/from_settings.hpp],
94ac5f34
PD
812 [boost::log::basic_settings<char> bs; bs.empty();])
813])# BOOST_LOG_SETUP
814
815
816# BOOST_MATH()
817# ------------
818# Look for Boost.Math
819# TODO: This library isn't header-only but it comes in multiple different
820# flavors that don't play well with BOOST_FIND_LIB (e.g, libboost_math_c99,
821# libboost_math_c99f, libboost_math_c99l, libboost_math_tr1,
822# libboost_math_tr1f, libboost_math_tr1l). This macro must be fixed to do the
823# right thing anyway.
824BOOST_DEFUN([Math],
825[BOOST_FIND_HEADER([boost/math/special_functions.hpp])])
826
827
2187934a
RK
828# BOOST_MPI([PREFERRED-RT-OPT])
829# -------------------------------
830# Look for Boost MPI. For the documentation of PREFERRED-RT-OPT, see the
831# documentation of BOOST_FIND_LIB above. Uses MPICXX variable if it is
832# set, otherwise tries CXX
833#
834BOOST_DEFUN([MPI],
835[boost_save_CXX=${CXX}
836boost_save_CXXCPP=${CXXCPP}
837if test x"${MPICXX}" != x; then
838 CXX=${MPICXX}
839 CXXCPP="${MPICXX} -E"
840fi
841BOOST_FIND_LIB([mpi], [$1],
842 [boost/mpi.hpp],
843 [int argc = 0;
844 char **argv = 0;
845 boost::mpi::environment env(argc,argv);])
846CXX=${boost_save_CXX}
847CXXCPP=${boost_save_CXXCPP}
848])# BOOST_MPI
849
850
94ac5f34
PD
851# BOOST_MULTIARRAY()
852# ------------------
853# Look for Boost.MultiArray
854BOOST_DEFUN([MultiArray],
855[BOOST_FIND_HEADER([boost/multi_array.hpp])])
856
857
2187934a
RK
858# BOOST_NUMERIC_UBLAS()
859# --------------------------
860# Look for Boost.NumericUblas (Basic Linear Algebra)
861BOOST_DEFUN([Numeric_Ublas],
862[BOOST_FIND_HEADER([boost/numeric/ublas/vector.hpp])
863])# BOOST_NUMERIC_UBLAS
864
865
94ac5f34
PD
866# BOOST_NUMERIC_CONVERSION()
867# --------------------------
868# Look for Boost.NumericConversion (policy-based numeric conversion)
869BOOST_DEFUN([Numeric_Conversion],
870[BOOST_FIND_HEADER([boost/numeric/conversion/converter.hpp])
871])# BOOST_NUMERIC_CONVERSION
872
873
874# BOOST_OPTIONAL()
875# ----------------
876# Look for Boost.Optional
877BOOST_DEFUN([Optional],
878[BOOST_FIND_HEADER([boost/optional.hpp])])
879
880
881# BOOST_PREPROCESSOR()
882# --------------------
883# Look for Boost.Preprocessor
884BOOST_DEFUN([Preprocessor],
885[BOOST_FIND_HEADER([boost/preprocessor/repeat.hpp])])
886
887
2187934a
RK
888# BOOST_RANGE()
889# --------------------
890# Look for Boost.Range
891BOOST_DEFUN([Range],
892[BOOST_FIND_HEADER([boost/range/adaptors.hpp])])
893
94ac5f34
PD
894# BOOST_UNORDERED()
895# -----------------
896# Look for Boost.Unordered
897BOOST_DEFUN([Unordered],
898[BOOST_FIND_HEADER([boost/unordered_map.hpp])])
899
900
901# BOOST_UUID()
902# ------------
903# Look for Boost.Uuid
904BOOST_DEFUN([Uuid],
905[BOOST_FIND_HEADER([boost/uuid/uuid.hpp])])
906
907
908# BOOST_PROGRAM_OPTIONS([PREFERRED-RT-OPT])
909# -----------------------------------------
910# Look for Boost.Program_options. For the documentation of PREFERRED-RT-OPT,
911# see the documentation of BOOST_FIND_LIB above.
912BOOST_DEFUN([Program_Options],
913[BOOST_FIND_LIB([program_options], [$1],
914 [boost/program_options.hpp],
915 [boost::program_options::options_description d("test");])
916])# BOOST_PROGRAM_OPTIONS
917
918
919
920# _BOOST_PYTHON_CONFIG(VARIABLE, FLAG)
921# ------------------------------------
922# Save VARIABLE, and define it via `python-config --FLAG`.
923# Substitute BOOST_PYTHON_VARIABLE.
924m4_define([_BOOST_PYTHON_CONFIG],
925[AC_SUBST([BOOST_PYTHON_$1],
926 [`python-config --$2 2>/dev/null`])dnl
927boost_python_save_$1=$$1
928$1="$$1 $BOOST_PYTHON_$1"])
929
930
931# BOOST_PYTHON([PREFERRED-RT-OPT])
932# --------------------------------
933# Look for Boost.Python. For the documentation of PREFERRED-RT-OPT,
934# see the documentation of BOOST_FIND_LIB above.
935BOOST_DEFUN([Python],
936[_BOOST_PYTHON_CONFIG([CPPFLAGS], [includes])
937_BOOST_PYTHON_CONFIG([LDFLAGS], [ldflags])
938_BOOST_PYTHON_CONFIG([LIBS], [libs])
939m4_pattern_allow([^BOOST_PYTHON_MODULE$])dnl
2187934a
RK
940BOOST_FIND_LIBS([python], [python python3], [$1],
941 [boost/python.hpp],
942 [], [BOOST_PYTHON_MODULE(empty) {}])
94ac5f34
PD
943CPPFLAGS=$boost_python_save_CPPFLAGS
944LDFLAGS=$boost_python_save_LDFLAGS
945LIBS=$boost_python_save_LIBS
946])# BOOST_PYTHON
947
948
949# BOOST_REF()
950# -----------
951# Look for Boost.Ref
952BOOST_DEFUN([Ref],
953[BOOST_FIND_HEADER([boost/ref.hpp])])
954
955
956# BOOST_REGEX([PREFERRED-RT-OPT])
957# -------------------------------
958# Look for Boost.Regex. For the documentation of PREFERRED-RT-OPT, see the
959# documentation of BOOST_FIND_LIB above.
960BOOST_DEFUN([Regex],
961[BOOST_FIND_LIB([regex], [$1],
962 [boost/regex.hpp],
963 [boost::regex exp("*"); boost::regex_match("foo", exp);])
964])# BOOST_REGEX
965
966
967# BOOST_SERIALIZATION([PREFERRED-RT-OPT])
968# ---------------------------------------
969# Look for Boost.Serialization. For the documentation of PREFERRED-RT-OPT, see
970# the documentation of BOOST_FIND_LIB above.
971BOOST_DEFUN([Serialization],
972[BOOST_FIND_LIB([serialization], [$1],
973 [boost/archive/text_oarchive.hpp],
974 [std::ostream* o = 0; // Cheap way to get an ostream...
975 boost::archive::text_oarchive t(*o);])
976])# BOOST_SERIALIZATION
977
978
979# BOOST_SIGNALS([PREFERRED-RT-OPT])
980# ---------------------------------
981# Look for Boost.Signals. For the documentation of PREFERRED-RT-OPT, see the
982# documentation of BOOST_FIND_LIB above.
983BOOST_DEFUN([Signals],
984[BOOST_FIND_LIB([signals], [$1],
985 [boost/signal.hpp],
986 [boost::signal<void ()> s;])
987])# BOOST_SIGNALS
988
989
990# BOOST_SIGNALS2()
991# ----------------
992# Look for Boost.Signals2 (new since 1.39.0).
993BOOST_DEFUN([Signals2],
994[BOOST_FIND_HEADER([boost/signals2.hpp])
995])# BOOST_SIGNALS2
996
997
998# BOOST_SMART_PTR()
999# -----------------
1000# Look for Boost.SmartPtr
1001BOOST_DEFUN([Smart_Ptr],
1002[BOOST_FIND_HEADER([boost/scoped_ptr.hpp])
1003BOOST_FIND_HEADER([boost/shared_ptr.hpp])
1004])
1005
1006
1007# BOOST_STATICASSERT()
1008# --------------------
1009# Look for Boost.StaticAssert
1010BOOST_DEFUN([StaticAssert],
1011[BOOST_FIND_HEADER([boost/static_assert.hpp])])
1012
1013
1014# BOOST_STRING_ALGO()
1015# -------------------
1016# Look for Boost.StringAlgo
1017BOOST_DEFUN([String_Algo],
1018[BOOST_FIND_HEADER([boost/algorithm/string.hpp])
1019])
1020
1021
1022# BOOST_SYSTEM([PREFERRED-RT-OPT])
1023# --------------------------------
1024# Look for Boost.System. For the documentation of PREFERRED-RT-OPT, see the
1025# documentation of BOOST_FIND_LIB above. This library was introduced in Boost
1026# 1.35.0.
1027BOOST_DEFUN([System],
1028[BOOST_FIND_LIB([system], [$1],
1029 [boost/system/error_code.hpp],
1030 [boost::system::error_code e; e.clear();])
1031])# BOOST_SYSTEM
1032
1033
1034# BOOST_TEST([PREFERRED-RT-OPT])
1035# ------------------------------
1036# Look for Boost.Test. For the documentation of PREFERRED-RT-OPT, see the
1037# documentation of BOOST_FIND_LIB above.
1038BOOST_DEFUN([Test],
1039[m4_pattern_allow([^BOOST_CHECK$])dnl
1040BOOST_FIND_LIB([unit_test_framework], [$1],
1041 [boost/test/unit_test.hpp], [BOOST_CHECK(2 == 2);],
1042 [using boost::unit_test::test_suite;
1043 test_suite* init_unit_test_suite(int argc, char ** argv)
1044 { return NULL; }])
1045])# BOOST_TEST
1046
1047
2187934a 1048# BOOST_THREAD([PREFERRED-RT-OPT])
94ac5f34
PD
1049# ---------------------------------
1050# Look for Boost.Thread. For the documentation of PREFERRED-RT-OPT, see the
1051# documentation of BOOST_FIND_LIB above.
2187934a 1052BOOST_DEFUN([Thread],
94ac5f34
PD
1053[dnl Having the pthread flag is required at least on GCC3 where
1054dnl boost/thread.hpp would complain if we try to compile without
1055dnl -pthread on GNU/Linux.
1056AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl
2187934a
RK
1057boost_thread_save_LIBS=$LIBS
1058boost_thread_save_LDFLAGS=$LDFLAGS
1059boost_thread_save_CPPFLAGS=$CPPFLAGS
94ac5f34
PD
1060# Link-time dependency from thread to system was added as of 1.49.0.
1061if test $boost_major_version -ge 149; then
1062BOOST_SYSTEM([$1])
1063fi # end of the Boost.System check.
1064m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
1065LIBS="$LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag"
1066LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
94ac5f34
PD
1067CPPFLAGS="$CPPFLAGS $boost_cv_pthread_flag"
1068
1069# When compiling for the Windows platform, the threads library is named
b0d6e9e6
KM
1070# differently. This suffix doesn't exist in new versions of Boost, or
1071# possibly new versions of GCC on mingw I am assuming it's Boost's change for
1072# now and I am setting version to 1.48, for lack of knowledge as to when this
1073# change occurred.
1074if test $boost_major_version -lt 148; then
1075 case $host_os in
1076 (*mingw*) boost_thread_lib_ext=_win32;;
1077 esac
1078fi
2187934a
RK
1079BOOST_FIND_LIBS([thread], [thread$boost_thread_lib_ext],
1080 [$1],
1081 [boost/thread.hpp], [boost::thread t; boost::mutex m;])
94ac5f34 1082
b0d6e9e6
KM
1083case $host_os in
1084 (*mingw*) boost_thread_w32_socket_link=-lws2_32;;
1085esac
1086
1087BOOST_THREAD_LIBS="$BOOST_THREAD_LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag $boost_thread_w32_socket_link"
94ac5f34
PD
1088BOOST_THREAD_LDFLAGS="$BOOST_SYSTEM_LDFLAGS"
1089BOOST_CPPFLAGS="$BOOST_CPPFLAGS $boost_cv_pthread_flag"
2187934a
RK
1090LIBS=$boost_thread_save_LIBS
1091LDFLAGS=$boost_thread_save_LDFLAGS
1092CPPFLAGS=$boost_thread_save_CPPFLAGS
1093])# BOOST_THREAD
1094
1095AU_ALIAS([BOOST_THREADS], [BOOST_THREAD])
94ac5f34
PD
1096
1097
1098# BOOST_TOKENIZER()
1099# -----------------
1100# Look for Boost.Tokenizer
1101BOOST_DEFUN([Tokenizer],
1102[BOOST_FIND_HEADER([boost/tokenizer.hpp])])
1103
1104
1105# BOOST_TRIBOOL()
1106# ---------------
1107# Look for Boost.Tribool
1108BOOST_DEFUN([Tribool],
1109[BOOST_FIND_HEADER([boost/logic/tribool_fwd.hpp])
1110BOOST_FIND_HEADER([boost/logic/tribool.hpp])
1111])
1112
1113
1114# BOOST_TUPLE()
1115# -------------
1116# Look for Boost.Tuple
1117BOOST_DEFUN([Tuple],
1118[BOOST_FIND_HEADER([boost/tuple/tuple.hpp])])
1119
1120
1121# BOOST_TYPETRAITS()
1122# --------------------
1123# Look for Boost.TypeTraits
1124BOOST_DEFUN([TypeTraits],
1125[BOOST_FIND_HEADER([boost/type_traits.hpp])])
1126
1127
1128# BOOST_UTILITY()
1129# ---------------
1130# Look for Boost.Utility (noncopyable, result_of, base-from-member idiom,
1131# etc.)
1132BOOST_DEFUN([Utility],
1133[BOOST_FIND_HEADER([boost/utility.hpp])])
1134
1135
1136# BOOST_VARIANT()
1137# ---------------
1138# Look for Boost.Variant.
1139BOOST_DEFUN([Variant],
1140[BOOST_FIND_HEADER([boost/variant/variant_fwd.hpp])
1141BOOST_FIND_HEADER([boost/variant.hpp])])
1142
2187934a
RK
1143
1144# BOOST_POINTER_CONTAINER()
94ac5f34
PD
1145# ------------------------
1146# Look for Boost.PointerContainer
1147BOOST_DEFUN([Pointer_Container],
1148[BOOST_FIND_HEADER([boost/ptr_container/ptr_deque.hpp])
1149BOOST_FIND_HEADER([boost/ptr_container/ptr_list.hpp])
1150BOOST_FIND_HEADER([boost/ptr_container/ptr_vector.hpp])
1151BOOST_FIND_HEADER([boost/ptr_container/ptr_array.hpp])
1152BOOST_FIND_HEADER([boost/ptr_container/ptr_set.hpp])
1153BOOST_FIND_HEADER([boost/ptr_container/ptr_map.hpp])
2187934a
RK
1154])# BOOST_POINTER_CONTAINER
1155
94ac5f34
PD
1156
1157# BOOST_WAVE([PREFERRED-RT-OPT])
1158# ------------------------------
1159# NOTE: If you intend to use Wave/Spirit with thread support, make sure you
2187934a 1160# call BOOST_THREAD first.
94ac5f34
PD
1161# Look for Boost.Wave. For the documentation of PREFERRED-RT-OPT, see the
1162# documentation of BOOST_FIND_LIB above.
1163BOOST_DEFUN([Wave],
1164[AC_REQUIRE([BOOST_FILESYSTEM])dnl
1165AC_REQUIRE([BOOST_DATE_TIME])dnl
1166boost_wave_save_LIBS=$LIBS
1167boost_wave_save_LDFLAGS=$LDFLAGS
1168m4_pattern_allow([^BOOST_((FILE)?SYSTEM|DATE_TIME|THREAD)_(LIBS|LDFLAGS)$])dnl
1169LIBS="$LIBS $BOOST_SYSTEM_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_DATE_TIME_LIBS \
1170$BOOST_THREAD_LIBS"
1171LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS \
1172$BOOST_DATE_TIME_LDFLAGS $BOOST_THREAD_LDFLAGS"
1173BOOST_FIND_LIB([wave], [$1],
1174 [boost/wave.hpp],
1175 [boost::wave::token_id id; get_token_name(id);])
1176LIBS=$boost_wave_save_LIBS
1177LDFLAGS=$boost_wave_save_LDFLAGS
1178])# BOOST_WAVE
1179
1180
1181# BOOST_XPRESSIVE()
1182# -----------------
1183# Look for Boost.Xpressive (new since 1.36.0).
1184BOOST_DEFUN([Xpressive],
1185[BOOST_FIND_HEADER([boost/xpressive/xpressive.hpp])])
1186
1187
1188# ----------------- #
1189# Internal helpers. #
1190# ----------------- #
1191
1192
1193# _BOOST_PTHREAD_FLAG()
1194# ---------------------
2187934a
RK
1195# Internal helper for BOOST_THREAD. Computes boost_cv_pthread_flag
1196# which must be used in CPPFLAGS and LIBS.
1197#
1198# Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3,
1199# boost/thread.hpp will trigger a #error if -pthread isn't used:
1200# boost/config/requires_threads.hpp:47:5: #error "Compiler threading support
1201# is not turned on. Please set the correct command line options for
1202# threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
1203#
1204# Based on ACX_PTHREAD: http://autoconf-archive.cryp.to/acx_pthread.html
94ac5f34
PD
1205AC_DEFUN([_BOOST_PTHREAD_FLAG],
1206[AC_REQUIRE([AC_PROG_CXX])dnl
1207AC_REQUIRE([AC_CANONICAL_HOST])dnl
1208AC_LANG_PUSH([C++])dnl
1209AC_CACHE_CHECK([for the flags needed to use pthreads], [boost_cv_pthread_flag],
1210[ boost_cv_pthread_flag=
1211 # The ordering *is* (sometimes) important. Some notes on the
1212 # individual items follow:
1213 # (none): in case threads are in libc; should be tried before -Kthread and
1214 # other compiler flags to prevent continual compiler warnings
1215 # -lpthreads: AIX (must check this before -lpthread)
1216 # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
1217 # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
1218 # -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
1219 # -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads)
1220 # -pthreads: Solaris/GCC
1221 # -mthreads: MinGW32/GCC, Lynx/GCC
1222 # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
1223 # doesn't hurt to check since this sometimes defines pthreads too;
1224 # also defines -D_REENTRANT)
1225 # ... -mt is also the pthreads flag for HP/aCC
1226 # -lpthread: GNU Linux, etc.
1227 # --thread-safe: KAI C++
1228 case $host_os in #(
1229 *solaris*)
1230 # On Solaris (at least, for some versions), libc contains stubbed
1231 # (non-functional) versions of the pthreads routines, so link-based
1232 # tests will erroneously succeed. (We need to link with -pthreads/-mt/
1233 # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
1234 # a function called by this macro, so we could check for that, but
1235 # who knows whether they'll stub that too in a future libc.) So,
1236 # we'll just look for -pthreads and -lpthread first:
1237 boost_pthread_flags="-pthreads -lpthread -mt -pthread";; #(
1238 *)
1239 boost_pthread_flags="-lpthreads -Kthread -kthread -llthread -pthread \
1240 -pthreads -mthreads -lpthread --thread-safe -mt";;
1241 esac
1242 # Generate the test file.
1243 AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <pthread.h>],
1244 [pthread_t th; pthread_join(th, 0);
1245 pthread_attr_init(0); pthread_cleanup_push(0, 0);
1246 pthread_create(0,0,0,0); pthread_cleanup_pop(0);])])
1247 for boost_pthread_flag in '' $boost_pthread_flags; do
1248 boost_pthread_ok=false
1249dnl Re-use the test file already generated.
1250 boost_pthreads__save_LIBS=$LIBS
1251 LIBS="$LIBS $boost_pthread_flag"
1252 AC_LINK_IFELSE([],
1253 [if grep ".*$boost_pthread_flag" conftest.err; then
1254 echo "This flag seems to have triggered warnings" >&AS_MESSAGE_LOG_FD
1255 else
1256 boost_pthread_ok=:; boost_cv_pthread_flag=$boost_pthread_flag
1257 fi])
1258 LIBS=$boost_pthreads__save_LIBS
1259 $boost_pthread_ok && break
1260 done
1261])
1262AC_LANG_POP([C++])dnl
1263])# _BOOST_PTHREAD_FLAG
1264
1265
1266# _BOOST_gcc_test(MAJOR, MINOR)
1267# -----------------------------
1268# Internal helper for _BOOST_FIND_COMPILER_TAG.
1269m4_define([_BOOST_gcc_test],
1270["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC @ gcc$1$2"])dnl
1271
2187934a
RK
1272# _BOOST_mingw_test(MAJOR, MINOR)
1273# -----------------------------
1274# Internal helper for _BOOST_FIND_COMPILER_TAG.
1275m4_define([_BOOST_mingw_test],
1276["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC && \
1277 (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \
1278 || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw$1$2"])dnl
1279
94ac5f34
PD
1280
1281# _BOOST_FIND_COMPILER_TAG()
1282# --------------------------
1283# Internal. When Boost is installed without --layout=system, each library
1284# filename will hold a suffix that encodes the compiler used during the
1285# build. The Boost build system seems to call this a `tag'.
1286AC_DEFUN([_BOOST_FIND_COMPILER_TAG],
1287[AC_REQUIRE([AC_PROG_CXX])dnl
1288AC_REQUIRE([AC_CANONICAL_HOST])dnl
2187934a
RK
1289AC_CACHE_CHECK([for the toolset name used by Boost for $CXX],
1290 [boost_cv_lib_tag],
94ac5f34
PD
1291[boost_cv_lib_tag=unknown
1292if test x$boost_cv_inc_path != xno; then
1293 AC_LANG_PUSH([C++])dnl
1294 # The following tests are mostly inspired by boost/config/auto_link.hpp
1295 # The list is sorted to most recent/common to oldest compiler (in order
1296 # to increase the likelihood of finding the right compiler with the
1297 # least number of compilation attempt).
1298 # Beware that some tests are sensible to the order (for instance, we must
1299 # look for MinGW before looking for GCC3).
1300 # I used one compilation test per compiler with a #error to recognize
1301 # each compiler so that it works even when cross-compiling (let me know
1302 # if you know a better approach).
1303 # Known missing tags (known from Boost's tools/build/v2/tools/common.jam):
1304 # como, edg, kcc, bck, mp, sw, tru, xlc
1305 # I'm not sure about my test for `il' (be careful: Intel's ICC pre-defines
1306 # the same defines as GCC's).
1307 for i in \
fe6a830f
PL
1308 _BOOST_mingw_test(5, 2) \
1309 _BOOST_gcc_test(5, 2) \
016ed2c1
RK
1310 _BOOST_mingw_test(5, 1) \
1311 _BOOST_gcc_test(5, 1) \
2187934a
RK
1312 _BOOST_mingw_test(5, 0) \
1313 _BOOST_gcc_test(5, 0) \
1314 _BOOST_mingw_test(4, 10) \
1315 _BOOST_gcc_test(4, 10) \
1316 _BOOST_mingw_test(4, 9) \
94ac5f34 1317 _BOOST_gcc_test(4, 9) \
2187934a 1318 _BOOST_mingw_test(4, 8) \
94ac5f34 1319 _BOOST_gcc_test(4, 8) \
2187934a 1320 _BOOST_mingw_test(4, 7) \
94ac5f34 1321 _BOOST_gcc_test(4, 7) \
2187934a 1322 _BOOST_mingw_test(4, 6) \
94ac5f34 1323 _BOOST_gcc_test(4, 6) \
2187934a 1324 _BOOST_mingw_test(4, 5) \
94ac5f34 1325 _BOOST_gcc_test(4, 5) \
2187934a 1326 _BOOST_mingw_test(4, 4) \
94ac5f34 1327 _BOOST_gcc_test(4, 4) \
2187934a 1328 _BOOST_mingw_test(4, 3) \
94ac5f34 1329 _BOOST_gcc_test(4, 3) \
2187934a 1330 _BOOST_mingw_test(4, 2) \
94ac5f34 1331 _BOOST_gcc_test(4, 2) \
2187934a 1332 _BOOST_mingw_test(4, 1) \
94ac5f34 1333 _BOOST_gcc_test(4, 1) \
2187934a 1334 _BOOST_mingw_test(4, 0) \
94ac5f34
PD
1335 _BOOST_gcc_test(4, 0) \
1336 "defined __GNUC__ && __GNUC__ == 3 && !defined __ICC \
1337 && (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \
1338 || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw" \
1339 _BOOST_gcc_test(3, 4) \
1340 _BOOST_gcc_test(3, 3) \
1341 "defined _MSC_VER && _MSC_VER >= 1500 @ vc90" \
1342 "defined _MSC_VER && _MSC_VER == 1400 @ vc80" \
1343 _BOOST_gcc_test(3, 2) \
1344 "defined _MSC_VER && _MSC_VER == 1310 @ vc71" \
1345 _BOOST_gcc_test(3, 1) \
1346 _BOOST_gcc_test(3, 0) \
1347 "defined __BORLANDC__ @ bcb" \
1348 "defined __ICC && (defined __unix || defined __unix__) @ il" \
1349 "defined __ICL @ iw" \
1350 "defined _MSC_VER && _MSC_VER == 1300 @ vc7" \
1351 _BOOST_gcc_test(2, 95) \
1352 "defined __MWERKS__ && __MWERKS__ <= 0x32FF @ cw9" \
1353 "defined _MSC_VER && _MSC_VER < 1300 && !defined UNDER_CE @ vc6" \
1354 "defined _MSC_VER && _MSC_VER < 1300 && defined UNDER_CE @ evc4" \
1355 "defined __MWERKS__ && __MWERKS__ <= 0x31FF @ cw8"
1356 do
1357 boost_tag_test=`expr "X$i" : 'X\([[^@]]*\) @ '`
1358 boost_tag=`expr "X$i" : 'X[[^@]]* @ \(.*\)'`
1359 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1360#if $boost_tag_test
1361/* OK */
1362#else
1363# error $boost_tag_test
1364#endif
1365]])], [boost_cv_lib_tag=$boost_tag; break], [])
1366 done
1367AC_LANG_POP([C++])dnl
1368 case $boost_cv_lib_tag in #(
1369 # Some newer (>= 1.35?) versions of Boost seem to only use "gcc" as opposed
1370 # to "gcc41" for instance.
1371 *-gcc | *'-gcc ') :;; #( Don't re-add -gcc: it's already in there.
1372 gcc*)
1373 boost_tag_x=
1374 case $host_os in #(
1375 darwin*)
1376 if test $boost_major_version -ge 136; then
1377 # The `x' added in r46793 of Boost.
1378 boost_tag_x=x
1379 fi;;
1380 esac
1381 # We can specify multiple tags in this variable because it's used by
1382 # BOOST_FIND_LIB that does a `for tag in -$boost_cv_lib_tag' ...
1383 boost_cv_lib_tag="$boost_tag_x$boost_cv_lib_tag -${boost_tag_x}gcc"
1384 ;; #(
1385 unknown)
1386 AC_MSG_WARN([[could not figure out which toolset name to use for $CXX]])
1387 boost_cv_lib_tag=
1388 ;;
1389 esac
1390fi])dnl end of AC_CACHE_CHECK
1391])# _BOOST_FIND_COMPILER_TAG
1392
1393
1394# _BOOST_GUESS_WHETHER_TO_USE_MT()
1395# --------------------------------
1396# Compile a small test to try to guess whether we should favor MT (Multi
1397# Thread) flavors of Boost. Sets boost_guess_use_mt accordingly.
1398AC_DEFUN([_BOOST_GUESS_WHETHER_TO_USE_MT],
1399[# Check whether we do better use `mt' even though we weren't ask to.
2187934a 1400AC_LANG_PUSH([C++])dnl
94ac5f34
PD
1401AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1402#if defined _REENTRANT || defined _MT || defined __MT__
1403/* use -mt */
1404#else
1405# error MT not needed
1406#endif
1407]])], [boost_guess_use_mt=:], [boost_guess_use_mt=false])
2187934a 1408AC_LANG_POP([C++])dnl
94ac5f34
PD
1409])
1410
1411# _BOOST_AC_LINK_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
1412# -------------------------------------------------------------------
1413# Fork of _AC_LINK_IFELSE that preserves conftest.o across calls. Fragile,
1414# will break when Autoconf changes its internals. Requires that you manually
1415# rm -f conftest.$ac_objext in between to really different tests, otherwise
1416# you will try to link a conftest.o left behind by a previous test.
1417# Used to aggressively optimize BOOST_FIND_LIB (see the big comment in this
1418# macro).
1419#
1420# Don't use "break" in the actions, as it would short-circuit some code
1421# this macro runs after the actions.
1422m4_define([_BOOST_AC_LINK_IFELSE],
1423[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
1424rm -f conftest$ac_exeext
1425boost_save_ac_ext=$ac_ext
1426boost_use_source=:
1427# If we already have a .o, re-use it. We change $ac_ext so that $ac_link
1428# tries to link the existing object file instead of compiling from source.
1429test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false &&
1430 _AS_ECHO_LOG([re-using the existing conftest.$ac_objext])
1431AS_IF([_AC_DO_STDERR($ac_link) && {
2187934a
RK
1432 test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" ||
1433 test ! -s conftest.err
94ac5f34 1434 } && test -s conftest$ac_exeext && {
2187934a
RK
1435 test "$cross_compiling" = yes ||
1436 $as_executable_p conftest$ac_exeext
94ac5f34
PD
1437dnl FIXME: use AS_TEST_X instead when 2.61 is widespread enough.
1438 }],
1439 [$2],
1440 [if $boost_use_source; then
1441 _AC_MSG_LOG_CONFTEST
1442 fi
1443 $3])
1444ac_objext=$boost_save_ac_objext
1445ac_ext=$boost_save_ac_ext
1446dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization)
1447dnl information created by the PGI compiler (conftest_ipa8_conftest.oo),
1448dnl as it would interfere with the next link command.
1449rm -f core conftest.err conftest_ipa8_conftest.oo \
1450 conftest$ac_exeext m4_ifval([$1], [conftest.$ac_ext])[]dnl
1451])# _BOOST_AC_LINK_IFELSE
1452
1453# Local Variables:
1454# mode: autoconf
1455# End: