build: Fix up generic build system

The purpose of this commit is to fix up a number of the issues in
the (previously broken) build system [citation needed].