-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
94 lines (76 loc) · 2.87 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: aderison <aderison@student.s19.be> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/12/16 12:25:14 by arnaud #+# #+# #
# Updated: 2024/07/16 17:04:34 by aderison ### ########.fr #
# #
# **************************************************************************** #
NAME = push_swap
CC = gcc
OBJ_DIR = obj
CFLAGS = -Wall -Wextra -Werror
LIBFT_I = ./lib/libft/include/
PUSHSWAP_I = ./include/
INCLUDES = -I$(LIBFT_I) -I$(PUSHSWAP_I)
# Colors
RED=\033[0;31m
GREEN=\033[0;32m
YELLOW=\033[1;33m
CYAN=\033[0;36m
NC=\033[0m
#push_swap operation
PUSH_SWAP_OPE = $(addprefix operations/, push.c reverse.c rotate.c swap.c)
#push_swap sort
PUSH_SWAP_SORT = $(addprefix sort/, move.c one-two.c quicksort.c sort.c)
#push_swap utils
PUSH_SWAP_UTILS = $(addprefix utils/, operations.c quicksort.c stack.c)
#push_swap stack
PUSH_SWAP_STACK = $(addprefix stack/, stack_error.c stack_init.c)
#push_swap main
PUSH_SWAP_MAIN = main.c
# Push_swap sources
PUSH_SWAP_SRCS = $(addprefix src/, $(PUSH_SWAP_SORT) \
$(PUSH_SWAP_UTILS) $(PUSH_SWAP_OPE) $(PUSH_SWAP_MAIN) $(PUSH_SWAP_STACK))
PUSH_SWAP_OBJS = $(PUSH_SWAP_SRCS:src/%.c=obj/%.o)
#checker
CHECKER_F = $(addprefix src/, $(PUSH_SWAP_SORT) \
$(PUSH_SWAP_UTILS) $(PUSH_SWAP_OPE) $(PUSH_SWAP_STACK))
CHECKER = $(addprefix src/bonus/, checker.c utils.c)
CHECKER_SRCS = $(CHECKER_F) $(CHECKER)
CHECKER_OBJS = $(CHECKER_SRCS:src/%.c=obj/%.o)
# Compilation rules
all: $(NAME)
$(NAME): $(PUSH_SWAP_OBJS)
@mkdir -p $(dir $@)
@cd ./lib/libft && make
@cp ./lib/libft/libft.a ./libft.a
@$(CC) $(CFLAGS) $(INCLUDES) $^ libft.a -o $@
@echo "${YELLOW}Executable $(NAME) created.${NC}"
bonus: $(CHECKER_OBJS)
@mkdir -p $(dir $@)
@cd ./lib/libft && make
@cp ./lib/libft/libft.a ./libft.a
@$(CC) $(CFLAGS) $(INCLUDES) $^ libft.a -o checker
@echo "${YELLOW}Executable checker created.${NC}"
obj/%.o: src/%.c
@mkdir -p $(dir $@)
@echo "\r${CYAN}Compiling $<...${NC}"
@$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
@rm -rf $(OBJ_DIR)
@echo "${GREEN}Object files cleaned.${NC}"
clean-libft:
@rm -rf ./lib/libft/obj
@rm -f ./lib/libft/libft.a
@echo "${RED}All files removed on libft.${NC}"
fclean: clean clean-libft
@rm -f libft.a
@rm -f $(NAME)
@rm -f checker
@echo "${RED}All files removed.${NC}"
re: fclean all
.PHONY: all clean fclean re clean-libft bonus