How to get the full path and directory of a Makefile itself?
Posted on In QAHow to get the full path and directory of a Makefile itself like finding Bash script’s own path?
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_path))
The piece of code gets you Makefile, finds its absolute path and the directory. It does not rely on your work directory at all.
Hi! Thanks for the tip.
Maybe you want fix it:
mkfile_dir := $(dir $(mkfile_path))
Fixed. Thanks for the comment.
how to get the files list included by a Makefile?
For example:
TOP?=/vobs
include $(TOP)/util/mak/compiler.mk
and compiler.mk may also include other files.
How to get the all included file list?
thanks
make files paths : /home/ovsa/krupa/Makefile2/tool
/home/ovsa/krupa/Makefile2/runtime
/home/ovsa/krupa/Makefile2/License
iam running the make in :: make -C ./krupa/Makefile2/License all
Giving below error:
make: Entering directory ‘/home/ovsa/krupakar/Makefile2/License’
mkdir -p /home/ovsa/../License/lib /home/ovsa/../License/bin /home/ovsa/../License/src/lib
mkdir: cannot create directory ‘/home/ovsa/../License’: Permission denied
mkdir: cannot create directory ‘/home/ovsa/../License’: Permission denied
mkdir: cannot create directory ‘/home/ovsa/../License’: Permission denied
make: *** [Makefile:100: create_dirs] Error 1
make: Leaving directory ‘/home/ovsa/krupakar/Makefile2/License’
It is not taking the exact path of the makefile, It is creating the directory in /home