制作文件:
include:
wget <tarball with another Makefile>.tar.gz
tar -zxvf <tarball with another Makefile>.tar.gz
include Makefile.from_tarball
我想像上面那样做,我想在运行目标时包含一个 Makefile
这可能吗?
您可以在 GNU make 中包含另一个 makefile,在顶层使用
include
命令:
-include foobar.mak
如果你在它前面放一个破折号(如上),那将不会给出错误,而是会延迟按需加载 makefile。如果该 makefile 有任何依赖项,GNU make 将首先确保它们是最新的,并在必要时在更新后重新读取 makefile
foobar.mak: foobar.tar.gz
tar xf $< $@ # extract the makefile
foobar.tar.gz:
wget <URL for tarball>
这些规则将下载 tarball(如果尚未下载),提取 makefile(如果 tarball 较新)然后包含它。