diff mbox series

[bug#36477,30/31] gnu: icu4c: Fix cross-compilation.

Message ID 20190708095913.3460-31-m.othacehe@gmail.com
State Accepted
Headers show
Series Fix cross-compilation issues | expand

Commit Message

Mathieu Othacehe July 8, 2019, 9:59 a.m. UTC
* gnu/packages/icu4c.scm (icu4c-build-root): New variable.
(icu4c)[native-inputs]: Add it.
[arguments]: Pass it as a configure-flag.
---
 gnu/packages/icu4c.scm | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/gnu/packages/icu4c.scm b/gnu/packages/icu4c.scm
index 6e93d6aed9..4d90b31c1c 100644
--- a/gnu/packages/icu4c.scm
+++ b/gnu/packages/icu4c.scm
@@ -4,6 +4,7 @@ 
 ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
 ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -25,6 +26,7 @@ 
   #:use-module (gnu packages perl)
   #:use-module (guix licenses)
   #:use-module (guix packages)
+  #:use-module (guix utils)
   #:use-module (guix download)
   #:use-module (guix build-system ant)
   #:use-module (guix build-system gnu))
@@ -44,11 +46,21 @@ 
             (sha256
              (base32 "17fbk0lm2clsxbmjzvyp245ayx0n4chji3ky1f3fbz2ljjv91i05"))))
    (build-system gnu-build-system)
+   ;; When cross-compiling, this package needs a source directory of a
+   ;; native-build of itself.
+   (native-inputs (if (%current-target-system)
+                      `(("icu4c-build-root" ,icu4c-build-root))
+                      '()))
    (inputs
     `(("perl" ,perl)))
    (arguments
     `(#:configure-flags
-      '("--enable-rpath"
+      (list
+       "--enable-rpath"
+        ,@(if (%current-target-system)
+              '((string-append "--with-cross-build="
+                                (assoc-ref %build-inputs "icu4c-build-root")))
+              '())
         ,@(if (let ((s (or (%current-target-system)
                            (%current-system))))
                 (or (string-prefix? "arm" s)
@@ -81,6 +93,25 @@  C/C++ part.")
    (license x11)
    (home-page "http://site.icu-project.org/")))
 
+(define-public icu4c-build-root
+  (package
+    (inherit icu4c)
+    (name "icu4c-build-root")
+    (arguments
+     (substitute-keyword-arguments (package-arguments icu4c)
+       ((#:tests? _ '())
+        #f)
+       ((#:out-of-source? _ '())
+        #t)
+       ((#:phases phases)
+        `(modify-phases ,phases
+           (replace 'install
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let ((out (assoc-ref outputs "out")))
+                 (copy-recursively "../build" out)
+                 #t)))))))
+    (native-inputs '())))
+
 (define-public java-icu4j
   (package
     (name "java-icu4j")