|
diff --git a/Makefile b/Makefile
|
| 1 |
MK_DESCRIPTION="This provides some additional tools for makefiles." |
1 |
MEX_DESCRIPTION="This provides some additional tools for makefiles." |
| 2 |
MK_LICENSE="Released under the BSD two-clause license, see the LICENSE file for more information." |
2 |
MEX_LICENSE="Released under the BSD two-clause license, see the LICENSE file for more information." |
| 3 |
MK_ASSURE="python3 ls tree clang" |
3 |
MEX_ASSURE="python3 ls tree clang" |
| 4 |
|
4 |
|
| 5 |
include makext.mk |
5 |
include makext.mk |
| 6 |
|
6 |
|
| ... |
|
diff --git a/README.md b/README.md
|
| ... |
| 93 |
|
93 |
|
| 94 |
You can provide description for the project that will be displayed |
94 |
You can provide description for the project that will be displayed |
| 95 |
together with `help`. To do this provide this information in the |
95 |
together with `help`. To do this provide this information in the |
| 96 |
`MK_DESCRIPTION` variable. |
96 |
`MEX_DESCRIPTION` variable. |
| 97 |
|
97 |
|
| 98 |
Same goes for license information. Provide this information by creating |
98 |
Same goes for license information. Provide this information by creating |
| 99 |
`MK_LICENSE` variable. |
99 |
`MEX_LICENSE` variable. |
| 100 |
|
100 |
|
| 101 |
If these variables are not present this information will not be displayed |
101 |
If these variables are not present this information will not be displayed |
| 102 |
in the help. |
102 |
in the help. |
| 103 |
|
103 |
|
| 104 |
> [!IMPORTANT] |
104 |
> [!IMPORTANT] |
| 105 |
> Variables `MK_DESCRIPTION` and `MK_LICENSE` must be defined before you |
105 |
> Variables `MEX_DESCRIPTION` and `MEX_LICENSE` must be defined before you |
| 106 |
> include `makext.mk` to your `Makefile`. This is needed because the way |
106 |
> include `makext.mk` to your `Makefile`. This is needed because the way |
| 107 |
> GNU Make is parsing Makefiles. |
107 |
> GNU Make is parsing Makefiles. |
| 108 |
|
108 |
|
| 109 |
```make |
109 |
```make |
| 110 |
MK_DESCRIPTION="This provides some additional tools for makefiles." |
110 |
MEX_DESCRIPTION="This provides some additional tools for makefiles." |
| 111 |
MK_LICENSE="Released under the BSD two-clause license, see the LICENSE file for more information." |
111 |
MEX_LICENSE="Released under the BSD two-clause license, see the LICENSE file for more information." |
| 112 |
|
112 |
|
| 113 |
include makext.mk |
113 |
include makext.mk |
| 114 |
|
114 |
|
| ... |
| 143 |
leaving project in a potentially broken state. |
143 |
leaving project in a potentially broken state. |
| 144 |
|
144 |
|
| 145 |
```make |
145 |
```make |
| 146 |
MK_ASSURE="python3 ls tree clang" |
146 |
MEX_ASSURE="python3 ls tree clang" |
| 147 |
|
147 |
|
| 148 |
include makext.mk |
148 |
include makext.mk |
| 149 |
|
149 |
|
| ... |
| 152 |
``` |
152 |
``` |
| 153 |
|
153 |
|
| 154 |
`.assure` prerequisite will loop over the list of programs defined in |
154 |
`.assure` prerequisite will loop over the list of programs defined in |
| 155 |
`MK_ASSURE` variable and in case one is missing will exit `make` with |
155 |
`MEX_ASSURE` variable and in case one is missing will exit `make` with |
| 156 |
status code error 1. This will stop executing the recipe and therefore |
156 |
status code error 1. This will stop executing the recipe and therefore |
| 157 |
not execute anything in target `build-app`. |
157 |
not execute anything in target `build-app`. |
| 158 |
|
158 |
|
| ... |
|
diff --git a/makext.mk b/makext.mk
|
| ... |
| 24 |
# and adds description and license information if data provided. |
24 |
# and adds description and license information if data provided. |
| 25 |
.PHONY: .help |
25 |
.PHONY: .help |
| 26 |
.help: |
26 |
.help: |
| 27 |
ifdef MK_DESCRIPTION |
27 |
ifdef MEX_DESCRIPTION |
| 28 |
@echo "$(MK_DESCRIPTION)\n" | fmt |
28 |
@echo "$(MEX_DESCRIPTION)\n" | fmt |
| 29 |
endif |
29 |
endif |
| 30 |
@echo "Targets:" |
30 |
@echo "Targets:" |
| 31 |
@grep -vE '^[[:space:]]' $(MAKEFILE_LIST) | grep -E '^.*:.* #' | sed -E 's/(.*):(.*):.*#(.*)/ \2###\3/' | column -t -s '###' |
31 |
@grep -vE '^[[:space:]]' $(MAKEFILE_LIST) | grep -E '^.*:.* #' | sed -E 's/(.*):(.*):.*#(.*)/ \2###\3/' | column -t -s '###' |
| 32 |
ifdef MK_LICENSE |
32 |
ifdef MEX_LICENSE |
| 33 |
@echo "\n$(MK_LICENSE)" | fmt |
33 |
@echo "\n$(MEX_LICENSE)" | fmt |
| 34 |
endif |
34 |
endif |
| 35 |
|
35 |
|
| 36 |
# Checks `MK_ASSURE` variable if all the programs declared actually |
36 |
# Checks `MEX_ASSURE` variable if all the programs declared actually |
| 37 |
# exist on a machine. If not this exists make with error. |
37 |
# exist on a machine. If not this exists make with error. |
| 38 |
.PHONY: .assure |
38 |
.PHONY: .assure |
| 39 |
.assure: |
39 |
.assure: |
| 40 |
ifndef MK_ASSURE |
40 |
ifndef MEX_ASSURE |
| 41 |
@echo "Variable MK_ASSURE is not defined. Can not check for programs." |
41 |
@echo "Variable MEX_ASSURE is not defined. Can not check for programs." |
| 42 |
else |
42 |
else |
| 43 |
@for prog in $(shell echo $(MK_ASSURE)); do \ |
43 |
@for prog in $(shell echo $(MEX_ASSURE)); do \ |
| 44 |
if ! which $$prog > /dev/null; then \ |
44 |
if ! which $$prog > /dev/null; then \ |
| 45 |
echo "Error: '$$prog' not found on this machine."; \ |
45 |
echo "Error: '$$prog' not found on this machine."; \ |
| 46 |
exit 1; \ |
46 |
exit 1; \ |
| ... |