-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
110 lines (91 loc) · 3.14 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: ple-stra <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/01/29 15:36:23 by ple-stra #+# #+# #
# Updated: 2022/08/21 08:16:02 by ple-stra ### ########.fr #
# #
# **************************************************************************** #
NAME = pipex
SRCS_DIR = srcs
SRCS = pipex.c\
path.c processes.c\
errors.c
SRCSBNS_DIR = srcs_bonus
SRCSBNS = pipex_bonus.c\
path_bonus.c processes_bonus.c pipes_utils_bonus.c here_doc_bonus.c\
errors_bonus.c
BUILD_DIR = build
OBJ_DIR = $(BUILD_DIR)/objs
OBJBNS_DIR = $(BUILD_DIR)/objs_bonus
OBJ = $(addprefix $(OBJ_DIR)/, $(SRCS:.c=.o))
OBJBNS = $(addprefix $(OBJBNS_DIR)/, $(SRCSBNS:.c=.o))
INC = -I./includes -I./$(LIBFT_DIR)/includes -I./
INCBNS = -I./includes_bonus -I./$(LIBFT_DIR)/includes -I./
LIBFT_DIR = libft
LIBFT = $(LIBFT_DIR)/build/libft.a
LIBFT_FLAGS = -L$(LIBFT_DIR)/build -lft
CC = cc
CFLAGS = -Wall -Wextra
LFLAGS = $(LIBFT_FLAGS)
ifneq (nWerror, $(filter nWerror,$(MAKECMDGOALS)))
CFLAGS += -Werror
endif
ifeq (sanitize, $(filter sanitize,$(MAKECMDGOALS)))
CFLAGS += -fsanitize=address
endif
ifeq (debug, $(filter debug,$(MAKECMDGOALS)))
CFLAGS += -D KDEBUG=1
endif
GIT_SUBM = $(shell \
sed -nE 's/path = +(.+)/\1\/.git/ p' .gitmodules | paste -s -)
RM = rm -rf
all : $(NAME)
bonus : $(GIT_SUBM) $(LIBFT) $(OBJBNS)
$(CC) $(CFLAGS) $(INCBNS) -o $(NAME) $(OBJBNS) $(LFLAGS)
$(OBJ_DIR)/%.o: $(SRCS_DIR)/%.c
@mkdir -p $(OBJ_DIR)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
$(OBJBNS_DIR)/%.o: $(SRCSBNS_DIR)/%.c
@mkdir -p $(OBJBNS_DIR)
$(CC) $(CFLAGS) $(INCBNS) -c $< -o $@
$(GIT_SUBM): %/.git: .gitmodules
ifneq (noconnection, $(filter noconnection,$(MAKECMDGOALS)))
@git submodule init
@git submodule update --remote $*
endif
$(LIBFT) :
ifeq (,$(wildcard $(LIBFT)))
@echo "building libft..."
@$(MAKE) -sC $(LIBFT_DIR) all disable_gnl_eof_mid_line
endif
rmlibft :
@echo "deleting libft build..."
@$(MAKE) -sC $(LIBFT_DIR) fclean
$(NAME) : $(GIT_SUBM) $(LIBFT) $(OBJ)
$(CC) $(CFLAGS) $(INC) -o $(NAME) $(OBJ) $(LFLAGS)
clean :
$(RM) $(OBJ_DIR)
$(RM) $(OBJBNS_DIR)
fclean :
$(RM) $(BUILD_DIR)
$(RM) $(NAME)
fcleanall : rmlibft
$(RM) $(BUILD_DIR)
$(RM) $(NAME)
re : fclean all
rebonus : fclean bonus
nWerror :
@echo "WARN: Compiling without Werror flag!"
sanitize :
@echo "WARN: Compiling with fsanitize flag!"
debug :
@echo "WARN: debug is enabled"
noconnection :
@echo "WARN: Fetching submodules disabled!"
.PHONY: \
all bonus clean fclean fcleanall re rebonus rmlibft\
nWerror sanitize debug noconnection