-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
154 lines (131 loc) · 7.11 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
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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: elagouch <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/01/23 07:56:10 by elagouch #+# #+# #
# Updated: 2025/01/31 15:35:44 by elagouch ### ########.fr #
# #
# **************************************************************************** #
# **************************************************************************** #
# ANSI COLOR CODES #
# **************************************************************************** #
include $(realpath ./extra-make/art.mk)
COLOR = $(COLOR_FT)
# **************************************************************************** #
# METADATA #
# **************************************************************************** #
GPM_FNAME = ft
# **************************************************************************** #
# COMMANDS #
# **************************************************************************** #
include $(realpath ./extra-make/commands.mk)
# **************************************************************************** #
# JOBS #
# **************************************************************************** #
# Format: milestone_number:job_name
JOBS = \
0:libft \
1:born2beroot \
1:ft_printf \
1:get_next_line \
2:push_swap \
2:pipex
JOBS_EXTRA = \
arthur \
ps-visualizer-minecraft
# **************************************************************************** #
# MAPPING #
# **************************************************************************** #
MILESTONE_TARGETS = $(foreach job,$(JOBS),milestone$(word 1,$(subst :, ,$(job)))$(word 2,$(subst :, ,$(job))))
MILESTONE_EXTRAS = $(foreach job,$(JOBS_EXTRA),extra-$(job))
SHORT_TARGETS = $(foreach job,$(JOBS),$(word 2,$(subst :, ,$(job))))
ALL_TARGETS = $(SHORT_TARGETS) $(MILESTONE_TARGETS)
# Get unique milestone numbers
MILESTONES = $(sort $(foreach job,$(JOBS),$(word 1,$(subst :, ,$(job)))))
# **************************************************************************** #
# TARGETS #
# **************************************************************************** #
default:
@$(ECHO) "$(MSG)👀 Please choose a project to build or run 'make all'.\n"
@$(ECHO) "\t\t Run 'make list' to see all available projects.\n"
# List all projects organized by milestone
list:
@$(ECHO) "$(MSG)👀 Available common core projects:$(RESET)\n"
@$(foreach mile,$(MILESTONES),\
$(foreach job,$(filter $(mile):%,$(JOBS)),\
$(ECHO) "$(MSG) - $(mile) $(word 2,$(subst :, ,$(job)))\n"; \
) \
)
@$(ECHO) "$(MSG)👀 Available extra projects:$(RESET)\n"
@$(foreach job,$(JOBS_EXTRA),\
$(ECHO) "$(MSG) - $(job)\n"; \
)
# Generate the short-name targets (e.g., libft)
$(foreach job,$(JOBS),$(eval $(word 2,$(subst :, ,$(job))): milestone$(word 1,$(subst :, ,$(job)))$(word 2,$(subst :, ,$(job)))))
# Generate the milestone targets (e.g., milestone0libft)
define make_milestone_target
milestone$(word 1,$(subst :, ,$(1)))$(word 2,$(subst :, ,$(1))):
@$(ECHO) "$(MSG)🏗️ Building $(word 2,$(subst :, ,$(1)))\n"
@$(MAKE) -C milestone-$(word 1,$(subst :, ,$(1)))-$(word 2,$(subst :, ,$(1)))
endef
define make_extra_target
extra-$(1):
@$(ECHO) "$(MSG)🏗️ Building $(1)\n"
@$(MAKE) -C $(1)
endef
$(foreach job,$(JOBS),$(eval $(call make_milestone_target,$(job))))
$(foreach job,$(JOBS_EXTRA),$(eval $(call make_extra_target,$(job))))
title:
@$(ECHO) "$(MSG)⢕⢕⢕⢕⢕⠅⢗⢕⠕⣠⠄⣗⢕⢕⠕⢕⢕⢕⠕⢠⣿⠐⢕⢕⢕⠑⢕⢕⠵⢕ __ ____ __ ____ \n"
@$(ECHO) "$(MSG)⢕⢕⢕⢕⠁⢜⠕⢁⣴⣿⡇⢓⢕⢵⢐⢕⢕⠕⢁⣾⢿⣧⠑⢕⢕⠄⢑⢕⠅⢕ / / ___ / / /__ _ _____ ____/ /__/ / / \n"
@$(ECHO) "$(MSG)⢕⢕⠵⢁⠔⢁⣤⣤⣶⣶⣶⡐⣕⢽⠐⢕⠕⣡⣾⣶⣶⣶⣤⡁⢓⢕⠄⢑⢅⢑ / _ \\/ -_) / / _ \\_ | |/|/ / _ \\/ __/ / _ /_/ \n"
@$(ECHO) "$(MSG)⠍⣧⠄⣶⣾⣿⣿⣿⣿⣿⣿⣷⣔⢕⢄⢡⣾⣿⣿⣿⣿⣿⣿⣿⣦⡑⢕⢤⠱⢐ /_//_/\\__/_/_/\\___( ) |__,__/\\___/_/ /_/\\_,_(_) \n"
@$(ECHO) "$(MSG)⢠⢕⠅⣾⣿⠋⢿⣿⣿⣿⠉⣿⣿⣷⣦⣶⣽⣿⣿⠈⣿⣿⣿⣿⠏⢹⣷⣷⡅⢐ |/ \n"
@$(ECHO) "$(MSG)⣔⢕⢥⢻⣿⡀⠈⠛⠛⠁⢠⣿⣿⣿⣿⣿⣿⣿⣿⡀⠈⠛⠛⠁⢀⣼⣿⣿⡇⢔ __ _ __ ___ _____ \n"
@$(ECHO) "$(MSG)⢕⢕⢽⢸⢟⢟⢖⢖⢤⣶⡟⢻⣿⡿⠻⣿⣿⡟⢀⣿⣦⢤⢤⢔⢞⢿⢿⣿⠁⢕ / / __ __(_) /__/ (_)__ ___ _ / _/ /_ \n"
@$(ECHO) "$(MSG)⢕⢕⠅⣐⢕⢕⢕⢕⢕⣿⣿⡄⠛⢀⣦⠈⠛⢁⣼⣿⢗⢕⢕⢕⢕⢕⢕⡏⣘⢕ / _ \\/ // / / / _ / / _ \\/ _ \`/ / _/ __/ \n"
@$(ECHO) "$(MSG)⢕⢕⠅⢓⣕⣕⣕⣕⣵⣿⣿⣿⣾⣿⣿⣿⣿⣿⣿⣿⣷⣕⢕⢕⢕⢕⡵⢀⢕⢕ /_.__/\\_,_/_/_/\\_,_/_/_//_/\\_, / /_/ \\__/ \n"
@$(ECHO) "$(MSG)⢑⢕⠃⡈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢃⢕⢕⢕ /___/ \n"
@$(ECHO) "$(MSG)🏗️ Building all projects\n"
all-core:
@for job in $(JOBS); do \
dir=milestone-$$(echo $$job | cut -d: -f1)-$$(echo $$job | cut -d: -f2); \
(cd "$$dir" && $(MAKE)); \
done
all-extra:
@for job in $(JOBS_EXTRA); do \
(cd "extra-$$job" && $(MAKE)); \
done
all: title all-core all-extra
core: title all-core
common: core
commons: core
extra: title all-extra
extras: extra
# Clean targets with better path handling
clean:
@$(ECHO) "$(MSG)🧹 Cleaning all projects\n"
@for job in $(JOBS); do \
dir=milestone-$$(echo $$job | cut -d: -f1)-$$(echo $$job | cut -d: -f2); \
(cd "$$dir" && $(MAKE) clean); \
done
@for job in $(JOBS_EXTRA); do \
(cd "extra-$$job" && $(MAKE) clean); \
done
fclean:
@$(ECHO) "$(MSG)🧹 Fcleaning all projects\n"
@for job in $(JOBS); do \
dir=milestone-$$(echo $$job | cut -d: -f1)-$$(echo $$job | cut -d: -f2); \
(cd "$$dir" && $(MAKE) fclean); \
done
@for job in $(JOBS_EXTRA); do \
(cd "extra-$$job" && $(MAKE) fclean); \
done
# **************************************************************************** #
# MAKE METADATA #
# **************************************************************************** #
MAKEFLAGS += --no-print-directory
.PHONY: clean fclean default $(ALL_TARGETS) all title all-core all-extra