Tweak build system to support static linking