mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2025-01-08 06:28:50 +03:00
quakespasm: add SDL2 support; add Darwin support
This commit is contained in:
parent
e91060f1db
commit
1dc56f1dc8
@ -1,4 +1,8 @@
|
||||
{ lib, stdenv, SDL, fetchurl, gzip, libvorbis, libmad, copyDesktopItems, makeDesktopItem }:
|
||||
{ lib, stdenv, SDL, SDL2, fetchurl, gzip, libvorbis, libmad
|
||||
, Cocoa, CoreAudio, CoreFoundation, IOKit, OpenGL
|
||||
, copyDesktopItems, makeDesktopItem
|
||||
, useSDL2 ? stdenv.isDarwin # TODO: CoreAudio fails to initialize with SDL 1.x for some reason.
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "quakespasm";
|
||||
@ -12,16 +16,58 @@ stdenv.mkDerivation rec {
|
||||
|
||||
sourceRoot = "${pname}-${version}/Quake";
|
||||
|
||||
nativeBuildInputs = [ copyDesktopItems ];
|
||||
buildInputs = [
|
||||
gzip SDL libvorbis libmad
|
||||
patches = lib.optionals stdenv.isDarwin [
|
||||
# Makes Darwin Makefile use system libraries instead of ones from app bundle
|
||||
./quakespasm-darwin-makefile-improvements.patch
|
||||
];
|
||||
|
||||
buildFlags = [ "DO_USERDIRS=1" ];
|
||||
nativeBuildInputs = [ copyDesktopItems ];
|
||||
buildInputs = [
|
||||
gzip libvorbis libmad (if useSDL2 then SDL2 else SDL)
|
||||
] ++ lib.optionals stdenv.isDarwin [
|
||||
Cocoa CoreAudio IOKit OpenGL
|
||||
] ++ lib.optionals (stdenv.isDarwin && useSDL2) [
|
||||
CoreFoundation
|
||||
];
|
||||
|
||||
buildFlags = [
|
||||
"DO_USERDIRS=1"
|
||||
# Makefile defaults, set here to enforce consistency on Darwin build
|
||||
"USE_CODEC_WAVE=1"
|
||||
"USE_CODEC_MP3=1"
|
||||
"USE_CODEC_VORBIS=1"
|
||||
"USE_CODEC_FLAC=0"
|
||||
"USE_CODEC_OPUS=0"
|
||||
"USE_CODEC_MIKMOD=0"
|
||||
"USE_CODEC_UMX=0"
|
||||
"MP3LIB=mad"
|
||||
"VORBISLIB=vorbis"
|
||||
] ++ lib.optionals useSDL2 [
|
||||
"SDL_CONFIG=sdl2-config"
|
||||
"USE_SDL2=1"
|
||||
];
|
||||
|
||||
makefile = if (stdenv.isDarwin) then "Makefile.darwin" else "Makefile";
|
||||
|
||||
preInstall = ''
|
||||
mkdir -p "$out/bin"
|
||||
substituteInPlace Makefile --replace "/usr/local/games" "$out/bin"
|
||||
substituteInPlace Makefile.darwin --replace "/usr/local/games" "$out/bin"
|
||||
'';
|
||||
|
||||
postInstall = lib.optionalString stdenv.isDarwin ''
|
||||
# Let's build app bundle
|
||||
mkdir -p $out/Applications/Quake.app/Contents/MacOS
|
||||
mkdir -p $out/Applications/Quake.app/Contents/Resources
|
||||
cp ../MacOSX/Info.plist $out/Applications/Quake.app/Contents/
|
||||
cp ../MacOSX/QuakeSpasm.icns $out/Applications/Quake.app/Contents/Resources/
|
||||
cp -r ../MacOSX/English.lproj $out/Applications/Quake.app/Contents/Resources/
|
||||
ln -sf $out/bin/quake $out/Applications/Quake.app/Contents/MacOS/quake
|
||||
|
||||
substituteInPlace $out/Applications/Quake.app/Contents/Info.plist \
|
||||
--replace '>''${EXECUTABLE_NAME}' '>quake'
|
||||
substituteInPlace $out/Applications/Quake.app/Contents/Info.plist \
|
||||
--replace '>''${PRODUCT_NAME}' '>QuakeSpasm'
|
||||
'';
|
||||
|
||||
enableParallelBuilding = true;
|
||||
@ -47,7 +93,7 @@ stdenv.mkDerivation rec {
|
||||
and smoother mouse input - though no CD support.
|
||||
'';
|
||||
|
||||
platforms = platforms.linux;
|
||||
maintainers = with maintainers; [ m3tti ];
|
||||
platforms = platforms.unix;
|
||||
maintainers = with maintainers; [ mikroskeem m3tti ];
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,92 @@
|
||||
--- a/Makefile.darwin 2021-09-12 14:42:51.000000000 +0300
|
||||
+++ b/Makefile.darwin 2021-09-12 15:09:16.000000000 +0300
|
||||
@@ -49,6 +49,7 @@
|
||||
LIPO ?= lipo
|
||||
|
||||
STRIP ?= strip
|
||||
+PKG_CONFIG ?= pkg-config
|
||||
|
||||
CPUFLAGS=
|
||||
LDFLAGS =
|
||||
@@ -84,9 +85,6 @@
|
||||
USE_RPATH=1
|
||||
endif
|
||||
CFLAGS += $(CPUFLAGS)
|
||||
-ifeq ($(USE_RPATH),1)
|
||||
-LDFLAGS+=-Wl,-rpath,@executable_path/../Frameworks
|
||||
-endif
|
||||
|
||||
ifneq ($(DEBUG),0)
|
||||
DFLAGS += -DDEBUG
|
||||
@@ -115,19 +113,14 @@
|
||||
# not relying on sdl-config command and assuming
|
||||
# /Library/Frameworks/SDL.framework is available
|
||||
SDL_CFLAGS =-D_GNU_SOURCE=1 -D_THREAD_SAFE
|
||||
-SDL_CFLAGS+=-DSDL_FRAMEWORK -DNO_SDL_CONFIG
|
||||
ifeq ($(USE_SDL2),1)
|
||||
-SDL_FRAMEWORK_NAME = SDL2
|
||||
+SDL_CONFIG ?= sdl2-config
|
||||
else
|
||||
-SDL_FRAMEWORK_NAME = SDL
|
||||
-endif
|
||||
-# default to our local SDL[2].framework for build
|
||||
-SDL_FRAMEWORK_PATH ?=../MacOSX
|
||||
-ifneq ($(SDL_FRAMEWORK_PATH),)
|
||||
-SDL_LIBS +=-F$(SDL_FRAMEWORK_PATH)
|
||||
-SDL_CFLAGS+=-F$(SDL_FRAMEWORK_PATH)
|
||||
+SDL_CONFIG ?= sdl2-config
|
||||
endif
|
||||
-SDL_LIBS +=-Wl,-framework,$(SDL_FRAMEWORK_NAME) -Wl,-framework,Cocoa
|
||||
+SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
|
||||
+SDL_LIBS := $(shell $(SDL_CONFIG) --libs)
|
||||
+SDL_LIBS += -Wl,-framework,Cocoa
|
||||
|
||||
NET_LIBS :=
|
||||
|
||||
@@ -164,38 +157,26 @@
|
||||
endif
|
||||
ifeq ($(USE_CODEC_FLAC),1)
|
||||
CFLAGS+= -DUSE_CODEC_FLAC
|
||||
-CODEC_INC = -I../MacOSX/codecs/include
|
||||
-CODEC_LINK= -L../MacOSX/codecs/lib
|
||||
CODECLIBS+= -lFLAC
|
||||
endif
|
||||
ifeq ($(USE_CODEC_OPUS),1)
|
||||
-CFLAGS+= -DUSE_CODEC_OPUS
|
||||
-CODEC_INC = -I../MacOSX/codecs/include
|
||||
-CODEC_LINK= -L../MacOSX/codecs/lib
|
||||
-CODECLIBS+= -lopusfile -lopus -logg
|
||||
+CFLAGS+= -DUSE_CODEC_OPUS $(shell $(PKG_CONFIG) --cflags opusfile)
|
||||
+CODECLIBS+= $(shell $(PKG_CONFIG) --libs opusfile)
|
||||
endif
|
||||
ifeq ($(USE_CODEC_VORBIS),1)
|
||||
CFLAGS+= -DUSE_CODEC_VORBIS $(cpp_vorbisdec)
|
||||
-CODEC_INC = -I../MacOSX/codecs/include
|
||||
-CODEC_LINK= -L../MacOSX/codecs/lib
|
||||
CODECLIBS+= $(lib_vorbisdec)
|
||||
endif
|
||||
ifeq ($(USE_CODEC_MP3),1)
|
||||
CFLAGS+= -DUSE_CODEC_MP3
|
||||
-CODEC_INC = -I../MacOSX/codecs/include
|
||||
-CODEC_LINK= -L../MacOSX/codecs/lib
|
||||
CODECLIBS+= $(lib_mp3dec)
|
||||
endif
|
||||
ifeq ($(USE_CODEC_MIKMOD),1)
|
||||
CFLAGS+= -DUSE_CODEC_MIKMOD
|
||||
-CODEC_INC = -I../MacOSX/codecs/include
|
||||
-CODEC_LINK= -L../MacOSX/codecs/lib
|
||||
CODECLIBS+= -lmikmod
|
||||
endif
|
||||
ifeq ($(USE_CODEC_XMP),1)
|
||||
CFLAGS+= -DUSE_CODEC_XMP
|
||||
-CODEC_INC = -I../MacOSX/codecs/include
|
||||
-CODEC_LINK= -L../MacOSX/codecs/lib
|
||||
CODECLIBS+= -lxmp
|
||||
endif
|
||||
ifeq ($(USE_CODEC_UMX),1)
|
||||
@@ -332,3 +313,5 @@
|
||||
clean:
|
||||
rm -f $(shell find . \( -name '*~' -o -name '#*#' -o -name '*.o' -o -name '*.res' -o -name $(DEFAULT_TARGET) \) -print)
|
||||
|
||||
+install: quakespasm
|
||||
+ install -D -m 755 quakespasm /usr/local/games/quake
|
@ -29898,7 +29898,9 @@ with pkgs;
|
||||
|
||||
quake3hires = callPackage ../games/quake3/content/hires.nix { };
|
||||
|
||||
quakespasm = callPackage ../games/quakespasm { };
|
||||
quakespasm = callPackage ../games/quakespasm {
|
||||
inherit (darwin.apple_sdk.frameworks) Cocoa CoreAudio CoreFoundation IOKit OpenGL;
|
||||
};
|
||||
vkquake = callPackage ../games/quakespasm/vulkan.nix { };
|
||||
|
||||
ioquake3 = callPackage ../games/quake3/ioquake { };
|
||||
|
Loading…
Reference in New Issue
Block a user