gnu: make-u-boot-package: Don't unnecessarily cross-compile.

* gnu/packages/bootloaders.scm (make-u-boot-package)[native-inputs]: Only
use cross-gcc and cross-binutils if compiling for a different
architecture.
[arguments]: Only use cross compiling make-flags if cross compiling.
This commit is contained in:
Efraim Flashner 2017-08-06 00:13:06 +03:00
parent 18c6a7b4c8
commit 3bfee8ff02
No known key found for this signature in database
GPG Key ID: 41AAE7DCCA3D8351
1 changed files with 50 additions and 42 deletions

View File

@ -333,48 +333,56 @@ also initializes the boards (RAM etc).")
(define (make-u-boot-package board triplet) (define (make-u-boot-package board triplet)
"Returns a u-boot package for BOARD cross-compiled for TRIPLET." "Returns a u-boot package for BOARD cross-compiled for TRIPLET."
(package (let ((same-arch? (if (string-prefix? (%current-system) triplet)
(inherit u-boot) `#t
(name (string-append "u-boot-" (string-downcase board))) `#f)))
(native-inputs (package
`(("cross-gcc" ,(cross-gcc triplet)) (inherit u-boot)
("cross-binutils" ,(cross-binutils triplet)) (name (string-append "u-boot-" (string-downcase board)))
,@(package-native-inputs u-boot))) (native-inputs
(arguments `(,@(if (not same-arch?)
`(#:modules ((ice-9 ftw) (guix build utils) (guix build gnu-build-system)) `(("cross-gcc" ,(cross-gcc triplet))
#:test-target "test" ("cross-binutils" ,(cross-binutils triplet)))
#:make-flags '())
(list "HOSTCC=gcc" (string-append "CROSS_COMPILE=" ,triplet "-")) ,@(package-native-inputs u-boot)))
#:phases (arguments
(modify-phases %standard-phases `(#:modules ((ice-9 ftw) (guix build utils) (guix build gnu-build-system))
(replace 'configure #:test-target "test"
(lambda* (#:key outputs make-flags #:allow-other-keys) #:make-flags
(let ((config-name (string-append ,board "_defconfig"))) (list "HOSTCC=gcc"
(if (file-exists? (string-append "configs/" config-name)) ,@(if (not same-arch?)
(zero? (apply system* "make" `(,@make-flags ,config-name))) `((string-append "CROSS_COMPILE=" ,triplet "-"))
(begin '()))
(display "Invalid board name. Valid board names are:") #:phases
(let ((suffix-len (string-length "_defconfig"))) (modify-phases %standard-phases
(scandir "configs" (replace 'configure
(lambda (file-name) (lambda* (#:key outputs make-flags #:allow-other-keys)
(when (string-suffix? "_defconfig" file-name) (let ((config-name (string-append ,board "_defconfig")))
(format #t (if (file-exists? (string-append "configs/" config-name))
"- ~A\n" (zero? (apply system* "make" `(,@make-flags ,config-name)))
(string-drop-right file-name (begin
suffix-len)))))) (display "Invalid board name. Valid board names are:")
#f))))) (let ((suffix-len (string-length "_defconfig")))
(replace 'install (scandir "configs"
(lambda* (#:key outputs make-flags #:allow-other-keys) (lambda (file-name)
(let* ((out (assoc-ref outputs "out")) (when (string-suffix? "_defconfig" file-name)
(libexec (string-append out "/libexec")) (format #t
(uboot-files (find-files "." ".*\\.(bin|efi|spl)$"))) "- ~A\n"
(mkdir-p libexec) (string-drop-right file-name
(for-each suffix-len))))))
(lambda (file) #f)))))
(let ((target-file (string-append libexec "/" file))) (replace 'install
(mkdir-p (dirname target-file)) (lambda* (#:key outputs make-flags #:allow-other-keys)
(copy-file file target-file))) (let* ((out (assoc-ref outputs "out"))
uboot-files))))))))) (libexec (string-append out "/libexec"))
(uboot-files (find-files "." ".*\\.(bin|efi|spl)$")))
(mkdir-p libexec)
(for-each
(lambda (file)
(let ((target-file (string-append libexec "/" file)))
(mkdir-p (dirname target-file))
(copy-file file target-file)))
uboot-files))))))))))
(define-public u-boot-vexpress (define-public u-boot-vexpress
(make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf")) (make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf"))