build: Add support for MSYS2

MSYS2 is a modern fork of Cygwin that is widely supported
and provides frequent releases and good support. It is
also the framework used by the official Windows Git port.
This patch adds MSYS2 support so that builds on Windows using
MSYS2 work properly.

Change-Id: Ia5743a410d1cff983a7aab37f8e3d8228cb8ae8e
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
diff --git a/Makefile b/Makefile
index d09d2c2..70c3d79 100644
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,11 @@
 MAKEFLAGS += -rR --include-dir=$(CURDIR)
 
 UNAME := $(shell uname)
-ifeq (MINGW, $(findstring MINGW, $(UNAME)))
+ifeq (MSYS, $(findstring MSYS, $(UNAME)))
+DISABLE_TRYRUN=y
+HOST_OS=MSYS
+PWD_OPT=-W
+else ifeq (MINGW, $(findstring MINGW, $(UNAME)))
 HOST_OS=MINGW
 PWD_OPT=-W
 DISABLE_TRYRUN=y
diff --git a/zephyr-env.sh b/zephyr-env.sh
index 2027ae5..d758a8d 100644
--- a/zephyr-env.sh
+++ b/zephyr-env.sh
@@ -35,10 +35,10 @@
 # zephyr-env_install.bash in your home directory. It will be automatically
 # run (if it exists) by this script.
 
-uname | grep -q MINGW && MINGW_OPT="-W"
+uname | grep -q -P "MINGW|MSYS" && PWD_OPT="-W"
 
 # identify OS source tree root directory
-export ZEPHYR_BASE=$( builtin cd "$( dirname "$DIR" )" && pwd ${MINGW_OPT})
+export ZEPHYR_BASE=$( builtin cd "$( dirname "$DIR" )" && pwd ${PWD_OPT})
 
 scripts_path=${ZEPHYR_BASE}/scripts
 scripts_path=$(echo "/$scripts_path" | sed 's/\\/\//g' | sed 's/://')