如何在 Makefile 列印讯息?

我想打印一些消息,同时做构建过程与 makefile。下面的代码可以打印消息,但不会在消息之后执行脚本。我怎样才能解决这个问题?

ifeq (yes, ${TEST})
CXXFLAGS := ${CXXFLAGS} -DDESKTOP_TEST
test:
@echo '************  TEST VERSION ************'
else
release:
@echo "************ RELEASE VERSIOIN **********"
endif
148520 次浏览

It's not clear what you want, or whether you want this trick to work with different targets, or whether you've defined these targets elsewhere, or what version of Make you're using, but what the heck, I'll go out on a limb:

ifeq (yes, ${TEST})
CXXFLAGS := ${CXXFLAGS} -DDESKTOP_TEST
test:
$(info ************  TEST VERSION ************)
else
release:
$(info ************ RELEASE VERSIOIN **********)
endif

$(info your_text) : Information. This doesn't stop the execution.

$(warning your_text) : Warning. This shows the text as a warning.

$(error your_text) : Fatal Error. This will stop the execution.

src: https://www.gnu.org/software/make/manual/make.html#Make-Control-Functions