Only in gnumake-130: Makefile
Only in gnumake-130: config.h
diff -ru make-3.81/default.c gnumake-130/default.c
--- make-3.81/default.c	2006-02-11 14:16:04.000000000 -0800
+++ gnumake-130/default.c	2011-12-22 12:02:13.000000000 -0800
@@ -45,7 +45,7 @@
 .mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \
 .w .ch .web .sh .elc .el .obj .exe .dll .lib";
 #else
-  = ".out .a .ln .o .c .cc .C .cpp .p .f .F .r .y .l .s .S \
+  = ".out .a .ln .o .c .cc .C .cpp .p .f .F .m .r .y .l .ym .lm .s .S \
 .mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \
 .w .ch .web .sh .elc .el";
 #endif
@@ -192,6 +192,8 @@
     "$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     ".f",
     "$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $@",
+    ".m",
+    "$(LINK.m) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     ".p",
     "$(LINK.p) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     ".F",
@@ -221,6 +223,8 @@
     "$(COMPILE.cpp) $(OUTPUT_OPTION) $<",
     ".f.o",
     "$(COMPILE.f) $(OUTPUT_OPTION) $<",
+    ".m.o",
+    "$(COMPILE.m) $(OUTPUT_OPTION) $<",
     ".p.o",
     "$(COMPILE.p) $(OUTPUT_OPTION) $<",
     ".F.o",
@@ -250,6 +254,11 @@
     ".l.c",
     "@$(RM) $@ \n $(LEX.l) $< > $@",
 
+    ".ym.m",
+    "$(YACC.m) $< \n mv -f y.tab.c $@",
+    ".lm.m",
+    "@$(RM) $@ \n $(LEX.m) $< > $@",
+
     ".F.f",
     "$(PREPROCESS.F) $(OUTPUT_OPTION) $<",
     ".r.f",
@@ -304,6 +313,9 @@
 
 static char *default_variables[] =
   {
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+    "GNUMAKE", "YES",	/* I'm not sure who uses this.  Dave Payne 8/10/99 */
+#endif /* __APPLE__ || NeXT || NeXT_PDO */
 #ifdef VMS
 #ifdef __ALPHA
     "ARCH", "ALPHA",
@@ -400,7 +412,7 @@
 # endif /* __MSDOS__ */
 #else
     "CC", "cc",
-    "CXX", "g++",
+    "CXX", "c++",
 #endif
 
     /* This expands to $(CO) $(COFLAGS) $< $@ if $@ does not exist,
@@ -468,6 +480,8 @@
     "LINK.o", "$(CC) $(LDFLAGS) $(TARGET_ARCH)",
     "COMPILE.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
     "LINK.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
+    "COMPILE.m", "$(COMPILE.c)",
+    "LINK.m", "$(LINK.c)",
     "COMPILE.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
     "COMPILE.C", "$(COMPILE.cc)",
     "COMPILE.cpp", "$(COMPILE.cc)",
@@ -476,6 +490,8 @@
     "LINK.cpp", "$(LINK.cc)",
     "YACC.y", "$(YACC) $(YFLAGS)",
     "LEX.l", "$(LEX) $(LFLAGS) -t",
+    "YACC.m", "$(YACC) $(YFLAGS)",
+    "LEX.m", "$(LEX) $(LFLAGS) -t",
     "COMPILE.f", "$(FC) $(FFLAGS) $(TARGET_ARCH) -c",
     "LINK.f", "$(FC) $(FFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
     "COMPILE.F", "$(FC) $(FFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
diff -ru make-3.81/expand.c gnumake-130/expand.c
--- make-3.81/expand.c	2006-03-14 19:31:30.000000000 -0800
+++ gnumake-130/expand.c	2012-01-25 11:17:28.000000000 -0800
@@ -76,7 +76,11 @@
 
 /* Return a pointer to the beginning of the variable buffer.  */
 
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+char *
+#else
 static char *
+#endif
 initialize_variable_output (void)
 {
   /* If we don't have a variable output buffer yet, get one.  */
@@ -90,6 +94,35 @@
 
   return variable_buffer;
 }
+
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+char *
+save_variable_output(savelenp)
+    int *savelenp;
+{
+  char *save;
+
+  save = variable_buffer;
+  *savelenp = variable_buffer_length;
+  
+  variable_buffer = 0;
+  variable_buffer_length = 0;
+
+  return (save);
+}
+
+void
+restore_variable_output (save, savelen)
+    char *save;
+    int savelen;
+{
+  if (variable_buffer != 0)
+    free (variable_buffer);
+
+  variable_buffer = save;
+  variable_buffer_length = savelen;
+}
+#endif /* __APPLE__ || NeXT || NeXT_PDO */
 
 /* Recursively expand V.  The returned string is malloc'd.  */
 
@@ -449,20 +482,25 @@
 variable_expand_for_file (char *line, struct file *file)
 {
   char *result;
-  struct variable_set_list *save;
+  struct variable_set_list *savev;
+  const struct floc *savef;
 
   if (file == 0)
     return variable_expand (line);
 
-  save = current_variable_set_list;
+  savev = current_variable_set_list;
   current_variable_set_list = file->variables;
+
+  savef = reading_file;
   if (file->cmds && file->cmds->fileinfo.filenm)
     reading_file = &file->cmds->fileinfo;
   else
     reading_file = 0;
+
   result = variable_expand (line);
-  current_variable_set_list = save;
-  reading_file = 0;
+
+  current_variable_set_list = savev;
+  reading_file = savef;
 
   return result;
 }
diff -ru make-3.81/file.c gnumake-130/file.c
--- make-3.81/file.c	2006-03-17 06:24:20.000000000 -0800
+++ gnumake-130/file.c	2011-12-22 12:02:13.000000000 -0800
@@ -207,6 +207,9 @@
   rehash_file (from_file, to_hname);
   while (from_file)
     {
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+      from_file->old_name = from_file->name;
+#endif  /* __APPLE__ || NeXT || NeXT_PDO */
       from_file->name = from_file->hname;
       from_file = from_file->prev;
     }
@@ -734,6 +737,14 @@
 	    f2->command_flags |= COMMANDS_SILENT;
     }
 
