I'm doing something similar.
I'm building a static(ish) site generator, that features a built-in "configure" command to generate a makefile, so that only changed files and their dependents need to be rebuilt.
That's also part of why it's called a 'static-ish' site generator - it can render stuff into pure static html, but it can also use things like SSI or ESI to embed common things, so e.g. a nav bar/footer could be injected using SSI or ESI, and then when that changes, not every page needs to be re-built.
Edit: s/script/command/