This repository has been archived by the owner on Nov 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
77 lines (61 loc) · 2.11 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
## ============= AVISO ============= ##
## Isso aqui foi gerado usando IA, ok?
## ================================= ##
FLAGS = -g -Wall -Wextra -pedantic -Iinclude
SFML_FLAGS = -lsfml-graphics -lsfml-window -lsfml-audio -lsfml-system
LINUX_FLAGS = -lFLAC -lfreetype -logg -lopenal -lvorbis -lvorbisenc -lvorbisfile
SRC_DIR = src
BUILD_DIR = _build
RELEASE_DIR = _release
TEST_DIR = tests
SRC_FILES = $(wildcard $(SRC_DIR)/**/*.cpp)
OBJ_FILES = $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(SRC_FILES))
OBJ_FILES += $(BUILD_DIR)/main.o
OBJ_FILES_WITHOUT_MAIN = $(filter-out $(BUILD_DIR)/main.o, $(OBJ_FILES))
TEST_SRC_FILES = $(wildcard $(TEST_DIR)/*.cpp)
TEST_OBJ_FILES = $(patsubst $(TEST_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(TEST_SRC_FILES))
ifeq ($(OS),Windows_NT)
EXEC = $(RELEASE_DIR)\bin\main.exe
TEST_EXEC = $(RELEASE_DIR)\bin\tests.exe
ENV = set LD_LIBRARY_PATH=$(RELEASE_DIR)/lib
MKDIR = if not exist $(subst /,\,$(dir $@)) mkdir $(subst /,\,$(dir $@))
RM = del /q /f
RMDIR = rmdir /q /s
else
EXEC = $(RELEASE_DIR)/bin/main
TEST_EXEC = $(RELEASE_DIR)/bin/tests
ENV = export LD_LIBRARY_PATH=$(RELEASE_DIR)/lib
MKDIR = mkdir -p $(dir $@)
RM = rm -f
RMDIR = rm -rf
SFML_FLAGS += $(LINUX_FLAGS)
endif
all: $(EXEC) $(TEST_EXEC)
valgrind: $(EXEC)
$(ENV) && valgrind --suppressions=./suppressions.supp --leak-check=full --show-leak-kinds=definite,possible --track-origins=yes --log-file=valgrind.log $(EXEC)
run: $(EXEC)
$(ENV) && $(EXEC)
dev: $(EXEC)
$(ENV) && $(EXEC)
compile: $(OBJ_FILES)
g++ -o $(EXEC) $^ -L$(RELEASE_DIR)/lib $(SFML_FLAGS)
test: $(TEST_EXEC)
$(ENV) && $(TEST_EXEC)
$(EXEC): $(OBJ_FILES)
g++ -o $@ $^ -L$(RELEASE_DIR)/lib $(SFML_FLAGS)
$(TEST_EXEC): $(TEST_OBJ_FILES) $(OBJ_FILES_WITHOUT_MAIN)
g++ -o $@ $^ -L$(RELEASE_DIR)/lib -lgtest -lgtest_main -lgmock -lgmock_main -pthread $(SFML_FLAGS)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
$(MKDIR)
g++ $(FLAGS) -c $< -o $@
$(BUILD_DIR)/%.o: $(TEST_DIR)/%.cpp
$(MKDIR)
g++ $(FLAGS) -c $< -o $@
$(BUILD_DIR)/main.o: main.cpp
$(MKDIR)
g++ $(FLAGS) -c $< -o $@
clean:
@$(RMDIR) $(BUILD_DIR)
@$(RM) $(EXEC)
@$(RM) $(TEST_EXEC)
.PHONY: all valgrind run dev compile test clean