diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2025-08-02 20:39:08 +0200 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2025-08-02 20:39:08 +0200 |
| commit | 6a351ac15e3604b94e39cde39eb63de421a7e0ef (patch) | |
| tree | 84b0b442961695cc869d2d3e883f2ee211950783 /makext.mk | |
| parent | f871619d7fedbf973c249ad6e16c0fcf7e819cf8 (diff) | |
| download | mitjafelicijan.com-6a351ac15e3604b94e39cde39eb63de421a7e0ef.tar.gz | |
Added makext
Diffstat (limited to 'makext.mk')
| -rw-r--r-- | makext.mk | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/makext.mk b/makext.mk new file mode 100644 index 0000000..bbfa148 --- /dev/null +++ b/makext.mk | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | # Makext is a collection of useful extensions for Makefiles, aimed at | ||
| 2 | # simplifying and enhancing the functionality of Make-based projects. These | ||
| 3 | # extensions provide additional features and convenience functions to | ||
| 4 | # improve the build process, manage dependencies, and streamline common | ||
| 5 | # tasks. | ||
| 6 | # | ||
| 7 | # Visit the GitHub repository at https://github.com/mitjafelicijan/makext | ||
| 8 | # to learn more and contribute to the project. | ||
| 9 | # | ||
| 10 | # `makext` was written by Mitja Felicijan and is released under the BSD | ||
| 11 | # two-clause license, see the LICENSE file for more information. | ||
| 12 | |||
| 13 | # Load environmental files from `MEX_ENVIRONMENT`. By default GNU make | ||
| 14 | # loads what is already in `env`. This extends it to other files. | ||
| 15 | ifdef MEX_ENVIRONMENT | ||
| 16 | TEMP_ENV_FILES=$(shell echo $(MEX_ENVIRONMENT) | tr ',' ' ') | ||
| 17 | $(foreach file,$(TEMP_ENV_FILES),$(eval include $(file))) | ||
| 18 | endif | ||
| 19 | |||
| 20 | # Help extension that lists all the targets with descriptions | ||
| 21 | # and adds description and license information if data provided. | ||
| 22 | .PHONY: .help | ||
| 23 | .help: | ||
| 24 | ifdef MEX_DESCRIPTION | ||
| 25 | @printf "%s\n\n" $(MEX_DESCRIPTION) | fmt | ||
| 26 | endif | ||
| 27 | @echo "Targets:" | ||
| 28 | @grep -vE '^[[:space:]]' $(MAKEFILE_LIST) | grep -E '^.*:.* #' | sed -E 's/(.*):(.*):.*#(.*)/ \2###\3/' | column -t -s '###' | ||
| 29 | ifdef MEX_LICENSE | ||
| 30 | @printf "\n%s" $(MEX_LICENSE) | fmt | ||
| 31 | endif | ||
| 32 | |||
| 33 | # Checks `MEX_ASSURE` variable if all the programs declared actually | ||
| 34 | # exist on a machine. If not this exists make with error. | ||
| 35 | .PHONY: .assure | ||
| 36 | .assure: | ||
| 37 | ifndef MEX_ASSURE | ||
| 38 | @printf "Variable MEX_ASSURE is not defined. Can not check for programs.\n" | ||
| 39 | else | ||
| 40 | @for prog in $(shell echo $(MEX_ASSURE)); do \ | ||
| 41 | if ! which $$prog > /dev/null; then \ | ||
| 42 | echo "Error: '$$prog' not found on this machine."; \ | ||
| 43 | exit 1; \ | ||
| 44 | fi; \ | ||
| 45 | done | ||
| 46 | endif | ||
