build system improvements

This should not break on WIN32, because I made it conditional on unix. However, you should double check.