Just to be clear, subst
is not short for subset, it's short for substitute.
$(subst $(ROOTDIR),,$(CURDIR)))
replaces every occurrence of whatever value $(ROOTDIR)
expands to, with nothing (no text), in the value that $(CURDIR)
expands to. The commas separate arguments so the first comma separates $(ROOTDIR)
from the next argument and the second comma separates the second argument (which is empty) from $(CURDIR)
.
This is kind of a bad use of subst
, though, because it will replace $(ROOTDIR)
every time it appears (even multiple times) anywhere in the value (even in the middle or the end).
For things like this, where you want to remove a prefix only, it's best to use patsubst
, as in $(patsubst $(ROOTDIR)%,%,$(CURDIR))
.