If you need something to stick around as a GNUMake variable, this somewhat tacky solution can work. It gets squirrelly looking with a parallel make. This is a working example ripped from a working project. Focus on the YHCOUNTER variable.
SHELL := /bin/bash
YHCOUNTER := 0
cache/%.yhjson: cache/%.cache
@: $(eval YHCOUNTER=$(shell echo $$(($(YHCOUNTER) + 1))))
@echo YHCOUNTER = $(YHCOUNTER)
@if [[ $(YHCOUNTER) -lt 10 ]] ; then \
echo do work ; \
else echo skipping $(@) ; \
fi
If someone has a classier way to do it, please post it. Thanks.
-E
GNU Make 4.3
Built for x86_64-pc-linux-gnu