Makefile不起作用,@ if,@ else,@ not found

时间:2015-08-22 06:05:28

标签: makefile

这是我的Makefile中失败的部分

b2dsetup:
            @$(ECHO) "Goes in b2dsetup"; \
            @if [-d "/external/src/Box2D"]; \
            @then $(PRINTF) "Option1"; \
            @else; \
            @$(ECHO) "Option2"; \
                    @cd /external/src/; \
                    @tar cfv Box2D.tgz Box2D; \
            @fi;

并给出以下错误:

Goes in b2dsetup
bash: line 1: @if: command not found
bash: line 2: @then: command not found
bash: line 3: @else: command not found
bash: line 4: @/bin/echo: No such file or directory
bash: line 5: @cd: command not found
bash: line 6: @tar: command not found
bash: line 7: @fi: command not found
Makefile_g30:71: recipe for target 'b2dsetup' failed
make: *** [b2dsetup] Error 127

shell returned 2

我尝试了很多语法修改和谷歌搜索,但没有任何帮助。

1 个答案:

答案 0 :(得分:3)

仅将@放在多行脚本的第一行。

b2dsetup:
        @$(ECHO) "Goes in b2dsetup"; \
        if [-d "/external/src/Box2D"]; \
        then $(PRINTF) "Option1"; \
        else \
            $(ECHO) "Option2"; \
            cd /external/src/; \
            tar cfv Box2D.tgz Box2D; \
        fi

或者:

b2dsetup:
        @$(ECHO) "Goes in b2dsetup"
        @if [-d "/external/src/Box2D"]; \
        then $(PRINTF) "Option1"; \
        else \
            $(ECHO) "Option2"; \
            cd /external/src/; \
            tar cfv Box2D.tgz Box2D; \
        fi