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>
9 ;;; This file is part of GNU Guix.
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24 (define-module (gnu packages groff)
25 #:use-module (guix licenses)
26 #:use-module (guix packages)
27 #:use-module (guix utils)
28 #:use-module (guix download)
29 #:use-module (guix git-download)
30 #:use-module (guix build-system gnu)
31 #:use-module (gnu packages)
32 #:use-module (gnu packages bison)
33 #:use-module (gnu packages ghostscript)
34 #:use-module (gnu packages netpbm)
35 #:use-module (gnu packages perl)
36 #:use-module (gnu packages texinfo))
44 (uri (string-append "mirror://gnu/groff/groff-" version
47 "14q2mldnr1vx0l9lqp9v2f6iww24gj28iyh4j2211hyynx67p3p7"))))
48 (build-system gnu-build-system)
50 "doc")) ;12MiB of PS, PDF, HTML, and examples
52 ;; Note: groff's HTML backend uses executables from netpbm when they are in
53 ;; $PATH. In practice, not having them doesn't prevent it from install its
54 ;; own HTML doc, nor does it change its capabilities, so we removed netpbm
57 (inputs `(("ghostscript" ,ghostscript)))
58 (native-inputs `(("bison" ,bison)
61 ("texinfo" ,texinfo)))
63 `(#:parallel-build? #f ; parallel build fails
65 (modify-phases %standard-phases
66 (add-after 'unpack 'disable-relocatability
68 ;; Groff contains a Rube Goldberg-esque relocator for the file
69 ;; "charset.alias". It tries to find the current executable
70 ;; using realpath, a do-it-yourself search in $PATH and so on.
71 ;; Furthermore, the routine that does the search is buggy
72 ;; in that it doesn't handle error cases when they arise.
73 ;; This causes preconv to segfault when trying to look up
74 ;; the file "charset.alias" in the NULL location.
75 ;; The "charset.alias" parser is a copy of gnulib's, and a
76 ;; non-broken version of gnulib's "charset.alias" parser is
77 ;; part of glibc's libcharset.
78 ;; However, groff unconditionally uses their own
79 ;; "charset.alias" parser, but then DOES NOT INSTALL the
80 ;; file "charset.alias" when glibc is too new.
81 ;; In Guix, our file "charset.alias" only contains an obscure
82 ;; alias for ASCII and nothing else. So just disable relocation
83 ;; and make the entire "charset.alias" lookup fail.
84 ;; See <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30785> for
86 (substitute* "Makefile.in"
87 (("-DENABLE_RELOCATABLE=1") ""))
89 (add-after 'unpack 'setenv
91 (setenv "GS_GENERATE_UUIDS" "0")
93 (add-after 'unpack 'fix-docdir
94 (lambda _ ;see https://savannah.gnu.org/bugs/index.php?55461
95 (substitute* "Makefile.in"
96 (("^docdir =.*") "docdir = @docdir@\n"))
98 (synopsis "Typesetting from plain text mixed with formatting commands")
100 "Groff is a typesetting package that reads plain text and produces
101 formatted output based on formatting commands contained within the text. It
102 is usually the formatter of \"man\" documentation pages.")
104 (home-page "https://www.gnu.org/software/groff/")))
106 (define-public groff-minimal
107 ;; Minimialist groff for use by man-db. Its closure size is less than half
108 ;; that of the full-blown groff.
111 (name "groff-minimal")
112 (synopsis "Minimalist variant of Groff for use by man-db")
115 ;; Omit the DVI, PS, PDF, and HTML backends.
117 (native-inputs `(("bison" ,bison)
121 `(#:disallowed-references (,perl)
123 #:configure-flags '("--with-doc=no")
125 ,@(substitute-keyword-arguments (package-arguments groff)
127 `(modify-phases ,phases
128 (add-after 'install 'remove-non-essential-programs
129 (lambda* (#:key outputs #:allow-other-keys)
130 ;; Keep only the programs that man-db needs at run time,
131 ;; and make sure we don't pull in Perl.
132 (let ((out (assoc-ref outputs "out"))
133 (kept '("eqn" "neqn" "pic" "tbl" "refer" "preconv"
134 "nroff" "groff" "troff" "grotty")))
135 (for-each (lambda (file)
136 (unless (member (basename file) kept)
138 (find-files (string-append out "/bin")))
140 ;; Remove a bunch of unneeded Perl scripts.
141 (for-each delete-file (find-files out "\\.pl$"))
142 (for-each delete-file
143 (find-files out "BuildFoundries"))
145 ;; Remove ~3 MiB from share/groff/X.Y/font/devBACKEND
146 ;; corresponding to the unused backends.
147 (for-each delete-file-recursively
148 (find-files out "^dev(dvi|ps|pdf|html|lj4)$"
152 ;; There are no releases, so we take the latest commit.
153 (define-public roffit
154 (let ((commit "e5228388e3faf2b7f1ae5bd048ad46ed565304c6")
158 (version (string-append "0.11-" revision "." (string-take commit 9)))
162 (url "https://github.com/bagder/roffit.git")
164 (file-name (string-append "roffit-" commit "-checkout"))
167 "1y7ndbqciy7h0khlpi1bv4v1614vhybnmm4jysj6fwxkw9cwv1nc"))))
168 (build-system gnu-build-system)
170 `(#:test-target "test"
172 (list (string-append "INSTALLDIR="
173 (assoc-ref %outputs "out") "/bin"))
175 (modify-phases %standard-phases
177 (add-before 'install 'pre-install
178 (lambda* (#:key outputs #:allow-other-keys)
179 (mkdir-p (string-append (assoc-ref outputs "out")
184 (home-page "https://daniel.haxx.se/projects/roffit/")
185 (synopsis "Convert nroff files to HTML")
187 "Roffit is a program that reads an nroff file and outputs an HTML file.
188 It is typically used to display man pages on a web site.")