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 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-8" ,libjpeg-8)
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.22")
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 "1fyi4yvdj39bjgs10klr31cda1fbx1ar7a7b7yz7v68gykk65y61"))
146 (patches (search-patches "ghostscript-runpath.patch"
147 "ghostscript-no-header-creationdate.patch"
148 "ghostscript-no-header-id.patch"
149 "ghostscript-no-header-uuid.patch"))
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"
158 "tiff" "zlib"))
159 #t))))
160 (build-system gnu-build-system)
161 (outputs '("out" "doc")) ;19 MiB of HTML/PS doc + examples
162 (arguments
163 `(#:disallowed-references ("doc")
164 #:configure-flags
165 (list "--with-system-libtiff"
166 "LIBS=-lz"
167 (string-append "ZLIBDIR="
168 (assoc-ref %build-inputs "zlib") "/include")
169 "--enable-dynamic"
170
171 ,@(if (%current-target-system)
172 '(;; Specify the native compiler, which is used to build 'echogs'
173 ;; and other intermediary tools when cross-compiling; see
174 ;; <https://ghostscript.com/FAQ.html>.
175 "CCAUX=gcc"
176
177 ;; Save 'config.log' etc. of the native build under
178 ;; auxtmp/, useful for debugging.
179 "--enable-save_confaux")
180 '()))
181 #:phases
182 (modify-phases %standard-phases
183 (add-after 'unpack 'fix-doc-dir
184 (lambda _
185 ;; Honor --docdir.
186 (substitute* "Makefile.in"
187 (("^docdir=.*$") "docdir = @docdir@\n")
188 (("^exdir=.*$") "exdir = $(docdir)/examples\n"))
189 #t))
190 (add-after 'configure 'remove-doc-reference
191 (lambda _
192 ;; Don't retain a reference to the 'doc' output in 'gs'.
193 ;; The only use of this definition is in the output of
194 ;; 'gs --help', so this change is fine.
195 (substitute* "base/gscdef.c"
196 (("GS_DOCDIR")
197 "\"~/.guix-profile/share/doc/ghostscript\""))
198 #t))
199 (add-after 'configure 'patch-config-files
200 (lambda _
201 (substitute* "base/unixhead.mak"
202 (("/bin/sh") (which "sh")))
203 #t))
204 ,@(if (%current-target-system)
205 `((add-after 'configure 'add-native-lz
206 (lambda _
207 ;; Add missing '-lz' for native tools such as 'mkromfs'.
208 (substitute* "Makefile"
209 (("^AUXEXTRALIBS=(.*)$" _ value)
210 (string-append "AUXEXTRALIBS = -lz " value "\n")))
211 #t)))
212 '())
213 (replace 'build
214 (lambda _
215 ;; Build 'libgs.so', but don't build the statically-linked 'gs'
216 ;; binary (saves 22 MiB).
217 (zero? (system* "make" "so" "-j"
218 (number->string (parallel-job-count))))))
219 (replace 'install
220 (lambda _
221 (zero? (system* "make" "soinstall"))))
222 (add-after 'install 'create-gs-symlink
223 (lambda* (#:key outputs #:allow-other-keys)
224 (let ((out (assoc-ref outputs "out")))
225 ;; Some programs depend on having a 'gs' binary available.
226 (symlink "gsc" (string-append out "/bin/gs"))
227 #t))))))
228 (native-inputs
229 `(("perl" ,perl)
230 ("python" ,python-wrapper)
231 ("tcl" ,tcl)
232
233 ;; When cross-compiling, some of the natively-built tools require all
234 ;; these libraries.
235 ,@(if (%current-target-system)
236 `(("zlib/native" ,zlib)
237 ("libjpeg/native" ,libjpeg)
238 ("lcms2/native" ,lcms))
239 '())))
240 (inputs
241 `(("freetype" ,freetype)
242 ("jbig2dec" ,jbig2dec)
243 ("lcms2" ,lcms)
244 ("libjpeg" ,libjpeg)
245 ("libpaper" ,libpaper)
246 ("libpng" ,libpng)
247 ("libtiff" ,libtiff)
248 ("zlib" ,zlib)))
249 (synopsis "PostScript and PDF interpreter")
250 (description
251 "Ghostscript is an interpreter for the PostScript language and the PDF
252 file format. It also includes a C library that implements the graphics
253 capabilities of the PostScript language. It supports a wide variety of
254 output file formats and printers.")
255 (home-page "https://www.ghostscript.com/")
256 (license license:agpl3+)))
257
258 (define-public ghostscript/x
259 (package/inherit ghostscript
260 (name (string-append (package-name ghostscript) "-with-x"))
261 (inputs `(("libxext" ,libxext)
262 ("libxt" ,libxt)
263 ,@(package-inputs ghostscript)))))
264
265 (define-public ghostscript/cups
266 (package/inherit ghostscript
267 (name "ghostscript-with-cups")
268 (inputs `(("cups" ,cups-minimal)
269 ,@(package-inputs ghostscript)))))
270
271 (define-public ijs
272 (package
273 (name "ijs")
274 (version (package-version ghostscript))
275 (source (package-source ghostscript))
276 (build-system gnu-build-system)
277 (native-inputs
278 `(("libtool" ,libtool)
279 ("automake" ,automake)
280 ("autoconf" ,autoconf)))
281 (arguments
282 `(#:phases
283 (modify-phases %standard-phases
284 (add-after 'unpack 'autogen
285 (lambda _
286 ;; need to regenerate macros
287 (system* "autoreconf" "-if")
288 ;; do not run configure
289 (substitute* "autogen.sh"
290 (("^.*\\$srcdir/configure.*") ""))
291 (system* "bash" "autogen.sh")
292 ;; create configure script in ./ijs/
293 (chdir "ijs")
294 ;; do not run configure
295 (substitute* "autogen.sh"
296 (("^.*\\$srcdir/configure.*") "")
297 (("^ + && echo Now type.*$") ""))
298 (zero? (system* "bash" "autogen.sh")))))))
299 (synopsis "IJS driver framework for inkjet and other raster devices")
300 (description
301 "IJS is a protocol for transmission of raster page images. This package
302 provides the reference implementation of the raster printer driver
303 architecture.")
304 (license license:expat)
305 (home-page (package-home-page ghostscript))))
306
307 (define-public gs-fonts
308 (package
309 (name "gs-fonts")
310 (version "8.11")
311 (source (origin
312 (method url-fetch)
313 (uri (string-append "mirror://sourceforge/gs-fonts/gs-fonts/"
314 version
315 "%20%28base%2035%2C%20GPL%29/ghostscript-fonts-std-"
316 version
317 ".tar.gz"))
318 (sha256 (base32
319 "00f4l10xd826kak51wsmaz69szzm2wp8a41jasr4jblz25bg7dhf"))))
320 (build-system gnu-build-system)
321 (arguments
322 `(#:tests? #f ; nothing to check, just files to copy
323
324 #:modules ((guix build gnu-build-system)
325 (guix build utils)
326 (srfi srfi-1))
327 #:phases
328 (modify-phases %standard-phases
329 (delete 'configure)
330 (delete 'build)
331 (replace 'install
332 (lambda* (#:key outputs #:allow-other-keys)
333 (let* ((out (assoc-ref outputs "out"))
334 (dir (string-append out "/share/fonts/type1/ghostscript")))
335 (mkdir-p dir)
336 (for-each
337 (lambda (file)
338 (copy-file file (string-append dir "/" file)))
339 (find-files "." "pfb|afm"))
340 #t))))))
341 (synopsis "Free replacements for the PostScript fonts")
342 (description
343 "Ghostscript fonts provides fonts and font metrics customarily distributed with
344 Ghostscript. It currently includes the 35 standard PostScript fonts.")
345 (license license:gpl2)
346 (home-page "https://sourceforge.net/projects/gs-fonts/")))
347
348 (define-public libspectre
349 (package
350 (name "libspectre")
351 (version "0.2.8")
352 (source (origin
353 (method url-fetch)
354 (uri (string-append "https://libspectre.freedesktop.org/releases/libspectre-"
355 version ".tar.gz"))
356 (sha256 (base32
357 "1a67iglsc3r05mzngyg9kb1gy8whq4fgsnyjwi7bqfw2i7rnl9b5"))))
358 (build-system gnu-build-system)
359 (inputs `(("ghostscript" ,ghostscript)))
360 (native-inputs `(("pkg-config" ,pkg-config)))
361 (synopsis "Postscript rendering library")
362 (description
363 "libspectre is a small library for rendering Postscript documents.
364 It provides a convenient easy to use API for handling and rendering
365 Postscript documents.")
366 (license license:gpl2+)
367 (home-page "https://www.freedesktop.org/wiki/Software/libspectre")))