gnu: gcc: Allow cross-compilation of GCC itself.

* gnu/packages/gcc.scm (gcc-4.7): Define `CC_FOR_TARGET',
  `AR_FOR_TARGET', etc. when cross-compiling.
This commit is contained in:
Ludovic Courtès 2013-06-26 16:51:39 +02:00
parent e7133c7680
commit de1d41f980
1 changed files with 128 additions and 107 deletions

View File

@ -32,7 +32,39 @@
"ftp://gcc.gnu.org/pub/gcc/infrastructure/") "ftp://gcc.gnu.org/pub/gcc/infrastructure/")
(define-public gcc-4.7 (define-public gcc-4.7
(let ((stripped? #t)) ; TODO: make this a parameter (let* ((stripped? #t) ; TODO: make this a parameter
(maybe-target-tools
(lambda ()
;; Return the `_FOR_TARGET' variables that are needed when
;; cross-compiling GCC.
(let ((target (%current-target-system)))
(if target
(map (lambda (var tool)
(string-append (string-append var "_FOR_TARGET")
"=" target "-" tool))
'("CC" "CXX" "LD" "AR" "NM" "RANLIB" "STRIP")
'("gcc" "g++" "ld" "ar" "nm" "ranlib" "strip"))
'()))))
(configure-flags
(lambda ()
;; This is terrible. Since we have two levels of quasiquotation,
;; we have to do this convoluted thing just so we can insert the
;; contents of (maybe-target-tools).
(list 'quasiquote
(append
'("--enable-plugin"
"--enable-languages=c,c++"
"--disable-multilib"
"--with-local-prefix=/no-gcc-local-prefix"
,(let ((libc (assoc-ref %build-inputs "libc")))
(if libc
(string-append "--with-native-system-header-dir=" libc
"/include")
"--without-headers")))
(maybe-target-tools))))))
(package (package
(name "gcc") (name "gcc")
(version "4.7.3") (version "4.7.3")
@ -54,18 +86,7 @@
(arguments (arguments
`(#:out-of-source? #t `(#:out-of-source? #t
#:strip-binaries? ,stripped? #:strip-binaries? ,stripped?
#:configure-flags #:configure-flags ,(configure-flags)
`("--enable-plugin"
"--enable-languages=c,c++"
"--disable-multilib"
"--with-local-prefix=/no-gcc-local-prefix"
,(let ((libc (assoc-ref %build-inputs "libc")))
(if libc
(string-append "--with-native-system-header-dir=" libc
"/include")
"--without-headers")))
#:make-flags #:make-flags
(let ((libc (assoc-ref %build-inputs "libc"))) (let ((libc (assoc-ref %build-inputs "libc")))
`(,@(if libc `(,@(if libc