Makefile dependency tracking

This expands on the patch in issue 7022, adding full dependency tracking for all targets. I don't regard it as finished, since this patch makes the build splash screen behave a bit confusingly when nothing is being built, but I haven't thought of a good solution for this yet. Ideas are welcome.