? tests/test-file
? tests/scripts/features/verbatim
Index: debug.h
===================================================================
RCS file: /sources/make/make/debug.h,v
retrieving revision 1.5
diff -p -u -r1.5 debug.h
--- debug.h	4 Jul 2007 19:35:17 -0000	1.5
+++ debug.h	2 Sep 2007 15:44:34 -0000
@@ -20,6 +20,7 @@ this program.  If not, see <http://www.g
 #define DB_VERBOSE      (0x002)
 #define DB_JOBS         (0x004)
 #define DB_IMPLICIT     (0x008)
+#define DB_PARSER       (0x010)
 #define DB_MAKEFILES    (0x100)
 
 #define DB_ALL          (0xfff)
Index: main.c
===================================================================
RCS file: /sources/make/make/main.c,v
retrieving revision 1.226
diff -p -u -r1.226 main.c
--- main.c	4 Jul 2007 19:35:19 -0000	1.226
+++ main.c	2 Sep 2007 15:44:35 -0000
@@ -635,6 +635,9 @@ decode_debug_flags (void)
             case 'm':
               db_level |= DB_BASIC | DB_MAKEFILES;
               break;
+            case 'p':
+              db_level |= DB_PARSER;
+              break;
             case 'v':
               db_level |= DB_BASIC | DB_VERBOSE;
               break;
