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