Fix build on mac.

Copied most of the cflags stuff, not sure if entirely correct.