merge platform_helper into configure script

With this code all in one place, it's easier to spot unused code and
simplification opportunities.
Merge pull request #859 from martine/platform-helper

merge platform_helper into configure script