-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
114 lines (94 loc) · 3.52 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
111
112
113
114
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: yzaytoun <[email protected] +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/10/03 19:16:59 by yzaytoun #+# #+# #
# Updated: 2022/11/02 21:07:52by yzaytoun ### ########.fr #
# #
# **************************************************************************** #
NAME = pipex.a
vpath %.c src
vpath %.h include
vpath %_bonus.c bonus
vpath %.o obj
# ************************ Colors ***********************************
ifneq (,$(findstring xterm,${TERM}))
BLACK := $(shell tput -Txterm setaf 0)
RED := $(shell tput -Txterm setaf 1)
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
LIGHTPURPLE := $(shell tput -Txterm setaf 4)
PURPLE := $(shell tput -Txterm setaf 5)
BLUE := $(shell tput -Txterm setaf 6)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
else
BLACK := ""
RED := ""
GREEN := ""
YELLOW := ""
LIGHTPURPLE := ""
PURPLE := ""
BLUE := ""
WHITE := ""
RESET := ""
endif
# --------------------- Definitions ------------------------------------
CC = gcc
AR = ar
ARFLAGS = -rcs
INC = include
CFLAGS = -Wall -Wextra -Werror -I $(INC) -g3
RM = rm -fr
SANITIAZE = -fsanitize=address -g3
PIPEXBONUS := .
# ------------------ Libft and printf ------------------------------
PRINTF = ft_printf/libftprintf.a
LIBFT = libft/libft.a
# ------------------------ Pipex ------------------------------
SRC = get_next_line.c get_next_line_utils.c pipe_com.c pipex_IO.c pipex_aux.c\
pipex_free.c pipex_list.c pipex_util.c pipex_string.c
BONUS = heredoc_bonus.c pipes_aux_bonus.c pipex_free_bonus.c
OBJDIR = obj
PIP_OBJ := $(SRC:%.c=$(OBJDIR)/%.o)
PIP_OBJB := $(BONUS:%.c=$(OBJDIR)/%.o)
$(OBJDIR)/%.o:%.c
@mkdir -p $(@D)
$(COMPILE.c) -o $@ $<
all: $(NAME)
$(NAME): $(LIBFT) $(PRINTF) $(PIP_OBJ) $(OBJDIR)
@echo "$(YELLOW)Compiling" $@
@$(AR) $(ARFLAGS) $@ $(PIP_OBJ)
@echo "$(GREEN)Done!!"
@$(CC) $(NAME) $(LIBFT) $(PRINTF) main.c -o
@chmod +x pipex
@echo "$(YELLOW)************Pipex Mandatory ready************,****\n"
$(PRINTF) $(LIBFT) &:
@echo "$(YELLOW)Making Libft"
@$(MAKE) -C libft
@echo "$(YELLOW)Making ft_printf"
@$(MAKE) -C ft_printf
@echo "$(GREEN)Finished!!!"
bonus: $(PIPEXBONUS)
$(PIPEXBONUS): $(LIBFT) $(PRINTF) $(PIP_OBJ) $(PIP_OBJB)
@echo "$(YELLOW)Doing Bonus part....."
@$(AR) $(ARFLAGS) $(NAME) $(PIP_OBJ) $(PIP_OBJB)
@$(CC) $(NAME) $(LIBFT) $(PRINTF) main_bonus.c -o pipex
@chmod +x pipex
@echo "$(GREEN)\n************Pipex bonus is ready****************\n"
fclean: clean
@$(RM) $(NAME) pipex
clean:
@echo "$(RED)Cleaning libft and ft_printf"
@(cd libft; make fclean)
@(cd ft_printf; make fclean)
@echo "Cleaning Object files"
@$(RM) $(PIP_OBJ) $(PIP_OBJB)
@echo "Cleaning pipex and pipex.a"
@$(RM) $(OBJDIR)
@echo "$(DONE)\n*****************DONE Cleaning**********************\n\n"
re: fclean bonus all
.PHONY: re all bonus fclean clean