forked from msokalski/asciicker
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile_game_mac
176 lines (134 loc) · 3.63 KB
/
makefile_game_mac
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# VAR := expands during assignment
# VAR = expands when referenced
# output binary
BIN := .run/game
# LDLIBS := -lutil
SRCS := gl.c \
gl45_emu.cpp \
x11.cpp \
sdl.cpp \
term.cpp \
font1.cpp \
gamepad.cpp \
game.cpp \
mainmenu.cpp \
game_api.cpp \
enemygen.cpp \
game_app.cpp \
network.cpp \
render.cpp \
terrain.cpp \
world.cpp \
inventory.cpp \
physics.cpp \
sprite.cpp \
upng.c \
tinfl.c \
rgba8.cpp \
audio.cpp \
stb_vorbis.cpp
LDLIBS := -lv8 -lv8_libbase -lv8_libplatform -lutil -framework OpenGL -lSDL2-2.0.0
# files included in the tarball generated by 'make dist' (e.g. add LICENSE file)
DISTFILES := $(BIN)
# filename of the tar archive generated by 'make dist'
DISTOUTPUT := $(BIN).tar.gz
# intermediate directory for generated object files
OBJDIR := .o_game
# intermediate directory for generated dependency files
DEPDIR := .d_game
# object files, auto generated from sourcce files
OBJS := $(patsubst %,$(OBJDIR)/%.o,$(basename $(SRCS)))
# dependency files, auto generated from source files
DEPS := $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS)))
# compilers (at least gcc and clang) don't create the subdirectories automatically
$(shell mkdir -p $(dir $(OBJS)) >/dev/null)
$(shell mkdir -p $(dir $(DEPS)) >/dev/null)
# C compiler
CC := gcc
# C++ compiler
CXX := g++
# linker
LD := g++
# tar
TAR := tar
# C flags
CFLAGS :=
# C++ flags
CXXFLAGS := -std=c++17 -O3
# C/C++ flags
CPPFLAGS := -save-temps=obj -pthread -DGAME -O3 -DUSE_SDL
# CPPFLAGS := -g -save-temps=obj -pthread -DGAME -O3
# CPPFLAGS := -g -save-temps=obj -pthread -DGAME
# CPPFLAGS := -g -save-temps=obj -pthread -DGAME -fsanitize=address
# linker flags
LDFLAGS := -save-temps=obj -pthread -O3 \
-framework Audiotoolbox -framework CoreAudio -framework CoreServices
# LDFLAGS := -g -save-temps=obj -pthread -O3
# LDFLAGS := -g -save-temps=obj -pthread
# LDFLAGS := -g -save-temps=obj -pthread -fsanitize=address
# flags required for dependency generation; passed to compilers
DEPFLAGS = -MT $@ -MD -MP -MF $(DEPDIR)/$*.Td
# compile C source files
COMPILE.c = $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) -c -o $@
# compile C++ source files
COMPILE.cc = $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -o $@
# link object files to binary
LINK.o = $(LD) $(LDFLAGS) -o $@
# precompile step
PRECOMPILE =
# postcompile step
POSTCOMPILE = mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d
all: $(BIN)
dist: $(DISTFILES)
@$(TAR) -cvzf $(DISTOUTPUT) $^
# $(BUILD)
.PHONY: clean
clean:
@$(RM) -r $(OBJDIR) $(DEPDIR)
# $(BUILD)
.PHONY: distclean
distclean: clean
@$(RM) $(BIN) $(DISTOUTPUT)
# $(BUILD)
.PHONY: install
install:
@echo no install tasks configured
.PHONY: uninstall
uninstall:
@echo no uninstall tasks configured
.PHONY: check
check:
@echo no tests configured
.PHONY: help
help:
@echo available targets: all dist clean distclean install uninstall check
$(BIN): $(OBJS)
@echo Linking: $(BIN)
@$(LINK.o) $^ $(LDLIBS)
$(OBJDIR)/%.o: %.c
$(OBJDIR)/%.o: %.c $(DEPDIR)/%.d
@echo Comiling $<
@$(PRECOMPILE)
@$(COMPILE.c) $<
@$(POSTCOMPILE)
$(OBJDIR)/%.o: %.cpp
$(OBJDIR)/%.o: %.cpp $(DEPDIR)/%.d
@echo Comiling $<
@$(PRECOMPILE)
@$(COMPILE.cc) $<
@$(POSTCOMPILE)
$(OBJDIR)/%.o: %.cc
$(OBJDIR)/%.o: %.cc $(DEPDIR)/%.d
@echo Comiling $<
@$(PRECOMPILE)
@$(COMPILE.cc) $<
@$(POSTCOMPILE)
$(OBJDIR)/%.o: %.cxx
$(OBJDIR)/%.o: %.cxx $(DEPDIR)/%.d
@echo Comiling $<
@$(PRECOMPILE)
@$(COMPILE.cc) $<
@$(POSTCOMPILE)
.PRECIOUS = $(DEPDIR)/%.d
$(DEPDIR)/%.d: ;
-include $(DEPS)