Skip to content

Instantly share code, notes, and snippets.

View nguyenvukhang's full-sized avatar
📚
Doing the exercise left for the reader

Khang nguyenvukhang

📚
Doing the exercise left for the reader
View GitHub Profile
@nguyenvukhang
nguyenvukhang / makefile_abspath.md
Last active January 25, 2026 02:40
Getting the absolute path of the current `Makefile`

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],