-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
36 lines (27 loc) · 749 Bytes
/
Makefile
File metadata and controls
36 lines (27 loc) · 749 Bytes
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
NAME = webserv
CXX = c++
CXXFLAGS = -Wall -Wextra -Werror -std=c++98
SRC_DIR = src
OBJ_DIR = obj
INC_DIR = include
# Include all subdirectories in include/
INC_DIRS = $(shell find $(INC_DIR) -type d)
CPPFLAGS = $(addprefix -I, $(INC_DIRS))
# Find all .cpp files recursively in src/
SRCS = $(shell find $(SRC_DIR) -name '*.cpp')
OBJS = $(SRCS:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.o)
all: $(NAME)
$(NAME): $(OBJS)
$(CXX) $(CXXFLAGS) $(OBJS) -o $(NAME)
@echo "Build successful: $(NAME)"
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
clean:
rm -rf $(OBJ_DIR)
@echo "Cleaned object files"
fclean: clean
rm -f $(NAME)
@echo "Cleaned executable"
re: fclean all
.PHONY: all clean fclean re