|
diff --git a/Makefile b/Makefile
|
| 1 |
MK_DESCRIPTION="This provides some additional tools for makefiles." |
1 |
MK_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 |
MK_LICENSE="Released under the BSD two-clause license, see the LICENSE file for more information." |
|
|
3 |
MK_ASSURE="python3 ls tree clang" |
| 3 |
|
4 |
|
| 4 |
include makext.mk |
5 |
include makext.mk |
| 5 |
|
6 |
|
| 6 |
help: .help |
7 |
help: .help |
| 7 |
|
8 |
|
| 8 |
demo: .assure |
9 |
demo-assure: .assure |
|
|
10 |
@echo "All good, continuing..." |
| 9 |
|
11 |
|
| 10 |
build-app: clean-cache # Build the application |
12 |
build-app: clean-cache # Build the application |
| 11 |
@echo "Building the application..." |
13 |
@echo "Building the application..." |
| ... |
|
diff --git a/README.md b/README.md
|
| ... |
| 11 |
> meant to really be a task runner. Keep that in mind. However, dispite |
11 |
> meant to really be a task runner. Keep that in mind. However, dispite |
| 12 |
> that, I constantly find myself using it as such. |
12 |
> that, I constantly find myself using it as such. |
| 13 |
|
13 |
|
| 14 |
Features include: |
14 |
| Extension | Description | |
|
|
15 |
|-----------|-----------------------------------------------------| |
|
|
16 |
| .help | Displays all targets with a comment in help format. | |
|
|
17 |
| .assure | Check for the existance of programs on a machine. | |
| 15 |
|
18 |
|
| 16 |
- Enhanced help message generation with support for custom descriptions. |
19 |
Additional features: |
|
|
20 |
|
| 17 |
- Automatic description inclusion in help message. |
21 |
- Automatic description inclusion in help message. |
| 18 |
- Automatic license inclusion in help message. |
22 |
- Automatic license inclusion in help message. |
| 19 |
|
23 |
|
| ... |
| 130 |
Released under the BSD two-clause license, see the LICENSE file for |
134 |
Released under the BSD two-clause license, see the LICENSE file for |
| 131 |
more information. |
135 |
more information. |
| 132 |
``` |
136 |
``` |
|
|
137 |
|
|
|
138 |
## Assure extension |
|
|
139 |
|
|
|
140 |
Often times project uses multiple programs and to ensure that these |
|
|
141 |
programs are already installed before recipes are executed `assure` can |
|
|
142 |
be used. If programs are missing recipes can only partially be executed |
|
|
143 |
leaving project in a potentially broken state. |
|
|
144 |
|
|
|
145 |
```make |
|
|
146 |
MK_ASSURE="python3 ls tree clang" |
|
|
147 |
|
|
|
148 |
include makext.mk |
|
|
149 |
|
|
|
150 |
build-app: .assure |
|
|
151 |
@echo "Building the application..." |
|
|
152 |
``` |
|
|
153 |
|
|
|
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 |
|
|
156 |
status code error 1. This will stop executing the recipe and therefore |
|
|
157 |
not execute anything in target `build-app`. |
| 133 |
|
158 |
|
| 134 |
## Acknowledgement |
159 |
## Acknowledgement |
| 135 |
|
160 |
|
| ... |
|
diff --git a/makext.mk b/makext.mk
|
| ... |
| 15 |
# `makext` was written by Mitja Felicijan and is released under the BSD |
15 |
# `makext` was written by Mitja Felicijan and is released under the BSD |
| 16 |
# two-clause license, see the LICENSE file for more information. |
16 |
# two-clause license, see the LICENSE file for more information. |
| 17 |
|
17 |
|
|
|
18 |
# Checks if operating system is Windows and exists with error. |
|
|
19 |
ifeq ($(OS),Windows_NT) |
|
|
20 |
$(error makext does not support Windows operating system) |
|
|
21 |
endif |
|
|
22 |
|
| 18 |
# Help extension that lists all the targets with descriptions |
23 |
# Help extension that lists all the targets with descriptions |
| 19 |
# and adds description and license information if data provided. |
24 |
# and adds description and license information if data provided. |
| 20 |
.PHONY: .help |
25 |
.PHONY: .help |
| ... |
| 27 |
ifdef MK_LICENSE |
32 |
ifdef MK_LICENSE |
| 28 |
@echo "\n$(MK_LICENSE)" | fmt |
33 |
@echo "\n$(MK_LICENSE)" | fmt |
| 29 |
endif |
34 |
endif |
|
|
35 |
|
|
|
36 |
# Checks `MK_ASSURE` variable if all the programs declared actually |
|
|
37 |
# exist on a machine. If not this exists make with error. |
|
|
38 |
.PHONY: .assure |
|
|
39 |
.assure: |
|
|
40 |
ifndef MK_ASSURE |
|
|
41 |
@echo "Variable MK_ASSURE is not defined. Can not check for programs." |
|
|
42 |
else |
|
|
43 |
@for prog in $(shell echo $(MK_ASSURE)); do \ |
|
|
44 |
if ! which $$prog > /dev/null; then \ |
|
|
45 |
echo "Error: '$$prog' not found on this machine."; \ |
|
|
46 |
exit 1; \ |
|
|
47 |
fi; \ |
|
|
48 |
done |
|
|
49 |
endif |