Makefile中用$(shell pwd)獲取相對路徑
阿新 • • 發佈:2018-12-13
Makefile裡面獲取相對路徑必須在pwd前面加shell,然後把shell pwd當一個變數來引用,書寫形式是:$(shell pwd)
INCDIR := $(shell pwd) //將shell pwd作為變數,通過 $(shell pwd)形式引用這個變數 # C前處理器的flag,flag就是編譯器可選的選項 CPPFLAGS := -nostdlib -nostdinc -I$(INCDIR)/include //-nostdlib表示不使用標準庫 //-nostdinc表示不使用標準標頭檔案 //-I是用來指定相對路徑的,這裡表示我們需要預處理的檔案所在的路徑是相對路徑下的include資料夾
學習一下別人關於$(shell pwd)與$(pwd)的區別。有個網友寫了這麼一段,說明$(pwd)不行
$(pwd)不行
我剛才試了一下,把這幾行儲存成Makefile,然後make可以看到結果
P=$(shell pwd) # 這樣可以輸出路徑
#P=$(pwd) # 這樣沒有輸出
all:
echo $P