gnu: sbcl-cl-cffi-gtk: Update to 20200417.
[jackhill/guix/guix.git] / gnu / packages / groff.scm
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 ;;;
9 ;;; This file is part of GNU Guix.
10 ;;;
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.
15 ;;;
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.
20 ;;;
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/>.
23
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))
37
38 (define-public groff
39 (package
40 (name "groff")
41 (version "1.22.4")
42 (source (origin
43 (method url-fetch)
44 (uri (string-append "mirror://gnu/groff/groff-" version
45 ".tar.gz"))
46 (sha256 (base32
47 "14q2mldnr1vx0l9lqp9v2f6iww24gj28iyh4j2211hyynx67p3p7"))))
48 (build-system gnu-build-system)
49 (outputs '("out"
50 "doc")) ;12MiB of PS, PDF, HTML, and examples
51
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
55 ;; from 'inputs'.
56
57 (inputs `(("ghostscript" ,ghostscript)))
58 (native-inputs `(("bison" ,bison)
59 ("perl" ,perl)
60 ("psutils" ,psutils)
61 ("texinfo" ,texinfo)))
62 (arguments
63 `(#:parallel-build? #f ; parallel build fails
64 #:phases
65 (modify-phases %standard-phases
66 (add-after 'unpack 'disable-relocatability
67 (lambda _
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
85 ;; details.
86 (substitute* "Makefile.in"
87 (("-DENABLE_RELOCATABLE=1") ""))
88 #t))
89 (add-after 'unpack 'setenv
90 (lambda _
91 (setenv "GS_GENERATE_UUIDS" "0")
92 #t))
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"))
97 #t)))))
98 (synopsis "Typesetting from plain text mixed with formatting commands")
99 (description
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.")
103 (license gpl3+)
104 (home-page "https://www.gnu.org/software/groff/")))
105
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.
109 (package
110 (inherit groff)
111 (name "groff-minimal")
112 (synopsis "Minimalist variant of Groff for use by man-db")
113 (outputs '("out"))
114
115 ;; Omit the DVI, PS, PDF, and HTML backends.
116 (inputs '())
117 (native-inputs `(("bison" ,bison)
118 ("perl" ,perl)))
119
120 (arguments
121 `(#:disallowed-references (,perl)
122
123 #:configure-flags '("--with-doc=no")
124
125 ,@(substitute-keyword-arguments (package-arguments groff)
126 ((#:phases phases)
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)
137 (delete-file file)))
138 (find-files (string-append out "/bin")))
139
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"))
144
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)$"
149 #:directories? #t))
150 #t))))))))))
151
152 ;; There are no releases, so we take the latest commit.
153 (define-public roffit
154 (let ((commit "e5228388e3faf2b7f1ae5bd048ad46ed565304c6")
155 (revision "1"))
156 (package
157 (name "roffit")
158 (version (string-append "0.11-" revision "." (string-take commit 9)))
159 (source (origin
160 (method git-fetch)
161 (uri (git-reference
162 (url "https://github.com/bagder/roffit.git")
163 (commit commit)))
164 (file-name (string-append "roffit-" commit "-checkout"))
165 (sha256
166 (base32
167 "1y7ndbqciy7h0khlpi1bv4v1614vhybnmm4jysj6fwxkw9cwv1nc"))))
168 (build-system gnu-build-system)
169 (arguments
170 `(#:test-target "test"
171 #:make-flags
172 (list (string-append "INSTALLDIR="
173 (assoc-ref %outputs "out") "/bin"))
174 #:phases
175 (modify-phases %standard-phases
176 (delete 'configure)
177 (add-before 'install 'pre-install
178 (lambda* (#:key outputs #:allow-other-keys)
179 (mkdir-p (string-append (assoc-ref outputs "out")
180 "/bin"))
181 #t)))))
182 (inputs
183 `(("perl" ,perl)))
184 (home-page "https://daniel.haxx.se/projects/roffit/")
185 (synopsis "Convert nroff files to HTML")
186 (description
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.")
189 (license expat))))