I understand that MAKE will exit on exit statuses other than 0, but I need to just capture the status and later on in the recipe decide to exit the make script. So I would like to:
- capture the exit status of a target command in a variable,
- do other tasks like printing a summary of execution progress, etc and then
- use the exit status to decide to exit the makefile script.
I have been through many threads on Stack Overflow, but I don't see any examples that are specific enough to address my issue.
This code works, but MKSTAT is only valid within in the shell where it is.
# The "somecmd" will exit with a status of 0 or greater than 0.
getstatus:
somecmd; \
MKSTAT=$$?; \
echo $$MKSTAT
So, you can see that the getstatus code is all in one shell. I can't use MKSTAT outside of this shell, it has to be used in the shell where it is assigned. I need something more flexible. How do I save MKSTAT as a MAKE variable that the makefile script can use in some other part of the recipe?