The gist: put this at the top of the Makefile: MAKEFILE_PATH := $(realpath $(lastword $(MAKEFILE_LIST))) MAKEFILE_DIR := $(dir $(MAKEFILE_PATH)) Explanation MAKEFILE_LIST, according to [this][special-vars],