This repository has been archived by the owner on Oct 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
112 lines (95 loc) · 2.81 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
##
## EPITECH PROJECT, 2018
## Makefile
## File description:
## compile
##
ECHO = /bin/echo -e
DEFAULT = "\e[0m"
BOLD_T = "\e[1m"
DIM_T = "\e[2m"
UNDLN_T = "\e[4m"
BLACK_C = "\e[30m"
RED_C = "\e[31m"
GREEN_C = "\e[32m"
YELLO_C = "\e[33m"
BLUE_C = "\e[34m"
MAGEN_C = "\e[35m"
CYAN_C = "\e[36m"
WHITE_C = "\e[97m"
DEFAULT_C = "\e[39m"
LIGHT_GREY = "\e[37m"
DARK_GREY = "\e[90m"
LIGHT_RED = "\e[91m"
LIGHT_GREEN = "\e[92m"
LIGHT_YELLO = "\e[93m"
LIGHT_BLUE = "\e[94m"
LIGHT_MAGEN = "\e[95m"
LIGHT_CYAN = "\e[96m"
LINE_RETURN = $(ECHO) ""
NAME = trade
COLOR_THEME = $(WHITE_C)
ROOT_PATH = ./
SRC_NAME = src
INCL_NAME = include
INCL_PATH = $(ROOT_PATH)$(INCL_NAME)
SRC_PATH = $(ROOT_PATH)$(SRC_NAME)
SRC = Trade.cpp
SRCS = $(SRC:%=$(SRC_PATH)/%)
OBJ = $(SRCS:.cpp=.o)
SRC_MAIN = src/main.cpp
OBJ_MAIN = $(SRC_MAIN:.cpp=.o)
CC = g++
CFLAGS = -ldl -I $(INCL_PATH)\
DEBUG_FLAGS = -g3 -gdwarf-4
MAKE_RULE = all
CLEAN_RULE = clean
all: message $(NAME)
message:
@$(LINE_RETURN)
@$(ECHO) $(BOLD_T)$(COLOR_THEME)" ____ _ _ _"$(DEFAULT)
@$(ECHO) $(BOLD_T)$(COLOR_THEME)"| __ ) _ _(_) | __| |"$(DEFAULT)
@$(ECHO) $(BOLD_T)$(COLOR_THEME)"| _ \| | | | | |/ _\` |"$(DEFAULT)
@$(ECHO) $(BOLD_T)$(COLOR_THEME)"| |_) | |_| | | | (_| |"$(DEFAULT)
@$(ECHO) $(BOLD_T)$(COLOR_THEME)"|____/ \__,_|_|_|\__,_|"$(DEFAULT)
@$(LINE_RETURN)
$(NAME): $(OBJ) $(OBJ_MAIN)
@$(CC) -o $(NAME) $(OBJ) $(OBJ_MAIN) $(CFLAGS) && \
$(ECHO) $(BOLD_T)$(GREEN_C)"\n[✔] COMPILED:" $(DEFAULT)$(LIGHT_GREEN) "$(NAME)\n"$(DEFAULT) || \
$(ECHO) $(RED_C)$(BOLD_T)"[✘] "$(UNDLN_T)"BUILD FAILED:" $(LIGHT_RED) "$(NAME)\n"$(DEFAULT)
clean:
@$(RM) $(OBJ)
@$(RM) $(OBJ_MAIN)
@$(RM) $(OBJ_TEST)
@$(ECHO) $(RED_C)$(DIM_T)"[clean] "$(DEFAULT) \
$(RED_C)$(BOLD_T)"DELETED: "$(DEFAULT) \
$(LIGHT_RED)"$(NAME)'s object files"$(DEFAULT)
@$(RM) vgcore.*
@$(ECHO) $(RED_C)$(DIM_T)"[clean] "$(DEFAULT) \
$(RED_C)$(BOLD_T)"DELETED: "$(DEFAULT) \
$(LIGHT_RED)"Valgrind files"$(DEFAULT)
@$(RM) tests/*.gcno
@$(RM) tests/*.gcda
@$(RM) src/*.gcno
@$(RM) src/*.gcda
@$(ECHO) $(RED_C)$(DIM_T)"[clean] "$(DEFAULT) \
$(RED_C)$(BOLD_T)"DELETED: "$(DEFAULT) \
$(LIGHT_RED)"Tests files"$(DEFAULT)
fclean: CLEAN_RULE=fclean
fclean: clean
@$(RM) $(NAME)
@$(RM) unit_tests
@$(ECHO) $(RED_C)$(DIM_T)"[fclean] "$(DEFAULT) \
$(RED_C)$(BOLD_T)"DELETED: "$(DEFAULT) \
$(LIGHT_RED)"Binary $(NAME)"$(DEFAULT)
re: fclean all
debug: CFLAGS += $(DEBUG_FLAGS)
debug: COLOR_THEME = $(CYAN_C)
debug: MAKE_RULE = debug
debug: re
@$(ECHO) $(BOLD_T)$(COLOR_THEME)"⚠ DEBUG MODE ACTIVATED ⚠\n"$(DEFAULT)
%.o: %.cpp
@$(CC) -c $(CFLAGS) -o $@ $< && \
$(ECHO) $(DIM_T) "cc $(CFLAGS) -c "$<$(COLOR_THEME)$(BOLD_T)" -o "$@ $(DEFAULT) || \
$(ECHO) "\n"$(MAGEN_C) $(UNDLN_T)$(BOLD_T)"cc $(CFLAGS) -c "$<" -o "$@$(DEFAULT)"\n"
.PHONY: all message clean fclean re debug