Use -dynamiclib instead of -shared for building shared libraries on OS X

Older toolchains don't recognize the -shared parameter.
Merge pull request #348 from mstorsjo/darwin-dylib

Use -dynamiclib instead of -shared for building shared libraries on OS X