1 # boost.m4: Locate Boost headers and libraries for autoconf-based projects.
2 # Copyright (C) 2007 Benoit Sigoure <tsuna@lrde.epita.fr>
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # BOOST_REQUIRE([VERSION])
20 # ------------------------
21 # Look for Boost. If version is given, it must either be a literal of the form
22 # "X.Y" where X and Y are integers or a variable "$var".
23 # Defines the value BOOST_CPPFLAGS. This macro only checks for headers with
24 # the required version, it does not check for any of the Boost libraries.
25 AC_DEFUN([BOOST_REQUIRE],
26 [dnl First find out what kind of argument we have.
27 dnl If we have an empty argument, there is no constraint on the version of
28 dnl Boost to use. If it's a literal version number, we can split it in M4 (so
29 dnl the resulting configure script will be smaller/faster). Otherwise we do
30 dnl the splitting at runtime.
32 [^ *$], [m4_pushdef([BOOST_VERSION_REQ], [])dnl
35 boost_version_subminor=0
37 [^[0-9]+\([-._][0-9]+\)*$],
38 [m4_pushdef([BOOST_VERSION_REQ], [ version >= $1])dnl
39 boost_version_major=m4_bregexp([$1], [^\([0-9]+\)], [\1])
40 boost_version_minor=m4_bregexp([$1], [^[0-9]+[-._]\([0-9]+\)], [\1])
41 boost_version_subminor=m4_bregexp([$1], [^[0-9]+[-._][0-9]+[-._]\([0-9]+\)], [\1])
44 [m4_pushdef([BOOST_VERSION_REQ], [])dnl
45 boost_version_major=`expr "X$1" : 'X\([[^-._]]*\)'`
46 boost_version_minor=`expr "X$1" : 'X[[0-9]]*[[-._]]\([[^-._]]*\)'`
47 boost_version_subminor=`expr "X$1" : 'X[[0-9]]*[[-._]][[0-9]]*[[-._]]\([[0-9]]*\)'`
48 case $boost_version_major:$boost_version_minor in #(
49 *: | :* | *[[^0-9]]*:* | *:*[[^0-9]]*)
50 AC_MSG_ERROR([[Invalid argument for REQUIRE_BOOST: `$1']])
54 [m4_fatal(Invalid argument: `$1')]
57 [AS_HELP_STRING([--with-boost=DIR],
58 [prefix of Boost]BOOST_VERSION_REQ[ @<:@guess@:>@])])dnl
59 AC_CACHE_CHECK([for Boost headers[]BOOST_VERSION_REQ],
62 AC_LANG_PUSH([C++])dnl
64 test x"$boost_version_subminor" != x \
65 && boost_subminor_chk="|| (BOOST_V_MAJ == $boost_version_major \
66 && BOOST_V_MIN == $boost_version_minor \
67 && BOOST_V_SUB % 100 < $boost_version_subminor)"
68 for i in "$with_boost/include" '' \
69 /opt/local/include /usr/local/include /opt/include /usr/include \
70 "$with_boost" C:/Boost/include
72 boost_save_CPPFLAGS=$CPPFLAGS
73 test x"$i" != x && CPPFLAGS="$CPPFLAGS -I$i"
74 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <boost/version.hpp>
76 # error BOOST_VERSION is not defined
78 #define BOOST_V_MAJ (BOOST_VERSION / 10000)
79 #define BOOST_V_MIN (BOOST_VERSION / 100 % 1000)
80 #define BOOST_V_SUB (BOOST_VERSION % 100)
81 #if (BOOST_V_MAJ < $boost_version_major) \
82 || (BOOST_V_MAJ == $boost_version_major \
83 && BOOST_V_MIN / 100 % 1000 < $boost_version_minor) $boost_subminor_chk
84 # error Boost headers version < $1
86 ]])], [boost_cv_version=yes], [boost_cv_version=no])
87 CPPFLAGS=$boost_save_CPPFLAGS
88 if test x"$boost_cv_version" = xyes; then
89 if test x"$i" != x; then
97 case $boost_cv_version in #(
99 AC_MSG_ERROR([Could not find Boost headers[]BOOST_VERSION_REQ])
105 BOOST_CPPFLAGS="-I$boost_cv_version"
108 AC_SUBST([BOOST_CPPFLAGS])dnl
109 m4_popdef([BOOST_VERSION_REQ])dnl