Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (69 loc) · 2.09 KB
/
Copy pathMakefile
File metadata and controls
97 lines (69 loc) · 2.09 KB
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
96
97
NAME := webserv
CXX := clang++
CXXFLAGS := -Wall -Wextra -Werror -std=c++98
SRCSDIR := ./src
OBJDIR := ./obj
DPSDIR := ./dps
INCDIR := $(shell find $(SRCSDIR) -maxdepth 2 -type d)
INCLUDE := $(addprefix -I, $(INCDIR))
VPATH := $(INCDIR)
SRCS := $(shell find $(SRCSDIR) -type f -name '*.cpp')
OBJS := $(patsubst $(SRCSDIR)%,$(OBJDIR)%,$(SRCS:.cpp=.o))
RM := rm -rf
.PHONY: all
all: $(NAME) ## Build
$(NAME): $(OBJS)
$(CXX) $(CXXFLAGS) $(OBJS) -o $(NAME)
$(OBJDIR)/%.o: %.cpp
@mkdir -p $(DPSDIR)
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) -MMD -MP -MF $(DPSDIR)/$(notdir $(<:.cpp=.d)) -c $< -o $@
-include $(DPS)
.PHONY: clean
clean: ## Remove object file
$(RM) $(OBJDIR) $(DPSDIR)
.PHONY: fclean
fclean: clean ## Remove object file, executable file
$(RM) $(NAME) *.dSYM tester
.PHONY: re
re: fclean all ## Rebuild
.PHONY: tidy
tidy: ## Run clang-tidy
clang-tidy $(SRCS) -- $(INCLUDE)
.PHONY: tidy-fix
tidy-fix: ## Run clang-tidy --fix
clang-tidy $(SRCS) --fix -- $(INCLUDE)
.PHONY: debug
debug: CXXFLAGS += -fsanitize=address -D WS_DEBUG=1
debug: re ## Debug mode rebuild
################# test script ####################
TESTDIR= ./test
.PHONY: lsof
lsof: ## Run lsof.sh
@bash $(TESTDIR)/lsof.sh
.PHONY: error_conf
error_conf: ## Run error_conf.sh
@bash $(TESTDIR)/error_conf.sh
################# google test ####################
GOOGLETESTDIR := ./test/google_test
.PHONY: gtest
gtest: $(OBJS) ## Create tester
@$(MAKE) -C $(GOOGLETESTDIR) gtest
@mv $(GOOGLETESTDIR)/tester ./
.PHONY: gtestclean
gtestclean: ## Clean google test object file
@$(MAKE) -C $(GOOGLETESTDIR) clean
BLUE := \033[34m
RESET := \033[39m
.PHONY: gtestlist
gtestlist: gtest ## Show google test list
@./tester --gtest_list_tests
@printf '\n$(BLUE)RUN ./tester --gtest_filter="(TESTCASE).(TESTNAME)"$(RESET)\n'
PHONY: help
help: ## Display this help screen
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' "Makefile" | awk -F ' ##' '{printf "$(BLUE)%-20s$(RESET) %s\n", $$1, $$2}'
################# Go test ####################
GOTESTDIR := ./test/go_test
.PHONY: go_test
go_test:
@$(MAKE) run -C $(GOTESTDIR)