1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
5 ;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
6 ;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2019 Eric Bavier <bavier@member.fsf.org>
8 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
10 ;;; This file is part of GNU Guix.
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25 (define-module (gnu packages groff)
26 #:use-module (guix licenses)
27 #:use-module (guix packages)
28 #:use-module (guix utils)
29 #:use-module (guix download)
30 #:use-module (guix git-download)
31 #:use-module (guix build-system gnu)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages bison)
34 #:use-module (gnu packages ghostscript)
35 #:use-module (gnu packages netpbm)
36 #:use-module (gnu packages perl)
37 #:use-module (gnu packages texinfo))
45 (uri (string-append "mirror://gnu/groff/groff-" version
48 "14q2mldnr1vx0l9lqp9v2f6iww24gj28iyh4j2211hyynx67p3p7"))))
49 (build-system gnu-build-system)
51 "doc")) ;12MiB of PS, PDF, HTML, and examples
53 ;; Note: groff's HTML backend uses executables from netpbm when they are in
54 ;; $PATH. In practice, not having them doesn't prevent it from install its
55 ;; own HTML doc, nor does it change its capabilities, so we removed netpbm
58 (inputs `(("ghostscript" ,ghostscript)))
60 ;; When cross-compiling, this package depends upon a native install of
62 (native-inputs `(,@(if (%current-target-system)
63 `(("self" ,this-package))
68 ("texinfo" ,texinfo)))
70 `(#:parallel-build? #f ; parallel build fails
71 ,@(if (%current-target-system)
73 ;; In groff-minimal package, that inherits from this package,
74 ;; we'll need to locate "groff" instead of "self".
75 (let ((groff (or (assoc-ref %build-host-inputs "groff")
76 (assoc-ref %build-host-inputs "self"))))
78 (string-append "GROFF_BIN_PATH=" groff)
79 (string-append "GROFFBIN=" groff "/bin/groff"))))
82 (modify-phases %standard-phases
83 (add-after 'unpack 'disable-relocatability
85 ;; Groff contains a Rube Goldberg-esque relocator for the file
86 ;; "charset.alias". It tries to find the current executable
87 ;; using realpath, a do-it-yourself search in $PATH and so on.
88 ;; Furthermore, the routine that does the search is buggy
89 ;; in that it doesn't handle error cases when they arise.
90 ;; This causes preconv to segfault when trying to look up
91 ;; the file "charset.alias" in the NULL location.
92 ;; The "charset.alias" parser is a copy of gnulib's, and a
93 ;; non-broken version of gnulib's "charset.alias" parser is
94 ;; part of glibc's libcharset.
95 ;; However, groff unconditionally uses their own
96 ;; "charset.alias" parser, but then DOES NOT INSTALL the
97 ;; file "charset.alias" when glibc is too new.
98 ;; In Guix, our file "charset.alias" only contains an obscure
99 ;; alias for ASCII and nothing else. So just disable relocation
100 ;; and make the entire "charset.alias" lookup fail.
101 ;; See <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30785> for
103 (substitute* "Makefile.in"
104 (("-DENABLE_RELOCATABLE=1") ""))
106 (add-after 'unpack 'setenv
108 (setenv "GS_GENERATE_UUIDS" "0")
110 (add-after 'unpack 'fix-docdir
111 (lambda _ ;see https://savannah.gnu.org/bugs/index.php?55461
112 (substitute* "Makefile.in"
113 (("^docdir =.*") "docdir = @docdir@\n"))
115 (synopsis "Typesetting from plain text mixed with formatting commands")
117 "Groff is a typesetting package that reads plain text and produces
118 formatted output based on formatting commands contained within the text. It
119 is usually the formatter of \"man\" documentation pages.")
121 (home-page "https://www.gnu.org/software/groff/")))
123 (define-public groff-minimal
124 ;; Minimialist groff for use by man-db. Its closure size is less than half
125 ;; that of the full-blown groff.
128 (name "groff-minimal")
129 (synopsis "Minimalist variant of Groff for use by man-db")
132 ;; Omit the DVI, PS, PDF, and HTML backends.
134 (native-inputs `(("bison" ,bison)
139 `(#:disallowed-references (,perl)
141 #:configure-flags '("--with-doc=no")
143 ,@(substitute-keyword-arguments (package-arguments groff)
145 `(modify-phases ,phases
146 (add-after 'install 'remove-non-essential-programs
147 (lambda* (#:key outputs #:allow-other-keys)
148 ;; Keep only the programs that man-db needs at run time,
149 ;; and make sure we don't pull in Perl.
150 (let ((out (assoc-ref outputs "out"))
151 (kept '("eqn" "neqn" "pic" "tbl" "refer" "preconv"
152 "nroff" "groff" "troff" "grotty")))
153 (for-each (lambda (file)
154 (unless (member (basename file) kept)
156 (find-files (string-append out "/bin")))
158 ;; Remove a bunch of unneeded Perl scripts.
159 (for-each delete-file (find-files out "\\.pl$"))
160 (for-each delete-file
161 (find-files out "BuildFoundries"))
163 ;; Remove ~3 MiB from share/groff/X.Y/font/devBACKEND
164 ;; corresponding to the unused backends.
165 (for-each delete-file-recursively
166 (find-files out "^dev(dvi|ps|pdf|html|lj4)$"
170 ;; There are no releases, so we take the latest commit.
171 (define-public roffit
172 (let ((commit "e5228388e3faf2b7f1ae5bd048ad46ed565304c6")
176 (version (string-append "0.11-" revision "." (string-take commit 9)))
180 (url "https://github.com/bagder/roffit.git")
182 (file-name (string-append "roffit-" commit "-checkout"))
185 "1y7ndbqciy7h0khlpi1bv4v1614vhybnmm4jysj6fwxkw9cwv1nc"))))
186 (build-system gnu-build-system)
188 `(#:test-target "test"
190 (list (string-append "INSTALLDIR="
191 (assoc-ref %outputs "out") "/bin"))
193 (modify-phases %standard-phases
195 (add-before 'install 'pre-install
196 (lambda* (#:key outputs #:allow-other-keys)
197 (mkdir-p (string-append (assoc-ref outputs "out")
202 (home-page "https://daniel.haxx.se/projects/roffit/")
203 (synopsis "Convert nroff files to HTML")
205 "Roffit is a program that reads an nroff file and outputs an HTML file.
206 It is typically used to display man pages on a web site.")