Better tool discovery and checking in the wrapper

Make the perl wrapper script search for more tools
in well-known paths, and make sure it tests all the
build tools, not just the language interpreters.

Also resolves an issue with stdout from the build
with some configurations.