toolchain fixes to enable cross compatibility

- Let the build environment decide about the toolchain to be used, in casethere are special tweaks and paths to be considered. Just provide some defaults, in case the values are undefined.
- py-version.sh does not need any bash specific features.
- Use libdl only on Linux for now. FreeBSD provides dl*() calls from libc.

This supersedes the mess from pull request #666