+  f = lookup_file (".POSIX");
+  if (f != 0 && f->is_target) {
+    posix_pedantic = 1;
+#ifndef VMS
+    define_variable("ARFLAGS", 7, "-rv", o_default, 1);
+#endif
+  }
+
   f = lookup_file (".NOTPARALLEL");
   if (f != 0 && f->is_target)
     not_parallel = 1;
diff -ru make-3.81/filedef.h gnumake-130/filedef.h
--- make-3.81/filedef.h	2006-02-11 14:16:04.000000000 -0800
+++ gnumake-130/filedef.h	2011-12-22 12:02:13.000000000 -0800
@@ -42,6 +42,10 @@
 				   entries for the same file.  */
     struct file *last;          /* Last entry for the same file name.  */
 
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+    char *old_name;
+#endif
+
     /* File that this file was renamed to.  After any time that a
        file could be renamed, call `check_renamed' (below).  */
     struct file *renamed;
Only in gnumake-130: gnumake.plist
Only in gnumake-130: gnumake.xcodeproj
diff -ru make-3.81/implicit.c gnumake-130/implicit.c
--- make-3.81/implicit.c	2006-03-31 22:36:40.000000000 -0800
+++ gnumake-130/implicit.c	2011-12-22 12:02:13.000000000 -0800
@@ -696,7 +696,7 @@
                  so it might actually exist.  */
 
               /* @@ dep->changed check is disabled. */
-              if (((f = lookup_file (name)) != 0 && f->is_target)
+              if (((f = lookup_file (name)) != 0)
                   /*|| ((!dep->changed || check_lastslash) && */
                   || file_exists_p (name))
                 continue;
@@ -786,8 +786,24 @@
 
   /* RULE is nil if the loop went all the way
      through the list and everything failed.  */
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO) /* for NEXT_VPATH_FLAG support */
+  if (rule == 0) {
+    if ((next_flag & NEXT_VPATH_FLAG) && file->old_name != 0) {
+      char *save_name = file->name;
+      file->name = file->old_name;
+      file->old_name = 0;
+      /* bad hack: rule should be non-null so the function returns a non-zero result */
+      if (pattern_search(file, archive, depth, recursions))
+        rule = (struct rule *)1;
+      file->old_name = file->name;
+      file->name = save_name;
+    }
+    goto done;
+  }
+#else
   if (rule == 0)
     goto done;
+#endif	/* __APPLE__ || NeXT || NeXT_PDO */
 
   foundrule = i;
 
diff -ru make-3.81/job.c gnumake-130/job.c
--- make-3.81/job.c	2006-03-19 19:03:04.000000000 -0800
+++ gnumake-130/job.c	2011-12-22 12:02:13.000000000 -0800
@@ -29,6 +29,9 @@
 
 #include <string.h>
 
+#if USE_POSIX_SPAWN
+#include <spawn.h>
+#endif
 /* Default shell to use.  */
 #ifdef WINDOWS32
 #include <windows.h>
@@ -971,6 +974,8 @@
 #endif
   register char *p;
   int flags;
+  int already_set_status = 0;
+  char *saved_cmd_ptr = NULL;
 #ifdef VMS
   char *argv;
 #else
@@ -986,8 +991,10 @@
   flags = (child->file->command_flags
 	   | child->file->cmds->lines_flags[child->command_line - 1]);
 
