In my makefile I implement a simple TODO counter like this
search-todo:
@echo "${_RED} --LOOKING FOR TODO ${_END}"
@grep -I -ri 'todo' $(SRCDIR) | wc -l
It worked fine until I delete my last TODO. So my wc return 0 and make interpret 0 as an error.
So I would improve my target "search-todo".
My idea is just to return a string like TODO count is XXX
So last night I try a lot of things but none works :
NB_TODO:=$(grep -I -ri 'todo' $(SRCDIR) | wc -l)
search-todo:
@echo "${_RED} --LOOKING FOR TODO ${_END}"
#echo interpret $v (and it's nothing) and display "TODO count is ar"
var="$(grep -I -ri 'todo' $(SRCDIR) | wc -l)" ; echo "TODO count is $var"
#echo interpret $(var) with nothing and display "TODO count is"
var="$(grep -I -ri 'todo' $(SRCDIR) | wc -l)" ; echo "TODO count is $(var)"
#info display nothing
$(info grep -I -ri 'todo' $(SRCDIR) | wc -l)
#echo display "toto tata"
echo "toto $(NB_TODO) tata"
#echo display nothing
echo $(grep -I -ri 'todo' $(SRCDIR) | wc -l)
#info display nothing
$(info $(NB_TODO))
#return 0
grep -I -ri 'todo' $(SRCDIR) | wc -l
With all this tests I understand that make can't store result of a command in a var. Or I don't know how to do it.
Any explanation of makefile mechanisms will be appreciated to understand how to store command result (and display it)