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