gzdoom: add package
authorDaniel Golle <daniel@makrotopia.org>
Thu, 7 Nov 2024 20:18:45 +0000 (20:18 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Thu, 5 Dec 2024 01:26:26 +0000 (01:26 +0000)
Add GZDoom package which brings high-res 3D accelerated implementation
of the Doom engine with many extra features.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
games/gzdoom/Makefile [new file with mode: 0644]
games/gzdoom/patches/0002-fix-musl-fts.patch [new file with mode: 0644]
games/gzdoom/patches/0003-define-cpu_set_t.patch [new file with mode: 0644]
games/gzdoom/patches/100-openwrt-cross-build.patch [new file with mode: 0644]
games/gzdoom/patches/120-lzma-pthreads.patch [new file with mode: 0644]
games/gzdoom/patches/no-execinfo.patch [new file with mode: 0644]
games/zmusic/Makefile [new file with mode: 0644]

diff --git a/games/gzdoom/Makefile b/games/gzdoom/Makefile
new file mode 100644 (file)
index 0000000..b79e2a4
--- /dev/null
@@ -0,0 +1,66 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gzdoom
+PKG_VERSION:=4.13.1
+PKG_RELEASE:=1
+
+PKG_SOURCE:=g$(PKG_VERSION).zip
+PKG_SOURCE_URL:=https://github.com/ZDoom/gzdoom/archive/refs/tags/
+PKG_HASH:=e584c6436f7ea2c9186324dc75a3f1eebf4302fbdd2f98db13550cff2dd393a3
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-g$(PKG_VERSION)
+HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)-g$(PKG_VERSION)
+
+PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
+PKG_LICENSE:=BSD-3c
+PKG_LICENSE_FILES:=COPYING LICENSE
+
+CMAKE_INSTALL:=1
+PKG_BUILD_DEPENDS:=gzdoom/host vulkan-loader
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+CMAKE_OPTIONS += \
+       -DHAVE_VULKAN=ON \
+       -DHAVE_GLES2=ON \
+       -DNO_OPENAL=ON \
+       -DFORCE_INTERNAL_BZIP2=ON \
+       -DSDL2_INCLUDE_DIR="$(STAGING_DIR)/usr/include/SDL2" \
+       -DIMPORT_EXECUTABLES="$(STAGING_DIR_HOSTPKG)/share/gzdoom/ImportExecutables.cmake" \
+       -DVULKAN_USE_XLIB=OFF \
+       -DVULKAN_USE_WAYLAND=ON
+
+define Package/gzdoom
+  SECTION:=games
+  CATEGORY:=Games
+  TITLE:=GZDoom
+  URL:=https://zdoom.org/
+  DEPENDS:=+alsa-lib +glib2 +libbz2 +libstdcpp +libzmusic +libvpx +libsdl2 +USE_MUSL:musl-fts
+endef
+
+define Package/gzdoom/description
+ ZDoom is a family of enhanced ports of the Doom engine for running on modern
+ operating systems. Use this port of DOOM on systems with some sort of hardware
+ 3D acceleration support.
+endef
+
+define Host/Install
+       $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/share/gzdoom
+       $(INSTALL_DATA) $(HOST_BUILD_DIR)/ImportExecutables.cmake $(STAGING_DIR_HOSTPKG)/share/gzdoom
+endef
+
+define Host/Uninstall
+       $(RM) $(STAGING_DIR_HOSTPKG)/share/gzdoom/ImportExecutables.cmake
+endef
+
+define Package/gzdoom/install
+       $(INSTALL_DIR) $(1)/usr/share/games
+       $(CP) $(PKG_INSTALL_DIR)/usr/share/games/* $(1)/usr/share/games
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gzdoom $(1)/usr/bin
+endef
+
+$(eval $(call BuildPackage,gzdoom))
+$(eval $(call HostBuild))
diff --git a/games/gzdoom/patches/0002-fix-musl-fts.patch b/games/gzdoom/patches/0002-fix-musl-fts.patch
new file mode 100644 (file)
index 0000000..111ca87
--- /dev/null
@@ -0,0 +1,10 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -291,6 +291,7 @@ else()
+               if ( NOT HAVE_FTS )
+                       include ( FindPkgConfig )
+                       pkg_check_modules( MUSL_FTS musl-fts )
++                      string(REPLACE ";" " " MUSL_FTS_LDFLAGS "${MUSL_FTS_LDFLAGS}")
+                       if ( MUSL_FTS_FOUND )
+                               set ( ALL_C_FLAGS "${ALL_C_FLAGS} ${MUSL_FTS_LDFLAGS}" )
+                       else ( MUSL_FTS_FOUND )
diff --git a/games/gzdoom/patches/0003-define-cpu_set_t.patch b/games/gzdoom/patches/0003-define-cpu_set_t.patch
new file mode 100644 (file)
index 0000000..ba6048e
--- /dev/null
@@ -0,0 +1,12 @@
+From https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/35711#note_243863
+_GNU_SOURCE is needed for cpu_set_t, and affinity disable is needed to work around lack of pthread_attr_setaffinity_np
+--- a/libraries/lzma/CMakeLists.txt
++++ b/libraries/lzma/CMakeLists.txt
+@@ -1,6 +1,6 @@
+ make_release_only()
+-set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DZ7_PPMD_SUPPORT" )
++set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -DZ7_PPMD_SUPPORT -DZ7_AFFINITY_DISABLE" )
+ find_package(Threads)
diff --git a/games/gzdoom/patches/100-openwrt-cross-build.patch b/games/gzdoom/patches/100-openwrt-cross-build.patch
new file mode 100644 (file)
index 0000000..1438820
--- /dev/null
@@ -0,0 +1,33 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -337,6 +337,7 @@ option(FORCE_INTERNAL_BZIP2 "Use interna
+ option(FORCE_INTERNAL_ASMJIT "Use internal asmjit" ON)
+ mark_as_advanced( FORCE_INTERNAL_ASMJIT )
++if( CMAKE_CROSSCOMPILING )
+ if (HAVE_VULKAN)
+       add_subdirectory( libraries/ZVulkan )
+ endif()
+@@ -375,6 +376,7 @@ if( ${HAVE_VM_JIT} )
+               set( ASMJIT_LIBRARY asmjit )
+       endif()
+ endif()
++endif()
+ if( BZIP2_FOUND AND NOT FORCE_INTERNAL_BZIP2 )
+       message( STATUS "Using system bzip2 library, includes found at ${BZIP2_INCLUDE_DIR}" )
+@@ -409,12 +411,14 @@ option( DYN_OPENAL "Dynamically load Ope
+ add_subdirectory( libraries/lzma )
+ add_subdirectory( libraries/miniz )
+ add_subdirectory( tools )
++if( CMAKE_CROSSCOMPILING )
+ add_subdirectory( wadsrc )
+ add_subdirectory( wadsrc_bm )
+ add_subdirectory( wadsrc_lights )
+ add_subdirectory( wadsrc_extra )
+ add_subdirectory( wadsrc_widepix )
+ add_subdirectory( src )
++endif()
+ if( NOT CMAKE_CROSSCOMPILING )
+       export(TARGETS ${CROSS_EXPORTS} FILE "${CMAKE_BINARY_DIR}/ImportExecutables.cmake" )
diff --git a/games/gzdoom/patches/120-lzma-pthreads.patch b/games/gzdoom/patches/120-lzma-pthreads.patch
new file mode 100644 (file)
index 0000000..54f492c
--- /dev/null
@@ -0,0 +1,18 @@
+--- a/libraries/lzma/CMakeLists.txt
++++ b/libraries/lzma/CMakeLists.txt
+@@ -2,8 +2,6 @@ make_release_only()
+ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -DZ7_PPMD_SUPPORT -D_7ZIP_AFFINITY_DISABLE" )
+-find_package(Threads)
+-
+ add_library( lzma STATIC
+       C/7zAlloc.c
+       C/7zArcIn.c
+@@ -48,4 +46,5 @@ add_library( lzma STATIC
+       C/XzEnc.c
+       C/XzIn.c
+ )
+-target_link_libraries( lzma Threads::Threads )
++
++target_link_libraries( lzma PUBLIC pthread )
diff --git a/games/gzdoom/patches/no-execinfo.patch b/games/gzdoom/patches/no-execinfo.patch
new file mode 100644 (file)
index 0000000..1e7ad64
--- /dev/null
@@ -0,0 +1,49 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -358,7 +358,7 @@ if( HAVE_VM_JIT AND UNIX )
+               if( HAVE_LIBEXECINFO )
+                       set( ALL_C_FLAGS "${ALL_C_FLAGS} -lexecinfo" )
+               else( HAVE_LIBEXECINFO )
+-                      set( HAVE_VM_JIT NO )
++                      #       set( HAVE_VM_JIT NO )
+               endif( HAVE_LIBEXECINFO )
+               set( CMAKE_REQUIRED_FLAGS )
+       endif( NOT HAVE_BACKTRACE )
+--- a/src/common/scripting/jit/jit_runtime.cpp
++++ b/src/common/scripting/jit/jit_runtime.cpp
+@@ -7,7 +7,6 @@
+ #include <DbgHelp.h>
+ #include <psapi.h>
+ #else
+-#include <execinfo.h>
+ #include <cxxabi.h>
+ #include <cstring>
+ #include <cstdlib>
+@@ -806,7 +805,7 @@ static int CaptureStackTrace(int max_fra
+       // JIT isn't supported here, so just do nothing.
+       return 0;//return RtlCaptureStackBackTrace(0, min(max_frames, 32), out_frames, nullptr);
+ #else
+-      return backtrace(out_frames, max_frames);
++      return 0;
+ #endif
+ }
+@@ -868,7 +867,9 @@ class NativeSymbolResolver
+ public:
+       FString GetName(void *frame)
+       {
+-              FString s;
++              FString s = "no backtrace";
++              return s;
++              #if 0
+               char **strings;
+               void *frames[1] = { frame };
+               strings = backtrace_symbols(frames, 1);
+@@ -925,6 +926,7 @@ public:
+               free(strings);
+               return s;
++              #endif
+       }
+ };
+ #endif
diff --git a/games/zmusic/Makefile b/games/zmusic/Makefile
new file mode 100644 (file)
index 0000000..27a2035
--- /dev/null
@@ -0,0 +1,41 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=zmusic
+PKG_VERSION:=1.1.14
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://github.com/ZDoom/ZMusic
+PKG_SOURCE_VERSION:=89f3d65734470fb7ec0c1e69f73a0cfcc88ed557
+PKG_MIRROR_HASH:=104af83c55909a3cc2151bf9a32b153355fab76ee503bf199f49fb401f595a2b
+
+PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
+PKG_LICENSE:=GPL-3.0
+PKG_LICENSE_FILES:=licenses/bsd.txt licenses/dumb.txt licenses/gplv3.txt \
+                  licenses/legal.txt licenses/lgplv21.txt licenses/lgplv3.txt \
+                  licenses/zmusic.txt
+
+CMAKE_INSTALL:=1
+PKG_BUILD_FLAGS:=gc-sections lto
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/libzmusic
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=ZMusic
+  URL:=https://zdoom.org/
+  DEPENDS:=+libstdcpp +libsndfile +alsa-lib +glib2
+endef
+
+define Package/libzmusic/description
+  GZDoom's music system as a standalone library
+endef
+
+define Package/libzmusic/install
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libzmusic.so* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libzmusic))