]>
Commit | Line | Data |
---|---|---|
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 | ||
24 | m4_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 | ||
48 | m4_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. | |
61 | m4_define([_BOOST_SED_CPP], | |
2187934a RK |
62 | [AC_LANG_PUSH([C++])dnl |
63 | AC_LANG_PREPROC_REQUIRE()dnl | |
94ac5f34 PD |
64 | AC_REQUIRE([AC_PROG_SED])dnl |
65 | AC_LANG_CONFTEST([AC_LANG_SOURCE([[$2]])]) | |
66 | AS_IF([dnl eval is necessary to expand ac_cpp. | |
67 | dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell. | |
68 | dnl Beware of Windows end-of-lines, for instance if we are running | |
69 | dnl some Windows programs under Wine. In that case, boost/version.hpp | |
70 | dnl is certainly using "\r\n", but the regular Unix shell will only | |
71 | dnl strip `\n' with backquotes, not the `\r'. This results in | |
72 | dnl boost_cv_lib_version='1_37\r' for instance, which breaks | |
73 | dnl everything else. | |
74 | dnl Cannot use 'dnl' after [$4] because a trailing dnl may break AC_CACHE_CHECK | |
2187934a RK |
75 | dnl |
76 | dnl Beware that GCC 5, when expanding macros, may embed # line directives | |
77 | dnl a within single line: | |
78 | dnl | |
79 | dnl # 1 "conftest.cc" | |
80 | dnl # 1 "<built-in>" | |
81 | dnl # 1 "<command-line>" | |
82 | dnl # 1 "conftest.cc" | |
83 | dnl # 1 "/opt/local/include/boost/version.hpp" 1 3 | |
84 | dnl # 2 "conftest.cc" 2 | |
85 | dnl boost-lib-version = | |
86 | dnl # 2 "conftest.cc" 3 | |
87 | dnl "1_56" | |
88 | dnl | |
89 | dnl 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]) | |
97 | rm -rf conftest* | |
2187934a RK |
98 | AC_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 | 113 | AC_DEFUN_ONCE([BOOST_REQUIRE], |
94ac5f34 PD |
114 | [AC_REQUIRE([AC_PROG_CXX])dnl |
115 | AC_REQUIRE([AC_PROG_GREP])dnl | |
116 | echo "$as_me: this is boost.m4[]_BOOST_SERIAL" >&AS_MESSAGE_LOG_FD | |
117 | boost_save_IFS=$IFS | |
118 | boost_version_req=$1 | |
119 | IFS=. | |
120 | set x $boost_version_req 0 0 0 | |
121 | IFS=$boost_save_IFS | |
122 | shift | |
123 | boost_version_req=`expr "$[1]" '*' 100000 + "$[2]" '*' 100 + "$[3]"` | |
124 | boost_version_req_string=$[1].$[2].$[3] | |
125 | AC_ARG_WITH([boost], | |
126 | [AS_HELP_STRING([--with-boost=DIR], | |
127 | [prefix of Boost $1 @<:@guess@:>@])])dnl | |
128 | AC_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. | |
131 | if 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 | |
138 | fi | |
139 | AC_SUBST([DISTCHECK_CONFIGURE_FLAGS], | |
140 | ["$DISTCHECK_CONFIGURE_FLAGS '--with-boost=$with_boost'"])dnl | |
141 | boost_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 | |
145 | AC_LANG_PUSH([C++])dnl | |
146 | m4_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 | |
206 | AC_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> |
230 | boost-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 | |
239 | fi | |
240 | CPPFLAGS=$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. | |
248 | AC_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). | |
270 | AC_DEFUN([BOOST_FIND_HEADER], | |
271 | [AC_REQUIRE([BOOST_REQUIRE])dnl | |
272 | if test x"$boost_cv_inc_path" = xno; then | |
273 | m4_default([$2], [AC_MSG_NOTICE([Boost not available, not searching for $1])]) | |
274 | else | |
275 | AC_LANG_PUSH([C++])dnl | |
276 | boost_save_CPPFLAGS=$CPPFLAGS | |
277 | CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" | |
278 | AC_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])])]) | |
282 | CPPFLAGS=$boost_save_CPPFLAGS | |
283 | AC_LANG_POP([C++])dnl | |
284 | fi | |
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 | 311 | AC_DEFUN([BOOST_FIND_LIBS], |
94ac5f34 PD |
312 | [AC_REQUIRE([BOOST_REQUIRE])dnl |
313 | AC_REQUIRE([_BOOST_FIND_COMPILER_TAG])dnl | |
314 | AC_REQUIRE([BOOST_STATIC])dnl | |
315 | AC_REQUIRE([_BOOST_GUESS_WHETHER_TO_USE_MT])dnl | |
316 | if test x"$boost_cv_inc_path" = xno; then | |
317 | AC_MSG_NOTICE([Boost not available, not searching for the Boost $1 library]) | |
318 | else | |
319 | dnl The else branch is huge and wasn't intended on purpose. | |
320 | AC_LANG_PUSH([C++])dnl | |
321 | AS_VAR_PUSHDEF([Boost_lib], [boost_cv_lib_$1])dnl | |
322 | AS_VAR_PUSHDEF([Boost_lib_LDFLAGS], [boost_cv_lib_$1_LDFLAGS])dnl | |
323 | AS_VAR_PUSHDEF([Boost_lib_LDPATH], [boost_cv_lib_$1_LDPATH])dnl | |
324 | AS_VAR_PUSHDEF([Boost_lib_LIBS], [boost_cv_lib_$1_LIBS])dnl | |
2187934a | 325 | BOOST_FIND_HEADER([$4]) |
94ac5f34 PD |
326 | boost_save_CPPFLAGS=$CPPFLAGS |
327 | CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" | |
94ac5f34 | 328 | AC_CACHE_CHECK([for the Boost $1 library], [Boost_lib], |
2187934a RK |
329 | [_BOOST_FIND_LIBS($@)]) |
330 | case $Boost_lib in #( | |
e512f4f9 AN |
331 | (yes) _AC_MSG_LOG_CONFTEST |
332 | AC_DEFINE(AS_TR_CPP([HAVE_BOOST_$1]), [1], [Defined if the Boost $1 library is available])dnl | |
333 | AC_SUBST(AS_TR_CPP([BOOST_$1_LDFLAGS]), [$Boost_lib_LDFLAGS])dnl | |
334 | AC_SUBST(AS_TR_CPP([BOOST_$1_LDPATH]), [$Boost_lib_LDPATH])dnl | |
335 | AC_SUBST([BOOST_LDPATH], [$Boost_lib_LDPATH])dnl | |
336 | AC_SUBST(AS_TR_CPP([BOOST_$1_LIBS]), [$Boost_lib_LIBS])dnl | |
2187934a RK |
337 | ;; |
338 | esac | |
2187934a RK |
339 | CPPFLAGS=$boost_save_CPPFLAGS |
340 | AS_VAR_POPDEF([Boost_lib])dnl | |
341 | AS_VAR_POPDEF([Boost_lib_LDFLAGS])dnl | |
342 | AS_VAR_POPDEF([Boost_lib_LDPATH])dnl | |
343 | AS_VAR_POPDEF([Boost_lib_LIBS])dnl | |
344 | AC_LANG_POP([C++])dnl | |
345 | fi | |
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. | |
354 | AC_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). | |
372 | AC_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 |
400 | dnl Optimization hacks: compiling C++ is slow, especially with Boost. What |
401 | dnl we're trying to do here is guess the right combination of link flags | |
402 | dnl (LIBS / LDFLAGS) to use a given library. This can take several | |
403 | dnl iterations before it succeeds and is thus *very* slow. So what we do | |
404 | dnl instead is that we compile the code first (and thus get an object file, | |
405 | dnl typically conftest.o). Then we try various combinations of link flags | |
406 | dnl until we succeed to link conftest.o in an executable. The problem is | |
407 | dnl that the various TRY_LINK / COMPILE_IFELSE macros of Autoconf always | |
408 | dnl remove all the temporary files including conftest.o. So the trick here | |
409 | dnl is to temporarily change the value of ac_objext so that conftest.o is | |
410 | dnl preserved accross tests. This is obviously fragile and I will burn in | |
411 | dnl hell for not respecting Autoconf's documented interfaces, but in the | |
412 | dnl mean time, it optimizes the macro by a factor of 5 to 30. | |
413 | dnl Another small optimization: the first argument of AC_COMPILE_IFELSE left | |
414 | dnl empty because the test file is generated only once above (before we | |
415 | dnl 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. | |
423 | for boost_lib_ in $2; do | |
94ac5f34 PD |
424 | for boost_tag_ in -$boost_cv_lib_tag ''; do |
425 | for boost_ver_ in -$boost_cv_lib_version ''; do | |
426 | for boost_mt_ in $boost_mt -mt ''; do | |
427 | for 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" | |
462 | dnl First argument of AC_LINK_IFELSE left empty because the test file is | |
463 | dnl 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 | |
504 | done | |
505 | done | |
506 | done | |
507 | done | |
2187934a | 508 | done # boost_lib_ |
94ac5f34 PD |
509 | rm -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. | |
527 | m4_define([BOOST_DEFUN], | |
528 | [m4_indir([AC_DEFUN], | |
529 | m4_toupper([BOOST_$1]), | |
530 | [m4_pushdef([BOOST_Library], [$1])dnl | |
531 | $2 | |
532 | m4_popdef([BOOST_Library])dnl | |
533 | ]) | |
534 | ]) | |
535 | ||
536 | # BOOST_ARRAY() | |
537 | # ------------- | |
538 | # Look for Boost.Array | |
539 | BOOST_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). | |
546 | BOOST_DEFUN([Asio], | |
547 | [AC_REQUIRE([BOOST_SYSTEM])dnl | |
548 | BOOST_FIND_HEADER([boost/asio.hpp])]) | |
549 | ||
550 | ||
551 | # BOOST_BIND() | |
552 | # ------------ | |
2187934a | 553 | # Look for Boost.Bind. |
94ac5f34 PD |
554 | BOOST_DEFUN([Bind], |
555 | [BOOST_FIND_HEADER([boost/bind.hpp])]) | |
556 | ||
557 | ||
558 | # BOOST_CHRONO() | |
2187934a RK |
559 | # -------------- |
560 | # Look for Boost.Chrono. | |
94ac5f34 PD |
561 | BOOST_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. | |
565 | if test $boost_major_version -ge 135; then | |
2187934a | 566 | BOOST_SYSTEM([$1]) |
94ac5f34 PD |
567 | fi # end of the Boost.System check. |
568 | boost_filesystem_save_LIBS=$LIBS | |
569 | boost_filesystem_save_LDFLAGS=$LDFLAGS | |
570 | m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl | |
571 | LIBS="$LIBS $BOOST_SYSTEM_LIBS" | |
572 | LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" | |
573 | BOOST_FIND_LIB([chrono], [$1], | |
574 | [boost/chrono.hpp], | |
575 | [boost::chrono::thread_clock d;]) | |
576 | if 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 |
578 | fi |
579 | LIBS=$boost_filesystem_save_LIBS | |
580 | LDFLAGS=$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 | |
afdd465f PL |
587 | # documentation of BOOST_FIND_LIB above. |
588 | # | |
589 | # * This library was introduced in Boost 1.51.0 | |
590 | # * The signatures of make_fcontext() and jump_fcontext were changed in 1.56.0 | |
591 | # * A dependency on boost_thread appears in 1.57.0 | |
2187934a | 592 | BOOST_DEFUN([Context], |
afdd465f PL |
593 | [boost_context_save_LIBS=$LIBS |
594 | boost_context_save_LDFLAGS=$LDFLAGS | |
595 | if test $boost_major_version -ge 157; then | |
596 | BOOST_THREAD([$1]) | |
597 | m4_pattern_allow([^BOOST_THREAD_(LIBS|LDFLAGS)$])dnl | |
598 | LIBS="$LIBS $BOOST_THREAD_LIBS" | |
599 | LDFLAGS="$LDFLAGS $BOOST_THREAD_LDFLAGS" | |
600 | fi | |
601 | BOOST_FIND_LIB([context], [$1], | |
2187934a | 602 | [boost/context/all.hpp],[[ |
afdd465f | 603 | |
2187934a RK |
604 | // creates a stack |
605 | void * stack_pointer = new void*[4096]; | |
606 | std::size_t const size = sizeof(void*[4096]); | |
607 | ||
afdd465f PL |
608 | #if BOOST_VERSION <= 105100 |
609 | ctx::make_fcontext(&fc, f); | |
610 | return ctx::jump_fcontext(&fcm, &fc, 3) == 6; | |
611 | ||
612 | #else | |
613 | ||
2187934a | 614 | fc = ctx::make_fcontext(stack_pointer, size, f); |
afdd465f PL |
615 | return ctx::jump_fcontext(&fcm, fc, 3) == 6; |
616 | ||
617 | #endif | |
618 | ||
619 | ||
620 | ]],[dnl | |
621 | ||
622 | #include <boost/version.hpp> | |
623 | #if BOOST_VERSION <= 105100 | |
624 | ||
625 | namespace ctx = boost::ctx; | |
626 | ||
627 | static ctx::fcontext_t fcm, fc; | |
628 | ||
629 | static void f(intptr_t i) { | |
630 | ctx::jump_fcontext(&fc, &fcm, i * 2); | |
631 | } | |
632 | ||
633 | #elif BOOST_VERSION <= 105500 | |
634 | ||
2187934a | 635 | namespace ctx = boost::context; |
afdd465f | 636 | |
2187934a RK |
637 | // context |
638 | static ctx::fcontext_t fcm, *fc; | |
afdd465f | 639 | |
2187934a RK |
640 | // context-function |
641 | static void f(intptr_t i) { | |
642 | ctx::jump_fcontext(fc, &fcm, i * 2); | |
afdd465f PL |
643 | } |
644 | ||
645 | #else | |
646 | ||
647 | namespace ctx = boost::context; | |
648 | ||
649 | // context | |
650 | static ctx::fcontext_t fcm, fc; | |
651 | ||
652 | // context-function | |
653 | static void f(intptr_t i) { | |
654 | ctx::jump_fcontext(&fc, fcm, i * 2); | |
655 | } | |
656 | #endif | |
657 | ]) | |
658 | LIBS=$boost_context_save_LIBS | |
659 | LDFLAGS=$boost_context_save_LDFLAGS | |
2187934a RK |
660 | ])# BOOST_CONTEXT |
661 | ||
662 | ||
94ac5f34 PD |
663 | # BOOST_CONVERSION() |
664 | # ------------------ | |
665 | # Look for Boost.Conversion (cast / lexical_cast) | |
666 | BOOST_DEFUN([Conversion], | |
667 | [BOOST_FIND_HEADER([boost/cast.hpp]) | |
668 | BOOST_FIND_HEADER([boost/lexical_cast.hpp]) | |
669 | ])# BOOST_CONVERSION | |
670 | ||
671 | ||
2187934a RK |
672 | # BOOST_COROUTINE([PREFERRED-RT-OPT]) |
673 | # ----------------------------------- | |
674 | # Look for Boost.Coroutine. For the documentation of PREFERRED-RT-OPT, see the | |
675 | # documentation of BOOST_FIND_LIB above. This library was introduced in Boost | |
676 | # 1.53.0 | |
677 | BOOST_DEFUN([Coroutine], | |
678 | [ | |
679 | boost_coroutine_save_LIBS=$LIBS | |
680 | boost_coroutine_save_LDFLAGS=$LDFLAGS | |
681 | # Link-time dependency from coroutine to context | |
682 | BOOST_CONTEXT([$1]) | |
683 | # Starting from Boost 1.55 a dependency on Boost.System is added | |
684 | if test $boost_major_version -ge 155; then | |
685 | BOOST_SYSTEM([$1]) | |
686 | fi | |
687 | m4_pattern_allow([^BOOST_(CONTEXT|SYSTEM)_(LIBS|LDFLAGS)]) | |
688 | LIBS="$LIBS $BOOST_CONTEXT_LIBS $BOOST_SYSTEM_LIBS" | |
689 | LDFLAGS="$LDFLAGS $BOOST_CONTEXT_LDFLAGS" | |
690 | ||
afdd465f PL |
691 | # in 1.53 coroutine was a header only library |
692 | if test $boost_major_version -eq 153; then | |
693 | BOOST_FIND_HEADER([boost/coroutine/coroutine.hpp]) | |
694 | else | |
695 | BOOST_FIND_LIB([coroutine], [$1], | |
696 | [boost/coroutine/coroutine.hpp], | |
697 | [ | |
698 | #include <boost/version.hpp> | |
699 | #if BOOST_VERSION <= 105500 | |
700 | boost::coroutines::coroutine<int(int)> coro; coro.get(); | |
701 | #else | |
702 | boost::coroutines::asymmetric_coroutine<int>::pull_type coro; coro.get(); | |
703 | #endif | |
704 | ]) | |
705 | fi | |
2187934a RK |
706 | # Link-time dependency from coroutine to context, existed only in 1.53, in 1.54 |
707 | # coroutine doesn't use context from its headers but from its library. | |
708 | if test $boost_major_version -eq 153 || test $enable_static_boost = yes && test $boost_major_version -ge 154; then | |
709 | BOOST_COROUTINE_LIBS="$BOOST_COROUTINE_LIBS $BOOST_CONTEXT_LIBS" | |
710 | BOOST_COROUTINE_LDFLAGS="$BOOST_COROUTINE_LDFLAGS $BOOST_CONTEXT_LDFLAGS" | |
711 | fi | |
712 | if test $enable_static_boost = yes && test $boost_major_version -ge 155; then | |
713 | BOOST_COROUTINE_LIBS="$BOOST_COROUTINE_LIBS $BOOST_SYSTEM_LIBS" | |
714 | BOOST_COROUTINE_LDFLAGS="$BOOST_COROUTINE_LDFLAGS $BOOST_SYSTEM_LDFLAGS" | |
715 | fi | |
716 | LIBS=$boost_coroutine_save_LIBS | |
717 | LDFLAGS=$boost_coroutine_save_LDFLAGS | |
718 | ])# BOOST_COROUTINE | |
719 | ||
720 | ||
94ac5f34 PD |
721 | # BOOST_CRC() |
722 | # ----------- | |
723 | # Look for Boost.CRC | |
724 | BOOST_DEFUN([CRC], | |
725 | [BOOST_FIND_HEADER([boost/crc.hpp]) | |
726 | ])# BOOST_CRC | |
727 | ||
728 | ||
729 | # BOOST_DATE_TIME([PREFERRED-RT-OPT]) | |
730 | # ----------------------------------- | |
731 | # Look for Boost.Date_Time. For the documentation of PREFERRED-RT-OPT, see the | |
732 | # documentation of BOOST_FIND_LIB above. | |
733 | BOOST_DEFUN([Date_Time], | |
734 | [BOOST_FIND_LIB([date_time], [$1], | |
735 | [boost/date_time/posix_time/posix_time.hpp], | |
736 | [boost::posix_time::ptime t;]) | |
737 | ])# BOOST_DATE_TIME | |
738 | ||
739 | ||
740 | # BOOST_FILESYSTEM([PREFERRED-RT-OPT]) | |
741 | # ------------------------------------ | |
742 | # Look for Boost.Filesystem. For the documentation of PREFERRED-RT-OPT, see | |
743 | # the documentation of BOOST_FIND_LIB above. | |
744 | # Do not check for boost/filesystem.hpp because this file was introduced in | |
745 | # 1.34. | |
746 | BOOST_DEFUN([Filesystem], | |
747 | [# Do we have to check for Boost.System? This link-time dependency was | |
748 | # added as of 1.35.0. If we have a version <1.35, we must not attempt to | |
749 | # find Boost.System as it didn't exist by then. | |
750 | if test $boost_major_version -ge 135; then | |
2187934a | 751 | BOOST_SYSTEM([$1]) |
94ac5f34 PD |
752 | fi # end of the Boost.System check. |
753 | boost_filesystem_save_LIBS=$LIBS | |
754 | boost_filesystem_save_LDFLAGS=$LDFLAGS | |
755 | m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl | |
756 | LIBS="$LIBS $BOOST_SYSTEM_LIBS" | |
757 | LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" | |
758 | BOOST_FIND_LIB([filesystem], [$1], | |
759 | [boost/filesystem/path.hpp], [boost::filesystem::path p;]) | |
760 | if test $enable_static_boost = yes && test $boost_major_version -ge 135; then | |
2187934a | 761 | BOOST_FILESYSTEM_LIBS="$BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS" |
94ac5f34 PD |
762 | fi |
763 | LIBS=$boost_filesystem_save_LIBS | |
764 | LDFLAGS=$boost_filesystem_save_LDFLAGS | |
765 | ])# BOOST_FILESYSTEM | |
766 | ||
767 | ||
2187934a RK |
768 | # BOOST_FLYWEIGHT() |
769 | # ----------------- | |
770 | # Look for Boost.Flyweight. | |
771 | BOOST_DEFUN([Flyweight], | |
772 | [dnl There's a hidden dependency on pthreads. | |
773 | AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl | |
774 | BOOST_FIND_HEADER([boost/flyweight.hpp]) | |
775 | AC_SUBST([BOOST_FLYWEIGHT_LIBS], [$boost_cv_pthread_flag]) | |
776 | ]) | |
777 | ||
778 | ||
94ac5f34 PD |
779 | # BOOST_FOREACH() |
780 | # --------------- | |
2187934a | 781 | # Look for Boost.Foreach. |
94ac5f34 PD |
782 | BOOST_DEFUN([Foreach], |
783 | [BOOST_FIND_HEADER([boost/foreach.hpp])]) | |
784 | ||
785 | ||
786 | # BOOST_FORMAT() | |
787 | # -------------- | |
2187934a | 788 | # Look for Boost.Format. |
94ac5f34 PD |
789 | # Note: we can't check for boost/format/format_fwd.hpp because the header isn't |
790 | # standalone. It can't be compiled because it triggers the following error: | |
791 | # boost/format/detail/config_macros.hpp:88: error: 'locale' in namespace 'std' | |
792 | # does not name a type | |
793 | BOOST_DEFUN([Format], | |
794 | [BOOST_FIND_HEADER([boost/format.hpp])]) | |
795 | ||
796 | ||
797 | # BOOST_FUNCTION() | |
798 | # ---------------- | |
799 | # Look for Boost.Function | |
800 | BOOST_DEFUN([Function], | |
801 | [BOOST_FIND_HEADER([boost/function.hpp])]) | |
802 | ||
803 | ||
804 | # BOOST_GEOMETRY() | |
805 | # ---------------- | |
806 | # Look for Boost.Geometry (new since 1.47.0). | |
807 | BOOST_DEFUN([Geometry], | |
808 | [BOOST_FIND_HEADER([boost/geometry.hpp]) | |
809 | ])# BOOST_GEOMETRY | |
810 | ||
811 | ||
812 | # BOOST_GRAPH([PREFERRED-RT-OPT]) | |
813 | # ------------------------------- | |
814 | # Look for Boost.Graphs. For the documentation of PREFERRED-RT-OPT, see the | |
815 | # documentation of BOOST_FIND_LIB above. | |
816 | BOOST_DEFUN([Graph], | |
afdd465f PL |
817 | [boost_graph_save_LIBS=$LIBS |
818 | boost_graph_save_LDFLAGS=$LDFLAGS | |
819 | # Link-time dependency from graph to regex was added as of 1.40.0. | |
820 | if test $boost_major_version -ge 140; then | |
821 | BOOST_REGEX([$1]) | |
822 | m4_pattern_allow([^BOOST_REGEX_(LIBS|LDFLAGS)$])dnl | |
823 | LIBS="$LIBS $BOOST_REGEX_LIBS" | |
824 | LDFLAGS="$LDFLAGS $BOOST_REGEX_LDFLAGS" | |
825 | fi | |
826 | BOOST_FIND_LIB([graph], [$1], | |
94ac5f34 | 827 | [boost/graph/adjacency_list.hpp], [boost::adjacency_list<> g;]) |
afdd465f PL |
828 | LIBS=$boost_graph_save_LIBS |
829 | LDFLAGS=$boost_graph_save_LDFLAGS | |
94ac5f34 PD |
830 | ])# BOOST_GRAPH |
831 | ||
832 | ||
833 | # BOOST_IOSTREAMS([PREFERRED-RT-OPT]) | |
834 | # ----------------------------------- | |
835 | # Look for Boost.IOStreams. For the documentation of PREFERRED-RT-OPT, see the | |
836 | # documentation of BOOST_FIND_LIB above. | |
837 | BOOST_DEFUN([IOStreams], | |
838 | [BOOST_FIND_LIB([iostreams], [$1], | |
839 | [boost/iostreams/device/file_descriptor.hpp], | |
840 | [boost::iostreams::file_descriptor fd; fd.close();]) | |
841 | ])# BOOST_IOSTREAMS | |
842 | ||
843 | ||
844 | # BOOST_HASH() | |
845 | # ------------ | |
846 | # Look for Boost.Functional/Hash | |
847 | BOOST_DEFUN([Hash], | |
848 | [BOOST_FIND_HEADER([boost/functional/hash.hpp])]) | |
849 | ||
850 | ||
851 | # BOOST_LAMBDA() | |
852 | # -------------- | |
853 | # Look for Boost.Lambda | |
854 | BOOST_DEFUN([Lambda], | |
855 | [BOOST_FIND_HEADER([boost/lambda/lambda.hpp])]) | |
856 | ||
857 | ||
2187934a RK |
858 | # BOOST_LOCALE() |
859 | # -------------- | |
860 | # Look for Boost.Locale | |
861 | BOOST_DEFUN([Locale], | |
afdd465f PL |
862 | [ |
863 | boost_locale_save_LIBS=$LIBS | |
864 | boost_locale_save_LDFLAGS=$LDFLAGS | |
865 | # require SYSTEM for boost-1.50.0 and up | |
866 | if test $boost_major_version -ge 150; then | |
867 | BOOST_SYSTEM([$1]) | |
868 | m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl | |
869 | LIBS="$LIBS $BOOST_SYSTEM_LIBS" | |
870 | LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" | |
871 | fi # end of the Boost.System check. | |
872 | BOOST_FIND_LIB([locale], [$1], | |
2187934a RK |
873 | [boost/locale.hpp], |
874 | [[boost::locale::generator gen; std::locale::global(gen(""));]]) | |
afdd465f PL |
875 | LIBS=$boost_locale_save_LIBS |
876 | LDFLAGS=$boost_locale_save_LDFLAGS | |
2187934a RK |
877 | ])# BOOST_LOCALE |
878 | ||
94ac5f34 PD |
879 | # BOOST_LOG([PREFERRED-RT-OPT]) |
880 | # ----------------------------- | |
2187934a | 881 | # Look for Boost.Log. For the documentation of PREFERRED-RT-OPT, see the |
94ac5f34 PD |
882 | # documentation of BOOST_FIND_LIB above. |
883 | BOOST_DEFUN([Log], | |
afdd465f PL |
884 | [boost_log_save_LIBS=$LIBS |
885 | boost_log_save_LDFLAGS=$LDFLAGS | |
886 | BOOST_SYSTEM([$1]) | |
887 | BOOST_FILESYSTEM([$1]) | |
888 | BOOST_DATE_TIME([$1]) | |
889 | m4_pattern_allow([^BOOST_(SYSTEM|FILESYSTEM|DATE_TIME)_(LIBS|LDFLAGS)$])dnl | |
890 | LIBS="$LIBS $BOOST_DATE_TIME_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS" | |
891 | LDFLAGS="$LDFLAGS $BOOST_DATE_TIME_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS $BOOST_SYSTEM_LDFLAGS" | |
892 | BOOST_FIND_LIB([log], [$1], | |
94ac5f34 PD |
893 | [boost/log/core/core.hpp], |
894 | [boost::log::attribute a; a.get_value();]) | |
afdd465f PL |
895 | LIBS=$boost_log_save_LIBS |
896 | LDFLAGS=$boost_log_save_LDFLAGS | |
94ac5f34 PD |
897 | ])# BOOST_LOG |
898 | ||
899 | ||
900 | # BOOST_LOG_SETUP([PREFERRED-RT-OPT]) | |
901 | # ----------------------------------- | |
2187934a | 902 | # Look for Boost.Log. For the documentation of PREFERRED-RT-OPT, see the |
94ac5f34 PD |
903 | # documentation of BOOST_FIND_LIB above. |
904 | BOOST_DEFUN([Log_Setup], | |
afdd465f PL |
905 | [boost_log_setup_save_LIBS=$LIBS |
906 | boost_log_setup_save_LDFLAGS=$LDFLAGS | |
907 | BOOST_LOG([$1]) | |
908 | m4_pattern_allow([^BOOST_LOG_(LIBS|LDFLAGS)$])dnl | |
909 | LIBS="$LIBS $BOOST_LOG_LIBS" | |
910 | LDFLAGS="$LDFLAGS $BOOST_LOG_LDFLAGS" | |
94ac5f34 | 911 | BOOST_FIND_LIB([log_setup], [$1], |
2187934a | 912 | [boost/log/utility/setup/from_settings.hpp], |
94ac5f34 | 913 | [boost::log::basic_settings<char> bs; bs.empty();]) |
afdd465f PL |
914 | LIBS=$boost_log_setup_save_LIBS |
915 | LDFLAGS=$boost_log_setup_save_LDFLAGS | |
94ac5f34 PD |
916 | ])# BOOST_LOG_SETUP |
917 | ||
918 | ||
919 | # BOOST_MATH() | |
920 | # ------------ | |
921 | # Look for Boost.Math | |
922 | # TODO: This library isn't header-only but it comes in multiple different | |
923 | # flavors that don't play well with BOOST_FIND_LIB (e.g, libboost_math_c99, | |
924 | # libboost_math_c99f, libboost_math_c99l, libboost_math_tr1, | |
925 | # libboost_math_tr1f, libboost_math_tr1l). This macro must be fixed to do the | |
926 | # right thing anyway. | |
927 | BOOST_DEFUN([Math], | |
928 | [BOOST_FIND_HEADER([boost/math/special_functions.hpp])]) | |
929 | ||
930 | ||
2187934a RK |
931 | # BOOST_MPI([PREFERRED-RT-OPT]) |
932 | # ------------------------------- | |
933 | # Look for Boost MPI. For the documentation of PREFERRED-RT-OPT, see the | |
934 | # documentation of BOOST_FIND_LIB above. Uses MPICXX variable if it is | |
935 | # set, otherwise tries CXX | |
936 | # | |
937 | BOOST_DEFUN([MPI], | |
938 | [boost_save_CXX=${CXX} | |
939 | boost_save_CXXCPP=${CXXCPP} | |
940 | if test x"${MPICXX}" != x; then | |
941 | CXX=${MPICXX} | |
942 | CXXCPP="${MPICXX} -E" | |
943 | fi | |
944 | BOOST_FIND_LIB([mpi], [$1], | |
945 | [boost/mpi.hpp], | |
946 | [int argc = 0; | |
947 | char **argv = 0; | |
948 | boost::mpi::environment env(argc,argv);]) | |
949 | CXX=${boost_save_CXX} | |
950 | CXXCPP=${boost_save_CXXCPP} | |
951 | ])# BOOST_MPI | |
952 | ||
953 | ||
94ac5f34 PD |
954 | # BOOST_MULTIARRAY() |
955 | # ------------------ | |
956 | # Look for Boost.MultiArray | |
957 | BOOST_DEFUN([MultiArray], | |
958 | [BOOST_FIND_HEADER([boost/multi_array.hpp])]) | |
959 | ||
960 | ||
2187934a RK |
961 | # BOOST_NUMERIC_UBLAS() |
962 | # -------------------------- | |
963 | # Look for Boost.NumericUblas (Basic Linear Algebra) | |
964 | BOOST_DEFUN([Numeric_Ublas], | |
965 | [BOOST_FIND_HEADER([boost/numeric/ublas/vector.hpp]) | |
966 | ])# BOOST_NUMERIC_UBLAS | |
967 | ||
968 | ||
94ac5f34 PD |
969 | # BOOST_NUMERIC_CONVERSION() |
970 | # -------------------------- | |
971 | # Look for Boost.NumericConversion (policy-based numeric conversion) | |
972 | BOOST_DEFUN([Numeric_Conversion], | |
973 | [BOOST_FIND_HEADER([boost/numeric/conversion/converter.hpp]) | |
974 | ])# BOOST_NUMERIC_CONVERSION | |
975 | ||
976 | ||
977 | # BOOST_OPTIONAL() | |
978 | # ---------------- | |
979 | # Look for Boost.Optional | |
980 | BOOST_DEFUN([Optional], | |
981 | [BOOST_FIND_HEADER([boost/optional.hpp])]) | |
982 | ||
983 | ||
984 | # BOOST_PREPROCESSOR() | |
985 | # -------------------- | |
986 | # Look for Boost.Preprocessor | |
987 | BOOST_DEFUN([Preprocessor], | |
988 | [BOOST_FIND_HEADER([boost/preprocessor/repeat.hpp])]) | |
989 | ||
990 | ||
2187934a RK |
991 | # BOOST_RANGE() |
992 | # -------------------- | |
993 | # Look for Boost.Range | |
994 | BOOST_DEFUN([Range], | |
995 | [BOOST_FIND_HEADER([boost/range/adaptors.hpp])]) | |
996 | ||
94ac5f34 PD |
997 | # BOOST_UNORDERED() |
998 | # ----------------- | |
999 | # Look for Boost.Unordered | |
1000 | BOOST_DEFUN([Unordered], | |
1001 | [BOOST_FIND_HEADER([boost/unordered_map.hpp])]) | |
1002 | ||
1003 | ||
1004 | # BOOST_UUID() | |
1005 | # ------------ | |
1006 | # Look for Boost.Uuid | |
1007 | BOOST_DEFUN([Uuid], | |
1008 | [BOOST_FIND_HEADER([boost/uuid/uuid.hpp])]) | |
1009 | ||
1010 | ||
1011 | # BOOST_PROGRAM_OPTIONS([PREFERRED-RT-OPT]) | |
1012 | # ----------------------------------------- | |
1013 | # Look for Boost.Program_options. For the documentation of PREFERRED-RT-OPT, | |
1014 | # see the documentation of BOOST_FIND_LIB above. | |
1015 | BOOST_DEFUN([Program_Options], | |
1016 | [BOOST_FIND_LIB([program_options], [$1], | |
1017 | [boost/program_options.hpp], | |
1018 | [boost::program_options::options_description d("test");]) | |
1019 | ])# BOOST_PROGRAM_OPTIONS | |
1020 | ||
1021 | ||
1022 | ||
1023 | # _BOOST_PYTHON_CONFIG(VARIABLE, FLAG) | |
1024 | # ------------------------------------ | |
1025 | # Save VARIABLE, and define it via `python-config --FLAG`. | |
1026 | # Substitute BOOST_PYTHON_VARIABLE. | |
1027 | m4_define([_BOOST_PYTHON_CONFIG], | |
1028 | [AC_SUBST([BOOST_PYTHON_$1], | |
1029 | [`python-config --$2 2>/dev/null`])dnl | |
1030 | boost_python_save_$1=$$1 | |
1031 | $1="$$1 $BOOST_PYTHON_$1"]) | |
1032 | ||
1033 | ||
1034 | # BOOST_PYTHON([PREFERRED-RT-OPT]) | |
1035 | # -------------------------------- | |
1036 | # Look for Boost.Python. For the documentation of PREFERRED-RT-OPT, | |
1037 | # see the documentation of BOOST_FIND_LIB above. | |
1038 | BOOST_DEFUN([Python], | |
1039 | [_BOOST_PYTHON_CONFIG([CPPFLAGS], [includes]) | |
1040 | _BOOST_PYTHON_CONFIG([LDFLAGS], [ldflags]) | |
1041 | _BOOST_PYTHON_CONFIG([LIBS], [libs]) | |
1042 | m4_pattern_allow([^BOOST_PYTHON_MODULE$])dnl | |
2187934a RK |
1043 | BOOST_FIND_LIBS([python], [python python3], [$1], |
1044 | [boost/python.hpp], | |
1045 | [], [BOOST_PYTHON_MODULE(empty) {}]) | |
94ac5f34 PD |
1046 | CPPFLAGS=$boost_python_save_CPPFLAGS |
1047 | LDFLAGS=$boost_python_save_LDFLAGS | |
1048 | LIBS=$boost_python_save_LIBS | |
1049 | ])# BOOST_PYTHON | |
1050 | ||
1051 | ||
1052 | # BOOST_REF() | |
1053 | # ----------- | |
1054 | # Look for Boost.Ref | |
1055 | BOOST_DEFUN([Ref], | |
1056 | [BOOST_FIND_HEADER([boost/ref.hpp])]) | |
1057 | ||
1058 | ||
1059 | # BOOST_REGEX([PREFERRED-RT-OPT]) | |
1060 | # ------------------------------- | |
1061 | # Look for Boost.Regex. For the documentation of PREFERRED-RT-OPT, see the | |
1062 | # documentation of BOOST_FIND_LIB above. | |
1063 | BOOST_DEFUN([Regex], | |
1064 | [BOOST_FIND_LIB([regex], [$1], | |
1065 | [boost/regex.hpp], | |
1066 | [boost::regex exp("*"); boost::regex_match("foo", exp);]) | |
1067 | ])# BOOST_REGEX | |
1068 | ||
1069 | ||
1070 | # BOOST_SERIALIZATION([PREFERRED-RT-OPT]) | |
1071 | # --------------------------------------- | |
1072 | # Look for Boost.Serialization. For the documentation of PREFERRED-RT-OPT, see | |
1073 | # the documentation of BOOST_FIND_LIB above. | |
1074 | BOOST_DEFUN([Serialization], | |
1075 | [BOOST_FIND_LIB([serialization], [$1], | |
1076 | [boost/archive/text_oarchive.hpp], | |
1077 | [std::ostream* o = 0; // Cheap way to get an ostream... | |
1078 | boost::archive::text_oarchive t(*o);]) | |
1079 | ])# BOOST_SERIALIZATION | |
1080 | ||
1081 | ||
1082 | # BOOST_SIGNALS([PREFERRED-RT-OPT]) | |
1083 | # --------------------------------- | |
1084 | # Look for Boost.Signals. For the documentation of PREFERRED-RT-OPT, see the | |
1085 | # documentation of BOOST_FIND_LIB above. | |
1086 | BOOST_DEFUN([Signals], | |
1087 | [BOOST_FIND_LIB([signals], [$1], | |
1088 | [boost/signal.hpp], | |
1089 | [boost::signal<void ()> s;]) | |
1090 | ])# BOOST_SIGNALS | |
1091 | ||
1092 | ||
1093 | # BOOST_SIGNALS2() | |
1094 | # ---------------- | |
1095 | # Look for Boost.Signals2 (new since 1.39.0). | |
1096 | BOOST_DEFUN([Signals2], | |
1097 | [BOOST_FIND_HEADER([boost/signals2.hpp]) | |
1098 | ])# BOOST_SIGNALS2 | |
1099 | ||
1100 | ||
1101 | # BOOST_SMART_PTR() | |
1102 | # ----------------- | |
1103 | # Look for Boost.SmartPtr | |
1104 | BOOST_DEFUN([Smart_Ptr], | |
1105 | [BOOST_FIND_HEADER([boost/scoped_ptr.hpp]) | |
1106 | BOOST_FIND_HEADER([boost/shared_ptr.hpp]) | |
1107 | ]) | |
1108 | ||
1109 | ||
1110 | # BOOST_STATICASSERT() | |
1111 | # -------------------- | |
1112 | # Look for Boost.StaticAssert | |
1113 | BOOST_DEFUN([StaticAssert], | |
1114 | [BOOST_FIND_HEADER([boost/static_assert.hpp])]) | |
1115 | ||
1116 | ||
1117 | # BOOST_STRING_ALGO() | |
1118 | # ------------------- | |
1119 | # Look for Boost.StringAlgo | |
1120 | BOOST_DEFUN([String_Algo], | |
1121 | [BOOST_FIND_HEADER([boost/algorithm/string.hpp]) | |
1122 | ]) | |
1123 | ||
1124 | ||
1125 | # BOOST_SYSTEM([PREFERRED-RT-OPT]) | |
1126 | # -------------------------------- | |
1127 | # Look for Boost.System. For the documentation of PREFERRED-RT-OPT, see the | |
1128 | # documentation of BOOST_FIND_LIB above. This library was introduced in Boost | |
1129 | # 1.35.0. | |
1130 | BOOST_DEFUN([System], | |
1131 | [BOOST_FIND_LIB([system], [$1], | |
1132 | [boost/system/error_code.hpp], | |
1133 | [boost::system::error_code e; e.clear();]) | |
1134 | ])# BOOST_SYSTEM | |
1135 | ||
1136 | ||
1137 | # BOOST_TEST([PREFERRED-RT-OPT]) | |
1138 | # ------------------------------ | |
1139 | # Look for Boost.Test. For the documentation of PREFERRED-RT-OPT, see the | |
1140 | # documentation of BOOST_FIND_LIB above. | |
1141 | BOOST_DEFUN([Test], | |
1142 | [m4_pattern_allow([^BOOST_CHECK$])dnl | |
1143 | BOOST_FIND_LIB([unit_test_framework], [$1], | |
1144 | [boost/test/unit_test.hpp], [BOOST_CHECK(2 == 2);], | |
1145 | [using boost::unit_test::test_suite; | |
1146 | test_suite* init_unit_test_suite(int argc, char ** argv) | |
1147 | { return NULL; }]) | |
1148 | ])# BOOST_TEST | |
1149 | ||
1150 | ||
2187934a | 1151 | # BOOST_THREAD([PREFERRED-RT-OPT]) |
94ac5f34 PD |
1152 | # --------------------------------- |
1153 | # Look for Boost.Thread. For the documentation of PREFERRED-RT-OPT, see the | |
1154 | # documentation of BOOST_FIND_LIB above. | |
2187934a | 1155 | BOOST_DEFUN([Thread], |
94ac5f34 PD |
1156 | [dnl Having the pthread flag is required at least on GCC3 where |
1157 | dnl boost/thread.hpp would complain if we try to compile without | |
1158 | dnl -pthread on GNU/Linux. | |
1159 | AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl | |
2187934a RK |
1160 | boost_thread_save_LIBS=$LIBS |
1161 | boost_thread_save_LDFLAGS=$LDFLAGS | |
1162 | boost_thread_save_CPPFLAGS=$CPPFLAGS | |
94ac5f34 PD |
1163 | # Link-time dependency from thread to system was added as of 1.49.0. |
1164 | if test $boost_major_version -ge 149; then | |
1165 | BOOST_SYSTEM([$1]) | |
1166 | fi # end of the Boost.System check. | |
1167 | m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl | |
1168 | LIBS="$LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag" | |
1169 | LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" | |
94ac5f34 PD |
1170 | CPPFLAGS="$CPPFLAGS $boost_cv_pthread_flag" |
1171 | ||
1172 | # When compiling for the Windows platform, the threads library is named | |
b0d6e9e6 KM |
1173 | # differently. This suffix doesn't exist in new versions of Boost, or |
1174 | # possibly new versions of GCC on mingw I am assuming it's Boost's change for | |
1175 | # now and I am setting version to 1.48, for lack of knowledge as to when this | |
1176 | # change occurred. | |
1177 | if test $boost_major_version -lt 148; then | |
1178 | case $host_os in | |
1179 | (*mingw*) boost_thread_lib_ext=_win32;; | |
1180 | esac | |
1181 | fi | |
2187934a RK |
1182 | BOOST_FIND_LIBS([thread], [thread$boost_thread_lib_ext], |
1183 | [$1], | |
1184 | [boost/thread.hpp], [boost::thread t; boost::mutex m;]) | |
94ac5f34 | 1185 | |
b0d6e9e6 KM |
1186 | case $host_os in |
1187 | (*mingw*) boost_thread_w32_socket_link=-lws2_32;; | |
1188 | esac | |
1189 | ||
1190 | BOOST_THREAD_LIBS="$BOOST_THREAD_LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag $boost_thread_w32_socket_link" | |
94ac5f34 PD |
1191 | BOOST_THREAD_LDFLAGS="$BOOST_SYSTEM_LDFLAGS" |
1192 | BOOST_CPPFLAGS="$BOOST_CPPFLAGS $boost_cv_pthread_flag" | |
2187934a RK |
1193 | LIBS=$boost_thread_save_LIBS |
1194 | LDFLAGS=$boost_thread_save_LDFLAGS | |
1195 | CPPFLAGS=$boost_thread_save_CPPFLAGS | |
1196 | ])# BOOST_THREAD | |
1197 | ||
1198 | AU_ALIAS([BOOST_THREADS], [BOOST_THREAD]) | |
94ac5f34 PD |
1199 | |
1200 | ||
1201 | # BOOST_TOKENIZER() | |
1202 | # ----------------- | |
1203 | # Look for Boost.Tokenizer | |
1204 | BOOST_DEFUN([Tokenizer], | |
1205 | [BOOST_FIND_HEADER([boost/tokenizer.hpp])]) | |
1206 | ||
1207 | ||
1208 | # BOOST_TRIBOOL() | |
1209 | # --------------- | |
1210 | # Look for Boost.Tribool | |
1211 | BOOST_DEFUN([Tribool], | |
1212 | [BOOST_FIND_HEADER([boost/logic/tribool_fwd.hpp]) | |
1213 | BOOST_FIND_HEADER([boost/logic/tribool.hpp]) | |
1214 | ]) | |
1215 | ||
1216 | ||
1217 | # BOOST_TUPLE() | |
1218 | # ------------- | |
1219 | # Look for Boost.Tuple | |
1220 | BOOST_DEFUN([Tuple], | |
1221 | [BOOST_FIND_HEADER([boost/tuple/tuple.hpp])]) | |
1222 | ||
1223 | ||
1224 | # BOOST_TYPETRAITS() | |
1225 | # -------------------- | |
1226 | # Look for Boost.TypeTraits | |
1227 | BOOST_DEFUN([TypeTraits], | |
1228 | [BOOST_FIND_HEADER([boost/type_traits.hpp])]) | |
1229 | ||
1230 | ||
1231 | # BOOST_UTILITY() | |
1232 | # --------------- | |
1233 | # Look for Boost.Utility (noncopyable, result_of, base-from-member idiom, | |
1234 | # etc.) | |
1235 | BOOST_DEFUN([Utility], | |
1236 | [BOOST_FIND_HEADER([boost/utility.hpp])]) | |
1237 | ||
1238 | ||
1239 | # BOOST_VARIANT() | |
1240 | # --------------- | |
1241 | # Look for Boost.Variant. | |
1242 | BOOST_DEFUN([Variant], | |
1243 | [BOOST_FIND_HEADER([boost/variant/variant_fwd.hpp]) | |
1244 | BOOST_FIND_HEADER([boost/variant.hpp])]) | |
1245 | ||
2187934a RK |
1246 | |
1247 | # BOOST_POINTER_CONTAINER() | |
94ac5f34 PD |
1248 | # ------------------------ |
1249 | # Look for Boost.PointerContainer | |
1250 | BOOST_DEFUN([Pointer_Container], | |
1251 | [BOOST_FIND_HEADER([boost/ptr_container/ptr_deque.hpp]) | |
1252 | BOOST_FIND_HEADER([boost/ptr_container/ptr_list.hpp]) | |
1253 | BOOST_FIND_HEADER([boost/ptr_container/ptr_vector.hpp]) | |
1254 | BOOST_FIND_HEADER([boost/ptr_container/ptr_array.hpp]) | |
1255 | BOOST_FIND_HEADER([boost/ptr_container/ptr_set.hpp]) | |
1256 | BOOST_FIND_HEADER([boost/ptr_container/ptr_map.hpp]) | |
2187934a RK |
1257 | ])# BOOST_POINTER_CONTAINER |
1258 | ||
94ac5f34 PD |
1259 | |
1260 | # BOOST_WAVE([PREFERRED-RT-OPT]) | |
1261 | # ------------------------------ | |
1262 | # NOTE: If you intend to use Wave/Spirit with thread support, make sure you | |
2187934a | 1263 | # call BOOST_THREAD first. |
94ac5f34 PD |
1264 | # Look for Boost.Wave. For the documentation of PREFERRED-RT-OPT, see the |
1265 | # documentation of BOOST_FIND_LIB above. | |
1266 | BOOST_DEFUN([Wave], | |
1267 | [AC_REQUIRE([BOOST_FILESYSTEM])dnl | |
1268 | AC_REQUIRE([BOOST_DATE_TIME])dnl | |
1269 | boost_wave_save_LIBS=$LIBS | |
1270 | boost_wave_save_LDFLAGS=$LDFLAGS | |
1271 | m4_pattern_allow([^BOOST_((FILE)?SYSTEM|DATE_TIME|THREAD)_(LIBS|LDFLAGS)$])dnl | |
1272 | LIBS="$LIBS $BOOST_SYSTEM_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_DATE_TIME_LIBS \ | |
1273 | $BOOST_THREAD_LIBS" | |
1274 | LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS \ | |
1275 | $BOOST_DATE_TIME_LDFLAGS $BOOST_THREAD_LDFLAGS" | |
1276 | BOOST_FIND_LIB([wave], [$1], | |
1277 | [boost/wave.hpp], | |
1278 | [boost::wave::token_id id; get_token_name(id);]) | |
1279 | LIBS=$boost_wave_save_LIBS | |
1280 | LDFLAGS=$boost_wave_save_LDFLAGS | |
1281 | ])# BOOST_WAVE | |
1282 | ||
1283 | ||
1284 | # BOOST_XPRESSIVE() | |
1285 | # ----------------- | |
1286 | # Look for Boost.Xpressive (new since 1.36.0). | |
1287 | BOOST_DEFUN([Xpressive], | |
1288 | [BOOST_FIND_HEADER([boost/xpressive/xpressive.hpp])]) | |
1289 | ||
1290 | ||
1291 | # ----------------- # | |
1292 | # Internal helpers. # | |
1293 | # ----------------- # | |
1294 | ||
1295 | ||
1296 | # _BOOST_PTHREAD_FLAG() | |
1297 | # --------------------- | |
2187934a RK |
1298 | # Internal helper for BOOST_THREAD. Computes boost_cv_pthread_flag |
1299 | # which must be used in CPPFLAGS and LIBS. | |
1300 | # | |
1301 | # Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3, | |
1302 | # boost/thread.hpp will trigger a #error if -pthread isn't used: | |
1303 | # boost/config/requires_threads.hpp:47:5: #error "Compiler threading support | |
1304 | # is not turned on. Please set the correct command line options for | |
1305 | # threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)" | |
1306 | # | |
1307 | # Based on ACX_PTHREAD: http://autoconf-archive.cryp.to/acx_pthread.html | |
94ac5f34 PD |
1308 | AC_DEFUN([_BOOST_PTHREAD_FLAG], |
1309 | [AC_REQUIRE([AC_PROG_CXX])dnl | |
1310 | AC_REQUIRE([AC_CANONICAL_HOST])dnl | |
1311 | AC_LANG_PUSH([C++])dnl | |
1312 | AC_CACHE_CHECK([for the flags needed to use pthreads], [boost_cv_pthread_flag], | |
1313 | [ boost_cv_pthread_flag= | |
1314 | # The ordering *is* (sometimes) important. Some notes on the | |
1315 | # individual items follow: | |
1316 | # (none): in case threads are in libc; should be tried before -Kthread and | |
1317 | # other compiler flags to prevent continual compiler warnings | |
1318 | # -lpthreads: AIX (must check this before -lpthread) | |
1319 | # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) | |
1320 | # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) | |
1321 | # -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread) | |
1322 | # -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads) | |
1323 | # -pthreads: Solaris/GCC | |
1324 | # -mthreads: MinGW32/GCC, Lynx/GCC | |
1325 | # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it | |
1326 | # doesn't hurt to check since this sometimes defines pthreads too; | |
1327 | # also defines -D_REENTRANT) | |
1328 | # ... -mt is also the pthreads flag for HP/aCC | |
1329 | # -lpthread: GNU Linux, etc. | |
1330 | # --thread-safe: KAI C++ | |
1331 | case $host_os in #( | |
1332 | *solaris*) | |
1333 | # On Solaris (at least, for some versions), libc contains stubbed | |
1334 | # (non-functional) versions of the pthreads routines, so link-based | |
1335 | # tests will erroneously succeed. (We need to link with -pthreads/-mt/ | |
1336 | # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather | |
1337 | # a function called by this macro, so we could check for that, but | |
1338 | # who knows whether they'll stub that too in a future libc.) So, | |
1339 | # we'll just look for -pthreads and -lpthread first: | |
1340 | boost_pthread_flags="-pthreads -lpthread -mt -pthread";; #( | |
1341 | *) | |
1342 | boost_pthread_flags="-lpthreads -Kthread -kthread -llthread -pthread \ | |
1343 | -pthreads -mthreads -lpthread --thread-safe -mt";; | |
1344 | esac | |
1345 | # Generate the test file. | |
1346 | AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <pthread.h>], | |
1347 | [pthread_t th; pthread_join(th, 0); | |
1348 | pthread_attr_init(0); pthread_cleanup_push(0, 0); | |
1349 | pthread_create(0,0,0,0); pthread_cleanup_pop(0);])]) | |
1350 | for boost_pthread_flag in '' $boost_pthread_flags; do | |
1351 | boost_pthread_ok=false | |
1352 | dnl Re-use the test file already generated. | |
1353 | boost_pthreads__save_LIBS=$LIBS | |
1354 | LIBS="$LIBS $boost_pthread_flag" | |
1355 | AC_LINK_IFELSE([], | |
1356 | [if grep ".*$boost_pthread_flag" conftest.err; then | |
1357 | echo "This flag seems to have triggered warnings" >&AS_MESSAGE_LOG_FD | |
1358 | else | |
1359 | boost_pthread_ok=:; boost_cv_pthread_flag=$boost_pthread_flag | |
1360 | fi]) | |
1361 | LIBS=$boost_pthreads__save_LIBS | |
1362 | $boost_pthread_ok && break | |
1363 | done | |
1364 | ]) | |
1365 | AC_LANG_POP([C++])dnl | |
1366 | ])# _BOOST_PTHREAD_FLAG | |
1367 | ||
1368 | ||
1369 | # _BOOST_gcc_test(MAJOR, MINOR) | |
1370 | # ----------------------------- | |
1371 | # Internal helper for _BOOST_FIND_COMPILER_TAG. | |
1372 | m4_define([_BOOST_gcc_test], | |
1373 | ["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC @ gcc$1$2"])dnl | |
1374 | ||
2187934a RK |
1375 | # _BOOST_mingw_test(MAJOR, MINOR) |
1376 | # ----------------------------- | |
1377 | # Internal helper for _BOOST_FIND_COMPILER_TAG. | |
1378 | m4_define([_BOOST_mingw_test], | |
1379 | ["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC && \ | |
1380 | (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \ | |
1381 | || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw$1$2"])dnl | |
1382 | ||
94ac5f34 PD |
1383 | |
1384 | # _BOOST_FIND_COMPILER_TAG() | |
1385 | # -------------------------- | |
1386 | # Internal. When Boost is installed without --layout=system, each library | |
1387 | # filename will hold a suffix that encodes the compiler used during the | |
1388 | # build. The Boost build system seems to call this a `tag'. | |
1389 | AC_DEFUN([_BOOST_FIND_COMPILER_TAG], | |
1390 | [AC_REQUIRE([AC_PROG_CXX])dnl | |
1391 | AC_REQUIRE([AC_CANONICAL_HOST])dnl | |
2187934a RK |
1392 | AC_CACHE_CHECK([for the toolset name used by Boost for $CXX], |
1393 | [boost_cv_lib_tag], | |
94ac5f34 PD |
1394 | [boost_cv_lib_tag=unknown |
1395 | if test x$boost_cv_inc_path != xno; then | |
1396 | AC_LANG_PUSH([C++])dnl | |
1397 | # The following tests are mostly inspired by boost/config/auto_link.hpp | |
1398 | # The list is sorted to most recent/common to oldest compiler (in order | |
1399 | # to increase the likelihood of finding the right compiler with the | |
1400 | # least number of compilation attempt). | |
1401 | # Beware that some tests are sensible to the order (for instance, we must | |
1402 | # look for MinGW before looking for GCC3). | |
1403 | # I used one compilation test per compiler with a #error to recognize | |
1404 | # each compiler so that it works even when cross-compiling (let me know | |
1405 | # if you know a better approach). | |
1406 | # Known missing tags (known from Boost's tools/build/v2/tools/common.jam): | |
1407 | # como, edg, kcc, bck, mp, sw, tru, xlc | |
1408 | # I'm not sure about my test for `il' (be careful: Intel's ICC pre-defines | |
1409 | # the same defines as GCC's). | |
1410 | for i in \ | |
3b6c745f KM |
1411 | _BOOST_mingw_test(6, 0) \ |
1412 | _BOOST_gcc_test(6, 0) \ | |
afdd465f PL |
1413 | _BOOST_mingw_test(5, 3) \ |
1414 | _BOOST_gcc_test(5, 3) \ | |
fe6a830f PL |
1415 | _BOOST_mingw_test(5, 2) \ |
1416 | _BOOST_gcc_test(5, 2) \ | |
016ed2c1 RK |
1417 | _BOOST_mingw_test(5, 1) \ |
1418 | _BOOST_gcc_test(5, 1) \ | |
2187934a RK |
1419 | _BOOST_mingw_test(5, 0) \ |
1420 | _BOOST_gcc_test(5, 0) \ | |
1421 | _BOOST_mingw_test(4, 10) \ | |
1422 | _BOOST_gcc_test(4, 10) \ | |
1423 | _BOOST_mingw_test(4, 9) \ | |
94ac5f34 | 1424 | _BOOST_gcc_test(4, 9) \ |
2187934a | 1425 | _BOOST_mingw_test(4, 8) \ |
94ac5f34 | 1426 | _BOOST_gcc_test(4, 8) \ |
2187934a | 1427 | _BOOST_mingw_test(4, 7) \ |
94ac5f34 | 1428 | _BOOST_gcc_test(4, 7) \ |
2187934a | 1429 | _BOOST_mingw_test(4, 6) \ |
94ac5f34 | 1430 | _BOOST_gcc_test(4, 6) \ |
2187934a | 1431 | _BOOST_mingw_test(4, 5) \ |
94ac5f34 | 1432 | _BOOST_gcc_test(4, 5) \ |
2187934a | 1433 | _BOOST_mingw_test(4, 4) \ |
94ac5f34 | 1434 | _BOOST_gcc_test(4, 4) \ |
2187934a | 1435 | _BOOST_mingw_test(4, 3) \ |
94ac5f34 | 1436 | _BOOST_gcc_test(4, 3) \ |
2187934a | 1437 | _BOOST_mingw_test(4, 2) \ |
94ac5f34 | 1438 | _BOOST_gcc_test(4, 2) \ |
2187934a | 1439 | _BOOST_mingw_test(4, 1) \ |
94ac5f34 | 1440 | _BOOST_gcc_test(4, 1) \ |
2187934a | 1441 | _BOOST_mingw_test(4, 0) \ |
94ac5f34 PD |
1442 | _BOOST_gcc_test(4, 0) \ |
1443 | "defined __GNUC__ && __GNUC__ == 3 && !defined __ICC \ | |
1444 | && (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \ | |
1445 | || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw" \ | |
1446 | _BOOST_gcc_test(3, 4) \ | |
1447 | _BOOST_gcc_test(3, 3) \ | |
1448 | "defined _MSC_VER && _MSC_VER >= 1500 @ vc90" \ | |
1449 | "defined _MSC_VER && _MSC_VER == 1400 @ vc80" \ | |
1450 | _BOOST_gcc_test(3, 2) \ | |
1451 | "defined _MSC_VER && _MSC_VER == 1310 @ vc71" \ | |
1452 | _BOOST_gcc_test(3, 1) \ | |
1453 | _BOOST_gcc_test(3, 0) \ | |
1454 | "defined __BORLANDC__ @ bcb" \ | |
1455 | "defined __ICC && (defined __unix || defined __unix__) @ il" \ | |
1456 | "defined __ICL @ iw" \ | |
1457 | "defined _MSC_VER && _MSC_VER == 1300 @ vc7" \ | |
1458 | _BOOST_gcc_test(2, 95) \ | |
1459 | "defined __MWERKS__ && __MWERKS__ <= 0x32FF @ cw9" \ | |
1460 | "defined _MSC_VER && _MSC_VER < 1300 && !defined UNDER_CE @ vc6" \ | |
1461 | "defined _MSC_VER && _MSC_VER < 1300 && defined UNDER_CE @ evc4" \ | |
1462 | "defined __MWERKS__ && __MWERKS__ <= 0x31FF @ cw8" | |
1463 | do | |
1464 | boost_tag_test=`expr "X$i" : 'X\([[^@]]*\) @ '` | |
1465 | boost_tag=`expr "X$i" : 'X[[^@]]* @ \(.*\)'` | |
1466 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | |
1467 | #if $boost_tag_test | |
1468 | /* OK */ | |
1469 | #else | |
1470 | # error $boost_tag_test | |
1471 | #endif | |
1472 | ]])], [boost_cv_lib_tag=$boost_tag; break], []) | |
1473 | done | |
1474 | AC_LANG_POP([C++])dnl | |
1475 | case $boost_cv_lib_tag in #( | |
1476 | # Some newer (>= 1.35?) versions of Boost seem to only use "gcc" as opposed | |
1477 | # to "gcc41" for instance. | |
1478 | *-gcc | *'-gcc ') :;; #( Don't re-add -gcc: it's already in there. | |
1479 | gcc*) | |
1480 | boost_tag_x= | |
1481 | case $host_os in #( | |
1482 | darwin*) | |
1483 | if test $boost_major_version -ge 136; then | |
1484 | # The `x' added in r46793 of Boost. | |
1485 | boost_tag_x=x | |
1486 | fi;; | |
1487 | esac | |
1488 | # We can specify multiple tags in this variable because it's used by | |
1489 | # BOOST_FIND_LIB that does a `for tag in -$boost_cv_lib_tag' ... | |
1490 | boost_cv_lib_tag="$boost_tag_x$boost_cv_lib_tag -${boost_tag_x}gcc" | |
1491 | ;; #( | |
1492 | unknown) | |
1493 | AC_MSG_WARN([[could not figure out which toolset name to use for $CXX]]) | |
1494 | boost_cv_lib_tag= | |
1495 | ;; | |
1496 | esac | |
1497 | fi])dnl end of AC_CACHE_CHECK | |
1498 | ])# _BOOST_FIND_COMPILER_TAG | |
1499 | ||
1500 | ||
1501 | # _BOOST_GUESS_WHETHER_TO_USE_MT() | |
1502 | # -------------------------------- | |
1503 | # Compile a small test to try to guess whether we should favor MT (Multi | |
1504 | # Thread) flavors of Boost. Sets boost_guess_use_mt accordingly. | |
1505 | AC_DEFUN([_BOOST_GUESS_WHETHER_TO_USE_MT], | |
1506 | [# Check whether we do better use `mt' even though we weren't ask to. | |
2187934a | 1507 | AC_LANG_PUSH([C++])dnl |
94ac5f34 PD |
1508 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
1509 | #if defined _REENTRANT || defined _MT || defined __MT__ | |
1510 | /* use -mt */ | |
1511 | #else | |
1512 | # error MT not needed | |
1513 | #endif | |
1514 | ]])], [boost_guess_use_mt=:], [boost_guess_use_mt=false]) | |
2187934a | 1515 | AC_LANG_POP([C++])dnl |
94ac5f34 PD |
1516 | ]) |
1517 | ||
1518 | # _BOOST_AC_LINK_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) | |
1519 | # ------------------------------------------------------------------- | |
1520 | # Fork of _AC_LINK_IFELSE that preserves conftest.o across calls. Fragile, | |
1521 | # will break when Autoconf changes its internals. Requires that you manually | |
1522 | # rm -f conftest.$ac_objext in between to really different tests, otherwise | |
1523 | # you will try to link a conftest.o left behind by a previous test. | |
1524 | # Used to aggressively optimize BOOST_FIND_LIB (see the big comment in this | |
1525 | # macro). | |
1526 | # | |
1527 | # Don't use "break" in the actions, as it would short-circuit some code | |
1528 | # this macro runs after the actions. | |
1529 | m4_define([_BOOST_AC_LINK_IFELSE], | |
1530 | [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl | |
1531 | rm -f conftest$ac_exeext | |
1532 | boost_save_ac_ext=$ac_ext | |
1533 | boost_use_source=: | |
1534 | # If we already have a .o, re-use it. We change $ac_ext so that $ac_link | |
1535 | # tries to link the existing object file instead of compiling from source. | |
1536 | test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false && | |
1537 | _AS_ECHO_LOG([re-using the existing conftest.$ac_objext]) | |
1538 | AS_IF([_AC_DO_STDERR($ac_link) && { | |
2187934a RK |
1539 | test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" || |
1540 | test ! -s conftest.err | |
94ac5f34 | 1541 | } && test -s conftest$ac_exeext && { |
2187934a RK |
1542 | test "$cross_compiling" = yes || |
1543 | $as_executable_p conftest$ac_exeext | |
94ac5f34 PD |
1544 | dnl FIXME: use AS_TEST_X instead when 2.61 is widespread enough. |
1545 | }], | |
1546 | [$2], | |
1547 | [if $boost_use_source; then | |
1548 | _AC_MSG_LOG_CONFTEST | |
1549 | fi | |
1550 | $3]) | |
1551 | ac_objext=$boost_save_ac_objext | |
1552 | ac_ext=$boost_save_ac_ext | |
1553 | dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization) | |
1554 | dnl information created by the PGI compiler (conftest_ipa8_conftest.oo), | |
1555 | dnl as it would interfere with the next link command. | |
1556 | rm -f core conftest.err conftest_ipa8_conftest.oo \ | |
1557 | conftest$ac_exeext m4_ifval([$1], [conftest.$ac_ext])[]dnl | |
1558 | ])# _BOOST_AC_LINK_IFELSE | |
1559 | ||
1560 | # Local Variables: | |
1561 | # mode: autoconf | |
1562 | # End: |