Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH] boost-utils.eclass -- for building against newest boost.
Date: Sun, 09 Sep 2012 21:41:44
Message-Id: 1347226888-2161-1-git-send-email-mgorny@gentoo.org
In Reply to: Re: [gentoo-dev] [PATCH] boost-utils.eclass -- for building against newest boost. by Arfrever Frehtes Taifersar Arahesis
1 Fixed to support any slot older than specified correctly.
2 ---
3 gx86/eclass/boost-utils.eclass | 95 ++++++++++++++++++++++++++++++++++++++++++
4 1 file changed, 95 insertions(+)
5 create mode 100644 gx86/eclass/boost-utils.eclass
6
7 diff --git a/gx86/eclass/boost-utils.eclass b/gx86/eclass/boost-utils.eclass
8 new file mode 100644
9 index 0000000..0d6eec3
10 --- /dev/null
11 +++ b/gx86/eclass/boost-utils.eclass
12 @@ -0,0 +1,95 @@
13 +# Copyright 1999-2012 Gentoo Foundation
14 +# Distributed under the terms of the GNU General Public License v2
15 +# $Header: $
16 +
17 +if [[ ! ${_BOOST_ECLASS} ]]; then
18 +
19 +# @ECLASS: boost-utils.eclass
20 +# @MAINTAINER:
21 +# Michał Górny <mgorny@g.o>
22 +# Tiziano Müller <dev-zero@g.o>
23 +# Sebastian Luther <SebastianLuther@×××.de>
24 +# Arfrever Frehtes Taifersar Arahesis <arfrever.fta@×××××.com>
25 +# @BLURB: helper functions for packages using Boost C++ library
26 +# @DESCRIPTION:
27 +# Helper functions to be used when building packages using the Boost C++
28 +# library collection.
29 +#
30 +# Please note that this eclass does not set the dependencies for you.
31 +# You need to do that yourself.
32 +#
33 +# For cmake & autotools it is usually necessary to set BOOST_ROOT using
34 +# boost-utils_export_root. However, other build system may require more
35 +# hackery or even appending -I$(boost-utils_get_includedir) to CFLAGS
36 +# and -L$(boost-utils_get_libdir) to LDFLAGS.
37 +
38 +case ${EAPI:-0} in
39 + 0|1|2|3|4) ;;
40 + *) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established."
41 +esac
42 +
43 +inherit multilib versionator
44 +
45 +# @ECLASS-VARIABLE: BOOST_MAX_SLOT
46 +# @DEFAULT_UNSET
47 +# @DESCRIPTION:
48 +# The maximal (newest) boost slot supported by the package. If unset,
49 +# there is no limit (the newest installed version will be used).
50 +
51 +# @FUNCTION: boost-utils_get_best_slot
52 +# @DESCRIPTION:
53 +# Get newest installed slot of Boost. If BOOST_MAX_SLOT is set, the version
54 +# returned will be at most in the specified slot.
55 +boost-utils_get_best_slot() {
56 + local pkg=dev-libs/boost
57 + [[ ${BOOST_MAX_SLOT} ]] && pkg="<=${pkg}-${BOOST_MAX_SLOT}.9999"
58 +
59 + local cpv=$(best_version ${pkg})
60 + get_version_component_range 1-2 ${cpv#${pkg}-}
61 +}
62 +
63 +# @FUNCTION: boost-utils_get_includedir
64 +# @USAGE: [slot]
65 +# @DESCRIPTION:
66 +# Get the includedir for the given Boost slot. If no slot is given,
67 +# defaults to the newest installed Boost slot (but not newer than
68 +# BOOST_MAX_SLOT if that variable is set).
69 +#
70 +# Outputs the sole path (without -I).
71 +boost-utils_get_includedir() {
72 + local slot=${1:-$(boost-utils_get_best_slot)}
73 + has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
74 +
75 + echo -n "${EPREFIX}/usr/include/boost-${slot/./_}"
76 +}
77 +
78 +# @FUNCTION: boost-utils_get_libdir
79 +# @USAGE: [slot]
80 +# @DESCRIPTION:
81 +# Get the libdir for the given Boost slot. If no slot is given, defaults
82 +# to the newest installed Boost slot (but not newer than BOOST_MAX_SLOT
83 +# if that variable is set).
84 +#
85 +# Outputs the sole path (without -L).
86 +boost-utils_get_libdir() {
87 + local slot=${1:-$(boost-utils_get_best_slot)}
88 + has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
89 +
90 + echo -n "${EPREFIX}/usr/$(get_libdir)/boost-${slot/./_}"
91 +}
92 +
93 +# @FUNCTION: boost-utils_export_root
94 +# @USAGE: [slot]
95 +# @DESCRIPTION:
96 +# Set the BOOST_ROOT variable to includedir for the given Boost slot.
97 +# If no slot is given, defaults to the newest installed Boost slot(but
98 +# not newer than BOOST_MAX_SLOT if that variable is set).
99 +#
100 +# This variable satisfies both cmake and sys-devel/boost-m4 autoconf
101 +# macros.
102 +boost-utils_export_root() {
103 + export BOOST_ROOT=$(boost-utils_get_includedir "${@}")
104 +}
105 +
106 +_BOOST_ECLASS=1
107 +fi # _BOOST_ECLASS
108 --
109 1.7.12

Replies