gnu: Add texlive-generic-xstring.
[jackhill/guix/guix.git] / gnu / packages / ghostscript.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2014, 2015, 2016, 2017 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
5 ;;; Copyright © 2013, 2015, 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
6 ;;; Copyright © 2017 Alex Vong <alexvong1995@gmail.com>
7 ;;; Copyright © 2017, 2018, 2019, 2021 Efraim Flashner <efraim@flashner.co.il>
8 ;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
9 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
10 ;;; Copyright © 2018, 2020 Marius Bakke <mbakke@fastmail.com>
11 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
12 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
13 ;;;
14 ;;; This file is part of GNU Guix.
15 ;;;
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
20 ;;;
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
25 ;;;
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29 (define-module (gnu packages ghostscript)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages autotools)
32 #:use-module (gnu packages compression)
33 #:use-module (gnu packages cups)
34 #:use-module (gnu packages fontutils)
35 #:use-module (gnu packages image)
36 #:use-module (gnu packages perl)
37 #:use-module (gnu packages pkg-config)
38 #:use-module (gnu packages python)
39 #:use-module (gnu packages tcl)
40 #:use-module (gnu packages xorg)
41 #:use-module ((guix licenses) #:prefix license:)
42 #:use-module (guix packages)
43 #:use-module (guix download)
44 #:use-module (guix utils)
45 #:use-module (guix build-system gnu)
46 #:use-module (guix build-system trivial)
47 #:use-module (srfi srfi-1))
48
49 (define-public lcms
50 (package
51 (name "lcms")
52 (version "2.12")
53 (source (origin
54 (method url-fetch)
55 (uri (string-append "mirror://sourceforge/lcms/lcms/" version
56 "/lcms2-" version ".tar.gz"))
57
58 (sha256 (base32
59 "1x8hzq8kw16lgjxmqpnqah1p3hrqqhjpcl1ymiah8434x22kjrhq"))))
60 (build-system gnu-build-system)
61 (arguments
62 `(#:configure-flags '("--disable-static")))
63 (inputs `(("libjpeg" ,libjpeg-turbo)
64 ("libtiff" ,libtiff)
65 ("zlib" ,zlib)))
66 (synopsis "Little CMS, a small-footprint colour management engine")
67 (description
68 "Little CMS is a small-footprint colour management engine, with special
69 focus on accuracy and performance. It uses the International Color
70 Consortium standard (ICC), approved as ISO 15076-1.")
71 (license license:x11)
72 (home-page "https://www.littlecms.com/")
73 (properties '((cpe-name . "little_cms_color_engine")))))
74
75 (define-public libpaper
76 (package
77 (name "libpaper")
78 (version "1.1.24")
79 (source (origin
80 (method url-fetch)
81 (uri (string-append
82 ;; Debian moved their libpaper-1.1.24 to archive.debian.net
83 ;; but in the move the hash of their tarball changed.
84 "http://pkgs.fedoraproject.org/repo/pkgs/libpaper/libpaper_"
85 version ".tar.gz/5bc87d494ba470aba54f6d2d51471834/libpaper_"
86 version ".tar.gz"))
87 (sha256 (base32
88 "0zhcx67afb6b5r936w5jmaydj3ks8zh83n9rm5sv3m3k8q8jib1q"))))
89 (build-system gnu-build-system)
90 (native-inputs
91 (list automake)) ; For up to date 'config.guess' and 'config.sub'.
92 (arguments
93 `(#:configure-flags '("--disable-static")
94 #:phases
95 (modify-phases %standard-phases
96 (add-after 'unpack 'fix-configure
97 (lambda* (#:key inputs native-inputs #:allow-other-keys)
98 ;; Replace outdated config.sub and config.guess:
99 (for-each (lambda (file)
100 (install-file
101 (string-append (assoc-ref
102 (or native-inputs inputs) "automake")
103 "/share/automake-"
104 ,(version-major+minor
105 (package-version automake))
106 "/" file) "."))
107 '("config.sub" "config.guess"))
108 #t)))))
109 (synopsis "Library for handling paper sizes")
110 (description
111 "The paper library and accompanying files are intended to provide a simple
112 way for applications to take actions based on a system- or user-specified
113 paper size.")
114 (license license:gpl2)
115 (home-page "https://packages.qa.debian.org/libp/libpaper.html")))
116
117 (define-public psutils
118 (package
119 (name "psutils")
120 (version "17")
121 (source (origin
122 (method url-fetch)
123 (uri "ftp://ftp.knackered.org/pub/psutils/psutils.tar.gz")
124 (sha256 (base32
125 "1r4ab1fvgganm02kmm70b2r1azwzbav2am41gbigpa2bb1wynlrq"))))
126 (build-system gnu-build-system)
127 (inputs (list perl))
128 (arguments
129 `(#:tests? #f ; none provided
130 #:phases
131 (modify-phases %standard-phases
132 (replace 'configure
133 (lambda* (#:key inputs outputs #:allow-other-keys #:rest args)
134 (let ((perl (assoc-ref inputs "perl"))
135 (out (assoc-ref outputs "out")))
136 (copy-file "Makefile.unix" "Makefile")
137 (substitute* "Makefile"
138 (("/usr/local/bin/perl") (string-append perl "/bin/perl")))
139 (substitute* "Makefile"
140 (("/usr/local") out))
141 ;; for the install phase
142 (substitute* "Makefile"
143 (("-mkdir") "mkdir -p"))
144 ;; drop installation of non-free files
145 (substitute* "Makefile"
146 ((" install.include") "")))
147 #t)))))
148 (synopsis "Collection of utilities for manipulating PostScript documents")
149 (description
150 "PSUtils is a collection of utilities for manipulating PostScript
151 documents. Programs included are psnup, for placing out several logical pages
152 on a single sheet of paper, psselect, for selecting pages from a document,
153 pstops, for general imposition, psbook, for signature generation for booklet
154 printing, and psresize, for adjusting page sizes.")
155 (license (license:non-copyleft "file://LICENSE"
156 "See LICENSE in the distribution."))
157 (home-page "http://knackered.org/angus/psutils/")))
158
159 (define-public ghostscript
160 (package
161 (name "ghostscript")
162 (version "9.54.0")
163 (source
164 (origin
165 (method url-fetch)
166 (uri (string-append "https://github.com/ArtifexSoftware/"
167 "ghostpdl-downloads/releases/download/gs"
168 (string-delete #\. version)
169 "/ghostscript-" version ".tar.xz"))
170 (sha256
171 (base32
172 "0fvfvv6di5s6j4sy4gaw65klm23dby39bkdjxxq4w3v0vqyb9dy2"))
173 (patches (search-patches "ghostscript-no-header-creationdate.patch"
174 "ghostscript-no-header-id.patch"
175 "ghostscript-no-header-uuid.patch"))
176 (modules '((guix build utils)))
177 (snippet
178 ;; Remove bundled libraries. The bundled OpenJPEG is a patched fork so
179 ;; we leave it, at least for now.
180 ;; TODO Try unbundling ijs, which is developed alongside Ghostscript.
181 ;; Likewise for the thread-safe lcms2 fork called "lcms2art".
182 '(begin
183 (for-each delete-file-recursively '("freetype" "jbig2dec" "jpeg"
184 "libpng" "tiff" "zlib"))
185 #t))))
186 (build-system gnu-build-system)
187 (outputs '("out" "doc")) ;19 MiB of HTML/PS doc + examples
188 (arguments
189 `(#:disallowed-references ("doc")
190 ;; XXX: Starting with version 9.27, building the tests in parallel
191 ;; occasionally fails like this:
192 ;; In file included from ./base/memory_.h:23:0,
193 ;; from ./obj/gsmd5.h:1,
194 ;; from ./obj/gsmd5.c:56:
195 ;; ./base/std.h:25:10: fatal error: arch.h: No such file or directory
196 #:parallel-tests? #f
197 #:configure-flags
198 (list (string-append "LDFLAGS=-Wl,-rpath="
199 (assoc-ref %outputs "out") "/lib")
200 "--with-system-libtiff"
201 "LIBS=-lz"
202 (string-append "ZLIBDIR="
203 (assoc-ref %build-inputs "zlib") "/include")
204 "--enable-dynamic"
205 "--disable-compile-inits"
206 (string-append "--with-fontpath="
207 (assoc-ref %build-inputs "font-ghostscript")
208 "/share/fonts/type1/ghostscript")
209
210 ,@(if (%current-target-system)
211 '(;; Specify the native compiler, which is used to build 'echogs'
212 ;; and other intermediary tools when cross-compiling; see
213 ;; <https://ghostscript.com/FAQ.html>.
214 "CCAUX=gcc"
215
216 ;; Save 'config.log' etc. of the native build under
217 ;; auxtmp/, useful for debugging.
218 "--enable-save_confaux")
219 '()))
220 #:phases
221 (modify-phases %standard-phases
222 (add-before 'configure 'create-output-directory
223 (lambda* (#:key outputs #:allow-other-keys)
224 ;; The configure script refuses to function if the directory
225 ;; specified as -rpath does not already exist.
226 (mkdir-p (string-append (assoc-ref outputs "out") "/lib"))
227 #t))
228 (add-after 'configure 'remove-doc-reference
229 (lambda _
230 ;; Don't retain a reference to the 'doc' output in 'gs'.
231 ;; The only use of this definition is in the output of
232 ;; 'gs --help', so this change is fine.
233 (substitute* "base/gscdef.c"
234 (("GS_DOCDIR")
235 "\"~/.guix-profile/share/doc/ghostscript\""))
236 #t))
237 (add-after 'configure 'patch-config-files
238 (lambda _
239 (substitute* "base/unixhead.mak"
240 (("/bin/sh") (which "sh")))
241 #t))
242 ,@(if (%current-target-system)
243 `((add-after 'configure 'add-native-lz
244 (lambda _
245 ;; Add missing '-lz' for native tools such as 'mkromfs'.
246 (substitute* "Makefile"
247 (("^AUXEXTRALIBS=(.*)$" _ value)
248 (string-append "AUXEXTRALIBS = -lz " value "\n")))
249 #t)))
250 '())
251 (replace 'build
252 (lambda _
253 ;; Build 'libgs.so', but don't build the statically-linked 'gs'
254 ;; binary (saves 22 MiB).
255 (invoke "make" "so" "-j"
256 (number->string (parallel-job-count)))))
257 (replace 'install
258 (lambda _
259 (invoke "make" "soinstall")))
260 (add-after 'install 'create-gs-symlink
261 (lambda* (#:key outputs #:allow-other-keys)
262 (let ((out (assoc-ref outputs "out")))
263 ;; Some programs depend on having a 'gs' binary available.
264 (symlink "gsc" (string-append out "/bin/gs"))
265 #t))))))
266 (native-inputs
267 `(("perl" ,perl)
268 ("pkg-config" ,pkg-config) ;needed for freetype
269 ("python" ,python-minimal-wrapper)
270 ("tcl" ,tcl)
271
272 ;; When cross-compiling, some of the natively-built tools require all
273 ;; these libraries.
274 ,@(if (%current-target-system)
275 `(("zlib/native" ,zlib)
276 ("libjpeg/native" ,libjpeg-turbo))
277 '())))
278 (inputs
279 `(("fontconfig" ,fontconfig)
280 ("freetype" ,freetype)
281 ("font-ghostscript" ,font-ghostscript)
282 ("jbig2dec" ,jbig2dec)
283 ("libjpeg" ,libjpeg-turbo)
284 ("libpaper" ,libpaper)
285 ("libpng" ,libpng)
286 ("libtiff" ,libtiff)
287 ("zlib" ,zlib)))
288 (synopsis "PostScript and PDF interpreter")
289 (description
290 "Ghostscript is an interpreter for the PostScript language and the PDF
291 file format. It also includes a C library that implements the graphics
292 capabilities of the PostScript language. It supports a wide variety of
293 output file formats and printers.")
294 (home-page "https://www.ghostscript.com/")
295 (license license:agpl3+)))
296
297 (define-public ghostscript/x
298 (package/inherit ghostscript
299 (name (string-append (package-name ghostscript) "-with-x"))
300 (inputs `(("libxext" ,libxext)
301 ("libxt" ,libxt)
302 ,@(package-inputs ghostscript)))))
303
304 (define-public ghostscript/cups
305 (package/inherit ghostscript
306 (name "ghostscript-with-cups")
307 (inputs `(("cups" ,cups-minimal)
308 ,@(package-inputs ghostscript)))))
309
310 (define-public ijs
311 (package
312 (name "ijs")
313 (version (package-version ghostscript))
314 (source (package-source ghostscript))
315 (build-system gnu-build-system)
316 (native-inputs
317 (list libtool automake autoconf))
318 (arguments
319 `(#:phases
320 (modify-phases %standard-phases
321 (add-after 'unpack 'autogen
322 (lambda _
323 ;; need to regenerate macros
324 (system* "autoreconf" "-if")
325 ;; do not run configure
326 (substitute* "autogen.sh"
327 (("^.*\\$srcdir/configure.*") ""))
328 (system* "bash" "autogen.sh")
329 ;; create configure script in ./ijs/
330 (chdir "ijs")
331 ;; do not run configure
332 (substitute* "autogen.sh"
333 (("^.*\\$srcdir/configure.*") "")
334 (("^ + && echo Now type.*$") ""))
335 (invoke "bash" "autogen.sh"))))))
336 (synopsis "IJS driver framework for inkjet and other raster devices")
337 (description
338 "IJS is a protocol for transmission of raster page images. This package
339 provides the reference implementation of the raster printer driver
340 architecture.")
341 (license license:expat)
342 (home-page (package-home-page ghostscript))))
343
344 (define-public font-ghostscript
345 (package
346 (name "font-ghostscript")
347 (version "8.11")
348 (source (origin
349 (method url-fetch)
350 (uri (string-append "mirror://sourceforge/gs-fonts/gs-fonts/"
351 version
352 "%20%28base%2035%2C%20GPL%29/ghostscript-fonts-std-"
353 version
354 ".tar.gz"))
355 (sha256 (base32
356 "00f4l10xd826kak51wsmaz69szzm2wp8a41jasr4jblz25bg7dhf"))))
357 (build-system gnu-build-system)
358 (arguments
359 `(#:tests? #f ; nothing to check, just files to copy
360
361 #:modules ((guix build gnu-build-system)
362 (guix build utils)
363 (srfi srfi-1))
364 #:phases
365 (modify-phases %standard-phases
366 (delete 'configure)
367 (delete 'build)
368 (replace 'install
369 (lambda* (#:key outputs #:allow-other-keys)
370 (let* ((out (assoc-ref outputs "out"))
371 (dir (string-append out "/share/fonts/type1/ghostscript")))
372 (mkdir-p dir)
373 (for-each
374 (lambda (file)
375 (copy-file file (string-append dir "/" file)))
376 (find-files "." "pfb|afm"))
377 #t))))))
378 (synopsis "Free replacements for the PostScript fonts")
379 (description
380 "Ghostscript fonts provides fonts and font metrics customarily distributed with
381 Ghostscript. It currently includes the 35 standard PostScript fonts.")
382 (license license:gpl2)
383 (home-page "https://sourceforge.net/projects/gs-fonts/")))
384
385 (define-public gs-fonts
386 (deprecated-package "gs-fonts" font-ghostscript))
387
388 (define-public libspectre
389 (package
390 (name "libspectre")
391 (version "0.2.9")
392 (source (origin
393 (method url-fetch)
394 (uri (string-append "https://libspectre.freedesktop.org/releases"
395 "/libspectre-" version ".tar.gz"))
396 (sha256
397 (base32
398 "1vgvxp77d5d9chhx4i9cv9hifw4x10jgw6aw8l2v90dgnm99rbj9"))))
399 (build-system gnu-build-system)
400 (inputs (list ghostscript))
401 (native-inputs (list pkg-config))
402 (synopsis "Postscript rendering library")
403 (description
404 "libspectre is a small library for rendering Postscript documents.
405 It provides a convenient easy to use API for handling and rendering
406 Postscript documents.")
407 (license license:gpl2+)
408 (home-page "https://www.freedesktop.org/wiki/Software/libspectre")))