diff mbox

[08/12] gnu: cross-base: Add cross-libtool.

Message ID 20160818060851.2853-9-janneke@gnu.org
State New
Headers show

Commit Message

Jan Nieuwenhuizen Aug. 18, 2016, 6:08 a.m. UTC
* gnu/packages/cross-base.scm (cross-libtool): New function.
---
 gnu/packages/cross-base.scm | 48 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
diff mbox

Patch

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 996e392..f11e8c1 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -21,6 +21,7 @@ 
 (define-module (gnu packages cross-base)
   #:use-module (gnu packages)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages commencement)
   #:use-module (gnu packages linux)
@@ -35,6 +36,7 @@ 
   #:use-module (ice-9 match)
   #:export (cross-binutils
             cross-libc
+            cross-libtool
             cross-gcc
             cross-newlib?))
 
@@ -463,6 +465,52 @@  XBINUTILS and the cross tool chain."
                          ,@(package-inputs glibc)     ;FIXME: static-bash
                          ,@(package-native-inputs glibc))))))))
 
+(define* (cross-libtool target
+                        #:optional
+                        (xgcc (cross-gcc target
+                                         (cross-binutils target)
+                                         (cross-libc target)))
+                        (xbinutils (cross-binutils target))
+                        (xlibc (cross-libc target)))
+  (package
+    (inherit libtool)
+    (name (string-append "cross-libtool-" target))
+    (inputs `(("xlibc" ,xlibc)))
+    (native-inputs `(("xgcc" ,xgcc)
+                     ("xbinutils" ,xbinutils)
+                     ("xlibc" ,xlibc)
+                     ,@(package-native-inputs libtool)))
+    (arguments
+     `(;; Libltdl is provided as a separate package, so don't install it here.
+       #:configure-flags
+       `("--disable-ltdl-install"
+         ;; The libtool script uses `host' rather than `target' to decide
+         ;; whether to use -lc, for example.
+         ,(string-append "--host=" ,target)
+         ,(string-append "--target=" ,target)
+         ,(string-append "--program-prefix=" ,target "-")
+         ,(string-append "CC=" ,target "-gcc"))
+       #:tests? #f
+       #:phases (modify-phases %standard-phases
+                  ;; As we are setup as a cross package, PATHs get setup
+                  ;; without the CROSS_ prefix.  Change that here.
+                  (add-before 'configure 'setenv
+                    (lambda* (#:key inputs #:allow-other-keys)
+                      (let* ((xgcc     (assoc-ref inputs "xgcc"))
+                             (xgcc-bin (string-append xgcc "/bin/"
+                                                      ,target "-cpp")))
+                        (setenv "CPP" xgcc-bin)
+                        (setenv "CXXCPP" xgcc-bin))
+                      (for-each (lambda (var)
+                                  (and=> (getenv var)
+                                         (lambda (value)
+                                           (let ((cross
+                                                  (string-append "CROSS_" var)))
+                                             (setenv cross value))
+                                           (unsetenv var))))
+                                (cons "LIBRARY_PATH" ',%gcc-include-paths))
+                      #t)))))))
+
 (define (native-libc target)
   (if (target-mingw? target)
       mingw-w64