-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (64 loc) · 2.66 KB
/
Makefile
File metadata and controls
83 lines (64 loc) · 2.66 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: ade-rese <ade-rese@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/08/14 15:47:01 by lde-merc #+# #+# #
# Updated: 2025/10/28 14:10:31 by ade-rese ### ########.fr #
# #
# **************************************************************************** #
vpath %.cpp srcs
vpath %.conf conf_file
NAME = webserv
CXX = c++
CXXFLAGS = -MMD -Wall -Werror -Wextra -g -std=c++98
INCLUDES = includes/
OBJ_DIR = objs/
SRC_DIR = srcs/
DEP := $(OBJ:.o=.d)
INVALID_FILE = empty_file.conf wrong_extension.txt no_port.conf no_server_name.conf obscure_data.conf
# Liste des fichiers source
SRC_FILES = main.cpp Server.cpp Server_parsing.cpp Request.cpp Reponse.cpp Utils.cpp Client.cpp
# Transforme chaque fichier source en un fichier objet dans $(OBJ_DIR)
OBJS = $(addprefix $(OBJ_DIR), $(SRC_FILES:.cpp=.o))
all: mkdir_obj $(NAME)
# Compilation des fichiers .cpp en .o dans le dossier $(OBJ_DIR)
$(OBJ_DIR)%.o: %.cpp
@$(CXX) $(CXXFLAGS) -c $< -o $@
# Création du dossier objs/ et des sous-répertoires s'ils n'existent pas
mkdir_obj:
@mkdir -p $(OBJ_DIR)
# Compilation finale
$(NAME): $(OBJS)
@echo "\033[34mCompilation $(NAME) en cours\033[0m"
@$(CXX) $(OBJS) $(CXXFLAGS) -o $(NAME)
@echo "\033[0;32mSUCCESS !\033[0m \033[0;33m$(NAME)\033[0m"
clean:
@rm -rf $(OBJ_DIR)
@echo "\033[0;34mDeleting almost everything !\033[0m"
fclean: clean
@rm -f $(NAME)
@echo "\033[0;35mDeleting everything !\033[0m"
re: fclean all
-include $(DEP)
val: all
valgrind --leak-check=full --show-leak-kinds=all ./$(NAME) conf_file/valid_file/maximal_valid.conf || true
test: all
@for file in $(INVALID_FILE); do \
echo ""; \
echo "Testing $$file..."; \
./$(NAME) $$file || true; \
done
@echo ""; echo "Testing without arguments..."; \
./$(NAME) || true
test_val: all
@for file in $(INVALID_FILE); do \
echo ""; \
echo "Testing $$file..."; \
valgrind --leak-check=full --show-leak-kinds=all ./$(NAME) $$file || true; \
done
@echo ""; echo "Testing without arguments..."; \
valgrind --leak-check=full --show-leak-kinds=all ./$(NAME) || true
.PHONY: all clean fclean re