From 4276283b30eb73359e27c7737b78655fed0a664f Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Wed, 11 Jan 2023 09:40:36 -0500 Subject: gnu: make-arm-trusted-firmware: Simplify build. Reuse knowledge from recent U-Boot modifications to streamline the package definition. * gnu/packages/firmware.scm (make-arm-trusted-firmware): Change optional argument ARCH to keyword TRIPLET. Default to aarch64-linux-gnu. [arguments]: Use gexps. Add a #:target argument. Streamline how the CROSS_COMPILE make flag is computed. [native-inputs]: Delete field. Signed-off-by: Maxim Cournoyer --- gnu/packages/firmware.scm | 116 +++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 64 deletions(-) (limited to 'gnu') diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm index b6ee4c0565..029e84d5c2 100644 --- a/gnu/packages/firmware.scm +++ b/gnu/packages/firmware.scm @@ -8,7 +8,7 @@ ;;; Copyright © 2019 Mathieu Othacehe ;;; Copyright © 2020, 2021, 2022 Marius Bakke ;;; Copyright © 2021 Petr Hodina -;;; Copyright © 2022 Maxim Cournoyer +;;; Copyright © 2022, 2023 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -944,70 +944,58 @@ Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.") (string-append fmw "/ovmf_arm.bin"))))))))) (supported-systems %supported-systems))) -(define* (make-arm-trusted-firmware platform #:optional (arch "aarch64")) - (package - (name (string-append "arm-trusted-firmware-" platform)) - (version "2.8") - (source - (origin - (method git-fetch) - (uri (git-reference +(define* (make-arm-trusted-firmware platform + #:key (triplet "aarch64-linux-gnu")) + (let ((native-build? (lambda () + ;; Note: %current-system is a *triplet*, unlike its + ;; name would suggest. + (or (not triplet) ;disable cross-compilation + (string=? (%current-system) + (gnu-triplet->nix-system triplet)))))) + (package + (name (string-append "arm-trusted-firmware-" platform)) + (version "2.8") + (source + (origin + (method git-fetch) + (uri (git-reference ;; There are only GitHub generated release snapshots. (url "https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/") (commit (string-append "v" version)))) - (file-name (git-file-name "arm-trusted-firmware" version)) - (sha256 - (base32 - "0grq3fgxi9xhcljnhwlxjvdghyz15gaq50raw41xy4lm8rkmnzp3")) - (snippet - #~(begin - (use-modules (guix build utils)) - ;; Remove binary blobs which do not contain source or proper license. - (for-each (lambda (file) - (delete-file file)) - (find-files "." "\\.bin$")))))) - (build-system gnu-build-system) - (arguments - `(#:phases - (modify-phases %standard-phases - (delete 'configure) ; no configure script - (replace 'install - (lambda* (#:key outputs #:allow-other-keys) - (let ((out (assoc-ref outputs "out")) - (bin (find-files "." "\\.(bin|elf)$"))) - (for-each - (lambda (file) - (install-file file out)) - bin))))) - #:make-flags (list (string-append "PLAT=" ,platform) - ,@(if (and (not (string-prefix? "aarch64" - (%current-system))) - (string-prefix? "aarch64" arch)) - `("CROSS_COMPILE=aarch64-linux-gnu-") - '()) - ,@(if (and (not (string-prefix? "armhf" - (%current-system))) - (string-prefix? "armhf" arch)) - `("CROSS_COMPILE=arm-linux-gnueabihf-") - '()) - "DEBUG=1") - #:tests? #f)) ; no tests - (native-inputs - (let ((system (%current-system))) - (cond - ((and (not (string-prefix? "aarch64" system)) - (string-prefix? "aarch64" arch)) - (list (cross-gcc "aarch64-linux-gnu") - (cross-binutils "aarch64-linux-gnu"))) - ((and (not (string-prefix? "armhf" system)) - (string-prefix? "armhf" arch)) - (list (cross-gcc "arm-linux-gnueabihf") - (cross-binutils "arm-linux-gnueabihf"))) - (else '())))) - (home-page "https://www.trustedfirmware.org/") - (synopsis "Implementation of \"secure world software\"") - (description - "ARM Trusted Firmware provides a reference implementation of secure world + (file-name (git-file-name "arm-trusted-firmware" version)) + (sha256 + (base32 + "0grq3fgxi9xhcljnhwlxjvdghyz15gaq50raw41xy4lm8rkmnzp3")) + (snippet + #~(begin + (use-modules (guix build utils)) + ;; Remove binary blobs which do not contain source or proper + ;; license. + (for-each (lambda (file) + (delete-file file)) + (find-files "." "\\.bin$")))))) + (build-system gnu-build-system) + (arguments + (list + #:target (and (not (native-build?)) triplet) + #:phases + #~(modify-phases %standard-phases + (delete 'configure) ;no configure script + (replace 'install + (lambda _ + (for-each (lambda (file) + (install-file file #$output)) + (find-files "." "\\.(bin|elf)$"))))) + #:make-flags #~(list (string-append "PLAT=" #$platform) + #$@(if (not (native-build?)) + (list (string-append "CROSS_COMPILE=" triplet "-")) + '()) + "DEBUG=1") + #:tests? #f)) ;no test suite + (home-page "https://www.trustedfirmware.org/") + (synopsis "Implementation of \"secure world software\"") + (description + "ARM Trusted Firmware provides a reference implementation of secure world software for ARMv7A and ARMv8-A, including a Secure Monitor executing at @dfn{Exception Level 3} (EL3). It implements various ARM interface standards, such as: @@ -1018,8 +1006,8 @@ such as: @item System Control and Management Interface @item Software Delegated Exception Interface (SDEI) @end enumerate\n") - (license (list license:bsd-3 - license:bsd-2)))) ; libfdt + (license (list license:bsd-3 + license:bsd-2))))) ; libfdt (define-public arm-trusted-firmware-sun50i-a64 (let ((base (make-arm-trusted-firmware "sun50i_a64"))) -- cgit v1.2.3