-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (52 loc) · 1.45 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
# COLORS #
_RED = \e[31m
_GREEN = \e[32m
_YELLOW = \e[33m
_BLUE = \e[34m
_END = \e[0m
# COMPILATION #
CC_FLAGS = -Wall -Wextra -Werror -fno-builtin
# DIRECTORIES #
DIR_HEADERS = ./includes/
DIR_SRCS = ./srcs/
DIR_OBJS = ./compiled_srcs/
# FILES #
SRCS = ft_malcolm.c \
args.c \
network.c \
logs.c \
utils.c
INCLUDES = ft_malcolm.h
# COMPILED_SOURCES #
OBJS = $(SRCS:%.c=$(DIR_OBJS)%.o)
NAME = ft_malcolm
ifeq ($(BUILD),debug)
CC_FLAGS += -DDEBUG -g3 -fsanitize=address
DIR_OBJS = ./debug-compiled_srcs/
NAME = ./debug-ft_malcolm
endif
## RULES ##
all: $(NAME)
# VARIABLES RULES #
$(NAME): $(OBJS) $(addprefix $(DIR_HEADERS), $(INCLUDES))
@printf "\033[2K\r$(_BLUE) All files compiled into '$(DIR_OBJS)'. $(_END)✅\n"
@gcc $(CC_FLAGS) -I $(DIR_HEADERS) $(OBJS) -o $(NAME)
@printf "\033[2K\r$(_GREEN) Executable '$(NAME)' created. $(_END)✅\n"
# COMPILED_SOURCES RULES #
$(OBJS): | $(DIR_OBJS)
$(DIR_OBJS)%.o: $(DIR_SRCS)%.c
@printf "\033[2K\r $(_YELLOW)Compiling $< $(_END)⌛ "
@gcc $(CC_FLAGS) -I $(DIR_HEADERS) -c $< -o $@
$(DIR_OBJS):
@mkdir -p $(DIR_OBJS)
# MANDATORY PART #
clean:
@rm -rf $(DIR_OBJS)
@printf "\033[2K\r$(_RED) '"$(DIR_OBJS)"' has been deleted. $(_END)🗑️\n"
fclean: clean
@rm -rf $(NAME)
@printf "\033[2K\r$(_RED) '"$(NAME)"' has been deleted. $(_END)🗑️\n"
re: fclean
@$(MAKE) --no-print-directory
# PHONY #
.PHONY: all clean fclean re