Reputation: 3341
I am working on a system which is composed of many projects and makefiles. Each makefile includes .inc files from it`s dependencies. If a dependency is missing, it complains and tells the user to compile the dependency first. This part works ok. Problem is the clean target.
If a dependency is cleaned first and it`s inc file is deleted (since inc files include compile time options and hard paths, we prefer to delete them), then Makefile fails to load the .inc file and aborts. So the mechanism that makes sure we have the right dependencies, does not let us call the clean target -which does not require the dependencies-.
Is there any way to include or ignore .inc files according to the rule?
PS: Since we are already using "-" for error checking so that is not an option.
Upvotes: 0
Views: 882
Reputation: 27053
the canonical way to prevent including when cleaning is as follows:
ifneq ($(MAKECMDGOALS),clean)
include $(some .inc files)
endif
as described here https://www.gnu.org/software/make/manual/make.html#Goals
although if i understand correctly the errors you are experiencing are not because of the failed includes, which you are already supressing with -include
, but because your makefile is dependent on some values from the includes.
to help you fix that we will need some code which demonstrates the problem. please read here for how to do so: https://stackoverflow.com/help/minimal-reproducible-example and http://www.sscce.org/
Upvotes: 2