-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
157 lines (127 loc) Β· 5.37 KB
/
Copy pathMakefile
File metadata and controls
157 lines (127 loc) Β· 5.37 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: xlamiel- <xlamiel-@student.42barcelona.com>+#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/08/01 22:51:59 by xlamiel- #+# #+# #
# Updated: 2025/11/13 17:04:28 by xlamiel- ### ########.fr #
# #
# **************************************************************************** #
###############################################################################
# πͺβΆοΈ Command line
###############################################################################
#
# gcc ./src/push_swap.c \
# -I./include \
# -I./libft/include \
# -L./libft \
# -lft \
# -oexec_push_swap
#
###############################################################################
# π¦ Project Configuration
###############################################################################
NAME := push_swap
SRC_DIR := src
OBJ_DIR := obj
DEP_DIR := dep
INCLUDE_DIR := include
LIBFT_DIR := ./libft
LIBFT := $(LIBFT_DIR)/libft.a
###############################################################################
# π οΈ Tools & Commands
###############################################################################
CC := cc
RM := rm -f
MKDIR := mkdir -p
###############################################################################
# βοΈ Compilation Flags
###############################################################################
CFLAGS := -Wall -Wextra -Werror
DEPFLAGS := -MMD -MP
INCLUDES := -I$(INCLUDE_DIR) -I$(LIBFT_DIR)/include
LDFLAGS := -L$(LIBFT_DIR)
LDLIBS := -lft
###############################################################################
# π¨ Terminal Colors
###############################################################################
GREEN := \033[0;32m
RED := \033[0;31m
RESET := \033[0m
###############################################################################
# π Source Files
###############################################################################
#$(SRC_DIR)/ps_sorting.c
SRC := \
$(SRC_DIR)/ps_basic_mov.c \
$(SRC_DIR)/ps_cost_calc.c \
$(SRC_DIR)/ps_help_test.c \
$(SRC_DIR)/ps_print_mov_p.c \
$(SRC_DIR)/ps_print_mov_r.c \
$(SRC_DIR)/ps_print_mov_rr.c \
$(SRC_DIR)/ps_print_mov_s.c \
$(SRC_DIR)/ps_sort_exec_mov.c \
$(SRC_DIR)/ps_sort_large.c \
$(SRC_DIR)/ps_sort_target.c \
$(SRC_DIR)/ps_sort_three.c \
$(SRC_DIR)/ps_sort_utils.c \
$(SRC_DIR)/ps_stack_init.c \
$(SRC_DIR)/ps_stack_ops1.c \
$(SRC_DIR)/ps_stack_ops2.c \
$(SRC_DIR)/push_swap.c
###############################################################################
# π§ Derived File Lists
###############################################################################
OBJ := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRC))
DEPS := $(patsubst $(SRC_DIR)/%.c,$(DEP_DIR)/%.d,$(SRC))
###############################################################################
# π Build Targets
###############################################################################
all: | $(OBJ_DIR) $(DEP_DIR)
all: $(LIBFT) $(NAME)
$(NAME): $(OBJ)
@$(CC) $(CFLAGS) $(OBJ) $(LDFLAGS) $(LDLIBS) -o $@
@echo "$(GREEN)β
Executable '$@' created$(RESET)"
$(LIBFT):
@$(MAKE) -C $(LIBFT_DIR)
###############################################################################
# π§± Object Compilation
###############################################################################
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c Makefile | $(OBJ_DIR) $(DEP_DIR)
@$(CC) $(CFLAGS) $(DEPFLAGS) $(INCLUDES) -c $< -o $@ -MF $(DEP_DIR)/$(notdir $*.d)
###############################################################################
# π Directory Creation
###############################################################################
$(OBJ_DIR):
@$(MKDIR) $@
$(DEP_DIR):
@$(MKDIR) $@
###############################################################################
# π§Ή Cleaning Rules
###############################################################################
clean:
@$(RM) -rf $(OBJ_DIR) $(DEP_DIR)
@echo "$(RED)π§Ή Object and dependency files removed$(RESET)"
@$(MAKE) -C $(LIBFT_DIR) clean
fclean: clean
@$(RM) $(NAME)
@echo "$(RED)π§Ή Executable '$(NAME)' removed$(RESET)"
@$(MAKE) -C $(LIBFT_DIR) fclean
re: fclean all
###############################################################################
# π Debug Build
###############################################################################
debug:
#@$(MAKE) -C $(LIBFT_DIR) debug
@$(MAKE) CFLAGS="$(CFLAGS) -g3" DEPFLAGS="$(DEPFLAGS)" re
###############################################################################
# π Dependency Inclusion
###############################################################################
#-include $(wildcard $(DEPS))
-include $(DEPS)
###############################################################################
# π Phony Targets
###############################################################################
.PHONY: all clean fclean re debug