小编m.s*_*tov的帖子

Ifdef 有条件的意外行为

我有一个带有如下命令的 Makefile:

#Makefile
    hello:
        echo 'hello'
        echo $(TAG)
        ifdef TAG
              $(warning MYWARNING)
        else
              $(error MYERROR)
        endif
Run Code Online (Sandbox Code Playgroud)

我这样使用它:

# make TAG='1.0' hello
Run Code Online (Sandbox Code Playgroud)

我希望该命令执行 echo 'hello',然后 echo $(TAG) 和 $(warning MYWARNING) 但我得到:

Makefile:17: MYWARNING
Makefile:19: *** MYERROR.  Stop.
Run Code Online (Sandbox Code Playgroud)

怎么了?

bash makefile conditional-compilation

5
推荐指数
1
解决办法
2405
查看次数

标签 统计

bash ×1

conditional-compilation ×1

makefile ×1