-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
51 lines (39 loc) · 1.72 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: hyap <hyap@student.42kl.edu.my> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/08/14 12:49:23 by hyap #+# #+# #
# Updated: 2023/01/19 17:47:33 by hyap ### ########.fr #
# #
# **************************************************************************** #
NAME = main
SRCSDIR = srcs
SRCS = $(wildcard $(SRCSDIR)/*.cpp)
OBJSDIR = srcs/obj
OBJS = $(SRCS:$(SRCSDIR)/%.cpp=$(OBJSDIR)/%.o)
DEPENDSDIR = srcs/depends
DEPENDS = $(SRCS:$(SRCSDIR)/%.cpp=$(DEPENDSDIR)/%.d)
CPPFLAGS = -Wall -Werror -Wextra -Wshadow -std=c++98 -pedantic -I includes/
DEPFLAGS = -MM
LDFLAGS = -g -lstdc++ -fno-elide-constructors -fsanitize=address
TPP = $(wildcard $(SRCSDIR)/*.tpp)
HPP = $(wildcard includes/*.hpp)
all: $(NAME)
$(NAME): $(OBJS)
gcc $(LDFLAGS) $< -o $(NAME)
$(OBJSDIR)/%.o: $(SRCSDIR)/%.cpp $(TPP) $(HPP) | $(OBJSDIR)
gcc $(CPPFLAGS) -c $< -o $@
$(DEPENDSDIR)/%.d: $(SRCSDIR)/%.cpp | $(DEPENDSDIR)
c++ $(CPPFLAGS) $(DEPFLAGS) $< -o $@
$(OBJSDIR) $(DEPENDSDIR):
mkdir -p $@
-include $(DEPENDS)
clean:
$(RM) -rv $(OBJSDIR) $(DEPENDSDIR)
fclean: clean
$(RM) $(NAME)
re: fclean all
.PHONY: all clean fclean re