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