[bug#35244,2/6] gnu: groff: Fix cross compilation.

Message ID 20190412131556.25282-2-m.othacehe@gmail.com
State New
Headers show
Series
  • Fix some cross-compilation issues.
Related show

Checks

Context Check Description
cbaines/applying patch success Successfully applied

Commit Message

Mathieu Othacehe April 12, 2019, 1:15 p.m. UTC
* gnu/packages/groff.scm (groff)[arguments]: Replace build phase to pass
GROFF_BIN_PATH and GROFFBIN variables when cross-compiling.

Also add native groff as an input.
---
 gnu/packages/groff.scm | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

Comments

Ludovic Courtès April 14, 2019, 3:22 p.m. UTC | #1
Hi,

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> * gnu/packages/groff.scm (groff)[arguments]: Replace build phase to pass
> GROFF_BIN_PATH and GROFFBIN variables when cross-compiling.
>
> Also add native groff as an input.

You’d need to mention ‘self-native-input?’ explicitly.

> +   (self-native-input? #t)

However, this field no longer exists: see commit
a7646bc5e17a829d23519d0b199a576fb1edbd04, and see
528ea990c3a815cb4b0ded913ea22cdc778839bd for how to adjust your package.

> +         (replace 'build
> +           (lambda* (#:key
> +                     make-flags parallel-build?
> +                     native-inputs target #:allow-other-keys)
> +             ;; When cross-compiling, native groff is needed, see:
> +             ;; http://www.mail-archive.com/bug-groff@gnu.org/msg01335.html
> +             (let ((parallel
> +                    (if parallel-build?
> +                        `("-j" ,(number->string (parallel-job-count)))
> +                        '()))
> +                   (flags
> +                    (if target
> +                        (let ((groff (or
> +                                      (assoc-ref native-inputs "groff")
> +                                      (assoc-ref native-inputs "self"))))
> +                          (append
> +                           make-flags
> +                           (list
> +                            (string-append "GROFF_BIN_PATH=" groff)
> +                            (string-append "GROFFBIN=" groff
> +                                           "/bin/groff"))))
> +                        make-flags)))
> +               (apply invoke `("make" ,@parallel ,@flags)))

If you make it conditional on (%current-target-system) , that’ll avoid a
massive rebuild of the 4K packages that depend on ‘groff’, and thus
it’ll be applicable on ‘master’.

Could you send an updated patch?

Thanks,
Ludo’.

Patch

diff --git a/gnu/packages/groff.scm b/gnu/packages/groff.scm
index cf392f5468..6f01395691 100644
--- a/gnu/packages/groff.scm
+++ b/gnu/packages/groff.scm
@@ -3,6 +3,7 @@ 
 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -53,6 +54,7 @@ 
    ;; own HTML doc, nor does it change its capabilities, so we removed netpbm
    ;; from 'inputs'.
 
+   (self-native-input? #t)
    (inputs `(("ghostscript" ,ghostscript)))
    (native-inputs `(("bison" ,bison)
                     ("perl" ,perl)
@@ -65,7 +67,31 @@ 
         (add-after 'unpack 'setenv
           (lambda _
             (setenv "GS_GENERATE_UUIDS" "0")
-            #t)))))
+            #t))
+         (replace 'build
+           (lambda* (#:key
+                     make-flags parallel-build?
+                     native-inputs target #:allow-other-keys)
+             ;; When cross-compiling, native groff is needed, see:
+             ;; http://www.mail-archive.com/bug-groff@gnu.org/msg01335.html
+             (let ((parallel
+                    (if parallel-build?
+                        `("-j" ,(number->string (parallel-job-count)))
+                        '()))
+                   (flags
+                    (if target
+                        (let ((groff (or
+                                      (assoc-ref native-inputs "groff")
+                                      (assoc-ref native-inputs "self"))))
+                          (append
+                           make-flags
+                           (list
+                            (string-append "GROFF_BIN_PATH=" groff)
+                            (string-append "GROFFBIN=" groff
+                                           "/bin/groff"))))
+                        make-flags)))
+               (apply invoke `("make" ,@parallel ,@flags)))
+             #t)))))
    (synopsis "Typesetting from plain text mixed with formatting commands")
    (description
     "Groff is a typesetting package that reads plain text and produces
@@ -86,7 +112,8 @@  is usually the formatter of \"man\" documentation pages.")
     ;; Omit the DVI, PS, PDF, and HTML backends.
     (inputs '())
     (native-inputs `(("bison" ,bison)
-                     ("perl" ,perl)))
+                     ("perl" ,perl)
+                     ("groff" ,groff)))
 
     (arguments
      `(#:disallowed-references (,perl)