summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2024-08-19 12:25:21 +0100
committerV3n3RiX <venerix@koprulu.sector>2024-08-19 12:25:21 +0100
commit1f3e27f8fde0df9246ce9151ced7d2dd4e96cb07 (patch)
tree2ccd1e9121906f2bccf218e14e3ca943a2b84bf3 /eclass
parent16be64511bd21e32a29645b49e37611507709790 (diff)
gentoo auto-resync : 19:08:2024 - 12:25:21
Diffstat (limited to 'eclass')
-rw-r--r--eclass/Manifest.gzbin39225 -> 39706 bytes
-rw-r--r--eclass/guile-single.eclass245
-rw-r--r--eclass/guile-utils.eclass275
-rw-r--r--eclass/guile.eclass358
-rw-r--r--eclass/toolchain-funcs.eclass2
5 files changed, 879 insertions, 1 deletions
diff --git a/eclass/Manifest.gz b/eclass/Manifest.gz
index 3eb8c3e8ffb1..7e7833f49b36 100644
--- a/eclass/Manifest.gz
+++ b/eclass/Manifest.gz
Binary files differ
diff --git a/eclass/guile-single.eclass b/eclass/guile-single.eclass
new file mode 100644
index 000000000000..41ede32928bc
--- /dev/null
+++ b/eclass/guile-single.eclass
@@ -0,0 +1,245 @@
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: guile-single.eclass
+# @PROVIDES: guile-utils
+# @MAINTAINER:
+# Gentoo Scheme project <scheme@gentoo.org>
+# @AUTHOR:
+# Author: Arsen Arsenović <arsen@gentoo.org>
+# Inspired by prior work in the Gentoo Python ecosystem.
+# @BLURB: Utilities for packages that build against a single Guile.
+# @SUPPORTED_EAPIS: 8
+# @PROVIDES: guile-utils
+# @DESCRIPTION:
+# This eclass facilitates packages building against a single slot of
+# Guile, which is normally something that uses Guile for extending, like
+# GNU Make, or for programs built in Guile, like Haunt.
+#
+# These packages should use guile_gen_cond_dep to generate a dependency
+# string for their Guile package dependencies (i.e. other Guile single-
+# and multi-implementation packages). They should also utilize
+# GUILE_DEPS and GUILE_REQUIRED_USE to specify a dependency on their
+# Guile versions.
+#
+# They should also bump sources via guile_bump_sources during
+# src_prepare, and unstrip ccache via guile_unstrip_ccache during
+# src_install.
+#
+# If the user of the eclass needs some USE flag on Guile itself, they
+# should provide it via GUILE_REQ_USE.
+#
+# This eclass provides a guile-single_pkg_setup that sets up environment
+# variables needed for Guile and build systems using it. See the
+# documentation for that function for more details.
+#
+# @EXAMPLE:
+# A Guile program:
+#
+# @CODE
+# # Copyright 2024 Gentoo Authors
+# # Distributed under the terms of the GNU General Public License v2
+#
+# EAPI=8
+#
+# GUILE_COMPAT=( 2-2 3-0 )
+# inherit guile-single
+#
+# DESCRIPTION="Haunt is a simple, functional, hackable static site generator"
+# HOMEPAGE="https://dthompson.us/projects/haunt.html"
+# SRC_URI="https://files.dthompson.us/releases/${PN}/${P}.tar.gz"
+#
+# LICENSE="GPL-3+"
+# SLOT="0"
+# KEYWORDS="~amd64"
+# REQUIRED_USE="${GUILE_REQUIRED_USE}"
+#
+# RDEPEND="
+# ${GUILE_DEPS}
+# $(guile_gen_cond_dep '
+# dev-scheme/guile-reader[${GUILE_MULTI_USEDEP}]
+# dev-scheme/guile-commonmark[${GUILE_MULTI_USEDEP}]
+# ')
+# "
+# DEPEND="${RDEPEND}"
+# @CODE
+#
+# A program utilizing Guile for extension (GNU make, irrelevant pieces
+# elided):
+# @CODE
+# GUILE_COMPAT=( 1-8 2-0 2-2 3-0 )
+# inherit flag-o-matic unpacker verify-sig guile-single
+# # ...
+# REQUIRED_USE="guile? ( ${GUILE_REQUIRED_USE} )"
+# DEPEND="
+# guile? ( ${GUILE_DEPS} )
+# "
+#
+# src_prepare() {
+# # ...
+# if use guile; then
+# guile-single_src_prepare
+# fi
+# }
+#
+# pkg_setup() {
+# if use guile; then
+# guile-single_pkg_setup
+# fi
+# }
+#
+# src_configure() {
+# # ...
+# local myeconfargs=(
+# $(use_with guile)
+# )
+# econf "${myeconfargs[@]}"
+# }
+#
+# src_install() {
+# # ...
+# if use guile; then
+# guile_unstrip_ccache
+# fi
+# }
+# @CODE
+
+case "${EAPI}" in
+ 8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ ! "${_GUILE_SINGLE_ECLASS}" ]]; then
+_GUILE_SINGLE_ECLASS=1
+
+inherit guile-utils
+
+# @ECLASS_VARIABLE: GUILE_COMPAT
+# @REQUIRED
+# @PRE_INHERIT
+# @DESCRIPTION:
+# List of acceptable versions of Guile. For instance, setting this
+# variable like below will allow the package to be built against either
+# Guile 2.2 or 3.0:
+#
+# @CODE
+# GUILE_COMPAT=( 2-2 3-0 )
+# @CODE
+#
+# Please keep in ascending order.
+
+_guile_setup() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ # Inhibit generating the GUILE_USEDEP. This variable is not usable
+ # for single packages.
+ local GUILE_USEDEP
+ guile_generate_depstrings guile_single_target ^^
+}
+
+_guile_setup
+unset -f _guile_setup
+
+# @FUNCTION: guile_gen_cond_dep
+# @USAGE: <dependency> [<pattern>...]
+# @DESCRIPTION:
+# Takes a string that uses (quoted) ${GUILE_SINGLE_USEDEP} and
+# ${GUILE_MULTI_USEDEP} markers as placeholders for the correct USE
+# dependency strings for each compatible slot.
+#
+# If the pattern is provided, it is taken to be list of slots to
+# generate the dependency string for, otherwise, ${GUILE_COMPAT[@]} is
+# taken.
+#
+# @EXAMPLE:
+# Note that the "inner" dependency string is in single quotes!
+# @CODE
+# RDEPEND="
+# $(guile_gen_cond_dep '
+# dev-scheme/guile-zstd[${GUILE_MULTI_USEDEP}]
+# dev-scheme/guile-config[${GUILE_SINGLE_USEDEP}]
+# ')
+# "
+# @CODE
+guile_gen_cond_dep() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local deps="$1"
+ shift
+
+ local candidates=( "$@" )
+ if [[ ${#candidates[@]} -eq 0 ]]; then
+ candidates=( "${GUILE_COMPAT[@]}" )
+ fi
+
+ local candidate
+ for candidate in "${candidates[@]}"; do
+ local s="guile_single_target_${candidate}(-)" \
+ m="guile_targets_${candidate}(-)" \
+ subdeps=${deps//\$\{GUILE_SINGLE_USEDEP\}/${s}}
+ subdeps=${subdeps//\$\{GUILE_MULTI_USEDEP\}/${m}}
+ echo "
+ guile_single_target_${candidate}? (
+ ${subdeps}
+ )
+ "
+ done
+}
+
+# @FUNCTION: guile-single_pkg_setup
+# @DESCRIPTION:
+# Sets up the PKG_CONFIG_PATH with the appropriate GUILE_SINGLE_TARGET,
+# as well as setting up a guile-config and the GUILE, GUILD and
+# GUILESNARF environment variables. Also sets GUILE_EFFECTIVE_VERSION
+# to the same value as GUILE_SELECTED_TARGET, as build systems sometimes
+# check that variable.
+#
+# For details on the latter three, see guile_export.
+guile-single_pkg_setup() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ guile_set_common_vars
+
+ GUILE_SELECTED_TARGET=
+ for ver in "${GUILE_COMPAT[@]}"; do
+ debug-print "${FUNCNAME}: checking for ${ver}"
+ use "guile_single_target_${ver}" || continue
+ GUILE_SELECTED_TARGET="${ver/-/.}"
+ break
+ done
+
+ [[ ${GUILE_SELECTED_TARGET} ]] \
+ || die "No GUILE_SINGLE_TARGET specified."
+
+ export PKG_CONFIG_PATH
+ guile_filter_pkgconfig_path "${GUILE_SELECTED_TARGET}"
+ guile_create_temporary_config "${GUILE_SELECTED_TARGET}"
+ local -x GUILE_EFFECTIVE_VERSION="${GUILE_SELECTED_TARGET}"
+ guile_export GUILE GUILD GUILESNARF
+}
+
+# @FUNCTION: guile-single_src_prepare
+# @DESCRIPTION:
+# Runs the default prepare stage, and then bumps Guile sources via
+# guile_bump_sources.
+guile-single_src_prepare() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ default
+ guile_bump_sources
+}
+
+# @FUNCTION: guile-single_src_install
+# @DESCRIPTION:
+# Runs the default install stage, and then marks ccache files not to be
+# stripped using guile_unstrip_ccache.
+guile-single_src_install() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ default
+ guile_unstrip_ccache
+}
+
+EXPORT_FUNCTIONS pkg_setup src_prepare src_install
+
+fi # _GUILE_SINGLE_ECLASS
diff --git a/eclass/guile-utils.eclass b/eclass/guile-utils.eclass
new file mode 100644
index 000000000000..3f122f63a36f
--- /dev/null
+++ b/eclass/guile-utils.eclass
@@ -0,0 +1,275 @@
+# Copyright 2023-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: guile-utils.eclass
+# @MAINTAINER:
+# Gentoo Scheme project <scheme@gentoo.org>
+# @AUTHOR:
+# Author: Arsen Arsenović <arsen@gentoo.org>
+# Inspired by prior work in the Gentoo Python ecosystem.
+# @BLURB: Common code between GNU Guile-related eclasses and ebuilds.
+# @SUPPORTED_EAPIS: 8
+# @DESCRIPTION:
+# This eclass contains various bits of common code between
+# dev-scheme/guile, Guile multi-implementation ebuilds and Guile
+# single-implementation ebuilds.
+
+case "${EAPI}" in
+ 8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ ! "${_GUILE_UTILS_ECLASS}" ]]; then
+_GUILE_UTILS_ECLASS=1
+
+inherit toolchain-funcs
+
+BDEPEND="virtual/pkgconfig"
+
+# @ECLASS_VARIABLE: GUILE_COMPAT
+# @REQUIRED
+# @PRE_INHERIT
+# @DESCRIPTION:
+# List of acceptable versions of Guile. For instance, setting this
+# variable like below will allow the package to be built against either
+# Guile 2.2 or 3.0:
+#
+# @CODE
+# GUILE_COMPAT=( 2-2 3-0 )
+# @CODE
+#
+# Please keep in ascending order.
+
+# @FUNCTION: guile_check_compat
+# @DESCRIPTION:
+# Checks that GUILE_COMPAT is set to an array, and has no invalid
+# values.
+guile_check_compat() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ if ! [[ ${GUILE_COMPAT@a} == *a* ]]; then
+ die "GUILE_COMPAT not set to an array"
+ fi
+
+ if [[ ${#GUILE_COMPAT[@]} -eq 0 ]]; then
+ die "GUILE_COMPAT is empty"
+ fi
+}
+
+guile_check_compat
+
+# @ECLASS_VARIABLE: GUILE_REQ_USE
+# @PRE_INHERIT
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Specifies a USE dependency string for all versions of Guile in
+# GUILE_COMPAT.
+#
+# @EXAMPLE:
+# GUILE_REQ_USE="deprecated"
+
+# @ECLASS_VARIABLE: GUILE_USEDEP
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# This variable is populated with a USE-dependency string which can be
+# used to depend on other Guile multi-implementation packages.
+# This variable is not usable from guile-single packages.
+
+# @ECLASS_VARIABLE: GUILE_DEPS
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# Contains the dependency string for the compatible Guile runtimes.
+
+# @FUNCTION: guile_set_common_vars
+# @DESCRIPTION:
+# Sets common variables that apply to all Guile packages, namely,
+# QA_PREBUILT.
+guile_set_common_vars() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ # These aren't strictly speaking prebuilt. but they do generated a
+ # nonstandard ELF object.
+ if [[ -z ${QA_PREBUILT} ]]; then
+ QA_PREBUILT="usr/$(get_libdir)/guile/*/site-ccache/*"
+ fi
+}
+
+# @FUNCTION: guile_filter_pkgconfig_path
+# @USAGE: <acceptable slots>...
+# @DESCRIPTION:
+# Alters ${PKG_CONFIG_PATH} such that it does not contain any Guile
+# slots besides the ones required by the caller.
+guile_filter_pkgconfig_path() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local filtered_path= unfiltered_path path
+ IFS=: read -ra unfiltered_path <<<"${PKG_CONFIG_PATH}"
+ debug-print "Unfiltered PKG_CONFIG_PATH:" "${unfiltered_path[@]}"
+ for p in "${unfiltered_path[@]}"; do
+ for v in "$@"; do
+ debug-print "... considering '${p}' for ${v}"
+ # Exclude non-selected versions.
+ [[ ${p} == */usr/share/guile-data/${v}/pkgconfig* ]] \
+ || continue
+ debug-print "... OK"
+
+ # Add separator, if some data already exists.
+ [[ "${filtered_path}" ]] && filtered_path+=:
+
+ filtered_path+="${p}"
+ break
+ done
+ done
+
+ debug-print "${FUNCNAME}: Constructed PKG_CONFIG_PATH: ${filtered_path}"
+ PKG_CONFIG_PATH="$filtered_path"
+}
+
+# @FUNCTION: guile_generate_depstrings
+# @USAGE: <prefix> <depop>
+# @DESCRIPTION:
+# Generates GUILE_REQUIRED_USE/GUILE_DEPS/GUILE_USEDEP based on
+# GUILE_COMPAT, and populates IUSE.
+guile_generate_depstrings() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ # Generate IUSE, REQUIRED_USE, GUILE_USEDEP
+ local prefix="$1" depop="$2"
+ GUILE_USEDEP=""
+ local ver uses=()
+ # TODO(arsen): enforce GUILE_COMPAT is in ascending order.
+ for ver in "${GUILE_COMPAT[@]}"; do
+ [[ -n ${GUILE_USEDEP} ]] && GUILE_USEDEP+=","
+ uses+=("${prefix}_${ver}")
+ GUILE_USEDEP+="${prefix}_${ver}"
+ done
+ GUILE_REQUIRED_USE="${depop} ( ${uses[@]} )"
+ IUSE="${uses[@]}"
+ debug-print "${FUNCNAME}: requse ${GUILE_REQUIRED_USE}"
+ debug-print "${FUNCNAME}: generated ${uses[*]}"
+ debug-print "${FUNCNAME}: iuse ${IUSE}"
+
+ # Generate GUILE_DEPS
+ local base_deps=()
+ local requse="${GUILE_REQ_USE+[}${GUILE_REQ_USE:-}${GUILE_REQ_USE+]}"
+ for ver in "${GUILE_COMPAT[@]}"; do
+ base_deps+="
+ ${prefix}_${ver}? (
+ dev-scheme/guile:${ver/-/.}${requse}
+ )
+ "
+ done
+ GUILE_DEPS="${base_deps[*]}"
+ debug-print "${FUNCNAME}: GUILE_DEPS=${GUILE_DEPS}"
+ debug-print "${FUNCNAME}: GUILE_USEDEP=${GUILE_USEDEP}"
+}
+
+# @FUNCTION: guile_unstrip_ccache
+# @DESCRIPTION:
+# Marks site-ccache files not to be stripped. Operates on ${D}.
+guile_unstrip_ccache() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local ccache
+ while read -r -d $'\0' ccache; do
+ debug-print "${FUNCNAME}: ccache found: ${ccache#.}"
+ dostrip -x "${ccache#.}"
+ done < <(cd "${ED}" || die; \
+ find . \
+ -name '*.go' \
+ -path "*/usr/$(get_libdir)/guile/*/site-ccache/*" \
+ -print0 || die) || die
+}
+
+# @FUNCTION: guile_export
+# @USAGE: [GUILE|GUILD|GUILE_SITECCACHEDIR|GUILE_SITEDIR]...
+# @DESCRIPTION:
+# Exports a given variable for the selected Guile variant.
+#
+# Supported variables are:
+#
+# - GUILE - Path to the guile executable,
+# - GUILD - Path to the guild executable,
+# - GUILESNARF - Path to the guile-snarf executable
+# - GUILECONFIG - Path to the guile-config executable
+# - GUILE_SITECCACHEDIR - Path to the site-ccache directory,
+# - GUILE_SITEDIR - Path to the site Scheme directory
+guile_export() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local gver
+ if [[ "${GUILE_CURRENT_VERSION}" ]]; then
+ gver="${GUILE_CURRENT_VERSION}"
+ elif [[ "${GUILE_SELECTED_TARGET}" ]]; then
+ gver="${GUILE_SELECTED_TARGET}"
+ else
+ die "Calling guile_export outside of a Guile build context?"
+ fi
+
+ _guile_pcvar() {
+ local tip="Did you source /etc/profile after an update?"
+ $(tc-getPKG_CONFIG) --variable="$1" guile-"${gver}" \
+ || die "Could not get $1 out of guile-${gver}. ${tip}"
+ }
+
+ for var; do
+ case "${var}" in
+ GUILE) export GUILE="$(_guile_pcvar guile)" ;;
+ GUILD) export GUILD="$(_guile_pcvar guild)" ;;
+ GUILESNARF)
+ GUILESNARF="${EPREFIX}/usr/bin/guile-snarf-${gver}"
+ export GUILESNARF
+ ;;
+ GUILECONFIG)
+ GUILECONFIG="${EPREFIX}/usr/bin/guile-config-${gver}"
+ export GUILECONFIG
+ ;;
+ GUILE_SITECCACHEDIR)
+ GUILE_SITECCACHEDIR="$(_guile_pcvar siteccachedir)"
+ export GUILE_SITECCACHEDIR
+ ;;
+ GUILE_SITEDIR)
+ export GUILE_SITEDIR="$(_guile_pcvar sitedir)"
+ ;;
+ *) die "Unknown variable '${var}'" ;;
+ esac
+ done
+}
+
+# @FUNCTION: guile_create_temporary_config
+# @USAGE: <version>
+# @DESCRIPTION:
+# Creates a guile-config executable for a given Guile version, and
+# inserts it into path.
+guile_create_temporary_config() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ [[ ${1} ]] || die "Must specify a Guile version"
+
+ local cdir="${T}/guiles/${1}/"
+ mkdir -p "${cdir}" || die
+
+ pushd "${cdir}" >/dev/null 2>&1 || die
+ cat >guile-config <<-EOF
+ #!/bin/sh
+ exec guile-config-${1} "\${@}"
+ EOF
+ chmod +x guile-config
+ popd >/dev/null 2>&1 || die
+ PATH="${cdir}:${PATH}"
+}
+
+# @FUNCTION: guile_bump_sources
+# @DESCRIPTION:
+# Searches over ${S} for .scm files and bumps them to avoid Guile using
+# the system ccache while trying to build packages.
+#
+# http://debbugs.gnu.org/cgi/bugreport.cgi?bug=38112
+guile_bump_sources() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ einfo "bumping *.scm source files..."
+ find "${S}" -name "*.scm" -exec touch {} + || die
+}
+
+fi # _GUILE_UTILS_ECLASS
diff --git a/eclass/guile.eclass b/eclass/guile.eclass
new file mode 100644
index 000000000000..d487d765e86a
--- /dev/null
+++ b/eclass/guile.eclass
@@ -0,0 +1,358 @@
+# Copyright 2023-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: guile.eclass
+# @PROVIDES: guile-utils
+# @MAINTAINER:
+# Gentoo Scheme project <scheme@gentoo.org>
+# @AUTHOR:
+# Author: Arsen Arsenović <arsen@gentoo.org>
+# Inspired by prior work in the Gentoo Python ecosystem.
+# @SUPPORTED_EAPIS: 8
+# @BLURB: Utilities for packages multi-implementation Guile packages.
+# @DESCRIPTION:
+# This eclass facilitates building against many Guile implementations,
+# useful for Guile libraries. Each ebuild must set GUILE_COMPAT to a
+# list of versions they support, which will be intersected with
+# GUILE_TARGETS to pick which versions to install. The eclass will
+# generate a GUILE_DEPS based on the configured GUILE_COMPAT, as well as
+# a GUILE_REQUIRED_USE, that the user must use.
+#
+# If the user of the eclass needs some USE flag on Guile itself, they
+# should provide it via GUILE_REQ_USE.
+#
+# This ebuild provides multibuild functionality. Use guile_foreach_impl
+# to run a given command for each enabled Guile version. The command
+# provided will be ran in a modified environment, see the description of
+# that function for more details.
+#
+# This package provides some stage functions written assuming a
+# conventional GNU Build System-based Guile library and may or may not
+# work.
+#
+# For each Guile target, a Guile library should have at least compiled
+# .go files in the ccache or %site-ccache-dir. It must also have
+# corresponding sources installed in %site-dir.
+#
+# If your package has some steps that should only happen for one
+# implementation (e.g. installing a program), you can utilize
+# guile_for_best_impl.
+#
+# Due to http://debbugs.gnu.org/cgi/bugreport.cgi?bug=38112, Guile
+# packages ought to bump their sources before building. To this end,
+# the src_prepare this eclass provides will call guile_bump_sources of
+# the guile-utils eclass.
+#
+# When installing, the packages using this eclass ought to use
+# guile_foreach_impl and its SLOTTED_{,E}D, followed by merging roots
+# via guile_merge_roots and unstripping ccache objects via
+# guile_unstrip_ccache. See descriptions of those functions for
+# details.
+#
+# Ebuild authors, please pay attention for potential conflicts between
+# slots. As an example, dev-scheme/guile-lib installs a pkg-config file
+# that depends on the Guile version it is installed for. This is not
+# acceptable, as it means revdeps will only ever see the version of the
+# file for the best Guile implementation in GUILE_TARGETS.
+#
+# @EXAMPLE:
+# The following example demonstrates a simple package relying entirely
+# on the setup of this eclass. For each enabled, compatible target, the
+# ebuild will bump sources (see description), and run the default
+# configure, compile and test stages (per PMS, meaning GNU Build
+# System), and an install stage modified such that it installs each
+# variant into SLOTTED_D followed by merging roots and unstripping.
+#
+# @CODE
+# EAPI=8
+#
+# GUILE_COMPAT=( 2-2 3-0 )
+# inherit guile
+#
+# DESCRIPTION="iCalendar/vCard parser for GNU Guile"
+# HOMEPAGE="https://github.com/artyom-poptsov/guile-ics"
+# SRC_URI="https://github.com/artyom-poptsov/${PN}/releases/download/v${PV}/${P}.tar.gz"
+#
+# LICENSE="GPL-3+"
+# SLOT="0"
+# KEYWORDS="~amd64"
+# REQUIRED_USE="${GUILE_REQUIRED_USE}"
+#
+# RDEPEND="
+# ${GUILE_DEPS}
+# dev-scheme/guile-smc[${GUILE_USEDEP}]
+# "
+# DEPEND="${RDEPEND}"
+# @CODE
+
+case "${EAPI}" in
+ 8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ ! "${_GUILE_ECLASS}" ]]; then
+_GUILE_ECLASS=1
+
+inherit guile-utils multibuild
+
+# @ECLASS_VARIABLE: GUILE_USEDEP
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# USE dependency string that can be applied to Guile
+# multi-implementation dependencies.
+#
+# @EXAMPLE:
+# RDEPEND="
+# ${GUILE_DEPS}
+# dev-scheme/bytestructures[${GUILE_USEDEP}]
+# >=dev-libs/libgit2-1:=
+# "
+# DEPEND="${RDEPEND}"
+
+# @ECLASS_VARIABLE: GUILE_COMPAT
+# @REQUIRED
+# @PRE_INHERIT
+# @DESCRIPTION:
+# List of acceptable versions of Guile. For instance, setting this
+# variable like below will allow the package to be built against both
+# Guile 2.2 or 3.0:
+#
+# @CODE
+# GUILE_COMPAT=( 2-2 3-0 )
+# @CODE
+#
+# Please keep in ascending order.
+
+_guile_setup() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ guile_generate_depstrings guile_targets '||'
+}
+
+_guile_setup
+unset -f _guile_setup
+
+# @ECLASS_VARIABLE: GUILE_SELECTED_TARGETS
+# @INTERNAL
+# @DESCRIPTION:
+# Contains the intersection of GUILE_TARGETS and GUILE_COMPAT.
+# Generated in guile_pkg_setup.
+
+# @FUNCTION: guile_pkg_setup
+# @DESCRIPTION:
+# Sets up eclass-internal variables for this build.
+guile_pkg_setup() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ guile_set_common_vars
+ GUILE_SELECTED_TARGETS=()
+ for ver in "${GUILE_COMPAT[@]}"; do
+ debug-print "${FUNCNAME}: checking for ${ver}"
+ use "guile_targets_${ver}" || continue
+ GUILE_SELECTED_TARGETS+=("${ver/-/.}")
+ done
+ if [[ "${#GUILE_SELECTED_TARGETS[@]}" -eq 0 ]]; then
+ die "No GUILE_TARGETS specified."
+ fi
+}
+
+# @FUNCTION: guile_copy_sources
+# @DESCRIPTION:
+# Create a single copy of the package sources for each selected Guile
+# implementation.
+guile_copy_sources() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local MULTIBUILD_VARIANTS
+ MULTIBUILD_VARIANTS=("${GUILE_SELECTED_TARGETS[@]}")
+
+ multibuild_copy_sources
+}
+
+# @FUNCTION: _guile_multibuild_wrapper
+# @USAGE: <command> [<argv>...]
+# @INTERNAL
+# @DESCRIPTION:
+# Initialize the environment for a single build variant. See
+# guile_foreach_impl.
+_guile_multibuild_wrapper() {
+ local GUILE_CURRENT_VERSION="${MULTIBUILD_VARIANT}"
+ debug-print-function ${FUNCNAME} "${@}" "on ${MULTIBUILD_VARIANT}"
+
+ local -x PATH="${PATH}"
+ guile_create_temporary_config "${GUILE_CURRENT_VERSION}"
+ guile_export GUILE GUILD GUILESNARF
+
+ local -x PKG_CONFIG_PATH="${PKG_CONFIG_PATH}"
+ guile_filter_pkgconfig_path "${MULTIBUILD_VARIANT}"
+ local ECONF_SOURCE="${S}"
+ local -x SLOTTED_D="${T}/dests/image${MULTIBUILD_ID}"
+ local -x SLOTTED_ED="${SLOTTED_D}${EPREFIX}/"
+ local -x GUILE_EFFECTIVE_VERSION="${GUILE_CURRENT_VERSION}"
+ mkdir -p "${BUILD_DIR}" || die
+ cd "${BUILD_DIR}" || die
+ "$@"
+}
+
+# @VARIABLE: SLOTTED_D
+# @DESCRIPTION:
+# In functions ran by guile_foreach_impl, this variable is set to a new
+# ${D} value that the variant being installed should use.
+
+# @VARIABLE: SLOTTED_ED
+# @DESCRIPTION:
+# In functions ran by guile_foreach_impl, this variable is set to a new
+# ${ED} value that the variant being installed should use. It is
+# equivalent to "${SLOTTED_D%/}${EPREFIX}/".
+
+# @VARIABLE: ECONF_SOURCE
+# @DESCRIPTION:
+# In functions ran by guile_foreach_impl, this variable is set to ${S},
+# for convenience.
+
+# @VARIABLE: PKG_CONFIG_PATH
+# @DESCRIPTION:
+# In functions ran by guile_foreach_impl, PKG_CONFIG_PATH is filtered to
+# contain only the current ${MULTIBUILD_VARIANT}.
+
+# @VARIABLE: BUILD_DIR
+# @DESCRIPTION:
+# In functions ran by guile_foreach_impl, this variable is set to a
+# newly-generated build directory for this variant.
+
+# @FUNCTION: guile_foreach_impl
+# @USAGE: <command> [<argv>...]
+# @DESCRIPTION:
+# Runs the given command for each of the selected Guile implementations.
+#
+# The function will return 0 status if all invocations succeed.
+# Otherwise, the return code from first failing invocation will
+# be returned.
+#
+# Each invocation will have PKG_CONFIG_DIR altered to contain only one
+# Guile implementation, as well as a SLOTTED_D, SLOTTED_ED for
+# installation purposes, and a new BUILD_DIR, in which the wrapped
+# function will be executed, with a pre-configured ECONF_SOURCE. A
+# temporary program called 'guile-config' is generated and inserted into
+# the PATH.
+#
+# Also automatically exported are GUILE, GUILD, and GUILESNARF - see
+# guile_export for details - as well as GUILE_CURRENT_VERSION and
+# GUILE_EFFECTIVE_VERSION, which are set to the same value (the current
+# version).
+#
+# This combination should cover Guile detection of a large amount of
+# packages out of the box.
+guile_foreach_impl() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local MULTIBUILD_VARIANTS
+ MULTIBUILD_VARIANTS=("${GUILE_SELECTED_TARGETS[@]}")
+
+ debug-print "${FUNCNAME}: Running for each of:" \
+ "${GUILE_SELECTED_TARGETS[@]}"
+
+ multibuild_foreach_variant _guile_multibuild_wrapper "${@}"
+}
+
+# @FUNCTION: _guile_merge_single_root
+# @INTERNAL
+# @DESCRIPTION:
+# Runs a single merge_root step for guile_merge_roots.
+_guile_merge_single_root() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ multibuild_merge_root "${SLOTTED_D}" "${D}"
+}
+
+# @FUNCTION: guile_merge_roots
+# @DESCRIPTION:
+# Merges install roots from all slots, diagnosing conflicts.
+guile_merge_roots() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ guile_foreach_impl _guile_merge_single_root
+}
+
+# @FUNCTION: guile_for_best_impl
+# @DESCRIPTION:
+# Runs the passed command once, for the best installed Guile
+# implementation.
+guile_for_best_impl() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ multibuild_for_best_variant _guile_multibuild_wrapper "${@}"
+}
+
+# Default implementations for a GNU Build System based Guile package.
+
+# @FUNCTION: guile_src_prepare
+# @DESCRIPTION:
+# Bumps SCM sources runs the default src_prepare and bumps all *.scm
+# files. See guile_bump_sources of guile-utils.eclass.
+guile_src_prepare() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ default
+ guile_bump_sources
+}
+
+# @FUNCTION: guile_src_configure
+# @DESCRIPTION:
+# Runs the default src_configure for each selected variant target.
+guile_src_configure() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ guile_foreach_impl default
+}
+
+# @FUNCTION: guile_src_compile
+# @DESCRIPTION:
+# Runs the default src_compile for each selected variant target.
+guile_src_compile() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ guile_foreach_impl default
+}
+
+# @FUNCTION: guile_src_test
+# @DESCRIPTION:
+# Runs the default src_test phase for each implementation.
+guile_src_test() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ guile_foreach_impl default
+}
+
+# @FUNCTION: _guile_default_install_slot
+# @INTERNAL
+# @DESCRIPTION:
+# Imitates the default build system install "substep", but for a given
+# ${SLOTTED_D} rather than the usual ${D}. See guile_src_install.
+_guile_default_install_slot() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ if [[ -f Makefile ]] || [[ -f GNUmakefile ]] || [[ -f makefile ]]; then
+ emake DESTDIR="${SLOTTED_D}" install
+ fi
+}
+
+# @FUNCTION: guile_src_install
+# @DESCRIPTION:
+# Runs the an imitation of the default src_install that does the right
+# thing for a GNU Build System based Guile package, for each selected
+# variant target. Merges roots after completing the installs.
+guile_src_install() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ guile_foreach_impl _guile_default_install_slot
+ guile_merge_roots
+ guile_unstrip_ccache
+
+ einstalldocs
+}
+
+EXPORT_FUNCTIONS pkg_setup src_prepare src_configure src_compile \
+ src_install src_test
+
+fi # _GUILE_ECLASS
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index bc1fb064fc45..5e36fa275dcd 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -472,7 +472,7 @@ tc-ld-is-bfd() {
EOF
out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1)
rm -f "${base}"*
- if [[ ${out} != "GNU ld"* ]] ; then
+ if [[ ! ${out} =~ .*^"GNU ld".* ]] ; then
return 1
fi