-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
45 lines (31 loc) · 906 Bytes
/
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
NAME = webserv
CXX = clang++
CXXFLAGS = -Wall -Wextra -Werror -Wpedantic -Wsign-conversion -std=c++98
RM = rm -rf
MKDIR = mkdir -p
SRC_DIR = src
OBJ_DIR = obj
DIRS = $(shell find $(SRC_DIR) -type d)
INCS = $(shell find $(SRC_DIR) -type f -name "*.hpp")
SRCS = $(shell find $(SRC_DIR) -type f -name "*.cpp")
SRCS_BASE = $(foreach file, $(SRCS), $(shell basename -a $(file)))
OBJS = $(addprefix $(OBJ_DIR)/, $(SRCS_BASE:.cpp=.o))
VPATH = $(SRC_DIR) $(DIRS)
all: CXXFLAGS += -g -fno-limit-debug-info
all: $(NAME)
release: CXXFLAGS += -O3
release: fclean $(NAME)
$(OBJ_DIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -I$(SRC_DIR) -c -o $@ $<
$(NAME): $(OBJ_DIR) $(OBJS)
$(CXX) -o $(NAME) $(OBJS)
$(OBJ_DIR):
@$(MKDIR) $(OBJ_DIR)
clean:
@$(RM) $(OBJ_DIR)
fclean: clean
@$(RM) $(NAME)
re: fclean all
fmt:
clang-format -i $(SRCS) $(INCS)
.PHONY: all release clean fclean re fmt