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

Diff of /make/read.c

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

revision 1.150 by bosk, Wed Aug 10 10:21:14 2005 UTC revision 1.151 by psmith, Mon Oct 24 13:01:40 2005 UTC
# Line 258  read_all_makefiles (char **makefiles) Line 258  read_all_makefiles (char **makefiles)
258                d->file = enter_file (*p);                d->file = enter_file (*p);
259                d->file->dontcare = 1;                d->file->dontcare = 1;
260                d->ignore_mtime = 0;                d->ignore_mtime = 0;
261                  d->staticpattern = 0;
262                d->need_2nd_expansion = 0;                d->need_2nd_expansion = 0;
263                /* 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
264                   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.  */
# Line 378  eval_makefile (char *filename, int flags Line 379  eval_makefile (char *filename, int flags
379    filename = deps->file->name;    filename = deps->file->name;
380    deps->changed = flags;    deps->changed = flags;
381    deps->ignore_mtime = 0;    deps->ignore_mtime = 0;
382      deps->staticpattern = 0;
383    deps->need_2nd_expansion = 0;    deps->need_2nd_expansion = 0;
384    if (flags & RM_DONTCARE)    if (flags & RM_DONTCARE)
385      deps->file->dontcare = 1;      deps->file->dontcare = 1;
# Line 1160  eval (struct ebuffer *ebuf, int set_defa Line 1162  eval (struct ebuffer *ebuf, int set_defa
1162              pattern_percent = find_percent (pattern);              pattern_percent = find_percent (pattern);
1163              if (pattern_percent == 0)              if (pattern_percent == 0)
1164                fatal (fstart, _("target pattern contains no `%%'"));                fatal (fstart, _("target pattern contains no `%%'"));
1165              free((char *)target);              free ((char *)target);
1166            }            }
1167          else          else
1168            pattern = 0;            pattern = 0;
# Line 1172  eval (struct ebuffer *ebuf, int set_defa Line 1174  eval (struct ebuffer *ebuf, int set_defa
1174    
1175          if (beg <= end && *beg != '\0')          if (beg <= end && *beg != '\0')
1176            {            {
1177              char *top;              /* Put all the prerequisites here; they'll be parsed later.  */
1178              const char *fromp = beg;              deps = (struct dep *) xmalloc (sizeof (struct dep));
   
             /* Make a copy of the dependency string.  Note if we find '$'.  */  
             deps = (struct dep*) xmalloc (sizeof (struct dep));  
1179              deps->next = 0;              deps->next = 0;
1180              deps->name = top = (char *) xmalloc (end - beg + 2);              deps->name = xstrdup (beg);
1181                deps->staticpattern = 0;
1182              deps->need_2nd_expansion = 0;              deps->need_2nd_expansion = 0;
             while (fromp <= end)  
               {  
                 if (*fromp == '$')  
                   deps->need_2nd_expansion = 1;  
                 *(top++) = *(fromp++);  
               }  
             *top = '\0';  
1183              deps->file = 0;              deps->file = 0;
1184            }            }
1185          else          else
# Line 1918  record_files (struct nameseq *filenames, Line 1911  record_files (struct nameseq *filenames,
1911      {      {
1912        char *name = filenames->name;        char *name = filenames->name;
1913        struct file *f;        struct file *f;
1914        struct dep *d;        struct dep *this = 0;
       struct dep *this;  
1915        char *implicit_percent;        char *implicit_percent;
1916    
1917        nextf = filenames->next;        nextf = filenames->next;
1918        free (filenames);        free (filenames);
1919    
1920        /* Check for .POSIX.  We used to do this in snap_deps() but that's not        /* Check for special targets.  Do it here instead of, say, snap_deps()
1921           good enough: it doesn't happen until after the makefile is read,           so that we can immediately use the value.  */
          which means we cannot use its value during parsing.  */  
1922    
1923        if (streq (name, ".POSIX"))        if (streq (name, ".POSIX"))
1924          posix_pedantic = 1;          posix_pedantic = 1;
1925          else if (streq (name, ".SECONDEXPANSION"))
1926            second_expansion = 1;
1927    
1928        implicit_percent = find_percent (name);        implicit_percent = find_percent (name);
1929        implicit |= implicit_percent != 0;        implicit |= implicit_percent != 0;
# Line 1965  record_files (struct nameseq *filenames, Line 1958  record_files (struct nameseq *filenames,
1958            continue;            continue;
1959          }          }
1960    
1961        /* If there are multiple filenames, copy the chain DEPS        /* If this is a static pattern rule:
1962           for all but the last one.  It is not safe for the same deps           `targets: target%pattern: dep%pattern; cmds',
1963           to go in more than one place in the database.  */           make sure the pattern matches this target name.  */
1964        this = nextf != 0 ? copy_dep_chain (deps) : deps;        if (pattern && !pattern_matches (pattern, pattern_percent, name))
1965            error (flocp, _("target `%s' doesn't match the target pattern"), name);
1966        if (pattern != 0)        else if (deps)
1967          {          {
1968            /* If this is an extended static rule:            /* If there are multiple filenames, copy the chain DEPS for all but
1969               `targets: target%pattern: dep%pattern; cmds',               the last one.  It is not safe for the same deps to go in more
1970               translate each dependency pattern into a plain filename               than one place in the database.  */
1971               using the target pattern and this target's name.  */            this = nextf != 0 ? copy_dep_chain (deps) : deps;
1972            if (!pattern_matches (pattern, pattern_percent, name))            this->need_2nd_expansion = second_expansion;
1973              {          }
               /* Give a warning if the rule is meaningless.  */  
               error (flocp,  
                      _("target `%s' doesn't match the target pattern"), name);  
               this = 0;  
             }  
           else  
             /* We use subst_expand to do the work of translating % to $* in  
                the dependency line.  */  
   
             if (this != 0 && find_percent (this->name) != 0)  
               {  
                 char *o;  
                 char *buffer = variable_expand ("");  
   
                 o = subst_expand (buffer, this->name, "%", "$*", 1, 2, 0);  
   
                 free (this->name);  
                 this->name = savestring (buffer, o - buffer);  
                 this->need_2nd_expansion = 1;  
               }  
         }  
