-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (58 loc) · 1.52 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
NAME = libfts.a
AS = nasm
ASFLAGS = -f macho64
ASDIR = asm
ASSRCDIR = $(ASDIR)/src
ASOBJDIR = $(ASDIR)/obj
ASSRCFILES = $(addprefix $(ASSRCFILES)/, $(addsuffix .s, $(FUNNAMES)))
ASOBJFILES = $(addprefix $(ASOBJDIR)/, $(addsuffix .o, $(FUNNAMES)))
CC = clang
CFLAGS = -Wall -Wextra -Werror -arch x86_64
TESTDIR = tests
TESTSRCDIR = $(TESTDIR)/src
TESTOBJDIR = $(TESTDIR)/obj
TESTSRCFILES = $(addprefix $(TESTSRCFILES)/, $(addsuffix .test.c, $(FUNNAMES)))
TESTOBJFILES = $(addprefix $(TESTOBJDIR)/, $(addsuffix .test.o, $(FUNNAMES)))
TESTEXECFILES = $(addprefix $(TESTDIR)/, $(addsuffix .test, $(FUNNAMES)))
.PRECIOUS: $(TESTOBJDIR)/%.test.o
FUNNAMES = ft_bzero \
ft_cat \
ft_isalnum \
ft_isalpha \
ft_isascii \
ft_isdigit \
ft_isprint \
ft_memcpy \
ft_memset \
ft_puts \
ft_strcat \
ft_strdup \
ft_strlen \
ft_tolower \
ft_toupper
$(ASOBJDIR)/%.o : $(ASSRCDIR)/%.s
$(AS) $(ASFLAGS) -o $@ $<
$(TESTOBJDIR)/%.test.o : $(TESTSRCDIR)/%.test.c
$(CC) $(CFLAGS) -o $@ -c $<
$(TESTDIR)/%.test : $(TESTOBJDIR)/%.test.o $(ASOBJDIR)/%.o
$(CC) -o $@ $^
$(NAME): FORCE $(ASOBJFILES)
ar rcs $(NAME) $(ASOBJFILES)
all: $(NAME)
obj: $(ASOBJFILES)
lib: all
clean:
rm -f $(ASOBJFILES)
fclean: clean
rm -f $(NAME)
re: fclean all
tests: FORCE $(TESTEXECFILES)
runtests: tests
@$(addsuffix ;, $(TESTEXECFILES))
testclean:
rm -f $(TESTOBJFILES)
testfclean: testclean
rm -f $(TESTEXECFILES)
bleach: fclean testfclean
FORCE:
mkdir -p $(ASSRCDIR) $(ASOBJDIR) $(TESTSRCDIR) $(TESTOBJDIR)