summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2013-02-01 21:39:50 +0000
committerMichał Górny <mgorny@gentoo.org>2013-02-01 21:39:50 +0000
commit7d6a76918772397ef3a9cede481fbd6679a3dc19 (patch)
treebc59b7e3843cd1fb39a7971203ed5aa88515a09a /eclass/multilib-build.eclass
parentRemove old. (diff)
downloadhistorical-7d6a76918772397ef3a9cede481fbd6679a3dc19.tar.gz
historical-7d6a76918772397ef3a9cede481fbd6679a3dc19.tar.bz2
historical-7d6a76918772397ef3a9cede481fbd6679a3dc19.zip
Introduce a common multilib-build eclass to help building packages for multilib, and use the new ABI_X86 flags in it.
Diffstat (limited to 'eclass/multilib-build.eclass')
-rw-r--r--eclass/multilib-build.eclass141
1 files changed, 141 insertions, 0 deletions
diff --git a/eclass/multilib-build.eclass b/eclass/multilib-build.eclass
new file mode 100644
index 000000000000..4298a541b7bc
--- /dev/null
+++ b/eclass/multilib-build.eclass
@@ -0,0 +1,141 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/eclass/multilib-build.eclass,v 1.1 2013/02/01 21:39:50 mgorny Exp $
+
+# @ECLASS: multilib-build.eclass
+# @MAINTAINER:
+# Michał Górny <mgorny@gentoo.org>
+# @BLURB: flags and utility functions for building multilib packages
+# @DESCRIPTION:
+# The multilib-build.eclass exports USE flags and utility functions
+# necessary to build packages for multilib in a clean and uniform
+# manner.
+#
+# Please note that dependency specifications for multilib-capable
+# dependencies shall use the USE dependency string in ${MULTILIB_USEDEP}
+# to properly request multilib enabled.
+
+if [[ ! ${_MULTILIB_BUILD} ]]; then
+
+# EAPI=5 is required for meaningful MULTILIB_USEDEP.
+case ${EAPI:-0} in
+ 5) ;;
+ *) die "EAPI=${EAPI} is not supported" ;;
+esac
+
+inherit multilib multiprocessing
+
+# @ECLASS-VARIABLE: _MULTILIB_FLAGS
+# @INTERNAL
+# @DESCRIPTION:
+# The list of multilib flags and corresponding ABI values.
+_MULTILIB_FLAGS=(
+ abi_x86_32:x86
+ abi_x86_64:amd64
+)
+
+# @ECLASS-VARIABLE: MULTILIB_USEDEP
+# @DESCRIPTION:
+# The USE-dependency to be used on dependencies (libraries) needing
+# to support multilib as well.
+#
+# Example use:
+# @CODE
+# RDEPEND="dev-libs/libfoo[${MULTILIB_USEDEP}]
+# net-libs/libbar[ssl,${MULTILIB_USEDEP}]"
+# @CODE
+
+_multilib_build_set_globals() {
+ local flags=( "${_MULTILIB_FLAGS[@]%:*}" )
+ local usedeps=${flags[@]/%/(-)?}
+
+ IUSE=${flags[*]}
+ MULTILIB_USEDEP=${usedeps// /,}
+}
+_multilib_build_set_globals
+
+# @FUNCTION: multilib_get_enabled_abis
+# @DESCRIPTION:
+# Return the ordered list of enabled ABIs if multilib builds
+# are enabled. The best (most preferred) ABI will come last.
+#
+# If multilib is disabled, the default ABI will be returned
+# in order to enforce consistent testing with multilib code.
+multilib_get_enabled_abis() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local abis=( $(get_all_abis) )
+
+ local abi i found
+ for abi in "${abis[@]}"; do
+ for i in "${_MULTILIB_FLAGS[@]}"; do
+ local m_abi=${i#*:}
+ local m_flag=${i%:*}
+
+ if [[ ${m_abi} == ${abi} ]] && use "${m_flag}"; then
+ echo "${abi}"
+ found=1
+ fi
+ done
+ done
+
+ if [[ ! ${found} ]]; then
+ debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${DEFAULT_ABI}"
+ echo ${DEFAULT_ABI}
+ fi
+}
+
+# @FUNCTION: multilib_foreach_abi
+# @USAGE: <argv>...
+# @DESCRIPTION:
+# If multilib support is enabled, sets the toolchain up for each
+# supported ABI along with the ABI variable and correct BUILD_DIR,
+# and runs the given commands with them.
+#
+# If multilib support is disabled, it just runs the commands. No setup
+# is done.
+multilib_foreach_abi() {
+ local initial_dir=${BUILD_DIR:-${S}}
+
+ local ABI
+ for ABI in $(multilib_get_enabled_abis); do
+ multilib_toolchain_setup "${ABI}"
+ BUILD_DIR=${initial_dir%%/}-${ABI} "${@}"
+ done
+}
+
+# @FUNCTION: multilib_parallel_foreach_abi
+# @USAGE: <argv>...
+# @DESCRIPTION:
+# If multilib support is enabled, sets the toolchain up for each
+# supported ABI along with the ABI variable and correct BUILD_DIR,
+# and runs the given commands with them. The commands are run
+# in parallel with number of jobs being determined from MAKEOPTS.
+#
+# If multilib support is disabled, it just runs the commands. No setup
+# is done.
+#
+# Useful for running configure scripts.
+multilib_parallel_foreach_abi() {
+ local initial_dir=${BUILD_DIR:-${S}}
+
+ multijob_init
+
+ local ABI
+ for ABI in $(multilib_get_enabled_abis); do
+ (
+ multijob_child_init
+
+ multilib_toolchain_setup "${ABI}"
+ BUILD_DIR=${initial_dir%%/}-${ABI}
+ "${@}"
+ ) &
+
+ multijob_post_fork
+ done
+
+ multijob_finish
+}
+
+_MULTILIB_BUILD=1
+fi