diff -Naur make-4.2.1/configh.dos make-4.2.1.1/configh.dos
--- make-4.2.1/configh.dos	2016-06-11 02:03:54 +0300
+++ make-4.2.1.1/configh.dos	2018-02-14 11:46:24 +0200
@@ -49,6 +49,9 @@
 /* Define to 1 if you have the 'getgroups' function. */
 #define HAVE_GETGROUPS 1
 
+/* Define to 1 if you have the 'getrlimit' function.  */
+#define HAVE_GETRLIMIT 1
+
 /* Define to 1 if you have the <memory.h> header file.  */
 #define HAVE_MEMORY_H 1
 
@@ -58,6 +61,12 @@
 /* Define to 1 if you have the 'mktemp' function. */
 #define HAVE_MKTEMP 1
 
+/* Define to 1 if you have the 'setrlimit' function.  */
+#define HAVE_SETRLIMIT 1
+
+/* Define to 1 if you have the <sys/resource.h> header file.  */
+#define HAVE_SYS_RESOURCE_H 1
+
 /* Define to 1 if you have the 'setlinebuf' function. */
 #define HAVE_SETLINEBUF 1
 
diff -Naur make-4.2.1/job.c make-4.2.1.1/job.c
--- make-4.2.1/job.c	2016-05-21 23:22:32 +0300
+++ make-4.2.1.1/job.c	2018-04-30 21:14:54 +0300
@@ -368,7 +368,135 @@
 }
 #endif /* WINDOWS32 */
 
-#ifdef __EMX__
+#ifdef __MSDOS__
+static char *
+create_batch_file (char const *base, int unixy, int *fd)
+{
+  const char *const ext = unixy ? ".SH" : ".BAT";
+  char temp_path[MAXPATHLEN]; /* need to know its length */
+  char *path;
+  char *tmpdir;
+  char c, pathsep = '\\';
+  unsigned r, path_size = 0;
+  int nx, i, k, m;
+  int ix[8];
+  static unsigned int state = 0;
+
+  if ((tmpdir = getenv ("TEMP")) == NULL && (tmpdir = getenv ("TMP")) == NULL)
+    {
+      tmpdir = getcwd(temp_path, MAXPATHLEN);
+    }
+
+  path_size = strlen(tmpdir);
+  if (unixy || strchr(tmpdir, '/') != NULL)
+    pathsep = '/';
+
+  memcpy(temp_path, tmpdir, path_size);
+  if (temp_path[path_size-1] != '/' && temp_path[path_size-1] != '\\')
+    {
+      temp_path[path_size] = pathsep;
+      ++path_size;
+    }
+
+  r = strlen(base);
+  memcpy(temp_path + path_size, base, r);
+  path_size += r;
+  nx = MAXPATHLEN - 1 - path_size - strlen(ext);
+
+  if (nx < 1)
+    O (fatal, NILF, _("Cannot create a temporary file\n"));
+
+  if (nx > 8 - r)
+    nx = 8 - r;
+
+  strcpy(&temp_path[path_size + nx], ext);
+
+  k = 0;
+  do
+    {
+      r = k + state + getpid();
+      for (i = 0; i < nx; ++i)
+        {
+          c = r % 36;
+          if (c < 10)
+            c = c + '0';
+          else if (c < 36)
+            c = c - 10 + 'A';
+          temp_path[path_size + i] = c;
+          r = 17*r + 0x75F1;
+        }
+      state ^= (r | (state >> 1));
+      r ^= (state | (r << 4));
+      state ^= (r | (state >> 1));
+      ++k;
+    }
+  while ((m = access(temp_path, F_OK)) == 0 && k < 9);
+
+  if (!m)
+    {
+      ix[0] = 1;
+      for (i = 1; i < nx; ++i)
+        ix[i] = 0;
+
+      do
+        {
+          for (; ix[0] < 36; ++ix[0])
+            {
+              c = temp_path[path_size];
+              if (c == '9')
+                c = 'A';
+              else if (c == 'Z')
+                c = '0';
+              else
+                ++c;
+              temp_path[path_size] = c;
+
+              m = access(temp_path, F_OK);
+              if (m)
+                goto create;
+            }
+          for (i = 1; i < nx; ++i)
+            {
+              c = temp_path[path_size + i];
+              if (c == '9')
+                c = 'A';
+              else if (c == 'Z')
+                c = '0';
+              else
+                ++c;
+              temp_path[path_size + i] = c;
+              if (ix[i] < 35)
+                {
+                  ++ix[i];
+                  break;
+                }
+              else
+                ix[i] = 0;
+            }
+          ix[0] = 0;
+        }
+      while (i < nx);
+
+      O (fatal, NILF, _("Cannot create a temporary file\n"));
+    }
+
+ create:
+  path_size += nx + strlen(ext) + 1;
+  path = xmalloc (path_size);
+  if (path == NULL)
+    O (fatal, NILF, _("Cannot allocate memory\n"));
+  memcpy (path, temp_path, path_size);
+
+  *fd = open(path, O_CREAT|O_EXCL|O_WRONLY, S_IREAD|S_IWRITE);
+  if (*fd == -1)
+    return NULL;
+
+  return path;
+}
+#endif
+
+
+#if defined (WINDOWS32) || defined (__EMX__)
 /* returns whether path is assumed to be a unix like shell. */
 int
 _is_unixy_shell (const char *path)
