-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
51 lines (35 loc) · 986 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
46
47
48
49
50
51
# Program name
NAME = webserv
# compiler
CC = c++
# compiler flags
CFLAGS = -std=c++11 -Wall -Werror -Wextra -MMD -g -fsanitize=address
DEBUG_FLAGS = -g
# src files and path for them
VPATH := $(shell find src -type d)
INCS := $(wildcard $(addsuffix /*.hpp, $(VPATH)))
INCLUDE = $(addprefix -I, $(VPATH))
# src files
SRC := main.cpp WebServerProg.cpp api_helpers.cpp api_get.cpp api_delete.cpp parser.cpp validateServers.cpp api_post.cpp utils.cpp request.cpp cgiHandler.cpp directoryListing.cpp
# obj files and path for them
OBJ_DIR = ./obj
OBJ =$(addprefix $(OBJ_DIR)/, $(SRC:%.cpp=%.o))
#dependencies
DEP =$(OBJ:.o=.d)
# rules
all: $(NAME)
debug: CFLAGS += $(DEBUG_FLAGS)
debug: all
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
$(NAME): $(OBJ_DIR) $(OBJ)
$(CC) $(CFLAGS) $(INCLUDE) $(OBJ) -o $@
-include $(DEP)
$(OBJ_DIR)/%.o: %.cpp
$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
clean:
rm -rf $(OBJ_DIR)
fclean: clean
rm -rf $(NAME)
re: fclean all
.PHONY: all debug clean fclean re