使用make命令时出现“no rule to make target”的原因是什么?

3

Makefile语法难道不是

target: require_files
   cmd...

为什么出现这个问题?
Makefile
MXMLC = /opt/flex/bin/mxmlc
MXMLC_RELEASE = $(MXMLC) -debug=false -compiler.optimize=true

release: bin-release/Wrapper.swf, bin-release/Application.swf

bin-release/Application.swf: src/**/*.as, lib/*.swc
    $(MXMLC_RELEASE) -output bin-release/Application.swf src/Application.as
    @@-rm ../server/public/game/Application.swf
    $(CP) bin-release/Application.swf ../server/public/game/Application.swf

bin-release/Wrapper.swf: src/*.as, src/engine/**/*.as, lib/*.swc
    $(MXMLC_RELEASE) -output bin-release/Wrapper.swf src/Wrapper.as
    @@-rm ../server/public/game/Wrapper.swf
    $(CP) bin-release/Wrapper.swf ../server/public/game/Wrapper.swf

$: 制作bin-release/Application.swf文件

~/workspace/project/src/flash [2]19:20 make: * 没有生成目标 src/constant/*.as,', 需要生成bin-release/Application.swf'. 停止。

2个回答

6
去掉逗号
MXMLC = /opt/flex/bin/mxmlc
MXMLC_RELEASE = $(MXMLC) -debug=false -compiler.optimize=true

release: bin-release/Wrapper.swf bin-release/Application.swf

bin-release/Application.swf: src/**/*.as lib/*.swc
    $(MXMLC_RELEASE) -output bin-release/Application.swf src/Application.as
    @@-rm ../server/public/game/Application.swf
    $(CP) bin-release/Application.swf ../server/public/game/Application.swf

bin-release/Wrapper.swf: src/*.as src/engine/**/*.as lib/*.swc
    $(MXMLC_RELEASE) -output bin-release/Wrapper.swf src/Wrapper.as
    @@-rm ../server/public/game/Wrapper.swf
    $(CP) bin-release/Wrapper.swf ../server/public/game/Wrapper.swf

我发现另一个问题,src/**/*.as不会匹配src/a/b/c/d.as,只能匹配src/a/b.as,有什么办法可以匹配src下的所有.as文件? - guilin 桂林
使用类似于find的东西与$(shell ...)一起使用。 - sehe

2

您可以使用find命令定位文件,例如:

ASFILES  = $(shell find src -name "*.as")
SWCFILES = $(shell find lib -name "*.swc")

然后在你的规则中使用这个列表:

bin-release/Application.swf: $(ASFILES) $(SWCFILES)
        $(MXMLC_RELEASE) etc

我想你会在这个步骤中使用.as.swc文件(即$(MXMLC_RELEASE)部分的内容),虽然你目前还没有使用。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接