-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (59 loc) · 2.47 KB
/
Makefile
File metadata and controls
71 lines (59 loc) · 2.47 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: kiroussa <contact@dynamicdispat.ch> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2026/03/05 01:44:00 by kiroussa #+# #+# #
# Updated: 2026/03/26 00:00:55 by kiroussa ### ########.fr #
# #
# **************************************************************************** #
PROJECT_ROOT := $(shell pwd)
CURRENT_MODULE := <root>
MODULE_NAME := root
include ./make/config.mk
include ./make/colors.mk
include ./make/functions.mk
define moduleOutput
ifeq ($(1),$(FINAL_MODULE))
$(call provideModuleOutput,$(1)): $(MODULES_DIR)/$(1)/Makefile $(LIB_MODULES_OUTPUT)
else
$(call provideModuleOutput,$(1)): $(MODULES_DIR)/$(1)/Makefile
endif
@$(MAKE) -C $(MODULES_DIR)/$(1)
endef
define moduleDelegate
$(1)_$(2):
@$(MAKE) -C $(MODULES_DIR)/$(2) $(1)
endef
.PHONY: all
all:
@$(MAKE) -j$(shell nproc) $(EXECUTABLE)
include $(shell find $(SHARED_BUILD_DIR) -type f -name '*.d' 2>/dev/null)
$(SHARED_BUILD_DIR)/%:
@# @echo "[*] Invalidating $@"
@if [ $(findstring .c, $<) ] || [ $(findstring .s, $<) ]; then \
rm -rf $@; \
fi
$(EXECUTABLE): $(FINAL_MODULE_OUTPUT)
@$(call taskStart,Linking $(BOLD)$<$(RESET) to $(BOLD)$@$(RESET)\n)
@ln -sf $< $@
$(foreach module,$(MODULES),$(eval $(call moduleOutput,$(module))))
$(foreach module,$(MODULES),$(eval $(call moduleDelegate,clean,$(module))))
$(foreach module,$(MODULES),$(eval $(call moduleDelegate,fclean,$(module))))
.PHONY: clean
clean: # $(MODULES:%=clean_%)
@$(call taskStart,Removing build directory $(BOLD)$(SHARED_BUILD_DIR)/$(RESET)\n)
@rm -rf $(SHARED_BUILD_DIR)
.PHONY: fclean
fclean: clean # $(MODULES:%=fclean_%)
@$(call taskStart,Removing executable $(BOLD)$(EXECUTABLE)$(RESET)\n)
@rm -f $(EXECUTABLE)
.PHONY: compile_commands.json
compile_commands.json: fclean
@$(call taskStart,Generating $(BOLD)$@$(RESET)\n)
@bear -- $(MAKE) -j$(shell nproc)
@sed -i 's|$(CXX)|$(shell which $(CXX))|g' compile_commands.json
.PHONY: re
re: fclean all