Index: read.c
===================================================================
RCS file: /sources/make/make/read.c,v
retrieving revision 1.167
diff -p -u -r1.167 read.c
--- read.c	4 Jul 2007 19:35:19 -0000	1.167
+++ read.c	2 Sep 2007 15:44:35 -0000
@@ -502,6 +502,7 @@ eval (struct ebuffer *ebuf, int set_defa
       unsigned int wlen;
       char *p;
       char *p2;
+      struct variable *vardef;
 
       /* Grab the next line to be evaluated */
       ebuf->floc.lineno += nlines;
@@ -517,12 +518,17 @@ eval (struct ebuffer *ebuf, int set_defa
         continue;
 
       linelen = strlen (line);
+      DB (DB_PARSER, (ignoring ? _("Ignore line:\n'%s'\n") 
+                               : _("Parse line:\n'%s'\n"), line));
 
       /* Check for a shell command line first.
 	 If it is not one, we can stop treating tab specially.  */
       if (line[0] == cmd_prefix)
 	{
-	  if (no_targets)
+          DB (DB_PARSER, (_("Shell command line %s"), 
+            (no_targets || !filenames) ? _("for no targets.\n")
+                                       : _("for targets: ")));
+          if (no_targets)
 	    /* Ignore the commands in a rule with no targets.  */
 	    continue;
 
@@ -533,8 +539,22 @@ eval (struct ebuffer *ebuf, int set_defa
 	  if (filenames != 0)
 	    {
 	      if (ignoring)
-		/* Yep, this is a shell command, and we don't care.  */
-		continue;
+		{
+                  DB (DB_PARSER, (_("(ignored)\n")));
+		  /* Yep, this is a shell command, and we don't care.  */
+		  continue;
+		}
+
+	      if (ISDB (DB_PARSER) && !no_targets)
+		{
+		  struct nameseq *cur = filenames;
+		  while (cur)
+		    {
+		      printf ("%s%s", cur->name, cur->next ? ", " : "\n");
+		      cur = cur->next;
+		    }
+		  fflush (stdout);
+		}
 
 	      /* Append this command line to the line being accumulated.  */
 	      if (commands_idx == 0)
@@ -593,6 +613,8 @@ eval (struct ebuffer *ebuf, int set_defa
       while (isspace ((unsigned char)*p2))
         ++p2;
 
+      DB (DB_PARSER, (_("First token: '%*.*s', second token: '%s'\n"), 
+        wlen, wlen, p, p2));
       if ((p2[0] == ':' || p2[0] == '+' || p2[0] == '=') && p2[1] == '\0')
         {
           /* It can't be a preprocessor token so skip it if we're ignoring */
@@ -609,6 +631,7 @@ eval (struct ebuffer *ebuf, int set_defa
       if (!in_ignored_define)
 	{
 	  int i = conditional_line (p, wlen, fstart);
+	  DB (DB_PARSER, (_("conditional_line returns %d\n"), i));
           if (i != -2)
             {
               if (i == -1)
@@ -621,6 +644,7 @@ eval (struct ebuffer *ebuf, int set_defa
 
       if (word1eq ("endef"))
 	{
+          DB (DB_PARSER, (_("Directive: endef%s\n"), ignoring ? _("(ignored)") : ""));
 	  if (!in_ignored_define)
 	    fatal (fstart, _("extraneous `endef'"));
           in_ignored_define = 0;
@@ -629,6 +653,7 @@ eval (struct ebuffer *ebuf, int set_defa
 
       if (word1eq ("define"))
 	{
+          DB (DB_PARSER, (_("Directive: define%s\n"), ignoring ? _("(ignored)") : ""));
 	  if (ignoring)
 	    in_ignored_define = 1;
 	  else
@@ -650,6 +675,7 @@ eval (struct ebuffer *ebuf, int set_defa
 
       if (word1eq ("override"))
         {
+          DB (DB_PARSER, (_("Directive: override%s\n"), ignoring ? _("(ignored)") : ""));
 	  if (*p2 == '\0')
 	    error (fstart, _("empty `override' directive"));
 
@@ -682,12 +708,16 @@ eval (struct ebuffer *ebuf, int set_defa
 	}
 
       if (ignoring)
-	/* Ignore the line.  We continue here so conditionals
-	   can appear in the middle of a rule.  */
-	continue;
+	{
+	  /* Ignore the line.  We continue here so conditionals
+	     can appear in the middle of a rule.  */
+	  DB (DB_PARSER, (_("Line ignored.\n")));
+	  continue;
+	}
 
       if (word1eq ("export"))
 	{
+          DB (DB_PARSER, (_("Directive: export\n")));
           /* 'export' by itself causes everything to be exported. */
 	  if (*p2 == '\0')
             export_all_variables = 1;
@@ -725,6 +755,7 @@ eval (struct ebuffer *ebuf, int set_defa
 
       if (word1eq ("unexport"))
 	{
+          DB (DB_PARSER, (_("Directive: unexport\n")));
 	  if (*p2 == '\0')
 	    export_all_variables = 0;
           else
@@ -759,6 +790,7 @@ eval (struct ebuffer *ebuf, int set_defa
           const char *cp;
 	  char *vpat;
 	  unsigned int l;
+          DB (DB_PARSER, (_("Directive: vpath\n")));
 	  cp = variable_expand (p2);
 	  p = find_next_token (&cp, &l);
 	  if (p != 0)
@@ -789,6 +821,7 @@ eval (struct ebuffer *ebuf, int set_defa
 	     exist.  "sinclude" is an alias for this from SGI.  */
 	  int noerror = (p[0] != 'i');
 
+          DB (DB_PARSER, (_("Directive: include\n")));
 	  p = allocated_variable_expand (p2);
 
           /* If no filenames, it's a no-op.  */
@@ -824,6 +857,7 @@ eval (struct ebuffer *ebuf, int set_defa
 	      free (files);
 	      files = next;
 
+              DB (DB_PARSER, (_("Including file '%s'...\n"), name));
               r = eval_makefile (name, (RM_INCLUDED | RM_NO_TILDE
                                         | (noerror ? RM_DONTCARE : 0)));
 	      if (!r && !noerror)
@@ -836,9 +870,13 @@ eval (struct ebuffer *ebuf, int set_defa
           goto rule_complete;
 	}
 
-      if (try_variable_definition (fstart, p, o_file, 0))
-	/* This line has been dealt with.  */
-	goto rule_complete;
+      if ((vardef = try_variable_definition (fstart, p, o_file, 0)))
+	{
+	  DB (DB_PARSER, (_("Define variable: '%s'='%s'\n"), 
+	    vardef->name, vardef->value));
+	  /* This line has been dealt with.  */
+	  goto rule_complete;
+	}
 
       /* This line starts with a tab but was not caught above because there
          was no preceding target, and the line might have been usable as a
@@ -865,6 +903,8 @@ eval (struct ebuffer *ebuf, int set_defa
         char *colonp;
         const char *end, *beg; /* Helpers for whitespace stripping. */
 
+        DB (DB_PARSER, (_("Line describes target files.\n")));
+
         /* Record the previous rule.  */
 
         record_waiting_files ();
@@ -980,11 +1020,14 @@ eval (struct ebuffer *ebuf, int set_defa
         if (wtype == w_eol)
           {
             if (*p2 != '\0')
-              /* There's no need to be ivory-tower about this: check for
-                 one of the most common bugs found in makefiles...  */
-              fatal (fstart, _("missing separator%s"),
+              {
+                /* There's no need to be ivory-tower about this: check for
+                   one of the most common bugs found in makefiles...  */
+                DB (DB_PARSER, (_("At '%s' in line\n'%s'\n"), p2, line));
+                fatal (fstart, _("missing separator%s"),
                      !strneq(line, "        ", 8) ? ""
                      : _(" (did you mean TAB instead of 8 spaces?)"));
+              }
             continue;
           }
 
Index: doc/make.texi
===================================================================
RCS file: /sources/make/make/doc/make.texi,v
retrieving revision 1.50
diff -p -u -r1.50 make.texi
--- doc/make.texi	15 Aug 2007 13:53:54 -0000	1.50
+++ doc/make.texi	2 Sep 2007 15:44:38 -0000
@@ -7983,6 +7983,10 @@ By default, the above messages are not e
 the makefiles.  This option enables messages while rebuilding makefiles,
 too.  Note that the @samp{all} option does enable this option.  This
 option also enables @samp{basic} messages.
+
+@item p (@i{parser})
+Prints informational messages during parsing to help track down subtle
+syntax errors or problems in generated code and @code{eval} calls.
 @end table
 
 @item -e