-  p = child->command_ptr;
-  child->noerror = ((flags & COMMANDS_NOERROR) != 0);
+  saved_cmd_ptr = p = child->command_ptr;
+  /* noerror is a single bit, so unless COMMANDS_NOERROR has the low bit set,
+    the ?1:0 isn't redundant */
+  child->noerror = (flags & COMMANDS_NOERROR) ? 1 : 0;
 
   while (*p != '\0')
     {
@@ -1032,7 +1039,8 @@
   /* If -q was given, say that updating `failed' if there was any text on the
      command line, or `succeeded' otherwise.  The exit status of 1 tells the
      user that -q is saying `something to do'; the exit status for a random
-     error is 2.  */
+     error is 2.  NOTE: in posix_pedantic mode we continue to look at commands,
+     without posix_pedantic we cna short curcuit */
   if (argv != 0 && question_flag && !(flags & COMMANDS_RECURSE))
     {
 #ifndef VMS
@@ -1040,23 +1048,45 @@
       free ((char *) argv);
 #endif
       child->file->update_status = 1;
-      notice_finished_file (child->file);
-      return;
+      already_set_status = 1;
+      if (!posix_pedantic) {
+	  notice_finished_file (child->file);
+	  return;
+      } else {
+	  argv = 0;
+      }
     }
 
-  if (touch_flag && !(flags & COMMANDS_RECURSE))
-    {
-      /* Go on to the next command.  It might be the recursive one.
-	 We construct ARGV only to find the end of the command line.  */
+  if (argv && touch_flag) {
+      if (!(flags & COMMANDS_RECURSE)) {
+	  /* Go on to the next command.  It might be the recursive one.
+	     We construct ARGV only to find the end of the command line.  */
 #ifndef VMS
-      if (argv)
-        {
-          free (argv[0]);
-          free ((char *) argv);
-        }
+	    if (argv) {
+		free (argv[0]);
+		free ((char *) argv);
+	    }
 #endif
-      argv = 0;
+	    argv = 0;
+    } else {
+	/* insert a non-recursave version of the current command next on
+	  the command list so that all the proper non-recursave stuff
+	  happens.  This fixes a signifigant bug where if all the commands
+	  for a given target were recursave "make -t" would not touch the
+	  target!
+	*/
+	struct child *nk = malloc(sizeof(struct child));
+	*nk = *child;
+	char *cp = saved_cmd_ptr;
+	while(*cp == '-' || *cp == '+' || *cp == '@') {
+	    fprintf(stderr, "cp %p %c\n", cp, *cp);
+	    cp++;
+	}
+	nk->command_ptr = cp;
+	child->next = nk;
+	nk->file->cmds->lines_flags[nk->command_line - 1] &= ~COMMANDS_RECURSE;
     }
+  }
 
   if (argv == 0)
     {
@@ -1072,7 +1102,9 @@
 	  /* No more commands.  Make sure we're "running"; we might not be if
              (e.g.) all commands were skipped due to -n.  */
           set_command_state (child->file, cs_running);
-	  child->file->update_status = 0;
+	  if (!already_set_status) {
+	      child->file->update_status = 0;
+	  }
 	  notice_finished_file (child->file);
 	}
       return;
@@ -1107,8 +1139,16 @@
 #else
       (argv[0] && !strcmp (argv[0], "/bin/sh"))
 #endif
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+      /* allow either -ec or -c */
+      && ((argv[1]
+	   && argv[1][0] == '-' && argv[1][1] == 'c' && argv[1][2] == '\0') ||
+          (argv[1]
+	   && argv[1][0] == '-' && argv[1][1] == 'e' && argv[1][2] == 'c' && argv[1][3] == '\0'))
+#else
       && (argv[1]
           && argv[1][0] == '-' && argv[1][1] == 'c' && argv[1][2] == '\0')
+#endif __APPLE__ || NeXT || NeXT_PDO
       && (argv[2] && argv[2][0] == ':' && argv[2][1] == '\0')
       && argv[3] == NULL)
     {
@@ -1258,6 +1298,42 @@
 
 #else  /* !__EMX__ */
 
+#if USE_POSIX_SPAWN
+      posix_spawn_file_actions_t file_actions;
+      posix_spawnattr_t attr;
+      sigset_t nosigs, allsigs;
+      int rc;
+      struct stat stat;
+      short spawn_flags = 0;
+
+      posix_spawn_file_actions_init(&file_actions);
+      if (!(flags & COMMANDS_RECURSE)) {
+	if (job_fds[0] >= 0 && fstat(job_fds[0], &stat)) 
+	  posix_spawn_file_actions_addclose(&file_actions, job_fds[0]);
+	if (job_fds[1] >= 0 && fstat(job_fds[1], &stat))
+	  posix_spawn_file_actions_addclose(&file_actions, job_fds[1]);
+      }
+      if (job_rfd >= 0 && fstat(job_rfd, &stat))
+	posix_spawn_file_actions_addclose(&file_actions, job_rfd);
+      if (!child->good_stdin && fstat(bad_stdin, &stat))
+	posix_spawn_file_actions_adddup2(&file_actions, bad_stdin, 0);
+      posix_spawnattr_init(&attr);
+      sigemptyset(&nosigs);
+      sigfillset(&allsigs);
+      posix_spawnattr_setsigmask(&attr, &nosigs);
+      posix_spawnattr_setsigdefault(&attr, &allsigs);
+      posix_spawnattr_getflags(&attr, &spawn_flags);
+      spawn_flags |= POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK;
+      posix_spawnattr_setflags(&attr, spawn_flags);
+      rc = posix_spawnp(&child->pid, argv[0], &file_actions, &attr, argv, child->environment);
+      environ = parent_environ;
+      posix_spawnattr_destroy(&attr);
+      posix_spawn_file_actions_destroy(&file_actions);
+      if (rc) {
+	error (NILF, _("%s: %s"), argv[0], strerror(rc));
+	rc = posix_spawnp(&child->pid, "/usr/bin/false", NULL, NULL, NULL, NULL);
+      }
+#else  /* !USE_POSIX_SPAWN */
       child->pid = vfork ();
       environ = parent_environ;	/* Restore value child may have clobbered.  */
       if (child->pid == 0)
@@ -1285,6 +1361,7 @@
 	  perror_with_name ("vfork", "");
 	  goto error;
 	}
+#  endif /* !USE_POSIX_SPAWN */
 # endif  /* !__EMX__ */
 #endif /* !VMS */
     }
