Bug 1065255: Support static linking

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