Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Makefile中,如何使用单个编译命令更新多个目标?_Makefile_Gnu Make - Fatal编程技术网

在Makefile中,如何使用单个编译命令更新多个目标?

在Makefile中,如何使用单个编译命令更新多个目标?,makefile,gnu-make,Makefile,Gnu Make,我有单独的.coffee文件,我已经使用一个Makefile将它们编译成多个对应的.js文件。我的规则: tmp/coffee/%.js: src/js/%.coffee coffee --compile --output $(@D) $? 看起来是这样的: $ make static coffee --compile --output tmp/coffee/global src/js/global/admin.coffee coffee --compile --output tmp/

我有单独的.coffee文件,我已经使用一个Makefile将它们编译成多个对应的.js文件。我的规则:

tmp/coffee/%.js: src/js/%.coffee
    coffee --compile --output $(@D) $?
看起来是这样的:

$ make static
coffee --compile --output tmp/coffee/global src/js/global/admin.coffee
coffee --compile --output tmp/coffee/global src/js/global/ads.coffee
我想优化我的构建过程,以便一次性调用coffee编译器来编译所有更新的文件。这对于干净的构建尤其重要

所以它看起来是这样的:

$ make static
coffee --compile --output tmp/coffee/global src/js/global/ads.coffee src/js/global/admin.coffee

您已经在使用
$?
,您真正需要的是使目标依赖于所有文件。也许您想保留一个单独的标志文件,比如
。build

.built: $(wildcard src/js/global/*.coffee)
        coffee --compile --output tmp/coffee/global $?
        touch $@
您可能希望重构现有的Makefile,这样就不会有任何代码重复


我假设您的所有文件都在
global
中,就像您的示例所说的那样,但不是您现有的代码。如果有多个子目录,则不能一次编译所有子目录(每个子目录的
--output
参数应该不同)。

不应该。回答得很好,谢谢!我确实需要做一些工作来适应我的情况(以及我的情况),但这绝对是我需要的线索。@tripleee:你当然是对的。我很高兴我把它表述为一个问题,而不是一个断言;-)