New build system

Non-recursive build system, which unlike the previous one, handles
header dependencies as well.

It can probably use a little polishing, but it's already better than the
previous one, so here it is.