Created
June 13, 2020 12:17
-
-
Save bbl/5429c4a0a498c5ef91c10201e1b651c2 to your computer and use it in GitHub Desktop.
Get Makefile root directory absolute path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) | |
test: | |
@echo $(ROOT_DIR) |
Ditto! My requirement was slightly different. I have a structure like this
repository/
tool1/
Makefile@ -> ../tool.makefile
tool2/
Makefile@ -> ../tool.makefile
tool.makefile
In other words, my tool makefiles are symlinks to the main makefile. In this case the above code always resolves to the repository
path.
But changing it to:
ROOT_DIR:=$(realpath $(shell dirname $(firstword $(MAKEFILE_LIST))))
test:
@echo $(ROOT_DIR)
resolved this resolution issue for me
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you