Index: trunk/src/gmake/glob/fnmatch.c
===================================================================
--- trunk/src/gmake/glob/fnmatch.c	(revision 802)
+++ trunk/src/gmake/glob/fnmatch.c	(revision 803)
@@ -120,5 +120,5 @@
    whose names are inconsistent.  */
 
-# if !defined _LIBC && !defined getenv
+# if !defined _LIBC && !defined getenv && !defined _MSC_VER
 extern char *getenv ();
 # endif
Index: trunk/src/gmake/glob/glob.c
===================================================================
--- trunk/src/gmake/glob/glob.c	(revision 802)
+++ trunk/src/gmake/glob/glob.c	(revision 803)
@@ -188,4 +188,5 @@
 # ifndef __SASC
 #  ifdef WINDOWS32
+#   include <malloc.h>
 static void *
 my_realloc (void *p, unsigned int n)
Index: trunk/src/gmake/job.c
===================================================================
--- trunk/src/gmake/job.c	(revision 802)
+++ trunk/src/gmake/job.c	(revision 803)
@@ -180,7 +180,9 @@
 
 #ifndef	HAVE_UNISTD_H
+# ifndef _MSC_VER
 extern int dup2 ();
 extern int execve ();
 extern void _exit ();
+# endif
 # ifndef VMS
 extern int geteuid ();
@@ -574,5 +576,5 @@
 # else
               status = (WAIT_T)completed_child->status;
-# endif 
+# endif
             }
           else
@@ -763,5 +765,5 @@
           if (!dontcare)
 #ifdef KMK
-            { 
+            {
               child_error (c->file->name, exit_code, exit_sig, coredump, 0);
               if ((  c->file->cmds->lines_flags[c->command_line - 1]
@@ -772,5 +774,5 @@
 #else
             child_error (c->file->name, exit_code, exit_sig, coredump, 0);
-#endif 
+#endif
 
           c->file->update_status = 2;
@@ -1072,5 +1074,5 @@
 #else
     |= flags & COMMANDS_RECURSE;
-#endif 
+#endif
 
   /* Figure out an argument list from this command line.  */
@@ -1540,5 +1542,5 @@
   if (c->file->command_flags & COMMANDS_NOTPARALLEL)
     {
-      DB (DB_KMK, (_("not_parallel %d -> %d (file=%p `%s') [start_waiting_job]\n"), 
+      DB (DB_KMK, (_("not_parallel %d -> %d (file=%p `%s') [start_waiting_job]\n"),
                    not_parallel, not_parallel + 1, c->file, c->file->name));
       assert(not_parallel >= 0);
@@ -1549,5 +1551,5 @@
   /* If we are running at least one job already and the load average
      is too high, make this one wait.  */
-  if (!c->remote 
+  if (!c->remote
 #ifdef CONFIG_WITH_EXTENDED_NOTPARALLEL
       && ((job_slots_used > 0 && (not_parallel > 0 || load_too_high ()))
@@ -1888,5 +1890,5 @@
   else if (not_parallel > 0)
     {
-      /* wait for all live children to finish and then continue 
+      /* wait for all live children to finish and then continue
          with the not-parallel child(s). FIXME: this loop could be better? */
       while (file->command_state == cs_running
@@ -2048,9 +2050,9 @@
 #ifdef CONFIG_WITH_EXTENDED_NOTPARALLEL
       /* If it's a not-parallel job, we've already counted it once
-         when it was queued in start_waiting_job, so decrement 
+         when it was queued in start_waiting_job, so decrement
          before sending it to  start_waiting_job again. */
       if (job->file->command_flags & COMMANDS_NOTPARALLEL)
         {
-          DB (DB_KMK, (_("not_parallel %d -> %d (file=%p `%s') [start_waiting_jobs]\n"), 
+          DB (DB_KMK, (_("not_parallel %d -> %d (file=%p `%s') [start_waiting_jobs]\n"),
                        not_parallel, not_parallel - 1, job->file, job->file->name));
           assert(not_parallel > 0);
@@ -2926,5 +2928,5 @@
 #ifdef KMK /* see test in Makefile.kmk, required on windows. */
                 if (!batch_mode_shell)
-#endif 
+#endif
 		*(ap++) = '\\';
 		*(ap++) = '\n';
@@ -3231,11 +3233,11 @@
 
 #ifdef CONFIG_WITH_KMK_BUILTIN
-  /* If it's a kmk_builtin command, make sure we're treated like a 
+  /* If it's a kmk_builtin command, make sure we're treated like a
      unix shell and and don't get batch files. */
-  if (   (  !unixy_shell 
+  if (   (  !unixy_shell
           || batch_mode_shell
 # ifdef WINDOWS32
           || no_default_sh_exe
-# endif 
+# endif
          )
       && !strncmp(line, "kmk_builtin_", sizeof("kmk_builtin_") - 1))
@@ -3246,5 +3248,5 @@
     int saved_no_default_sh_exe = no_default_sh_exe;
     no_default_sh_exe = 0;
-# endif 
+# endif
     unixy_shell = 1;
     batch_mode_shell = 0;
Index: trunk/src/gmake/kmkbuiltin.c
===================================================================
--- trunk/src/gmake/kmkbuiltin.c	(revision 802)
+++ trunk/src/gmake/kmkbuiltin.c	(revision 803)
@@ -35,5 +35,7 @@
 #include "kmkbuiltin.h"
 
+#ifndef _MSC_VER
 extern char **environ;
+#endif
 
 int kmk_builtin_command(const char *pszCmd)
Index: trunk/src/gmake/main.c
===================================================================
--- trunk/src/gmake/main.c	(revision 802)
+++ trunk/src/gmake/main.c	(revision 803)
@@ -72,5 +72,5 @@
 #endif
 
-#ifndef	HAVE_UNISTD_H
+#if !defined(HAVE_UNISTD_H) && !defined(_MSC_VER)
 extern int chdir ();
 #endif
@@ -1005,5 +1005,7 @@
 #endif
 
+#ifndef _MSC_VER
 extern char *mktemp PARAMS ((char *template));
+#endif
 extern int mkstemp PARAMS ((char *template));
 
Index: trunk/src/gmake/make.h
===================================================================
--- trunk/src/gmake/make.h	(revision 802)
+++ trunk/src/gmake/make.h	(revision 803)
@@ -494,5 +494,5 @@
 
 #ifdef  HAVE_GETCWD
-# if !defined(VMS) && !defined(__DECC)
+# if !defined(VMS) && !defined(__DECC) && !defined(_MSC_VER)
 extern char *getcwd ();
 # endif
@@ -505,5 +505,7 @@
 extern const struct floc **expanding_var;
 
+#if !defined(_MSC_VER)
 extern char **environ;
+#endif
 
 extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
