-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
98 lines (77 loc) · 1.71 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
##
## EPITECH PROJECT, 2023
## mat
## File description:
## Makefile
##
MAIN_SRC = src/main.c
ASM_SRC = src/strlen.asm \
src/strchr.asm \
src/strrchr.asm \
src/memset.asm \
src/memcpy.asm \
src/strcmp.asm \
src/memmove.asm \
src/strncmp.asm \
src/strcasecmp.asm \
src/strpbrk.asm \
src/strcspn.asm \
src/strstr.asm \
src/index.asm \
src/rindex.asm \
src/memfrob.asm
TEST_SRC = tests/strlen.c \
tests/strchr.c \
tests/strrchr.c \
tests/memset.c \
tests/memcpy.c \
tests/strcmp.c \
tests/memmove.c \
tests/strncmp.c \
tests/strcasecmp.c \
tests/strpbrk.c \
tests/strcspn.c \
tests/strstr.c
MAIN_OBJ = $(MAIN_SRC:.c=.o)
ASM_OBJ = $(ASM_SRC:.asm=.o)
TEST_OBJ = $(TEST_SRC:.c=_test.o)
CC = gcc
NASM = nasm
ASMFLAGS = -f elf64
CFLAGS =
LIB = -L. -lasm
LDFLAGS = $(LIB)
COVERAGE = --coverage -lcriterion
DLIB = libasm.so
EXE = binary
TEST_EXE = $(EXE)_test
all: $(DLIB)
%.o: %.c
$(CC) -o $@ -c $< $(CFLAGS) -g3
%.o : %.asm
$(NASM) -o $@ $< $(ASMFLAGS)
%_test.o: %.c
$(CC) -o $@ -c $<
$(DLIB): $(ASM_OBJ)
ld -shared -o $@ $^
run: $(DLIB) $(MAIN_OBJ)
$(CC) -o $(EXE) $(MAIN_OBJ) $(LDFLAGS) -L. -lasm
clean:
rm -rf $(MAIN_OBJ)
rm -rf $(TEST_OBJ)
rm -rf $(ASM_OBJ)
$(shell find * -name "*.gcda" -delete)
$(shell find * -name "*.gcno" -delete)
$(shell find * -name "vgcore.*" -delete)
fclean: clean
rm -rf $(EXE)
rm -rf $(DLIB)
rm -rf $(TEST_EXE)
re: fclean all
unit_tests: CFLAGS += $(COVERAGE)
unit_tests: LDFLAGS += $(COVERAGE)
unit_tests: $(DLIB) $(FILE_OBJ) $(TEST_OBJ)
$(CC) -o $(TEST_EXE) $(FILE_OBJ) $(TEST_OBJ) $(LDFLAGS) -L. -lasm
tests_run: clean unit_tests
./$(TEST_EXE)
.PHONY: all clean re fclean tests_run