Advertisement
FlyFar

boost.m4

Feb 8th, 2024
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.79 KB | Cybersecurity | 0 0
  1. # boost.m4: Locate Boost headers and libraries for autoconf-based projects.
  2. # Copyright (C) 2007, 2008, 2009, 2010 Benoit Sigoure <tsuna@lrde.epita.fr>
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # Additional permission under section 7 of the GNU General Public
  10. # License, version 3 ("GPLv3"):
  11. #
  12. # If you convey this file as part of a work that contains a
  13. # configuration script generated by Autoconf, you may do so under
  14. # terms of your choice.
  15. #
  16. # This program is distributed in the hope that it will be useful,
  17. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. # GNU General Public License for more details.
  20. #
  21. # You should have received a copy of the GNU General Public License
  22. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  23.  
  24. m4_define([_BOOST_SERIAL], [m4_translit([
  25. # serial 13
  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_])
  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. # PATTERN is *not* overquoted, as in AC_EGREP_CPP. It could be useful
  56. # to turn this into a macro which extracts the value of any macro.
  57. m4_define([_BOOST_SED_CPP],
  58. [AC_LANG_PREPROC_REQUIRE()dnl
  59. AC_REQUIRE([AC_PROG_SED])dnl
  60. AC_LANG_CONFTEST([AC_LANG_SOURCE([[$2]])])
  61. AS_IF([dnl eval is necessary to expand ac_cpp.
  62. dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
  63. dnl Beware of Windows end-of-lines, for instance if we are running
  64. dnl some Windows programs under Wine. In that case, boost/version.hpp
  65. dnl is certainly using "\r\n", but the regular Unix shell will only
  66. dnl strip `\n' with backquotes, not the `\r'. This results in
  67. dnl boost_cv_lib_version='1_37\r' for instance, which breaks
  68. dnl everything else.
  69. dnl Cannot use 'dnl' after [$4] because a trailing dnl may break AC_CACHE_CHECK
  70. (eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
  71. tr -d '\r' |
  72. $SED -n -e "$1" >conftest.i 2>&1],
  73. [$3],
  74. [$4])
  75. rm -rf conftest*
  76. ])# AC_EGREP_CPP
  77.  
  78.  
  79.  
  80. # BOOST_REQUIRE([VERSION], [ACTION-IF-NOT-FOUND])
  81. # -----------------------------------------------
  82. # Look for Boost. If version is given, it must either be a literal of the form
  83. # "X.Y.Z" where X, Y and Z are integers (the ".Z" part being optional) or a
  84. # variable "$var".
  85. # Defines the value BOOST_CPPFLAGS. This macro only checks for headers with
  86. # the required version, it does not check for any of the Boost libraries.
  87. # On # success, defines HAVE_BOOST. On failure, calls the optional
  88. # ACTION-IF-NOT-FOUND action if one was supplied.
  89. # Otherwise aborts with an error message.
  90. AC_DEFUN([BOOST_REQUIRE],
  91. [AC_REQUIRE([AC_PROG_CXX])dnl
  92. AC_REQUIRE([AC_PROG_GREP])dnl
  93. echo "$as_me: this is boost.m4[]_BOOST_SERIAL" >&AS_MESSAGE_LOG_FD
  94. boost_save_IFS=$IFS
  95. boost_version_req=$1
  96. IFS=.
  97. set x $boost_version_req 0 0 0
  98. IFS=$boost_save_IFS
  99. shift
  100. boost_version_req=`expr "$[1]" '*' 100000 + "$[2]" '*' 100 + "$[3]"`
  101. boost_version_req_string=$[1].$[2].$[3]
  102. AC_ARG_WITH([boost],
  103. [AS_HELP_STRING([--with-boost=DIR],
  104. [prefix of Boost $1 @<:@guess@:>@])])dnl
  105. AC_ARG_VAR([BOOST_ROOT],[Location of Boost installation])dnl
  106. # If BOOST_ROOT is set and the user has not provided a value to
  107. # --with-boost, then treat BOOST_ROOT as if it the user supplied it.
  108. if test x"$BOOST_ROOT" != x; then
  109. if test x"$with_boost" = x; then
  110. AC_MSG_NOTICE([Detected BOOST_ROOT; continuing with --with-boost=$BOOST_ROOT])
  111. with_boost=$BOOST_ROOT
  112. else
  113. AC_MSG_NOTICE([Detected BOOST_ROOT=$BOOST_ROOT, but overridden by --with-boost=$with_boost])
  114. fi
  115. fi
  116. AC_SUBST([DISTCHECK_CONFIGURE_FLAGS],
  117. ["$DISTCHECK_CONFIGURE_FLAGS '--with-boost=$with_boost'"])
  118. boost_save_CPPFLAGS=$CPPFLAGS
  119. AC_CACHE_CHECK([for Boost headers version >= $boost_version_req_string],
  120. [boost_cv_inc_path],
  121. [boost_cv_inc_path=no
  122. AC_LANG_PUSH([C++])dnl
  123. m4_pattern_allow([^BOOST_VERSION$])dnl
  124. AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#include <boost/version.hpp>
  125. #if !defined BOOST_VERSION
  126. # error BOOST_VERSION is not defined
  127. #elif BOOST_VERSION < $boost_version_req
  128. # error Boost headers version < $boost_version_req
  129. #endif
  130. ]])])
  131. # If the user provided a value to --with-boost, use it and only it.
  132. case $with_boost in #(
  133. ''|yes) set x '' /opt/local/include /usr/local/include /opt/include \
  134. /usr/include C:/Boost/include;; #(
  135. *) set x "$with_boost/include" "$with_boost";;
  136. esac
  137. shift
  138. for boost_dir
  139. do
  140. # Without --layout=system, Boost (or at least some versions) installs
  141. # itself in <prefix>/include/boost-<version>. This inner loop helps to
  142. # find headers in such directories.
  143. #
  144. # Any ${boost_dir}/boost-x_xx directories are searched in reverse version
  145. # order followed by ${boost_dir}. The final '.' is a sentinel for
  146. # searching $boost_dir" itself. Entries are whitespace separated.
  147. #
  148. # I didn't indent this loop on purpose (to avoid over-indented code)
  149. boost_layout_system_search_list=`cd "$boost_dir" 2>/dev/null \
  150. && ls -1 | "${GREP}" '^boost-' | sort -rn -t- -k2 \
  151. && echo .`
  152. for boost_inc in $boost_layout_system_search_list
  153. do
  154. if test x"$boost_inc" != x.; then
  155. boost_inc="$boost_dir/$boost_inc"
  156. else
  157. boost_inc="$boost_dir" # Uses sentinel in boost_layout_system_search_list
  158. fi
  159. if test x"$boost_inc" != x; then
  160. # We are going to check whether the version of Boost installed
  161. # in $boost_inc is usable by running a compilation that
  162. # #includes it. But if we pass a -I/some/path in which Boost
  163. # is not installed, the compiler will just skip this -I and
  164. # use other locations (either from CPPFLAGS, or from its list
  165. # of system include directories). As a result we would use
  166. # header installed on the machine instead of the /some/path
  167. # specified by the user. So in that precise case (trying
  168. # $boost_inc), make sure the version.hpp exists.
  169. #
  170. # Use test -e as there can be symlinks.
  171. test -e "$boost_inc/boost/version.hpp" || continue
  172. CPPFLAGS="$CPPFLAGS -I$boost_inc"
  173. fi
  174. AC_COMPILE_IFELSE([], [boost_cv_inc_path=yes], [boost_cv_version=no])
  175. if test x"$boost_cv_inc_path" = xyes; then
  176. if test x"$boost_inc" != x; then
  177. boost_cv_inc_path=$boost_inc
  178. fi
  179. break 2
  180. fi
  181. done
  182. done
  183. AC_LANG_POP([C++])dnl
  184. ])
  185. case $boost_cv_inc_path in #(
  186. no)
  187. boost_errmsg="cannot find Boost headers version >= $boost_version_req_string"
  188. m4_if([$2], [], [AC_MSG_ERROR([$boost_errmsg])],
  189. [AC_MSG_NOTICE([$boost_errmsg])])
  190. $2
  191. ;;#(
  192. yes)
  193. BOOST_CPPFLAGS=
  194. ;;#(
  195. *)
  196. AC_SUBST([BOOST_CPPFLAGS], ["-I$boost_cv_inc_path"])
  197. ;;
  198. esac
  199. if test x"$boost_cv_inc_path" != xno; then
  200. AC_DEFINE([HAVE_BOOST], [1],
  201. [Defined if the requested minimum BOOST version is satisfied])
  202. AC_CACHE_CHECK([for Boost's header version],
  203. [boost_cv_lib_version],
  204. [m4_pattern_allow([^BOOST_LIB_VERSION$])dnl
  205. _BOOST_SED_CPP([/^boost-lib-version = /{s///;s/\"//g;p;g;}],
  206. [#include <boost/version.hpp>
  207. boost-lib-version = BOOST_LIB_VERSION],
  208. [boost_cv_lib_version=`cat conftest.i`])])
  209. # e.g. "134" for 1_34_1 or "135" for 1_35
  210. boost_major_version=`echo "$boost_cv_lib_version" | sed 's/_//;s/_.*//'`
  211. case $boost_major_version in #(
  212. '' | *[[!0-9]]*)
  213. AC_MSG_ERROR([invalid value: boost_major_version=$boost_major_version])
  214. ;;
  215. esac
  216. fi
  217. CPPFLAGS=$boost_save_CPPFLAGS
  218. ])# BOOST_REQUIRE
  219.  
  220. # BOOST_STATIC()
  221. # --------------
  222. # Add the "--enable-static-boost" configure argument. If this argument is given
  223. # on the command line, static versions of the libraries will be looked up.
  224. AC_DEFUN([BOOST_STATIC],
  225. [AC_ARG_ENABLE([static-boost],
  226. [AC_HELP_STRING([--enable-static-boost],
  227. [Prefer the static boost libraries over the shared ones [no]])],
  228. [enable_static_boost=yes],
  229. [enable_static_boost=no])])# BOOST_STATIC
  230.  
  231. # BOOST_FIND_HEADER([HEADER-NAME], [ACTION-IF-NOT-FOUND], [ACTION-IF-FOUND])
  232. # --------------------------------------------------------------------------
  233. # Wrapper around AC_CHECK_HEADER for Boost headers. Useful to check for
  234. # some parts of the Boost library which are only made of headers and don't
  235. # require linking (such as Boost.Foreach).
  236. #
  237. # Default ACTION-IF-NOT-FOUND: Fail with a fatal error unless Boost couldn't be
  238. # found in the first place, in which case by default a notice is issued to the
  239. # user. Presumably if we haven't died already it's because it's OK to not have
  240. # Boost, which is why only a notice is issued instead of a hard error.
  241. #
  242. # Default ACTION-IF-FOUND: define the preprocessor symbol HAVE_<HEADER-NAME> in
  243. # case of success # (where HEADER-NAME is written LIKE_THIS, e.g.,
  244. # HAVE_BOOST_FOREACH_HPP).
  245. AC_DEFUN([BOOST_FIND_HEADER],
  246. [AC_REQUIRE([BOOST_REQUIRE])dnl
  247. if test x"$boost_cv_inc_path" = xno; then
  248. m4_default([$2], [AC_MSG_NOTICE([Boost not available, not searching for $1])])
  249. else
  250. AC_LANG_PUSH([C++])dnl
  251. boost_save_CPPFLAGS=$CPPFLAGS
  252. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  253. AC_CHECK_HEADER([$1],
  254. [m4_default([$3], [AC_DEFINE(AS_TR_CPP([HAVE_$1]), [1],
  255. [Define to 1 if you have <$1>])])],
  256. [m4_default([$2], [AC_MSG_ERROR([cannot find $1])])])
  257. CPPFLAGS=$boost_save_CPPFLAGS
  258. AC_LANG_POP([C++])dnl
  259. fi
  260. ])# BOOST_FIND_HEADER
  261.  
  262.  
  263. # BOOST_FIND_LIB([LIB-NAME], [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST],
  264. # [CXX-PROLOGUE])
  265. # -------------------------------------------------------------------------
  266. # Look for the Boost library LIB-NAME (e.g., LIB-NAME = `thread', for
  267. # libboost_thread). Check that HEADER-NAME works and check that
  268. # libboost_LIB-NAME can link with the code CXX-TEST. The optional argument
  269. # CXX-PROLOGUE can be used to include some C++ code before the `main'
  270. # function.
  271. #
  272. # Invokes BOOST_FIND_HEADER([HEADER-NAME]) (see above).
  273. #
  274. # Boost libraries typically come compiled with several flavors (with different
  275. # runtime options) so PREFERRED-RT-OPT is the preferred suffix. A suffix is one
  276. # or more of the following letters: sgdpn (in that order). s = static
  277. # runtime, d = debug build, g = debug/diagnostic runtime, p = STLPort build,
  278. # n = (unsure) STLPort build without iostreams from STLPort (it looks like `n'
  279. # must always be used along with `p'). Additionally, PREFERRED-RT-OPT can
  280. # start with `mt-' to indicate that there is a preference for multi-thread
  281. # builds. Some sample values for PREFERRED-RT-OPT: (nothing), mt, d, mt-d, gdp
  282. # ... If you want to make sure you have a specific version of Boost
  283. # (eg, >= 1.33) you *must* invoke BOOST_REQUIRE before this macro.
  284. AC_DEFUN([BOOST_FIND_LIB],
  285. [AC_REQUIRE([BOOST_REQUIRE])dnl
  286. AC_REQUIRE([_BOOST_FIND_COMPILER_TAG])dnl
  287. AC_REQUIRE([BOOST_STATIC])dnl
  288. AC_REQUIRE([_BOOST_GUESS_WHETHER_TO_USE_MT])dnl
  289. if test x"$boost_cv_inc_path" = xno; then
  290. AC_MSG_NOTICE([Boost not available, not searching for the Boost $1 library])
  291. else
  292. dnl The else branch is huge and wasn't intended on purpose.
  293. AC_LANG_PUSH([C++])dnl
  294. AS_VAR_PUSHDEF([Boost_lib], [boost_cv_lib_$1])dnl
  295. AS_VAR_PUSHDEF([Boost_lib_LDFLAGS], [boost_cv_lib_$1_LDFLAGS])dnl
  296. AS_VAR_PUSHDEF([Boost_lib_LDPATH], [boost_cv_lib_$1_LDPATH])dnl
  297. AS_VAR_PUSHDEF([Boost_lib_LIBS], [boost_cv_lib_$1_LIBS])dnl
  298. BOOST_FIND_HEADER([$3])
  299. boost_save_CPPFLAGS=$CPPFLAGS
  300. CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
  301. # Now let's try to find the library. The algorithm is as follows: first look
  302. # for a given library name according to the user's PREFERRED-RT-OPT. For each
  303. # library name, we prefer to use the ones that carry the tag (toolset name).
  304. # Each library is searched through the various standard paths were Boost is
  305. # usually installed. If we can't find the standard variants, we try to
  306. # enforce -mt (for instance on MacOSX, libboost_threads.dylib doesn't exist
  307. # but there's -obviously- libboost_threads-mt.dylib).
  308. AC_CACHE_CHECK([for the Boost $1 library], [Boost_lib],
  309. [Boost_lib=no
  310. case "$2" in #(
  311. mt | mt-) boost_mt=-mt; boost_rtopt=;; #(
  312. mt* | mt-*) boost_mt=-mt; boost_rtopt=`expr "X$2" : 'Xmt-*\(.*\)'`;; #(
  313. *) boost_mt=; boost_rtopt=$2;;
  314. esac
  315. if test $enable_static_boost = yes; then
  316. boost_rtopt="s$boost_rtopt"
  317. fi
  318. # Find the proper debug variant depending on what we've been asked to find.
  319. case $boost_rtopt in #(
  320. *d*) boost_rt_d=$boost_rtopt;; #(
  321. *[[sgpn]]*) # Insert the `d' at the right place (in between `sg' and `pn')
  322. boost_rt_d=`echo "$boost_rtopt" | sed 's/\(s*g*\)\(p*n*\)/\1\2/'`;; #(
  323. *) boost_rt_d='-d';;
  324. esac
  325. # If the PREFERRED-RT-OPT are not empty, prepend a `-'.
  326. test -n "$boost_rtopt" && boost_rtopt="-$boost_rtopt"
  327. $boost_guess_use_mt && boost_mt=-mt
  328. # Look for the abs path the static archive.
  329. # $libext is computed by Libtool but let's make sure it's non empty.
  330. test -z "$libext" &&
  331. AC_MSG_ERROR([the libext variable is empty, did you invoke Libtool?])
  332. boost_save_ac_objext=$ac_objext
  333. # Generate the test file.
  334. AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <$3>
  335. $5], [$4])])
  336. dnl Optimization hacks: compiling C++ is slow, especially with Boost. What
  337. dnl we're trying to do here is guess the right combination of link flags
  338. dnl (LIBS / LDFLAGS) to use a given library. This can take several
  339. dnl iterations before it succeeds and is thus *very* slow. So what we do
  340. dnl instead is that we compile the code first (and thus get an object file,
  341. dnl typically conftest.o). Then we try various combinations of link flags
  342. dnl until we succeed to link conftest.o in an executable. The problem is
  343. dnl that the various TRY_LINK / COMPILE_IFELSE macros of Autoconf always
  344. dnl remove all the temporary files including conftest.o. So the trick here
  345. dnl is to temporarily change the value of ac_objext so that conftest.o is
  346. dnl preserved accross tests. This is obviously fragile and I will burn in
  347. dnl hell for not respecting Autoconf's documented interfaces, but in the
  348. dnl mean time, it optimizes the macro by a factor of 5 to 30.
  349. dnl Another small optimization: the first argument of AC_COMPILE_IFELSE left
  350. dnl empty because the test file is generated only once above (before we
  351. dnl start the for loops).
  352. AC_COMPILE_IFELSE([],
  353. [ac_objext=do_not_rm_me_plz],
  354. [AC_MSG_ERROR([cannot compile a test that uses Boost $1])])
  355. ac_objext=$boost_save_ac_objext
  356. boost_failed_libs=
  357. # Don't bother to ident the 6 nested for loops, only the 2 innermost ones
  358. # matter.
  359. for boost_tag_ in -$boost_cv_lib_tag ''; do
  360. for boost_ver_ in -$boost_cv_lib_version ''; do
  361. for boost_mt_ in $boost_mt -mt ''; do
  362. for boost_rtopt_ in $boost_rtopt '' -d; do
  363. for boost_lib in \
  364. boost_$1$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_ \
  365. boost_$1$boost_tag_$boost_rtopt_$boost_ver_ \
  366. boost_$1$boost_tag_$boost_mt_$boost_ver_ \
  367. boost_$1$boost_tag_$boost_ver_
  368. do
  369. # Avoid testing twice the same lib
  370. case $boost_failed_libs in #(
  371. *@$boost_lib@*) continue;;
  372. esac
  373. # If with_boost is empty, we'll search in /lib first, which is not quite
  374. # right so instead we'll try to a location based on where the headers are.
  375. boost_tmp_lib=$with_boost
  376. test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include}
  377. for boost_ldpath in "$boost_tmp_lib/lib" '' \
  378. /opt/local/lib /usr/local/lib /opt/lib /usr/lib \
  379. "$with_boost" C:/Boost/lib /lib /usr/lib64 /lib64
  380. do
  381. test -e "$boost_ldpath" || continue
  382. boost_save_LDFLAGS=$LDFLAGS
  383. # Are we looking for a static library?
  384. case $boost_ldpath:$boost_rtopt_ in #(
  385. *?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt)
  386. Boost_lib_LIBS="$boost_ldpath/lib$boost_lib.$libext"
  387. test -e "$Boost_lib_LIBS" || continue;; #(
  388. *) # No: use -lboost_foo to find the shared library.
  389. Boost_lib_LIBS="-l$boost_lib";;
  390. esac
  391. boost_save_LIBS=$LIBS
  392. LIBS="$Boost_lib_LIBS $LIBS"
  393. test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath"
  394. dnl First argument of AC_LINK_IFELSE left empty because the test file is
  395. dnl generated only once above (before we start the for loops).
  396. _BOOST_AC_LINK_IFELSE([],
  397. [Boost_lib=yes], [Boost_lib=no])
  398. ac_objext=$boost_save_ac_objext
  399. LDFLAGS=$boost_save_LDFLAGS
  400. LIBS=$boost_save_LIBS
  401. if test x"$Boost_lib" = xyes; then
  402. Boost_lib_LDFLAGS="-L$boost_ldpath -R$boost_ldpath"
  403. Boost_lib_LDPATH="$boost_ldpath"
  404. break 6
  405. else
  406. boost_failed_libs="$boost_failed_libs@$boost_lib@"
  407. fi
  408. done
  409. done
  410. done
  411. done
  412. done
  413. done
  414. rm -f conftest.$ac_objext
  415. ])
  416. case $Boost_lib in #(
  417. no) _AC_MSG_LOG_CONFTEST
  418. AC_MSG_ERROR([cannot not find the flags to link with Boost $1])
  419. ;;
  420. esac
  421. AC_SUBST(AS_TR_CPP([BOOST_$1_LDFLAGS]), [$Boost_lib_LDFLAGS])
  422. AC_SUBST(AS_TR_CPP([BOOST_$1_LDPATH]), [$Boost_lib_LDPATH])
  423. AC_SUBST([BOOST_LDPATH], [$Boost_lib_LDPATH])
  424. AC_SUBST(AS_TR_CPP([BOOST_$1_LIBS]), [$Boost_lib_LIBS])
  425. CPPFLAGS=$boost_save_CPPFLAGS
  426. AS_VAR_POPDEF([Boost_lib])dnl
  427. AS_VAR_POPDEF([Boost_lib_LDFLAGS])dnl
  428. AS_VAR_POPDEF([Boost_lib_LDPATH])dnl
  429. AS_VAR_POPDEF([Boost_lib_LIBS])dnl
  430. AC_LANG_POP([C++])dnl
  431. fi
  432. ])# BOOST_FIND_LIB
  433.  
  434.  
  435. # --------------------------------------- #
  436. # Checks for the various Boost libraries. #
  437. # --------------------------------------- #
  438.  
  439. # List of boost libraries: http://www.boost.org/libs/libraries.htm
  440. # The page http://beta.boost.org/doc/libs is useful: it gives the first release
  441. # version of each library (among other things).
  442.  
  443. # BOOST_ARRAY()
  444. # -------------
  445. # Look for Boost.Array
  446. AC_DEFUN([BOOST_ARRAY],
  447. [BOOST_FIND_HEADER([boost/array.hpp])])
  448.  
  449.  
  450. # BOOST_ASIO()
  451. # ------------
  452. # Look for Boost.Asio (new in Boost 1.35).
  453. AC_DEFUN([BOOST_ASIO],
  454. [AC_REQUIRE([BOOST_SYSTEM])dnl
  455. BOOST_FIND_HEADER([boost/asio.hpp])])
  456.  
  457.  
  458. # BOOST_BIND()
  459. # ------------
  460. # Look for Boost.Bind
  461. AC_DEFUN([BOOST_BIND],
  462. [BOOST_FIND_HEADER([boost/bind.hpp])])
  463.  
  464.  
  465. # BOOST_CONVERSION()
  466. # ------------------
  467. # Look for Boost.Conversion (cast / lexical_cast)
  468. AC_DEFUN([BOOST_CONVERSION],
  469. [BOOST_FIND_HEADER([boost/cast.hpp])
  470. BOOST_FIND_HEADER([boost/lexical_cast.hpp])
  471. ])# BOOST_CONVERSION
  472.  
  473.  
  474. # BOOST_DATE_TIME([PREFERRED-RT-OPT])
  475. # -----------------------------------
  476. # Look for Boost.Date_Time. For the documentation of PREFERRED-RT-OPT, see the
  477. # documentation of BOOST_FIND_LIB above.
  478. AC_DEFUN([BOOST_DATE_TIME],
  479. [BOOST_FIND_LIB([date_time], [$1],
  480. [boost/date_time/posix_time/posix_time.hpp],
  481. [boost::posix_time::ptime t;])
  482. ])# BOOST_DATE_TIME
  483.  
  484.  
  485. # BOOST_FILESYSTEM([PREFERRED-RT-OPT])
  486. # ------------------------------------
  487. # Look for Boost.Filesystem. For the documentation of PREFERRED-RT-OPT, see
  488. # the documentation of BOOST_FIND_LIB above.
  489. # Do not check for boost/filesystem.hpp because this file was introduced in
  490. # 1.34.
  491. AC_DEFUN([BOOST_FILESYSTEM],
  492. [# Do we have to check for Boost.System? This link-time dependency was
  493. # added as of 1.35.0. If we have a version <1.35, we must not attempt to
  494. # find Boost.System as it didn't exist by then.
  495. if test $boost_major_version -ge 135; then
  496. BOOST_SYSTEM([$1])
  497. fi # end of the Boost.System check.
  498. boost_filesystem_save_LIBS=$LIBS
  499. boost_filesystem_save_LDFLAGS=$LDFLAGS
  500. m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
  501. LIBS="$LIBS $BOOST_SYSTEM_LIBS"
  502. LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
  503. BOOST_FIND_LIB([filesystem], [$1],
  504. [boost/filesystem/path.hpp], [boost::filesystem::path p;])
  505. LIBS=$boost_filesystem_save_LIBS
  506. LDFLAGS=$boost_filesystem_save_LDFLAGS
  507. ])# BOOST_FILESYSTEM
  508.  
  509.  
  510. # BOOST_FOREACH()
  511. # ---------------
  512. # Look for Boost.Foreach
  513. AC_DEFUN([BOOST_FOREACH],
  514. [BOOST_FIND_HEADER([boost/foreach.hpp])])
  515.  
  516.  
  517. # BOOST_FORMAT()
  518. # --------------
  519. # Look for Boost.Format
  520. # Note: we can't check for boost/format/format_fwd.hpp because the header isn't
  521. # standalone. It can't be compiled because it triggers the following error:
  522. # boost/format/detail/config_macros.hpp:88: error: 'locale' in namespace 'std'
  523. # does not name a type
  524. AC_DEFUN([BOOST_FORMAT],
  525. [BOOST_FIND_HEADER([boost/format.hpp])])
  526.  
  527.  
  528. # BOOST_FUNCTION()
  529. # ----------------
  530. # Look for Boost.Function
  531. AC_DEFUN([BOOST_FUNCTION],
  532. [BOOST_FIND_HEADER([boost/function.hpp])])
  533.  
  534.  
  535. # BOOST_GRAPH([PREFERRED-RT-OPT])
  536. # -------------------------------
  537. # Look for Boost.Graphs. For the documentation of PREFERRED-RT-OPT, see the
  538. # documentation of BOOST_FIND_LIB above.
  539. AC_DEFUN([BOOST_GRAPH],
  540. [BOOST_FIND_LIB([graph], [$1],
  541. [boost/graph/adjacency_list.hpp], [boost::adjacency_list<> g;])
  542. ])# BOOST_GRAPH
  543.  
  544.  
  545. # BOOST_IOSTREAMS([PREFERRED-RT-OPT])
  546. # -------------------------------
  547. # Look for Boost.IOStreams. For the documentation of PREFERRED-RT-OPT, see the
  548. # documentation of BOOST_FIND_LIB above.
  549. AC_DEFUN([BOOST_IOSTREAMS],
  550. [BOOST_FIND_LIB([iostreams], [$1],
  551. [boost/iostreams/device/file_descriptor.hpp],
  552. [boost::iostreams::file_descriptor fd; fd.close();])
  553. ])# BOOST_IOSTREAMS
  554.  
  555.  
  556. # BOOST_HASH()
  557. # ------------
  558. # Look for Boost.Functional/Hash
  559. AC_DEFUN([BOOST_HASH],
  560. [BOOST_FIND_HEADER([boost/functional/hash.hpp])])
  561.  
  562.  
  563. # BOOST_LAMBDA()
  564. # --------------
  565. # Look for Boost.Lambda
  566. AC_DEFUN([BOOST_LAMBDA],
  567. [BOOST_FIND_HEADER([boost/lambda/lambda.hpp])])
  568.  
  569.  
  570. # BOOST_MATH()
  571. # ------------
  572. # Look for Boost.Math
  573. # TODO: This library isn't header-only but it comes in multiple different
  574. # flavors that don't play well with BOOST_FIND_LIB (e.g, libboost_math_c99,
  575. # libboost_math_c99f, libboost_math_c99l, libboost_math_tr1,
  576. # libboost_math_tr1f, libboost_math_tr1l). This macro must be fixed to do the
  577. # right thing anyway.
  578. AC_DEFUN([BOOST_MATH],
  579. [BOOST_FIND_HEADER([boost/math/special_functions.hpp])])
  580.  
  581.  
  582. # BOOST_MULTIARRAY()
  583. # ------------------
  584. # Look for Boost.MultiArray
  585. AC_DEFUN([BOOST_MULTIARRAY],
  586. [BOOST_FIND_HEADER([boost/multi_array.hpp])])
  587.  
  588.  
  589. # BOOST_NUMERIC_CONVERSION()
  590. # --------------------------
  591. # Look for Boost.NumericConversion (policy-based numeric conversion)
  592. AC_DEFUN([BOOST_NUMERIC_CONVERSION],
  593. [BOOST_FIND_HEADER([boost/numeric/conversion/converter.hpp])
  594. ])# BOOST_NUMERIC_CONVERSION
  595.  
  596.  
  597. # BOOST_OPTIONAL()
  598. # ----------------
  599. # Look for Boost.Optional
  600. AC_DEFUN([BOOST_OPTIONAL],
  601. [BOOST_FIND_HEADER([boost/optional.hpp])])
  602.  
  603.  
  604. # BOOST_PREPROCESSOR()
  605. # --------------------
  606. # Look for Boost.Preprocessor
  607. AC_DEFUN([BOOST_PREPROCESSOR],
  608. [BOOST_FIND_HEADER([boost/preprocessor/repeat.hpp])])
  609.  
  610.  
  611. # BOOST_PROGRAM_OPTIONS([PREFERRED-RT-OPT])
  612. # -----------------------------------------
  613. # Look for Boost.Program_options. For the documentation of PREFERRED-RT-OPT, see
  614. # the documentation of BOOST_FIND_LIB above.
  615. AC_DEFUN([BOOST_PROGRAM_OPTIONS],
  616. [BOOST_FIND_LIB([program_options], [$1],
  617. [boost/program_options.hpp],
  618. [boost::program_options::options_description d("test");])
  619. ])# BOOST_PROGRAM_OPTIONS
  620.  
  621.  
  622. # BOOST_REF()
  623. # -----------
  624. # Look for Boost.Ref
  625. AC_DEFUN([BOOST_REF],
  626. [BOOST_FIND_HEADER([boost/ref.hpp])])
  627.  
  628.  
  629. # BOOST_REGEX([PREFERRED-RT-OPT])
  630. # -------------------------------
  631. # Look for Boost.Regex. For the documentation of PREFERRED-RT-OPT, see the
  632. # documentation of BOOST_FIND_LIB above.
  633. AC_DEFUN([BOOST_REGEX],
  634. [BOOST_FIND_LIB([regex], [$1],
  635. [boost/regex.hpp],
  636. [boost::regex exp("*"); boost::regex_match("foo", exp);])
  637. ])# BOOST_REGEX
  638.  
  639.  
  640. # BOOST_SERIALIZATION([PREFERRED-RT-OPT])
  641. # ---------------------------------------
  642. # Look for Boost.Serialization. For the documentation of PREFERRED-RT-OPT, see
  643. # the documentation of BOOST_FIND_LIB above.
  644. AC_DEFUN([BOOST_SERIALIZATION],
  645. [BOOST_FIND_LIB([serialization], [$1],
  646. [boost/archive/text_oarchive.hpp],
  647. [std::ostream* o = 0; // Cheap way to get an ostream...
  648. boost::archive::text_oarchive t(*o);])
  649. ])# BOOST_SIGNALS
  650.  
  651.  
  652. # BOOST_SIGNALS([PREFERRED-RT-OPT])
  653. # ---------------------------------
  654. # Look for Boost.Signals. For the documentation of PREFERRED-RT-OPT, see the
  655. # documentation of BOOST_FIND_LIB above.
  656. AC_DEFUN([BOOST_SIGNALS],
  657. [BOOST_FIND_LIB([signals], [$1],
  658. [boost/signal.hpp],
  659. [boost::signal<void ()> s;])
  660. ])# BOOST_SIGNALS
  661.  
  662.  
  663. # BOOST_SMART_PTR()
  664. # -----------------
  665. # Look for Boost.SmartPtr
  666. AC_DEFUN([BOOST_SMART_PTR],
  667. [BOOST_FIND_HEADER([boost/scoped_ptr.hpp])
  668. BOOST_FIND_HEADER([boost/shared_ptr.hpp])
  669. ])
  670.  
  671.  
  672. # BOOST_STATICASSERT()
  673. # --------------------
  674. # Look for Boost.StaticAssert
  675. AC_DEFUN([BOOST_STATICASSERT],
  676. [BOOST_FIND_HEADER([boost/static_assert.hpp])])
  677.  
  678.  
  679. # BOOST_STRING_ALGO()
  680. # -------------------
  681. # Look for Boost.StringAlgo
  682. AC_DEFUN([BOOST_STRING_ALGO],
  683. [BOOST_FIND_HEADER([boost/algorithm/string.hpp])
  684. ])
  685.  
  686.  
  687. # BOOST_SYSTEM([PREFERRED-RT-OPT])
  688. # --------------------------------
  689. # Look for Boost.System. For the documentation of PREFERRED-RT-OPT, see the
  690. # documentation of BOOST_FIND_LIB above. This library was introduced in Boost
  691. # 1.35.0.
  692. AC_DEFUN([BOOST_SYSTEM],
  693. [BOOST_FIND_LIB([system], [$1],
  694. [boost/system/error_code.hpp],
  695. [boost::system::error_code e; e.clear();])
  696. ])# BOOST_SYSTEM
  697.  
  698.  
  699. # BOOST_TEST([PREFERRED-RT-OPT])
  700. # ------------------------------
  701. # Look for Boost.Test. For the documentation of PREFERRED-RT-OPT, see the
  702. # documentation of BOOST_FIND_LIB above.
  703. AC_DEFUN([BOOST_TEST],
  704. [m4_pattern_allow([^BOOST_CHECK$])dnl
  705. BOOST_FIND_LIB([unit_test_framework], [$1],
  706. [boost/test/unit_test.hpp], [BOOST_CHECK(2 == 2);],
  707. [using boost::unit_test::test_suite;
  708. test_suite* init_unit_test_suite(int argc, char ** argv)
  709. { return NULL; }])
  710. ])# BOOST_TEST
  711.  
  712.  
  713. # BOOST_THREADS([PREFERRED-RT-OPT])
  714. # ---------------------------------
  715. # Look for Boost.Thread. For the documentation of PREFERRED-RT-OPT, see the
  716. # documentation of BOOST_FIND_LIB above.
  717. # FIXME: Provide an alias "BOOST_THREAD".
  718. AC_DEFUN([BOOST_THREADS],
  719. [dnl Having the pthread flag is required at least on GCC3 where
  720. dnl boost/thread.hpp would complain if we try to compile without
  721. dnl -pthread on GNU/Linux.
  722. AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl
  723. boost_threads_save_LIBS=$LIBS
  724. boost_threads_save_CPPFLAGS=$CPPFLAGS
  725. LIBS="$LIBS $boost_cv_pthread_flag"
  726. # Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3,
  727. # boost/thread.hpp will trigger a #error if -pthread isn't used:
  728. # boost/config/requires_threads.hpp:47:5: #error "Compiler threading support
  729. # is not turned on. Please set the correct command line options for
  730. # threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
  731. CPPFLAGS="$CPPFLAGS $boost_cv_pthread_flag"
  732. BOOST_FIND_LIB([thread], [$1],
  733. [boost/thread.hpp], [boost::thread t; boost::mutex m;])
  734. BOOST_THREAD_LIBS="$BOOST_THREAD_LIBS $boost_cv_pthread_flag"
  735. BOOST_CPPFLAGS="$BOOST_CPPFLAGS $boost_cv_pthread_flag"
  736. LIBS=$boost_threads_save_LIBS
  737. CPPFLAGS=$boost_threads_save_CPPFLAGS
  738. ])# BOOST_THREADS
  739.  
  740.  
  741. # BOOST_TOKENIZER()
  742. # -----------------
  743. # Look for Boost.Tokenizer
  744. AC_DEFUN([BOOST_TOKENIZER],
  745. [BOOST_FIND_HEADER([boost/tokenizer.hpp])])
  746.  
  747.  
  748. # BOOST_TRIBOOL()
  749. # ---------------
  750. # Look for Boost.Tribool
  751. AC_DEFUN([BOOST_TRIBOOL],
  752. [BOOST_FIND_HEADER([boost/logic/tribool_fwd.hpp])
  753. BOOST_FIND_HEADER([boost/logic/tribool.hpp])
  754. ])
  755.  
  756.  
  757. # BOOST_TUPLE()
  758. # -------------
  759. # Look for Boost.Tuple
  760. AC_DEFUN([BOOST_TUPLE],
  761. [BOOST_FIND_HEADER([boost/tuple/tuple.hpp])])
  762.  
  763.  
  764. # BOOST_TYPETRAITS()
  765. # --------------------
  766. # Look for Boost.TypeTraits
  767. AC_DEFUN([BOOST_TYPETRAITS],
  768. [BOOST_FIND_HEADER([boost/type_traits.hpp])])
  769.  
  770.  
  771. # BOOST_UTILITY()
  772. # ---------------
  773. # Look for Boost.Utility (noncopyable, result_of, base-from-member idiom,
  774. # etc.)
  775. AC_DEFUN([BOOST_UTILITY],
  776. [BOOST_FIND_HEADER([boost/utility.hpp])])
  777.  
  778.  
  779. # BOOST_VARIANT()
  780. # ---------------
  781. # Look for Boost.Variant.
  782. AC_DEFUN([BOOST_VARIANT],
  783. [BOOST_FIND_HEADER([boost/variant/variant_fwd.hpp])
  784. BOOST_FIND_HEADER([boost/variant.hpp])])
  785.  
  786.  
  787. # BOOST_WAVE([PREFERRED-RT-OPT])
  788. # ------------------------------
  789. # NOTE: If you intend to use Wave/Spirit with thread support, make sure you
  790. # call BOOST_THREADS first.
  791. # Look for Boost.Wave. For the documentation of PREFERRED-RT-OPT, see the
  792. # documentation of BOOST_FIND_LIB above.
  793. AC_DEFUN([BOOST_WAVE],
  794. [AC_REQUIRE([BOOST_FILESYSTEM])dnl
  795. AC_REQUIRE([BOOST_DATE_TIME])dnl
  796. boost_wave_save_LIBS=$LIBS
  797. boost_wave_save_LDFLAGS=$LDFLAGS
  798. m4_pattern_allow([^BOOST_((FILE)?SYSTEM|DATE_TIME|THREAD)_(LIBS|LDFLAGS)$])dnl
  799. LIBS="$LIBS $BOOST_SYSTEM_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_DATE_TIME_LIBS\
  800. $BOOST_THREAD_LIBS"
  801. LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS\
  802. $BOOST_DATE_TIME_LDFLAGS $BOOST_THREAD_LDFLAGS"
  803. BOOST_FIND_LIB([wave], [$1],
  804. [boost/wave.hpp],
  805. [boost::wave::token_id id; get_token_name(id);])
  806. LIBS=$boost_wave_save_LIBS
  807. LDFLAGS=$boost_wave_save_LDFLAGS
  808. ])# BOOST_WAVE
  809.  
  810.  
  811. # BOOST_XPRESSIVE()
  812. # -----------------
  813. # Look for Boost.Xpressive (new since 1.36.0).
  814. AC_DEFUN([BOOST_XPRESSIVE],
  815. [BOOST_FIND_HEADER([boost/xpressive/xpressive.hpp])])
  816.  
  817.  
  818. # ----------------- #
  819. # Internal helpers. #
  820. # ----------------- #
  821.  
  822.  
  823. # _BOOST_PTHREAD_FLAG()
  824. # ---------------------
  825. # Internal helper for BOOST_THREADS. Based on ACX_PTHREAD:
  826. # http://autoconf-archive.cryp.to/acx_pthread.html
  827. AC_DEFUN([_BOOST_PTHREAD_FLAG],
  828. [AC_REQUIRE([AC_PROG_CXX])dnl
  829. AC_REQUIRE([AC_CANONICAL_HOST])dnl
  830. AC_LANG_PUSH([C++])dnl
  831. AC_CACHE_CHECK([for the flags needed to use pthreads], [boost_cv_pthread_flag],
  832. [ boost_cv_pthread_flag=
  833. # The ordering *is* (sometimes) important. Some notes on the
  834. # individual items follow:
  835. # (none): in case threads are in libc; should be tried before -Kthread and
  836. # other compiler flags to prevent continual compiler warnings
  837. # -lpthreads: AIX (must check this before -lpthread)
  838. # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
  839. # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
  840. # -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
  841. # -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads)
  842. # -pthreads: Solaris/GCC
  843. # -mthreads: MinGW32/GCC, Lynx/GCC
  844. # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
  845. # doesn't hurt to check since this sometimes defines pthreads too;
  846. # also defines -D_REENTRANT)
  847. # ... -mt is also the pthreads flag for HP/aCC
  848. # -lpthread: GNU Linux, etc.
  849. # --thread-safe: KAI C++
  850. case $host_os in #(
  851. *solaris*)
  852. # On Solaris (at least, for some versions), libc contains stubbed
  853. # (non-functional) versions of the pthreads routines, so link-based
  854. # tests will erroneously succeed. (We need to link with -pthreads/-mt/
  855. # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
  856. # a function called by this macro, so we could check for that, but
  857. # who knows whether they'll stub that too in a future libc.) So,
  858. # we'll just look for -pthreads and -lpthread first:
  859. boost_pthread_flags="-pthreads -lpthread -mt -pthread";; #(
  860. *)
  861. boost_pthread_flags="-lpthreads -Kthread -kthread -llthread -pthread \
  862. -pthreads -mthreads -lpthread --thread-safe -mt";;
  863. esac
  864. # Generate the test file.
  865. AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <pthread.h>],
  866. [pthread_t th; pthread_join(th, 0);
  867. pthread_attr_init(0); pthread_cleanup_push(0, 0);
  868. pthread_create(0,0,0,0); pthread_cleanup_pop(0);])])
  869. for boost_pthread_flag in '' $boost_pthread_flags; do
  870. boost_pthread_ok=false
  871. dnl Re-use the test file already generated.
  872. boost_pthreads__save_LIBS=$LIBS
  873. LIBS="$LIBS $boost_pthread_flag"
  874. AC_LINK_IFELSE([],
  875. [if grep ".*$boost_pthread_flag" conftest.err; then
  876. echo "This flag seems to have triggered warnings" >&AS_MESSAGE_LOG_FD
  877. else
  878. boost_pthread_ok=:; boost_cv_pthread_flag=$boost_pthread_flag
  879. fi])
  880. LIBS=$boost_pthreads__save_LIBS
  881. $boost_pthread_ok && break
  882. done
  883. ])
  884. AC_LANG_POP([C++])dnl
  885. ])# _BOOST_PTHREAD_FLAG
  886.  
  887.  
  888. # _BOOST_gcc_test(MAJOR, MINOR)
  889. # -----------------------------
  890. # Internal helper for _BOOST_FIND_COMPILER_TAG.
  891. m4_define([_BOOST_gcc_test],
  892. ["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC @ gcc$1$2"])dnl
  893.  
  894.  
  895. # _BOOST_FIND_COMPILER_TAG()
  896. # --------------------------
  897. # Internal. When Boost is installed without --layout=system, each library
  898. # filename will hold a suffix that encodes the compiler used during the
  899. # build. The Boost build system seems to call this a `tag'.
  900. AC_DEFUN([_BOOST_FIND_COMPILER_TAG],
  901. [AC_REQUIRE([AC_PROG_CXX])dnl
  902. AC_REQUIRE([AC_CANONICAL_HOST])dnl
  903. AC_CACHE_CHECK([for the toolset name used by Boost for $CXX], [boost_cv_lib_tag],
  904. [boost_cv_lib_tag=unknown
  905. if test x$boost_cv_inc_path != xno; then
  906. AC_LANG_PUSH([C++])dnl
  907. # The following tests are mostly inspired by boost/config/auto_link.hpp
  908. # The list is sorted to most recent/common to oldest compiler (in order
  909. # to increase the likelihood of finding the right compiler with the
  910. # least number of compilation attempt).
  911. # Beware that some tests are sensible to the order (for instance, we must
  912. # look for MinGW before looking for GCC3).
  913. # I used one compilation test per compiler with a #error to recognize
  914. # each compiler so that it works even when cross-compiling (let me know
  915. # if you know a better approach).
  916. # Known missing tags (known from Boost's tools/build/v2/tools/common.jam):
  917. # como, edg, kcc, bck, mp, sw, tru, xlc
  918. # I'm not sure about my test for `il' (be careful: Intel's ICC pre-defines
  919. # the same defines as GCC's).
  920. for i in \
  921. _BOOST_gcc_test(4, 5) \
  922. _BOOST_gcc_test(4, 4) \
  923. _BOOST_gcc_test(4, 3) \
  924. _BOOST_gcc_test(4, 2) \
  925. _BOOST_gcc_test(4, 1) \
  926. _BOOST_gcc_test(4, 0) \
  927. "defined __GNUC__ && __GNUC__ == 3 && !defined __ICC \
  928. && (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \
  929. || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw" \
  930. _BOOST_gcc_test(3, 4) \
  931. _BOOST_gcc_test(3, 3) \
  932. "defined _MSC_VER && _MSC_VER >= 1500 @ vc90" \
  933. "defined _MSC_VER && _MSC_VER == 1400 @ vc80" \
  934. _BOOST_gcc_test(3, 2) \
  935. "defined _MSC_VER && _MSC_VER == 1310 @ vc71" \
  936. _BOOST_gcc_test(3, 1) \
  937. _BOOST_gcc_test(3, 0) \
  938. "defined __BORLANDC__ @ bcb" \
  939. "defined __ICC && (defined __unix || defined __unix__) @ il" \
  940. "defined __ICL @ iw" \
  941. "defined _MSC_VER && _MSC_VER == 1300 @ vc7" \
  942. _BOOST_gcc_test(2, 95) \
  943. "defined __MWERKS__ && __MWERKS__ <= 0x32FF @ cw9" \
  944. "defined _MSC_VER && _MSC_VER < 1300 && !defined UNDER_CE @ vc6" \
  945. "defined _MSC_VER && _MSC_VER < 1300 && defined UNDER_CE @ evc4" \
  946. "defined __MWERKS__ && __MWERKS__ <= 0x31FF @ cw8"
  947. do
  948. boost_tag_test=`expr "X$i" : 'X\([[^@]]*\) @ '`
  949. boost_tag=`expr "X$i" : 'X[[^@]]* @ \(.*\)'`
  950. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  951. #if $boost_tag_test
  952. /* OK */
  953. #else
  954. # error $boost_tag_test
  955. #endif
  956. ]])], [boost_cv_lib_tag=$boost_tag; break], [])
  957. done
  958. AC_LANG_POP([C++])dnl
  959. case $boost_cv_lib_tag in #(
  960. # Some newer (>= 1.35?) versions of Boost seem to only use "gcc" as opposed
  961. # to "gcc41" for instance.
  962. *-gcc | *'-gcc ') :;; #( Don't re-add -gcc: it's already in there.
  963. gcc*)
  964. boost_tag_x=
  965. case $host_os in #(
  966. darwin*)
  967. if test $boost_major_version -ge 136; then
  968. # The `x' added in r46793 of Boost.
  969. boost_tag_x=x
  970. fi;;
  971. esac
  972. # We can specify multiple tags in this variable because it's used by
  973. # BOOST_FIND_LIB that does a `for tag in -$boost_cv_lib_tag' ...
  974. boost_cv_lib_tag="$boost_tag_x$boost_cv_lib_tag -${boost_tag_x}gcc"
  975. ;; #(
  976. unknown)
  977. AC_MSG_WARN([[could not figure out which toolset name to use for $CXX]])
  978. boost_cv_lib_tag=
  979. ;;
  980. esac
  981. fi])dnl end of AC_CACHE_CHECK
  982. ])# _BOOST_FIND_COMPILER_TAG
  983.  
  984.  
  985. # _BOOST_GUESS_WHETHER_TO_USE_MT()
  986. # --------------------------------
  987. # Compile a small test to try to guess whether we should favor MT (Multi
  988. # Thread) flavors of Boost. Sets boost_guess_use_mt accordingly.
  989. AC_DEFUN([_BOOST_GUESS_WHETHER_TO_USE_MT],
  990. [# Check whether we do better use `mt' even though we weren't ask to.
  991. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  992. #if defined _REENTRANT || defined _MT || defined __MT__
  993. /* use -mt */
  994. #else
  995. # error MT not needed
  996. #endif
  997. ]])], [boost_guess_use_mt=:], [boost_guess_use_mt=false])
  998. ])
  999.  
  1000. # _BOOST_AC_LINK_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
  1001. # -------------------------------------------------------------------
  1002. # Fork of _AC_LINK_IFELSE that preserves conftest.o across calls. Fragile,
  1003. # will break when Autoconf changes its internals. Requires that you manually
  1004. # rm -f conftest.$ac_objext in between to really different tests, otherwise
  1005. # you will try to link a conftest.o left behind by a previous test.
  1006. # Used to aggressively optimize BOOST_FIND_LIB (see the big comment in this
  1007. # macro).
  1008. #
  1009. # Don't use "break" in the actions, as it would short-circuit some code
  1010. # this macro runs after the actions.
  1011. m4_define([_BOOST_AC_LINK_IFELSE],
  1012. [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
  1013. rm -f conftest$ac_exeext
  1014. boost_save_ac_ext=$ac_ext
  1015. boost_use_source=:
  1016. # If we already have a .o, re-use it. We change $ac_ext so that $ac_link
  1017. # tries to link the existing object file instead of compiling from source.
  1018. test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false &&
  1019. _AS_ECHO_LOG([re-using the existing conftest.$ac_objext])
  1020. AS_IF([_AC_DO_STDERR($ac_link) && {
  1021. test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" ||
  1022. test ! -s conftest.err
  1023. } && test -s conftest$ac_exeext && {
  1024. test "$cross_compiling" = yes ||
  1025. $as_executable_p conftest$ac_exeext
  1026. dnl FIXME: use AS_TEST_X instead when 2.61 is widespread enough.
  1027. }],
  1028. [$2],
  1029. [if $boost_use_source; then
  1030. _AC_MSG_LOG_CONFTEST
  1031. fi
  1032. $3])
  1033. ac_objext=$boost_save_ac_objext
  1034. ac_ext=$boost_save_ac_ext
  1035. dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization)
  1036. dnl information created by the PGI compiler (conftest_ipa8_conftest.oo),
  1037. dnl as it would interfere with the next link command.
  1038. rm -f core conftest.err conftest_ipa8_conftest.oo \
  1039. conftest$ac_exeext m4_ifval([$1], [conftest.$ac_ext])[]dnl
  1040. ])# _BOOST_AC_LINK_IFELSE
  1041.  
  1042. # Local Variables:
  1043. # mode: autoconf
  1044. # End:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement