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