79672969

Date: 2025-06-20 07:04:55
Score: 1
Natty:
Report link

Based on @John Bollinger answer + googling about colorizing error outputs from make I've stumbled across following solution in the makefile documentation:

ifdef REVISION
$(info "REVISION is ${REVISION}")
ERR = :
else
ERR = $(error "REVISION is unspecified...")
endif

all: err <some other prerequisities>



.PHONY: err
err: ; ERR

.PHONY: clear
clear:
    rm -r build

According to my understanding, the first prerequisite "err" in the "all" target gets executed first. From that perspective the "ERR" variable is expanded and executed.

However, this solution might not solve what @John Bollinger pointed out and that is if someone tries to execute an intermediate file or so.

However, my case is, that the REV propagates into source code from makefile via CFLAGS and if it's not defined, the code doesn't get compiled, as there is detection for revision. So both solutions are acceptable for me. :-)

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @John
  • User mentioned (0): @John
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: ST Renegade