[bug#36477,16/31] gnu: groff: Fix cross compilation.
diff mbox series

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

Commit Message

Mathieu Othacehe July 8, 2019, 9:58 a.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 a native-input when cross-compiling.
---
 gnu/packages/groff.scm | 40 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/gnu/packages/groff.scm b/gnu/packages/groff.scm
index cf392f5468..27f796eb98 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.
 ;;;
@@ -54,7 +55,13 @@ 
    ;; from 'inputs'.
 
    (inputs `(("ghostscript" ,ghostscript)))
-   (native-inputs `(("bison" ,bison)
+
+   ;; When cross-compiling, this package depends upon a native install of
+   ;; itself.
+   (native-inputs `(,@(if (%current-target-system)
+                          `(("self" ,this-package))
+                          '())
+                    ("bison" ,bison)
                     ("perl" ,perl)
                     ("psutils" ,psutils)
                     ("texinfo" ,texinfo)))
@@ -65,7 +72,33 @@ 
         (add-after 'unpack 'setenv
           (lambda _
             (setenv "GS_GENERATE_UUIDS" "0")
-            #t)))))
+            #t))
+        ,@(if (%current-target-system)
+              '((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 +119,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)