-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
102 lines (83 loc) · 2.46 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Compiler
CC := c++
# Directories
SRC_DIR := ./src
BUILD_DIR := ./build
TARGET_DIR := $(BUILD_DIR)/bin
OBJ_DIR := $(BUILD_DIR)/obj
INCLUDE_DIR := ./include
CONFIG_DIR := ./config
TEMPLATE_DIR := ./template
# The Target Binary Program
TARGET := $(TARGET_DIR)/webserv.exe
DEBUG_LOG_FILE := $(BUILD_DIR)/debug/debug.log
# extentions
SRC_EXT := cpp
OBJ_EXT := o
# Flags
CFLAGS := -Wall -Wextra -Werror
CFLAGS += -std=c++98
# Sources
# -------------------------------------------------------------
SRCS := $(SRC_DIR)/core/luncher.$(SRC_EXT) \
$(SRC_DIR)/core/webserv.$(SRC_EXT) \
$(SRC_DIR)/core/context.$(SRC_EXT) \
$(SRC_DIR)/core/loadConfiguration.$(SRC_EXT) \
$(SRC_DIR)/core/tools.$(SRC_EXT) \
$(SRC_DIR)/http/client.$(SRC_EXT) \
$(SRC_DIR)/http/connectionHandler.$(SRC_EXT) \
$(SRC_DIR)/http/request.$(SRC_EXT) \
$(SRC_DIR)/http/response.$(SRC_EXT) \
$(SRC_DIR)/http/responseHandler.$(SRC_EXT) \
$(SRC_DIR)/http/tools.$(SRC_EXT) \
$(SRC_DIR)/http/requestHandler.$(SRC_EXT) \
$(SRC_DIR)/http/baseParser.$(SRC_EXT) \
$(SRC_DIR)/http/blockMatchAlgorithm.$(SRC_EXT) \
$(SRC_DIR)/http/readBodyFromBuffer.$(SRC_EXT) \
$(SRC_DIR)/http/getMethodHandler.$(SRC_EXT) \
$(SRC_DIR)/http/postMethodHundler.$(SRC_EXT) \
$(SRC_DIR)/http/deleteMethodHundler.$(SRC_EXT) \
$(SRC_DIR)/http/IBase.$(SRC_EXT) \
$(SRC_DIR)/http/cgiExecutor.$(SRC_EXT)
# -------------------------------------------------------------
OBJS := $(SRCS:$(SRC_DIR)/%.$(SRC_EXT)=$(OBJ_DIR)/%.$(OBJ_EXT))
TEMPLATES := $(wildcard $(TEMPLATE_DIR)/*)
CONFIGS := $(TEMPLATES:$(TEMPLATE_DIR)/%=$(CONFIG_DIR)/%)
# colors
RED := \033[0;31m
GREEN := \033[0;32m
END := \033[0m
.PHONY: all
all: debug
startCmp:
@ echo "$(GREEN)Compiling ...$(END)"
endCmp :
@ echo "$(GREEN)Done!$(END)"
.PHONY: debug
debug: CFLAGS += -g3 -fsanitize=address
debug: CFLAGS += -D DEBUG
debug: startCmp $(TARGET) endCmp
.PHONY: release
release: startCmp $(TARGET) endCmp
.PHONY: run
run: generate debug
@ ./$(TARGET) $(ARGS) > $(DEBUG_LOG_FILE)
.PHONY: generate
generate: $(CONFIGS)
@ echo "$(GREEN)Generate config Done!$(END)"
$(TARGET) : $(OBJS)
@ $(CC) $(CFLAGS) -o $(TARGET) $(OBJS)
$(OBJ_DIR)/%.$(OBJ_EXT): $(SRC_DIR)/%.$(SRC_EXT)
@ $(CC) $(CFLAGS) -c -o $@ $< -I $(INCLUDE_DIR)
$(CONFIG_DIR)/%: $(TEMPLATE_DIR)/%
@ ./tools/envsubst.exe < $< > $@
.PHONY: clean
clean:
@ echo "$(RED)Cleaning ...$(END)"
@ rm -rf $(OBJS)
@ echo "$(RED)Done!$(END)"
.PHONY: fclean
fclean: clean
@ rm -rf $(TARGET)
.PHONY: re
re: fclean all