-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
95 lines (78 loc) · 2.54 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: angavrel <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2017/07/29 21:40:42 by angavrel #+# #+# #
# Updated: 2018/12/09 16:53:05 by angavrel ### ########.fr #
# #
# **************************************************************************** #
NAME = libfts.a
ASM_FILES = ft_isascii \
ft_isdigit \
ft_isupper \
ft_islower \
ft_isalpha \
ft_isalnum \
ft_isprint \
ft_strlen \
ft_puts \
ft_memcpy \
ft_toupper \
ft_tolower \
ft_strcat \
ft_pow \
ft_strdup \
ft_abs \
ft_memset \
ft_rand \
ft_swap \
ft_collatz \
ft_memchr \
ft_strncmp \
ft_atoi \
ft_align \
ft_cat \
table_type
OS := $(shell uname)
ifeq ($(OS), Darwin)
ASM_COMPILER = nasm -f macho64 -g#~/.brew/bin/nasm -f macho64 -g
else
ASM_COMPILER = nasm -f elf64 -g
endif
ASM_SRC_DIR = srcs/
ASM_OBJ_DIR_NAME = obj
ASM_OBJ_DIR = $(ASM_OBJ_DIR_NAME)/
ASM_OBJ := $(addsuffix .o,$(ASM_FILES))
ASM_OBJ := $(addprefix $(ASM_OBJ_DIR),$(ASM_OBJ))
TEST = $(TEST_FILES).out
TEST_FILES = maintest
C_COMPILER = clang -Wall -Werror -Wextra -pedantic -O3
TEST_DIR_NAME = test
TEST_DIR = $(TEST_DIR_NAME)/
TEST_OBJ := $(addsuffix .o,$(TEST_FILES))
TEST_OBJ := $(addprefix $(TEST_DIR),$(TEST_OBJ))
OBJ_PATHS := $(ASM_OBJ) $(TEST_OBJ)
all: $(NAME)
$(NAME): $(ASM_OBJ)
ar rc $(NAME) $(ASM_OBJ)
test: re $(TEST_OBJ)
$(C_COMPILER) -L. $(TEST_OBJ) $(NAME) -o $(TEST)
shared: $(ASM_OBJ)
gcc -fPIC -shared -o libft.so $^
cp libft.so libft-unit-test
$(ASM_OBJ): $(ASM_OBJ_DIR)%.o: $(ASM_SRC_DIR)%.s
@/bin/mkdir -p $(ASM_OBJ_DIR)
$(ASM_COMPILER) $< -o $@
$(TEST_OBJ): $(TEST_DIR)%.o: $(TEST_DIR)%.c
$(C_COMPILER) -c -I. $< -o $@
clean:
-/bin/rm -f $(OBJ_PATHS)
/usr/bin/find . -name "$(ASM_OBJ_DIR_NAME)" -maxdepth 1 -type d -empty -delete
fclean: clean
-/bin/rm -f $(NAME)
-/bin/rm -f $(TEST)
re: fclean all
.PHONY: all clean fclean re