ghostscript.scm 17 KB

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