-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
65 lines (43 loc) · 1.47 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
# **************************************************************************** #
# VARIABLES #
# **************************************************************************** #
NAME := webserv
CXX := c++
CXXFLAGS := -Wall -Wextra -Werror -std=c++98 -g -fsanitize=address -fsanitize=undefined
CPPFLAGS :=
DEPFLAGS = -MT $@ -MMD -MP -MF $(DDIR)/$*.d
LDFLAGS :=
LDLIBS :=
VPATH := src/ \
src/config/ \
src/core/ \
src/http/ \
src/utils/
SRCS := $(notdir $(foreach dir, $(VPATH), $(wildcard $(dir)/*.cpp)))
BUILDDIR := build
ODIR := $(BUILDDIR)/obj
OBJS := $(SRCS:%.cpp=$(ODIR)/%.o)
DDIR := $(BUILDDIR)/deps
DEPS := $(SRCS:%.cpp=$(DDIR)/%.d)
# **************************************************************************** #
# RULES #
# **************************************************************************** #
.PHONY: all clean fclean re
all: $(BUILDDIR)/$(NAME)
clean:
$(RM) -r $(DDIR) $(ODIR)
fclean: clean
$(RM) -r $(BUILDDIR)
re: fclean all
run: $(BUILDDIR)/$(NAME)
@$(BUILDDIR)/$(NAME) $(ARGS)
$(BUILDDIR)/$(NAME): $(OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJS) -o $@ $(LDLIBS)
$(ODIR)/%.o: %.cpp $(DDIR)/%.d | $(ODIR) $(DDIR)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(DEPFLAGS) -c $< -o $@
$(ODIR):
mkdir -p $@
$(DDIR):
mkdir -p $@
$(DEPS):
-include $(DEPS)