在 Makefile 中使用条件运算符比较两个变量
comparing two variables using condition operator in Makefiles
下面是我的 Makefile。我只想使用 && 运算符(或等效运算符)进行比较
如下图pseudocode.I想运行下面逻辑里面的“全部”target
# if (CUR_PI_VERSION == LAST_PI_VERSION) && (CUR_GIT_VERSION == LAST_GIT_VERSION)
# print "everything matched. Nothing to do"
# else
# print "files not matched"
# run python script.
#
# How do I achieve this.
我看了其他的答案,但得不到我想要的结果。
我已附上我的示例代码以供参考。
CUR_PI_VERSION:= "abc"
CUR_GIT_VERSION:= "cde"
LAST_PI_VERSION:= "abc"
LAST_GIT_VERSION:= "cde"
$(info $$CUR_GIT_VERSION is [${CUR_GIT_VERSION}])
$(info $$CUR_PI_VERSION is [${CUR_PI_VERSION}])
$(info $$LAST_GIT_VERSION is [${LAST_GIT_VERSION}])
$(info $$LAST_PI_VERSION is [${LAST_PI_VERSION}])
all:
# The pseudocode of what I want to do is as follows
# if (CUR_PI_VERSION == LAST_PI_VERSION) && (CUR_GIT_VERSION == LAST_GIT_VERSION)
# print "everything matched. Nothing to do"
# else
# print "files not matched"
# run python script.
#
# How do I achieve this.
#
ifeq ($(CUR_GIT_VERSION),$(LAST_GIT_VERSION))
ifeq ($(CUR_FPI_VERSION),$(LAST_FPI_VERSION))
echo "Everything matched, so don't need the make top"
endif
endif
非常感谢任何帮助。
你可以试试这个:
all:
ifeq ($(CUR_PI_VERSION)@$(CUR_GIT_VERSION),$(LAST_PI_VERSION)@$(LAST_GIT_VERSION))
echo "Everything matched, so don't need the make top"
endif
以上测试比较了两个连接的字符串(由 @
连接):
$(CUR_PI_VERSION)@$(CUR_GIT_VERSION)
和
$(LAST_PI_VERSION)@$(LAST_GIT_VERSION)
下面是我的 Makefile。我只想使用 && 运算符(或等效运算符)进行比较 如下图pseudocode.I想运行下面逻辑里面的“全部”target
# if (CUR_PI_VERSION == LAST_PI_VERSION) && (CUR_GIT_VERSION == LAST_GIT_VERSION)
# print "everything matched. Nothing to do"
# else
# print "files not matched"
# run python script.
#
# How do I achieve this.
我看了其他的答案,但得不到我想要的结果。 我已附上我的示例代码以供参考。
CUR_PI_VERSION:= "abc"
CUR_GIT_VERSION:= "cde"
LAST_PI_VERSION:= "abc"
LAST_GIT_VERSION:= "cde"
$(info $$CUR_GIT_VERSION is [${CUR_GIT_VERSION}])
$(info $$CUR_PI_VERSION is [${CUR_PI_VERSION}])
$(info $$LAST_GIT_VERSION is [${LAST_GIT_VERSION}])
$(info $$LAST_PI_VERSION is [${LAST_PI_VERSION}])
all:
# The pseudocode of what I want to do is as follows
# if (CUR_PI_VERSION == LAST_PI_VERSION) && (CUR_GIT_VERSION == LAST_GIT_VERSION)
# print "everything matched. Nothing to do"
# else
# print "files not matched"
# run python script.
#
# How do I achieve this.
#
ifeq ($(CUR_GIT_VERSION),$(LAST_GIT_VERSION))
ifeq ($(CUR_FPI_VERSION),$(LAST_FPI_VERSION))
echo "Everything matched, so don't need the make top"
endif
endif
非常感谢任何帮助。
你可以试试这个:
all:
ifeq ($(CUR_PI_VERSION)@$(CUR_GIT_VERSION),$(LAST_PI_VERSION)@$(LAST_GIT_VERSION))
echo "Everything matched, so don't need the make top"
endif
以上测试比较了两个连接的字符串(由 @
连接):
$(CUR_PI_VERSION)@$(CUR_GIT_VERSION)
和
$(LAST_PI_VERSION)@$(LAST_GIT_VERSION)