-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
111 lines (94 loc) · 3.6 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: yzaytoun <[email protected] +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/10/03 19:16:59 by yzaytoun #+# #+# #
# Updated: 2022/11/02 21:07:52by yzaytoun ### ########.fr #
# #
# **************************************************************************** #
NAME = push_swap.a
PUSHBONUS := checker.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
# ------------------ Libft and printf ------------------------------
PRINTF = ft_printf/libftprintf.a
LIBFT = libft/libft.a
# ------------------------ Push Swap ------------------------------
SRC = pushswap_actions.c pushswap_aux.c\
pushswap_operations.c pushswap_sort.c pushswap_utils.c pushswap_utils2.c\
pushswap_merge.c pushswap_sort_aux.c pushswap_sort_aux2.c pushswap.c
BONUS = checker_aux_bonus.c checker_bonus.c
OBJDIR = obj
PUSH_OBJ := $(SRC:%.c=$(OBJDIR)/%.o)
PUSH_OBJB := $(BONUS:%.c=$(OBJDIR)/%.o)
$(OBJDIR)/%.o:%.c
@mkdir -p $(@D)
$(COMPILE.c) -o $@ $<
all: $(NAME)
$(NAME): $(LIBFT) $(PRINTF) $(PUSH_OBJ)
@echo "$(YELLOW)Compiling" $@
@$(AR) $(ARFLAGS) $@ $(PUSH_OBJ)
@echo "$(GREEN)Done!!"
@$(CC) $(NAME) $(LIBFT) $(PRINTF) main.c -o push_swap
@chmod +x push_swap
@echo "$(BLUE)************Push Swap is ready****************\n"
$(PRINTF) $(LIBFT) &:
@echo "$(YELLOW)Making Libft"
@cd libft; make bonus;
@echo "$(YELLOW)Making ft_printf"
@$(MAKE) -C ft_printf
@echo "$(GREEN)Finished!!!"
bonus: $(PUSHBONUS)
$(PUSHBONUS): $(LIBFT) $(PRINTF) $(PUSH_OBJ) $(PUSH_OBJB)
@echo "$(YELLOW)Doing Bonus part....."
@$(AR) $(ARFLAGS) $@ $(PUSH_OBJ) $(PUSH_OBJB)
@$(CC) $(PUSHBONUS) $(LIBFT) $(PRINTF) main_bonus.c -o checker
@chmod +x checker
@echo "$(PURPLE)\n************Checker DONE****************\n"
fclean: clean
@$(RM) $(NAME) push_swap $(PUSHBONUS) checker
clean:
@echo "$(RED)Cleaning libft and ft_printf"
@(cd libft; make fclean)
@(cd ft_printf; make fclean)
@echo "Cleaning Object files"
@$(RM) $(PUSH_OBJ) $(PUSH_OBJB) $(OBJDIR)
@echo "Cleaning push_swap and push_swap.a"
@echo "$(BLUE)\n*****************DONE Cleaning**********************\n\n"
re: fclean all bonus
.PHONY: bonus all re fclean clean