makefile - check变量就是其中之一

ikh*_*ikh 4 makefile

在我的项目的makefile中,有类似的代码:

ifneq ($(MAKECMDGOALS), rebuild)
ifneq ($(MAKECMDGOALS), rerun)
ifneq ($(MAKECMDGOALS), distclean)
ifneq ($(MAKECMDGOALS), clean)
ifneq ($(MAKECMDGOALS), mostlyclean)
ifneq ($(MAKECMDGOALS), dep-clean)
ifneq ($(MAKECMDGOALS), tools)
ifneq ($(MAKECMDGOALS), tools-clean)
include $(DEPENDENCIES)
endif
endif
endif
endif
endif
endif
endif
endif
Run Code Online (Sandbox Code Playgroud)

太累了..有没有办法让它变得更简单?

Mad*_*ist 10

@keltar的答案有效但findstring不是真正的最佳选择,因为它甚至可以成功实现子串.更好的是使用filter哪个是确切的单词匹配:

GOALS := rebuild rerun distclean clean mostlyclean dep-clean tools tools-clean

ifeq (,$(filter $(GOALS),$(MAKECMDGOALS)))
  include $(DEPENDENCIES)
endif
Run Code Online (Sandbox Code Playgroud)