-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
138 lines (111 loc) · 6.98 KB
/
Makefile
File metadata and controls
138 lines (111 loc) · 6.98 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: joolibar <joolibar@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/08/29 17:28:14 by joolibar #+# #+# #
# Updated: 2026/03/10 12:54:35 by joolibar ### ########.fr #
# #
# **************************************************************************** #
################################################################################
# 📦 CONFIG #
################################################################################
# 📦 Program Name
NAME = libftprintf.a
# 📁 Directories
INC_DIR = inc
SRC_DIR = src
OBJ_DIR = obj
# 🛠️ Commands
CC = cc
CFLAGS = -Wall -Werror -Wextra
AR = ar -rcs
RM = rm -rf
MKD = mkdir -p
# 📜 Header
HEADER = $(INC_DIR)/ft_printf.h
################################################################################
# 📝 SOURCE FILES #
################################################################################
SRC_FILES = ft_c.c ft_check_specifier.c ft_d.c ft_i.c ft_p.c ft_printf.c \
ft_s.c ft_u.c ft_x.c ft_x_upper.c
################################################################################
# 🔗 SOURCE PATH CONSTRUCTION #
################################################################################
SRCS = $(addprefix $(SRC_DIR)/, $(SRC_FILES))
OBJS = $(SRCS:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
DEPS = $(OBJS:.o=.d)
################################################################################
# 🎨 COLORS #
################################################################################
DEF_COLOR = \033[0m
BOLD = \033[1m
GRAY = \033[0;90m
RED = \033[38;5;210m
GREEN = \033[38;5;114m
BLUE = \033[38;5;110m
PURPLE = \033[38;5;141m
CYAN = \033[38;5;123m
YELLOW = \033[38;5;228m
WHITE = \033[38;5;231m
ORANGE = \033[38;5;208m
################################################################################
# 🎭 BANNER #
################################################################################
define BANNER
$(CYAN)
╭──────────────────────────────────────────────────────────────────────────╮
│ │
│ ███████╗████████╗ ██████╗ ██████╗ ██╗███╗ ██╗████████╗███████╗ │
│ ██╔════╝╚══██╔══╝ ██╔══██╗██╔══██╗██║████╗ ██║╚══██╔══╝██╔════╝ │
│ █████╗ ██║ ██████╔╝██████╔╝██║██╔██╗██║ ██║ █████╗ │
│ ██╔══╝ ██║ ██╔═══╝ ██╔══██╗██║██║╚████║ ██║ ██╔══╝ │
│ ██║ ██║ ██║ ██║ ██║██║██║ ╚███║ ██║ ██║ │
│ ╚═╝ ╚═╝ ███████ ╚═╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚══╝ ╚═╝ ╚═╝ │
│ ╚═════╝ │
│ │
├──────────────────────────────────────────────────────────────────────────┤
│ $(WHITE)📖 Custom printf library$(CYAN) │
│ $(GRAY)made by joolibar • 42 School • 2026$(CYAN) │
╰──────────────────────────────────────────────────────────────────────────╯
$(DEF_COLOR)
endef
export BANNER
################################################################################
# 🎯 BUILD RULES #
################################################################################
all: banner $(NAME)
banner:
@echo "$$BANNER"
$(NAME): $(OBJS)
@$(AR) $(NAME) $(OBJS)
@echo "\n$(GREEN) ✓ Libftprintf built successfully! $(GRAY)[$(NAME)]$(DEF_COLOR)"
################################################################################
# 🔧 COMPILATION RULES #
################################################################################
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c Makefile $(HEADER)
@$(MKD) $(OBJ_DIR)
@printf "$(CYAN)\r › Compiling: $(WHITE)$<...\r$(DEF_COLOR)"
@$(CC) $(CFLAGS) -MMD -MP -I$(INC_DIR) -c $< -o $@
################################################################################
# 🧹 CLEANUP RULES #
################################################################################
clean:
@$(RM) $(OBJ_DIR)
@echo "$(YELLOW) ○ Object files cleaned$(DEF_COLOR)"
fclean: clean
@$(RM) $(NAME)
@echo "$(RED) ✗ Libraries removed$(DEF_COLOR)"
# Rebuild Everything
re: fclean all
@echo "\n$(ORANGE) ↺ Rebuild complete$(DEF_COLOR)"
################################################################################
# 🎯 PHONY TARGETS #
################################################################################
.PHONY: all clean fclean re banner
################################################################################
# 📋 DEPENDENCY INCLUSION #
################################################################################
-include $(DEPS)