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