make help
This commit is contained in:
parent
3eb742d3fe
commit
757aea6464
46
Makefile
46
Makefile
@ -6,7 +6,7 @@
|
||||
# By: qmennen <qmennen@student.codam.nl> +#+ #
|
||||
# +#+ #
|
||||
# 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)
|
||||
|
||||
.PHONY: run_$(1)
|
||||
|
||||
run_$(1): $(1)
|
||||
$$(info $(bold)$(green)Running $(1)$(reset))
|
||||
$$(info $$(bold)$$(green)Running $(1)$$(reset))
|
||||
./$(BUILD_PATH)/$(1)/$(NAME)
|
||||
|
||||
$(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 $$@
|
||||
|
||||
-include $$($(1)_DEPENDS)
|
||||
@ -68,7 +67,7 @@ $$($(1)_OBJ_PATH)/%.o: %.c $(LIBFT) | $$($(1)_OBJ_PATH)
|
||||
$$(CC) $$(CFLAGS) $$(INCLUDES) -MMD -MP -c $$< -o $$@
|
||||
|
||||
$$($(1)_OBJ_PATH):
|
||||
$$(info $(bold)$(green)Creating $(1) object directory$(reset))
|
||||
$$(info $$(bold)$$(green)Creating $(1) object directory$$(reset))
|
||||
mkdir -p $$@
|
||||
endef
|
||||
|
||||
@ -81,10 +80,10 @@ $(foreach config,$(BUILD_CONFIGS),$(eval $(call BUILD_TARGETS,$(config))))
|
||||
|
||||
# Build all configurations
|
||||
all: release debug asan tsan
|
||||
$(info $(bold)$(green)Building all$(reset))
|
||||
$(info $(bold)$(green)All builc config have been build$(reset))
|
||||
|
||||
# Build libft
|
||||
$(LIBFT): $(LIBFT_PATH) check-and-reinit-submodules
|
||||
$(LIBFT): $(LIBFT_PATH) submodules
|
||||
$(info $(bold)$(green)Building libft$(reset))
|
||||
$(MAKE) -C $(LIBFT_PATH)
|
||||
|
||||
@ -118,11 +117,10 @@ re: fclean
|
||||
|
||||
# Run the project with the release build configuration
|
||||
run: run_release
|
||||
$(info $(bold)$(green)Running$(reset))
|
||||
|
||||
# Remove sources.mk to force regeneration
|
||||
srcs:
|
||||
$(info $(bold)$(green)Regenerating sources.mk$(reset))
|
||||
$(info $(bold)$(green)Regenerating sources.mk on next make$(reset))
|
||||
$(RM) sources.mk
|
||||
|
||||
# Show this help.
|
||||
@ -130,11 +128,35 @@ help:
|
||||
@echo "Usage: make [target]"
|
||||
@echo ""
|
||||
@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 ""
|
||||
|
||||
.PHONY: check-and-reinit-submodules
|
||||
check-and-reinit-submodules:
|
||||
|
||||
.PHONY: submodules
|
||||
submodules:
|
||||
$(info $(bold)$(green)Checking and reinitializing submodules$(reset))
|
||||
@if git submodule status | egrep -q '^[-+]' ; then \
|
||||
echo "INFO: Need to reinitialize git submodules"; \
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user