I have the following makefile structure
$ cat makefile
foo:
$(MAKE) -C bar barbaz
$ cat bar/makefile
barbaz:
exit 111
$ make foo
make -C bar barbaz
make[1]: Entering directory `bar'
exit 111
make[1]: *** [barbaz] Error 111
make[1]: Leaving directory `bar'
make: *** [foo] Error 2
This is not an issue with recursive make
invocation; that is a red herring.
If you simply do this from the shell:
$ make barbaz # in bar directory
exit 111
make[1]: *** [barbaz] Error 111
$ echo $?
2
Make isn't propagating the exact exit status of the failing recipe.
This is documented here:
https://www.gnu.org/software/make/manual/html_node/Running.html
"The exit status of make is always one of three values: [...]'