A collection of Makefile helpers to streamline command-line tooling for your projects.
This repository provides ready-to-use utilities for handling arguments, logging, and usage documentation in a clean and consistent way.
-
Self-documented Makefiles
Use inline comments to automatically generate a cleanmake helpoutput:##before a target β describes that target###before a section name β creates a section in the help output
-
Argument handling
- Access positional arguments:
$(call GET_ARG,1) - Access named variables:
$(my_var) - Join arguments with custom separators:
$(call JOIN_ARGS,|,$(ARGS))
- Access positional arguments:
-
Validation helpers
- Require a minimum number of arguments with usage message:
$(call REQUIRE_ARGS,2,<name> <age>)
- Require a named variable:
$(call REQUIRE_VAR,my_var)
- Require a minimum number of arguments with usage message:
-
Logging with colors
Standardized logging functions for info, success, warning, and error messages:$(call log,One log for fun) $(call log_info,Starting process...) $(call log_warn,Something looks odd...) $(call log_error,Something went wrong!!) $(call log_success,All done!)
include ./MakefileUtils.mk## Say hello to someone
hello:
$(call REQUIRE_ARGS, 1,<name>);
@name=$(call GET_ARG,1); \
printf "Hello %s\n" "$$name"make hello JohnSee Makefile for multiple usage examples
With make help, you automatically get a neat summary:
Usage:
make <target>
Available targets:
greet Say hello to someone
build Build the project
test Run all tests
- GNU Make
Contributions are welcome!
Feel free to open issues or pull requests to improve the utilities.