Check build environment

Moved some common check build environment stuff into common functions.