forked from dantol29/webserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (53 loc) · 1.26 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
# Compiler and Flags
CXX = c++
CXXFLAGS = -Wall -Wextra -Werror -std=c++98 -I. -Iinclude -Isrc -Isrc/events -g
DEPFLAGS = -MMD -MP
UNAME_S := $(shell uname -s)
# Additional Flags for macOS
ifeq ($(UNAME_S), Darwin)
CXXFLAGS += -fsanitize=address
LDFLAGS += -fsanitize=address
endif
# Source and Object Files
SRCS = src/main.cpp \
src/Parser.cpp \
src/Config.cpp \
src/Connection.cpp \
src/Server.cpp \
src/server_utils.cpp \
src/HTTPRequest.cpp \
src/HTTPResponse.cpp \
src/Router.cpp \
src/AResponseHandler.cpp \
src/StaticContentHandler.cpp \
src/CGIHandler.cpp \
src/MetaVariables.cpp \
src/UploadHandler.cpp \
src/Debug.cpp \
src/utils.cpp \
src/ServerBlock.cpp \
src/ServerSocket.cpp \
src/Listen.cpp \
src/events/EventManager.cpp \
src/events/ServerEventListener.cpp
OBJDIR = obj
OBJS = $(SRCS:%.cpp=$(OBJDIR)/%.o)
# Main Target
TARGET = webserv
# Build Rules
all: $(TARGET)
# Ensure the necessary directories exist before compiling anything
$(OBJDIR)/%.o: %.cpp
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(DEPFLAGS) -c $< -o $@
# Linking the main target
$(TARGET): $(OBJS)
$(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJS)
# Cleaning up the build
clean:
rm -rf $(OBJDIR)
rm -f $(TARGET)
fclean: clean
rm -f $(TARGET)
re: fclean all
.PHONY: all clean fclean re