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

login
register
mail settings
Submitter Jan Nieuwenhuizen
Date May 14, 2016, 8:26 p.m.
Message ID <87wpmw9yib.fsf@drakenvlieg.flower>
Download mbox | patch
Permalink /patch/12256/
State New
Headers show

Comments

Jan Nieuwenhuizen - May 14, 2016, 8:26 p.m.
Andy Wingo writes:

>> +    (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?

I think so.  The libtool script uses $host rather than $target in tests
like these

	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
	  case $host in
	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
	    # These systems don't actually have a C or math library (as such)
	    continue
	    ;;

I have added this comment

         ;; The libtool script uses `host' rather than `target' to decide
         ;; whether to use -lc, for example.
         ,(string-append "--host=" ,target)

>> +                      (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" ...)).

libtool is `special' when it is built as a cross package, like we do
here in cross-libtool.

I have added this comment

                  ;; As we are setup as a cross package, PATHs get setup
                  ;; without the CROSS_ prefix.  Change that here.
                  (add-before 'configure 'setenv

Thanks!
Greetings,
Jan
Andy Wingo - May 17, 2016, 7:21 a.m.
On Sat 14 May 2016 22:26, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> From 78efd3acd57df52ec635de5d306a5d3865b473b6 Mon Sep 17 00:00:00 2001
> From: Jan Nieuwenhuizen <janneke@gnu.org>
> Date: Wed, 27 Apr 2016 10:33:52 +0200
> Subject: [PATCH 07/11] gnu: cross-base: Add cross-libtool.

Thanks for the comments; LGTM for me :)

Patch

From 78efd3acd57df52ec635de5d306a5d3865b473b6 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Wed, 27 Apr 2016 10:33:52 +0200
Subject: [PATCH 07/11] gnu: cross-base: Add cross-libtool.

* 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 6efd748..18329df 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?))
 
@@ -460,6 +462,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
-- 
2.7.3