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

Older toolchains don't recognize the -shared parameter.