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

login
register
mail settings
Submitter Jan Nieuwenhuizen
Date Aug. 9, 2016, 6:41 a.m.
Message ID <20160809064139.27872-9-janneke@gnu.org>
Download mbox | patch
Permalink /patch/14441/
State New
Headers show

Comments

Jan Nieuwenhuizen - Aug. 9, 2016, 6:41 a.m.
* gnu/packages/cross-base.scm (cross-libtool): New function.
---
 gnu/packages/cross-base.scm | 52 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
Alex Kost - Aug. 9, 2016, 8:08 a.m.
Jan Nieuwenhuizen (2016-08-09 09:41 +0300) wrote:

> * gnu/packages/cross-base.scm (cross-libtool): New function.
> ---
>  gnu/packages/cross-base.scm | 52 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
>
>
> diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
> index 294de40..f6c30ec 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?))
>  
> @@ -477,6 +479,56 @@ 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 native-inputs #:allow-other-keys)

It looks like 'native-inputs' is not needed, as it is not used further.

> +                      (let ((xgcc (assoc-ref inputs "xgcc")))
> +                        (setenv "CPP" (string-append xgcc "/bin/"
> +                                                     ,target "-cpp"))
> +                        (setenv "CXXCPP" (string-append xgcc "/bin/"
> +                                                        ,target "-cpp")))

Since the values are the same, what about:

  (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))))
> +                                '("C_INCLUDE_PATH"
> +                                  "CPLUS_INCLUDE_PATH"
> +                                  "OBJC_INCLUDE_PATH"
> +                                  "OBJCPLUS_INCLUDE_PATH"
> +                                  "LIBRARY_PATH"))

I have already seen this list of environment variables in an earlier
patch.  Perhaps it would be reasonable to make some global variable with
this list and to put it in (guix build utils) or another appropriate
place, WDYT?

> +                      #t)))))))
> +
>  (define (native-libc target)
>    (if (mingw-target? target)
>        mingw-w64

Patch

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 294de40..f6c30ec 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?))
 
@@ -477,6 +479,56 @@  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 native-inputs #:allow-other-keys)
+                      (let ((xgcc (assoc-ref inputs "xgcc")))
+                        (setenv "CPP" (string-append xgcc "/bin/"
+                                                     ,target "-cpp"))
+                        (setenv "CXXCPP" (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