Using Makefiles

Makefiles are great to self-document frequently executed commands in a repository. They provide easy access to the bash code by easy to remember tags.

Formatting

Only tabs are allowed to indent lines. The indentation groups the commands under the rules.

Set Bash as the shell

On some systems Bash is not the default shell when Makefiles run. To set the shell add the line to the top of the Makefile:

SHELL := /bin/bash

Using pushd

Make executes every line in a new context. If you need to use pushd, popd you need to write all commands between them in one line separated with semicolons.

cluster-create:
	pushd ../terraform; terraform apply; popd

Leave a comment

Leave a Reply