-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
104 lines (70 loc) · 2.23 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
#-------------------------------------------------------------
#Assume-se uma distribuição Linux como sistema operacional padrão
#-------------------------------------------------------------
COMPILER = g++
#comando para remover pastas
RMDIR = rm -rf
#comando para remover arquivos
RM = rm -f
#Flags para geração automática de dependências
DEP_FLAGS = -MT $@ -MMD -MP -MF $(DEP_PATH)/$.d
LIBS = -LC:/TDM-GCC-64/include/SDL2/bin -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lm
FLAGS= -std=c++11 -Wall -pedantic -fdiagnostics-color
#FLAGS= -std=c++11 -Wall -pedantic -Wextra -fmax-errors=5
INC_PATH = -Iinclude
SRC_PATH = src
BIN_PATH = bin
DEP_PATH = dep
#Uma lista de arquivos por extensão:
CPP_FILES= $(wildcard $(SRC_PATH)/*.cpp)
OBJ_FILES= $(addprefix $(BIN_PATH)/,$(notdir $(CPP_FILES:.cpp=.o)))
DEP_FILES = $(wildcard $(DEP_PATH)/*.d)
#Nome do executável
EXEC = JOGO
#-------------------------------------------------------------
#Caso o sistema seja windows
#-------------------------------------------------------------
ifeq ($(OS),Windows_NT)
#comando para remover um diretório recursivamente
RMDIR= rd /s /q
#comando para deletar um único arquivo
RM = del
#path da SDL
SDL_PATH = C:/Tools/msys64/mingw64
INC_PATH += -I$(SDL_PATH)/include/SDL2
FLAGS = -mwindows
LIBS := -lmingw32 -lSDL2main $(LIBS)
#Nome do executável
EXEC := $(EXEC).exe
else
UNAME_S := $(shell uname -s)
#-------------------------------------------------------------
#Caso o sistema seja Mac
#-------------------------------------------------------------
ifeq ($(UNAME_S), Darwin)
LIBS = -lm -framework SDL2 -framework SDL2_image -framework SDL2_mixer -framework SDL2_ttf
endif
endif
all: $(EXEC)
$(EXEC): $(OBJ_FILES)
$(COMPILER) -o $@ $^ $(LIBS)
$(BIN_PATH)/%.o: $(SRC_PATH)/%.cpp
ifeq ($(OS), Windows_NT)
@if not exist $(DEP_PATH) @ mkdir $(DEP_PATH)
@if not exist $(BIN_PATH) @ mkdir $(BIN_PATH)
else
@mkdir -p $(DEP_PATH) $(BIN_PATH)
endif
$(COMPILER) $(DEP_FLAGS) -c -o $@ $< $(INC_PATH) $(FLAGS)
-include $(DEP_FILES)
clean:
$(RMDIR) $(BIN_PATH) $(DEP_PATH)
$(RM) $(EXEC)
clear
.PHONY: debug clean release again
#regra pra debug
print-% : ; @echo $* = $($*)
debug: FLAGS += -g -O0
debug: all
release: FLAGS += -O3 -mtune=native
release: all