aboutsummaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorGregory M. Tuner <gmt@be-evil.net>2014-05-30 17:31:22 -0700
committerGregory M. Tuner <gmt@be-evil.net>2014-05-30 17:31:22 -0700
commit06ea98e02c8fe9922f095c05ffbe954759b48447 (patch)
tree2c6f627697213c3ba4e855266a39af250ac24a83 /eclass
parenteclass/multilib: sync with upstream and drop PKG_CONFIG magic (which upstream... (diff)
downloadgmt-06ea98e02c8fe9922f095c05ffbe954759b48447.tar.gz
gmt-06ea98e02c8fe9922f095c05ffbe954759b48447.tar.bz2
gmt-06ea98e02c8fe9922f095c05ffbe954759b48447.zip
eclass/multilib-build: try to sync with upstream some more
Signed-off-by: Gregory M. Tuner <gmt@be-evil.net>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/multilib-build.eclass269
1 files changed, 171 insertions, 98 deletions
diff --git a/eclass/multilib-build.eclass b/eclass/multilib-build.eclass
index 36f70d4..290b3be 100644
--- a/eclass/multilib-build.eclass
+++ b/eclass/multilib-build.eclass
@@ -4,7 +4,9 @@
# @ECLASS: multilib-build.eclass
# @MAINTAINER:
-# Michał Górny <mgorny@gentoo.org>
+# gx86-multilib team <multilib@gentoo.org>
+# @AUTHOR:
+# Author: 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
@@ -72,6 +74,24 @@ _MULTILIB_FLAGS=(
# net-libs/libbar[ssl,${MULTILIB_USEDEP}]"
# @CODE
+# @ECLASS-VARIABLE: MULTILIB_ABI_FLAG
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# The complete ABI name. Resembles the USE flag name.
+#
+# This is set within multilib_foreach_abi(),
+# multilib_parallel_foreach_abi() and multilib-minimal sub-phase
+# functions.
+#
+# It may be null (empty) when the build is done on ABI not controlled
+# by a USE flag (e.g. on non-multilib arch or when using multilib
+# portage). The build will always be done for a single ABI then.
+#
+# Example value:
+# @CODE
+# abi_x86_64
+# @CODE
+
_multilib_build_set_globals() {
local flags=( "${_MULTILIB_FLAGS[@]%:*}" )
@@ -217,6 +237,21 @@ multilib_flag_abi() {
multilib_get_enabled_abis() {
debug-print-function ${FUNCNAME} "${@}"
+ local pairs=( $(multilib_get_enabled_abi_pairs) )
+ echo "${pairs[@]#*.}"
+}
+
+# @FUNCTION: multilib_get_enabled_abi_pairs
+# @DESCRIPTION:
+# Return the ordered list of enabled <use-flag>.<ABI> pairs
+# if multilib builds are enabled. The best (most preferred)
+# ABI will come last.
+#
+# If multilib is disabled, the default ABI will be returned
+# along with empty <use-flag>.
+multilib_get_enabled_abi_pairs() {
+ debug-print-function ${FUNCNAME} "${@}"
+
local abis=( $(get_all_abis) )
local abi i found
@@ -230,7 +265,7 @@ multilib_get_enabled_abis() {
# for the split is more complex than cheating like this
for m_abi in ${m_abis//,/ }; do
if [[ ${m_abi} == ${abi} ]] && use "${m_flag}"; then
- echo "${abi}"
+ echo "${m_flag}.${abi}"
found=1
break 2
fi
@@ -245,7 +280,7 @@ multilib_get_enabled_abis() {
debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${abi}"
debug-print "${FUNCNAME}: ABI=${ABI}, DEFAULT_ABI=${DEFAULT_ABI}"
- echo ${abi}
+ echo ".${abi}"
fi
}
@@ -257,8 +292,10 @@ multilib_get_enabled_abis() {
_multilib_multibuild_wrapper() {
debug-print-function ${FUNCNAME} "${@}"
- local ABI=${MULTIBUILD_VARIANT}
+ local ABI=${MULTIBUILD_VARIANT#*.}
+ # fixme: deprecated -- try to use MULTIIB_ABI_FLAG (but not exported, so...?)
local MULTILIB_BUILD_ABI="${ABI}"
+ local MULTILIB_ABI_FLAG=${MULTIBUILD_VARIANT%.*}
export MULTILIB_BUILD_ABI
multilib_toolchain_setup "${ABI}"
"${@}"
@@ -342,7 +379,7 @@ multilib_tc_export() {
multilib_foreach_abi() {
debug-print-function ${FUNCNAME} "${@}"
- local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) )
multibuild_foreach_variant _multilib_multibuild_wrapper "${@}"
}
@@ -361,7 +398,7 @@ multilib_foreach_abi() {
multilib_parallel_foreach_abi() {
debug-print-function ${FUNCNAME} "${@}"
- local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) )
multibuild_parallel_foreach_variant _multilib_multibuild_wrapper "${@}"
}
@@ -372,9 +409,31 @@ multilib_parallel_foreach_abi() {
multilib_for_best_abi() {
debug-print-function ${FUNCNAME} "${@}"
- local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ eqawarn "QA warning: multilib_for_best_abi() function is deprecated and should"
+ eqawarn "not be used. Use multilib_for_native_abi instead"
- multibuild_for_best_variant _multilib_multibuild_wrapper "${@}"
+ multilib_for_native_abi "${@}"
+}
+
+# @FUNCTION: multilib_for_native_abi
+# @USAGE: <argv>....
+# @DESCRIPTION:
+# While iterating through ABIs, allows one to temporarily assume the context of
+# the native ABI.
+multilib_for_native_abi() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ if multilib_is_native_abi; then
+ "${@}"
+ else
+ do_if_is_native_multilib_variant() {
+ local oldrslt=$?
+ [[ ${MULTIBUILD_VARIANT#*.} == ${DEFAULT_ABI:-default} ]] ||
+ return $oldrslt
+ _multilib_multibuild_wrapper "${@}"
+ }
+ multibuild_foreach_variant do_if_is_native_multilib_variant "${@}"
+ fi
}
# @ECLASS-VARIABLE: MULTILIB_UNCHECKED_HEADERS
@@ -383,7 +442,7 @@ multilib_for_best_abi() {
# If an ebuild or eclass author has implemented their own solution
# to a possible header conflict, (if appropriate, that solution may
# simply be to ignore it, which would typically result in the
-# best-ABI's header being installed (see: multilib_for_best_abi)
+# native ABI's header being installed (see: multilib_for_native_abi)
#
# This variable has to be a bash array. Paths shall be relative to
# installation root (${ED}), and name regular files.
@@ -461,7 +520,7 @@ multilib_check_headers() {
multilib_copy_sources() {
debug-print-function ${FUNCNAME} "${@}"
- local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
+ local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) )
multibuild_copy_sources
}
@@ -472,7 +531,7 @@ multilib_copy_sources() {
# including them conditionally to current ABI.
#
# This variable has to be a bash array. Paths shall be relative to
-# installation root (${ED}), and name regular files. Recursive wrapping
+# installation root (${ED}), and name regular files. Recursive wrapping
# is not supported.
#
# Please note that header wrapping is *discouraged*. It is preferred to
@@ -627,26 +686,36 @@ multilib_prepare_wrappers() {
local f
local generate_wrapper
- for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do
- local generate_wrapper=yes
- [[ ${f:0:1} == ^ ]] && generate_wrapper=no
- f="${f#^}"
- # drop leading slash if it's there
- [[ ${f} =~ ^/+ ]] && f="${f#${BASH_REMATCH[0]}}"
-
- if [[ ${f} != usr/include/* ]]; then
- die "Wrapping headers outside of /usr/include is not supported at the moment."
- fi
- # and then usr/include
- f="${f#usr/include}"
-
- local dir="${f%/*}"
-
- if [[ ${generate_wrapper} == yes && ! -f "${ED}tmp/multilib-include${f}" ]]; then
- einfo "generating multilib wrapper for header ${f}"
- dodir "/tmp/multilib-include${dir}"
- # a generic template
- cat > "${ED}tmp/multilib-include${f}" <<_EOF_
+ if [[ ${MULTILIB_WRAPPED_HEADERS[@]} ]]; then
+ # If abi_flag is unset, then header wrapping is unsupported on
+ # this ABI. This means the arch doesn't support multilib at all
+ # -- in this case, the headers are not wrapped and everything
+ # works as expected.
+
+ if [[ ${MULTILIB_ABI_FLAG} ]]; then
+ for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do
+ local generate_wrapper=yes
+ [[ ${f:0:1} == ^ ]] && generate_wrapper=no
+ f="${f#^}"
+ # drop leading slash if it's there
+ [[ ${f} =~ ^/+ ]] && f="${f#${BASH_REMATCH[0]}}"
+
+ if [[ ${f} != usr/include/* ]]; then
+ die "Wrapping headers outside of /usr/include is not supported at the moment."
+ fi
+ # and then usr/include
+ f="${f#usr/include}"
+
+ local dir="${f%/*}"
+
+ # Some ABIs may have install less files than others.
+ if [[ ${generate_wrapper} == yes && -f ${root}usr/include${f} ]]; then
+ local wrapper=${ED}tmp/multilib-include${f}
+ if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then
+ einfo "generating multilib wrapper for header ${f}"
+ dodir "/tmp/multilib-include${dir}"
+ # a generic template
+ cat > "${wrapper}" <<_EOF_
/* This file is auto-generated by multilib-build.eclass
* as a multilib-friendly wrapper. For the original content,
* please see the files that are #included below.
@@ -668,44 +737,55 @@ multilib_prepare_wrappers() {
# elif(_MIPS_SIM == _ABIO32) /* o32 */
# error "abi_mips_o32 not supported by the package."
# endif
+#elif defined(__sparc__)
+# if defined(__arch64__)
+# error "abi_sparc_64 not supported by the package."
+# else
+# error "abi_sparc_32 not supported by the package."
+# endif
+#elif defined(__s390__)
+# if defined(__s390x__)
+# error "abi_s390_64 not supported by the package."
+# else
+# error "abi_s390_32 not supported by the package."
+# endif
+#elif defined(__powerpc__)
+# if defined(__powerpc64__)
+# error "abi_ppc_64 not supported by the package."
+# else
+# error "abi_ppc_32 not supported by the package."
+# endif
#else
# error "No ABI matched, please report a bug to bugs.gentoo.org"
#endif
_EOF_
+ fi
+
+ if ! grep -q "${MULTILIB_ABI_FLAG} " "${wrapper}"
+ then
+ die "Flag ${MULTILIB_ABI_FLAG} not listed in wrapper template. Please report a bug to https://bugs.gentoo.org."
+ fi
+
+ # $CHOST shall be set by multilib_toolchain_setup
+ dodir "/tmp/multilib-include/${CHOST}${dir}"
+ mv "${root}usr/include${f}" "${ED}tmp/multilib-include/${CHOST}${dir}/" || die
+ if [[ ${generate_wrapper} == yes ]] ; then
+ # Note: match a space afterwards to avoid collision potential.
+ sed -e "/${MULTILIB_ABI_FLAG} /s&error.*&include <${CHOST}${f}>&" \
+ -i "${wrapper}" || die
+
+ # Hack for emul-linux-x86 compatibility.
+ # It assumes amd64 will come after x86, and will use amd64
+ # headers if no specific x86 headers were installed.
+ if [[ ${ABI} == amd64 ]]; then
+ sed -e "/abi_x86_32 /s&error.*&include <${CHOST}${f}>&" \
+ -i "${wrapper}" || die
+ fi
+ fi
+ fi
+ done
fi
-
- # Some ABIs may have install less files than others.
- if [[ -f "${root}usr/include${f}" ]]; then
- # $CHOST shall be set by multilib_toolchain_setup
- dodir "/tmp/multilib-include/${CHOST}${dir}"
- mv "${root}usr/include${f}" "${ED}tmp/multilib-include/${CHOST}${dir}/" || die
- if [[ ${generate_wrapper} == yes ]] ; then
- # XXX: get abi_* directly
- local abi_flag
- case "${ABI}" in
- amd64|amd64_fbsd)
- abi_flag=abi_x86_64;;
- x86|x86_fbsd)
- abi_flag=abi_x86_32;;
- x32)
- abi_flag=abi_x86_x32;;
- n32)
- abi_flag=abi_mips_n32;;
- n64)
- abi_flag=abi_mips_n64;;
- o32)
- abi_flag=abi_mips_o32;;
- *)
- die "Header wrapping for ${ABI} not supported yet";;
- esac
-
- # Note: match a space afterwards to avoid collision potential.
- sed -e "/${abi_flag} /s&error.*&include <${CHOST}${f}>&" \
- -i "${ED}tmp/multilib-include${f}" || die
- fi
- fi
- done
-
+ fi
for f in "${MULTILIB_WRAPPED_EXECUTABLES[@]}" ; do
generate_wrapper=no
[[ ${f:0:1} == @ ]] && generate_wrapper=yes
@@ -881,7 +961,7 @@ _EOF_
eend $?
popd > /dev/null || die
}
- multilib_for_best_abi do_executable_wrapper_compile
+ multilib_for_native_abi do_executable_wrapper_compile
# make wrapper-executable like -ABI wrapped executable
chown -c --reference="${root}${f}-${ABI}" "${ED}tmp/multilib-bin-wrappers/${f}" || \
die "Cant chown \"${ED}tmp/multilib-bin-wrappers/${f}\""
@@ -922,10 +1002,10 @@ _EOF_
local dir=${f%/*}
local fn=${f##*/}
- cp "${root}/${f}" "${root}/${dir}/${CHOST}-${fn}" || die
+ cp "${root}${f}" "${root}/${dir}/${CHOST}-${fn}" || die
# symlink the native one back (unless it's also an @wrapped-MULTILIB_WRAPPED_EXECUTABLE)
- if multilib_build_binaries; then
+ if multilib_is_native_abi; then
dosymlink=yes
for f1 in "${MULTILIB_WRAPPED_EXECUTABLES[@]}" ; do
[[ ${f1:0:1} == @ ]] || continue
@@ -941,11 +1021,19 @@ _EOF_
fi
done
if [[ ${dosymlink} == yes ]] ; then
- rm "${root}/${f}" || die
- ln -s "${CHOST}-${fn}" "${root}/${f}" || die
+ # rewrite the symlink target
+ local target=$(readlink "${root}${f}")
+ local target_dir
+ local target_fn=${target##*/}
+
+ [[ ${target} == */* ]] && target_dir=${target%/*}
+
+ rm "${root}${f}" || die
+ ln -f -s "${target_dir+${target_dir}/}${CHOST}-${target_fn}" \
+ "${root}${f}"
fi
else
- rm "${root}/${f}" || die
+ rm "${root}${f}" || die
fi
done
}
@@ -971,6 +1059,7 @@ multilib_install_wrappers() {
[[ ${COMPLETE_MULTILIB} == yes ]] && return
local root=${1:-${ED}}
+
# ensure root has a single trailing slash
[[ ${root} =~ /+$ ]] && root="${root%${BASH_REMATCH[0]}}"
root="${root}/"
@@ -994,9 +1083,6 @@ multilib_install_wrappers() {
# @DESCRIPTION:
# Determine whether the currently built ABI is the profile native.
# Return true status (0) if that is true, otherwise false (1).
-#
-# This function is not intended to be used directly. Please use
-# multilib_build_binaries instead.
multilib_is_native_abi() {
debug-print-function ${FUNCNAME} "${@}"
@@ -1007,14 +1093,7 @@ multilib_is_native_abi() {
# @FUNCTION: multilib_build_binaries
# @DESCRIPTION:
-# Determine whether to build binaries for the currently built ABI.
-# Returns true status (0) if the currently built ABI is the profile
-# native or COMPLETE_MULTILIB variable is set to 'yes', otherwise
-# false (1).
-#
-# This is often useful for configure calls when some of the options are
-# supposed to be disabled for multilib ABIs (like those used for
-# executables only).
+# Deprecated alias for multilib_is_native_abi
multilib_build_binaries() {
debug-print-function ${FUNCNAME} "${@}"
@@ -1026,31 +1105,25 @@ multilib_build_binaries() {
# @FUNCTION: multilib_is_best_abi
# @DESCRIPTION:
-# Determine whether the current ABI is the "best" abi,
-# in the sense that it is the ABI we would get if we ran
-# multilib_for_best_abi. Gives the same result as
-# multilib_for_native_abi, unless the native ABI is disabled.
-#
-# Returns true status (0) if that is true, otherwise false (1).
-#
-# Useful for doing something, such as generating
-# documentation, which only need happen once,
-# during multilib_foreach_abi iteration.
+# Deprecated alias for multilib_is_native_abi.
multilib_is_best_abi() {
debug-print-function ${FUNCNAME} "${@}"
- [[ ${MULTILIB_BUILD_ABI} ]] \
- || die "${FUNCNAME}: MULTILIB_BUILD_ABI needs to be set"
- [[ ${MULTILIB_BUILD_ABI} == $(multilib_get_best_abi) ]]
+ eqawarn "QA warning: multilib_is_best_abi is deprecated. Please use the equivalent"
+ eqawarn "multilib_is_native_abi function instead."
+
+ multilib_is_native_abi "${@}"
}
# @FUNCTION: multilib_get_best_abi
# @DESCRIPTION:
-# Return the best abi && return it via echo to stdout
+# Depreciated function to return the best ABI. Just returns the native ABI
+# instead. :(
multilib_get_best_abi() {
- declare -a abis=( $(multilib_get_enabled_abis) )
- echo "${abis[$(( ${#abis[@]} - 1))]}"
- return 0
+ # yes, the >&2 may actually do something... see isolated-functions.sh
+ eqawarn "QA warning: multilib_is_best_abi is deprecated. Please use the equivalent" >&2
+ eqawarn "multilib_is_native_abi function instead." >&2
+ echo "${DEFAULT_ABI:-default}"
}
# @FUNCTION: multilib_native_use_with