-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (61 loc) · 2.33 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: kdhrif <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/11/29 14:25:53 by kdhrif #+# #+# #
# Updated: 2023/01/12 12:42:40 by kdhrif ### ########.fr #
# #
# **************************************************************************** #
NAME = pipex
BONUS_NAME = pipex_bonus
SRCS_DIR = srcs
BONUS_DIR = bonus
OBJS_DIR = objs
BONUS_OBJS_DIR = bonus_objs
SRCS := $(shell find srcs/*.c -exec basename \ {} \;)
BONUS := $(shell find bonus/*.c -exec basename \ {} \;)
OBJS = ${patsubst %.c,${OBJS_DIR}/%.o,${SRCS}}
BONUS_OBJS = ${patsubst %.c,${BONUS_OBJS_DIR}/%.o,${BONUS}}
CC = gcc
CFLAGS = -g3 -Wall -Wextra -Werror
LIB = libft/libft.a
HEADERS = includes/pipex.h
BONUS_HEADERS = includes/pipex_bonus.h
all: $(NAME)
$(OBJS_DIR):
@mkdir -p $(OBJS_DIR)
@echo "\033[33mcompiling ${NAME}..."
@echo "SRCS = ${SRCS}"
@echo "OBJS = ${OBJS}"
$(BONUS_OBJS_DIR):
@mkdir -p $(BONUS_OBJS_DIR)
@echo "\033[33mcompiling ${NAME}..."
@echo "SRCS = ${BONUS}"
@echo "OBJS = ${BONUS_OBJS}"
${OBJS_DIR}/%.o: ${SRCS_DIR}/%.c
@${CC} ${CFLAGS} -c $< -o $@
${LIB} :
@make -C libft
${NAME}: $(LIB) $(OBJS_DIR) $(OBJS) ${HEADERS}
$(CC) $(CFLAGS) $(OBJS) ${LIB} -o $(NAME)
@echo "\033[32m$ ${NAME} compiled !"
${BONUS_OBJS_DIR}/%.o: ${BONUS_DIR}/%.c
@${CC} ${CFLAGS} -c $< -o $@
${BONUS_NAME}: $(LIB) $(BONUS_OBJS_DIR) $(BONUS_OBJS) ${BONUS_HEADERS}
$(CC) $(CFLAGS) $(BONUS_OBJS) ${LIB} -o $(BONUS_NAME)
@echo "\033[32m$ ${NAME} compiled !"
bonus: ${BONUS_NAME}
clean:
make -C libft clean
rm -rf $(OBJS_DIR)
rm -rf $(BONUS_OBJS_DIR)
fclean: clean
rm -rf $(NAME)
rm -rf $(BONUS_NAME)
re: fclean all
# valgrind: all
# valgrind --leak-check=full --show-leak-kinds=all ./$(NAME)
.PHONY: all clean fclean re