-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
60 lines (47 loc) · 2.03 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: edboutil <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/12/24 17:05:14 by edboutil #+# #+# #
# Updated: 2022/12/24 17:05:15 by edboutil ### ########lyon.fr #
# #
# **************************************************************************** #
# VAR ---------------------------------------------------------------
OBJS_DIR = .OBJS/
NAME_SERV = server
SRCS_SERV = SRCS/server.c \
UTILS/printf.c UTILS/list.c
OBJS_SERV = $(addprefix ${OBJS_DIR}, $(SRCS_SERV:.c=.o))
DEP_SERV = $(addprefix $(OBJS_DIR), $(SRCS_SERV:.c=.d))
NAME_CLI = client
SRCS_CLI = SRCS/client.c \
UTILS/printf.c UTILS/atoi.c UTILS/is_number.c
OBJS_CLI = $(addprefix ${OBJS_DIR}, $(SRCS_CLI:.c=.o))
DEP_CLI = $(addprefix $(OBJS_DIR), $(SRCS_CLI:.c=.d))
HEAD = INCLUDES/
CC = cc
RM = rm -rf
FLAGS = -Wall -Wextra -Werror
FLAGS += -MMD -MP
# RULES -------------------------------------------------------------
all: $(NAME_SERV) $(NAME_CLI)
$(NAME_SERV): $(OBJS_SERV)
$(CC) $(FLAGS) $(OBJS_SERV) -o $(NAME_SERV)
$(NAME_CLI): $(OBJS_CLI)
$(CC) $(FLAGS) $(OBJS_CLI) -o $(NAME_CLI)
-include $(DEP_SERV) $(DEP_CLI)
$(OBJS_DIR)%.o: %.c | dir
$(CC) $(FLAGS) -I $(HEAD) -c $< -o $@
dir:
@mkdir -p $(OBJS_DIR)
@mkdir -p $(OBJS_DIR)UTILS
@mkdir -p $(OBJS_DIR)SRCS
clean:
$(RM) $(OBJS_DIR)
fclean: clean
$(RM) $(NAME_SERV) $(NAME_CLI)
re: fclean all
.PHONY: all dir clean fclean re