【发布时间】:2020-06-09 13:17:44
【问题描述】:
我希望使用“MY_TYPE”来切换目标“top”的先决条件。
基于 MY_TYPE 我可以选择所需的先决条件
例如,对于
MY_TYPE=FOO ,我希望 $(BUILD) $(TARGETS) $(X_LOCALS) 作为 top 的先决条件
MY_TYPE=BAR,我希望 $(BUILD) $(TARGETS) $(Y_LOCALS) 作为 top 的先决条件
我怎样才能实现它?
下面是一个简单的代码sn-p。
BUILD = build
TARGETS = targets
XLOCALS = xlocals
YLOCALS = ylocals
# can be FOO or BAR
MY_TYPE ?= FOO
$(BUILD):
printf "\t Doing Build\n"
$(TARGETS):
printf "\t Doing target\n"
$(XLOCALS):
printf "\t my local build for X \n"
$(YLOCALS):
printf "\t my local build for Y \n"
# based on MY_TYPE Can I select the pre-requisites required
# For example, for
# MY_TYPE=FOO , I wish to have $(BUILD) $(TARGETS) $(X_LOCALS) as pre-requisites for 'top' target
# MY_TYPE=BAR , I wish to have $(BUILD) $(TARGETS) $(Y_LOCALS) as pre-requisites for 'top' target
# How can I achieve it .
top: $(BUILD) $(TARGETS) $(XLOCALS)
printf "\t doing top\n"
很高兴听取您的意见。
【问题讨论】: