[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/02: gnu: perl-extutils-pkgconfig: Support cross-compilation.
From: |
guix-commits |
Subject: |
01/02: gnu: perl-extutils-pkgconfig: Support cross-compilation. |
Date: |
Mon, 6 Mar 2023 22:11:00 -0500 (EST) |
apteryx pushed a commit to branch master
in repository guix.
commit ff5f34ae757d709987896d6164bf125319a0f764
Author: Maxim Cournoyer <maxim.cournoyer@gmail.com>
AuthorDate: Fri Feb 24 17:30:03 2023 -0500
gnu: perl-extutils-pkgconfig: Support cross-compilation.
* guix/search-paths.scm ($PKG_CONFIG_PATH): New variable.
* gnu/packages/pkg-config.scm (%pkg-config): Use it.
* gnu/packages/perl.scm (perl-extutils-pkgconfig-for-target): New procedure.
(perl-extutils-pkgconfig): Turn into a syntax that
conditionally expands to...
(cross-perl-extutils-pkgconfig): ... this when %current-target-system is
set,
or...
(%perl-extutils-pkgconfig): ... this in a native compilation context.
[arguments]: New field.
[propagated-inputs]: Turn into...
[native-inputs]: ... this.
[native-search-paths]: New field.
---
gnu/packages/perl.scm | 63 +++++++++++++++++++++++++++++++++++++++++----
gnu/packages/pkg-config.scm | 5 ++--
guix/search-paths.scm | 8 ++++++
3 files changed, 68 insertions(+), 8 deletions(-)
diff --git a/gnu/packages/perl.scm b/gnu/packages/perl.scm
index 41b68baea8..08ae11724c 100644
--- a/gnu/packages/perl.scm
+++ b/gnu/packages/perl.scm
@@ -28,7 +28,7 @@
;;; Copyright © 2020 Paul Garlick <pgarlick@tourbillion-technology.com>
;;; Copyright © 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
;;; Copyright © 2020 Malte Frank Gerdes <malte.f.gerdes@gmail.com>
-;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021 Raghav Gururajan <rg@raghavgururajan.name>
;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
@@ -63,6 +63,8 @@
#:use-module (guix utils)
#:use-module (guix build-system gnu)
#:use-module (guix build-system perl)
+ #:use-module (guix memoization)
+ #:use-module (guix search-paths)
#:use-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module (gnu packages compression)
@@ -90,7 +92,8 @@
#:use-module (gnu packages video)
#:use-module (gnu packages web)
#:use-module (gnu packages xml)
- #:use-module (gnu packages xorg))
+ #:use-module (gnu packages xorg)
+ #:export (perl-extutils-pkgconfig))
;;;
;;; Please: Try to add new module packages in alphabetic order.
@@ -4616,7 +4619,10 @@ convert Perl XS code into C code, the ExtUtils::Typemaps
module to
handle Perl/XS typemap files, and their submodules.")
(license (package-license perl))))
-(define-public perl-extutils-pkgconfig
+;; This is the "primitive" perl-extutils-pkgconfig package. People should use
+;; `perl-extutils-pkgconfig' instead (see below)', but we export
+;; %perl-extutils-pkgconfig so that `fold-packages' finds it.
+(define-public %perl-extutils-pkgconfig
(package
(name "perl-extutils-pkgconfig")
(version "1.16")
@@ -4628,8 +4634,32 @@ handle Perl/XS typemap files, and their submodules.")
(base32
"0vhwh0731rhh1sswmvagq0myn754dnkab8sizh6d3n6pjpcwxsmv"))))
(build-system perl-build-system)
- (propagated-inputs
- (list pkg-config))
+ ;; XXX: Patch the pkg-config references to avoid propagating it, as that
+ ;; would cause the search path to be wrong when cross-building, due to
+ ;; propagated inputs being treated as host inputs, not native inputs.
+ (arguments
+ (list
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'patch-pkg-config-path
+ (lambda* (#:key native-inputs inputs #:allow-other-keys)
+ (let* ((target #$(%current-target-system))
+ (pkg-config-name (if target
+ (string-append target "-pkg-config")
+ "pkg-config"))
+ (pkg-config (search-input-file
+ (or native-inputs inputs)
+ (string-append "bin/" pkg-config-name))))
+ (substitute* '("Makefile.PL"
+ "lib/ExtUtils/PkgConfig.pm")
+ (("qx/pkg-config([^/]*)/" _ args)
+ (string-append "`" pkg-config args "`"))
+ (("(`|\")pkg-config" _ quote)
+ (string-append quote pkg-config)))))))))
+ (native-inputs (list pkg-config))
+ ;; Note: do not use the pkg-config syntax here, as the search paths fields
+ ;; are not thunked and its value could be wrong.
+ (native-search-paths (list $PKG_CONFIG_PATH))
(home-page "https://metacpan.org/release/ExtUtils-PkgConfig")
(synopsis "Simplistic interface to pkg-config")
(description
@@ -4639,6 +4669,29 @@ of perl extensions which bind libraries that
@command{pkg-config} knows.
It is really just boilerplate code that you would have written yourself.")
(license license:lgpl2.1+)))
+(define-public cross-perl-extutils-pkgconfig
+ (mlambda (target)
+ "Return a perl-extutils-pkgconfig for TARGET, adjusting the search paths."
+ (package
+ (inherit %perl-extutils-pkgconfig)
+ ;; Ignore native inputs, and set `PKG_CONFIG_PATH' for target inputs.
+ (native-search-paths '())
+ (search-paths (list $PKG_CONFIG_PATH)))))
+
+(define (perl-extutils-pkgconfig-for-target target)
+ "Return a perl-extutils-pkgconfig package for TARGET, which may be either #f
+for a native build, or a GNU triplet."
+ (if target
+ (cross-perl-extutils-pkgconfig target)
+ %perl-extutils-pkgconfig))
+
+;; This hack mimics the one for pkg-config, to allow automatically choosing
+;; the native or the cross `pkg-config' depending on whether it's being used
+;; in a cross-build environment or not.
+(define-syntax perl-extutils-pkgconfig
+ (identifier-syntax (perl-extutils-pkgconfig-for-target
+ (%current-target-system))))
+
(define-public perl-extutils-typemaps-default
(package
(name "perl-extutils-typemaps-default")
diff --git a/gnu/packages/pkg-config.scm b/gnu/packages/pkg-config.scm
index 6263e90f1f..b15b646416 100644
--- a/gnu/packages/pkg-config.scm
+++ b/gnu/packages/pkg-config.scm
@@ -24,6 +24,7 @@
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix gexp)
+ #:use-module (guix search-paths)
#:use-module (guix build-system gnu)
#:use-module (guix build-system trivial)
#:use-module (gnu packages bash)
@@ -66,9 +67,7 @@
"ac_cv_func_posix_getgrgid_r=yes")
'()))))
(native-search-paths
- (list (search-path-specification
- (variable "PKG_CONFIG_PATH")
- (files '("lib/pkgconfig" "lib64/pkgconfig" "share/pkgconfig")))))
+ (list $PKG_CONFIG_PATH))
(home-page "https://www.freedesktop.org/wiki/Software/pkg-config")
(license gpl2+)
(synopsis "Helper tool used when compiling applications and libraries")
diff --git a/guix/search-paths.scm b/guix/search-paths.scm
index 4a8f5131ed..fcbe7b7953 100644
--- a/guix/search-paths.scm
+++ b/guix/search-paths.scm
@@ -34,6 +34,7 @@
$PATH
$GUIX_EXTENSIONS_PATH
+ $PKG_CONFIG_PATH
$SSL_CERT_DIR
$SSL_CERT_FILE
@@ -83,6 +84,13 @@
(variable "GUIX_EXTENSIONS_PATH")
(files '("share/guix/extensions"))))
+(define $PKG_CONFIG_PATH
+ ;; 'PKG_CONFIG_PATH' is used by pkg-config to locate available header files
+ ;; and libraries, via their .pc files.
+ (search-path-specification
+ (variable "PKG_CONFIG_PATH")
+ (files '("lib/pkgconfig" "lib64/pkgconfig" "share/pkgconfig"))))
+
;; Two variables for certificates (info "(guix)X.509 Certificates"),
;; respected by OpenSSL and possibly GnuTLS in the future
;; (https://gitlab.com/gnutls/gnutls/-/merge_requests/1541)