Patchwork [07/11] gnu: cross-base: Add cross-libtool.

login
register
mail settings
Submitter Jan Nieuwenhuizen
Date May 8, 2016, 8:42 p.m.
Message ID <1462740169-15029-8-git-send-email-janneke@gnu.org>
Download mbox | patch
Permalink /patch/12157/
State New
Headers show

Comments

Jan Nieuwenhuizen - May 8, 2016, 8:42 p.m.
* gnu/packages/cross-base.scm (cross-libtool): New function.
---
 gnu/packages/cross-base.scm | 46 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
Andy Wingo - May 9, 2016, 7:29 a.m.
On Sun 08 May 2016 22:42, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> * gnu/packages/cross-base.scm (cross-libtool): New function.
> ---
>  gnu/packages/cross-base.scm | 46 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 46 insertions(+)
>
> diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
> index a7227d0..011f58d 100644
> --- a/gnu/packages/cross-base.scm
> +++ b/gnu/packages/cross-base.scm
> @@ -22,6 +22,7 @@
>    #:use-module ((guix licenses) #:prefix license:)
>    #:use-module (gnu packages)
>    #:use-module (gnu packages base)
> +  #:use-module (gnu packages autotools)
>    #:use-module (gnu packages bash)
>    #:use-module (gnu packages gawk)
>    #:use-module (gnu packages gcc)
> @@ -40,6 +41,7 @@
>    #:use-module (ice-9 match)
>    #:export (cross-binutils
>              cross-libc
> +            cross-libtool
>              cross-gcc
>              cross-newlib?))
>  
> @@ -449,6 +451,50 @@ 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"
> +         ,(string-append "--host=" ,target)
> +         ,(string-append "--target=" ,target)
> +         ,(string-append "--program-prefix=" ,target "-")
> +         ,(string-append "CC=" ,target "-gcc"))

Is this the right --host setting?

> +       #:tests? #f
> +       #:phases (modify-phases %standard-phases
> +                  (add-before 'configure 'setenv
> +                    (lambda* (#:key inputs native-inputs #:allow-other-keys)
> +                      (let ((xgcc (assoc-ref inputs "xgcc")))
> +                        (setenv "CPP" (string-append xgcc "/bin/"
> +                                                     ,target "-cpp")))
> +                      (for-each (lambda (var)
> +                                  (and=> (getenv var)
> +                                         (lambda (value)
> +                                           (let ((cross
> +                                                  (string-append "CROSS_" var)))
> +                                             (setenv cross value))
> +                                           (unsetenv var))))
> +                                '("C_INCLUDE_PATH"
> +                                  "CPLUS_INCLUDE_PATH"
> +                                  "OBJC_INCLUDE_PATH"
> +                                  "OBJCPLUS_INCLUDE_PATH"
> +                                  "LIBRARY_PATH"))
> +                      #t)))))))

Ignorant question: Why do we have to do this here?  Is libtool a special
case?  We should certainly limit the number of places in Guix's code
where we have to do (for-each ... '("C_INCLUDE_PATH" ...)).

Andy

Patch

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index a7227d0..011f58d 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -22,6 +22,7 @@ 
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (gnu packages)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages gawk)
   #:use-module (gnu packages gcc)
@@ -40,6 +41,7 @@ 
   #:use-module (ice-9 match)
   #:export (cross-binutils
             cross-libc
+            cross-libtool
             cross-gcc
             cross-newlib?))
 
@@ -449,6 +451,50 @@  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"
+         ,(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
+                  (add-before 'configure 'setenv
+                    (lambda* (#:key inputs native-inputs #:allow-other-keys)
+                      (let ((xgcc (assoc-ref inputs "xgcc")))
+                        (setenv "CPP" (string-append xgcc "/bin/"
+                                                     ,target "-cpp")))
+                      (for-each (lambda (var)
+                                  (and=> (getenv var)
+                                         (lambda (value)
+                                           (let ((cross
+                                                  (string-append "CROSS_" var)))
+                                             (setenv cross value))
+                                           (unsetenv var))))
+                                '("C_INCLUDE_PATH"
+                                  "CPLUS_INCLUDE_PATH"
+                                  "OBJC_INCLUDE_PATH"
+                                  "OBJCPLUS_INCLUDE_PATH"
+                                  "LIBRARY_PATH"))
+                      #t)))))))
+
 (define (native-libc target)
   (if (mingw-target? target)
       mingw-w64