Server application for collaborative production of 3D assets and animations.
(define-module (vfx packages base)
  #:use-module (gnu packages)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages gcc)
  #:use-module (gnu packages llvm)
  #:use-module (gnu packages libffi)
  #:use-module (gnu packages boost)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages graphics)
  #:use-module (gnu packages tbb)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages jemalloc)
  #:use-module (gnu packages gl)
  #:use-module (gnu packages sdl)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages python)
  #:use-module (gnu packages pretty-print)
  #:use-module (gnu packages image)
  #:use-module (gnu packages xml)
  #:use-module (gnu packages python-xyz)
  #:use-module (gnu packages datastructures)
  #:use-module (gnu packages fontutils)
  #:use-module (gnu packages image-processing)
  #:use-module (gnu packages video)
  #:use-module (gnu packages photo)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages qt)
  #:use-module (gnu packages documentation)
  #:use-module (gnu packages serialization)
  #:use-module (gnu packages ghostscript)
  #:use-module (gnu packages check)
  #:use-module (gnu packages algebra)
  #:use-module (gnu packages bison)
  #:use-module (gnu packages flex)
  #:use-module (gnu packages xml)

  #:use-module (guix)
  #:use-module (guix packages)
  #:use-module (guix git-download)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system cmake)
  #:use-module ((guix licenses) #:prefix license:))

(define (llvm-uri component version)
  ;; LLVM release candidate file names are formatted 'tool-A.B.C-rcN/tool-A.B.CrcN.src.tar.xz'
  ;; so we specify the version as A.B.C-rcN and delete the hyphen when referencing the file name.
  (string-append "https://github.com/llvm/llvm-project/releases/download"
                 "/llvmorg-" version "/" component "-" (string-delete #\- version) ".src.tar.xz"))

(define-public llvm-11.1
  (package
    (inherit llvm-11)
    (version "11.1.0")
    (source
     (origin
      (method url-fetch)
      (uri (llvm-uri "llvm" version))
      (sha256
       (base32
        "199yq3a214avcbi4kk2q0ajriifkvsr0l2dkx3a666m033ihi1ff"))))))

(define-public spirv-headers-3
  (package
    (name "spirv-headers")
    (version "3.236.0")
    (source
     (origin
        (method url-fetch)
        (uri
 	      (string-append "https://github.com/KhronosGroup/SPIRV-Headers/"
	  	             "archive/refs/tags/sdk-1." version ".tar.gz"))
        (sha256
          (base32 "0y1b5d7vslqfv76l7an9bzs7vchc39kxs962lzmnji6pzn2wcx2d"))))
    (build-system cmake-build-system)
    (arguments
     `(#:tests? #f))                    ;no tests
    (home-page "https://github.com/KhronosGroup/SPIRV-Headers")
    (synopsis "Machine-readable files from the SPIR-V Registry")
    (description
     "SPIRV-Headers is a repository containing machine-readable files from
the SPIR-V Registry.  This includes:
@itemize
@item Header files for various languages.
@item JSON files describing the grammar for the SPIR-V core instruction set,
and for the GLSL.std.450 extended instruction set.
@item The XML registry file.
@end itemize\n")
    (license (license:x11-style
              (string-append "https://github.com/KhronosGroup/SPIRV-Headers/blob/"
                             version "/LICENSE")))))

(define-public spirv-tools-3
  (package
    (name "spirv-tools")
    (version "3.236.0")
    (source
     (origin
        (method url-fetch)
        (uri
 	      (string-append "https://github.com/KhronosGroup/SPIRV-Tools/"
	  	             "archive/refs/tags/sdk-1." version ".tar.gz"))
        (sha256
          (base32 "1agxkmbvlyr1vwy53s62rjlygp8c5wvgjyfmqcks33xsm21cg2b7"))))
    (build-system cmake-build-system)
    (arguments
     `(#:configure-flags (list "-DBUILD_SHARED_LIBS=ON"
                               (string-append
                                "-DSPIRV-Headers_SOURCE_DIR="
                                (assoc-ref %build-inputs "spirv-headers")))))
    (inputs (list spirv-headers-3))
    (native-inputs (list pkg-config python))
    (home-page "https://github.com/KhronosGroup/SPIRV-Tools")
    (synopsis "API and commands for processing SPIR-V modules")
    (description
     "The SPIR-V Tools project provides an API and commands for processing
SPIR-V modules.  The project includes an assembler, binary module
parser,disassembler, validator, and optimizer for SPIR-V.")
    (license license:asl2.0)))

(define-public spirv-llvm-translator
  (package
    (name "spirv-llvm-translator")
    (version "15.0.0")
    (source
      (origin
        (method url-fetch)
        (uri
 	      (string-append "https://github.com/KhronosGroup/SPIRV-LLVM-Translator/"
	  	             "archive/refs/tags/v" version ".tar.gz"))
        (sha256
          (base32 "123dhhpiw0kx6z5s0s91c5d82if5vp17hbl50267b219yxvvvgmi"))))
    (build-system cmake-build-system)
    (native-inputs
      (list pkg-config))
    (inputs
     (list llvm-15 spirv-headers-3 spirv-tools-3 libffi))
    (arguments
     `(#:tests? #f
       #:configure-flags
         (list (string-append "-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR="
                              (assoc-ref %build-inputs "spirv-headers")
	       (string-append "-DPKG_CONFIG_PATH="
                              (assoc-ref %build-inputs "spirv-tools")
			      "/lib/pkgconfig")))))
    (home-page "https://github.com/intel/intel-graphics-compiler")
    (synopsis "Intel Graphics Compiler for OpenCL")
    (description "The Intel® Graphics Compiler for OpenCL™ is an LLVM based
compiler for OpenCL™ targeting Intel Gen graphics hardware architecture.")
    (license license:expat)))

(define-public opencl-clang
  (package
   (name "opencl-clang")
   (version "15.0.0")
   (source
    (origin
     (method url-fetch)
     (uri
      (string-append "https://github.com/intel/opencl-clang/"
		     "archive/refs/tags/v" version ".tar.gz"))
     (sha256
      (base32 "048lmm2ydp02n7yvqzn3sbvm4w3z8sz7cpv5w9ccdj1bwms9c5za"))))
    (build-system cmake-build-system)
    (inputs
      (list llvm-15 clang-15 spirv-llvm-translator libffi))
    (arguments
     `(#:tests? #f
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'force
           (lambda _
             (substitute* "cl_headers/CMakeLists.txt"
                    (("endif\\(USE_PREBUILT_LLVM\\)")
                     (string-append "endif(USE_PREBUILT_LLVM)
set(OPENCL_HEADERS_DIR \"" (assoc-ref %build-inputs "clang") "/lib/clang/15.0.6/include\")")))
	     #t)))
       #:configure-flags
       (list "-DLLVMSPIRV_INCLUDED_IN_LLVM=OFF"
	     (string-append "-DSPIRV_TRANSLATOR_DIR="
			    (assoc-ref %build-inputs "spirv-llvm-translator")))))
    (home-page "https://github.com/intel/vc-intrinsics")
    (synopsis "Thin wrapper library around clang")
    (description "The library has OpenCL-oriented API and is capable
to compile OpenCL C kernels to SPIR-V modules.")
    (license license:bsd-3)))

(define-public ptex
  (package
    (name "ptex")
    (version "2.4.2")
    (source
      (origin
        (method url-fetch)
        (uri
 	  (string-append "https://github.com/wdas/ptex/archive/refs/tags/"
	                 "v" version ".tar.gz"))
        (sha256
          (base32 "1qcyjzrqcl3w2gajmqy5hrla8av6bd6s0klghh8gn74j1jrmy8y8"))))
    (build-system cmake-build-system)
    (native-inputs
      (list pkg-config doxygen))
    (inputs
      (list zlib))
    (home-page "https://ptex.us/")
    (synopsis "Ptex texture mapping system")
    (description "Ptex is a texture mapping system developed by Walt
Disney Animation Studios for production-quality rendering.
No UV assignment is required! Ptex applies a separate texture to each
face of a subdivision or polygon mesh.
The Ptex file format can efficiently store hundreds of thousands of
texture images in a single file.
The Ptex API provides cached file I/O and high-quality filtering -
everything that is needed to easily add Ptex support to a
production-quality renderer or texture authoring application.")
    (license license:bsd-3)))

(define-public openvdb-10.0
  (package
    (name "openvdb")
    (version "10.0.1")
    (source (origin
        (method url-fetch)
        (uri
 	 (string-append "https://github.com/AcademySoftwareFoundation/openvdb"
	  	        "/archive/refs/tags/v" version ".tar.gz"))
        (sha256
          (base32 "0bv27i9gbplmscva16j7zkjjcgdknhxgpx0lg73j0syrzf8k6yl8"))))
    (build-system cmake-build-system)
    (arguments
     `(#:configure-flags
       (list "-DOPENVDB_BUILD_VDB_LOD=ON"
             "-DOPENVDB_BUILD_VDB_RENDER=ON"
             "-DOPENVDB_BUILD_VDB_VIEW=ON"
             "-DOPENVDB_BUILD_NANOVDB=ON"
             "-DNANOVDB_BUILD_TOOLS=ON"
	     (string-append "-DCMAKE_EXE_LINKER_FLAGS=-Wl,-rpath="
                            (assoc-ref %outputs "out") "/lib"))))
    (native-inputs
     (list
      pkg-config))
    (inputs
     (list
      ;; for the library
      jemalloc-5.3
      boost
      tbb-2020
      ilmbase
      c-blosc
      zlib
      ;; for the binaries
      mesa
      glfw
      glu))
    (home-page "https://www.openvdb.org/")
    (synopsis "Sparse volume data structure and tools")
    (description "OpenVDB is a C++ library comprising a hierarchical data
structure and a large suite of tools for the efficient storage and
manipulation of sparse volumetric data discretized on three-dimensional grids.
It was developed by DreamWorks Animation for use in volumetric applications
typically encountered in feature film production.")
    (license license:mpl2.0)))

(define-public yaml-cpp-0.7
  (package
    (name "yaml-cpp")
    (version "0.7.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/jbeder/yaml-cpp"
                                  "/archive/refs/tags/yaml-cpp-" version ".tar.gz"))
              (sha256
               (base32
                "1hxp11rb95ra235mh366r6hrgm758wwqgl7h2laqgba6n7yakrj3"))))
    (build-system cmake-build-system)
    (arguments
     '(#:configure-flags '("-DYAML_BUILD_SHARED_LIBS=ON")))
    (native-inputs
     (list python))
    (home-page "https://github.com/jbeder/yaml-cpp")
    (synopsis "YAML parser and emitter in C++")
    (description "YAML parser and emitter in C++ matching the YAML 1.2 spec.")
    (license license:bsd-3)))

(define-public pystring
  (package
    (name "pystring")
    (version "1.1.4")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/imageworks/pystring"
                                  "/archive/refs/tags/v" version ".tar.gz"))
              (sha256
               (base32
                "1yw8szpqrdl708rl4dh06vwql9x2cggk1rfc8ly0sd29l3i0znj9"))))
    (build-system cmake-build-system)
    (arguments
     '(#:phases
       (modify-phases %standard-phases
         (add-after 'install 'install-header
           (lambda* (#:key outputs #:allow-other-keys)
	       (let* ((out     (assoc-ref outputs "out"))
	  	      (include (string-append out "/include/pystring")))
               (install-file "../pystring-1.1.4/pystring.h" include)
               #t))))))
    (home-page "https://github.com/imageworks/pystring")
    (synopsis "C++ functions matching the interface of python's string.")
    (description "Pystring is a collection of C++ functions which match the
interface and behavior of python's string class methods using std::string.
Implemented in C++, it does not require or make use of a python interpreter.
It provides convenience and familiarity for common string operations not
included in the standard C++ library. It's also useful in environments where
both C++ and python are used.")
    (license license:bsd-3)))

(define-public zlib-1.2.13
  (package
    (inherit zlib)
    (version "1.2.13")
    (source
     (origin
      (method url-fetch)
      (uri (list (string-append "http://zlib.net/zlib-"
                                 version ".tar.gz")
                 (string-append "mirror://sourceforge/libpng/zlib/"
                                version "/zlib-" version ".tar.gz")))
      (sha256
       (base32
        "0c5b8vw40dy178xlpddw65q9gf1h2186jcc3p4swinwggbllv8mk"))))))

(define-public minizip-ng
  (package
    (name "minizip-ng")
    (version "3.0.8")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/zlib-ng/minizip-ng"
                                  "/archive/refs/tags/" version ".tar.gz"))
              (sha256
               (base32
                "16k20h57kc328095yswwpbw8b0vj0b76mz26ndqrpmq2rmi2zk17"))))
    (build-system cmake-build-system)
    (arguments
     `(#:tests?  #f))
    (native-inputs
     (list pkg-config))
    (inputs
     (list zlib))
    (home-page "https://github.com/zlib-ng/minizip-ng")
    (synopsis "Zip manipulation library")
    (description "minizip-ng is a zip manipulation library written in C
that is supported on Windows, macOS, and Linux.")
    (license license:zlib)))

(define-public pybind11-2.10
  (package
    (name "pybind11")
    (version "2.10.3")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/pybind/pybind11"
                                  "/archive/refs/tags/v" version ".tar.gz"))
              (sha256
               (base32
                "05d3did0fjasb83mh3b7wkxc525r5hhsblm39fa3m3a2v9flr32x"))))
    (build-system cmake-build-system)
    (native-inputs
     (list python-wrapper
	   python-pytest
	   catch-framework
	   eigen))
    (inputs (list boost))
    (arguments
     `(#:configure-flags
       (list (string-append "-DCATCH_INCLUDE_DIR="
                            (assoc-ref %build-inputs "catch")
                            "/include"))

       #:phases (modify-phases %standard-phases
                  (add-after 'install 'install-python
                    (lambda* (#:key outputs #:allow-other-keys)
                      (let ((out (assoc-ref outputs "out")))
                        (with-directory-excursion "../pybind11-2.10.3"
                          (setenv "PYBIND11_USE_CMAKE" "yes")
                          (invoke "python" "setup.py" "install"
                                  "--single-version-externally-managed"
                                  "--root=/"
                                  (string-append "--prefix=" out)))))))

       #:test-target "check"))
    (home-page "https://github.com/pybind/pybind11/")
    (synopsis "Seamless operability between C++11 and Python")
    (description
     "@code{pybind11} is a lightweight header-only library that exposes C++
types in Python and vice versa, mainly to create Python bindings of existing
C++ code.  Its goals and syntax are similar to the @code{Boost.Python}
library: to minimize boilerplate code in traditional extension modules by
inferring type information using compile-time introspection.")
    (license license:bsd-3)))

(define-public libde265-1.0.11
  (package
    (name "libde265")
    (version "1.0.11")
    (source 
     (origin
       (method git-fetch)
       (uri
        (git-reference
         (url "https://github.com/strukturag/libde265")
         (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "0vy1brb8mnc590g5l21qfj3fg0arbw7dif1w0vizkxbqk23m996i"))))
    (build-system gnu-build-system)
    (arguments
     `(#:configure-flags
       (list "--disable-static"
	     ;; disable examples depending on Qt5, Sdl, ...
	     "--disable-dec265"
	     "--disable-sherlock265")))
    (native-inputs
     `(("autoconf" ,autoconf)
       ("automake" ,automake)
       ("libtool" ,libtool)
       ("pkg-config" ,pkg-config)
       ("python" ,python-wrapper)))
    (synopsis "H.265 video codec implementation")
    (description "Libde265 is an implementation of the h.265 video codec.  It is
written from scratch and has a plain C API to enable a simple integration into
other software.")
    (home-page "https://www.libde265.org/")
    (license license:lgpl3+)))

(define-public libheif-1.15
  (package
    (name "libheif")
    (version "1.15.1")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/strukturag/libheif")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "0m7zgdcrfgxjwkccjpm5lg8asxjjcvlsmv64c517h4d1ir5krpg7"))))
    (build-system cmake-build-system)
    (arguments
     `(#:tests? #f)) ;no test target although there is a tests folder
    (native-inputs
     (list autoconf automake libtool pkg-config))
    (inputs
     `(("gdk-pixbuf" ,gdk-pixbuf) ;optional
       ("libjpeg" ,libjpeg-turbo)
       ("libpng" ,libpng)))
     ;; Propagated to satisfy 'libheif.pc'.
     (propagated-inputs
      (list dav1d libaom libde265-1.0.11 x265))
    (home-page "https://github.com/strukturag/libheif")
    (synopsis "HEIF and AVIF file format decoder and encoder")
    (description
     "@code{libheif} is an ISO/IEC 23008-12:2017 HEIF and AVIF (AV1 Image File
Format) file format decoder and encoder.")
    (license license:lgpl3+)))

(define-public opencolorio-2.2
  (package
    (name "opencolorio")
    (version "2.2.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/AcademySoftwareFoundation/OpenColorIO"
                                  "/archive/refs/tags/v" version ".tar.gz"))
              (sha256
               (base32
                "03jqp0i08k68gryamg10anh5lwk8is5rphh530j5qkpwhxc7rwin"))
	      (patches (search-patches "vfx/patches/opencolorio-link-extra.patch"))))
    (build-system cmake-build-system)
    (arguments
     `(#:configure-flags
       (list (string-append "-DCMAKE_CXX_FLAGS="
                            "-Wno-error=deprecated-declarations "
                            "-Wno-error=unused-function")
	     "-DOCIO_BUILD_APPS=OFF"
	     "-DOCIO_BUILD_PYTHON=OFF"
	     "-DOCIO_BUILD_TESTS=OFF"
	     (string-append "-Dpystring_INCLUDE_DIR="
	      		    (assoc-ref %build-inputs "pystring")
	      		    "/include"))))
       ;; #:phases
       ;; (modify-phases %standard-phases
       ;;   (add-after 'unpack 'patch-test-suite
       ;;     (lambda _
       ;;       (substitute* "src/core_tests/CMakeLists.txt"
       ;;         (("/bin/sh") (which "bash")))
       ;;       #t)))))
    (native-inputs
     (list ;;git
	   pkg-config))
    (inputs
     ;; XXX Adding freeglut, glew, ilmbase, mesa, and openimageio for
     ;; ocioconvert fails: error: conflicting declaration ?typedef void
     ;; (* PFNGLGETFRAGMENTMATERIALFVSGIXPROC)(GLenum, GLenum, GLfloat*)
     (list mesa glew freeglut expat yaml-cpp-0.7 lcms openexr tinyxml pystring imath zlib-1.2.13 minizip-ng pybind11-2.10 libzip))
    (home-page "https://opencolorio.org")
    (synopsis "Color management for visual effects and animation")
    (description
     "OpenColorIO, or OCIO, is a complete color management solution geared
towards motion picture production, with an emphasis on visual effects and
computer animation.  It provides a straightforward and consistent user
experience across all supporting applications while allowing for sophisticated
back-end configuration options suitable for high-end production usage.

OCIO is compatible with the @acronym{ACES, Academy Color Encoding
Specification} and is @acronym{LUT, look-up table}-format agnostic, supporting
many popular formats.")
    (license (list license:expat        ; docs/ociotheme/static, ext/yaml-cpp-*
                   license:zlib         ; src/core/md5
                   license:bsd-3))))    ; the rest

(define-public openimageio-2.4
  (package
    (name "openimageio")
    (version "2.4.8.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/OpenImageIO/oiio"
                                  "/archive/refs/tags/v" version ".tar.gz"))
              (sha256
               (base32
                "0169f7wx1w6ls1y36mk5658a0xbxpdwzlq3hj4ccfj0djx8jhh78"))))
    (build-system cmake-build-system)
    ;; FIXME: To run all tests successfully, test image sets from multiple
    ;; third party sources have to be present.  For details see
    ;; <https://github.com/OpenImageIO/oiio/blob/master/INSTALL.md>
    (arguments
     `(#:tests? #f
       #:configure-flags
       (list "-DUSE_EXTERNAL_PUGIXML=1")))
    (native-inputs
     (list pkg-config))
    (inputs
     (list
      boost
      tbb-2020
      python-wrapper
      ;;qtbase-5
      zlib
      libtiff
      openexr
      imath
      libjpeg-turbo
      pugixml
      libpng
      freetype
      opencolorio-2.2
      ffmpeg
      giflib
      libheif-1.15
      libraw
      openjpeg
      openvdb-10.0
      ptex
      robin-map
      fmt-8
      pybind11))
    (synopsis "C++ library for reading and writing images")
    (description
     "OpenImageIO is a library for reading and writing images, and a bunch of
related classes, utilities, and applications.  There is a particular emphasis
on formats and functionality used in professional, large-scale animation and
visual effects work for film.")
    (home-page "https://www.openimageio.org")
    (license license:bsd-3)))

(define-public openshadinglanguage-1.12
  (package
    (name "openshadinglanguage")
    (version "1.12.9.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/AcademySoftwareFoundation/OpenShadingLanguage"
                                  "/archive/refs/tags/v" version ".tar.gz"))
              (sha256
               (base32
                "0a6bzcrdd6hxrwp58zjd7j289s1169ki0k8xgpkig8swqf7qzm8j"))
	      (patches (search-patches "vfx/patches/openshadinglanguage-custom-clang.patch"))))
    (build-system cmake-build-system)
    (arguments
     `(#:configure-flags
       (list "-DUSE_PARTIO=OFF" ; TODO: not packaged
    	     (string-append "-DLLVM_DIRECTORY="
   		            (assoc-ref %build-inputs "llvm"))
    	     (string-append "-DCLANG_DIRECTORY="
   		            (assoc-ref %build-inputs "clang")))
       #:phases
       (modify-phases %standard-phases
         ;; (add-after 'set-paths 'add-ilmbase-include-path
         ;;   (lambda* (#:key inputs #:allow-other-keys)
         ;;     ;; OpenEXR 2 propagates ilmbase, but its include files do not
         ;;     ;; appear in the C_INCLUDE_PATH.
         ;;     (let ((headers (string-append
         ;;                     (assoc-ref inputs "ilmbase")
         ;;                     "/include/OpenEXR")))
         ;;       (setenv "C_INCLUDE_PATH"
         ;;               (string-append headers ":"
         ;;                              (or (getenv "C_INCLUDE_PATH") "")))
         ;;       (setenv "CPLUS_INCLUDE_PATH"
         ;;               (string-append headers ":"
         ;;                              (or (getenv "CPLUS_INCLUDE_PATH") ""))))))
	 (delete 'check))))
    (native-inputs
     (list bison
           clang-15
           flex
           llvm-15
           pybind11
           python-wrapper))
    (inputs
     (list boost
           openexr
           openimageio-2.4
           pugixml
           qtbase-5
           zlib))
    (home-page "https://github.com/AcademySoftwareFoundation/OpenShadingLanguage")
    (synopsis "Shading language for production GI renderers")
    (description "Open Shading Language (OSL) is a language for programmable
shading in advanced renderers and other applications, ideal for describing
materials, lights, displacement, and pattern generation.")
    (license license:bsd-3)))

(define-public freetype-2.13
  (package
   (name "freetype")
   (version "2.13.0")
   (source
    (origin
      (method url-fetch)
      (uri (string-append "https://gitlab.freedesktop.org/freetype/freetype/-/archive/VER-"
			  (string-replace-substring version "." "-")
			  "/freetype-VER-"
			  (string-replace-substring version "." "-")
                          ".tar.gz"))
      (sha256
       (base32 "04mbhf7b1g7fmf3a27mfp085chc7dybjsad9mkgd55gf384z30x6"))))
   (build-system cmake-build-system)
   (arguments
    `(#:tests? #f
      #:configure-flags
      (list "-DBUILD_SHARED_LIBS=true"
	    "-DCMAKE_BUILD_TYPE=Release")))
   (native-inputs
    (list pkg-config))
   (inputs
    ;; These are all in the Requires.private field of freetype2.pc.
    (list bzip2 brotli harfbuzz libpng zlib))
   (synopsis "Font rendering library")
   (description
    "Freetype is a library that can be used by applications to access the
contents of font files.  It provides a uniform interface to access font files.
It supports both bitmap and scalable formats, including TrueType, OpenType,
Type1, CID, CFF, Windows FON/FNT, X11 PCF, and others.  It supports high-speed
anti-aliased glyph bitmap generation with 256 gray levels.")
   (license license:freetype)           ; some files have other licenses
   (home-page "https://www.freetype.org/")))

(define-public jemalloc-5.3
  (package
    (inherit jemalloc-4.5.0)
    (version "5.3.0")
    (source (origin
              (method url-fetch)
              (uri (string-append
                    "https://github.com/jemalloc/jemalloc/releases/download/"
                    version "/jemalloc-" version ".tar.bz2"))
              (sha256
               (base32
                "1apyxjd1ixy4g8xkr61p0ny8jiz8vyv1j0k4nxqkxpqrf4g2vf1d"))))
    (arguments
      (substitute-keyword-arguments (package-arguments jemalloc-4.5.0)
        ;; Disable the thread local storage model in jemalloc 5 to prevent
        ;; shared libraries linked to libjemalloc from crashing on dlopen()
        ;; https://github.com/jemalloc/jemalloc/issues/937
        ((#:configure-flags base-configure-flags '())
         `(cons "--disable-initial-exec-tls" ,base-configure-flags))))
    (inputs (list perl))))