Razzi's guides to make


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.

make shell script example

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

Note that you gotta use tabs for indentation.

And the filename is Makefile with a capital M.

Then use it as follows:

$ make
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:

.PHONY: lint

# (other targets)

	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

project page


source code


Depends on