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