make help

This commit is contained in:
whaffman 2025-02-23 13:33:09 +01:00
parent 3eb742d3fe
commit 757aea6464
2 changed files with 35 additions and 13 deletions

View File

@ -6,7 +6,7 @@
# By: qmennen <qmennen@student.codam.nl> +#+ # # By: qmennen <qmennen@student.codam.nl> +#+ #
# +#+ # # +#+ #
# Created: 2024/10/15 11:48:46 by whaffman #+# #+# # # Created: 2024/10/15 11:48:46 by whaffman #+# #+# #
# Updated: 2025/02/23 11:20:52 by willem ######## odam.nl # # Updated: 2025/02/23 12:30:21 by willem ######## odam.nl #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -53,13 +53,12 @@ $(1): CFLAGS = $$($(1)_CFLAGS)
$(1): $(BUILD_PATH)/$(1)/$(NAME) $(1): $(BUILD_PATH)/$(1)/$(NAME)
.PHONY: run_$(1) .PHONY: run_$(1)
run_$(1): $(1) run_$(1): $(1)
$$(info $(bold)$(green)Running $(1)$(reset)) $$(info $$(bold)$$(green)Running $(1)$$(reset))
./$(BUILD_PATH)/$(1)/$(NAME) ./$(BUILD_PATH)/$(1)/$(NAME)
$(BUILD_PATH)/$(1)/$(NAME): $(LIBFT) $$($(1)_OBJECTS) $(BUILD_PATH)/$(1)/$(NAME): $(LIBFT) $$($(1)_OBJECTS)
$$(info $(bold)$(green)Linking $(1) config$(reset)) $$(info $$(bold)$$(green)Linking $(1) config$$(reset))
$$(CC) $$(CFLAGS) $$($(1)_OBJECTS) $$(LDLIBS) -o $$@ $$(CC) $$(CFLAGS) $$($(1)_OBJECTS) $$(LDLIBS) -o $$@
-include $$($(1)_DEPENDS) -include $$($(1)_DEPENDS)
@ -68,7 +67,7 @@ $$($(1)_OBJ_PATH)/%.o: %.c $(LIBFT) | $$($(1)_OBJ_PATH)
$$(CC) $$(CFLAGS) $$(INCLUDES) -MMD -MP -c $$< -o $$@ $$(CC) $$(CFLAGS) $$(INCLUDES) -MMD -MP -c $$< -o $$@
$$($(1)_OBJ_PATH): $$($(1)_OBJ_PATH):
$$(info $(bold)$(green)Creating $(1) object directory$(reset)) $$(info $$(bold)$$(green)Creating $(1) object directory$$(reset))
mkdir -p $$@ mkdir -p $$@
endef endef
@ -81,10 +80,10 @@ $(foreach config,$(BUILD_CONFIGS),$(eval $(call BUILD_TARGETS,$(config))))
# Build all configurations # Build all configurations
all: release debug asan tsan all: release debug asan tsan
$(info $(bold)$(green)Building all$(reset)) $(info $(bold)$(green)All builc config have been build$(reset))
# Build libft # Build libft
$(LIBFT): $(LIBFT_PATH) check-and-reinit-submodules $(LIBFT): $(LIBFT_PATH) submodules
$(info $(bold)$(green)Building libft$(reset)) $(info $(bold)$(green)Building libft$(reset))
$(MAKE) -C $(LIBFT_PATH) $(MAKE) -C $(LIBFT_PATH)
@ -118,11 +117,10 @@ re: fclean
# Run the project with the release build configuration # Run the project with the release build configuration
run: run_release run: run_release
$(info $(bold)$(green)Running$(reset))
# Remove sources.mk to force regeneration # Remove sources.mk to force regeneration
srcs: srcs:
$(info $(bold)$(green)Regenerating sources.mk$(reset)) $(info $(bold)$(green)Regenerating sources.mk on next make$(reset))
$(RM) sources.mk $(RM) sources.mk
# Show this help. # Show this help.
@ -130,11 +128,35 @@ help:
@echo "Usage: make [target]" @echo "Usage: make [target]"
@echo "" @echo ""
@echo "Targets:" @echo "Targets:"
@awk '/^#/{c=substr($$0,3);next}c&&/^[[:alpha:]][[:alnum:]_-]+:/{print substr($$1,1,index($$1,":")),c}1{c=0}' $(MAKEFILE_LIST) | column -s: -t @echo " $(green)$(bold)all $(reset)- Build all configurations (release, debug, asan, tsan)"
@echo " $(green)$(bold)clean $(reset)- Remove build artifacts"
@echo " $(green)$(bold)fclean $(reset)- Remove build artifacts and the executable"
@echo " $(green)$(bold)re $(reset)- Rebuild the project"
@echo " $(green)$(bold)run $(reset)- Run the release build"
@echo " $(green)$(bold)srcs $(reset)- Remove sources.mk"
@echo " $(green)$(bold)help $(reset)- Show this help message"
@echo ""
@echo "Build configurations:"
@echo " $(green)$(bold)release $(reset)- Build with release configuration"
@echo " $(green)$(bold)debug $(reset)- Build with debug configuration"
@echo " $(green)$(bold)asan $(reset)- Build with AddressSanitizer configuration"
@echo " $(green)$(bold)tsan $(reset)- Build with ThreadSanitizer configuration"
@echo ""
@echo "Run configurations:"
@echo " $(green)$(bold)run_release $(reset)- Run the release build"
@echo " $(green)$(bold)run_debug $(reset)- Run the debug build"
@echo " $(green)$(bold)run_asan $(reset)- Run the AddressSanitizer build"
@echo " $(green)$(bold)run_tsan $(reset)- Run the ThreadSanitizer build"
@echo ""
@echo "Other targets:"
@echo " $(green)$(bold)submodules $(reset)- Check and reinitialize git submodules"
@echo " $(green)$(bold)libft $(reset)- Build libft"
@echo " $(green)$(bold)sources.mk $(reset)- Generate sources.mk"
@echo "" @echo ""
.PHONY: check-and-reinit-submodules
check-and-reinit-submodules: .PHONY: submodules
submodules:
$(info $(bold)$(green)Checking and reinitializing submodules$(reset)) $(info $(bold)$(green)Checking and reinitializing submodules$(reset))
@if git submodule status | egrep -q '^[-+]' ; then \ @if git submodule status | egrep -q '^[-+]' ; then \
echo "INFO: Need to reinitialize git submodules"; \ echo "INFO: Need to reinitialize git submodules"; \

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/02/05 16:04:44 by whaffman #+# #+# */ /* Created: 2025/02/05 16:04:44 by whaffman #+# #+# */
/* Updated: 2025/02/05 16:05:07 by whaffman ######## odam.nl */ /* Updated: 2025/02/23 12:31:28 by willem ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */