Make shared library get generated from static

Avoids having to compile all the sources twice.
However, will currently only work on certain
linkers (should work on Mac OS with default tools,
any non-ancient GNU ld, and lld)
Merge branch 'refs/heads/library_magic'