Tidying up the build system

This series of commits removes unused bits from the build system, and makes various well-used and portable dependencies mandatory, saving much #ifdeffery.

There are some other bits of tidy-up too. Overall, about 1,000 lines of code are removed.