3 ms·
How I handle that: .var.%: FORCE @printf '%s' '$(subst ','\'',$($*))' | sed 's|^|#|' | $(WRITE_IFCHANGED) $@ -include $(wildcard .var*) .PHONY
by LukeShu 10y ago
How I handle that:
.var.%: FORCE
@printf '%s' '$(subst ','\'',$($*))' | sed 's|^|#|' | $(WRITE_IFCHANGED) $@
-include $(wildcard .var*)
.PHONY: FORCE
Where WRITE_IFCHANGED is a program that essentially does 'cat > $1', but only if doing so would create or change the file. https://lukeshu.com/git/autothing/tree/build-aux/write-ifchanged?h=mod-write-ifchanged https://lukeshu.com/git/autothing/tree/build-aux/write-ifcha...
Then, if a file depends on the value of a variable, I have it depend on .var.VARNAME. Of course, that means you may have to do something like $(filter-out .var.%,$^) in the command to generate a file.