Build system fixes

Hopefully helps towards solving cldwalker/debugger#52 for people.