aboutsummaryrefslogtreecommitdiff
path: root/makext.mk
diff options
context:
space:
mode:
Diffstat (limited to 'makext.mk')
-rw-r--r--makext.mk46
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.
15ifdef MEX_ENVIRONMENT
16TEMP_ENV_FILES=$(shell echo $(MEX_ENVIRONMENT) | tr ',' ' ')
17$(foreach file,$(TEMP_ENV_FILES),$(eval include $(file)))
18endif
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:
24ifdef MEX_DESCRIPTION
25 @printf "%s\n\n" $(MEX_DESCRIPTION) | fmt
26endif
27 @echo "Targets:"
28 @grep -vE '^[[:space:]]' $(MAKEFILE_LIST) | grep -E '^.*:.* #' | sed -E 's/(.*):(.*):.*#(.*)/ \2###\3/' | column -t -s '###'
29ifdef MEX_LICENSE
30 @printf "\n%s" $(MEX_LICENSE) | fmt
31endif
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:
37ifndef MEX_ASSURE
38 @printf "Variable MEX_ASSURE is not defined. Can not check for programs.\n"
39else
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
46endif