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