@@ -1601,6 +1678,19 @@
 						     file);
     }
 
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO) /* for NEXT_VPATH_FLAG support */
+  if (next_flag & NEXT_VPATH_FLAG) {
+      for (i = 0; i < cmds->ncommand_lines; ++i) {
+	  char *line;
+	  if (lines[i] != 0) {
+	      line = allocated_vpath_expand_for_file (lines[i], file);
+	      free (lines[i]);
+	      lines[i] = line;
+	  }
+      }
+  }
+#endif	/* __APPLE__ || NeXT || NeXT_PDO */
+
   /* Start the command sequence, record it in a new
      `struct child', and add that to the chain.  */
 
@@ -2423,23 +2513,7 @@
 	    }
 	  else if (*p == '\\' && p[1] == '\n')
             {
-              /* Backslash-newline is handled differently depending on what
-                 kind of string we're in: inside single-quoted strings you
-                 keep them; in double-quoted strings they disappear.
-	         For DOS/Windows/OS2, if we don't have a POSIX shell,
-		 we keep the pre-POSIX behavior of removing the
-		 backslash-newline.  */
-              if (instring == '"'
-#if defined (__MSDOS__) || defined (__EMX__) || defined (WINDOWS32)
-		  || !unixy_shell
-#endif
-		  )
                 ++p;
-              else
-                {
-                  *(ap++) = *(p++);
-                  *(ap++) = *p;
-                }
               /* If there's a TAB here, skip it.  */
               if (p[1] == '\t')
                 ++p;
@@ -2690,15 +2764,33 @@
        argument list.  */
 
     unsigned int shell_len = strlen (shell);
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+    char *minus_c;
+    int minus_c_len;
+
+    if (next_flag & NEXT_ERREXIT_FLAG) {
+      minus_c = " -ec ";
+      minus_c_len = 5;
+    } else {
+      minus_c = " -c ";
+      minus_c_len = 4;
+    }
+#else
 #ifndef VMS
     static char minus_c[] = " -c ";
 #else
     static char minus_c[] = "";
 #endif
+#endif /* __APPLE__ || NeXT || NeXT_PDO */
     unsigned int line_len = strlen (line);
 
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+    char *new_line = (char *) alloca (shell_len + minus_c_len
+				      + (line_len * 2) + 1);
+#else
     char *new_line = (char *) alloca (shell_len + (sizeof (minus_c) - 1)
 				      + (line_len * 2) + 1);
+#endif /* __APPLE__ || NeXT || NeXT_PDO */
     char *command_ptr = NULL; /* used for batch_mode_shell mode */
 
 # ifdef __EMX__ /* is this necessary? */
@@ -2709,8 +2801,13 @@
     ap = new_line;
     bcopy (shell, ap, shell_len);
     ap += shell_len;
+#ifdef __APPLE__
+    bcopy (minus_c, ap, minus_c_len);
+    ap += minus_c_len;
+#else /* !__APPLE__ */
     bcopy (minus_c, ap, sizeof (minus_c) - 1);
     ap += sizeof (minus_c) - 1;
+#endif /* __APPLE__ */
     command_ptr = ap;
     for (p = line; *p != '\0'; ++p)
       {
@@ -2721,22 +2818,6 @@
 	  }
 	else if (*p == '\\' && p[1] == '\n')
 	  {
-	    /* POSIX says we keep the backslash-newline, but throw out
-               the next char if it's a TAB.  If we don't have a POSIX
-               shell on DOS/Windows/OS2, mimic the pre-POSIX behavior
-               and remove the backslash/newline.  */
-#if defined (__MSDOS__) || defined (__EMX__) || defined (WINDOWS32)
-# define PRESERVE_BSNL  unixy_shell
-#else
-# define PRESERVE_BSNL  1
-#endif
-	    if (PRESERVE_BSNL)
-	      {
-		*(ap++) = '\\';
-		*(ap++) = '\\';
-		*(ap++) = '\n';
-	      }
-
 	    ++p;
 	    if (p[1] == '\t')
 	      ++p;
@@ -2761,7 +2842,7 @@
 #endif
 	*ap++ = *p;
       }
-    if (ap == new_line + shell_len + sizeof (minus_c) - 1)
+    if (ap == new_line + shell_len + minus_c_len)
       /* Line was empty.  */
       return 0;
     *ap = '\0';
diff -ru make-3.81/main.c gnumake-130/main.c
--- make-3.81/main.c	2006-03-19 18:36:37.000000000 -0800
+++ gnumake-130/main.c	2011-12-22 12:02:13.000000000 -0800
@@ -90,6 +90,27 @@
 static char *quote_for_env PARAMS ((char *out, char *in));
 static void initialize_global_hash_tables PARAMS ((void));
 
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+/*
+ * The various Apple, NeXT, and NeXT PDO hacks are no longer enabled by
+ * default, so that default behaves matches GNU make.
+ *
+ * The hacks can be enabled selectively enabling the following options.
+ * They can be enabled by setting the variable USE_APPLE_PB_SUPPORT to one
+ * or more of the options, or by specify "-N <option>" on the command line.
+ *
+ *	all		Turn on all NeXT features.
+ *
+ *	makefiles	DON'T remake Makefiles
+ *
+ *	quiet		Be quiet: warn about using vpath compatibility
+ *			mode or missing targets or overriding implicit rules.
+ *
+ *	vpath		Use the System V vpath compatibility mode.
+ *
+ *	errexit		Use "sh -ec" (instead of "sh -c") to execute rules.
+ */
+#endif
 
 /* The structure that describes an accepted command switch.  */
 
@@ -192,6 +213,10 @@
 int keep_going_flag;
 int default_keep_going_flag = 0;
 
+/* we are required to track these so we can show them in MAKEFLAGS rather
+ then merely showing the current state */
+int seen_k_switch = 0, seen_S_switch = 0;
+
 /* Nonzero means check symlink mtimes.  */
 
 int check_symlink_flag = 0;
@@ -213,6 +238,13 @@
 
 static struct stringlist *makefiles = 0;
 
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+/* Apple's hacks are OFF by default, and are enabled by putting the
+   "use-apple-pbhacks-*" directives in the pb_makefiles. */
+unsigned int next_flag = 0;
+static struct stringlist *next_flag_list = 0;
+#endif
+
 /* Number of job slots (commands that can be run at once).  */
 
 unsigned int job_slots = 1;
@@ -354,6 +386,11 @@
                               Consider FILE to be infinitely new.\n"),
     N_("\
   --warn-undefined-variables  Warn when an undefined variable is referenced.\n"),
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+    N_("\
+  -N OPTION, --NeXT-option=OPTION\n\
+                              Turn on value of NeXT OPTION.\n"),
+#endif /* __APPLE__ || NeXT || NeXT_PDO */
     NULL
   };
 
