inkscape.scm 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2014 John Darrington <jmd@gnu.org>
  3. ;;; Copyright © 2014, 2016 Mark H Weaver <mhw@netris.org>
  4. ;;; Copyright © 2016, 2018 Ricardo Wurmus <rekado@elephly.net>
  5. ;;; Copyright © 2017, 2020 Marius Bakke <mbakke@fastmail.com>
  6. ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
  7. ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  8. ;;; Copyright © 2020 Boris A. Dekshteyn <boris.dekshteyn@gmail.com>
  9. ;;; Copyright © 2020 Ekaitz Zarraga <ekaitz@elenq.tech>
  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. (define-module (gnu packages inkscape)
  26. #:use-module ((guix licenses) #:prefix license:)
  27. #:use-module (guix packages)
  28. #:use-module (guix download)
  29. #:use-module (guix utils)
  30. #:use-module (guix build-system cmake)
  31. #:use-module (gnu packages)
  32. #:use-module (gnu packages aspell)
  33. #:use-module (gnu packages bdw-gc)
  34. #:use-module (gnu packages boost)
  35. #:use-module (gnu packages check)
  36. #:use-module (gnu packages glib)
  37. #:use-module (gnu packages gnome)
  38. #:use-module (gnu packages graphics)
  39. #:use-module (gnu packages gtk)
  40. #:use-module (gnu packages imagemagick)
  41. #:use-module (gnu packages libreoffice)
  42. #:use-module (gnu packages maths)
  43. #:use-module (gnu packages perl)
  44. #:use-module (gnu packages pdf)
  45. #:use-module (gnu packages popt)
  46. #:use-module (gnu packages python)
  47. #:use-module (gnu packages python-xyz)
  48. #:use-module (gnu packages xml)
  49. #:use-module (gnu packages ghostscript)
  50. #:use-module (gnu packages fontutils)
  51. #:use-module (gnu packages image)
  52. #:use-module (gnu packages pkg-config))
  53. (define-public inkscape
  54. (package
  55. (name "inkscape")
  56. (version "0.92.4")
  57. (source (origin
  58. (method url-fetch)
  59. (uri (string-append "https://media.inkscape.org/dl/"
  60. "resources/file/"
  61. "inkscape-" version ".tar.bz2"))
  62. (patches (search-patches "inkscape-poppler-0.76.patch"))
  63. (sha256
  64. (base32
  65. "0pjinhjibfsz1aywdpgpj3k23xrsszpj4a1ya5562dkv2yl2vv2p"))))
  66. (build-system cmake-build-system)
  67. (inputs
  68. `(("aspell" ,aspell)
  69. ("gtkmm" ,gtkmm-2)
  70. ("gtk" ,gtk+-2)
  71. ("gsl" ,gsl)
  72. ("poppler" ,poppler)
  73. ("libpng" ,libpng)
  74. ("libxml2" ,libxml2)
  75. ("libxslt" ,libxslt)
  76. ("libgc" ,libgc)
  77. ("freetype" ,freetype)
  78. ("popt" ,popt)
  79. ("potrace" ,potrace)
  80. ("python" ,python-wrapper)
  81. ("lcms" ,lcms)
  82. ("boost" ,boost)))
  83. (native-inputs
  84. `(("intltool" ,intltool)
  85. ("glib" ,glib "bin")
  86. ("perl" ,perl)
  87. ("pkg-config" ,pkg-config)))
  88. ;; FIXME: tests require gmock
  89. (arguments
  90. `(#:tests? #f
  91. #:phases
  92. (modify-phases %standard-phases
  93. (add-after 'unpack 'patch-icon-cache-generator
  94. (lambda _
  95. (substitute* "share/icons/application/CMakeLists.txt"
  96. (("gtk-update-icon-cache") "true"))
  97. #t))
  98. (add-after 'unpack 'adjust-for-new-poppler
  99. (lambda _
  100. (substitute* (find-files "src/extension/internal/pdfinput")
  101. ;; Needed for Poppler 0.82.
  102. (("Unicode \\*u") "Unicode const *u")
  103. ;; Needed for Poppler 0.83.
  104. (("\\(GfxPath") "(const GfxPath")
  105. (("GfxSubpath") "const GfxSubpath")
  106. (("new GlobalParams\\(\\)")
  107. "std::unique_ptr<GlobalParams>(new GlobalParams())")
  108. (("new GlobalParams\\(poppler_datadir\\)")
  109. "std::unique_ptr<GlobalParams>(new GlobalParams(poppler_datadir))"))
  110. #t)))))
  111. (home-page "https://inkscape.org/")
  112. (synopsis "Vector graphics editor")
  113. (description "Inkscape is a vector graphics editor. What sets Inkscape
  114. apart is its use of Scalable Vector Graphics (SVG), an XML-based W3C standard,
  115. as the native format.")
  116. (license license:gpl2+)))
  117. (define-public inkscape-1.1
  118. (package
  119. (name "inkscape")
  120. (version "1.1")
  121. (source
  122. (origin
  123. (method url-fetch)
  124. (uri (string-append "https://media.inkscape.org/dl/"
  125. "resources/file/"
  126. "inkscape-" version ".tar.xz"))
  127. (patches (search-patches "inkscape-1.1-fix-build-witch-gcc7.5.patch"))
  128. (sha256
  129. (base32
  130. "1rlm2wqg8bgdxkdvnadh49wfp0mrbrk7d8n4vdcjyw6z7z7firki"))
  131. (modules '((guix build utils)
  132. (ice-9 format)))
  133. (snippet
  134. '(begin
  135. (let-syntax
  136. ;; XXX: The build system doesn't currently support using
  137. ;; system libraries over bundled ones (see:
  138. ;; https://gitlab.com/inkscape/inkscape/issues/876).
  139. ((unbundle
  140. (syntax-rules ()
  141. ((_ (name source-dir use-pkg-config?) ...)
  142. (begin
  143. ;; Delete bundled source directories.
  144. (delete-file-recursively source-dir) ...
  145. (substitute* '("src/CMakeLists.txt"
  146. "src/3rdparty/CMakeLists.txt")
  147. (((string-append ".*add_subdirectory\\("
  148. (basename source-dir) "\\).*"))
  149. "") ...)
  150. ;; Remove bundled entries from INKSCAPE_TARGET_LIBS.
  151. (substitute* "src/CMakeLists.txt"
  152. (((string-append name "_LIB.*")) "") ...)
  153. ;; Register the external libraries, so that their
  154. ;; headers are added to INKSCAPE_INCS_SYS and their
  155. ;; shared libraries added to INKSCAPE_LIBS.
  156. (if use-pkg-config?
  157. (let* ((width (string-length "pkg_check_modules("))
  158. (indent (string-join (make-list width " ") "")))
  159. (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
  160. (("^pkg_check_modules\\(INKSCAPE_DEP REQUIRED.*" start)
  161. (string-append start
  162. (format #f "~a~a~%" indent name)))))
  163. (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
  164. (("^find_package\\(Iconv REQUIRED\\).*" start)
  165. (string-append (format #f "
  166. find_path(~a_INCLUDE_DIR NAMES ~:*~a/~:*~a.h ~:*~a.h)
  167. if(NOT ~:*~a_INCLUDE_DIR)
  168. message(FATAL_ERROR \"~:*~a headers not found\")
  169. else()
  170. list(APPEND INKSCAPE_INCS_SYS ${~:*~a_INCLUDE_DIR})
  171. endif()
  172. find_library(~:*~a_LIB NAMES ~:*~a)
  173. if(NOT ~:*~a_LIB)
  174. message(FATAL_ERROR \"~:*~a library not found\")
  175. else()
  176. list(APPEND INKSCAPE_LIBS ~:*~a_LIB)
  177. endif()~%~%"
  178. name)
  179. start)))) ...
  180. ;; Fix the references to the headers of the
  181. ;; unbundled libraries.
  182. (substitute* (find-files "." "\\.h$|\\.cpp$")
  183. (((string-append "#include (\"|<)3rdparty/"
  184. (basename source-dir)) _ quote)
  185. (string-append "#include " quote
  186. (basename source-dir)))
  187. ...))))))
  188. (unbundle ("2geom" "src/3rdparty/2geom" #t)
  189. ;; libcroco cannot be unbundled as it is heavily
  190. ;; modified (see:
  191. ;; https://gitlab.com/inkscape/inkscape/issues/876#note_276114904).
  192. ;; ("croco" "src/3rdparty/libcroco" #t)
  193. ;; FIXME: Unbundle the following libraries once they
  194. ;; have been packaged.
  195. ;; ("cola" "src/3rdparty/adaptagrams/libcola")
  196. ;; ("avoid" "src/3rdparty/adaptagrams/libavoid")
  197. ;; ("vpsc" "src/3rdparty/adaptagrams/libvpsc")
  198. ;; libuemf cannot be unbundled as it slightly modified
  199. ;; from upstream (see:
  200. ;; https://gitlab.com/inkscape/inkscape/issues/973).
  201. ;; ("uemf" "src/3rdparty/libuemf" #f)
  202. ;; FIXME: libdepixelize upstream is ancient and doesn't
  203. ;; build with a recent lib2geom
  204. ;; (see: https://bugs.launchpad.net/libdepixelize/+bug/1862458).
  205. ;;("depixelize" "src/3rdparty/libdepixelize")
  206. ("autotrace" "src/3rdparty/autotrace" #t)))
  207. ;; Lift the requirement on the double-conversion library, as
  208. ;; it is only needed by lib2geom, which is now unbundled.
  209. (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
  210. ((".*find_package\\(DoubleConversion.*") ""))
  211. #t))))
  212. (build-system cmake-build-system)
  213. (arguments
  214. `(#:tests? #t
  215. #:test-target "check" ;otherwise some test binaries are missing
  216. #:imported-modules (,@%cmake-build-system-modules
  217. (guix build glib-or-gtk-build-system))
  218. #:modules ((guix build cmake-build-system)
  219. ((guix build glib-or-gtk-build-system) #:prefix glib-or-gtk:)
  220. (guix build utils))
  221. #:phases
  222. (modify-phases %standard-phases
  223. (add-after 'unpack 'patch-icon-cache-generator
  224. (lambda _
  225. (substitute* "share/icons/application/CMakeLists.txt"
  226. (("gtk-update-icon-cache") "true"))
  227. #t))
  228. (add-after 'unpack 'disable-latex-export-tests
  229. ;; FIXME: For some reason the test.pdf_tex file generated by the
  230. ;; "--export-latex" lacks "some text" in its content when run in
  231. ;; the build environment. Skip the related tests.
  232. (lambda _
  233. (substitute* "testfiles/cli_tests/CMakeLists.txt"
  234. (("add_cli_test\\(export-latex")
  235. "message(TEST_DISABLED: export-latex"))
  236. #t))
  237. (add-after 'unpack 'set-home
  238. ;; Mute Inkscape warnings during tests.
  239. (lambda _
  240. (setenv "HOME" (getcwd))
  241. (format #t "ARGS is set to: ~a" (getenv "ARGS"))
  242. #t))
  243. ;; Move the check phase after the install phase, as when run in the
  244. ;; tests, Inkscape relies on files that are not yet installed, such
  245. ;; as the "share/inkscape/ui/units.xml" file.
  246. (delete 'check)
  247. (add-after 'install 'check
  248. (assoc-ref %standard-phases 'check))
  249. (add-after 'install 'glib-or-gtk-compile-schemas
  250. (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
  251. (add-after 'glib-or-gtk-compile-schemas 'glib-or-gtk-wrap
  252. (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap))
  253. (add-after 'install 'wrap-program
  254. ;; Ensure Python is available at runtime.
  255. (lambda* (#:key outputs #:allow-other-keys)
  256. (let ((out (assoc-ref outputs "out")))
  257. (wrap-program (string-append out "/bin/inkscape")
  258. `("GUIX_PYTHONPATH" ":" prefix (,(getenv "GUIX_PYTHONPATH")))))
  259. #t)))))
  260. (inputs
  261. `(("aspell" ,aspell)
  262. ("autotrace" ,autotrace)
  263. ("gdl" ,gdl-minimal)
  264. ("gtkmm" ,gtkmm-3)
  265. ("gtk" ,gtk+)
  266. ("gtkspell3" ,gtkspell3)
  267. ("gsl" ,gsl)
  268. ("poppler" ,poppler)
  269. ("lib2geom" ,lib2geom)
  270. ("libjpeg" ,libjpeg-turbo)
  271. ("libpng" ,libpng)
  272. ("libxml2" ,libxml2)
  273. ("libxslt" ,libxslt)
  274. ("libgc" ,libgc)
  275. ("libsoup" ,libsoup-minimal)
  276. ("libcdr" ,libcdr)
  277. ("libvisio" ,libvisio)
  278. ("libwpd" ,libwpd)
  279. ("libwpg" ,libwpg)
  280. ("freetype" ,freetype)
  281. ("popt" ,popt)
  282. ("potrace" ,potrace)
  283. ("lcms" ,lcms)
  284. ("boost" ,boost)
  285. ("python" ,python-wrapper)
  286. ("python-scour" ,python-scour)
  287. ("python-pyserial" ,python-pyserial)
  288. ("python-numpy" ,python-numpy)
  289. ("python-lxml" ,python-lxml)))
  290. (native-inputs
  291. `(("imagemagick" ,imagemagick) ;for tests
  292. ("intltool" ,intltool)
  293. ("glib" ,glib "bin")
  294. ("googletest" ,googletest)
  295. ("perl" ,perl)
  296. ("pkg-config" ,pkg-config)))
  297. (home-page "https://inkscape.org/")
  298. (synopsis "Vector graphics editor")
  299. (description "Inkscape is a vector graphics editor. What sets Inkscape
  300. apart is its use of Scalable Vector Graphics (SVG), an XML-based W3C standard,
  301. as the native format.")
  302. (license license:gpl3+))) ;see the file COPYING