Bug 1065255: Support static linking

This patch adds support for building static libraries. This is requiried
to create self-contained executables.
Merge pull request #2 from tdz/bug-1065255

Bug 1065255: Support static linking