範例程式取得Makefile所在絕對路徑 (Absolute Path of current Makefile)
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
current_mk_abspathname := $(abspath $(lastword $(MAKEFILE_LIST))) | |
current_mk_absdir := $(dir $(current_mk_abspathname)) | |
all: | |
@echo "Makefile absolute pathname: $(current_mk_abspathname)" ; \ | |
echo "Makefile absolute path: $(current_mk_absdir)" |
test results on linux
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
/build$ make -v | |
GNU Make 4.1 | |
Built for x86_64-pc-linux-gnu | |
Copyright (C) 1988-2014 Free Software Foundation, Inc. | |
License GPLv3+: GNU GPL version 3 or later | |
This is free software: you are free to change and redistribute it. | |
There is NO WARRANTY, to the extent permitted by law. | |
/build$ lsb_release -a | |
No LSB modules are available. | |
Distributor ID: Ubuntu | |
Description: Ubuntu 16.04.4 LTS | |
Release: 16.04 | |
Codename: xenial | |
/build$ make -f 2019-03-21/01-abspath-mk.mk | |
Makefile absolute pathname: /build/2019-03-21/01-abspath-mk.mk | |
Makefile absolute path: /build/2019-03-21/ |
沒有留言:
張貼留言