[PATCH 1/4] perl-module.eclass: support Dist::Build

Sam James <[email protected]> Tue, 4 Aug 2026 20:54:28 +0100
Newsgroups gmane.linux.gentoo.devel
Message-ID <af17a74b9fcde94431cc5898078fc49950ddc468.1785873252.git.sam@gentoo.org>
Signed-off-by: Sam James <[email protected]>
---
I'll push the series shortly.

 eclass/perl-module.eclass | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/eclass/perl-module.eclass b/eclass/perl-module.eclass
index 29b4959bfa98d..6acaa108cd269 100644
--- a/eclass/perl-module.eclass
+++ b/eclass/perl-module.eclass
@@ -255,7 +255,31 @@ perl-module_src_configure() {
 		local myconf_local=("${myconf[@]}")
 	fi
 
-	if [[ ( ${PREFER_BUILDPL} == yes || ! -f Makefile.PL ) && -f Build.PL ]] ; then
+	if [[ -f Build.PL ]] && grep -q '\(use\|require\)\s* Dist::Build' Build.PL ; then
+		einfo "Using Dist::Build"
+		if [[ ${BDEPEND} != *dev-perl/Dist-Build* && ${PN} != Dist-Build ]]; then
+			eerror "QA Notice: The ebuild uses Dist::Build but doesn't depend on it."
+			eerror " Add dev-perl/Dist-Build to BDEPEND!"
+		fi
+
+		# https://metacpan.org/pod/CPAN::API::BuildPL#Command-Line-Options
+		set -- \
+			--installdirs=vendor \
+			--create_packlist=1 \
+			--verbose \
+			--prefix "${EPREFIX}"/usr \
+			--config ar="$(tc-getAR)" \
+			--config cc="$(tc-getCC)" \
+			--config cpp="$(tc-getCPP)" \
+			--config ld="$(tc-getCC)" \
+			--config nm="$(tc-getNM)" \
+			--config ranlib="$(tc-getRANLIB)" \
+			--config optimize="${CFLAGS}" \
+			--config ldflags="${LDFLAGS}" \
+			"${myconf_local[@]}"
+		einfo "perl Build.PL" "$@"
+		perl Build.PL "$@" <<< "${pm_echovar}" || die "Unable to build!"
+	elif [[ ( ${PREFER_BUILDPL} == yes || ! -f Makefile.PL ) && -f Build.PL ]] ; then
 		if grep -q '\(use\|require\)\s*Module::Build::Tiny' Build.PL ; then
 			einfo "Using Module::Build::Tiny"
 			if [[ ${BDEPEND} != *dev-perl/Module-Build-Tiny* && ${PN} != Module-Build-Tiny ]]; then

base-commit: 1988178626a9a9d0a783333092913890d58e22eb
-- 
2.55.0