检查ifeq在makefile中的变量

时间:2018-07-25 13:09:19

标签: makefile

关注不起作用,你知道为什么吗?

注意:CURRENT_CLUSTER不是“ my-local-cluster”,并且stil失败。

check-env:
    ifeq ($(CURRENT_CLUSTER), 'my-local-cluster')
        $(error CURRENT_CLUSTER is local $(CURRENT_CLUSTER), should be production cluster)
    endif

1 个答案:

答案 0 :(得分:1)

也许您想要的是:

check-env:
ifeq ($(CURRENT_CLUSTER),my-local-cluster)
    $(error CURRENT_CLUSTER is local $(CURRENT_CLUSTER), should be production cluster)
endif
    @echo Whatever

all:
    @echo "Still good"

这将产生以下结果:

$ make check-env CURRENT_CLUSTER=my-local-cluster
Makefile:220: *** CURRENT_CLUSTER is local my-local-cluster, should be
$ make all CURRENT_CLUSTER=my-local-cluster
Still good
$ make check-env CURRENT_CLUSTER=anything
Whatever