diff -Naur bison-3.0.5-orig/build-aux/config.guess bison-3.0.5/build-aux/config.guess
--- bison-3.0.5-orig/build-aux/config.guess	2018-05-08 13:02:48.000000000 +0300
+++ bison-3.0.5/build-aux/config.guess	2018-05-31 08:52:50.957050300 +0300
@@ -947,6 +947,9 @@
     amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
 	GUESS=x86_64-pc-cygwin
 	;;
+    amd64:MSYS*:*:* | x86_64:MSYS*:*:*)
+	echo x86_64-unknown-msys
+	exit ;;
     prep*:SunOS:5.*:*)
 	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
 	GUESS=powerpcle-unknown-solaris2$SUN_REL
diff -Naur bison-3.0.5-orig/build-aux/config.rpath bison-3.0.5/build-aux/config.rpath
--- bison-3.0.5-orig/build-aux/config.rpath	2018-05-08 13:02:48.000000000 +0300
+++ bison-3.0.5/build-aux/config.rpath	2018-05-31 08:49:39.149826800 +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 bison-3.0.5-orig/m4/double-slash-root.m4 bison-3.0.5/m4/double-slash-root.m4
--- bison-3.0.5-orig/m4/double-slash-root.m4	2018-05-08 13:02:49.000000000 +0300
+++ bison-3.0.5/m4/double-slash-root.m4	2018-05-31 08:49:39.227827000 +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 bison-3.0.5-orig/m4/dup2.m4 bison-3.0.5/m4/dup2.m4
--- bison-3.0.5-orig/m4/dup2.m4	2018-05-08 13:02:49.000000000 +0300
+++ bison-3.0.5/m4/dup2.m4	2018-05-31 08:49:39.227827000 +0300
@@ -71,6 +71,8 @@
            gl_cv_func_dup2_works="guessing no" ;;
          cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
            gl_cv_func_dup2_works="guessing no" ;;
+         msys*) # on msys 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,
                  # not EBADF.
diff -aurp bison-3.1/m4/fcntl.m4.orig bison-3.1/m4/fcntl.m4
--- bison-3.1/m4/fcntl.m4.orig	2018-10-01 07:19:34.862451100 -0400
+++ bison-3.1/m4/fcntl.m4	2018-10-01 07:22:21.605390400 -0400
@@ -69,7 +69,7 @@ AC_DEFUN([gl_FUNC_FCNTL],
          [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 bison-3.0.5-orig/m4/getdtablesize.m4 bison-3.0.5/m4/getdtablesize.m4
--- bison-3.0.5-orig/m4/getdtablesize.m4	2018-05-08 13:02:49.000000000 +0300
+++ bison-3.0.5/m4/getdtablesize.m4	2018-05-31 08:53:34.677327300 +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 bison-3.0.5-orig/m4/printf.m4 bison-3.0.5/m4/printf.m4
--- bison-3.0.5-orig/m4/printf.m4	2018-05-08 13:02:49.000000000 +0300
+++ bison-3.0.5/m4/printf.m4	2018-05-31 08:54:22.304211000 +0300
@@ -785,6 +785,7 @@
            irix*)           gl_cv_func_printf_directive_ls="guessing no";;
            solaris*)        gl_cv_func_printf_directive_ls="guessing no";;
            cygwin*)         gl_cv_func_printf_directive_ls="guessing no";;
+           msys*)           gl_cv_func_printf_directive_ls="guessing no";;
            beos* | haiku*)  gl_cv_func_printf_directive_ls="guessing no";;
                             # Guess no on Android.
            linux*-android*) gl_cv_func_printf_directive_ls="guessing no";;
@@ -1524,6 +1524,7 @@
            darwin*)              gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
                                  # Guess yes on Cygwin.
            cygwin*)              gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
+           msys*)                gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
                                  # Guess yes on Solaris >= 2.6.
            solaris2.[0-5] | solaris2.[0-5].*)
                                  gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
diff -Naur bison-3.0.5-orig/m4/threadlib.m4 bison-3.0.5/m4/threadlib.m4
--- bison-3.0.5-orig/m4/threadlib.m4	2018-05-08 13:02:50.000000000 +0300
+++ bison-3.0.5/m4/threadlib.m4	2018-05-31 08:49:39.446227300 +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 ;;
