简体   繁体   中英

What does "$$?" mean in this makefile snippet?

What does "$$?" mean in below Makefile snippet?

$(PROGS): FORCE
    @cd $(BUILD_DIRECTORY_PATH)/$@; \
    mkdir -p obj; \
    $(MAKE) || exit "$$?"; \  <====== HERE

ADD 1

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.

Said another way, $$? is the Makefile equivalent of $? . In Make, to escape $? you need to use $$? . More info: Shell status codes in make

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM