Merge pull request #185573 from mikroskeem/fix-quakespasm-darwin

quakespasm: fix darwin build

authored by Domen Kožar and committed by GitHub 2fa6e525 1228cddd

+55 -30
+12 -6
pkgs/games/quakespasm/default.nix
··· 1 - { lib, stdenv, SDL, SDL2, fetchurl, gzip, libvorbis, libmad 1 + { lib, stdenv, SDL, SDL2, fetchurl, gzip, libvorbis, libmad, flac, libopus, opusfile, libogg, libxmp 2 2 , Cocoa, CoreAudio, CoreFoundation, IOKit, OpenGL 3 - , copyDesktopItems, makeDesktopItem 3 + , copyDesktopItems, makeDesktopItem, pkg-config 4 4 , useSDL2 ? stdenv.isDarwin # TODO: CoreAudio fails to initialize with SDL 1.x for some reason. 5 5 }: 6 6 ··· 20 20 ./quakespasm-darwin-makefile-improvements.patch 21 21 ]; 22 22 23 - nativeBuildInputs = [ copyDesktopItems ]; 23 + nativeBuildInputs = [ 24 + copyDesktopItems 25 + pkg-config 26 + ]; 27 + 24 28 buildInputs = [ 25 - gzip libvorbis libmad (if useSDL2 then SDL2 else SDL) 29 + gzip libvorbis libmad flac libopus opusfile libogg libxmp 30 + (if useSDL2 then SDL2 else SDL) 26 31 ] ++ lib.optionals stdenv.isDarwin [ 27 32 Cocoa CoreAudio IOKit OpenGL 28 33 ] ++ lib.optionals (stdenv.isDarwin && useSDL2) [ ··· 35 40 "USE_CODEC_WAVE=1" 36 41 "USE_CODEC_MP3=1" 37 42 "USE_CODEC_VORBIS=1" 38 - "USE_CODEC_FLAC=0" 39 - "USE_CODEC_OPUS=0" 43 + "USE_CODEC_FLAC=1" 44 + "USE_CODEC_OPUS=1" 40 45 "USE_CODEC_MIKMOD=0" 41 46 "USE_CODEC_UMX=0" 47 + "USE_CODEC_XMP=1" 42 48 "MP3LIB=mad" 43 49 "VORBISLIB=vorbis" 44 50 ] ++ lib.optionals useSDL2 [
+43 -24
pkgs/games/quakespasm/quakespasm-darwin-makefile-improvements.patch
··· 1 - --- a/Makefile.darwin 2021-09-12 14:42:51.000000000 +0300 2 - +++ b/Makefile.darwin 2021-09-12 15:09:16.000000000 +0300 3 - @@ -49,6 +49,7 @@ 1 + diff --git a/Quake/Makefile.darwin b/Quake/Makefile.darwin 2 + index 6a08e6d..4e320cd 100644 3 + --- a/Makefile.darwin 4 + +++ b/Makefile.darwin 5 + @@ -50,6 +50,7 @@ LINKER = $(CC) 4 6 LIPO ?= lipo 5 7 6 - STRIP ?= strip 8 + STRIP ?= strip -S 7 9 +PKG_CONFIG ?= pkg-config 8 10 9 11 CPUFLAGS= 10 12 LDFLAGS = 11 - @@ -84,9 +85,6 @@ 12 - USE_RPATH=1 13 + @@ -86,9 +87,6 @@ USE_RPATH=1 13 14 endif 15 + CFLAGS += $(call check_gcc,-std=gnu11,) 14 16 CFLAGS += $(CPUFLAGS) 15 17 -ifeq ($(USE_RPATH),1) 16 18 -LDFLAGS+=-Wl,-rpath,@executable_path/../Frameworks 17 19 -endif 18 - 19 20 ifneq ($(DEBUG),0) 20 21 DFLAGS += -DDEBUG 21 - @@ -115,19 +113,14 @@ 22 + CFLAGS += -g 23 + @@ -117,19 +115,14 @@ CFLAGS += -DGL_SILENCE_DEPRECATION=1 22 24 # not relying on sdl-config command and assuming 23 25 # /Library/Frameworks/SDL.framework is available 24 26 SDL_CFLAGS =-D_GNU_SOURCE=1 -D_THREAD_SAFE ··· 34 36 -ifneq ($(SDL_FRAMEWORK_PATH),) 35 37 -SDL_LIBS +=-F$(SDL_FRAMEWORK_PATH) 36 38 -SDL_CFLAGS+=-F$(SDL_FRAMEWORK_PATH) 37 - +SDL_CONFIG ?= sdl2-config 39 + +SDL_CONFIG ?= sdl-config 38 40 endif 39 41 -SDL_LIBS +=-Wl,-framework,$(SDL_FRAMEWORK_NAME) -Wl,-framework,Cocoa 40 42 +SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags) 41 43 +SDL_LIBS := $(shell $(SDL_CONFIG) --libs) 42 - +SDL_LIBS += -Wl,-framework,Cocoa 44 + +SDL_LIBS += -Wl,-framework,Cocoa 43 45 44 46 NET_LIBS := 45 47 46 - @@ -164,38 +157,26 @@ 48 + @@ -165,45 +158,31 @@ ifeq ($(USE_CODEC_WAVE),1) 49 + CFLAGS+= -DUSE_CODEC_WAVE 47 50 endif 48 51 ifeq ($(USE_CODEC_FLAC),1) 49 - CFLAGS+= -DUSE_CODEC_FLAC 52 + -CFLAGS+= -DUSE_CODEC_FLAC 50 53 -CODEC_INC = -I../MacOSX/codecs/include 51 54 -CODEC_LINK= -L../MacOSX/codecs/lib 52 - CODECLIBS+= -lFLAC 55 + -CODECLIBS+= -lFLAC 56 + +CFLAGS+= -DUSE_CODEC_FLAC $(shell $(PKG_CONFIG) --cflags flac) 57 + +CODECLIBS+= $(shell $(PKG_CONFIG) --libs flac) 53 58 endif 54 59 ifeq ($(USE_CODEC_OPUS),1) 55 60 -CFLAGS+= -DUSE_CODEC_OPUS 56 61 -CODEC_INC = -I../MacOSX/codecs/include 57 62 -CODEC_LINK= -L../MacOSX/codecs/lib 58 63 -CODECLIBS+= -lopusfile -lopus -logg 59 - +CFLAGS+= -DUSE_CODEC_OPUS $(shell $(PKG_CONFIG) --cflags opusfile) 60 - +CODECLIBS+= $(shell $(PKG_CONFIG) --libs opusfile) 64 + +CFLAGS+= -DUSE_CODEC_OPUS $(shell $(PKG_CONFIG) --cflags ogg opus opusfile) 65 + +CODECLIBS+= $(shell $(PKG_CONFIG) --libs ogg opus opusfile) 61 66 endif 62 67 ifeq ($(USE_CODEC_VORBIS),1) 63 - CFLAGS+= -DUSE_CODEC_VORBIS $(cpp_vorbisdec) 68 + -CFLAGS+= -DUSE_CODEC_VORBIS $(cpp_vorbisdec) 64 69 -CODEC_INC = -I../MacOSX/codecs/include 65 70 -CODEC_LINK= -L../MacOSX/codecs/lib 66 - CODECLIBS+= $(lib_vorbisdec) 71 + -CODECLIBS+= $(lib_vorbisdec) 72 + +CFLAGS+= -DUSE_CODEC_VORBIS $(shell $(PKG_CONFIG) --cflags ogg vorbis vorbisfile) 73 + +CODECLIBS+= $(shell $(PKG_CONFIG) --libs ogg vorbis vorbisfile) 67 74 endif 68 75 ifeq ($(USE_CODEC_MP3),1) 69 - CFLAGS+= -DUSE_CODEC_MP3 76 + -CFLAGS+= -DUSE_CODEC_MP3 70 77 -CODEC_INC = -I../MacOSX/codecs/include 71 78 -CODEC_LINK= -L../MacOSX/codecs/lib 72 - CODECLIBS+= $(lib_mp3dec) 79 + -CODECLIBS+= $(lib_mp3dec) 80 + +CFLAGS+= -DUSE_CODEC_MP3 $(shell $(PKG_CONFIG) --cflags $(MP3LIB)) 81 + +CODECLIBS+= $(shell $(PKG_CONFIG) --libs $(MP3LIB)) 73 82 endif 74 83 ifeq ($(USE_CODEC_MIKMOD),1) 75 84 CFLAGS+= -DUSE_CODEC_MIKMOD ··· 78 87 CODECLIBS+= -lmikmod 79 88 endif 80 89 ifeq ($(USE_CODEC_XMP),1) 81 - CFLAGS+= -DUSE_CODEC_XMP 90 + -CFLAGS+= -DUSE_CODEC_XMP 91 + -CODEC_INC = -I../MacOSX/codecs/include 92 + -CODEC_LINK= -L../MacOSX/codecs/lib 93 + -CODECLIBS+= -lxmp 94 + +CFLAGS+= -DUSE_CODEC_XMP $(shell $(PKG_CONFIG) --cflags libxmp) 95 + +CODECLIBS+= $(shell $(PKG_CONFIG) --libs libxmp) 96 + endif 97 + ifeq ($(USE_CODEC_MODPLUG),1) 98 + CFLAGS+= -DUSE_CODEC_MODPLUG 82 99 -CODEC_INC = -I../MacOSX/codecs/include 83 100 -CODEC_LINK= -L../MacOSX/codecs/lib 84 - CODECLIBS+= -lxmp 101 + CODECLIBS+= -lmodplug 85 102 endif 86 103 ifeq ($(USE_CODEC_UMX),1) 87 - @@ -332,3 +313,5 @@ 104 + @@ -333,4 +312,7 @@ debug: 88 105 clean: 89 - rm -f $(shell find . \( -name '*~' -o -name '#*#' -o -name '*.o' -o -name '*.res' -o -name $(DEFAULT_TARGET) \) -print) 106 + $(RM) *.o *.d $(DEFAULT_TARGET) 90 107 91 - +install: quakespasm 108 + +install: quakespasm 92 109 + install -D -m 755 quakespasm /usr/local/games/quake 110 + + 111 + sinclude $(OBJS:.o=.d)