我想在這下面的代碼行此命令的輸出(也就是在我的makefile)來生成文件HEADER VAR分配,如:將makefile變量值分配給bash命令結果?
HEADER = $(shell for file in `find . -name *.h`;do echo $file; done)
的問題是,如果我打印的報頭在我的makefile文件使用:
print:
@echo $(HEADER)
我得到
ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile ile
如果我直接在控制檯運行此命令,並直接在我的生成文件是:
myaccount$ for file in `find . -name *.h`;do echo $file; done
./engine/helper/crypto/tomcrypt/headers/._tomcrypt_pk.h
./engine/helper/crypto/tomcrypt/headers/tomcrypt.h
./engine/helper/crypto/tomcrypt/headers/tomcrypt_argchk.h
./engine/helper/crypto/tomcrypt/headers/tomcrypt_cfg.h
./engine/helper/crypto/tomcrypt/headers/tomcrypt_cipher.h
./engine/helper/crypto/tomcrypt/headers/tomcrypt_custom.h
./engine/helper/crypto/tomcrypt/headers/tomcrypt_hash.h
./engine/helper/crypto/tomcrypt/headers/tomcrypt_mac.h
....
所以我得到我所有的頭文件。我這樣做是爲了避免在我的makefile中手動指定所有的.h文件。
任何想法?
很不錯的響應:),我這樣做是這種方式,因爲在我的for循環其實我執行更復雜的東西,所以我只是貼小片段在這裏。非常感謝@ e.James。 – Goles