Various build fixes to enable a certain level of cross-platform support

Various build fixes to enable a certain level of cross-platform support, including

- respect build environment settings
- remove superfluous dependency on bash for py-version.sh
- enable alloca() support on FreeBSD