【发布时间】:2011-01-23 07:18:41
【问题描述】:
我正在尝试将此命令的输出(在我的 makefile 中)分配给 makefile HEADER var,如下面的代码行所示:
HEADER = $(shell for file in `find . -name *.h`;do echo $file; done)
问题是,如果我在 makefile 中使用以下命令打印 HEADER:
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
如果我直接在控制台中运行此命令,并且直接在我的 makefile 所在的位置:
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 文件。
有什么想法吗?
【问题讨论】:
-
我认为这不值得回答,因为这不是您真正要问的,但我只能假设您这样做是为了依赖;如果修改了头文件,则需要重新编译相应的源文件?如果是这样,您可能会发现使用 cc(从技术上讲是 cpp)的 -MM 选项。您甚至可以为具有单独(不相关)源文件的目录制作这样的 Makefile。这对于制表符补全很有用。但它的价值在于它还为源文件生成依赖项(就像它是单个项目一样)。