Fix build portability issues

Some platforms don't accept running c++ with the -std=c99 option.  Also,
adding the -fPIC option is not portable.  Instead, rely on the built-in
rules to build shared objects, and override the right flags per file.