-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
106 lines (79 loc) · 3.2 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: lgaume <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/11/19 08:24:40 by lgaume #+# #+# #
# Updated: 2023/11/30 11:48:18 by lgaume ### ########.fr #
# #
# **************************************************************************** #
NAME = push_swap
BONUS = checker
cc = gcc
FLAGS = -Wall -Werror -Wextra -I
RM = rm -f
SRC_PATH = src/
OBJ_PATH = obj/
BONUS_PATH = bonus/
BONUS_OBJ_PATH = bonus_obj/
LIBFT = libft/libft.a
INC = inc/
# Source files
COST_DIR = $(SRC_PATH)cost/cost.c
INI_DIR = $(SRC_PATH)Initialization/initialization.c \
$(SRC_PATH)Initialization/input_check_utils.c \
$(SRC_PATH)Initialization/input_check.c \
$(SRC_PATH)Initialization/stacks.c
MOVE_DIR = $(SRC_PATH)move/do_move.c \
$(SRC_PATH)move/position.c
OPERATIONS_DIR = $(SRC_PATH)Operations/push.c \
$(SRC_PATH)Operations/reverse_rotate.c \
$(SRC_PATH)Operations/rotate.c \
$(SRC_PATH)Operations/swap.c
SORT_DIR = $(SRC_PATH)Sorting_algo/sort_tiny.c \
$(SRC_PATH)Sorting_algo/sort.c
UTILS_DIR = $(SRC_PATH)utils/split.c \
$(SRC_PATH)utils/utils.c
MAIN_DIR = $(SRC_PATH)main.c
BONUS_DIR = $(BONUS_PATH)checker.c \
$(SRC_PATH)initialization/initialization.c \
$(SRC_PATH)initialization/input_check.c \
$(SRC_PATH)initialization/input_check_utils.c \
$(SRC_PATH)initialization/stacks.c \
$(SRC_PATH)Operations/push.c \
$(SRC_PATH)Operations/reverse_rotate.c \
$(SRC_PATH)Operations/rotate.c \
$(SRC_PATH)Operations/swap.c \
$(SRC_PATH)Utils/split.c \
$(SRC_PATH)Utils/utils.c
SRCS = $(COST_DIR) $(INI_DIR) $(MOVE_DIR) $(OPERATIONS_DIR) $(SORT_DIR) $(UTILS_DIR) $(MAIN_DIR)
OBJS = $(patsubst $(SRC_PATH)%.c,$(OBJ_PATH)%.o,$(SRCS))
SRCS_BONUS = $(BONUS_DIR)
OBJS_BONUS = $(patsubst $(BONUS_PATH)%.c,$(BONUS_OBJ_PATH)%.o,$(SRCS_BONUS))
# Rules
all : $(NAME)
both : $(NAME) bonus
$(NAME): $(OBJS) $(LIBFT)
@$(CC) $(FLAGS) $(INC) $(OBJS) $(LIBFT) -o $(NAME)
bonus: $(OBJS_BONUS) $(LIBFT)
@$(CC) $(FLAGS) $(INC) $(OBJS_BONUS) $(LIBFT) -o $(BONUS)
$(LIBFT):
@make -C ./libft
$(OBJ_PATH)%.o: $(SRC_PATH)%.c
@mkdir -p $(@D)
@$(CC) $(FLAGS) $(INC) -c $< -o $@
$(BONUS_OBJ_PATH)%.o: $(BONUS_PATH)%.c
@mkdir -p $(@D)
@$(CC) $(FLAGS) $(INC) -c $< -o $@
clean:
@$(RM) -r $(OBJ_PATH)
@$(RM) -r $(BONUS_OBJ_PATH)
@make clean -C ./libft
fclean: clean
@$(RM) $(NAME)
@$(RM) $(BONUS)
@make fclean -C ./libft
re: fclean all bonus
.PHONY: all clean fclean re bonus both