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