How to get the full path and directory of a Makefile itself?

How to get the full path and directory of a Makefile itself like finding Bash script's own path?

asked Aug 3, 2016 by anonymous

1 Answer

This 2 lines in Makefile get the full path and dir of the Makefile itself:

mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir := $(dir $(mkfile_dir))

The piece of code gets you Makefile, finds its absolute path and the directory. It does not rely on your work directory at all.

answered Oct 3, 2016 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...