/[make]/make/read.c
ViewVC logotype

Diff of /make/read.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.142 by psmith, Fri Apr 8 12:51:20 2005 UTC revision 1.143 by psmith, Wed Apr 13 03:16:33 2005 UTC
# Line 253  read_all_makefiles (char **makefiles) Line 253  read_all_makefiles (char **makefiles)
253                d->file = enter_file (*p);                d->file = enter_file (*p);
254                d->file->dontcare = 1;                d->file->dontcare = 1;
255                d->ignore_mtime = 0;                d->ignore_mtime = 0;
256                  d->need_2nd_expansion = 0;
257                /* Tell update_goal_chain to bail out as soon as this file is                /* Tell update_goal_chain to bail out as soon as this file is
258                   made, and main not to die if we can't make this file.  */                   made, and main not to die if we can't make this file.  */
259                d->changed = RM_DONTCARE;                d->changed = RM_DONTCARE;
# Line 372  eval_makefile (char *filename, int flags Line 373  eval_makefile (char *filename, int flags
373    filename = deps->file->name;    filename = deps->file->name;
374    deps->changed = flags;    deps->changed = flags;
375    deps->ignore_mtime = 0;    deps->ignore_mtime = 0;
376      deps->need_2nd_expansion = 0;
377    if (flags & RM_DONTCARE)    if (flags & RM_DONTCARE)
378      deps->file->dontcare = 1;      deps->file->dontcare = 1;
379    
# Line 1167  eval (struct ebuffer *ebuf, int set_defa Line 1169  eval (struct ebuffer *ebuf, int set_defa
1169    
1170          if (beg <= end && *beg != '\0')          if (beg <= end && *beg != '\0')
1171            {            {
1172                char *top;
1173                const char *fromp = beg;
1174    
1175                /* Make a copy of the dependency string.  Note if we find '$'.  */
1176              deps = (struct dep*) xmalloc (sizeof (struct dep));              deps = (struct dep*) xmalloc (sizeof (struct dep));
1177              deps->next = 0;              deps->next = 0;
1178              deps->name = savestring (beg, end - beg + 1);              deps->name = top = (char *) xmalloc (end - beg + 2);
1179                deps->need_2nd_expansion = 0;
1180                while (fromp <= end)
1181                  {
1182                    if (*fromp == '$')
1183                      deps->need_2nd_expansion = 1;
1184                    *(top++) = *(fromp++);
1185                  }
1186                *top = '\0';
1187              deps->file = 0;              deps->file = 0;
1188            }            }
1189          else          else
# Line 1194  eval (struct ebuffer *ebuf, int set_defa Line 1208  eval (struct ebuffer *ebuf, int set_defa
1208              commands[commands_idx++] = '\n';              commands[commands_idx++] = '\n';
1209            }            }
1210    
1211          /* Determine if this target should be made default. We used          /* Determine if this target should be made default. We used to do
1212             to do this in record_files() but because of the delayed             this in record_files() but because of the delayed target recording
1213             target recording and because preprocessor directives are             and because preprocessor directives are legal in target's commands
1214             legal in target's commands it is too late. Consider this             it is too late. Consider this fragment for example:
            fragment for example:  
1215    
1216             foo:             foo:
1217    
# Line 1206  eval (struct ebuffer *ebuf, int set_defa Line 1219  eval (struct ebuffer *ebuf, int set_defa
1219                ...                ...
1220             endif             endif
1221    
1222             Because the target is not recorded until after ifeq             Because the target is not recorded until after ifeq directive is
1223             directive is evaluated the .DEFAULT_TARGET does not             evaluated the .DEFAULT_TARGET does not contain foo yet as one
1224             contain foo yet as one would expect. Because of this             would expect. Because of this we have to move some of the logic
1225             we have to move some of the logic here. */             here.  */
1226    
1227          if (**default_target_name == '\0' && set_default)          if (**default_target_name == '\0' && set_default)
1228            {            {
# Line 1232  eval (struct ebuffer *ebuf, int set_defa Line 1245  eval (struct ebuffer *ebuf, int set_defa
1245  #ifdef HAVE_DOS_PATHS  #ifdef HAVE_DOS_PATHS
1246                      && strchr (name, '\\') == 0                      && strchr (name, '\\') == 0
1247  #endif  #endif
1248                  )                      )
1249                    continue;                    continue;
1250    
1251    
# Line 1895  record_files (struct nameseq *filenames, Line 1908  record_files (struct nameseq *filenames,
1908    
1909        /* If there are multiple filenames, copy the chain DEPS        /* If there are multiple filenames, copy the chain DEPS
1910           for all but the last one.  It is not safe for the same deps           for all but the last one.  It is not safe for the same deps
1911           to go in more than one place in the data base.  */           to go in more than one place in the database.  */
1912        this = nextf != 0 ? copy_dep_chain (deps) : deps;        this = nextf != 0 ? copy_dep_chain (deps) : deps;
1913    
1914        if (pattern != 0)        if (pattern != 0)
# Line 1912  record_files (struct nameseq *filenames, Line 1925  record_files (struct nameseq *filenames,
1925                this = 0;                this = 0;
1926              }              }
1927            else            else
1928              {              /* We use subst_expand to do the work of translating % to $* in
1929                /* We use subst_expand to do the work of translating                 the dependency line.  */
                  % to $* in the dependency line.  */  
1930    
1931                if (this != 0 && find_percent (this->name) != 0)              if (this != 0 && find_percent (this->name) != 0)
1932                  {                {
1933                    char *o;                  char *o;
1934                    char *buffer = variable_expand ("");                  char *buffer = variable_expand ("");
1935    
1936                    o = subst_expand (buffer, this->name, "%", "$*",                  o = subst_expand (buffer, this->name, "%", "$*", 1, 2, 0);
                                     1, 2, 0);  
1937    
1938                    free (this->name);                  free (this->name);
1939                    this->name = savestring (buffer, o - buffer);                  this->name = savestring (buffer, o - buffer);
1940                  }                  this->need_2nd_expansion = 1;
1941              }                }
1942          }          }
1943    
1944        if (!two_colon)        if (!two_colon)
# Line 2009  record_files (struct nameseq *filenames, Line 2020  record_files (struct nameseq *filenames,
2020                        /* This is the rule without commands. Put its                        /* This is the rule without commands. Put its
2021                           dependencies at the end but before dependencies                           dependencies at the end but before dependencies
2022                           from the rule with commands (if any). This way                           from the rule with commands (if any). This way
2023                           everyhting appears in makefile order.  */                           everything appears in makefile order.  */
2024    
2025                        if (f->cmds != 0)                        if (f->cmds != 0)
2026                          {                          {
# Line 2026  record_files (struct nameseq *filenames, Line 2037  record_files (struct nameseq *filenames,
2037                /* This is a hack. I need a way to communicate to snap_deps()                /* This is a hack. I need a way to communicate to snap_deps()
2038                   that the last dependency line in this file came with commands                   that the last dependency line in this file came with commands
2039                   (so that logic in snap_deps() can put it in front and all                   (so that logic in snap_deps() can put it in front and all
2040                   this $< -logic works). I cannot's simply rely oon file->cmds                   this $< -logic works). I cannot simply rely on file->cmds
2041                   being not 0 because of the cases like the following:                   being not 0 because of the cases like the following:
2042    
2043                   foo: bar                   foo: bar

Legend:
Removed from v.1.142  
changed lines
  Added in v.1.143

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26