diff -Naur sed-4.7-orig/build-aux/ar-lib sed-4.7/build-aux/ar-lib
--- sed-4.7-orig/build-aux/ar-lib	2017-05-11 05:07:49.000000000 +0300
+++ sed-4.7/build-aux/ar-lib	2018-12-26 10:34:03.213661000 +0300
@@ -56,6 +56,9 @@
 	  CYGWIN*)
 	    file_conv=cygwin
 	    ;;
+	  MSYS*)
+	    file_conv=cygwin
+	    ;;
 	  *)
 	    file_conv=wine
 	    ;;
@@ -68,6 +71,9 @@
 	cygwin)
 	  file=`cygpath -m "$file" || echo "$file"`
 	  ;;
+	msys)
+	  file=`cygpath -m "$file" || echo "$file"`
+	  ;;
 	wine)
 	  file=`winepath -w "$file" || echo "$file"`
 	  ;;
diff -Naur sed-4.7-orig/build-aux/compile sed-4.7/build-aux/compile
--- sed-4.7-orig/build-aux/compile	2017-01-17 03:22:47.000000000 +0300
+++ sed-4.7/build-aux/compile	2018-12-26 10:34:03.229261000 +0300
@@ -56,6 +56,9 @@
 	  CYGWIN*)
 	    file_conv=cygwin
 	    ;;
+	  MSYS*)
+	    file_conv=cygwin
+	    ;;
 	  *)
 	    file_conv=wine
 	    ;;