@@ -416,6 +453,9 @@
     { 'W', string, (char *) &new_files, 0, 0, 0, 0, 0, "what-if" },
     { CHAR_MAX+4, flag, (char *) &warn_undefined_variables_flag, 1, 1, 0, 0, 0,
       "warn-undefined-variables" },
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+    { 'N', string, (char *) &next_flag_list, 0, 0, 0, 0, 0, "NeXT-option" },
+#endif /* __APPLE__ || NeXT || NeXT_PDO */
     { 0, 0, 0, 0, 0, 0, 0, 0, 0 }
   };
 
@@ -885,6 +925,36 @@
 #endif
 }
 
+#ifdef __APPLE__
+static void
+define_makefilepath_variable(void)
+{
+	uint32_t bufsize;
+	char buf[PATH_MAX], path[PATH_MAX];
+	char *p;
+	struct stat sb;
+
+	/* For $ANY_DIR/usr/bin/make, try $ANY_DIR/Makefiles */
+	bufsize = sizeof(buf);
+	if (_NSGetExecutablePath(buf, &bufsize) == 0 && realpath(buf, path) != NULL) {
+		p = strstr(path, "/usr/bin/gnumake");
+		if (p == NULL) {
+			p = strstr(path, "/usr/bin/make");
+		}
+
+		if (p != NULL && p != path) {
+			strcpy(p, "/Makefiles");
+			if (lstat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) {
+				define_variable("MAKEFILEPATH", 12, path, o_default, 0);
+				return;
+			}
+		}
+	}
+
+	/* Fallback is $DEVELOPER_DIR/Makefiles */
+	define_variable("MAKEFILEPATH", 12, "$(shell /usr/bin/xcode-select -print-path 2>/dev/null || echo /Developer)/Makefiles", o_default, 1);
+}
+#endif /* __APPLE__ */
 
 #ifdef _AMIGA
 int
