This repository was archived by the owner on Aug 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
151 lines (123 loc) · 4.36 KB
/
Makefile
File metadata and controls
151 lines (123 loc) · 4.36 KB
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
##
## EPITECH PROJECT, 2023
## abstractVM [WSL: Manjaro]
## File description:
## Makefile
##
# NAME: Name of the executable
NAME = abstractVM
# CC: Compiler
CC = g++
# SRC: Source files
SRC = $(wildcard src/*.cpp) \
$(wildcard src/utils/*.cpp)
# OBJ: Object files
OBJ = $(SRC:src/%.cpp=$(BUILDDIR)/%.o)
# TESTSRC: Source files for tests
TESTSRC = $(wildcard tests/*.cpp)
# TESTOBJ: Object files for tests
TESTOBJ = $(TESTSRC:tests/%.cpp=$(BUILDDIR)/%.o)
# BONUS: Source files for bonus
BONUS = $(wildcard bonus/*.cpp)
# BONUSOBJ: Object files for bonus
BONUSOBJ = $(BONUS:bonus/%.cpp=$(BUILDDIR)/bonus/%.o)
# BUILDDIR: Directory where object files will be stored
BUILDDIR = obj
# Create the build directory
$(BUILDDIR):
@mkdir -p $(BUILDDIR)
@mkdir -p $(BUILDDIR)/utils
@mkdir -p $(BUILDDIR)/bonus
# TESTDIR: Directory where tests files will be stored
TESTDIR = tests
# CFLAGS: Flags for the compiler
CFLAGS = -I ./include/ -I ./interfaces
CFLAGS += -Wall -Wextra -Werror -std=c++20
# Build rules
$(BUILDDIR)/%.o: src/%.cpp | $(BUILDDIR)
@$(CC) -o $@ -c $< $(CFLAGS)
@echo -e "\e[01m\e[33m Compiling...\
\e[00m\e[39m$<\e[032m [OK]\e[00m"
# Rules for make all
all: $(NAME)
# Rules for make
$(NAME): $(OBJ)
@$(CC) -o $(NAME) $(OBJ) $(CFLAGS)
@echo -e "\e[36;1m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\
\e[0m"
@echo -e "\e[36;1mIf you need help, use the command './$(NAME) -h'\
\e[0m"
@echo -e "\e[36;1m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\
\e[0m"
# Rules for make clean, fclean, re
clean:
@rm -rf $(BUILDDIR)
@find . -name "*.gcda" -delete
@find . -name "*.gcov" -delete
@find . -name "*.gcno" -delete
@rm -f ./unit_tests
@echo -e "\e[31;1mAll object files have been removed.\e[0m"
fclean: clean
@rm -f $(NAME)
@rm -rf html
@echo -e "\e[38;5;210m$(NAME)\e[0m\e[38;5;196m has been removed.\e[0m"
re: fclean all
@echo -e "\e[38;5;42m$(NAME)\e[0m\e[32;1m has been recompiled.\e[0m"
# Rules for make debug
debug: re
debug: CFLAGS += -g -fsanitize=address
# Rules for make debug_no_re
debug_no_re: CFLAGS += -g -fsanitize=address
debug_no_re: $(NAME)
# Rules for make tests_run
tests_compile: CFLAGS += -lcriterion --coverage -fprofile-abs-path
tests_compile: SRC := $(filter-out src/main.cpp, $(SRC))
tests_compile: $(TESTOBJ) $(OBJ)
@$(CC) -o unit_tests $(TESTOBJ) $(OBJ) $(CFLAGS)
# Build rules for tests
$(BUILDDIR)/%.o: tests/%.cpp | $(BUILDDIR)
@$(CC) -o $@ -c $< $(CFLAGS)
@echo -e "\e[01m\e[33m Compiling...\
\e[00m\e[39m$<\e[032m [OK]\e[00m"
# Rules for make tests_display
tests_display:
./unit_tests
# Rules for make tests_run
tests_run: tests_compile tests_display
# Rules for make cover
cover:
@gcovr ./obj/ --exclude tests --exclude src/main.cpp --exclude include \
--exclude interfaces
@gcovr ./obj/ --branches --exclude tests --exclude src/main.cpp --exclude include \
--exclude interfaces
@rm -f unit_tests*
# Rules for make htmlcover
htmlcover:
@mkdir -p html
@gcovr ./obj --html-details html/$(NAME).html $(FLAGS) \
--exclude src/main.cpp --exclude tests --exclude include \
--exclude interfaces
# Rules for make bonus
bonus: CFLAGS += -I ./bonus/include/ -lsfml-graphics -lsfml-window -lsfml-system
bonus: SRC := $(filter-out src/main.cpp, $(SRC))
bonus: $(BONUSOBJ) $(OBJ)
@$(CC) -o $(NAME) $(OBJ) $(BONUSOBJ) $(CFLAGS)
@echo -e "\e[36;1m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\
\e[0m"
@echo -e "\e[36;1mTo launch the program, type \e[32;1m./$(NAME)\e[36;1m\
\e[0m"
@echo -e "\e[36;1m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\
\e[0m"
# Build rules for bonus
$(BUILDDIR)/bonus/%.o: bonus/%.cpp | $(BUILDDIR)
@$(CC) -o $@ -c $< $(CFLAGS)
@echo -e "\e[01m\e[33m Compiling...\
\e[00m\e[39m$<\e[032m [OK]\e[00m"
# Rules for make bonus_re
bonus_re: fclean bonus
# Rules for make bonus_debug
bonus_debug: CFLAGS += -g -fsanitize=address
bonus_debug: bonus_re
# .PHONY: All rules
.PHONY: all clean fclean re debug debug_no_re tests_compile tests_display \
tests_run cover htmlcover