@@ -70,6 +73,9 @@
 	cygwin/*)
 	  file=`cygpath -m "$file" || echo "$file"`
 	  ;;
+	msys/*)
+	  file=`cygpath -m "$file" || echo "$file"`
+	  ;;
 	wine/*)
 	  file=`winepath -w "$file" || echo "$file"`
 	  ;;
diff -Naur sed-4.7-orig/build-aux/config.guess sed-4.7/build-aux/config.guess
--- sed-4.7-orig/build-aux/config.guess	2018-12-13 09:11:38.000000000 +0300
+++ sed-4.7/build-aux/config.guess	2018-12-26 10:34:03.244861000 +0300
@@ -891,6 +891,9 @@
     amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
 	echo x86_64-pc-cygwin
 	exit ;;
+    amd64:MSYS*:*:* | x86_64:MSYS*:*:*)
+	echo x86_64-unknown-cygwin
+	exit ;;
     prep*:SunOS:5.*:*)
 	echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
 	exit ;;
diff -Naur sed-4.7-orig/build-aux/config.rpath sed-4.7/build-aux/config.rpath
--- sed-4.7-orig/build-aux/config.rpath	2018-01-04 03:36:29.000000000 +0300
+++ sed-4.7/build-aux/config.rpath	2018-12-26 10:34:03.291661100 +0300
@@ -57,7 +57,7 @@
     aix*)
       wl='-Wl,'
       ;;
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
+    mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
       ;;
     hpux9* | hpux10* | hpux11*)
       wl='-Wl,'
@@ -149,7 +149,7 @@
 hardcode_minus_L=no
 
 case "$host_os" in
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     # FIXME: the MSVC++ port hasn't been tested in a loooong time
     # When not using gcc, we currently assume that we are using
     # Microsoft Visual C++.
@@ -198,7 +198,7 @@
         ld_shlibs=no
       fi
       ;;
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # hardcode_libdir_flag_spec is actually meaningless, as there is
       # no search path for DLLs.
       hardcode_libdir_flag_spec='-L$libdir'
@@ -348,7 +348,7 @@
       ;;
     bsdi[45]*)
       ;;
-    cygwin* | mingw* | pw32* | cegcc*)
+    cygwin* | msys* | mingw* | pw32* | cegcc*)
       # When not using gcc, we currently assume that we are using
       # Microsoft Visual C++.
       # hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -533,7 +533,7 @@
   bsdi[45]*)
     library_names_spec='$libname$shrext'
     ;;
-  cygwin* | mingw* | pw32* | cegcc*)
+  cygwin* | msys* | mingw* | pw32* | cegcc*)
     shrext=.dll
     library_names_spec='$libname.dll.a $libname.lib'
     ;;
diff -Naur sed-4.7-orig/configure.ac sed-4.7/configure.ac
--- sed-4.7-orig/configure.ac	2018-12-10 06:26:36.000000000 +0300
+++ sed-4.7/configure.ac	2018-12-26 10:34:03.307261100 +0300
@@ -73,7 +73,7 @@
 }], [sed_cv_fopen_rt=yes],
     [sed_cv_fopen_rt=no],
     [case $host in
-       *cygwin* | *mingw*) sed_cv_fopen_rt=yes ;;
+       *cygwin* | *msys* | *mingw*) sed_cv_fopen_rt=yes ;;
        *) sed_cv_fopen_rt='assuming no' ;;
      esac])])
 if test "$sed_cv_fopen_rt" = yes; then
diff -Naur sed-4.7-orig/gnulib-tests/test-copy-acl.sh sed-4.7/gnulib-tests/test-copy-acl.sh
--- sed-4.7-orig/gnulib-tests/test-copy-acl.sh	2014-09-15 02:58:00.000000000 +0400
+++ sed-4.7/gnulib-tests/test-copy-acl.sh	2018-12-26 10:34:03.307261100 +0300
@@ -128,7 +128,7 @@
   # the programs.
   # func_test_same_acls file1 file2
   case $acl_flavor in
-    linux | cygwin | freebsd | solaris)
+    linux | cygwin | msys | freebsd | solaris)
       func_test_same_acls ()
       {
         getfacl "$1" | sed -e "s/$1/FILENAME/g" > tmpaclout1
@@ -302,7 +302,7 @@
 
         ;;
 
-      cygwin)
+      cygwin | msys)
 
         # Set an ACL for a group.
         setfacl -m group:0:1 tmpfile0
diff -Naur sed-4.7-orig/gnulib-tests/test-file-has-acl.sh sed-4.7/gnulib-tests/test-file-has-acl.sh
--- sed-4.7-orig/gnulib-tests/test-file-has-acl.sh	2014-09-15 02:58:00.000000000 +0400
+++ sed-4.7/gnulib-tests/test-file-has-acl.sh	2018-12-26 10:34:03.322861200 +0300
@@ -247,7 +247,7 @@
         fi
         ;;
 
-      cygwin)
+      cygwin | msys)
 
         # Set an ACL for a group.
         if setfacl -m group:0:1 tmpfile0; then
diff -Naur sed-4.7-orig/gnulib-tests/test-set-mode-acl.sh sed-4.7/gnulib-tests/test-set-mode-acl.sh
--- sed-4.7-orig/gnulib-tests/test-set-mode-acl.sh	2014-09-15 02:58:00.000000000 +0400
+++ sed-4.7/gnulib-tests/test-set-mode-acl.sh	2018-12-26 10:34:03.338461200 +0300
@@ -177,7 +177,7 @@
           linux | freebsd | solaris)
             setfacl -m user:$auid:1 tmpfile0
             ;;
-          cygwin)
+          cygwin | msys)
             setfacl -m group:0:1 tmpfile0
             ;;
           hpux)
diff -Naur sed-4.7-orig/m4/btowc.m4 sed-4.7/m4/btowc.m4
--- sed-4.7-orig/m4/btowc.m4	2018-01-04 03:36:29.000000000 +0300
+++ sed-4.7/m4/btowc.m4	2018-12-26 10:34:03.369661200 +0300
@@ -50,6 +50,8 @@
            case "$host_os" in
                       # Guess no on Cygwin.
              cygwin*) gl_cv_func_btowc_nul="guessing no" ;;
+                      # Guess no on MSYS.
+             msys*)   gl_cv_func_btowc_nul="guessing no" ;;
                       # Guess yes on native Windows.
              mingw*)  gl_cv_func_btowc_nul="guessing yes" ;;
                       # Guess yes otherwise.
diff -Naur sed-4.7-orig/m4/double-slash-root.m4 sed-4.7/m4/double-slash-root.m4
--- sed-4.7-orig/m4/double-slash-root.m4	2018-01-04 03:36:29.000000000 +0300
+++ sed-4.7/m4/double-slash-root.m4	2018-12-26 10:34:03.385261300 +0300
@@ -16,7 +16,7 @@
         # special semantics and is distinct from /, please report it to
         # <bug-gnulib@gnu.org>.
         case $host in
-          *-cygwin | i370-ibm-openedition)
+          *-cygwin | *-msys | i370-ibm-openedition)
             gl_cv_double_slash_root=yes ;;
           *)
             # Be optimistic and assume that / and // are the same when we
diff -Naur sed-4.7-orig/m4/dup2.m4 sed-4.7/m4/dup2.m4
--- sed-4.7-orig/m4/dup2.m4	2018-01-04 03:36:29.000000000 +0300
+++ sed-4.7/m4/dup2.m4	2018-12-26 10:34:03.416461300 +0300
@@ -78,7 +78,7 @@
         [case "$host_os" in
            mingw*) # on this platform, dup2 always returns 0 for success
              gl_cv_func_dup2_works="guessing no" ;;
-           cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
+           cygwin* | msys*) # on cygwin 1.5.x, dup2(1,1) returns 0
              gl_cv_func_dup2_works="guessing no" ;;
            aix* | freebsd*)
                    # on AIX 7.1 and FreeBSD 6.1, dup2 (1,toobig) gives EMFILE,
diff -Naur sed-4.7-orig/m4/fcntl.m4 sed-4.7/m4/fcntl.m4
--- sed-4.7-orig/m4/fcntl.m4	2018-01-04 03:36:29.000000000 +0300
+++ sed-4.7/m4/fcntl.m4	2018-12-26 10:34:03.432061400 +0300
@@ -69,7 +69,7 @@
          [gl_cv_func_fcntl_f_dupfd_works=yes],
          [gl_cv_func_fcntl_f_dupfd_works=no],
          [case $host_os in
-            aix* | cygwin* | haiku*)
+            aix* | cygwin* | msys* | haiku*)
                gl_cv_func_fcntl_f_dupfd_works="guessing no" ;;
             *) gl_cv_func_fcntl_f_dupfd_works="guessing yes" ;;
           esac])])
diff -Naur sed-4.7-orig/m4/getcwd.m4 sed-4.7/m4/getcwd.m4
--- sed-4.7-orig/m4/getcwd.m4	2018-12-13 09:11:38.000000000 +0300
+++ sed-4.7/m4/getcwd.m4	2018-12-26 10:34:03.463261400 +0300
@@ -51,7 +51,7 @@
                            # Guess yes on musl systems.
             *-musl*)       gl_cv_func_getcwd_null="guessing yes";;
                            # Guess yes on Cygwin.
-            cygwin*)       gl_cv_func_getcwd_null="guessing yes";;
+            cygwin* | msys*)       gl_cv_func_getcwd_null="guessing yes";;
                            # If we don't know, obey --enable-cross-guesses.
             *)             gl_cv_func_getcwd_null="$gl_cross_guess_normal";;
           esac
diff -Naur sed-4.7-orig/m4/getdtablesize.m4 sed-4.7/m4/getdtablesize.m4
--- sed-4.7-orig/m4/getdtablesize.m4	2018-01-04 03:36:29.000000000 +0300
+++ sed-4.7/m4/getdtablesize.m4	2018-12-26 10:34:03.463261400 +0300
@@ -39,7 +39,7 @@
              [gl_cv_func_getdtablesize_works=yes],
              [gl_cv_func_getdtablesize_works=no],
              [case "$host_os" in
-                cygwin*) # on cygwin 1.5.25, getdtablesize() automatically grows
+                cygwin* | msys*) # on cygwin 1.5.25, getdtablesize() automatically grows
                   gl_cv_func_getdtablesize_works="guessing no" ;;
                 *) gl_cv_func_getdtablesize_works="guessing yes" ;;
               esac
diff -Naur sed-4.7-orig/m4/malloc.m4 sed-4.7/m4/malloc.m4
--- sed-4.7-orig/m4/malloc.m4	2018-12-13 09:11:38.000000000 +0300
+++ sed-4.7/m4/malloc.m4	2018-12-26 10:34:03.510061500 +0300
@@ -33,7 +33,7 @@
        [case "$host_os" in
           # Guess yes on platforms where we know the result.
           *-gnu* | gnu* | *-musl* | freebsd* | netbsd* | openbsd* \
-          | hpux* | solaris* | cygwin* | mingw*)
+          | hpux* | solaris* | cygwin* | msys* | mingw*)
             ac_cv_func_malloc_0_nonnull="guessing yes" ;;
           # If we don't know, assume the worst.
           *) ac_cv_func_malloc_0_nonnull="guessing no" ;;
diff -Naur sed-4.7-orig/m4/realloc.m4 sed-4.7/m4/realloc.m4
--- sed-4.7-orig/m4/realloc.m4	2018-01-04 03:36:29.000000000 +0300
+++ sed-4.7/m4/realloc.m4	2018-12-26 10:34:03.541261600 +0300
@@ -33,7 +33,7 @@
        [case "$host_os" in
           # Guess yes on platforms where we know the result.
           *-gnu* | gnu* | *-musl* | freebsd* | netbsd* | openbsd* \
-          | hpux* | solaris* | cygwin* | mingw*)
+          | hpux* | solaris* | cygwin* | msys* | mingw*)
             ac_cv_func_realloc_0_nonnull="guessing yes" ;;
           # If we don't know, assume the worst.
           *) ac_cv_func_realloc_0_nonnull="guessing no" ;;
diff -Naur sed-4.7-orig/m4/setlocale.m4 sed-4.7/m4/setlocale.m4
--- sed-4.7-orig/m4/setlocale.m4	2018-12-13 09:11:38.000000000 +0300
+++ sed-4.7/m4/setlocale.m4	2018-12-26 10:34:03.556861600 +0300
@@ -14,7 +14,7 @@
     mingw*) REPLACE_SETLOCALE=1 ;;
     dnl On Cygwin 1.5.x, setlocale always succeeds but setlocale(LC_CTYPE,NULL)
     dnl is then still "C".
-    cygwin*)
+    cygwin* | msys*)
       case `uname -r` in
         1.5.*) REPLACE_SETLOCALE=1 ;;
       esac
diff -Naur sed-4.7-orig/m4/threadlib.m4 sed-4.7/m4/threadlib.m4
--- sed-4.7-orig/m4/threadlib.m4	2018-12-13 09:11:38.000000000 +0300
+++ sed-4.7/m4/threadlib.m4	2018-12-26 10:34:03.572461600 +0300
@@ -68,7 +68,7 @@
          dnl Disable multithreading by default on Cygwin 1.5.x, because it has
          dnl bugs that lead to endless loops or crashes. See
          dnl <https://cygwin.com/ml/cygwin/2009-08/msg00283.html>.
-         cygwin*)
+         cygwin* | msys*)
                case `uname -r` in
                  1.[0-5].*) gl_use_threads=no ;;
                  *)         gl_use_threads=yes ;;
diff -Naur sed-4.7-orig/m4/wctob.m4 sed-4.7/m4/wctob.m4
--- sed-4.7-orig/m4/wctob.m4	2018-01-04 03:36:29.000000000 +0300
+++ sed-4.7/m4/wctob.m4	2018-12-26 10:34:03.619261700 +0300
@@ -39,7 +39,7 @@
         esac
 changequote([,])dnl
         case "$host_os" in
-          cygwin*)
+          cygwin* | msys*)
             AC_RUN_IFELSE(
               [AC_LANG_SOURCE([[
 #include <locale.h>
