-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (50 loc) · 1.56 KB
/
Makefile
File metadata and controls
71 lines (50 loc) · 1.56 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
# ---------- BINARY/LIB NAMES ----------
NAME = libasm.a
TEST_NAME = test_mandatory
TEST_NAME_BONUS = test_bonus
# ---------- COMPILATION ----------
C_COMPIL = cc
C_OPT = -Wall -Werror -Wextra
c_DEBUG = -g
ASM_COMPIL = nasm
ASM_OPT = -f elf64
ASM_DEBUG = -g -F dwarf
# ---------- OBJ DIR ----------
OBJDIR = obj
# ---------- SRC DIR ----------
TEST_SRC = test/test_mandatory.c
TEST_SRC_BONUS = test/test_bonus.c
SRC = ft_read.s ft_strcmp.s ft_strcpy.s ft_strdup.s ft_strlen.s ft_write.s
SRC_BONUS = ft_atoi_base_bonus.s ft_list_push_front_bonus.s \
ft_list_remove_if_bonus.s ft_list_size_bonus.s ft_list_sort_bonus.s
# ---------- OBJ NAMES ----------
OBJ = $(patsubst %.s,$(OBJDIR)/%.o,$(SRC))
OBJ_BONUS = $(patsubst %.s,$(OBJDIR)/%.o,$(SRC_BONUS))
DEBUG_OBJ = $(patsubst %.s,$(OBJDIR)/debug_%.o,$(SRC))
DEBUG_OBJ_BONUS = $(patsubst %.s,$(OBJDIR)/debug_%.o,$(SRC_BONUS))
# ---------- RULES ----------
all: $(NAME)
$(NAME): $(OBJ)
ar rcs $(NAME) $^
bonus: $(OBJ) $(OBJ_BONUS)
ar rcs $(NAME) $^
$(OBJDIR)/%.o: %.s
mkdir -p $(OBJDIR)
$(ASM_COMPIL) $(ASM_OPT) $< -o $@
$(OBJDIR)/debug_%.o: %.s
mkdir -p $(OBJDIR)
$(ASM_COMPIL) $(ASM_OPT) $(ASM_DEBUG) $< -o $@
debug: $(DEBUG_OBJ)
ar rcs $(NAME) $^
debug_bonus: $(DEBUG_OBJ) $(DEBUG_OBJ_BONUS)
ar rcs $(NAME) $^
test: all
$(C_COMPIL) $(C_OPT) $(TEST_SRC) $(NAME) -o $(TEST_NAME)
test_bonus: bonus
$(C_COMPIL) $(C_OPT) $(TEST_SRC_BONUS) $(NAME) -o $(TEST_NAME_BONUS)
clean:
rm -rf $(OBJDIR)
fclean: clean
rm -f $(NAME) $(TEST_NAME) $(TEST_NAME_BONUS)
re: fclean all
.PHONY: all bonus test test_bonus clean fclean re