Makefile 不对 xxx 执行任何操作
我很困惑。我见过一些类似的问题,但没有一个能解决我的问题;所以我在网上抓取了这个脚本,它通过运行 makefile 自动压缩 javascript 文件,如下所示:
concatenated.min.js: file1.js file2.js
java -jar ~/bin/compiler.jar $(addprefix --js=,$^) >$@
我在这里有这个 make 文件
JS_TARGETS = a.js b.js c.js d.js
CLOSURE = java -jar ~/bin/compiler.jar
CLOSURE_FLAGS =
JS_MINIFIED = $(JS_TARGETS:.js=.min.js)
JS_GZIP = $(JS_TARGETS:.js=.js.gz)
JS_MIN_GZIP = $(JS_TARGETS:.js=.min.js.gz)
js: $(JS_TARGETS) $(JS_MINIFIED) $(JS_GZIP) $(JS_MIN_GZIP)
%.min.js: %.js
$(CLOSURE) $(CLOSURE_FLAGS) --js=$< >$@
在与 a.js、b.js、c.js 和 d.js 相同的目录中我有一个文件concat.min.js。然后,我运行了 make concat.min.js
并且 makefile 给出了“对 concat.min.js 无需执行任何操作”。
我还认为问题是因为我缺少 %.min.js
规则中的 $(addprefix --js=,$^) >$@
部分。但即使我将其添加到规则中,它似乎仍然给我同样的错误。我做错了什么/打字错误吗?谢谢。
I'm confused. I have seen some of the similar questions but none of them solve my problem; So I have this script I grabbed online that automatically compress javascript files by running makefile like this:
concatenated.min.js: file1.js file2.js
java -jar ~/bin/compiler.jar $(addprefix --js=,$^) >$@
I have this make file here
JS_TARGETS = a.js b.js c.js d.js
CLOSURE = java -jar ~/bin/compiler.jar
CLOSURE_FLAGS =
JS_MINIFIED = $(JS_TARGETS:.js=.min.js)
JS_GZIP = $(JS_TARGETS:.js=.js.gz)
JS_MIN_GZIP = $(JS_TARGETS:.js=.min.js.gz)
js: $(JS_TARGETS) $(JS_MINIFIED) $(JS_GZIP) $(JS_MIN_GZIP)
%.min.js: %.js
$(CLOSURE) $(CLOSURE_FLAGS) --js=lt; >$@
In the same directory as a.js, b.js, c.js, and d.js I have a file concat.min.js. Then, I ran make concat.min.js
and the makefile gives me 'nothing to be done for concat.min.js'.
I also thought the problem was because i was missing the $(addprefix --js=,$^) >$@
piece on the %.min.js
rule. But it seems that it keeps giving me the same error even when I add it to the rule. did I do something wrong/typo? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
%.min.js: %.js
行的意思是“如果文件 foo.js 比 foo.min.js 新,则 foo.min.js 已过时” ,以下是更新方法”。因此,如果您说make a.min.js
,make 会发现您(大概)没有a.min.js
文件,因此它肯定不是较新的文件比a.js
更重要,因此它将使用 makefile 中的命令来生成它。您收到的消息是“您要求我制作 concat.min.js,但没有比它更新的文件 concat.js,所以......没有什么可做的”。
看看你问题的其余部分,我怀疑你想要类似的东西:
这确保
concatenated.min.js
比JS_TARGETS
中列出的每个文件都更新。What the
%.min.js: %.js
line is saying is "if the file foo.js is newer than foo.min.js, then foo.min.js is out-of-date, and here's how to update it". Therefore if you saymake a.min.js
, make will spot that you (presumably) don't have aa.min.js
file, so it's certainly not newer thana.js
, and so it'll make it using the command in the makefile.The message you're getting is saying "you asked me to make concat.min.js, but there isn't a file concat.js which is newer than it, so... there's nothing to be done".
Looking at the rest of your question, I suspect you want something like:
That makes sure that
concatenated.min.js
is newer than each of the files listed inJS_TARGETS
.如果您没有 concat.js 文件,则可能会发生这种情况。
This can happen if you don't have concat.js file.