@@ -1230,6 +1300,27 @@
   decode_env_switches (STRING_SIZE_TUPLE ("MFLAGS"));
 #endif
   decode_switches (argc, argv, 0);
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+  if (next_flag_list != 0) {
+        char **p;
+      next_flag = 0;
+      for (p = next_flag_list->list; *p != 0; p++) {
+	  if (strcmp(*p, "vpath") == 0) {
+	      next_flag |= NEXT_VPATH_FLAG;
+	  } else if (strcmp(*p, "quiet") == 0) {
+	      next_flag |= NEXT_QUIET_FLAG;
+	  } else if (strcmp(*p, "makefiles") == 0) {
+	      next_flag |= NEXT_MAKEFILES_FLAG;
+	  } else if (strcmp(*p, "errexit") == 0) {
+	      next_flag |= NEXT_ERREXIT_FLAG;
+	  } else if (strcmp(*p, "all") == 0) {
+	      next_flag = NEXT_ALL_FLAGS;
+	  } else {
+	      error (NILF, "Unrecognized flag `%s'.", *p);
+	  }
+      }
+  }
+#endif	/* __APPLE__ || NeXT || NeXT_PDO */
 #ifdef WINDOWS32
   if (suspend_flag) {
         fprintf(stderr, "%s (pid = %ld)\n", argv[0], GetCurrentProcessId());
@@ -1406,9 +1497,11 @@
       makelevel = 0;
   }
 
+#if !(defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO))
   /* Except under -s, always do -w in sub-makes and under -C.  */
   if (!silent_flag && (directories != 0 || makelevel > 0))
     print_directory_flag = 1;
+#endif
 
   /* Let the user disable that with --no-print-directory.  */
   if (inhibit_print_directory_flag)
@@ -1590,6 +1683,10 @@
     default_goal_name = &v->value;
   }
 
+#ifdef __APPLE__
+  define_makefilepath_variable ();
+#endif /* __APPLE__ */
+
   /* Read all the makefiles.  */
 
   read_makefiles
@@ -1804,6 +1901,9 @@
   remote_setup ();
 
   if (read_makefiles != 0)
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+      if (!(next_flag & NEXT_MAKEFILES_FLAG))
+#endif
     {
       /* Update any makefiles if necessary.  */
 
@@ -2075,8 +2175,10 @@
 	  fflush (stderr);
 
           /* Close the dup'd jobserver pipe if we opened one.  */
-          if (job_rfd >= 0)
+          if (job_rfd >= 0) {
             close (job_rfd);
+	    job_rfd = -1;
+	  }
 
 #ifdef _AMIGA
 	  exec_command (nargv);
@@ -2221,6 +2323,11 @@
       error (NILF,
              _("warning:  Clock skew detected.  Your build may be incomplete."));
 
+    /* Without this a make -q on a target containing all +'ed actions
+      returns MAKE_SUCCESS */
+    if (question_flag && commands_started && status == MAKE_SUCCESS) {
+	status = MAKE_TROUBLE;
+    }
     /* Exit.  */
     die (status);
   }
@@ -2441,6 +2548,12 @@
 		 options which are to be ignored still consume args.  */
 	      int doit = !env || cs->env;
 
+	      if (c == 'k') {
+		  seen_k_switch = 1;
+	      } else if (c == 'S') {
+		  seen_S_switch = 1;
+	      }
+
 	      switch (cs->type)
 		{
 		default:
@@ -2697,6 +2810,15 @@
       flagslen += 2 + strlen (cs->long_name);				      \
   } while (0)
 
