-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
73 lines (52 loc) · 1.98 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: lcouto <lcouto@student.42sp.org.br> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/01/24 20:37:04 by lcouto #+# #+# #
# Updated: 2021/08/14 16:32:14 by lcouto ### ########.fr #
# #
# **************************************************************************** #
NAME = libft.a
HEADERS = -I includes
DIR_SRCS = sources
DIR_OBJS = objects
DIRS = str mem lst ascii gnl hashmap
SRC = $(wildcard $(DIR_SRCS)/*.c)
SOURCEDIRS = $(foreach dir, $(DIRS), $(addprefix $(DIR_SRCS)/, $(dir)))
SOURCES = $(foreach dir,$(SOURCEDIRS),$(wildcard $(dir)/*.c))
OBJS = $(subst $(DIR_SRCS),$(DIR_OBJS),$(SOURCES:.c=.o))
CC = clang
RM = rm -rf
CFLAGS = -Wall -Wextra -Werror -g $(HEADERS)
ifeq ($(SANITIZE_A),true)
CFLAGS += -fsanitize=address -fno-omit-frame-pointer
endif
ifeq ($(SANITIZE_L),true)
CFLAGS += -fsanitize=leak -fno-omit-frame-pointer
endif
$(NAME): $(OBJS)
@ar -rc $(NAME) $(OBJS)
@ranlib $(NAME)
@echo "Created libft.a file successfully"
$(DIR_OBJS)/%.o: $(DIR_SRCS)/%.c
@mkdir -p objects
@mkdir -p objects/ascii
@mkdir -p objects/gnl
@mkdir -p objects/hashmap
@mkdir -p objects/lst
@mkdir -p objects/mem
@mkdir -p objects/str
@$(CC) $(CFLAGS) $(HEADER) -c $< -o $@
@echo "Compiled "$<" successfully!"
all: $(NAME)
clean:
@$(RM) $(OBJS)
@$(RM) $(DIR_OBJS)
fclean: clean
@$(RM) $(NAME)
@$(RM) $(DIR_OBJS)
re: fclean all
PHONY: all clean fclean re