1. ;; why is this not working???
  2. (define-module (wongworks packages newgz)
  3. #:use-module (guix packages)
  4. #:use-module (guix download)
  5. #:use-module (guix gexp)
  6. #:use-module (guix git-download)
  7. #:use-module (guix build-system cmake)
  8. #:use-module (gnu packages)
  9. #:use-module (gnu packages pkg-config)
  10. #:use-module (gnu packages audio)
  11. #:use-module (gnu packages compression)
  12. #:use-module (gnu packages gl)
  13. #:use-module (gnu packages gtk)
  14. #:use-module (gnu packages image)
  15. #:use-module (gnu packages mp3)
  16. #:use-module (gnu packages pulseaudio)
  17. #:use-module (gnu packages sdl)
  18. #:use-module ((guix licenses) #:prefix license:))
  19. (define-public gzdoom-new
  20. (package
  21. (name "gzdoom-new")
  22. (version "4.13.2")
  23. (source
  24. (origin
  25. (method git-fetch)
  26. (uri (git-reference
  27. (url "https://github.com/coelckers/gzdoom")
  28. (commit (string-append "g" version))))
  29. (file-name (git-file-name name version))
  30. (sha256
  31. (base32 "0zlvrdayrj1rk5x2hwnc57l8pl29bl64zmfq3qc9yfypknj1syfy"))
  32. (patches (search-patches "gzdoom-search-in-installed-share.patch"
  33. "gzdoom-find-system-libgme.patch"))
  34. (modules '((guix build utils)
  35. (ice-9 regex)))
  36. (snippet
  37. '(begin
  38. ;; Remove files which mustn't be commercially redistributed. See
  39. ;; <https://zdoom.org/wiki/License#Commercial_se>, the ‘Contribution
  40. ;; Guidelines’ at <https://github.com/ZDoom>, and Guix issue #73435.
  41. (for-each
  42. (lambda (directory)
  43. (delete-file-recursively directory)
  44. (substitute* "CMakeLists.txt"
  45. (((string-append "add_subdirectory\\([[:blank:]]*"
  46. directory
  47. "[[:blank:]]*\\)"))
  48. "")))
  49. '( ;; "wadsrc_extra" ;game_support.pk3
  50. "wadsrc_bm")) ;brightmaps.pk3
  51. ;; Removing game_support.pk3 entirely would break Freedoom & remove
  52. ;; users' ability to play commercial games, despite owning (only) the
  53. ;; non-functional data. That can't be right. Out of an abundance of
  54. ;; caution, remove anything from the PK3 that could conceivably be
  55. ;; derived from copyrightable data that's not freely redistributable.
  56. (display "Keeping only the following game_support.pk3 files:\n")
  57. (let* ((regexps (list "/font\\.inf$"
  58. "/harmony/.*\\.(txt|zs)$"
  59. "/(iwadinfo|mapinfo|sprofs)\\.txt$"
  60. "\\.z$"))
  61. (regexp* (format #f "(~{~a~^|~})" regexps))
  62. (regexp (make-regexp regexp* regexp/icase)))
  63. (define (keep-file? file stat)
  64. (let ((keep? (regexp-exec regexp file)))
  65. (when keep?
  66. (format #t " ~a~%" file))
  67. keep?))
  68. (for-each delete-file (find-files "wadsrc_extra/static"
  69. (negate keep-file?))))
  70. ;; Remove some bundled libraries. XXX There are more, but removing
  71. ;; them would require, at least, patching the build system.
  72. (with-directory-excursion "libraries"
  73. (delete-file-recursively "bzip2")
  74. (delete-file-recursively "game-music-emu")
  75. (delete-file-recursively "jpeg")
  76. (delete-file-recursively "zlib"))))))
  77. (arguments
  78. (list
  79. #:tests? #f
  80. #:configure-flags
  81. #~(list
  82. (string-append
  83. "-DCMAKE_CXX_FLAGS:="
  84. "-DSHARE_DIR=\\\"" #$output "/share/\\\" "
  85. "-DGUIX_OUT_PK3=\\\"" #$output "/share/games/doom\\\"")
  86. ;; The build requires some extra convincing not to use the bundled
  87. ;; libgme previously deleted in the soure snippet.
  88. "-DFORCE_INTERNAL_GME=OFF"
  89. ;; Link libraries at build time instead of loading them at run time.
  90. "-DDYN_OPENAL=OFF"
  91. "-DDYN_FLUIDSYNTH=OFF"
  92. "-DDYN_GTK=OFF"
  93. "-DDYN_MPG123=OFF"
  94. "-DDYN_SNDFILE=OFF")
  95. #:phases
  96. #~(modify-phases %standard-phases
  97. (add-before 'configure 'fix-file-names
  98. (lambda* (#:key inputs #:allow-other-keys)
  99. (substitute* "src/CMakeLists.txt"
  100. (("COMMAND /bin/sh")
  101. (string-append "COMMAND " (which "sh"))))
  102. (substitute*
  103. "libraries/zmusic/mididevices/music_fluidsynth_mididevice.cpp"
  104. (("/usr/share/sounds/sf2/FluidR3_GM.sf2")
  105. (search-input-file inputs
  106. "share/soundfonts/FluidR3Mono_GM.sf3")))
  107. (substitute*
  108. "libraries/zmusic/mididevices/music_timiditypp_mididevice.cpp"
  109. (("(exename = \")(timidity)(\".*)" dum prefix exe suffix)
  110. (string-append prefix
  111. (search-input-file inputs
  112. (string-append "bin/" exe))
  113. suffix))))))))
  114. (build-system cmake-build-system)
  115. (inputs (list bzip2
  116. fluid-3
  117. fluidsynth
  118. gtk+
  119. libgme
  120. libjpeg-turbo
  121. libsndfile
  122. mesa
  123. mpg123
  124. openal
  125. sdl2
  126. timidity++
  127. zlib))
  128. (native-inputs (list pkg-config unzip))
  129. (synopsis "Modern Doom 2 source port")
  130. (description "GZdoom is a port of the Doom 2 game engine, with a modern
  131. renderer. It improves modding support with ZDoom's advanced mapping features
  132. and the new ZScript language. In addition to Doom, it supports Heretic, Hexen,
  133. Strife, Chex Quest, and fan-created games like Harmony, Hacx and Freedoom.")
  134. (home-page "https://zdoom.org/index")
  135. ;; The source uses x86 assembly
  136. (supported-systems '("x86_64-linux" "i686-linux"))
  137. (license (list license:gpl3+ ; gzdoom game
  138. license:lgpl3+ ; gzdoom renderer
  139. license:expat ; gdtoa
  140. (license:non-copyleft ; modified dumb
  141. "file://dumb/licence.txt"
  142. "Dumb license, explicitly GPL compatible.")))))