-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (53 loc) · 1.58 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
NAME = libasm.a
SRC_DIR = ./src
SRC = $(SRC_DIR)/ft_strlen.s \
$(SRC_DIR)/ft_strcpy.s \
$(SRC_DIR)/ft_strcmp.s \
$(SRC_DIR)/ft_write.s \
$(SRC_DIR)/ft_read.s \
$(SRC_DIR)/ft_strdup.s \
SRC_BONUS = $(SRC_DIR)/ft_atoi_base_bonus.s \
$(SRC_DIR)/ft_list_push_front_bonus.s \
$(SRC_DIR)/ft_list_size_bonus.s \
$(SRC_DIR)/ft_list_sort_bonus.s \
$(SRC_DIR)/ft_list_remove_if_bonus.s
OBJ_DIR = ./obj
OBJ = $(patsubst $(SRC_DIR)/%.s, $(OBJ_DIR)/%.o, $(SRC))
OBJ_BONUS = $(patsubst $(SRC_DIR)/%.s, $(OBJ_DIR)/%.o, $(SRC_BONUS))
TESTS_DIR = ./main_tests
SRC_TESTS = $(TESTS_DIR)/test_ft_strlen.c \
$(TESTS_DIR)/test_ft_strcpy.c \
$(TESTS_DIR)/test_ft_strcmp.c \
$(TESTS_DIR)/test_ft_write.c \
$(TESTS_DIR)/test_ft_read.c \
$(TESTS_DIR)/test_ft_strdup.c
BONUS_TESTS = $(TESTS_DIR)/test_linked_list_bonus.c \
$(TESTS_DIR)/test_ft_atoi_base_bonus.c
INCLUDE = ./include
ASM = nasm
ASM_FLAG = -f elf64
CC = clang
CC_FLAGS = -Wall -Werror -Wextra -g \
-L. -lasm
HEADER = -I $(INCLUDE) \
-I.
RM = /bin/rm -f
all: $(NAME)
$(NAME): $(OBJ)
ar rcs $(NAME) $(OBJ)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.s
mkdir -p $(OBJ_DIR)
$(ASM) $(ASM_FLAG) $< -o $@
test: $(NAME) $(SRC_TESTS) main.c
$(CC) main.c $(SRC_TESTS) $(HEADER) $(CC_FLAGS) -o $@
bonus: all $(OBJ_BONUS)
ar rcs $(NAME) $(OBJ_BONUS)
testbonus: bonus main_bonus.c
$(CC) main_bonus.c $(BONUS_TESTS) $(HEADER) $(CC_FLAGS) -o $@
clean:
$(RM) $(OBJ)
$(RM) -r $(OBJ_DIR)
fclean: clean
$(RM) $(NAME) test testbonus
re: fclean all
.PONY: all, test, bonus, testbonus, clean, fclean, re