In the makefile of my project, there's code which is similiar to this:
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
It's too tired.. Is there any way to make it more simple?
@keltar's answer works but findstring
is not really the best choice since it succeeds even for substrings. Better is to use filter
which is exact word matches:
GOALS := rebuild rerun distclean clean mostlyclean dep-clean tools tools-clean
ifeq (,$(filter $(GOALS),$(MAKECMDGOALS)))
include $(DEPENDENCIES)
endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With