1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
| | ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2014, 2015, 2016, 2017 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2013, 2015, 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Alex Vong <alexvong1995@gmail.com>
;;; Copyright © 2017, 2018, 2019, 2021, 2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2018, 2020, 2022 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2020, 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2024 David Elsing <david.elsing@posteo.net>
;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu packages ghostscript)
#:use-module (gnu packages)
#:use-module (gnu packages autotools)
#:use-module (gnu packages c)
#:use-module (gnu packages compression)
#:use-module (gnu packages cups)
#:use-module (gnu packages fontutils)
#:use-module (gnu packages image)
#:use-module (gnu packages man)
#:use-module (gnu packages perl)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
#:use-module (gnu packages tcl)
#:use-module (gnu packages xorg)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix gexp)
#:use-module (guix git-download)
#:use-module (guix utils)
#:use-module (guix build-system gnu)
#:use-module (srfi srfi-1))
(define-public lcms
(package
(name "lcms")
(version "2.13.1")
(source (origin
(method url-fetch)
(uri (string-append "mirror://sourceforge/lcms/lcms/"
(version-major+minor version)
"/lcms2-" version ".tar.gz"))
(sha256
(base32
"121v414bg2zk0fcwx0kigr2l6nxl88nmblfn3gq5lz5jwybffwyl"))))
(build-system gnu-build-system)
(arguments
'(#:configure-flags '("--disable-static")))
(inputs
(list libjpeg-turbo libtiff zlib))
(synopsis "Little CMS, a small-footprint colour management engine")
(description
"Little CMS is a small-footprint colour management engine, with special
focus on accuracy and performance. It uses the International Color
Consortium standard (ICC), approved as ISO 15076-1.")
(license license:x11)
(home-page "https://www.littlecms.com/")
(properties '((cpe-name . "little_cms_color_engine")))))
;; Fork of LCMS 2 for Ghostscript and MuPDF
(define-public lcms2mt
(package
(inherit lcms)
(name "lcms2mt")
(version "2.16")
(source
(origin
(method git-fetch)
(uri (git-reference
(url "git://git.ghostscript.com/thirdparty-lcms2")
(commit (string-append "lcms" version))))
(file-name (git-file-name name version))
(sha256
(base32 "0dxpq59r1w3r1391fngpvka51r16505zmr32zjs2azjlrz49k3x4"))))
(synopsis "Little CMS, a small-footprint colour management engine
(GhostScript fork)")
(home-page "https://www.ghostscript.com/")))
(define-public extract
(package
(name "extract")
(version "10.03.0")
(source (origin
(method git-fetch)
(uri (git-reference
(url "git://git.ghostscript.com/extract.git")
(commit (string-append "ghostpdl-" version))))
(file-name (git-file-name name version))
(sha256
(base32
"17mb96xpsbr26q2l3kahmi3f1mcqzn7n1q1783f40155lrkk88q9"))
(snippet
'(for-each
delete-file
'("src/docx_template.c" "src/docx_template.h"
"src/odt_template.c" "src/odt_template.h"
"src/memento.h" "src/memento.c")))
(patches (search-patches "extract-shared-library.patch"))))
(build-system gnu-build-system)
(arguments
(list
#:test-target "test"
#:make-flags
`(list
"build=debug-opt"
"flags_compile=-MMD -MP -Iinclude -Isrc -fPIC"
(string-append "CC=" ,(cc-for-target))
(string-append "CXX=" ,(cxx-for-target)))
#:phases
#~(modify-phases %standard-phases
(delete 'configure) ; no configure script
(replace 'install
(lambda _
(install-file "libextract.so" (string-append #$output "/lib"))
(copy-recursively
"include" (string-append #$output "/include")))))))
(inputs (list memento zlib))
(native-inputs (list python unzip))
(home-page "https://git.ghostscript.com/?p=extract.git")
(synopsis "Document content extraction library")
(description "extract is a library for exstracting dox, odt, html and text
files from documents.")
(license license:agpl3+)))
(define-public libpaper
(package
(name "libpaper")
(version "2.0.0")
(source (origin
(method url-fetch)
(uri (string-append "https://github.com/rrthomas/libpaper/releases"
"/download/v" version "/libpaper-"
version ".tar.gz"))
(sha256
(base32
"0aipyaqp30cn919j7w5wvlgkw0v4aqsax82i2zw4wmgck8g6ax77"))))
(build-system gnu-build-system)
(native-inputs
(list help2man))
(arguments
(list #:configure-flags ''("--disable-static"
;; Tests require a relocatable build.
"--enable-relocatable")
;; --enable-relocate is broken on the Hurd
#:tests? (not (or (target-hurd?)
(%current-target-system)))))
(outputs '("out" "debug"))
(home-page "https://github.com/rrthomas/libpaper")
(synopsis "Library for handling paper sizes")
(description
"The paper library and accompanying files are intended to provide a simple
way for applications to take actions based on a system- or user-specified
paper size.")
;; The library is LGPL3+, everything else GPL3+.
(license (list license:lgpl3+ license:gpl3+))))
(define-public psutils
(package
(name "psutils")
(version "2.09")
(source (origin
(method url-fetch)
(uri (string-append "https://github.com/rrthomas/psutils/releases"
"/download/v" version "/psutils-"
version ".tar.gz"))
(sha256
(base32
"1nmp0hb7c4a315vv1mqw2cbckvca8bzh1cv3gdvwwy24w9qba6p3"))))
(build-system gnu-build-system)
(inputs (list perl))
(native-inputs
(list libpaper))
(arguments
(list #:tests? #f ;FIXME: requires files not present in tarball
#:configure-flags
;; Help the build system locate Perl when cross-compiling.
(if (%current-target-system)
#~(list (string-append "ac_cv_path_PERL="
(search-input-file %build-inputs "bin/perl")))
#~'())))
(synopsis "Collection of utilities for manipulating PostScript documents")
(description
"PSUtils is a collection of utilities for manipulating PostScript
documents. Programs included are psnup, for placing out several logical pages
on a single sheet of paper, psselect, for selecting pages from a document,
pstops, for general imposition, psbook, for signature generation for booklet
printing, and psresize, for adjusting page sizes.")
(home-page "https://github.com/rrthomas/psutils")
(license (list license:gpl3+
;; This file carries the "historical" psutils license (v1),
;; which is "effectively BSD 3-clause" (a quote from the file).
(license:non-copyleft
"file://extractres.in.in"
"See extractres.in.in in the distribution.")))))
(define-public ghostscript
(package
(name "ghostscript")
(version "10.03.1")
(source
(origin
(method git-fetch)
(uri (git-reference
(url "git://git.ghostscript.com/ghostpdl.git")
(commit (string-append "ghostpdl-" version))))
(file-name (git-file-name name version))
(sha256
(base32
"1rzgk12vmv3062l8w7vw5kdsgfphmpwbq38alv2qgiz5wpalsrds"))
(patches (search-patches "ghostscript-reproducibility.patch"))
(modules '((guix build utils)))
(snippet
'(begin
(for-each
delete-file-recursively
(append
(list
;; Bundled software (some non-free)
"cups" "expat" "freetype" "ijs" "jbig2dec" "jpeg" "jpegxr"
"lcms2mt" "libpng" "openjpeg" "pcl" "tiff" "xps" "zlib"
;; Non-free ICC profile
"doc/language-bindings/images"
;; Contain autogenerated files
"demos/csharp/windows"
"toolbin/Acrobat2Tiff"
"base/scfdtab.c"
"demos/java/jni/gs_jni/com_artifex_gsjava_util_NativePointer.h"
"demos/java/jni/gs_jni/com_artifex_gsjava_GSAPI.h"
"doc/GS9_Color_Management.pdf"
"doc/Ghostscript.pdf"
"doc/pclxps/ghostpdl.pdf")
(find-files "doc/src/_static" "cm-fig.*\\.png")))
(for-each
(lambda (name)
(delete-file (string-append "arch/" name)))
'("osx-x86-x86_64-ppc-gcc.h"
"windows-arm-msvc.h"
"windows-x64-msvc.h"
"windows-x86-msvc.h"))
(delete-file "base/memento.c")
(delete-file "base/memento.h")))))
(build-system gnu-build-system)
(arguments
(list
#:configure-flags
#~(list (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib")
"--with-system-libtiff"
;; Requires jpegxr, which has a nonfree license.
"--without-xps"
"LIBS=-lz"
(string-append "ZLIBDIR="
(dirname (search-input-file %build-inputs
"include/zlib.h")))
"--disable-compile-inits"
(string-append "--with-fontpath="
(search-input-directory
%build-inputs
"share/fonts/type1/ghostscript"))
#$@(if (%current-target-system)
'(;; Specify the native compiler, which is used to build 'echogs'
;; and other intermediary tools when cross-compiling; see
;; <https://ghostscript.com/FAQ.html>.
"CCAUX=gcc"
;; Save 'config.log' etc. of the native build under
;; auxtmp/, useful for debugging.
"--enable-save_confaux")
'()))
#:phases
#~(modify-phases %standard-phases
(add-after 'unpack 'unbundle
(lambda _
(substitute* '("base/lib.mak" "base/tiff.mak"
"devices/dcontrib.mak" "devices/devs.mak"
"psi/int.mak")
((".*:\\$\\(GLSRC\\)memento\\.h".*) ""))
(substitute* "base/lib.mak"
((" \\$\\(GLOBJ\\)memento\\.\\$\\(OBJ\\)") ""))))
(add-before 'bootstrap 'patch-autogen
(lambda _
(substitute* "autogen.sh"
(("^autoreconf.*" orig)
(string-append orig "\nexit\n")))))
(add-before 'configure 'create-output-directory
(lambda _
;; The configure script refuses to function if the directory
;; specified as -rpath does not already exist.
(mkdir-p (string-append #$output "/lib"))))
(add-after 'configure 'remove-doc-reference
(lambda _
;; The only use of this definition is in the output of
;; 'gs --help', so this change is fine.
(substitute* "base/gscdef.c"
(("GS_DOCDIR")
"\"~/.guix-profile/share/doc/ghostscript\""))))
(add-after 'configure 'patch-config-files
(lambda _
(substitute* "base/unixhead.mak"
(("/bin/sh") (which "sh")))))
#$@(if (%current-target-system)
'((add-after 'configure 'add-native-lz
(lambda _
;; Add missing '-lz' for native tools such as 'mkromfs'.
(substitute* "Makefile"
(("^AUXEXTRALIBS=(.*)$" _ value)
(string-append "AUXEXTRALIBS = -lz " value "\n"))))))
'())
(add-before 'build 'generate-scfdtab
(lambda _
(invoke "make" "obj/arch.h")
;; These changes are necessary for cross builds, where there can
;; be a conflict for int64_t.
(with-directory-excursion "base"
(copy-file "scommon.h" "tmpfile")
(substitute* "scommon.h"
((".*#include \"stdint_\\.h\".*") ""))
(let ((include-path (getenv "C_INCLUDE_PATH")))
;; For cross builds
(setenv "C_INCLUDE_PATH"
(string-append #$(this-package-input "memento")
"/include"))
(invoke "gcc" "-Dfopen=fopen" "-I../obj"
"scfdgen.c" "scfetab.c" "-o" "scfdgen")
(setenv "C_INCLUDE_PATH" include-path))
(rename-file "tmpfile" "scommon.h")
(invoke "./scfdgen"))))
(replace 'build
(lambda _
;; Build 'libgs.so', but don't build the statically-linked 'gs'
;; binary (saves 22 MiB).
(invoke "make" "so" "-j"
(number->string (parallel-job-count)))))
(replace 'install
(lambda _
(invoke "make" "soinstall")))
(add-after 'install 'create-gs-symlink
(lambda _
;; Some programs depend on having a 'gs' binary available.
(symlink "gsc" (string-append #$output "/bin/gs")))))))
(native-inputs
(append
(list autoconf
automake
perl
pkg-config ;needed for freetype
python-minimal-wrapper
tcl)
;; When cross-compiling, some of the natively-built tools require all
;; these libraries.
(if (%current-target-system)
(list zlib libjpeg-turbo)
'())))
(inputs
(list extract
fontconfig
freetype
font-ghostscript
ijs
jbig2dec
lcms2mt
libjpeg-turbo
libpaper
libpng
libtiff
memento
openjpeg
zlib))
(synopsis "PostScript and PDF interpreter")
(description
"Ghostscript is an interpreter for the PostScript language and the PDF
file format. It also includes a C library that implements the graphics
capabilities of the PostScript language. It supports a wide variety of
output file formats and printers.")
(home-page "https://www.ghostscript.com/")
(license
(list
;; Most of the code is distributed under the AGPLv3+.
license:agpl3+
;; Some files (or parts of files) are distributed under other,
;; compatible licenses.
(license:non-copyleft "file://devices/gdev4693.c")
(license:non-copyleft "file://devices/gdevifno.c")
(license:non-copyleft "file://base/icc34.h")
(license:non-copyleft "file://base/CMap/78-EUC-H")
license:asl2.0
license:bsd-3
license:expat
license:freetype
license:gpl1+
license:gpl2+
license:isc
license:lgpl2.1
license:public-domain
license:zlib
;; Additional exception for the font files in Resource/Font for
;; inclusion in Postscript and PDF files.
(license:non-copyleft "file://LICENSE")))))
(define-public ghostscript/x
(package/inherit ghostscript
(name (string-append (package-name ghostscript) "-with-x"))
(inputs (modify-inputs (package-inputs ghostscript)
(prepend libxext libxt)))))
(define-public ghostscript/cups
(package/inherit ghostscript
(name "ghostscript-with-cups")
(inputs (modify-inputs (package-inputs ghostscript)
(prepend cups-minimal)))))
(define-public ijs
(package
(name "ijs")
(version (package-version ghostscript))
(source
(origin
(inherit
(package-source ghostscript))
(modules '((guix build utils)
(srfi srfi-1)
(ice-9 ftw)))
(snippet
'(begin
(for-each delete-file-recursively
(lset-difference equal? (scandir ".")
'("." ".." "ijs")))
(chdir "ijs")
(for-each
delete-file
'("compile"
"config.guess"
"config.sub"
"configure"
"ijs_spec.pdf"
"ijs_spec.ps"
"install-sh"
"libtool"
"ltmain.sh"
"Makefile.in"
"missing"
"state.eps"
"state.fig"))))
(patches '())))
(build-system gnu-build-system)
(native-inputs
(append (if (target-riscv64?)
(list config)
'())
(list libtool automake autoconf)))
(arguments
`(#:phases
(modify-phases %standard-phases
(add-after 'unpack 'prepare
(lambda _
(chdir "ijs")
;; do not run configure
(substitute* "autogen.sh"
(("^.*\\$srcdir/configure.*") "")
(("^ + && echo Now type.*$") ""))
(substitute* "configure.ac"
(("AC_DISABLE_SHARED") ""))))
,@(if (target-riscv64?)
`((add-after 'unpack 'update-config-scripts
(lambda* (#:key native-inputs inputs #:allow-other-keys)
(for-each (lambda (file)
(install-file
(search-input-file
(or native-inputs inputs)
(string-append "/bin/" file)) "ijs"))
'("config.guess" "config.sub")))))
'()))))
(synopsis "IJS driver framework for inkjet and other raster devices")
(description
"IJS is a protocol for transmission of raster page images. This package
provides the reference implementation of the raster printer driver
architecture.")
(license license:expat)
(home-page (package-home-page ghostscript))))
(define-public font-ghostscript
(package
(name "font-ghostscript")
(version "8.11")
(source (origin
(method url-fetch)
(uri (string-append "mirror://sourceforge/gs-fonts/gs-fonts/"
version
"%20%28base%2035%2C%20GPL%29/ghostscript-fonts-std-"
version
".tar.gz"))
(sha256 (base32
"00f4l10xd826kak51wsmaz69szzm2wp8a41jasr4jblz25bg7dhf"))))
(build-system gnu-build-system)
(arguments
`(#:tests? #f ; nothing to check, just files to copy
#:modules ((guix build gnu-build-system)
(guix build utils)
(srfi srfi-1))
#:phases
(modify-phases %standard-phases
(delete 'configure)
(delete 'build)
(replace 'install
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(dir (string-append out "/share/fonts/type1/ghostscript")))
(mkdir-p dir)
(for-each
(lambda (file)
(copy-file file (string-append dir "/" file)))
(find-files "." "pfb|afm"))
#t))))))
(synopsis "Free replacements for the PostScript fonts")
(description
"Ghostscript fonts provides fonts and font metrics customarily distributed with
Ghostscript. It currently includes the 35 standard PostScript fonts.")
(license license:gpl2)
(home-page "https://sourceforge.net/projects/gs-fonts/")))
(define-public gs-fonts
(deprecated-package "gs-fonts" font-ghostscript))
(define-public libspectre
(package
(name "libspectre")
(version "0.2.10")
(source (origin
(method url-fetch)
(uri (string-append "https://libspectre.freedesktop.org/releases"
"/libspectre-" version ".tar.gz"))
(sha256
(base32
"01sdaakrv5js8r6gj2r1ankyl304161z060f25mrmz3b1ylb4q6g"))))
(build-system gnu-build-system)
(inputs (list ghostscript))
(native-inputs (list pkg-config))
(synopsis "Postscript rendering library")
(description
"libspectre is a small library for rendering Postscript documents.
It provides a convenient easy to use API for handling and rendering
Postscript documents.")
(license license:gpl2+)
(home-page "https://www.freedesktop.org/wiki/Software/libspectre")))
|