+#define ADD_SWITCH(CH, ARG,LEN) { \
+    const struct command_switch *cs;  \
+    for(cs = switches; cs->c != '\0'; ++cs) {  \
+	if (cs->c == CH) {  \
+	    ADD_FLAG(ARG, LEN); \
+	}  \
+    } \
+}
+
   for (cs = switches; cs->c != '\0'; ++cs)
     if (cs->toenv && (!makefile || !cs->no_makefile))
       switch (cs->type)
@@ -2777,6 +2899,13 @@
 	  break;
 	}
 
+  if (seen_S_switch) {
+      ADD_SWITCH('S', 0, 0);
+      if (seen_k_switch && !keep_going_flag) {
+	  ADD_SWITCH('k', 0, 0);
+      }
+  }
+
   flagslen += 4 + sizeof posixref; /* Four more for the possible " -- ".  */
 
 #undef	ADD_FLAG
@@ -2909,7 +3038,7 @@
 			  to redefine its value with the full set of
 			  switches.  Of course, an override or command
 			  definition will still take precedence.  */
-		       o_file, 1);
+		       posix_pedantic ? o_env : o_file, 1);
   if (! all)
     /* The first time we are called, set MAKEFLAGS to always be exported.
        We should not do this again on the second call, because that is
@@ -3015,7 +3144,7 @@
 
       /* Close the write side, so the read() won't hang.  */
       close (job_fds[1]);
-
+      job_fds[1] = -1;
       while (read (job_fds[0], &token, 1) == 1)
         ++tcnt;
 
@@ -3025,6 +3154,7 @@
                tcnt, master_job_slots);
 
       close (job_fds[0]);
+      job_fds[0] = -1;
     }
 }
 
diff -ru make-3.81/make.h gnumake-130/make.h
--- make-3.81/make.h	2006-02-15 15:54:43.000000000 -0800
+++ gnumake-130/make.h	2011-12-22 12:02:13.000000000 -0800
@@ -508,6 +508,21 @@
 extern int warn_undefined_variables_flag, posix_pedantic, not_parallel;
 extern int second_expansion, clock_skew_detected, rebuilding_makefiles;
 
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+extern unsigned int next_flag;
+#define NEXT_VPATH_FLAG			(1 << 0)
+#define NEXT_QUIET_FLAG			(1 << 1)
+#define NEXT_MAKEFILES_FLAG		(1 << 2)
+#define NEXT_ERREXIT_FLAG		(1 << 3)
+#define NEXT_ALL_FLAGS			(NEXT_VPATH_FLAG | 	\
+					 NEXT_QUIET_FLAG | 	\
+					 NEXT_MAKEFILES_FLAG |	\
+					 NEXT_ERREXIT_FLAG)
+
+extern int general_vpath_search();
+extern char *allocated_vpath_expand_for_file();
+#endif	/* __APPLE__ || NeXT || NeXT_PDO */
+
 /* can we run commands via 'sh -c xxx' or must we use batch files? */
 extern int batch_mode_shell;
 
Only in gnumake-130: next.c
Only in gnumake-130: patches
Only in make-3.81/po: en@boldquot.header
Only in make-3.81/po: en@quot.header
diff -ru make-3.81/read.c gnumake-130/read.c
--- make-3.81/read.c	2006-03-17 06:24:20.000000000 -0800
+++ gnumake-130/read.c	2011-12-22 12:02:13.000000000 -0800
@@ -1821,7 +1821,7 @@
           current_variable_set_list = f->variables;
           v = try_variable_definition (flocp, defn, origin, 1);
           if (!v)
-            error (flocp, _("Malformed target-specific variable definition"));
+            fatal (flocp, _("Malformed target-specific variable definition"));
           current_variable_set_list = global;
         }
 
@@ -1972,6 +1972,9 @@
 	    fatal (flocp,
                    _("target file `%s' has both : and :: entries"), f->name);
 
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+          if (!(next_flag & NEXT_QUIET_FLAG)) {
+#endif
 	  /* If CMDS == F->CMDS, this target was listed in this rule
 	     more than once.  Just give a warning since this is harmless.  */
 	  if (cmds != 0 && cmds == f->cmds)
@@ -1991,6 +1994,9 @@
                      _("warning: ignoring old commands for target `%s'"),
                      f->name);
 	    }
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+	      }
+#endif
 
 	  f->is_target = 1;
 
