Makefile 逻辑与
Makefile logical AND
如何在 makefile 中执行逻辑与。如果我 运行 make test
它按预期工作
它给出输出 Both PARAMETERS are required
。如果缺少其中一个参数它仍然应该提供相同的输出但它不是那样工作例如如果我 运行 make test PARAM1=abc
它应该输出 Both PARAMETERS are required
。我如何强制这两个参数.
%/test:
ifeq ($(PARAM1)$(PARAM2),)
@echo "Both PARAMETERS are required"
@exit 1
endif
@echo "Do Something $(PARAM1) $(PARAM2)"
我试过下面的代码,它给出错误 *** missing separator。停止。我不熟悉 makefile 任何帮助表示赞赏。
%/test:
@# $(or $(and $(PARAME1),$(PARAM2)),$(error Both PARAMETERS must be set))
@>&2 echo "Do Something $(PARAM1),$(PARAME2)"
您的测试本质上是检查两者的串联是否为空字符串。如果这不是您要检查的内容,请执行不同的检查。例如,
%/test:
@# $(or $(and $(PARAM1),$(PARAM2)),$(error Both PARAMETERS must be set))
各种其他变体;
如何在 makefile 中执行逻辑与。如果我 运行 make test
它按预期工作
它给出输出 Both PARAMETERS are required
。如果缺少其中一个参数它仍然应该提供相同的输出但它不是那样工作例如如果我 运行 make test PARAM1=abc
它应该输出 Both PARAMETERS are required
。我如何强制这两个参数.
%/test:
ifeq ($(PARAM1)$(PARAM2),)
@echo "Both PARAMETERS are required"
@exit 1
endif
@echo "Do Something $(PARAM1) $(PARAM2)"
我试过下面的代码,它给出错误 *** missing separator。停止。我不熟悉 makefile 任何帮助表示赞赏。
%/test:
@# $(or $(and $(PARAME1),$(PARAM2)),$(error Both PARAMETERS must be set))
@>&2 echo "Do Something $(PARAM1),$(PARAME2)"
您的测试本质上是检查两者的串联是否为空字符串。如果这不是您要检查的内容,请执行不同的检查。例如,
%/test:
@# $(or $(and $(PARAM1),$(PARAM2)),$(error Both PARAMETERS must be set))
各种其他变体;