Merge pull request #251 from Alexpux/mingw-w64-builds

Optimize build script.
Merge pull request #252 from Alexpux/mingw-w64-builds

Fix variable visibility