forked from tmewett/BrogueCE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (85 loc) · 2.75 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
include config.mk
cflags := -Isrc/brogue -Isrc/platform -std=c99 \
-Wall -Wpedantic -Werror=implicit -Wno-parentheses -Wno-unused-result \
-Wformat -Werror=format-security -Wformat-overflow=0 -Wformat-truncation=0
libs := -lm
cppflags := -DDATADIR=$(DATADIR)
sources := $(wildcard src/brogue/*.c) $(addprefix src/platform/,main.c platformdependent.c)
ifeq ($(RELEASE),YES)
extra_version :=
else
extra_version := $(shell bash tools/git-extra-version)
endif
cppflags += -DBROGUE_EXTRA_VERSION='"$(extra_version)"'
ifeq ($(TERMINAL),YES)
sources += $(addprefix src/platform/,curses-platform.c term.c)
cppflags += -DBROGUE_CURSES
libs += -lncurses
endif
ifeq ($(GRAPHICS),YES)
sources += $(addprefix src/platform/,sdl2-platform.c tiles.c)
cflags += $(shell $(SDL_CONFIG) --cflags)
cppflags += -DBROGUE_SDL
libs += $(shell $(SDL_CONFIG) --libs) -lSDL2_image
endif
ifeq ($(WEBBROGUE),YES)
sources += $(addprefix src/platform/,web-platform.c)
cppflags += -DBROGUE_WEB
endif
ifeq ($(MAC_APP),YES)
cppflags += -DSDL_PATHS
endif
ifeq ($(DEBUG),YES)
cflags += -g -Og
cppflags += -DENABLE_PLAYBACK_SWITCH
else
cflags += -O2
endif
objects := $(sources:.c=.o)
.PHONY: clean
%.o: %.c src/brogue/Rogue.h src/brogue/IncludeGlobals.h
$(CC) $(cppflags) $(CPPFLAGS) $(cflags) $(CFLAGS) -c $< -o $@
bin/brogue: $(objects)
$(CC) $(cflags) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(libs) $(LDLIBS)
windows/icon.o: windows/icon.rc
windres $< $@
bin/brogue.exe: $(objects) windows/icon.o
$(CC) $(cflags) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(libs) $(LDLIBS)
mt -manifest windows/brogue.exe.manifest '-outputresource:bin/brogue.exe;1'
clean:
$(RM) src/brogue/*.o src/platform/*.o windows/icon.o bin/brogue{,.exe}
# Release archives
common_bin := bin/assets bin/keymap.txt
define make_release_base
mkdir $@
cp README.md $@/README.txt
cp CHANGELOG.md $@/CHANGELOG.txt
cp LICENSE.txt $@
endef
# Flatten bin/ in the Windows archive
BrogueCE-windows: bin/brogue.exe
$(make_release_base)
cp -r $(common_bin) bin/{brogue.exe,brogue-cmd.bat} $@
BrogueCE-macos: Brogue.app
$(make_release_base)
cp -r Brogue.app $@/"Brogue CE.app"
BrogueCE-linux: bin/brogue
$(make_release_base)
cp brogue $@
cp -r --parents $(common_bin) bin/brogue $@
cp linux/make-link-for-desktop.sh $@
# macOS app bundle
# $* is the matched %
icon_%.png: bin/assets/icon.png
convert $< -resize $* $@
macos/Brogue.icns: icon_32.png icon_128.png icon_256.png icon_512.png
png2icns $@ $^
$(RM) $^
Brogue.app: bin/brogue
mkdir -p $@/Contents/{MacOS,Resources}
cp macos/Info.plist $@/Contents
cp bin/brogue $@/Contents/MacOS
cp -r macos/Brogue.icns bin/assets $@/Contents/Resources
macos/sdl2.rb:
curl -L 'https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/sdl2.rb' >$@
patch $@ macos/sdl2-deployment-target.patch