gnu: python-2.7: Fix build.
[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 ;;;
8 ;;; This file is part of GNU Guix.
9 ;;;
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
14 ;;;
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
19 ;;;
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23 (define-module (gnu packages groff)
24 #:use-module (guix licenses)
25 #:use-module (guix packages)
26 #:use-module (guix utils)
27 #:use-module (guix download)
28 #:use-module (guix git-download)
29 #:use-module (guix build-system gnu)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages bison)
32 #:use-module (gnu packages ghostscript)
33 #:use-module (gnu packages netpbm)
34 #:use-module (gnu packages perl)
35 #:use-module (gnu packages texinfo))
36
37 (define-public groff
38 (package
39 (name "groff")
40 (version "1.22.4")
41 (source (origin
42 (method url-fetch)
43 (uri (string-append "mirror://gnu/groff/groff-" version
44 ".tar.gz"))
45 (sha256 (base32
46 "14q2mldnr1vx0l9lqp9v2f6iww24gj28iyh4j2211hyynx67p3p7"))))
47 (build-system gnu-build-system)
48 (outputs '("out"
49 "doc")) ;12MiB of PS, PDF, HTML, and examples
50
51 ;; Note: groff's HTML backend uses executables from netpbm when they are in
52 ;; $PATH. In practice, not having them doesn't prevent it from install its
53 ;; own HTML doc, nor does it change its capabilities, so we removed netpbm
54 ;; from 'inputs'.
55
56 (inputs `(("ghostscript" ,ghostscript)))
57 (native-inputs `(("bison" ,bison)
58 ("perl" ,perl)
59 ("psutils" ,psutils)
60 ("texinfo" ,texinfo)))
61 (arguments
62 `(#:parallel-build? #f ; parallel build fails
63 #:phases
64 (modify-phases %standard-phases
65 (add-after 'unpack 'setenv
66 (lambda _
67 (setenv "GS_GENERATE_UUIDS" "0")
68 #t)))))
69 (synopsis "Typesetting from plain text mixed with formatting commands")
70 (description
71 "Groff is a typesetting package that reads plain text and produces
72 formatted output based on formatting commands contained within the text. It
73 is usually the formatter of \"man\" documentation pages.")
74 (license gpl3+)
75 (home-page "https://www.gnu.org/software/groff/")))
76
77 (define-public groff-minimal
78 ;; Minimialist groff for use by man-db. Its closure size is less than half
79 ;; that of the full-blown groff.
80 (package
81 (inherit groff)
82 (name "groff-minimal")
83 (synopsis "Minimalist variant of Groff for use by man-db")
84 (outputs '("out"))
85
86 ;; Omit the DVI, PS, PDF, and HTML backends.
87 (inputs '())
88 (native-inputs `(("bison" ,bison)
89 ("perl" ,perl)))
90
91 (arguments
92 `(#:disallowed-references (,perl)
93
94 #:configure-flags '("--with-doc=no")
95
96 ,@(substitute-keyword-arguments (package-arguments groff)
97 ((#:phases phases)
98 `(modify-phases ,phases
99 (add-after 'install 'remove-non-essential-programs
100 (lambda* (#:key outputs #:allow-other-keys)
101 ;; Keep only the programs that man-db needs at run time,
102 ;; and make sure we don't pull in Perl.
103 (let ((out (assoc-ref outputs "out"))
104 (kept '("eqn" "neqn" "pic" "tbl" "refer" "preconv"
105 "nroff" "groff" "troff" "grotty")))
106 (for-each (lambda (file)
107 (unless (member (basename file) kept)
108 (delete-file file)))
109 (find-files (string-append out "/bin")))
110
111 ;; Remove a bunch of unneeded Perl scripts.
112 (for-each delete-file (find-files out "\\.pl$"))
113 (for-each delete-file
114 (find-files out "BuildFoundries"))
115
116 ;; Remove ~3 MiB from share/groff/X.Y/font/devBACKEND
117 ;; corresponding to the unused backends.
118 (for-each delete-file-recursively
119 (find-files out "^dev(dvi|ps|pdf|html|lj4)$"
120 #:directories? #t))
121 #t))))))))))
122
123 ;; There are no releases, so we take the latest commit.
124 (define-public roffit
125 (let ((commit "e5228388e3faf2b7f1ae5bd048ad46ed565304c6")
126 (revision "1"))
127 (package
128 (name "roffit")
129 (version (string-append "0.11-" revision "." (string-take commit 9)))
130 (source (origin
131 (method git-fetch)
132 (uri (git-reference
133 (url "https://github.com/bagder/roffit.git")
134 (commit commit)))
135 (file-name (string-append "roffit-" commit "-checkout"))
136 (sha256
137 (base32
138 "1y7ndbqciy7h0khlpi1bv4v1614vhybnmm4jysj6fwxkw9cwv1nc"))))
139 (build-system gnu-build-system)
140 (arguments
141 `(#:test-target "test"
142 #:make-flags
143 (list (string-append "INSTALLDIR="
144 (assoc-ref %outputs "out") "/bin"))
145 #:phases
146 (modify-phases %standard-phases
147 (delete 'configure)
148 (add-before 'install 'pre-install
149 (lambda* (#:key outputs #:allow-other-keys)
150 (mkdir-p (string-append (assoc-ref outputs "out")
151 "/bin"))
152 #t)))))
153 (inputs
154 `(("perl" ,perl)))
155 (home-page "https://daniel.haxx.se/projects/roffit/")
156 (synopsis "Convert nroff files to HTML")
157 (description
158 "Roffit is a program that reads an nroff file and outputs an HTML file.
159 It is typically used to display man pages on a web site.")
160 (license expat))))