inkscape.scm 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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, 2021 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 "1.1.1")
  57. (source
  58. (origin
  59. (method url-fetch)
  60. (uri (string-append "https://media.inkscape.org/dl/"
  61. "resources/file/"
  62. "inkscape-" version ".tar.xz"))
  63. (sha256
  64. (base32 "1bvqg5xfs3m6r7qfdhmgzwhd1hx8wvg3nhvhmalwzcdm6ffhpjmf"))
  65. (modules '((guix build utils)
  66. (ice-9 format)))
  67. (snippet
  68. '(begin
  69. (let-syntax
  70. ;; XXX: The build system doesn't currently support using
  71. ;; system libraries over bundled ones (see:
  72. ;; https://gitlab.com/inkscape/inkscape/issues/876).
  73. ((unbundle
  74. (syntax-rules ()
  75. ((_ (name source-dir use-pkg-config?) ...)
  76. (begin
  77. ;; Delete bundled source directories.
  78. (delete-file-recursively source-dir) ...
  79. (substitute* '("src/CMakeLists.txt"
  80. "src/3rdparty/CMakeLists.txt")
  81. (((string-append ".*add_subdirectory\\("
  82. (basename source-dir) "\\).*"))
  83. "") ...)
  84. ;; Remove bundled entries from INKSCAPE_TARGET_LIBS.
  85. (substitute* "src/CMakeLists.txt"
  86. (((string-append name "_LIB.*")) "") ...)
  87. ;; Register the external libraries, so that their
  88. ;; headers are added to INKSCAPE_INCS_SYS and their
  89. ;; shared libraries added to INKSCAPE_LIBS.
  90. (if use-pkg-config?
  91. (let* ((width (string-length "pkg_check_modules("))
  92. (indent (string-join (make-list width " ") "")))
  93. (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
  94. (("^pkg_check_modules\\(INKSCAPE_DEP REQUIRED.*" start)
  95. (string-append start
  96. (format #f "~a~a~%" indent name)))))
  97. (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
  98. (("^find_package\\(Iconv REQUIRED\\).*" start)
  99. (string-append (format #f "
  100. find_path(~a_INCLUDE_DIR NAMES ~:*~a/~:*~a.h ~:*~a.h)
  101. if(NOT ~:*~a_INCLUDE_DIR)
  102. message(FATAL_ERROR \"~:*~a headers not found\")
  103. else()
  104. list(APPEND INKSCAPE_INCS_SYS ${~:*~a_INCLUDE_DIR})
  105. endif()
  106. find_library(~:*~a_LIB NAMES ~:*~a)
  107. if(NOT ~:*~a_LIB)
  108. message(FATAL_ERROR \"~:*~a library not found\")
  109. else()
  110. list(APPEND INKSCAPE_LIBS ~:*~a_LIB)
  111. endif()~%~%"
  112. name)
  113. start)))) ...
  114. ;; Fix the references to the headers of the
  115. ;; unbundled libraries.
  116. (substitute* (find-files "." "\\.h$|\\.cpp$")
  117. (((string-append "#include (\"|<)3rdparty/"
  118. (basename source-dir)) _ quote)
  119. (string-append "#include " quote
  120. (basename source-dir)))
  121. ...))))))
  122. (unbundle ("2geom" "src/3rdparty/2geom" #t)
  123. ;; libcroco cannot be unbundled as it is heavily
  124. ;; modified (see:
  125. ;; https://gitlab.com/inkscape/inkscape/issues/876#note_276114904).
  126. ;; ("croco" "src/3rdparty/libcroco" #t)
  127. ;; FIXME: Unbundle the following libraries once they
  128. ;; have been packaged.
  129. ;; ("cola" "src/3rdparty/adaptagrams/libcola")
  130. ;; ("avoid" "src/3rdparty/adaptagrams/libavoid")
  131. ;; ("vpsc" "src/3rdparty/adaptagrams/libvpsc")
  132. ;; libuemf cannot be unbundled as it slightly modified
  133. ;; from upstream (see:
  134. ;; https://gitlab.com/inkscape/inkscape/issues/973).
  135. ;; ("uemf" "src/3rdparty/libuemf" #f)
  136. ;; FIXME: libdepixelize upstream is ancient and doesn't
  137. ;; build with a recent lib2geom
  138. ;; (see: https://bugs.launchpad.net/libdepixelize/+bug/1862458).
  139. ;;("depixelize" "src/3rdparty/libdepixelize")
  140. ("autotrace" "src/3rdparty/autotrace" #t)))
  141. ;; Lift the requirement on the double-conversion library, as
  142. ;; it is only needed by lib2geom, which is now unbundled.
  143. (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
  144. ((".*find_package\\(DoubleConversion.*") ""))))))
  145. (build-system cmake-build-system)
  146. (arguments
  147. `(#:test-target "check" ;otherwise some test binaries are missing
  148. #:imported-modules (,@%cmake-build-system-modules
  149. (guix build glib-or-gtk-build-system))
  150. #:modules ((guix build cmake-build-system)
  151. ((guix build glib-or-gtk-build-system) #:prefix glib-or-gtk:)
  152. (guix build utils))
  153. #:phases
  154. (modify-phases %standard-phases
  155. (add-after 'unpack 'generate-gdk-pixbuf-loaders-cache-file
  156. (assoc-ref glib-or-gtk:%standard-phases
  157. 'generate-gdk-pixbuf-loaders-cache-file))
  158. (add-after 'unpack 'patch-icon-cache-generator
  159. (lambda _
  160. (substitute* "share/icons/application/CMakeLists.txt"
  161. (("gtk-update-icon-cache") "true"))))
  162. (add-after 'unpack 'disable-latex-export-tests
  163. ;; FIXME: For some reason the test.pdf_tex file generated by the
  164. ;; "--export-latex" lacks "some text" in its content when run in
  165. ;; the build environment. Skip the related tests.
  166. (lambda _
  167. (substitute* "testfiles/cli_tests/CMakeLists.txt"
  168. (("add_cli_test\\(export-latex")
  169. "message(TEST_DISABLED: export-latex"))))
  170. (add-after 'unpack 'set-home
  171. ;; Mute Inkscape warnings during tests.
  172. (lambda _
  173. (setenv "HOME" (getcwd))))
  174. ;; Move the check phase after the install phase, as when run in the
  175. ;; tests, Inkscape relies on files that are not yet installed, such
  176. ;; as the "share/inkscape/ui/units.xml" file.
  177. (delete 'check)
  178. (add-after 'install 'check
  179. (assoc-ref %standard-phases 'check))
  180. (add-after 'install 'glib-or-gtk-compile-schemas
  181. (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
  182. (add-after 'glib-or-gtk-compile-schemas 'glib-or-gtk-wrap
  183. (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap))
  184. (add-after 'install 'wrap-program
  185. ;; Ensure Python is available at runtime.
  186. (lambda* (#:key outputs #:allow-other-keys)
  187. (let ((out (assoc-ref outputs "out")))
  188. (wrap-program (string-append out "/bin/inkscape")
  189. `("GUIX_PYTHONPATH" ":" prefix
  190. (,(getenv "GUIX_PYTHONPATH"))))))))))
  191. (inputs
  192. `(("aspell" ,aspell)
  193. ("autotrace" ,autotrace)
  194. ("gdl" ,gdl-minimal)
  195. ("gtkmm" ,gtkmm-3)
  196. ("gtk" ,gtk+)
  197. ("gtkspell3" ,gtkspell3)
  198. ("gsl" ,gsl)
  199. ("poppler" ,poppler)
  200. ("lib2geom" ,lib2geom)
  201. ("libjpeg" ,libjpeg-turbo)
  202. ("libpng" ,libpng)
  203. ("libxml2" ,libxml2)
  204. ("libxslt" ,libxslt)
  205. ("libgc" ,libgc)
  206. ("libsoup" ,libsoup-minimal-2)
  207. ("libcdr" ,libcdr)
  208. ("libvisio" ,libvisio)
  209. ("libwpd" ,libwpd)
  210. ("libwpg" ,libwpg)
  211. ("freetype" ,freetype)
  212. ("popt" ,popt)
  213. ("potrace" ,potrace)
  214. ("lcms" ,lcms)
  215. ("boost" ,boost)
  216. ("python" ,python-wrapper)
  217. ("python-scour" ,python-scour)
  218. ("python-pyserial" ,python-pyserial)
  219. ("python-numpy" ,python-numpy)
  220. ("python-lxml" ,python-lxml)))
  221. (native-inputs
  222. (list imagemagick ;for tests
  223. intltool
  224. `(,glib "bin")
  225. googletest
  226. perl
  227. pkg-config))
  228. (home-page "https://inkscape.org/")
  229. (synopsis "Vector graphics editor")
  230. (description "Inkscape is a vector graphics editor. What sets Inkscape
  231. apart is its use of Scalable Vector Graphics (SVG), an XML-based W3C standard,
  232. as the native format.")
  233. (license license:gpl3+))) ;see the file COPYING