-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (60 loc) · 2.32 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: armgonza <[email protected] +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/09/19 07:49:59 by armgonza #+# #+# #
# Updated: 2024/09/19 07:50:07 by armgonza ### ########.fr #
# #
# **************************************************************************** #
# Standard
NAME = push_swap
# Directories
LIBFT = ./libft/libft.a
INC = inc/
SRC_DIR = src/
OBJ_DIR = obj/
# Compiler and CFlags
CC = gcc
CFLAGS = -Wall -Werror -Wextra -Iinc/ -g
RM = rm -f
# Source Files
COMMANDS_DIR = $(SRC_DIR)commands/push.c \
$(SRC_DIR)commands/rev_rotate.c \
$(SRC_DIR)commands/rotate.c \
$(SRC_DIR)commands/sort_stacks.c \
$(SRC_DIR)commands/sort_three.c \
$(SRC_DIR)commands/swap.c
PUSH_SWAP_DIR = $(SRC_DIR)push_swap/errors.c \
$(SRC_DIR)push_swap/init_a-b.c \
$(SRC_DIR)push_swap/init_b-a.c \
$(SRC_DIR)push_swap/push_swap.c \
$(SRC_DIR)push_swap/stack_init.c \
$(SRC_DIR)push_swap/stack_utils.c
# Concatenate all source files
SRCS = $(COMMANDS_DIR) $(PUSH_SWAP_DIR)
# Apply the pattern substitution to each source file in SRC and produce a corresponding list of object files in the OBJ_DIR
OBJ = $(patsubst $(SRC_DIR)%.c,$(OBJ_DIR)%.o,$(SRCS))
# Build rules
start:
@make all
$(LIBFT):
@make -C ./libft
all: $(NAME)
$(NAME): $(OBJ) $(LIBFT)
@$(CC) $(OBJ) $(LIBFT) -o $(NAME)
# Compile object files from source files
$(OBJ_DIR)%.o: $(SRC_DIR)%.c
@mkdir -p $(@D)
@$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
@$(RM) -r $(OBJ_DIR)
@make clean -C ./libft
fclean: clean
@$(RM) $(NAME)
@$(RM) $(LIBFT)
re: fclean all
# Phony targets represent actions not files
.PHONY: start all clean fclean re