diff -ru make-3.81/remake.c gnumake-130/remake.c
--- make-3.81/remake.c	2006-03-19 18:36:37.000000000 -0800
+++ gnumake-130/remake.c	2011-12-22 12:02:13.000000000 -0800
@@ -223,6 +223,9 @@
 		     or not at all.  G->changed will have been set above if
 		     any commands were actually started for this goal.  */
 		  && file->update_status == 0 && !g->changed
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+		  && !(next_flag & NEXT_QUIET_FLAG)
+#endif
 		  /* Never give a message under -s or -q.  */
 		  && !silent_flag && !question_flag)
 		message (1, ((file->phony || file->cmds == 0)
@@ -481,6 +484,9 @@
 
       if (is_updating (d->file))
 	{
+#if __APPLE__ || NeXT || NeXT_PDO
+         if (!(next_flag & NEXT_QUIET_FLAG))
+#endif
 	  error (NILF, _("Circular %s <- %s dependency dropped."),
 		 file->name, d->file->name);
 	  /* We cannot free D here because our the caller will still have
@@ -740,6 +746,9 @@
 
       while (file)
         {
+#if __APPLE__ || NeXT || NeXT_PDO
+          file->old_name = file->name;
+#endif	/* __APPLE__ || NeXT || NeXT_PDO */
           file->name = file->hname;
           file = file->prev;
         }
@@ -993,6 +1002,9 @@
 
 	      if (is_updating (d->file))
 		{
+#if __APPLE__ || NeXT || NeXT_PDO
+		  if (!(next_flag & NEXT_QUIET_FLAG))
+#endif
 		  error (NILF, _("Circular %s <- %s dependency dropped."),
 			 file->name, d->file->name);
 		  if (lastd == 0)
@@ -1106,12 +1118,23 @@
 	   Pretend it was successfully remade.  */
 	file->update_status = 0;
       else
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+      {
+	char *name = file->name;
+	if ((next_flag & NEXT_VPATH_FLAG) && general_vpath_search(&name)) {
+	  free(name);
+	  file->update_status = 0;
+	} else
+#endif /* defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO) */
         {
           /* This is a dependency file we cannot remake.  Fail.  */
           if (!rebuilding_makefiles || !file->dontcare)
             complain (file);
           file->update_status = 2;
         }
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+      }
+#endif
     }
   else
     {
diff -ru make-3.81/variable.c gnumake-130/variable.c
--- make-3.81/variable.c	2006-03-08 12:15:08.000000000 -0800
+++ gnumake-130/variable.c	2011-12-22 12:02:13.000000000 -0800
@@ -144,6 +144,41 @@
 
 /* Implement variables.  */
 
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+static void check_apple_pb_support (name, length, value)
+     const char *name;
+     unsigned int length;
+     char *value;
+{
+  char *p;
+
+  if (length == 20 && !strncmp (name, "USE_APPLE_PB_SUPPORT", length)) {
+    //if (makelevel == 0) error(NILF, "USE_APPLE_PB_SUPPORT is deprecated");
+    for (p = value; *p != '\0'; p++) {
+      if (isspace (*p)) {
+	continue;
+      }
+      if (!strncmp (p, "all", 3)) {
+	p += 3;
+	next_flag |= NEXT_ALL_FLAGS;
+      } else if (!strncmp (p, "vpath", 5)) {
+	p += 5;
+	next_flag |= NEXT_VPATH_FLAG;
+      } else if (!strncmp (p, "quiet", 5)) {
+	p += 5;
+	next_flag |= NEXT_QUIET_FLAG;
+      } else if (!strncmp (p, "makefiles", 9)) {
+	p += 9;
+	next_flag |= NEXT_MAKEFILES_FLAG;
+      } else if (!strncmp (p, "errexit", 7)) {
+	p += 7;
+	next_flag |= NEXT_ERREXIT_FLAG;
+      }
+    }
+  }
+}
+#endif /* __APPLE__ || NeXT || NeXT_PDO */
+
 void
 init_hash_global_variable_set (void)
 {
@@ -168,6 +203,10 @@
   struct variable **var_slot;
   struct variable var_key;
 
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+  check_apple_pb_support (name, length, value);
+#endif /* __APPLE__ || NeXT || NeXT_PDO */
+
   if (set == NULL)
     set = &global_variable_set;
 
diff -ru make-3.81/variable.h gnumake-130/variable.h
--- make-3.81/variable.h	2006-02-14 07:42:18.000000000 -0800
+++ gnumake-130/variable.h	2011-12-22 12:02:13.000000000 -0800
@@ -110,6 +110,13 @@
 
 /* expand.c */
 extern char *variable_buffer_output PARAMS ((char *ptr, char *string, unsigned int length));
+
+#if defined(__APPLE__) || defined(NeXT) || defined(NeXT_PDO)
+extern char *initialize_variable_output PARAMS ((void));
+extern char *save_variable_output PARAMS ((int *savelenp));
+extern void restore_variable_output PARAMS ((char *save, int savelen));
+#endif /* __APPLE__ || NeXT || NeXT_PDO */
+
 extern char *variable_expand PARAMS ((char *line));
 extern char *variable_expand_for_file PARAMS ((char *line, struct file *file));
 extern char *allocated_variable_expand_for_file PARAMS ((char *line, struct file *file));
Only in gnumake-130: xcodescripts
