eclass/autotools: Sync with gentoo

It's from gentoo commit 74fe7755f50b6968c35c3a5dc247be66e27cbe11.
This commit is contained in:
Krzesimir Nowak 2021-12-21 09:25:29 +01:00
parent ff5f9e015e
commit fb18341312

View File

@ -1,10 +1,10 @@
# Copyright 1999-2018 Gentoo Foundation # Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
# @ECLASS: autotools.eclass # @ECLASS: autotools.eclass
# @MAINTAINER: # @MAINTAINER:
# base-system@gentoo.org # base-system@gentoo.org
# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7 # @SUPPORTED_EAPIS: 5 6 7 8
# @BLURB: Regenerates auto* build scripts # @BLURB: Regenerates auto* build scripts
# @DESCRIPTION: # @DESCRIPTION:
# This eclass is for safely handling autotooled software packages that need to # This eclass is for safely handling autotooled software packages that need to
@ -19,31 +19,38 @@ if [[ ${__AUTOTOOLS_AUTO_DEPEND+set} == "set" ]] ; then
# eclass at that point, but that adds overhead, and it's trivial # eclass at that point, but that adds overhead, and it's trivial
# to re-order inherit in eclasses/ebuilds instead. #409611 # to re-order inherit in eclasses/ebuilds instead. #409611
if [[ ${__AUTOTOOLS_AUTO_DEPEND} != ${AUTOTOOLS_AUTO_DEPEND} ]] ; then if [[ ${__AUTOTOOLS_AUTO_DEPEND} != ${AUTOTOOLS_AUTO_DEPEND} ]] ; then
die "AUTOTOOLS_AUTO_DEPEND changed value between inherits; please inherit autotools.eclass first! ${__AUTOTOOLS_AUTO_DEPEND} -> ${AUTOTOOLS_AUTO_DEPEND}" die "AUTOTOOLS_AUTO_DEPEND changed value between inherits; please inherit ${ECLASS} first! ${__AUTOTOOLS_AUTO_DEPEND} -> ${AUTOTOOLS_AUTO_DEPEND}"
fi fi
fi fi
if [[ -z ${_AUTOTOOLS_ECLASS} ]] ; then if [[ -z ${_AUTOTOOLS_ECLASS} ]] ; then
_AUTOTOOLS_ECLASS=1 _AUTOTOOLS_ECLASS=1
case ${EAPI:-0} in case ${EAPI} in
0|1|2|3|4|5|6|7) ;; 5|6)
# Needed for eqawarn
inherit eutils
;;
7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI} not supported" ;; *) die "${ECLASS}: EAPI ${EAPI} not supported" ;;
esac esac
inherit libtool inherit gnuconfig libtool
# @ECLASS-VARIABLE: WANT_AUTOCONF # @ECLASS-VARIABLE: WANT_AUTOCONF
# @PRE_INHERIT
# @DESCRIPTION: # @DESCRIPTION:
# The major version of autoconf your package needs # The major version of autoconf your package needs
: ${WANT_AUTOCONF:=latest} : ${WANT_AUTOCONF:=latest}
# @ECLASS-VARIABLE: WANT_AUTOMAKE # @ECLASS-VARIABLE: WANT_AUTOMAKE
# @PRE_INHERIT
# @DESCRIPTION: # @DESCRIPTION:
# The major version of automake your package needs # The major version of automake your package needs
: ${WANT_AUTOMAKE:=latest} : ${WANT_AUTOMAKE:=latest}
# @ECLASS-VARIABLE: WANT_LIBTOOL # @ECLASS-VARIABLE: WANT_LIBTOOL
# @PRE_INHERIT
# @DESCRIPTION: # @DESCRIPTION:
# Do you want libtool? Valid values here are "latest" and "none". # Do you want libtool? Valid values here are "latest" and "none".
: ${WANT_LIBTOOL:=latest} : ${WANT_LIBTOOL:=latest}
@ -54,18 +61,20 @@ inherit libtool
# CONSTANT! # CONSTANT!
# The latest major unstable and stable version/slot of automake available # The latest major unstable and stable version/slot of automake available
# on each arch. # on each arch.
# Only add unstable version if it is in a different slot than latest stable
# version.
# List latest unstable version first to boost testing adoption rate because # List latest unstable version first to boost testing adoption rate because
# most package manager dependency resolver will pick the first suitable # most package manager dependency resolver will pick the first suitable
# version. # version.
# If a newer slot is stable on any arch, and is NOT reflected in this list, # If a newer slot is stable on any arch, and is NOT reflected in this list,
# then circular dependencies may arise during emerge @system bootstraps. # then circular dependencies may arise during emerge @system bootstraps.
# #
# See bug 312315 and 465732 for further information and context. # See bug #312315 and bug #465732 for further information and context.
# #
# Do NOT change this variable in your ebuilds! # Do NOT change this variable in your ebuilds!
# If you want to force a newer minor version, you can specify the correct # If you want to force a newer minor version, you can specify the correct
# WANT value by using a colon: <PV>:<WANT_AUTOMAKE> # WANT value by using a colon: <PV>:<WANT_AUTOMAKE>
_LATEST_AUTOMAKE=( 1.16.1:1.16 1.15.1:1.15 ) _LATEST_AUTOMAKE=( 1.16.2-r1:1.16 )
_automake_atom="sys-devel/automake" _automake_atom="sys-devel/automake"
_autoconf_atom="sys-devel/autoconf" _autoconf_atom="sys-devel/autoconf"
@ -73,16 +82,9 @@ if [[ -n ${WANT_AUTOMAKE} ]]; then
case ${WANT_AUTOMAKE} in case ${WANT_AUTOMAKE} in
# Even if the package doesn't use automake, we still need to depend # Even if the package doesn't use automake, we still need to depend
# on it because we run aclocal to process m4 macros. This matches # on it because we run aclocal to process m4 macros. This matches
# the autoreconf tool, so this requirement is correct. #401605 # the autoreconf tool, so this requirement is correct, bug #401605.
none) ;; none) ;;
latest) latest) _automake_atom="|| ( `printf '>=sys-devel/automake-%s:%s ' ${_LATEST_AUTOMAKE[@]/:/ }` )" ;;
# Use SLOT deps if we can. For EAPI=0, we get pretty close.
if [[ ${EAPI:-0} != 0 ]] ; then
_automake_atom="|| ( `printf '>=sys-devel/automake-%s:%s ' ${_LATEST_AUTOMAKE[@]/:/ }` )"
else
_automake_atom="|| ( `printf '>=sys-devel/automake-%s ' ${_LATEST_AUTOMAKE[@]/%:*}` )"
fi
;;
*) _automake_atom="=sys-devel/automake-${WANT_AUTOMAKE}*";; *) _automake_atom="=sys-devel/automake-${WANT_AUTOMAKE}*";;
esac esac
export WANT_AUTOMAKE export WANT_AUTOMAKE
@ -109,24 +111,27 @@ if [[ -n ${WANT_LIBTOOL} ]] ; then
export WANT_LIBTOOL export WANT_LIBTOOL
fi fi
# Force people (nicely) to upgrade to a newer version of gettext as # @ECLASS-VARIABLE: AUTOTOOLS_DEPEND
# older ones are known to be crappy. #496454 # @OUTPUT_VARIABLE
AUTOTOOLS_DEPEND="!<sys-devel/gettext-0.18.1.1-r3 # @DESCRIPTION:
${_automake_atom} # Contains the combination of requested automake/autoconf/libtool
# versions in *DEPEND format.
AUTOTOOLS_DEPEND="${_automake_atom}
${_autoconf_atom} ${_autoconf_atom}
${_libtool_atom}" ${_libtool_atom}"
RDEPEND="" RDEPEND=""
# @ECLASS-VARIABLE: AUTOTOOLS_AUTO_DEPEND # @ECLASS-VARIABLE: AUTOTOOLS_AUTO_DEPEND
# @PRE_INHERIT
# @DESCRIPTION: # @DESCRIPTION:
# Set to 'no' to disable automatically adding to DEPEND. This lets # Set to 'no' to disable automatically adding to DEPEND. This lets
# ebuilds form conditional depends by using ${AUTOTOOLS_DEPEND} in # ebuilds form conditional depends by using ${AUTOTOOLS_DEPEND} in
# their own DEPEND string. # their own DEPEND string.
: ${AUTOTOOLS_AUTO_DEPEND:=yes} : ${AUTOTOOLS_AUTO_DEPEND:=yes}
if [[ ${AUTOTOOLS_AUTO_DEPEND} != "no" ]] ; then if [[ ${AUTOTOOLS_AUTO_DEPEND} != "no" ]] ; then
case ${EAPI:-0} in case ${EAPI} in
0|1|2|3|4|5|6) DEPEND=${AUTOTOOLS_DEPEND} ;; 5|6) DEPEND=${AUTOTOOLS_DEPEND} ;;
7) BDEPEND=${AUTOTOOLS_DEPEND} ;; *) BDEPEND=${AUTOTOOLS_DEPEND} ;;
esac esac
fi fi
__AUTOTOOLS_AUTO_DEPEND=${AUTOTOOLS_AUTO_DEPEND} # See top of eclass __AUTOTOOLS_AUTO_DEPEND=${AUTOTOOLS_AUTO_DEPEND} # See top of eclass
@ -138,6 +143,14 @@ unset _automake_atom _autoconf_atom
# @DESCRIPTION: # @DESCRIPTION:
# Additional options to pass to automake during # Additional options to pass to automake during
# eautoreconf call. # eautoreconf call.
: ${AM_OPTS:=}
# @ECLASS-VARIABLE: AT_NOEAUTOHEADER
# @DEFAULT_UNSET
# @DESCRIPTION:
# Don't run eautoheader command if set to 'yes'; only used to work around
# packages that don't want their headers being modified.
: ${AT_NOEAUTOHEADER:=}
# @ECLASS-VARIABLE: AT_NOEAUTOMAKE # @ECLASS-VARIABLE: AT_NOEAUTOMAKE
# @DEFAULT_UNSET # @DEFAULT_UNSET
@ -145,6 +158,7 @@ unset _automake_atom _autoconf_atom
# Don't run eautomake command if set to 'yes'; only used to workaround # Don't run eautomake command if set to 'yes'; only used to workaround
# broken packages. Generally you should, instead, fix the package to # broken packages. Generally you should, instead, fix the package to
# not call AM_INIT_AUTOMAKE if it doesn't actually use automake. # not call AM_INIT_AUTOMAKE if it doesn't actually use automake.
: ${AT_NOEAUTOMAKE:=}
# @ECLASS-VARIABLE: AT_NOELIBTOOLIZE # @ECLASS-VARIABLE: AT_NOELIBTOOLIZE
# @DEFAULT_UNSET # @DEFAULT_UNSET
@ -152,13 +166,16 @@ unset _automake_atom _autoconf_atom
# Don't run elibtoolize command if set to 'yes', # Don't run elibtoolize command if set to 'yes',
# useful when elibtoolize needs to be ran with # useful when elibtoolize needs to be ran with
# particular options # particular options
: ${AT_NOELIBTOOLIZE:=}
# @ECLASS-VARIABLE: AT_M4DIR # @ECLASS-VARIABLE: AT_M4DIR
# @DEFAULT_UNSET
# @DESCRIPTION: # @DESCRIPTION:
# Additional director(y|ies) aclocal should search # Additional director(y|ies) aclocal should search
: ${AT_M4DIR:=} : ${AT_M4DIR:=}
# @ECLASS-VARIABLE: AT_SYS_M4DIR # @ECLASS-VARIABLE: AT_SYS_M4DIR
# @DEFAULT_UNSET
# @INTERNAL # @INTERNAL
# @DESCRIPTION: # @DESCRIPTION:
# For system integrators, a list of additional aclocal search paths. # For system integrators, a list of additional aclocal search paths.
@ -177,13 +194,13 @@ unset _automake_atom _autoconf_atom
eautoreconf() { eautoreconf() {
local x g local x g
# Subdirs often share a common build dir #529404. If so, we can't safely # Subdirs often share a common build dir, bug #529404. If so, we can't safely
# run in parallel because many tools clobber the content in there. Libtool # run in parallel because many tools clobber the content in there. Libtool
# and automake both `rm && cp` while aclocal reads the output. We might be # and automake both `rm && cp` while aclocal reads the output. We might be
# able to handle this if we split the steps and grab locks on the dirs the # able to handle this if we split the steps and grab locks on the dirs the
# tools actually write to. Then we'd run all the common tools that use # tools actually write to. Then we'd run all the common tools that use
# those inputs. Doing this in bash does not scale easily. # those inputs. Doing this in bash does not scale easily.
# If we do re-enable parallel support, make sure #426512 is handled. # If we do re-enable parallel support, make sure bug #426512 is handled.
if [[ -z ${AT_NO_RECURSIVE} ]] ; then if [[ -z ${AT_NO_RECURSIVE} ]] ; then
# Take care of subdirs # Take care of subdirs
for x in $(autotools_check_macro_val AC_CONFIG_SUBDIRS) ; do for x in $(autotools_check_macro_val AC_CONFIG_SUBDIRS) ; do
@ -234,12 +251,12 @@ eautoreconf() {
done done
${rerun_aclocal} && eaclocal ${rerun_aclocal} && eaclocal
if [[ ${WANT_AUTOCONF} = 2.1 ]] ; then if [[ ${WANT_AUTOCONF} == "2.1" ]] ; then
eautoconf eautoconf
else else
eautoconf --force eautoconf --force
fi fi
eautoheader [[ ${AT_NOEAUTOHEADER} != "yes" ]] && eautoheader
[[ ${AT_NOEAUTOMAKE} != "yes" ]] && FROM_EAUTORECONF="yes" eautomake ${AM_OPTS} [[ ${AT_NOEAUTOMAKE} != "yes" ]] && FROM_EAUTORECONF="yes" eautomake ${AM_OPTS}
if [[ ${AT_NOELIBTOOLIZE} != "yes" ]] ; then if [[ ${AT_NOELIBTOOLIZE} != "yes" ]] ; then
@ -254,6 +271,7 @@ eautoreconf() {
# @FUNCTION: _at_uses_pkg # @FUNCTION: _at_uses_pkg
# @USAGE: <macros> # @USAGE: <macros>
# @INTERNAL # @INTERNAL
# @DESCRIPTION:
# See if the specified macros are enabled. # See if the specified macros are enabled.
_at_uses_pkg() { _at_uses_pkg() {
if [[ -n $(autotools_check_macro "$@") ]] ; then if [[ -n $(autotools_check_macro "$@") ]] ; then
@ -289,8 +307,8 @@ eaclocal_amflags() {
[[ -e ${amflags_file} ]] || continue [[ -e ${amflags_file} ]] || continue
# setup the env in case the pkg does something crazy # setup the env in case the pkg does something crazy
# in their ACLOCAL_AMFLAGS. like run a shell script # in their ACLOCAL_AMFLAGS. like run a shell script
# which turns around and runs autotools. #365401 # which turns around and runs autotools (bug #365401)
# or split across multiple lines. #383525 # or split across multiple lines (bug #383525)
autotools_env_setup autotools_env_setup
aclocal_opts=$(sed -n \ aclocal_opts=$(sed -n \
"/^ACLOCAL_AMFLAGS[[:space:]]*=/{ \ "/^ACLOCAL_AMFLAGS[[:space:]]*=/{ \
@ -312,7 +330,7 @@ eaclocal_amflags() {
# specified parametes. The name of the tool run is the same of the function # specified parametes. The name of the tool run is the same of the function
# without e prefix. # without e prefix.
# They also force installing the support files for safety. # They also force installing the support files for safety.
# Respects AT_M4DIR for additional directories to search for macro's. # Respects AT_M4DIR for additional directories to search for macros.
eaclocal() { eaclocal() {
[[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \ [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && \
autotools_run_tool --at-m4flags aclocal "$@" $(eaclocal_amflags) autotools_run_tool --at-m4flags aclocal "$@" $(eaclocal_amflags)
@ -326,7 +344,7 @@ eaclocal() {
_elibtoolize() { _elibtoolize() {
local LIBTOOLIZE=${LIBTOOLIZE:-$(type -P glibtoolize > /dev/null && echo glibtoolize || echo libtoolize)} local LIBTOOLIZE=${LIBTOOLIZE:-$(type -P glibtoolize > /dev/null && echo glibtoolize || echo libtoolize)}
if [[ $1 == "--auto-ltdl" ]] ; then if [[ ${1} == "--auto-ltdl" ]] ; then
shift shift
_at_uses_libltdl && set -- "$@" --ltdl _at_uses_libltdl && set -- "$@" --ltdl
fi fi
@ -354,12 +372,29 @@ eautoconf() {
echo echo
die "No configure.{ac,in} present!" die "No configure.{ac,in} present!"
fi fi
if [[ ${WANT_AUTOCONF} != "2.1" && -e configure.in ]] ; then if [[ ${WANT_AUTOCONF} != "2.1" && -e configure.in ]] ; then
case ${EAPI:-0} in
0|1|2|3|4|5|6|7)
eqawarn "This package has a configure.in file which has long been deprecated. Please" eqawarn "This package has a configure.in file which has long been deprecated. Please"
eqawarn "update it to use configure.ac instead as newer versions of autotools will die" eqawarn "update it to use configure.ac instead as newer versions of autotools will die"
eqawarn "when it finds this file. See https://bugs.gentoo.org/426262 for details." eqawarn "when it finds this file. See https://bugs.gentoo.org/426262 for details."
;;
*)
# Move configure file to the new location only on newer EAPIs to ensure
# checks are done rather than retroactively breaking ebuilds.
eqawarn "Moving configure.in to configure.ac (bug #426262)"
mv configure.{in,ac} || die
;;
esac
fi fi
# Install config.guess and config.sub which are required by many macros
# in autoconf >=2.70.
local _gnuconfig=$(gnuconfig_findnewest)
cp "${_gnuconfig}"/config.{guess,sub} . || die
autotools_run_tool --at-m4flags autoconf "$@" autotools_run_tool --at-m4flags autoconf "$@"
} }
@ -406,7 +441,7 @@ eautomake() {
|| extra_opts+=( --foreign ) || extra_opts+=( --foreign )
# Older versions of automake do not support --force-missing. But we want # Older versions of automake do not support --force-missing. But we want
# to use this whenever possible to update random bundled files #133489. # to use this whenever possible to update random bundled files, bug #133489.
case $(_automake_version) in case $(_automake_version) in
1.4|1.4[.-]*) ;; 1.4|1.4[.-]*) ;;
*) extra_opts+=( --force-missing ) ;; *) extra_opts+=( --force-missing ) ;;
@ -429,7 +464,16 @@ eautopoint() {
# use gettext directly. So we have to copy it in manually since # use gettext directly. So we have to copy it in manually since
# we can't let `autopoint` do it for us. # we can't let `autopoint` do it for us.
config_rpath_update() { config_rpath_update() {
local dst src=$(type -P gettext | sed 's:bin/gettext:share/gettext/config.rpath:') local dst src
case ${EAPI} in
5|6)
src="${EPREFIX}/usr/share/gettext/config.rpath"
;;
*)
src="${BROOT}/usr/share/gettext/config.rpath"
;;
esac
[[ $# -eq 0 ]] && set -- $(find -name config.rpath) [[ $# -eq 0 ]] && set -- $(find -name config.rpath)
[[ $# -eq 0 ]] && return 0 [[ $# -eq 0 ]] && return 0
@ -453,7 +497,7 @@ autotools_env_setup() {
for pv in ${_LATEST_AUTOMAKE[@]/#*:} ; do for pv in ${_LATEST_AUTOMAKE[@]/#*:} ; do
# Break on first hit to respect _LATEST_AUTOMAKE order. # Break on first hit to respect _LATEST_AUTOMAKE order.
local hv_args="" local hv_args=""
case ${EAPI:-0} in case ${EAPI} in
5|6) 5|6)
hv_args="--host-root" hv_args="--host-root"
;; ;;
@ -478,8 +522,8 @@ autotools_env_setup() {
autotools_run_tool() { autotools_run_tool() {
# Process our own internal flags first # Process our own internal flags first
local autofail=true m4flags=false missing_ok=false return_output=false local autofail=true m4flags=false missing_ok=false return_output=false
while [[ -n $1 ]] ; do while [[ -n ${1} ]] ; do
case $1 in case ${1} in
--at-no-fail) autofail=false ;; --at-no-fail) autofail=false ;;
--at-m4flags) m4flags=true ;; --at-m4flags) m4flags=true ;;
--at-missing) missing_ok=true ;; --at-missing) missing_ok=true ;;
@ -490,18 +534,18 @@ autotools_run_tool() {
shift shift
done done
if [[ ${EBUILD_PHASE} != "unpack" && ${EBUILD_PHASE} != "prepare" ]]; then if [[ ${EBUILD_PHASE_FUNC} != "src_unpack" && ${EBUILD_PHASE_FUNC} != "src_prepare" ]] ; then
ewarn "QA Warning: running $1 in ${EBUILD_PHASE} phase" eqawarn "Running '${1}' in ${EBUILD_PHASE_FUNC} phase"
fi fi
if ${missing_ok} && ! type -P ${1} >/dev/null ; then if ${missing_ok} && ! type -P ${1} >/dev/null ; then
einfo "Skipping '$*' due $1 not installed" einfo "Skipping '$*' because '${1}' not installed"
return 0 return 0
fi fi
autotools_env_setup autotools_env_setup
# Allow people to pass in full paths. #549268 # Allow people to pass in full paths, bug #549268
local STDERR_TARGET="${T}/${1##*/}.out" local STDERR_TARGET="${T}/${1##*/}.out"
# most of the time, there will only be one run, but if there are # most of the time, there will only be one run, but if there are
# more, make sure we get unique log filenames # more, make sure we get unique log filenames
@ -515,7 +559,7 @@ autotools_run_tool() {
fi fi
if ${m4flags} ; then if ${m4flags} ; then
set -- "${1}" $(autotools_m4dir_include) "${@:2}" $(autotools_m4sysdir_include) set -- "${1}" $(autotools_m4dir_include) $(autotools_m4sysdir_include) "${@:2}"
fi fi
# If the caller wants to probe something, then let them do it directly. # If the caller wants to probe something, then let them do it directly.
@ -524,19 +568,19 @@ autotools_run_tool() {
return return
fi fi
printf "***** $1 *****\n***** PWD: ${PWD}\n***** $*\n\n" > "${STDERR_TARGET}" printf "***** ${1} *****\n***** PWD: ${PWD}\n***** $*\n\n" > "${STDERR_TARGET}"
ebegin "Running $@" ebegin "Running '$@'"
"$@" >> "${STDERR_TARGET}" 2>&1 "$@" >> "${STDERR_TARGET}" 2>&1
if ! eend $? && ${autofail} ; then if ! eend $? && ${autofail} ; then
echo echo
eerror "Failed Running $1 !" eerror "Failed running '${1}'!"
eerror eerror
eerror "Include in your bug report the contents of:" eerror "Include in your bug report the contents of:"
eerror eerror
eerror " ${STDERR_TARGET}" eerror " ${STDERR_TARGET}"
echo echo
die "Failed Running $1 !" die "Failed running '${1}'!"
fi fi
} }
@ -609,7 +653,7 @@ _autotools_m4dir_include() {
# We handle it below # We handle it below
-${flag}) ;; -${flag}) ;;
*) *)
[[ ! -d ${x} ]] && ewarn "autotools.eclass: '${x}' does not exist" [[ ! -d ${x} ]] && ewarn "${ECLASS}: '${x}' does not exist"
include_opts+=" -${flag} ${x}" include_opts+=" -${flag} ${x}"
;; ;;
esac esac