aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/cross-base.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-12-07 21:49:25 +0100
committerLudovic Courtès <ludo@gnu.org>2016-12-07 21:52:26 +0100
commit3593e5d5c50b08cf69739aac98cd7c89247fa6da (patch)
tree4b6ef97613890e50ad2a85ca5a7d9d19da6a92d0 /gnu/packages/cross-base.scm
parent3009a9e451baf13f9d9fe138e13fe00844355878 (diff)
downloadgnu-guix-3593e5d5c50b08cf69739aac98cd7c89247fa6da.tar
gnu-guix-3593e5d5c50b08cf69739aac98cd7c89247fa6da.tar.gz
gnu: cross-base: Move phases to (gnu build cross-toolchain).
* gnu/packages/cross-base.scm (cross-gcc-arguments) <#:phases>: Use 'cross-gcc-build-phases', and move body cross-toolchain.scm. (cross-gcc): Add #:imported-modules. Add (gnu build cross-toolchain) to #:modules. * gnu/build/cross-toolchain.scm: New file, with code from 'cross-gcc-arguments'. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
Diffstat (limited to 'gnu/packages/cross-base.scm')
-rw-r--r--gnu/packages/cross-base.scm140
1 files changed, 6 insertions, 134 deletions
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 7917e9fd0a..763bbf50e2 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -164,136 +164,7 @@ may be either a libc package or #f.)"
,flags))
flags))
((#:phases phases)
- (let ((phases
- `(alist-cons-after
- 'install 'make-cross-binutils-visible
- (lambda* (#:key outputs inputs #:allow-other-keys)
- (let* ((out (assoc-ref outputs "out"))
- (libexec (string-append out "/libexec/gcc/"
- ,target))
- (binutils (string-append
- (assoc-ref inputs "binutils-cross")
- "/bin/" ,target "-"))
- (wrapper (string-append
- (assoc-ref inputs "ld-wrapper-cross")
- "/bin/" ,target "-ld")))
- (for-each (lambda (file)
- (symlink (string-append binutils file)
- (string-append libexec "/"
- file)))
- '("as" "nm"))
- (symlink wrapper (string-append libexec "/ld"))
- #t))
- (alist-replace
- 'install
- (lambda _
- ;; Unlike our 'strip' phase, this will do the right thing
- ;; for cross-compilers.
- (zero? (system* "make" "install-strip")))
- ,phases))))
- (cond
- ((target-mingw? target)
- `(modify-phases ,phases
- (add-before
- 'configure 'set-cross-path
- (lambda* (#:key inputs #:allow-other-keys)
- ;; Add the cross mingw headers to CROSS_C_*_INCLUDE_PATH,
- ;; and remove them from C_*INCLUDE_PATH.
- (let ((libc (assoc-ref inputs "libc"))
- (gcc (assoc-ref inputs "gcc")))
- (define (cross? x)
- (and libc (string-prefix? libc x)))
- (define (unpacked-mingw-dir)
- (match
- (scandir
- "."
- (lambda (name) (string-contains name "mingw-w64")))
- ((mingw-dir)
- (string-append
- (getcwd) "/" mingw-dir "/mingw-w64-headers"))))
- (if libc
- (let ((cpath (string-append
- libc "/include"
- ":" libc "/i686-w64-mingw32/include")))
- (for-each (cut setenv <> cpath)
- ',%gcc-cross-include-paths))
- ;; libc is false, so we are building xgcc-sans-libc
- ;; Add essential headers from mingw-w64.
- (let ((mingw-source (assoc-ref inputs "mingw-source")))
- (system* "tar" "xf" mingw-source)
- (let ((mingw-headers (unpacked-mingw-dir)))
- ;; We need _mingw.h which will gets built from
- ;; _mingw.h.in by mingw-w64's configure. We
- ;; cannot configure mingw-w64 until we have
- ;; xgcc-sans-libc; substitute to the rescue.
- (copy-file (string-append mingw-headers
- "/crt/_mingw.h.in")
- (string-append mingw-headers
- "/crt/_mingw.h"))
- (substitute* (string-append mingw-headers
- "/crt/_mingw.h")
- (("@MINGW_HAS_SECURE_API@")
- "#define MINGW_HAS_SECURE_API 1"))
- (let ((cpath
- (string-append
- mingw-headers "/include"
- ":" mingw-headers "/crt"
- ":" mingw-headers "/defaults/include")))
- (for-each (cut setenv <> cpath)
- (cons
- "CROSS_LIBRARY_PATH"
- ',%gcc-cross-include-paths))))
- (when libc
- (setenv "CROSS_LIBRARY_PATH"
- (string-append
- libc "/lib"
- ":" libc "/i686-w64-mingw32/lib")))))
- (setenv "CPP" (string-append gcc "/bin/cpp"))
- (for-each
- (lambda (var)
- (and=>
- (getenv var)
- (lambda (value)
- (let* ((path (search-path-as-string->list
- value))
- (native-path (list->search-path-as-string
- (remove cross? path) ":")))
- (setenv var native-path)))))
- (cons "LIBRARY_PATH" ',%gcc-include-paths))
- #t)))))
- (libc
- `(alist-cons-before
- 'configure 'set-cross-path
- (lambda* (#:key inputs #:allow-other-keys)
- ;; Add the cross kernel headers to CROSS_CPATH, and remove
- ;; them from CPATH.
- (let ((libc (assoc-ref inputs "libc"))
- (kernel (assoc-ref inputs "xkernel-headers")))
- (define (cross? x)
- ;; Return #t if X is a cross-libc or cross Linux.
- (or (string-prefix? libc x)
- (string-prefix? kernel x)))
- (let ((cpath (string-append
- libc "/include"
- ":" kernel "/include")))
- (for-each (cut setenv <> cpath)
- ',%gcc-cross-include-paths))
- (setenv "CROSS_LIBRARY_PATH"
- (string-append libc "/lib:"
- kernel "/lib")) ;for Hurd's libihash
- (for-each
- (lambda (var)
- (and=>
- (getenv var)
- (lambda (value)
- (let* ((path (search-path-as-string->list value))
- (native-path (list->search-path-as-string
- (remove cross? path) ":")))
- (setenv var native-path)))))
- (cons "LIBRARY_PATH" ',%gcc-include-paths))
- #t))
- ,phases))
- (else phases))))))))
+ `(cross-gcc-build-phases ,target ,phases))))))
(define (cross-gcc-patches target)
"Return GCC patches needed for TARGET."
@@ -336,13 +207,14 @@ GCC that does not target a libc; otherwise, target that libc."
(arguments
`(#:implicit-inputs? #f
+ #:imported-modules ((gnu build cross-toolchain)
+ ,@%gnu-build-system-modules)
#:modules ((guix build gnu-build-system)
(guix build utils)
- (ice-9 ftw)
- (ice-9 match)
- (ice-9 regex)
+ (gnu build cross-toolchain)
(srfi srfi-1)
- (srfi srfi-26))
+ (srfi srfi-26)
+ (ice-9 regex))
,@(cross-gcc-arguments target libc)))