make compilable on Mac OS X, where standard sed isn't working

This code tries to find which OS is used, and on Mac OS X checks for GNU sed.
If it's too verbose, feel free to remove not necessary code