forked from krystiankaluzny/Tanks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
78 lines (61 loc) · 1.79 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
PROJECT_NAME = Tanks
BUILD = build
BIN = $(BUILD)/bin
RESOURCES_DIR = resources
ifeq ($(OS),Windows_NT)
CC = $(MINGW_HOME)/bin/mingw32-g++.exe
INCLUDEPATH = -I$(RESOURCES_DIR)/SDL/i686-w64-mingw32/include
LFLAGS = -mwindows -O
CFLAGS = -c -Wall
LIBS = -L$(RESOURCES_DIR)/SDL/i686-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf
APP_RESOURCES = SDL/i686-w64-mingw32/bin/*.dll dll/*.dll font/prstartk.ttf png/texture.png levels
RESOURCES = $(APP_RESOURCES) mingw_resources
else
CC = g++
INCLUDEPATH =
LFLAGS = -O
CFLAGS = -c -Wall -std=c++11
LIBS = -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf
APP_RESOURCES = font/prstartk.ttf png/texture.png levels
RESOURCES = $(APP_RESOURCES)
endif
MODULES = engine app_state objects
SRC_DIRS = src $(addprefix src/,$(MODULES))
BUILD_DIRS = $(BUILD) $(BIN) $(addprefix $(BUILD)/,$(MODULES))
SOURCES = $(foreach sdir,$(SRC_DIRS),$(wildcard $(sdir)/*.cpp))
OBJS = $(patsubst src/%.cpp,$(BUILD)/%.o,$(SOURCES))
vpath %.cpp $(SRC_DIRS)
all: print $(BUILD_DIRS) $(RESOURCES) compile
print:
@echo
@echo OS: $(OS)
@echo MODULES: $(MODULES)
@echo SRC_DIRS: $(SRC_DIRS)
@echo BUILD_DIRS: $(BUILD_DIRS)
@echo SOURCES: $(SOURCES)
@echo RESOURCES: $(RESOURCES)
@echo OBJS: $(OBJS)
@echo INCLUDEPATH: $(INCLUDEPATH)
@echo LIBSPATH: $(LIBSPATH)
@echo LIBS: $(LIBS)
@echo LFLAGS: $(LFLAGS)
@echo
$(BUILD_DIRS):
mkdir -p $@
compile: $(OBJS)
$(CC) $(OBJS) $(INCLUDEPATH) $(LIBSPATH) $(LIBS) $(LFLAGS) -o $(BIN)/$(PROJECT_NAME)
build/%.o: src/%.cpp
$(CC) $(CFLAGS) $(INCLUDEPATH) $< -o $@
$(APP_RESOURCES):
cp -R $(RESOURCES_DIR)/$@ $(BIN)
ifeq ($(OS),Windows_NT)
mingw_resources:
cp $(MINGW_HOME)/bin/libstdc++-6.dll $(BIN)
cp $(MINGW_HOME)/bin/libgcc_s_dw2-1.dll $(BIN)
endif
clean:
rm -rf $(BUILD)
rm -rf doc
doc:
doxywizard Doxyfile
doxygen