I work with a Makefile generated by an external tool (Netbeans), where I can not change the logic of the main target, but I am able to "inject" logic in a target that is executed before the actual build (.build-pre to be specific in Netbeans-generated Makefile)
I would like for that target to conditionally terminate the make execution, but without raising an error. If I do
exit
inside the "pre" rule, nothing happens (I mean, the rule terminates, but make continues). If I add
exit 1
make will terminate, but it will return an error status.
Is there a way to force make to exit in a clean way? I searched for make functions, but found only error/warn/info, but nothing like exit.
Thanks in advance!
EDIT: Based on comments it does not seem possible. Pity.
For completeness, a more specific example of what I'd like to achieve:
default: pre
@echo "Doing default"
pre:
@echo "Doing pre"
ifeq "$(SOME_VARIABLE)" "yes"
exit 0
fi
With Makefile like above, I'd like to be able for pre to execute, and conditionally prevent 'default' from executing, but still return 0 to the shell.
make foo
then make will try to makefoo
, and the only way it will stop makingfoo
is if it sees an error. You can't ask it to give up without makingfoo
and without generating an error. If this is some way not an accurate description of what you're trying to achieve please make your question more specific. – Martelleexit;...
, or have thepre
rule call a rule to temporarily rebuild the makefile itself with a default do-nothing rule. In short, you should talk to the person who imposed this protocol and explain the advantage of unity builds, or else accept the slow compilation and keep some crossword puzzles on hand. – Jettonmake pre
. This doesn't even require modifying the makefile, but you could, if pre were in fact a long list of targets. – Bugbear