Enable building on os x

I haven't tested the changes on linux (or windows, for that matter). The only part I'd be concerned about not working is the modification to the linked libraries (LDFLAGS). I changed all the relevant flags to -g3 -O0, as without those, GDB refused to give me correct debug information. This seems to be strictly for debugging stuff anyway...