-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (49 loc) · 1.25 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
SHELL=/bin/bash
# COLORS #
_RED = \e[31m
_GREEN = \e[32m
_YELLOW = \e[33m
_BLUE = \e[34m
_END = \e[0m
# COMPILATION #
FLAGS = -f elf64
# DIRECTORIES #
DIR_SRCS = ./srcs/
DIR_INCLUDES = ./includes/
DIR_OBJS = ./compiled_srcs/
# FILES #
SRCS = death.s
NAME = Death
ifeq ($(BUILD),debug)
FLAGS += -DDEBUG
DIR_OBJS = ./debug-compiled_srcs/
NAME = ./debug-Death
endif
# COMPILED_SOURCES #
OBJS = $(SRCS:%.s=$(DIR_OBJS)%.o)
## RULES ##
all: $(NAME)
fsociety: FLAGS += -DFSOCIETY
fsociety: all
# VARIABLES RULES #
$(NAME): $(OBJS)
@printf "\033[2K\r$(_BLUE) All files compiled into '$(DIR_OBJS)'. $(_END)✅\n"
@ld -s -o $@ $^
@printf "\033[2K\r$(_GREEN) Executable '$(NAME)' created. $(_END)✅\n"
# COMPILED_SOURCES RULES #
$(OBJS): | $(DIR_OBJS)
$(DIR_OBJS)%.o: $(DIR_SRCS)%.s
@printf "\033[2K\r $(_YELLOW)Compiling $< $(_END)⌛ "
@nasm $(FLAGS) -I $(DIR_INCLUDES) -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 all
# PHONY #
.PHONY: all clean fclean re