Skip to content

Commit 8d88759

Browse files
committed
Add fixes for Mac OS compilation.
Signed-off-by: Ryan McQuen <rpcm@linux.com>
1 parent 9af6191 commit 8d88759

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

Makefile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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`
3939
SOURCE=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+
4053
LIBS='-Wl,-rpath,$$ORIGIN' $(SDL2_FLAGS) -l SDL2_image -l SDL2_mixer -l SDL2_ttf
4154
ifeq ($(origin EXTRA_LIBS), default)
4255
EXTRA_LIBS=
4356
endif
4457
TARGET=-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
8599
windows: source/*
86100
copy $(TITLE).exe windows\ &

0 commit comments

Comments
 (0)