|
diff --git a/README.md b/README.md
|
| ... |
| 3 |
Makext is a collection of useful extensions for Makefiles, aimed at |
3 |
Makext is a collection of useful extensions for Makefiles, aimed at |
| 4 |
simplifying and enhancing the functionality of Make-based projects. These |
4 |
simplifying and enhancing the functionality of Make-based projects. These |
| 5 |
extensions provide additional features and convenience functions to |
5 |
extensions provide additional features and convenience functions to |
| 6 |
improve the build process, manage dependencies, and streamline common |
6 |
improve the overall usage of GNU Make as a task runner. |
| 7 |
tasks. |
|
|
| 8 |
|
7 |
|
| 9 |
> [!NOTE] |
8 |
> [!NOTE] |
| 10 |
> This extensions are abusing GNU Make in some sense since it was not |
9 |
> This extensions are abusing GNU Make in some sense since it was not |
| 11 |
> meant to really be a task runner. Keep that in mind. However, dispite |
10 |
> meant to really be a task runner. Keep that in mind. However, despite |
| 12 |
> that, I constantly find myself using it as such. |
11 |
> that, I constantly find myself using it as such. |
| 13 |
|
12 |
|
| 14 |
### Extensions |
13 |
### Extensions |
| ... |
| 16 |
| Extension | Description | |
15 |
| Extension | Description | |
| 17 |
|-------------|-----------------------------------------------------| |
16 |
|-------------|-----------------------------------------------------| |
| 18 |
| help | Displays all targets with a comment in help format. | |
17 |
| help | Displays all targets with a comment in help format. | |
| 19 |
| assure | Check for the existance of programs on a machine. | |
18 |
| assure | Check for the existence of programs on a machine. | |
| 20 |
| environment | Loads environmental variables from other files. | |
19 |
| environment | Loads environmental variables from other files. | |
| 21 |
|
20 |
|
| 22 |
Additional features: |
21 |
Additional features: |
| ... |
| 56 |
|
55 |
|
| 57 |
## Help extension |
56 |
## Help extension |
| 58 |
|
57 |
|
| 59 |
This is all that is needed to start using `makext`. One of the extensions |
58 |
One of the extensions is `.help` which displays all the targets in the |
| 60 |
is `.help` which displays all the targets in the `Makefile` and their |
59 |
`Makefile` and their descriptions which are provided as comments next |
| 61 |
descriptions which are provided as comments next to the target definition. |
60 |
to the target definition. |
| 62 |
|
61 |
|
| 63 |
Lets check how and example `Makefile` would look. It |
62 |
Lets check how and example `Makefile` would look like. It |
| 64 |
is recommended to use `.PHONY` for targets that are not |
63 |
is recommended to use `.PHONY` for targets that are not |
| 65 |
actual files. In the example below I am not doing that |
64 |
actual files. In the example below I am not doing that |
| 66 |
though, but it is wise to follow that rule. Check [4.6 Phony |
65 |
though, but it is wise to follow that rule. Check [4.6 Phony |
| ... |
| 85 |
@echo "Running tests..." |
84 |
@echo "Running tests..." |
| 86 |
``` |
85 |
``` |
| 87 |
|
86 |
|
| 88 |
This will give us under we execute command `make` the following result. |
87 |
This will give us the following result when we execute command `make` |
|
|
88 |
without any arguments. |
| 89 |
|
89 |
|
| 90 |
```text |
90 |
```text |
| 91 |
$ make |
91 |
$ make |
| ... |
| 98 |
- Targets without defined comment next to the target will be ignored |
98 |
- Targets without defined comment next to the target will be ignored |
| 99 |
from help list. In this case `run-tests` is missing from the list. |
99 |
from help list. In this case `run-tests` is missing from the list. |
| 100 |
- Targets that start with `.` will also be ignored. |
100 |
- Targets that start with `.` will also be ignored. |
| 101 |
- Prerequisites in targets will be ommited from the result. |
101 |
- Prerequisites in targets will be omitted from the result. See how |
|
|
102 |
`clean-cache` is missing from `build-app` target. |
| 102 |
|
103 |
|
| 103 |
## Description & License information |
104 |
## Description & License information |
| 104 |
|
105 |
|
| ... |
| 112 |
If these variables are not present this information will not be displayed |
113 |
If these variables are not present this information will not be displayed |
| 113 |
in the help. |
114 |
in the help. |
| 114 |
|
115 |
|
|
|
116 |
Description and license information is also formatted to max 75 characters |
|
|
117 |
per row. |
|
|
118 |
|
| 115 |
> [!IMPORTANT] |
119 |
> [!IMPORTANT] |
| 116 |
> Variables `MEX_DESCRIPTION` and `MEX_LICENSE` must be defined before you |
120 |
> Variables `MEX_DESCRIPTION` and `MEX_LICENSE` must be defined before you |
| 117 |
> include `makext.mk` to your `Makefile`. This is needed because the way |
121 |
> include `makext.mk` to your `Makefile`. This is needed because the way |
| 118 |
> GNU Make is parsing Makefiles. |
122 |
> GNU Make is parsing Makefiles. |
| 119 |
|
123 |
|
| 120 |
```make |
124 |
```make |
| 121 |
MEX_DESCRIPTION="This provides some additional tools for makefiles." |
125 |
MEX_DESCRIPTION="This provides some additional tools for this project." |
| 122 |
MEX_LICENSE="Released under the BSD two-clause license, see the LICENSE file for more information." |
126 |
MEX_LICENSE="Released under the BSD two-clause license, see the LICENSE file for more information." |
| 123 |
|
127 |
|
| 124 |
include makext.mk |
128 |
include makext.mk |
| ... |
| 164 |
|
168 |
|
| 165 |
`.assure` prerequisite will loop over the list of programs defined in |
169 |
`.assure` prerequisite will loop over the list of programs defined in |
| 166 |
`MEX_ASSURE` variable and in case one is missing will exit `make` with |
170 |
`MEX_ASSURE` variable and in case one is missing will exit `make` with |
| 167 |
status code error 1. This will stop executing the recipe and therefore |
171 |
error status code 1. This will stop executing the recipe and therefore |
| 168 |
not execute anything in target `build-app`. |
172 |
not execute anything in target `build-app`. |
| 169 |
|
173 |
|
| 170 |
## Environment extension |
174 |
## Environment extension |
| 171 |
|
175 |
|
| 172 |
This extension helps loading of additional environmental files in your |
176 |
This extension helps loading of additional environmental files in your |
| 173 |
project. The files should have environmental variables defined in the |
177 |
project. The files should have environmental variables defined in the |
| 174 |
usual way. Seperate each file by a space and that is about it. |
178 |
usual way. Separate each file by a space and that is about it. |
| 175 |
|
179 |
|
| 176 |
If a file is missing this will break the execution of make and exit with |
180 |
If a file is missing this will break the execution of make and exit with |
| 177 |
status code 1. |
181 |
status code 1. |
| ... |
| 190 |
include makext.mk |
194 |
include makext.mk |
| 191 |
|
195 |
|
| 192 |
demo-envars: |
196 |
demo-envars: |
| 193 |
@echo "Envrionment variables" |
197 |
@echo "Environment variables" |
| 194 |
@echo " HOME: $(HOME)" |
198 |
@echo " HOME: $(HOME)" |
| 195 |
@echo " TERM: $(TERM)" |
199 |
@echo " TERM: $(TERM)" |
| 196 |
@echo " ENV: $(MEX_ENVIRONMENT)" |
200 |
@echo " ENV: $(MEX_ENVIRONMENT)" |
| ... |
| 202 |
you have. They will however override variables the shell already has |
206 |
you have. They will however override variables the shell already has |
| 203 |
defined. |
207 |
defined. |
| 204 |
|
208 |
|
| 205 |
## Acknowledgement |
209 |
## Alternative tools |
|
|
210 |
|
|
|
211 |
- https://github.com/casey/just |
|
|
212 |
- https://github.com/ruby/rake |
|
|
213 |
- https://github.com/taskctl/taskctl |
|
|
214 |
- https://github.com/go-task/task |
|
|
215 |
- https://github.com/pydoit/doit |
|
|
216 |
|
|
|
217 |
## Acknowledgment |
| 206 |
|
218 |
|
| 207 |
- https://stackoverflow.com/a/59087509 |
219 |
- https://stackoverflow.com/a/59087509 |
| 208 |
|
220 |
|
| ... |