make has got a lot of quirks, but it’s installed everywhere and gives more structure than a shell script.
So let’s lay out a usage that works for 90% of cases.
The remaining 10%, use a dedicated build tool, and if you’d like, add a Makefile to invoke it.
You don’t need to compile anything with make.
$ cat > example.sh echo it works $ chmod +x example.sh
all: example.sh example: example.sh ./example.sh
Note that you gotta use tabs for indentation.
And the filename is
Makefile with a capital M.
Then use it as follows:
$ make ./example.sh it works
For a build step that involves compilation, the kilo makefile is just about as basic as they come:
If you want to have a target that doesn’t depend on files at all,
add it to
.PHONY: lint # (other targets) lint: shellcheck example.sh
Then invoke like so (try tab completing targets :)
$ make lint shellcheck example.sh In example.sh line 1: echo it works ^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
Full example as git repository: https://git.sr.ht/~razzi/make-example/tree