[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/48: gnu: perl: Actually produce a host perl when cross-compiling.
From: |
guix-commits |
Subject: |
01/48: gnu: perl: Actually produce a host perl when cross-compiling. |
Date: |
Sun, 19 Apr 2020 10:22:05 -0400 (EDT) |
janneke pushed a commit to branch wip-hurd-vm
in repository guix.
commit 974bb01f15ee695e9664af552e20ef5fa6274e6c
Author: Jan (janneke) Nieuwenhuizen <address@hidden>
AuthorDate: Sat Apr 18 17:05:48 2020 +0200
gnu: perl: Actually produce a host perl when cross-compiling.
* gnu/packages/perl.scm (perl)[native-inputs]: When cross-compiling, add
`perl-cross' input.
[arguments]: When cross-compiling, use it to produce binary for host.
---
gnu/packages/perl.scm | 106 +++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 100 insertions(+), 6 deletions(-)
diff --git a/gnu/packages/perl.scm b/gnu/packages/perl.scm
index d6a7550..c8332ec 100644
--- a/gnu/packages/perl.scm
+++ b/gnu/packages/perl.scm
@@ -11,7 +11,7 @@
;;; Copyright © 2016 Alex Sassmannshausen <address@hidden>
;;; Copyright © 2016, 2018, 2020 Roel Janssen <address@hidden>
;;; Copyright © 2016 Ben Woodcroft <address@hidden>
-;;; Copyright © 2016 Jan Nieuwenhuizen <address@hidden>
+;;; Copyright © 2016, 2020 Jan (janneke) Nieuwenhuizen <address@hidden>
;;; Copyright © 2017 Raoul J.P. Bonnal <address@hidden>
;;; Copyright © 2017, 2018 Marius Bakke <address@hidden>
;;; Copyright © 2017 Adriano Peluso <address@hidden>
@@ -48,14 +48,17 @@
#:use-module (gnu packages)
#:use-module (guix packages)
#:use-module (guix download)
+ #:use-module (guix git-download)
#:use-module (guix utils)
#:use-module (guix build-system gnu)
#:use-module (guix build-system perl)
#:use-module (gnu packages base)
+ #:use-module (gnu packages bash)
#:use-module (gnu packages compression)
#:use-module (gnu packages databases)
#:use-module (gnu packages freedesktop)
#:use-module (gnu packages gd)
+ #:use-module (gnu packages hurd)
#:use-module (gnu packages less)
#:use-module (gnu packages ncurses)
#:use-module (gnu packages perl-check)
@@ -112,7 +115,7 @@
;; Use the right path for `pwd'.
(substitute* "dist/PathTools/Cwd.pm"
(("/bin/pwd")
- (which "pwd")))
+ (which "pwd"))) ;TODO: fix cross-compile next rebuild cycle
;; Build in GNU89 mode to tolerate C++-style comment in libc's
;; <bits/string3.h>.
@@ -120,10 +123,84 @@
(("-std=c89")
"-std=gnu89"))
#t))
- (replace 'configure
- (lambda* (#:key configure-flags #:allow-other-keys)
- (format #t "Perl configure flags: ~s~%" configure-flags)
- (apply invoke "./Configure" configure-flags)))
+ ,@(if (%current-target-system)
+ `((add-after 'unpack 'unpack-cross
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let ((cross-checkout (assoc-ref %build-inputs
"perl-cross")))
+ (invoke "chmod" "-R" "+w" ".")
+ (copy-recursively cross-checkout "."))
+ (let ((bash (assoc-ref %build-inputs "bash")))
+ (substitute* '("Makefile.config.SH"
+ "cnf/config.guess"
+ "cnf/config.sub"
+ "cnf/configure"
+ "cnf/configure_misc.sh"
+ "miniperl_top")
+ (("! */bin/sh") (string-append "! " bash "/bin/bash"))
+ ((" /bin/sh") (string-append bash "/bin/bash")))
+ (substitute* '("cnf/configure_tool.sh")
+ (( "[\t ]*result \"BSD\".*")
+ "\
+ result \"BSD\"
+ ;;
+ *-gnu)
+ result \"GNU\"
+"))
+ (substitute* '("ext/Errno/Errno_pm.PL")
+ (( "\\$cpp < errno.c") "gcc -E errno.c")))
+ #t))
+ (replace 'configure
+ (lambda* (#:key configure-flags outputs inputs
#:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (configure-flags
+ (cons*
+ ;; `perl-cross' confuses target and host
+ (string-append "--target="
,(%current-target-system))
+ (string-append "--prefix=" out)
+ "-Dbyteorder=1234"
+ (filter (negate
+ (lambda (x) (or (string-prefix? "-d" x)
+ (string-prefix? "-Dcc="
x))))
+ configure-flags)))
+ (bash (assoc-ref inputs "bash"))
+ (coreutils (assoc-ref inputs "coreutils")))
+ (format (current-error-port)
+ "running ./configure ~a\n" (string-join
configure-flags))
+ (apply invoke (cons "./configure" configure-flags))
+ (substitute* "config.sh"
+ (("^libs=.*") "libs='-ldl -lpthread -lm'\n")
+ (("^perllibs=.*") "perllibs='-ldl -lpthread -lm'\n")
+ (("/gnu/store/[^/]*-bash-[^/]*") bash))
+ (substitute* '("config.h")
+ (("^#define OSNAME .*")
+ (string-append "#define OSNAME \""
+ ,(if (hurd-target?) "GNU" "Linux")
+ "\"\n"))
+ (("^# HAS_NANOSLEEP") "/* #undef HAS_NANOSLEEP */")
+ (("^#define SH_PATH .*")
+ (string-append "#define SH_PATH \"" bash
"/bin/bash\"\n")))
+ ;;TODO: fix this in setup-configure next rebuild cycle
+ (substitute* "dist/PathTools/Cwd.pm"
+ (("/gnu/store/[^/]*-coreutils-[^/]*") coreutils))
+ #t)))
+ (add-after 'build 'touch-non-built-files-for-install
+ (lambda _
+ ;; `make install' wants to install this; it wasn't
built...
+ (mkdir-p "cpan/Pod-Usage/blib/script")
+ (with-output-to-file "cpan/Pod-Usage/blib/script/pod2text"
+ (lambda _ (display "")))
+ (with-output-to-file
"cpan/Pod-Usage/blib/script/pod2usage"
+ (lambda _ (display "")))
+ (with-output-to-file
"cpan/Pod-Checker/blib/script/podchecker"
+ (lambda _ (display "")))
+ (mkdir-p "cpan/Pod-Parser/blib/script")
+ (with-output-to-file
"cpan/Pod-Parser/blib/script/podselect"
+ (lambda _ (display "")))
+ #t)))
+ `((replace 'configure
+ (lambda* (#:key configure-flags #:allow-other-keys)
+ (format #t "Perl configure flags: ~s~%" configure-flags)
+ (apply invoke "./Configure" configure-flags)))))
(add-after 'install 'remove-extra-references
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
@@ -152,6 +229,23 @@
"/lib',\n"))))
config2)
#t))))))
+ (inputs
+ (if (%current-target-system)
+ `(("bash" ,bash-minimal)
+ ("coreutils" ,coreutils))
+ '()))
+ (native-inputs
+ (if (%current-target-system)
+ `(("perl-cross"
+ ,(origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/arsv/perl-cross")
+ (commit "1.3.3")))
+ (file-name (git-file-name "perl-cross" "1.3.3"))
+ (sha256
+ (base32
"065qbl1x44maykaj8p8za0b6qxj74bz7fi2zsrlydir1mqb1js3d")))))
+ '()))
(native-search-paths (list (search-path-specification
(variable "PERL5LIB")
(files '("lib/perl5/site_perl")))))
- branch wip-hurd-vm created (now ba6bdb0), guix-commits, 2020/04/19
- 01/48: gnu: perl: Actually produce a host perl when cross-compiling.,
guix-commits <=
- 05/48: vm: Make the device node procedure a parameter., guix-commits, 2020/04/19
- 04/48: gnu: texinfo: Cross-build fix: Use host perl in host scripts., guix-commits, 2020/04/19
- 02/48: gnu: autoconf: Support cross-build., guix-commits, 2020/04/19
- 03/48: gnu: automake: Support cross-build., guix-commits, 2020/04/19
- 06/48: syscalls: 'readdir*' chooses between the Linux and Hurd code at run time., guix-commits, 2020/04/19
- 08/48: gnu: hurd: Fix references to /bin/w., guix-commits, 2020/04/19
- 11/48: gnu: Add dde-sources., guix-commits, 2020/04/19
- 13/48: gnu: hurd: Add NFS support., guix-commits, 2020/04/19
- 12/48: gnu: Add netdde., guix-commits, 2020/04/19
- 17/48: services: Add hurd-ttys-service-type., guix-commits, 2020/04/19