@@ -35,14 +35,27 @@ EMCC?=emcc
3535# certain enviros, it breaks without the full
3636# path ... even though the binary is in
3737# the calling path.
38- SDL2_FLAGS =` $$ (which sdl2-config) --cflags --libs`
38+ SDL2_FLAGS =` $$ (which sdl2-config) --cflags --libs --static-libs `
3939SOURCE =source/$(TITLE ) .c
40+
41+ # On macOS, SDL2 add-on headers/libs installed via Homebrew are not covered by sdl2-config.
42+ UNAME_S := $(shell uname -s)
43+ BREW_PREFIX :=
44+
45+ ifeq ($(UNAME_S ) ,Darwin)
46+ BREW_PREFIX := $(shell command -v brew >/dev/null 2>&1 && brew --prefix)
47+ ifneq ($(BREW_PREFIX ) ,)
48+ CPPFLAGS += -I$(BREW_PREFIX ) /include
49+ EXTRA_LIBS += -L$(BREW_PREFIX ) /lib
50+ endif
51+ endif
52+
4053LIBS ='-Wl,-rpath,$$ORIGIN' $(SDL2_FLAGS ) -l SDL2_image -l SDL2_mixer -l SDL2_ttf
4154ifeq ($(origin EXTRA_LIBS ) , default)
4255EXTRA_LIBS =
4356endif
4457TARGET =-o $(TITLE )
45- COMPILE =$(CC ) $(FLAGS ) $(SOURCE ) $(LIBS ) $(EXTRA_LIBS )
58+ COMPILE =$(CC ) $(FLAGS ) $(CPPFLAGS ) $( SOURCE ) $(LIBS ) $(EXTRA_LIBS )
4659# \
4760!endif
4861
@@ -81,6 +94,7 @@ mac: source/*
8194 cp $(TITLE ) mac/$(TITLE ) .app/Contents/Resources/
8295 cp -r assets mac/$(TITLE ) .app/Contents/Resources/
8396 find /usr/local/Cellar -type f -iname " *sdl2*.dylib" -exec cp {} mac/$(TITLE ) .app/Contents/Resources/ \;
97+ find /opt/homebrew/Cellar -type f -iname " *sdl2*.dylib" -exec cp {} mac/$(TITLE ) .app/Contents/Resources/ \;
8498 zip -r $(TITLE ) .mac.zip mac/$(TITLE ) .app
8599windows : source/*
86100 copy $(TITLE ) .exe windows\ &
0 commit comments