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