Kir*_*gin 5 unix linux shell makefile gnu-make
GNU Make有-B
强制make
忽略现有目标的选项.它允许重建目标,但它也会重建目标的所有依赖关系树.我想知道有没有办法强制重建目标而不重建其依赖项(使用GNU Make选项,Makefile中的设置,类似兼容make
的软件等)?
问题的插图:
$ mkdir test; cd test
$ unexpand -t4 >Makefile <<EOF
huge:
@echo "rebuilding huge"; date >huge
small: huge
@echo "rebuilding small"; sh -c 'cat huge; date' >small
EOF
$ make small
rebuilding huge
rebuilding small
$ ls
huge Makefile small
$ make small
make: 'small' is up to date.
$ make -B small
rebuilding huge # how to get rid of this line?
rebuilding small
$ make --version | head -n3
GNU Make 4.0
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2013 Free Software Foundation, Inc.
Run Code Online (Sandbox Code Playgroud)
当然可以rm small; make small
,但有内置方式吗?
一种方法是对-o
您不想重制的所有目标使用该选项:
Run Code Online (Sandbox Code Playgroud)-o FILE, --old-file=FILE, --assume-old=FILE Consider FILE to be very old and don't remake it.
编辑
我认为您在误读有关的文档-B
;它说:
Run Code Online (Sandbox Code Playgroud)-B, --always-make Unconditionally make all targets.
注意,这里的所有目标;huge
当然是目标,因此如果您使用-B
它,它将被重新制作。
但是,我也会误解您的问题。我以为你想重建small
不重建huge
,即使huge
是新的,但你正在试图获得small
被重建,即使huge
已经没有改变,对不对?
您绝对不想使用-B
。该选项根本不是您想要的。
通常,人们可以通过删除small
:
rm -f small
make small
Run Code Online (Sandbox Code Playgroud)
可以使用一个选项来强制重新创建给定目标,但是该选项不存在。
您可以使用-W huge
,但这又意味着您需要知道先决条件的名称,而不仅仅是您要构建的目标。
归档时间: |
|
查看次数: |
1172 次 |
最近记录: |