Initial OS X compatibility changes

Preliminary changes. The code compiles and runs, but makefiles are temporarily hacked to compile on OS X and there are a couple of logging functions #define'd away temporarily for compatibility.