Suppress external warnings

This PR contains Arne Morten's build system code to silence external warnings, modified a bit by me to make it a little more applicable.

It builds on #571, and I guess that is unfortunate and makes it harder to read (includes all those commits as well). Please tell me if you want me to create a new PR after #571 is in.