Use Libtool and -R to encode run paths.
[boost.m4.git] / build-aux / boost.m4
blob1cd09f0db4ba6da62e92bbfaf61e50188fe0f822
1 # boost.m4: Locate Boost headers and libraries for autoconf-based projects.
2 # Copyright (C) 2007  Benoit Sigoure <tsuna@lrde.epita.fr>
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 # serial 1
18 # Original sources can be found at http://repo.or.cz/w/boost.m4.git
19 # You can fetch the latest version of the script by doing:
20 #   wget 'http://repo.or.cz/w/boost.m4.git?a=blob_plain;f=build-aux/boost.m4;hb=HEAD' -O boost.m4
22 # ------ #
23 # README #
24 # ------ #
26 # This file provides several macros to use the various Boost libraries.
27 # The first macro is BOOST_REQUIRE.  It will simply check if it's possible to
28 # find the Boost headers of a given (optional) minimum version and it will
29 # define BOOST_CPPFLAGS accordingly.  It will add an option --with-boost to
30 # your configure so that users can specify non standard locations.
31 # For more README and documentation, go to http://repo.or.cz/w/boost.m4.git
33 m4_pattern_forbid([^_?BOOST_])
35 # BOOST_REQUIRE([VERSION])
36 # ------------------------
37 # Look for Boost.  If version is given, it must either be a literal of the form
38 # "X.Y" where X and Y are integers or a variable "$var".
39 # Defines the value BOOST_CPPFLAGS.  This macro only checks for headers with
40 # the required version, it does not check for any of the Boost libraries.
41 # FIXME: Add a 2nd optionnal argument so that it's not fatal if Boost isn't found
42 # and add an AC_DEFINE to tell whether HAVE_BOOST.
43 AC_DEFUN([BOOST_REQUIRE],
44 [dnl First find out what kind of argument we have.
45 dnl If we have an empty argument, there is no constraint on the version of
46 dnl Boost to use.  If it's a literal version number, we can split it in M4 (so
47 dnl the resulting configure script will be smaller/faster).  Otherwise we do
48 dnl the splitting at runtime.
49 m4_bmatch([$1],
50   [^ *$], [m4_pushdef([BOOST_VERSION_REQ], [])dnl
51            boost_version_major=0
52            boost_version_minor=0
53            boost_version_subminor=0
55   [^[0-9]+\([-._][0-9]+\)*$],
56     [m4_pushdef([BOOST_VERSION_REQ], [ version >= $1])dnl
57      boost_version_major=m4_bregexp([$1], [^\([0-9]+\)], [\1])
58      boost_version_minor=m4_bregexp([$1], [^[0-9]+[-._]\([0-9]+\)], [\1])
59      boost_version_subminor=m4_bregexp([$1], [^[0-9]+[-._][0-9]+[-._]\([0-9]+\)], [\1])
61   [^\$[a-zA-Z_]+$],
62     [m4_pushdef([BOOST_VERSION_REQ], [])dnl
63      boost_version_major=`expr "X$1" : 'X\([[^-._]]*\)'`
64      boost_version_minor=`expr "X$1" : 'X[[0-9]]*[[-._]]\([[^-._]]*\)'`
65      boost_version_subminor=`expr "X$1" : 'X[[0-9]]*[[-._]][[0-9]]*[[-._]]\([[0-9]]*\)'`
66      case $boost_version_major:$boost_version_minor in #(
67        *: | :* | *[[^0-9]]*:* | *:*[[^0-9]]*)
68          AC_MSG_ERROR([[Invalid argument for REQUIRE_BOOST: `$1']])
69          ;;
70      esac
72   [m4_fatal(Invalid argument: `$1')]
73 )dnl
74 AC_ARG_WITH([boost],
75    [AS_HELP_STRING([--with-boost=DIR],
76                    [prefix of Boost]BOOST_VERSION_REQ[ @<:@guess@:>@])])dnl
77 AC_SUBST([DISTCHECK_CONFIGURE_FLAGS],
78          ["$DISTCHECK_CONFIGURE_FLAGS '--with-boost=$with_boost'"])
79   AC_CACHE_CHECK([for Boost headers[]BOOST_VERSION_REQ],
80     [boost_cv_inc_path],
81     [boost_cv_inc_path=no
82 AC_LANG_PUSH([C++])dnl
83     boost_subminor_chk=
84     test x"$boost_version_subminor" != x \
85       && boost_subminor_chk="|| (B_V_MAJ == $boost_version_major \
86 && B_V_MIN == $boost_version_minor \
87 && B_V_SUB % 100 < $boost_version_subminor)"
88     for boost_inc in "$with_boost/include" '' \
89              /opt/local/include /usr/local/include /opt/include /usr/include \
90              "$with_boost" C:/Boost/include
91     do
92       test -e "$boost_inc" || continue
93       boost_save_CPPFLAGS=$CPPFLAGS
94       test x"$boost_inc" != x && CPPFLAGS="$CPPFLAGS -I$boost_inc"
95 m4_pattern_allow([^BOOST_VERSION$])dnl
96       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <boost/version.hpp>
97 #ifndef BOOST_VERSION
98 # error BOOST_VERSION is not defined
99 #endif
100 #define B_V_MAJ (BOOST_VERSION / 10000)
101 #define B_V_MIN (BOOST_VERSION / 100 % 1000)
102 #define B_V_SUB (BOOST_VERSION % 100)
103 #if (B_V_MAJ < $boost_version_major) \
104    || (B_V_MAJ == $boost_version_major \
105        && B_V_MIN / 100 % 1000 < $boost_version_minor) $boost_subminor_chk
106 # error Boost headers version < $1
107 #endif
108 ]])], [boost_cv_inc_path=yes], [boost_cv_version=no])
109       CPPFLAGS=$boost_save_CPPFLAGS
110       if test x"$boost_cv_inc_path" = xyes; then
111         if test x"$boost_inc" != x; then
112           boost_cv_inc_path=$boost_inc
113         fi
114         break
115       fi
116     done
117 AC_LANG_POP([C++])dnl
118     ])
119     case $boost_cv_inc_path in #(
120       no)
121         AC_MSG_ERROR([Could not find Boost headers[]BOOST_VERSION_REQ])
122         ;;#(
123       yes)
124         BOOST_CPPFLAGS=
125         ;;#(
126       *)
127         BOOST_CPPFLAGS="-I$boost_cv_inc_path"
128         ;;
129     esac
130 AC_SUBST([BOOST_CPPFLAGS])dnl
131   AC_CACHE_CHECK([for Boost's header version],
132     [boost_cv_lib_version],
133     [m4_pattern_allow([^BOOST_LIB_VERSION$])dnl
134     boost_cv_lib_version=unknown
135     boost_sed_version='/^.*BOOST_LIB_VERSION.*"\([[^"]]*\)".*$/!d;s//\1/'
136     boost_version_hpp="$boost_inc/boost/version.hpp"
137     test -e "$boost_version_hpp" \
138       && boost_cv_lib_version=`sed "$boost_sed_version" "$boost_version_hpp"`
139     ])
140 m4_popdef([BOOST_VERSION_REQ])dnl
141 ])# BOOST_REQUIRE
144 # BOOST_FIND_HEADER([HEADER-NAME], [ACTION-IF-NOT-FOUND], [ACTION-IF-FOUND])
145 # --------------------------------------------------------------------------
146 # Wrapper around AC_CHECK_HEADER for Boost headers.  Useful to check for
147 # some parts of the Boost library which are only made of headers and don't
148 # require linking (such as Boost.Foreach).
150 # Default ACTION-IF-NOT-FOUND: Fail with a fatal error.
152 # Default ACTION-IF-FOUND: define the preprocessor symbol HAVE_<HEADER-NAME> in
153 # case of success # (where HEADER-NAME is written LIKE_THIS, e.g.,
154 # HAVE_BOOST_FOREACH_HPP).
155 AC_DEFUN([BOOST_FIND_HEADER],
156 [AC_REQUIRE([BOOST_REQUIRE])dnl
157 AC_LANG_PUSH([C++])dnl
158 boost_save_CPPFLAGS=$CPPFLAGS
159 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
160 AC_CHECK_HEADER([$1],
161   [m4_default([$3], [AC_DEFINE(AS_TR_CPP([HAVE_$1]), [1],
162                                [Define to 1 if you have <$1>])])],
163   [m4_default([$2], [AC_MSG_ERROR([cannot find $1])])])
164 CPPFLAGS=$boost_save_CPPFLAGS
165 AC_LANG_POP([C++])dnl
166 ])# BOOST_FIND_HEADER
169 # BOOST_FIND_LIB([LIB-NAME], [PREFERED-RT-OPT], [HEADER-NAME], [CXX-TEST])
170 # ------------------------------------------------------------------------
171 # Look for the Boost library LIB-NAME (e.g., LIB-NAME = `thread', for
172 # libboost_thread).  Check that HEADER-NAME works and check that
173 # libboost_LIB-NAME can link with the code CXX-TEST.
175 # Invokes BOOST_FIND_HEADER([HEADER-NAME]) (see above).
177 # Boost libraries typically come compiled with several flavors (with different
178 # runtime options) so PREFERED-RT-OPT is the prefered suffix.  A suffix is one
179 # or more of the following letters: sgdpn (in that order).  s = static
180 # runtime, d = debug build, g = debug/diagnostic runtime, p = STLPort build,
181 # n = (unsure) STLPort build without iostreams from STLPort (it looks like `n'
182 # must always be used along with `p').  Additionally, PREFERED-RT-OPT can
183 # start with `mt-' to indicate that there is a preference for multi-thread
184 # builds.  Some sample values for PREFERED-RT-OPT: (nothing), mt, d, mt-d, gdp
185 # ...  If you want to make sure you have a specific version of Boost
186 # (eg, >= 1.33) you *must* invoke BOOST_REQUIRE before this macro.
187 AC_DEFUN([BOOST_FIND_LIB],
188 [AC_REQUIRE([_BOOST_FIND_COMPILER_TAG])dnl
189 AC_REQUIRE([BOOST_REQUIRE])dnl
190 AC_LANG_PUSH([C++])dnl
191 AS_VAR_PUSHDEF([Boost_lib], [boost_cv_lib_$1])dnl
192 AS_VAR_PUSHDEF([Boost_lib_LDFLAGS], [boost_cv_lib_$1_LDFLAGS])dnl
193 AS_VAR_PUSHDEF([Boost_lib_LIBS], [boost_cv_lib_$1_LIBS])dnl
194 BOOST_FIND_HEADER([$3])
195 boost_save_CPPFLAGS=$CPPFLAGS
196 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
197 # Now let's try to find the library.  The algorithm is as follows: first look
198 # for a given library name according to the user's PREFERED-RT-OPT.  For each
199 # library name, we prefer to use the ones that carry the tag (toolset name).
200 # Each library is searched through the various standard paths were Boost is
201 # usually installed.  If we can't find the standard variants, we try to
202 # enforce -mt (for instance on MacOSX, libboost_threads.dylib doesn't exist
203 # but there's -obviously- libboost_threads-mt.dylib).
204 AC_CACHE_CHECK([for the Boost $1 library], [Boost_lib],
205   [Boost_lib=no
206   case "$2" in #(
207     mt | mt-) boost_mt=-mt; boost_rtopt=;; #(
208     mt* | mt-*) boost_mt=-mt; boost_rtopt=`expr "X$2" : 'Xmt-*\(.*\)'`;; #(
209     *) boost_mt=; boost_rtopt=$2;;
210   esac
211   # If the PREFERED-RT-OPT are not empty, prepend a `-'.
212   case $boost_rtopt in #(
213     *[[a-z0-9A-Z]]*) boost_rtopt="-$boost_rtopt";;
214   esac
215   # Check whether we do better use `mt' even though we weren't ask to.
216   if test x"$boost_mt" = x; then
217     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
218 #if defined _REENTRANT || defined _MT || defined __MT__
219 /* use -mt */
220 #else
221 # error MT not needed
222 #endif
223 ]])], [boost_mt=-mt])
224   fi
225   # Generate the test file.
226   AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <$3>], [$4])])
227   boost_failed_libs=
228 # Don't bother to ident the 6 nested for loops, only the 2 insidemost ones
229 # matter.
230 for boost_tag_ in -$boost_cv_lib_tag ''; do
231 for boost_ver_ in -$boost_cv_lib_version ''; do
232 for boost_mt_ in $boost_mt -mt ''; do
233 for boost_rtopt_ in $boost_rtopt '' -d; do
234   for boost_lib in \
235     boost_$1$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_ \
236     boost_$1$boost_tag_$boost_mt_$boost_ver_ \
237     boost_$1$boost_tag_$boost_rtopt_$boost_ver_ \
238     boost_$1$boost_tag_$boost_mt_ \
239     boost_$1$boost_tag_$boost_ver_
240   do
241     # Avoid testing twice the same lib
242     case $boost_failed_libs in #(
243       *@$boost_lib@*) continue;;
244     esac
245     boost_save_LIBS=$LIBS
246     LIBS="-l$boost_lib $LIBS"
247     # If with_boost is empty, we'll search in /lib first, which is not quite
248     # right so instead we'll try to a location based on where the headers are.
249     boost_tmp_lib=$with_boost
250     test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include}
251     for boost_ldpath in "$boost_tmp_lib/lib" '' \
252              /opt/local/lib /usr/local/lib /opt/lib /usr/lib \
253              "$with_boost" C:/Boost/lib /lib /usr/lib64 /lib64
254     do
255       test -e "$boost_ldpath" || continue
256       boost_save_LDFLAGS=$LDFLAGS
257       test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath -R$boost_ldpath"
258 dnl First argument of AC_LINK_IFELSE left empty because the test file is
259 dnl generated only once above (before we start the for loops).
260       AC_LINK_IFELSE([],
261                      [Boost_lib=yes], [Boost_lib=no])
262       if test x"$Boost_lib" = xyes; then
263         Boost_lib_LDFLAGS="-L$boost_ldpath -R$boost_ldpath"
264         Boost_lib_LIBS="-l$boost_lib"
265         break 6
266       else
267         boost_failed_libs="$boost_failed_libs@$boost_lib@"
268       fi
269       LDFLAGS=$boost_save_LDFLAGS
270     done
271     LIBS=$boost_save_LIBS
272   done
273 done
274 done
275 done
276 done
278 AC_SUBST(AS_TR_CPP([BOOST_$1_LDFLAGS]), [$Boost_lib_LDFLAGS])
279 AC_SUBST(AS_TR_CPP([BOOST_$1_LIBS]), [$Boost_lib_LIBS])
280 CPPFLAGS=$boost_save_CPPFLAGS
281 AS_VAR_POPDEF([Boost_lib])dnl
282 AS_VAR_POPDEF([Boost_lib_LDFLAGS])dnl
283 AS_VAR_POPDEF([Boost_lib_LIBS])dnl
284 AC_LANG_POP([C++])dnl
285 ])# BOOST_FIND_LIB
288 # --------------------------------------- #
289 # Checks for the various Boost libraries. #
290 # --------------------------------------- #
292 # List of boost libraries: http://www.boost.org/libs/libraries.htm
293 # The page http://beta.boost.org/doc/libs is useful: it gives the first release
294 # version of each library (among other things).
297 # BOOST_CONVERSION()
298 # ------------------
299 # Look for Boost.Conversion (cast / lexical_cast)
300 AC_DEFUN([BOOST_CONVERSION],
301 [BOOST_FIND_HEADER([boost/cast.hpp])
302 BOOST_FIND_HEADER([boost/lexical_cast.hpp])
303 ])# BOOST_CONVERSION
306 # BOOST_FILESYSTEM([PREFERED-RT-OPT])
307 # -----------------------------------
308 # Look for Boost.Filesystem.  For the documentation of PREFERED-RT-OPT, see the
309 # documentation of BOOST_FIND_LIB above.
310 AC_DEFUN([BOOST_FILESYSTEM],
311 [BOOST_FIND_LIB([filesystem], [$1],
312                 [boost/filesystem.hpp], [boost::filesystem::path p;])
313 ])# BOOST_FILESYSTEM
316 # BOOST_FOREACH()
317 # ---------------
318 # Look for Boost.Foreach
319 AC_DEFUN([BOOST_FOREACH],
320 [BOOST_FIND_HEADER([boost/foreach.hpp])])
323 # BOOST_FORMAT()
324 # ------------------
325 # Look for Boost.Format
326 # Note: we can't check for boost/format/format_fwd.hpp because the header isn't
327 # standalone.  It can't be compiled because it triggers the following error:
328 # boost/format/detail/config_macros.hpp:88: error: 'locale' in namespace 'std'
329 #                                                  does not name a type
330 AC_DEFUN([BOOST_FORMAT],
331 [BOOST_FIND_HEADER([boost/format.hpp])])
334 # BOOST_GRAPH([PREFERED-RT-OPT])
335 # ------------------------------
336 # Look for Boost.Graphs.  For the documentation of PREFERED-RT-OPT, see the
337 # documentation of BOOST_FIND_LIB above.
338 AC_DEFUN([BOOST_GRAPH],
339 [BOOST_FIND_LIB([graph], [$1],
340                 [boost/graph/adjacency_list.hpp], [boost::adjacency_list g;])
341 ])# BOOST_GRAPH
344 # BOOST_THREADS([PREFERED-RT-OPT])
345 # --------------------------------
346 # Look for Boost.Thread.  For the documentation of PREFERED-RT-OPT, see the
347 # documentation of BOOST_FIND_LIB above.
348 # FIXME: Provide an alias "BOOST_THREAD".
349 AC_DEFUN([BOOST_THREADS],
350 [dnl Having the pthread flag is required at least on GCC3 where
351 dnl boost/thread.hpp would complain if we try to compile without
352 dnl -pthread on GNU/Linux.
353 AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl
354 boost_threads_save_LIBS=$LIBS
355 # Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3,
356 # boost/thread.hpp will trigger a #error if -pthread isn't used:
357 #   boost/config/requires_threads.hpp:47:5: #error "Compiler threading support
358 #   is not turned on. Please set the correct command line options for
359 #   threading: -pthread (Linux), -pthreads (Sola ris) or -mthreads (Mingw32)"
360 boost_threads_save_CPPFLAGS=$LIBS
361 LIBS="$LIBS $boost_cv_pthread_flag"
362 CPPFLAGS="$CPPFLAGS $boost_cv_pthread_flag"
363 BOOST_FIND_LIB([thread], [$1],
364                 [boost/thread.hpp], [boost::thread t; boost::mutex m;])
365 BOOST_THREAD_LIBS="$BOOST_THREAD_LIBS $boost_cv_pthread_flag"
366 BOOST_CPPFLAGS="$BOOST_CPPFLAGS $boost_cv_pthread_flag"
367 LIBS=$boost_threads_save_LIBS
368 CPPFLAGS=$boost_threads_save_CPPFLAGS
369 ])# BOOST_THREADS
372 # BOOST_SMART_PTR()
373 # -----------------
374 # Look for Boost.SmartPtr
375 AC_DEFUN([BOOST_SMART_PTR],
376 [BOOST_FIND_HEADER([boost/scoped_ptr.hpp])
377 BOOST_FIND_HEADER([boost/shared_ptr.hpp])
381 # BOOST_STRING_ALGO()
382 # -------------------
383 # Look for Boost.StringAlgo
384 AC_DEFUN([BOOST_STRING_ALGO],
385 [BOOST_FIND_HEADER([boost/algorithm/string.hpp])
389 # BOOST_TRIBOOL()
390 # -----------------
391 # Look for Boost.Tribool
392 AC_DEFUN([BOOST_TRIBOOL],
393 [BOOST_FIND_HEADER([boost/logic/tribool_fwd.hpp])
394 BOOST_FIND_HEADER([boost/logic/tribool.hpp])
398 # BOOST_TUPLE()
399 # -------------
400 # Look for Boost.Tuple
401 AC_DEFUN([BOOST_TUPLE],
402 [BOOST_FIND_HEADER([boost/tuple/tuple.hpp])])
405 # BOOST_UTILITY()
406 # ---------------
407 # Look for Boost.Utility (noncopyable, result_of, base-from-member idiom,
408 # etc.)
409 AC_DEFUN([BOOST_UTILITY],
410 [BOOST_FIND_HEADER([boost/utility.hpp])])
413 # BOOST_VARIANT()
414 # ---------------
415 # Look for Boost.Variant.
416 AC_DEFUN([BOOST_VARIANT],
417 [BOOST_FIND_HEADER([boost/variant/variant_fwd.hpp])
418 BOOST_FIND_HEADER([boost/variant.hpp])])
421 # ----------------- #
422 # Internal helpers. #
423 # ----------------- #
426 # _BOOST_PTHREAD_FLAG()
427 # ---------------------
428 # Internal helper for BOOST_THREADS.  Based on ACX_PTHREAD:
429 # http://autoconf-archive.cryp.to/acx_pthread.html
430 AC_DEFUN([_BOOST_PTHREAD_FLAG],
431 [AC_REQUIRE([AC_PROG_CXX])dnl
432 AC_REQUIRE([AC_CANONICAL_HOST])dnl
433 AC_LANG_PUSH([C++])dnl
434 AC_CACHE_CHECK([for the flags needed to use pthreads], [boost_cv_pthread_flag],
435 [ boost_cv_pthread_flag=
436   # The ordering *is* (sometimes) important.  Some notes on the
437   # individual items follow:
438   # (none): in case threads are in libc; should be tried before -Kthread and
439   #       other compiler flags to prevent continual compiler warnings
440   # -lpthreads: AIX (must check this before -lpthread)
441   # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
442   # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
443   # -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
444   # -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads)
445   # -pthreads: Solaris/GCC
446   # -mthreads: MinGW32/GCC, Lynx/GCC
447   # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
448   #      doesn't hurt to check since this sometimes defines pthreads too;
449   #      also defines -D_REENTRANT)
450   #      ... -mt is also the pthreads flag for HP/aCC
451   # -lpthread: GNU Linux, etc.
452   # --thread-safe: KAI C++
453   case $host_os in #(
454     *solaris*)
455       # On Solaris (at least, for some versions), libc contains stubbed
456       # (non-functional) versions of the pthreads routines, so link-based
457       # tests will erroneously succeed.  (We need to link with -pthreads/-mt/
458       # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
459       # a function called by this macro, so we could check for that, but
460       # who knows whether they'll stub that too in a future libc.)  So,
461       # we'll just look for -pthreads and -lpthread first:
462       boost_pthread_flags="-pthreads -lpthread -mt -pthread";; #(
463     *)
464       boost_pthread_flags="-lpthreads -Kthread -kthread -llthread -pthread \
465                            -pthreads -mthreads -lpthread --thread-safe -mt";;
466   esac
467   # Generate the test file.
468   AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <pthread.h>],
469     [pthread_t th; pthread_join(th, 0);
470     pthread_attr_init(0); pthread_cleanup_push(0, 0);
471     pthread_create(0,0,0,0); pthread_cleanup_pop(0);])])
472   for boost_pthread_flag in '' $boost_pthread_flags; do
473     boost_pthread_ok=false
474 dnl Re-use the test file already generated.
475     boost_pthreads__save_LIBS=$LIBS
476     LIBS="$LIBS $boost_pthread_flag"
477     AC_LINK_IFELSE([],
478       [if grep ".*$boost_pthread_flag" conftest.err; then
479          echo "This flag seems to have triggered warnings" >&AS_MESSAGE_LOG_FD
480        else
481          boost_pthread_ok=:; boost_cv_pthread_flag=$boost_pthread_flag
482        fi])
483     LIBS=$boost_pthreads__save_LIBS
484     $boost_pthread_ok && break
485   done
487 AC_LANG_POP([C++])dnl
488 ])# _BOOST_PTHREAD_FLAG
491 # _BOOST_gcc_test(MAJOR, MINOR)
492 # -----------------------------
493 # Internal helper for _BOOST_FIND_COMPILER_TAG.
494 m4_define([_BOOST_gcc_test],
495 ["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC @ gcc$1$2"])dnl
498 # _BOOST_FIND_COMPILER_TAG()
499 # --------------------------
500 # Internal.  When Boost is installed without --layout=system, each library
501 # filename will hold a suffix that encodes the compiler used during the
502 # build.  The Boost build system seems to call this a `tag'.
503 AC_DEFUN([_BOOST_FIND_COMPILER_TAG],
504 [AC_REQUIRE([AC_PROG_CXX])dnl
505 AC_CACHE_CHECK([for the toolset name used by Boost for $CXX], [boost_cv_lib_tag],
506 [AC_LANG_PUSH([C++])dnl
507   boost_cv_lib_tag=unknown
508   # The following tests are mostly inspired by boost/config/auto_link.hpp
509   # The list is sorted to most recent/common to oldest compiler (in order
510   # to increase the likelihood of finding the right compiler with the
511   # least number of compilation attempt).
512   # Beware that some tests are sensible to the order (for instance, we must
513   # look for MinGW before looking for GCC3).
514   # I used one compilation test per compiler with a #error to recognize
515   # each compiler so that it works even when cross-compiling (let me know
516   # if you know a better approach).
517   # Known missing tags (known from Boost's tools/build/v2/tools/common.jam):
518   #   como, edg, kcc, bck, mp, sw, tru, xlc
519   # I'm not sure about my test for `il' (be careful: Intel's ICC pre-defines
520   # the same defines as GCC's).
521   # TODO: Move the test on GCC 4.3 up once it's released.
522   for i in \
523     _BOOST_gcc_test(4, 2) \
524     _BOOST_gcc_test(4, 1) \
525     _BOOST_gcc_test(4, 0) \
526     "defined __GNUC__ && __GNUC__ == 3 && !defined __ICC \
527      && (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \
528          || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw" \
529     _BOOST_gcc_test(3, 4) \
530     _BOOST_gcc_test(3, 3) \
531     "defined _MSC_VER && _MSC_VER >= 1400 @ vc80" \
532     _BOOST_gcc_test(3, 2) \
533     "defined _MSC_VER && _MSC_VER == 1310 @ vc71" \
534     _BOOST_gcc_test(3, 1) \
535     _BOOST_gcc_test(3, 0) \
536     "defined __BORLANDC__ @ bcb" \
537     "defined __ICC && (defined __unix || defined __unix__) @ il" \
538     "defined __ICL @ iw" \
539     "defined _MSC_VER && _MSC_VER == 1300 @ vc7" \
540     _BOOST_gcc_test(4, 3) \
541     _BOOST_gcc_test(2, 95) \
542     "defined __MWERKS__ && __MWERKS__ <= 0x32FF @ cw9" \
543     "defined _MSC_VER && _MSC_VER < 1300 && !defined UNDER_CE @ vc6" \
544     "defined _MSC_VER && _MSC_VER < 1300 && defined UNDER_CE @ evc4" \
545     "defined __MWERKS__ && __MWERKS__ <= 0x31FF @ cw8"
546   do
547     boost_tag_test=`expr "X$i" : 'X\([[^@]]*\) @ '`
548     boost_tag=`expr "X$i" : 'X[[^@]]* @ \(.*\)'`
549     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
550 #if $boost_tag_test
551 /* OK */
552 #else
553 # error $boost_tag_test
554 #endif
555 ]])], [boost_cv_lib_tag=$boost_tag; break], [])
556   done
557 AC_LANG_POP([C++])dnl
559   if test x"$boost_cv_lib_tag" = xunknown; then
560     AC_MSG_WARN([[could not figure out which toolset name to use for $CXX]])
561     boost_cv_lib_tag=
562   fi
563 ])# _BOOST_FIND_COMPILER_TAG