Skip to content

Makefile

Check if a variable is defined

Source

Source

ifdef MY_VARIABLE
$(info Variable is set)
else
$(error Variable is not set)
endif

Forcing use of a specific shell

Source

The SHELL variable can be set to force a given shell.

Warning

Don't use ?= to assign to this variable. SHELL is always set, so this assignment will never execute.

Get directory of current Makefile

makefile_directory := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))

Warning

This will be the directory of the most recently run makefile.

If this expression is computed in a file that is sourced, then it will be the directory of the sourced Makefile, NOT the original file.