build: calculate dependencies

We're past the point where it's pleasant to keep doing 'make clean all'
instead of calculating dependencies.

.d file generating hack lifted from

   http://scottmcpeak.com/autodepend/autodepend.html

which has the same idea as the one listed in the GNU Make manual, but
it's a bit more refined.