Dan
Dan

Reputation: 3341

How can I print message in Makefile?

I want to print some message while doing build process with a makefile. The following one can print the message, but it will not execute the script after it. How can I fix this issues?

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

Upvotes: 116

Views: 186601

Answers (2)

Vishnu N K
Vishnu N K

Reputation: 1580

$(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.

See GNU make: 8.13 Functions That Control Make for details.

Upvotes: 143

Beta
Beta

Reputation: 99154

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

Upvotes: 125

Related Questions