1974    
1975        if (!two_colon)        if (!two_colon)
1976          {          {
# Line 2038  record_files (struct nameseq *filenames, Line 2010  record_files (struct nameseq *filenames,
2010            if (cmds != 0)            if (cmds != 0)
2011              f->cmds = cmds;              f->cmds = cmds;
2012    
2013            /* Defining .SUFFIXES with no dependencies            /* Defining .SUFFIXES with no dependencies clears out the list of
2014               clears out the list of suffixes.  */               suffixes.  */
2015            if (f == suffix_file && this == 0)            if (f == suffix_file && this == 0)
2016              {              {
2017                d = f->deps;                free_dep_chain (f->deps);
               while (d != 0)  
                 {  
                   struct dep *nextd = d->next;  
                   free (d->name);  
                   free ((char *)d);  
                   d = nextd;  
                 }  
2018                f->deps = 0;                f->deps = 0;
2019              }              }
2020            else if (this != 0)            else if (this != 0)
# Line 2109  record_files (struct nameseq *filenames, Line 2074  record_files (struct nameseq *filenames,
2074          }          }
2075        else        else
2076          {          {
2077            /* Double-colon.  Make a new record            /* Double-colon.  Make a new record even if there already is one.  */
              even if the file already has one.  */  
2078            f = lookup_file (name);            f = lookup_file (name);
2079    
2080            /* Check for both : and :: rules.  Check is_target so            /* Check for both : and :: rules.  Check is_target so
2081               we don't lose on default suffix rules or makefiles.  */               we don't lose on default suffix rules or makefiles.  */
2082            if (f != 0 && f->is_target && !f->double_colon)            if (f != 0 && f->is_target && !f->double_colon)
2083              fatal (flocp,              fatal (flocp,
2084                     _("target file `%s' has both : and :: entries"), f->name);                     _("target file `%s' has both : and :: entries"), f->name);
2085            f = enter_file (name);            f = enter_file (name);
2086            /* If there was an existing entry and it was a double-colon            /* If there was an existing entry and it was a double-colon entry,
2087               entry, enter_file will have returned a new one, making it the               enter_file will have returned a new one, making it the prev
2088               prev pointer of the old one, and setting its double_colon               pointer of the old one, and setting its double_colon pointer to
2089               pointer to the first one.  */               the first one.  */
2090            if (f->double_colon == 0)            if (f->double_colon == 0)
2091              /* This is the first entry for this name, so we must              /* This is the first entry for this name, so we must set its
2092                 set its double_colon pointer to itself.  */                 double_colon pointer to itself.  */
2093              f->double_colon = f;              f->double_colon = f;
2094            f->is_target = 1;            f->is_target = 1;
2095            f->deps = this;            f->deps = this;
2096            f->cmds = cmds;            f->cmds = cmds;
2097          }          }
2098    
2099        /* If this is a static pattern rule, set the file's stem to        /* If this is a static pattern rule, set the stem to the part of its
2100           the part of its name that matched the `%' in the pattern,           name that matched the `%' in the pattern, so you can use $* in the
2101           so you can use $* in the commands.  */           commands.  */
2102        if (pattern != 0)        if (pattern)
2103          {          {
2104            static char *percent = "%";            static char *percent = "%";
2105            char *buffer = variable_expand ("");            char *buffer = variable_expand ("");
2106            char *o = patsubst_expand (buffer, name, pattern, percent,            char *o = patsubst_expand (buffer, name, pattern, percent,
2107                                       pattern_percent+1, percent+1);                                       pattern_percent+1, percent+1);
2108            f->stem = savestring (buffer, o - buffer);            f->stem = savestring (buffer, o - buffer);
2109              if (this)
2110                this->staticpattern = 1;
2111          }          }
2112    
2113        /* Free name if not needed further.  */        /* Free name if not needed further.  */
# Line 2152  record_files (struct nameseq *filenames, Line 2119  record_files (struct nameseq *filenames,
2119          }          }
2120    
2121        /* If this target is a default target, update DEFAULT_GOAL_FILE.  */        /* If this target is a default target, update DEFAULT_GOAL_FILE.  */
2122        if (strcmp (*default_goal_name, name) == 0        if (streq (*default_goal_name, name)
2123            && (default_goal_file == 0            && (default_goal_file == 0
2124                || strcmp (default_goal_file->name, name) != 0))                || ! streq (default_goal_file->name, name)))
2125          default_goal_file = f;          default_goal_file = f;
2126      }      }
2127    
# Line 2162  record_files (struct nameseq *filenames, Line 2129  record_files (struct nameseq *filenames,
2129      {      {
2130        targets[target_idx] = 0;        targets[target_idx] = 0;
2131        target_percents[target_idx] = 0;        target_percents[target_idx] = 0;
2132          deps->need_2nd_expansion = second_expansion;
2133          /* We set this to indicate we've not yet parsed the prereq string.  */
2134          deps->staticpattern = 1;
2135        create_pattern_rule (targets, target_percents, two_colon, deps, cmds, 1);        create_pattern_rule (targets, target_percents, two_colon, deps, cmds, 1);
2136        free ((char *) target_percents);        free ((char *) target_percents);
2137      }      }
# Line 2291  find_percent (char *pattern) Line 2261  find_percent (char *pattern)
2261  struct nameseq *  struct nameseq *
2262  parse_file_seq (char **stringp, int stopchar, unsigned int size, int strip)  parse_file_seq (char **stringp, int stopchar, unsigned int size, int strip)
2263  {  {
2264    register struct nameseq *new = 0;    struct nameseq *new = 0;
2265    register struct nameseq *new1, *lastnew1;    struct nameseq *new1, *lastnew1;
2266    register char *p = *stringp;    char *p = *stringp;
2267    char *q;    char *q;
2268    char *name;    char *name;
2269    

Legend:
Removed from v.1.150  
changed lines
  Added in v.1.151

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