Bug 1054934: Support static linking

This patch adds support for building static libraries. This is requiried
to create self-contained executables.