--- a/tools/build/src/engine/build.sh 2020-04-22 18:36:26.000000000 +0500
+++ b/tools/build/src/engine/build.sh 2020-05-20 18:03:00.581459600 +0500
@@ -68,5 +68,12 @@
     fi
 }
+
+test_msystem ()
+{
+    if [ -n $MSYSTEM ]; then
+      test "$MSYSTEM" = "$*"
+    fi
+}

 # Check that the given command runs.
 test_exec ()
 {
@@ -108,6 +115,12 @@
 guess_toolset ()
 {
     if test_uname Darwin && test_cxx11 clang ; then B2_TOOLSET=clang
+    elif test_msystem MINGW32 ; then
+        B2_TOOLSET=gcc
+        B2_TOOLSET_ROOT=/mingw32/
+    elif test_msystem MINGW64 ; then
+        B2_TOOLSET=gcc
+        B2_TOOLSET_ROOT=/mingw64/
     elif test_uname IRIX && test_cxx11 mipspro ; then B2_TOOLSET=mipspro
     elif test_uname IRIX64 && test_cxx11 mipspro ; then B2_TOOLSET=mipspro
     elif test_uname OSF1 && test_cxx11 tru64cxx ; then B2_TOOLSET=tru64cxx
