Added conditional compilation for OSX (Darwin)

Out of the box sophia won't compile for OS X, so I made it work and added the changes back to the Makefiles so that it will compile on both Linux and OS X. The Linux section is unchanged, flag-wise.