forked from msokalski/asciicker
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile_server
161 lines (122 loc) · 3.27 KB
/
makefile_server
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
# VAR := expands during assignment
# VAR = expands when referenced
# output binary
BIN := .run/server
SRCS := game_svr.cpp \
audio.cpp \
stb_vorbis.cpp \
network.cpp \
sha1.c \
font1.cpp \
gamepad.cpp \
game.cpp \
enemygen.cpp \
render.cpp \
terrain.cpp \
world.cpp \
inventory.cpp \
physics.cpp \
sprite.cpp \
tinfl.c \
LDLIBS := -lutil -pthread -lpulse
# 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_server
# intermediate directory for generated dependency files
DEPDIR := .d_server
# 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
# C/C++ flags
CPPFLAGS := -save-temps=obj -pthread -DSERVER -O3
# CPPFLAGS := -g -save-temps=obj -pthread -DSERVER -O3
# CPPFLAGS := -g -save-temps=obj -pthread -DSERVER -fsanitize=address
# linker flags
LDFLAGS := -save-temps=obj -pthread -O3
# LDFLAGS := -g -save-temps=obj -pthread -O3
# 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)