-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
81 lines (55 loc) · 2.47 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
CXX = g++
CXXFLAGS = -std=c++17 -O2 -pedantic -Wall -Wextra -Werror
LDFLAGS = -lexpat -lsfml-network -lsfml-system -lsfml-window -lsfml-graphics -lpthread -lcppunit
INC = -Inetwork -Imodel -Iui -Icontroller -Iai
OBJDIR = obj
MAIN = main
MAIN_TEST_MODEL = main_test_model
SRCDIR_MODEL = model
SRCDIR_NETWORK = network
SRCDIR_UI = ui
SRCDIR_CONTROLLER = controller
SRCDIR_AI = ai
SRCDIR_TEST_MODEL = test_model
OBJECTS_MODEL = $(patsubst $(SRCDIR_MODEL)/%.cpp,$(OBJDIR)/%.o,$(wildcard $(SRCDIR_MODEL)/*.cpp))
OBJECTS_NETWORK = $(patsubst $(SRCDIR_NETWORK)/%.cpp,$(OBJDIR)/%.o,$(wildcard $(SRCDIR_NETWORK)/*.cpp))
OBJECTS_UI = $(patsubst $(SRCDIR_UI)/%.cpp,$(OBJDIR)/%.o,$(wildcard $(SRCDIR_UI)/*.cpp))
OBJECTS_CONTROLLER = $(patsubst $(SRCDIR_CONTROLLER)/%.cpp,$(OBJDIR)/%.o,$(wildcard $(SRCDIR_CONTROLLER)/*.cpp))
OBJECTS_AI = $(patsubst $(SRCDIR_AI)/%.cpp,$(OBJDIR)/%.o,$(wildcard $(SRCDIR_AI)/*.cpp))
OBJECTS_TEST_MODEL = $(patsubst $(SRCDIR_TEST_MODEL)/%.cpp,$(OBJDIR)/%.o,$(wildcard $(SRCDIR_TEST_MODEL)/*.cpp))
EXE = game
TEST = test
all: $(EXE)
$(EXE): model network ui controller ai $(MAIN)
$(CXX) $(OBJECTS_MODEL) $(OBJECTS_NETWORK) $(OBJECTS_UI) $(OBJECTS_CONTROLLER) $(OBJECTS_AI) $(OBJDIR)/$(MAIN).o -o $(EXE) $(LDFLAGS)
$(TEST): $(MAIN_TEST_MODEL) model test_model
$(CXX) $(OBJECTS_MODEL) $(OBJECTS_TEST_MODEL) $(OBJDIR)/$(MAIN_TEST_MODEL).o -o $(TEST) $(LDFLAGS)
model: $(OBJDIR) $(OBJECTS_MODEL)
network: $(OBJDIR) $(OBJECTS_NETWORK)
ui: $(OBJDIR) $(OBJECTS_UI)
controller: $(OBJDIR) $(OBJECTS_CONTROLLER)
ai: $(OBJDIR) $(OBJECTS_AI)
test_model: $(OBJDIR) $(OBJECTS_TEST_MODEL)
$(MAIN): $(OBJDIR) $(OBJDIR)/$(MAIN).o
$(MAIN_TEST_MODEL): $(OBJDIR) $(OBJDIR)/$(MAIN_TEST_MODEL).o
$(OBJDIR)/%.o: $(SRCDIR_MODEL)/%.cpp
$(CXX) $(CXXFLAGS) $(INC) -c -MMD -o $@ $<
$(OBJDIR)/%.o: $(SRCDIR_NETWORK)/%.cpp
$(CXX) $(CXXFLAGS) $(INC) -c -MMD -o $@ $<
$(OBJDIR)/%.o: $(SRCDIR_UI)/%.cpp
$(CXX) $(CXXFLAGS) $(INC) -c -MMD -o $@ $<
$(OBJDIR)/%.o: $(SRCDIR_CONTROLLER)/%.cpp
$(CXX) $(CXXFLAGS) $(INC) -c -MMD -o $@ $<
$(OBJDIR)/%.o: $(SRCDIR_AI)/%.cpp
$(CXX) $(CXXFLAGS) $(INC) -c -MMD -o $@ $<
$(OBJDIR)/%.o: $(SRCDIR_TEST_MODEL)/%.cpp
$(CXX) $(CXXFLAGS) $(INC) -c -MMD -o $@ $<
$(OBJDIR)/$(MAIN).o: $(MAIN).cpp
$(CXX) $(CXXFLAGS) $(INC) -c -MMD -o $@ $<
$(OBJDIR)/$(MAIN_TEST_MODEL).o: $(MAIN_TEST_MODEL).cpp
$(CXX) $(CXXFLAGS) $(INC) -c -MMD -o $@ $<
$(OBJDIR):
mkdir -p $(OBJDIR)
clean:
rm -rf $(OBJDIR) $(EXE) $(TEST)
.PHONY: all clean model network ui ai test_model $(MAIN) $(MAIN_TEST_MODEL)