From 053a672668a26e86a312d80f7c3ac629ea73472e Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Tue, 12 Jun 2018 22:34:01 +0100 Subject: [PATCH] autotools.eclass: Add has_version workaround for cross-prefix builds Closes: https://bugs.gentoo.org/655414 --- eclass/autotools.eclass | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/eclass/autotools.eclass b/eclass/autotools.eclass index 2bc70f7b3c00..4497af236faf 100644 --- a/eclass/autotools.eclass +++ b/eclass/autotools.eclass @@ -444,14 +444,30 @@ autotools_env_setup() { for pv in ${_LATEST_AUTOMAKE[@]/#*:} ; do # Break on first hit to respect _LATEST_AUTOMAKE order. local hv_args="" - case ${EAPI:-0} in - 5|6) - hv_args="--host-root" - ;; - 7) - hv_args="-b" - ;; - esac + # Cross-prefix builds rely on non-standard behaviour where + # automake is executed from the target system instead of the + # build system. ROOT=/ in this context but in other + # contexts, ROOT=/ indicates that the target system is also + # the build system, so we can check the target system + # without negatively impacting anyone. However, we only do + # this when EPREFIX is set just to be on the safe side. See + # https://bugs.gentoo.org/655414. + if [[ ${ROOT} == / && -n ${EPREFIX} ]]; then + case ${EAPI:-0} in + 7) + hv_args="-d" + ;; + esac + else + case ${EAPI:-0} in + 5|6) + hv_args="--host-root" + ;; + 7) + hv_args="-b" + ;; + esac + fi ROOT=/ has_version ${hv_args} "=sys-devel/automake-${pv}*" && export WANT_AUTOMAKE="${pv}" && break done [[ ${WANT_AUTOMAKE} == "latest" ]] && \ -- 2.17.0