What does "$$?" mean in below Makefile snippet?
$(PROGS): FORCE
@cd $(BUILD_DIRECTORY_PATH)/$@; \
mkdir -p obj; \
$(MAKE) || exit "$$?"; \ <====== HERE
I guess it means exit "$?"
in bash since $$
in makefile escapes to $
.
But what does exit "$?"
mean then?
$? is the return code when a program exits or finishes. Therefore, in your line
$(MAKE) || exit "$$?"
It will execute $(MAKE)
. If this program does not finish correctly, it will have a return code different from 0 and then the exit "$$?"
will be executed. which will make the current process to exit to shell with the same return code as the $(MAKE)
program, which you will be able to show executing echo $?
in the shell.