Makefile ifeq 中单个参数的逻辑 "OR" 条件
Logical "OR" condition in Makefile ifeq for a single parameter
我找到了一个示例 here,展示了如何实现 OR 逻辑来检查标志的不同值。
但我只想将一个没有值的参数(start
,而不是 start=yes
)传递给 2 个 make 命令:run
和 run_whatever
(示例名称)
对于我正在使用的 run
命令:
ifeq (run,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "run"
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(RUN_ARGS):;@:)
endif
和
run:
./myprogram $(RUN_ARGS)
我想扩展 ifeq 条件以支持:
run_whatever:
./myotherprogram $(RUN_ARGS)
并称他们为:make run start
、make run_whatever start
在这种情况下你可以使用:
ifeq (,$(filter-out run run_whatever,$(firstword $(MAKECMDGOALS))))
我找到了一个示例 here,展示了如何实现 OR 逻辑来检查标志的不同值。
但我只想将一个没有值的参数(start
,而不是 start=yes
)传递给 2 个 make 命令:run
和 run_whatever
(示例名称)
对于我正在使用的 run
命令:
ifeq (run,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "run"
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(RUN_ARGS):;@:)
endif
和
run:
./myprogram $(RUN_ARGS)
我想扩展 ifeq 条件以支持:
run_whatever:
./myotherprogram $(RUN_ARGS)
并称他们为:make run start
、make run_whatever start
在这种情况下你可以使用:
ifeq (,$(filter-out run run_whatever,$(firstword $(MAKECMDGOALS))))