是否可以制作所有目标'.PHONY'? (使用gmake)

时间:2014-12-19 10:44:18

标签: makefile

我有一个Makefile,其中没有一个目标引用文件,所以如果这可以在某个循环中完成它将是 方便。

有没有办法将makefile中的每个目标设置为.PHONY


我问这个的原因是我从不希望与makefile在同一目录中的任何文件与目标冲突(其中makefile会自动将任何目标与文件目录关联)

1 个答案:

答案 0 :(得分:3)

您可以通过定义一个空的" FORCE"来确保目标始终建立。目标并让你所有其他目标依赖它

target1: FORCE
      ./foobar $@
target2: FORCE
      ./dongle $@
FORCE:

(如make manual中所述)

您还可以运行" make -B"而不是" make"?

`-B'
`--always-make'
     Consider all targets out-of-date.  GNU `make' proceeds to consider
     targets and their prerequisites using the normal algorithms;
     however, all these targets are remade, regardless of the status of
     their prerequisites.
相关问题