-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
98 lines (74 loc) · 2.44 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: apuchill <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/02/16 15:56:04 by apuchill #+# #+# #
# Updated: 2021/03/06 12:50:50 by apuchill ### ########.fr #
# #
# **************************************************************************** #
NAME = libasm.a
TEST = test.out
DIR_SRCS = srcs
DIR_OBJS = objs
DIR_TEST = tests
SRCS = ft_strlen.s ft_write.s ft_read.s ft_strcpy.s ft_strcmp.s \
ft_strdup.s
OBJS = $(patsubst %.s, ${DIR_OBJS}/%.o, ${SRCS})
TEST_SRCS = $(foreach dir, $(DIR_TEST), $(wildcard $(dir)/*.c))
INCLUDES = -I includes
ASM = nasm
ASM_FLAGS = -f elf64
CC = clang
CFLAGS = -Wall -Wextra -Werror -lasm -L .
RM = /bin/rm -f
NORM = ~/.norminette/norminette.rb
C_H_LINE = "\033[38;5;43m"
C_H_TITLE = "\033[1m\033[38;5;199m"
C_END = "\033[0m"
all: $(NAME)
$(DIR_OBJS)/%.o : $(DIR_SRCS)/%.s
@mkdir -p $(DIR_OBJS)
@$(ASM) $(ASM_FLAGS) $< -o $@
$(NAME): $(OBJS)
@ar -rcs $(NAME) $(OBJS)
.PHONY: test
test: $(NAME) $(TEST_SRCS)
@$(CC) $(TEST_SRCS) $(CFLAGS) $(INCLUDES) -o $(TEST)
@echo $(C_H_LINE) && cat $(DIR_TEST)/header_line1.txt && \
echo $(C_H_TITLE) && cat $(DIR_TEST)/header_title.txt && \
echo "\033[1m\033[38;5;23m42saopaulo" \
$(C_H_LINE) && cat $(DIR_TEST)/header_line2.txt && echo $(C_END)
.PHONY: test_all
test_all: test
@./$(TEST) all
.PHONY: ft_strlen
ft_strlen: test
@./$(TEST) ft_strlen
.PHONY: ft_strdup
ft_strdup: test
@./$(TEST) ft_strdup
.PHONY: ft_strcpy
ft_strcpy: test
@./$(TEST) ft_strcpy
.PHONY: ft_strcmp
ft_strcmp: test
@./$(TEST) ft_strcmp
.PHONY: ft_write
ft_write: test
@./$(TEST) ft_write
.PHONY: ft_read
ft_read: test
@./$(TEST) ft_read
.PHONY: norm
norm:
$(NORM) */*.h */*.c
clean:
@$(RM) $(OBJS)
@$(RM) -r $(DIR_OBJS)
fclean: clean
@$(RM) $(NAME) $(TEST)
re: fclean all
.PHONY: all clean fclean re