@@ -411,7 +539,8 @@
   /* in doubt assume a unix like shell */
   return 1;
 }
-#endif /* __EMX__ */
+#define _is_dos_shell(path)  (!_is_unixy_shell(path))
+#endif
 
 /* determines whether path looks to be a Bourne-like shell. */
 int
@@ -3005,19 +3134,23 @@
               }
             *t = '\0';
           }
-#ifdef WINDOWS32
-        else    /* non-Posix shell (cmd.exe etc.) */
+#if defined WINDOWS32 || defined __MSDOS__
+        else if(_is_dos_shell (shell))   /* non-Posix shell (cmd.exe etc.) */
           {
             const char *f = line;
             char *t = line;
             char *tstart = t;
             int temp_fd;
             FILE* batch = NULL;
-            int id = GetCurrentProcessId ();
             PATH_VAR(fbuf);
+#ifdef WINDOWS32
+            int id = GetCurrentProcessId ();
 
-            /* Generate a file name for the temporary batch file.  */
             sprintf (fbuf, "make%d", id);
+#else
+            strcpy(fbuf, "MAKE");
+#endif
+            /* Generate a file name for the temporary batch file.  */
             *batch_filename = create_batch_file (fbuf, 0, &temp_fd);
             DB (DB_JOBS, (_("Creating temporary batch file %s\n"),
                           *batch_filename));
@@ -3077,7 +3210,7 @@
             new_argv[1] = NULL;
             return new_argv;
           }
-#endif /* WINDOWS32 */
+#endif
         /* Create an argv list for the shell command line.  */
         {
           int n = 0;
diff -Naur make-4.2.1/makeint.h make-4.2.1.1/makeint.h
--- make-4.2.1/makeint.h	2016-05-21 23:22:32 +0300
+++ make-4.2.1.1/makeint.h	2018-02-19 08:40:15 +0200
@@ -379,6 +379,20 @@
 # define WIN32_LEAN_AND_MEAN
 #endif  /* WINDOWS32 */
 
+#ifdef __MSDOS__
+# include <io.h>
+# define _setmode        setmode
+# define _fdopen         fdopen
+
+/* We don't have a preferred fixed value for LOCALEDIR.  */
+# ifndef LOCALEDIR
+#  define LOCALEDIR NULL
+# endif
+
+int _is_dos_shell (const char *path);
+int _is_unixy_shell (const char *path);
+#endif  /* __MSDOS__ */
+
 #define ANY_SET(_v,_m)  (((_v)&(_m)) != 0)
 #define NONE_SET(_v,_m) (! ANY_SET ((_v),(_m)))
 
diff -Naur make-4.2.1/read.c make-4.2.1.1/read.c
--- make-4.2.1/read.c	2016-05-21 23:22:32 +0300
+++ make-4.2.1.1/read.c	2018-02-12 10:53:22 +0200
@@ -2072,7 +2072,7 @@
         }
       else if (streq (name, ".SECONDEXPANSION"))
         second_expansion = 1;
-#if !defined (__MSDOS__) && !defined (__EMX__)
+#if !defined (__EMX__)
       else if (streq (name, ".ONESHELL"))
         one_shell = 1;
 #endif
diff -Naur make-4.2.1/variable.c make-4.2.1.1/variable.c
--- make-4.2.1/variable.c	2016-05-21 23:22:32 +0300
+++ make-4.2.1.1/variable.c	2017-11-12 19:51:18 +0200
@@ -1346,50 +1346,6 @@
     }
   else
 #endif /* __MSDOS__ */
-#ifdef WINDOWS32
-  if ((origin == o_file || origin == o_override || origin == o_command)
-      && streq (varname, "SHELL"))
-    {
-      extern const char *default_shell;
-
-      /* Call shell locator function. If it returns TRUE, then
-         set no_default_sh_exe to indicate sh was found and
-         set new value for SHELL variable.  */
-
-      if (find_and_set_default_shell (p))
-        {
-          v = define_variable_in_set (varname, strlen (varname), default_shell,
-                                      origin, flavor == f_recursive,
-                                      (target_var
-                                       ? current_variable_set_list->set
-                                       : NULL),
-                                      flocp);
-          no_default_sh_exe = 0;
-        }
-      else
-        {
-          char *tp = alloc_value;
-
-          alloc_value = allocated_variable_expand (p);
-
-          if (find_and_set_default_shell (alloc_value))
-            {
-              v = define_variable_in_set (varname, strlen (varname), p,
-                                          origin, flavor == f_recursive,
-                                          (target_var
-                                           ? current_variable_set_list->set
-                                           : NULL),
-                                          flocp);
-              no_default_sh_exe = 0;
-            }
-          else
-            v = lookup_variable (varname, strlen (varname));
-
-          free (tp);
-        }
-    }
-  else
-#endif
 
   /* If we are defining variables inside an $(eval ...), we might have a
      different variable context pushed, not the global context (maybe we're
