Ignore:
Timestamp:
Jun 17, 2012, 10:45:31 PM (13 years ago)
Author:
bird
Message:

kmk: Merged in changes from GNU make 3.82. Previous GNU make base version was gnumake-2008-10-28-CVS.

Location:
trunk/src/kmk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk

    • Property svn:ignore
      •  

        old new  
        1313stamp-*
        1414makebook*
         15
        1516.*gdbinit
         17.gdb_history
         18
        1619*.dep
        1720*.dvi
         
        3134*.pg
        3235*.pgs
         36
        3337README
        3438README.DOS
        3539README.W32
         40README.OS2
        3641aclocal.m4
        3742autom4te.cache
         
        5257config.h.W32
        5358config.h-vms
         59
        5460loadavg
        5561loadavg.c
        5662make
         63
        5764.deps
        5865.dep_segment
         66ID
         67TAGS
         68
        5969_*
        6070sun4
         
        7282sol2
        7383i486-linux
         84
        7485customs
         86
        7587install-sh
        7688mkinstalldirs
         89
         90.directive.asc
  • trunk/src/kmk/implicit.c

    r2024 r2591  
    11/* Implicit rule searching for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    4949    return 1;
    5050
    51 #ifndef NO_ARCHIVES
     51#ifndef NO_ARCHIVES
    5252  /* If this is an archive member reference, use just the
    5353     archive member name to search for implicit rules.  */
     
    5757           _("Looking for archive-member implicit rule for `%s'.\n"));
    5858      if (pattern_search (file, 1, depth, 0))
    59         return 1;
     59        return 1;
    6060    }
    6161#endif
     
    6464}
    6565
    66 
    67 
    68 #ifdef CONFIG_WITH_ALLOC_CACHES
    69 struct alloccache idep_cache;
    70 #endif
    71 
    72 /* Struct idep captures information about implicit prerequisites
    73    that come from implicit rules. */
    74 struct idep
    75 {
    76   struct idep *next;              /* struct dep -compatible interface */
    77   const char *name;               /* name of the prerequisite */
    78   struct file *intermediate_file; /* intermediate file, 0 otherwise */
    79   const char *intermediate_pattern; /* pattern for intermediate file */
    80   unsigned char had_stem;         /* had % substituted with stem */
    81   unsigned char ignore_mtime;     /* ignore_mtime flag */
    82 };
    83 
    84 static void
    85 free_idep_chain (struct idep *p)
    86 {
    87   struct idep *n;
    88 
    89   for (; p != 0; p = n)
    90     {
    91       n = p->next;
    92 #ifndef CONFIG_WITH_ALLOC_CACHES
    93       free (p);
    94 #else
    95       alloccache_free (&idep_cache, p);
    96 #endif
    97     }
    98 }
    9966
    10067
     
    10370   length of the word.  */
    10471
    105 static char *
     72static const char *
    10673get_next_word (const char *buffer, unsigned int *length)
    10774{
     
    181148    *length = p - beg;
    182149
    183   return (char *)beg;
     150  return beg;
     151}
     152
     153/* This structure stores information about the expanded prerequisites for a
     154   pattern rule.  NAME is always set to the strcache'd name of the prereq.
     155   FILE and PATTERN will be set for intermediate files only.  IGNORE_MTIME is
     156   copied from the prerequisite we expanded.
     157 */
     158struct patdeps
     159  {
     160    const char *name;
     161    const char *pattern;
     162    struct file *file;
     163    unsigned int ignore_mtime : 1;
     164  };
     165
     166/* This structure stores information about pattern rules that we need
     167   to try.
     168*/
     169struct tryrule
     170  {
     171    struct rule *rule;
     172
     173    /* Index of the target in this rule that matched the file. */
     174    unsigned int matches;
     175
     176    /* Stem length for this match. */
     177    unsigned int stemlen;
     178
     179    /* Definition order of this rule. Used to implement stable sort.*/
     180    unsigned int order;
     181
     182    /* Nonzero if the LASTSLASH logic was used in matching this rule. */
     183    char checked_lastslash;
     184  };
     185
     186int
     187stemlen_compare (const void *v1, const void *v2)
     188{
     189  const struct tryrule *r1 = v1;
     190  const struct tryrule *r2 = v2;
     191  int r = r1->stemlen - r2->stemlen;
     192  return r != 0 ? r : (int)(r1->order - r2->order);
    184193}
    185194
     
    209218
    210219  /* The last slash in FILENAME (or nil if there is none).  */
    211   char *lastslash;
     220  const char *lastslash;
    212221
    213222  /* This is a file-object used as an argument in
    214223     recursive calls.  It never contains any data
    215224     except during a recursive call.  */
    216   struct file *intermediate_file = 0;
    217 
    218   /* This linked list records all the prerequisites actually
    219      found for a rule along with some other useful information
    220      (see struct idep for details). */
    221   struct idep* deps = 0;
    222 
    223   /* 1 if we need to remove explicit prerequisites, 0 otherwise. */
    224   unsigned int remove_explicit_deps = 0;
     225  struct file *int_file = 0;
     226
     227  /* List of dependencies found recursively.  */
     228  struct patdeps *deplist
     229    = xmalloc (max_pattern_deps * sizeof (struct patdeps));
     230  struct patdeps *pat = deplist;
     231
     232  /* All the prerequisites actually found for a rule, after expansion. */
     233  struct dep *deps;
    225234
    226235  /* Names of possible dependencies are constructed in this buffer.  */
     
    233242
    234243  /* Buffer in which we store all the rules that are possibly applicable.  */
    235   struct rule **tryrules = xmalloc (num_pattern_rules * max_pattern_targets
    236                                     * sizeof (struct rule *));
     244  struct tryrule *tryrules = xmalloc (num_pattern_rules * max_pattern_targets
     245                                      * sizeof (struct tryrule));
    237246
    238247  /* Number of valid elements in TRYRULES.  */
    239248  unsigned int nrules;
    240249
    241   /* The numbers of the rule targets of each rule
    242      in TRYRULES that matched the target file.  */
    243   unsigned int *matches = alloca (num_pattern_rules * sizeof (unsigned int));
    244 
    245   /* Each element is nonzero if LASTSLASH was used in
    246      matching the corresponding element of TRYRULES.  */
    247   char *checked_lastslash = alloca (num_pattern_rules * sizeof (char));
    248 
    249250  /* The index in TRYRULES of the rule we found.  */
    250251  unsigned int foundrule;
     
    252253  /* Nonzero if should consider intermediate files as dependencies.  */
    253254  int intermed_ok;
     255
     256  /* Nonzero if we have initialized file variables for this target.  */
     257  int file_vars_initialized = 0;
    254258
    255259  /* Nonzero if we have matched a pattern-rule target
     
    257261  int specific_rule_matched = 0;
    258262
     263  struct dep dep_simple;
     264
    259265  unsigned int ri;  /* uninit checks OK */
    260266  struct rule *rule;
    261   struct dep *dep, *expl_d;
    262 
    263   struct idep *d;
    264   struct idep **id_ptr;
    265   struct dep **d_ptr;
     267
     268  char *pathdir = NULL;
     269  unsigned long pathlen;
    266270
    267271  PATH_VAR (stem_str); /* @@ Need to get rid of stem, stemlen, etc. */
    268272
    269 #ifdef CONFIG_WITH_ALLOC_CACHES
    270   if (!idep_cache.size)
    271     alloccache_init (&idep_cache, sizeof (struct idep), "idep", NULL, NULL);
    272 #endif
    273 
    274 #ifndef NO_ARCHIVES
     273#ifndef NO_ARCHIVES
    275274  if (archive || ar_name (filename))
    276275    lastslash = 0;
     
    279278    {
    280279      /* Set LASTSLASH to point at the last slash in FILENAME
    281         but not counting any slash at the end.  (foo/bar/ counts as
    282         bar/ in directory foo/, not empty in directory foo/bar/.)  */
     280        but not counting any slash at the end.  (foo/bar/ counts as
     281        bar/ in directory foo/, not empty in directory foo/bar/.)  */
    283282#ifdef VMS
    284283      lastslash = strrchr (filename, ']');
    285284      if (lastslash == 0)
    286         lastslash = strrchr (filename, ':');
     285        lastslash = strrchr (filename, ':');
    287286#else
    288287      lastslash = strrchr (filename, '/');
    289288#ifdef HAVE_DOS_PATHS
    290289      /* Handle backslashes (possibly mixed with forward slashes)
    291         and the case of "d:file".  */
     290        and the case of "d:file".  */
    292291      {
    293         char *bslash = strrchr (filename, '\\');
    294         if (lastslash == 0 || bslash > lastslash)
    295           lastslash = bslash;
    296         if (lastslash == 0 && filename[0] && filename[1] == ':')
    297           lastslash = (char *)filename + 1;
     292        char *bslash = strrchr (filename, '\\');
     293        if (lastslash == 0 || bslash > lastslash)
     294          lastslash = bslash;
     295        if (lastslash == 0 && filename[0] && filename[1] == ':')
     296          lastslash = filename + 1;
    298297      }
    299298#endif
    300299#endif
    301300      if (lastslash != 0 && lastslash[1] == '\0')
    302         lastslash = 0;
     301        lastslash = 0;
    303302    }
    304303
    305   /* First see which pattern rules match this target
    306      and may be considered.  Put them in TRYRULES.  */
     304  pathlen = lastslash - filename + 1;
     305
     306  /* First see which pattern rules match this target and may be considered.
     307     Put them in TRYRULES.  */
    307308
    308309  nrules = 0;
     
    312313
    313314      /* If the pattern rule has deps but no commands, ignore it.
    314         Users cancel built-in rules by redefining them without commands.  */
     315        Users cancel built-in rules by redefining them without commands.  */
    315316      if (rule->deps != 0 && rule->cmds == 0)
    316         continue;
     317        continue;
    317318
    318319      /* If this rule is in use by a parent pattern_search,
    319         don't use it here.  */
     320        don't use it here.  */
    320321      if (rule->in_use)
    321         {
    322           DBS (DB_IMPLICIT, (_("Avoiding implicit rule recursion.\n")));
    323           continue;
    324         }
     322        {
     323          DBS (DB_IMPLICIT, (_("Avoiding implicit rule recursion.\n")));
     324          continue;
     325        }
    325326
    326327      for (ti = 0; ti < rule->num; ++ti)
    327         {
    328           const char *target = rule->targets[ti];
    329           const char *suffix = rule->suffixes[ti];
    330           int check_lastslash;
    331 
    332           /* Rules that can match any filename and are not terminal
    333              are ignored if we're recursing, so that they cannot be
    334              intermediate files.  */
    335           if (recursions > 0 && target[1] == '\0' && !rule->terminal)
    336             continue;
    337 
    338           if (rule->lens[ti] > namelen)
    339             /* It can't possibly match.  */
    340             continue;
    341 
    342           /* From the lengths of the filename and the pattern parts,
    343              find the stem: the part of the filename that matches the %.  */
    344           stem = filename + (suffix - target - 1);
    345           stemlen = namelen - rule->lens[ti] + 1;
    346 
    347           /* Set CHECK_LASTSLASH if FILENAME contains a directory
    348              prefix and the target pattern does not contain a slash.  */
     328        {
     329          const char *target = rule->targets[ti];
     330          const char *suffix = rule->suffixes[ti];
     331          int check_lastslash;
     332
     333          /* Rules that can match any filename and are not terminal
     334             are ignored if we're recursing, so that they cannot be
     335             intermediate files.  */
     336          if (recursions > 0 && target[1] == '\0' && !rule->terminal)
     337            continue;
     338
     339          if (rule->lens[ti] > namelen)
     340            /* It can't possibly match.  */
     341            continue;
     342
     343          /* From the lengths of the filename and the pattern parts,
     344             find the stem: the part of the filename that matches the %.  */
     345          stem = filename + (suffix - target - 1);
     346          stemlen = namelen - rule->lens[ti] + 1;
     347
     348          /* Set CHECK_LASTSLASH if FILENAME contains a directory
     349             prefix and the target pattern does not contain a slash.  */
    349350
    350351          check_lastslash = 0;
     
    366367#endif
    367368            }
    368           if (check_lastslash)
    369             {
    370               /* If so, don't include the directory prefix in STEM here.  */
    371               unsigned int difference = lastslash - filename + 1;
    372               if (difference > stemlen)
    373                 continue;
    374               stemlen -= difference;
    375               stem += difference;
    376             }
    377 
    378           /* Check that the rule pattern matches the text before the stem.  */
    379           if (check_lastslash)
    380             {
    381               if (stem > (lastslash + 1)
    382                   && !strneq (target, lastslash + 1, stem - lastslash - 1))
    383                 continue;
    384             }
    385           else if (stem > filename
    386                    && !strneq (target, filename, stem - filename))
    387             continue;
    388 
    389           /* Check that the rule pattern matches the text after the stem.
    390              We could test simply use streq, but this way we compare the
    391              first two characters immediately.  This saves time in the very
    392              common case where the first character matches because it is a
    393              period.  */
    394           if (*suffix != stem[stemlen]
    395               || (*suffix != '\0' && !streq (&suffix[1], &stem[stemlen + 1])))
    396             continue;
    397 
    398           /* Record if we match a rule that not all filenames will match.  */
    399           if (target[1] != '\0')
    400             specific_rule_matched = 1;
    401 
    402           /* A rule with no dependencies and no commands exists solely to set
    403              specific_rule_matched when it matches.  Don't try to use it.  */
    404           if (rule->deps == 0 && rule->cmds == 0)
    405             continue;
    406 
    407           /* Record this rule in TRYRULES and the index of the matching
    408              target in MATCHES.  If several targets of the same rule match,
    409              that rule will be in TRYRULES more than once.  */
    410           tryrules[nrules] = rule;
    411           matches[nrules] = ti;
    412           checked_lastslash[nrules] = check_lastslash;
    413           ++nrules;
    414         }
     369          if (check_lastslash)
     370            {
     371              /* If so, don't include the directory prefix in STEM here.  */
     372              if (pathlen > stemlen)
     373                continue;
     374              stemlen -= pathlen;
     375              stem += pathlen;
     376            }
     377
     378          /* Check that the rule pattern matches the text before the stem.  */
     379          if (check_lastslash)
     380            {
     381              if (stem > (lastslash + 1)
     382                  && !strneq (target, lastslash + 1, stem - lastslash - 1))
     383                continue;
     384            }
     385          else if (stem > filename
     386                   && !strneq (target, filename, stem - filename))
     387            continue;
     388
     389          /* Check that the rule pattern matches the text after the stem.
     390             We could test simply use streq, but this way we compare the
     391             first two characters immediately.  This saves time in the very
     392             common case where the first character matches because it is a
     393             period.  */
     394          if (*suffix != stem[stemlen]
     395              || (*suffix != '\0' && !streq (&suffix[1], &stem[stemlen + 1])))
     396            continue;
     397
     398          /* Record if we match a rule that not all filenames will match.  */
     399          if (target[1] != '\0')
     400            specific_rule_matched = 1;
     401
     402          /* A rule with no dependencies and no commands exists solely to set
     403             specific_rule_matched when it matches.  Don't try to use it.  */
     404          if (rule->deps == 0 && rule->cmds == 0)
     405            continue;
     406
     407          /* Record this rule in TRYRULES and the index of the matching
     408             target in MATCHES.  If several targets of the same rule match,
     409             that rule will be in TRYRULES more than once.  */
     410          tryrules[nrules].rule = rule;
     411          tryrules[nrules].matches = ti;
     412          tryrules[nrules].stemlen = stemlen + (check_lastslash ? pathlen : 0);
     413          tryrules[nrules].order = nrules;
     414          tryrules[nrules].checked_lastslash = check_lastslash;
     415          ++nrules;
     416        }
    415417    }
     418
     419  /* Bail out early if we haven't found any rules. */
     420  if (nrules == 0)
     421    goto done;
     422
     423  /* Sort the rules to place matches with the shortest stem first. This
     424     way the most specific rules will be tried first. */
     425  if (nrules > 1)
     426    qsort (tryrules, nrules, sizeof (struct tryrule), stemlen_compare);
    416427
    417428  /* If we have found a matching rule that won't match all filenames,
     
    419430  if (specific_rule_matched)
    420431    for (ri = 0; ri < nrules; ++ri)
    421       if (!tryrules[ri]->terminal)
    422         {
    423           unsigned int j;
    424           for (j = 0; j < tryrules[ri]->num; ++j)
    425             if (tryrules[ri]->targets[j][1] == '\0')
     432      if (!tryrules[ri].rule->terminal)
     433        {
     434          unsigned int j;
     435          for (j = 0; j < tryrules[ri].rule->num; ++j)
     436            if (tryrules[ri].rule->targets[j][1] == '\0')
    426437              {
    427                 tryrules[ri] = 0;
     438                tryrules[ri].rule = 0;
    428439                break;
    429440              }
    430         }
    431 
    432   /* We are going to do second expansion so initialize file variables
    433      for the rule. */
    434   initialize_file_variables (file, 0);
     441        }
    435442
    436443  /* Try each rule once without intermediate files, then once with them.  */
    437   for (intermed_ok = 0; intermed_ok == !!intermed_ok; ++intermed_ok)
     444  for (intermed_ok = 0; intermed_ok < 2; ++intermed_ok)
    438445    {
    439       /* Try each pattern rule till we find one that applies.
    440          If it does, expand its dependencies (as substituted)
    441          and chain them in DEPS.  */
    442 
     446      pat = deplist;
     447
     448      /* Try each pattern rule till we find one that applies.  If it does,
     449         expand its dependencies (as substituted) and chain them in DEPS.  */
    443450      for (ri = 0; ri < nrules; ri++)
    444         {
    445           struct file *f;
     451        {
     452          struct dep *dep;
     453          int check_lastslash;
    446454          unsigned int failed = 0;
    447           int check_lastslash;
    448455          int file_variables_set = 0;
    449 
    450           rule = tryrules[ri];
    451 
    452           remove_explicit_deps = 0;
    453 
    454           /* RULE is nil when we discover that a rule,
    455              already placed in TRYRULES, should not be applied.  */
    456           if (rule == 0)
    457             continue;
    458 
    459           /* Reject any terminal rules if we're
    460              looking to make intermediate files.  */
    461           if (intermed_ok && rule->terminal)
    462             continue;
    463 
    464           /* Mark this rule as in use so a recursive
    465              pattern_search won't try to use it.  */
    466           rule->in_use = 1;
    467 
    468           /* From the lengths of the filename and the matching pattern parts,
    469              find the stem: the part of the filename that matches the %.  */
    470           stem = filename
    471             + (rule->suffixes[matches[ri]] - rule->targets[matches[ri]]) - 1;
    472           stemlen = namelen - rule->lens[matches[ri]] + 1;
    473           check_lastslash = checked_lastslash[ri];
    474           if (check_lastslash)
    475             {
    476               stem += lastslash - filename + 1;
    477               stemlen -= (lastslash - filename) + 1;
    478             }
    479 
    480           DBS (DB_IMPLICIT, (_("Trying pattern rule with stem `%.*s'.\n"),
     456          unsigned int deps_found = 0;
     457          /* NPTR points to the part of the prereq we haven't processed.  */
     458          const char *nptr = 0;
     459          const char *dir = NULL;
     460          int order_only = 0;
     461          unsigned int matches;
     462
     463          rule = tryrules[ri].rule;
     464
     465          /* RULE is nil when we discover that a rule, already placed in
     466             TRYRULES, should not be applied.  */
     467          if (rule == 0)
     468            continue;
     469
     470          /* Reject any terminal rules if we're looking to make intermediate
     471             files.  */
     472          if (intermed_ok && rule->terminal)
     473            continue;
     474
     475          /* From the lengths of the filename and the matching pattern parts,
     476             find the stem: the part of the filename that matches the %.  */
     477          matches = tryrules[ri].matches;
     478          stem = filename + (rule->suffixes[matches]
     479                             - rule->targets[matches]) - 1;
     480          stemlen = (namelen - rule->lens[matches]) + 1;
     481          check_lastslash = tryrules[ri].checked_lastslash;
     482          if (check_lastslash)
     483            {
     484              stem += pathlen;
     485              stemlen -= pathlen;
     486
     487              /* We need to add the directory prefix, so set it up.  */
     488              if (! pathdir)
     489                {
     490                  pathdir = alloca (pathlen + 1);
     491                  memcpy (pathdir, filename, pathlen);
     492                  pathdir[pathlen] = '\0';
     493                }
     494              dir = pathdir;
     495            }
     496
     497          DBS (DB_IMPLICIT, (_("Trying pattern rule with stem `%.*s'.\n"),
    481498                             (int) stemlen, stem));
    482499
    483500          strncpy (stem_str, stem, stemlen);
    484501          stem_str[stemlen] = '\0';
     502
     503          /* If there are no prerequisites, then this rule matches.  */
     504          if (rule->deps == 0)
     505            break;
    485506
    486507          /* Temporary assign STEM to file->stem (needed to set file
     
    488509          file->stem = stem_str;
    489510
    490           /* Try each dependency; see if it "exists".  */
    491 
    492           for (dep = rule->deps; dep != 0; dep = dep->next)
    493             {
    494               unsigned int len;
     511          /* Mark this rule as in use so a recursive pattern_search won't try
     512             to use it.  */
     513          rule->in_use = 1;
     514
     515          /* Try each prerequisite; see if it exists or can be created.  We'll
     516             build a list of prereq info in DEPLIST.  Due to 2nd expansion we
     517             may have to process multiple prereqs for a single dep entry.  */
     518
     519          pat = deplist;
     520          dep = rule->deps;
     521          nptr = dep_name (dep);
     522          while (1)
     523            {
     524              struct dep *dl, *d;
    495525              char *p;
    496               char *p2;
    497               unsigned int order_only = 0; /* Set if '|' was seen. */
    498 
    499               /* In an ideal world we would take the dependency line,
    500                  substitute the stem, re-expand the whole line and chop it
    501                  into individual prerequisites. Unfortunately this won't work
    502                  because of the "check_lastslash" twist.  Instead, we will
    503                  have to go word by word, taking $()'s into account, for each
    504                  word we will substitute the stem, re-expand, chop it up, and,
    505                  if check_lastslash != 0, add the directory part to each
     526
     527              /* If we're out of name to parse, start the next prereq.  */
     528              if (! nptr)
     529                {
     530                  dep = dep->next;
     531                  if (dep == 0)
     532                    break;
     533                  nptr = dep_name (dep);
     534                }
     535
     536              /* If we don't need a second expansion, just replace the %.  */
     537              if (! dep->need_2nd_expansion)
     538                {
     539                  dep_simple = *dep;
     540                  dep_simple.next = 0;
     541                  p = strchr (nptr, '%');
     542                  if (p == 0)
     543                    dep_simple.name = nptr;
     544                  else
     545                    {
     546                      char *o = depname;
     547                      if (check_lastslash)
     548                        {
     549                          memcpy (o, filename, pathlen);
     550                          o += pathlen;
     551                        }
     552                      memcpy (o, nptr, p - nptr);
     553                      o += p - nptr;
     554                      memcpy (o, stem_str, stemlen);
     555                      o += stemlen;
     556                      strcpy (o, p + 1);
     557                      dep_simple.name = strcache_add (depname);
     558                    }
     559                  dl = &dep_simple;
     560
     561                  /* We've used up this dep, so next time get a new one.  */
     562                  nptr = 0;
     563                  ++deps_found;
     564                }
     565
     566              /* We have to perform second expansion on this prereq.  In an
     567                 ideal world we would take the dependency line, substitute the
     568                 stem, re-expand the whole line and chop it into individual
     569                 prerequisites.  Unfortunately this won't work because of the
     570                 "check_lastslash" twist.  Instead, we will have to go word by
     571                 word, taking $()'s into account.  For each word we will
     572                 substitute the stem, re-expand, chop it up, and, if
     573                 check_lastslash != 0, add the directory part to each
    506574                 resulting prerequisite.  */
    507 
    508               p = get_next_word (dep->name, &len);
    509 
    510               while (1)
     575              else
    511576                {
    512577                  int add_dir = 0;
    513                   int had_stem = 0;
    514 
     578                  unsigned int len;
     579
     580                  nptr = get_next_word (nptr, &len);
     581                  if (nptr == 0)
     582                    continue;
     583
     584                  /* See this is a transition to order-only prereqs.  */
     585                  if (! order_only && len == 1 && nptr[0] == '|')
     586                    {
     587                      order_only = 1;
     588                      nptr += len;
     589                      continue;
     590                    }
     591
     592                  /* If the dependency name has %, substitute the stem.  If we
     593                     just replace % with the stem value then later, when we do
     594                     the 2nd expansion, we will re-expand this stem value
     595                     again.  This is not good if you have certain characters
     596                     in your stem (like $).
     597
     598                     Instead, we will replace % with $* and allow the second
     599                     expansion to take care of it for us.  This way (since $*
     600                     is a simple variable) there won't be additional
     601                     re-expansion of the stem.  */
     602
     603                  p = lindex (nptr, nptr + len, '%');
    515604                  if (p == 0)
    516                     break; /* No more words */
    517 
    518                   /* Is there a pattern in this prerequisite?  */
    519 
    520                   for (p2 = p; p2 < p + len && *p2 != '%'; ++p2)
    521                     ;
    522 
    523                   if (dep->need_2nd_expansion)
    524                     {
    525                       /* If the dependency name has %, substitute the stem.
    526 
    527                          Watch out, we are going to do something tricky
    528                          here. If we just replace % with the stem value,
    529                          later, when we do the second expansion, we will
    530                          re-expand this stem value once again. This is not
    531                          good especially if you have certain characters in
    532                          your stem (like $).
    533 
    534                          Instead, we will replace % with $* and allow the
    535                          second expansion to take care of it for us. This way
    536                          (since $* is a simple variable) there won't be
    537                          additional re-expansion of the stem.  */
    538 
    539                       if (p2 < p + len)
    540                         {
    541                           unsigned int i = p2 - p;
    542                           memcpy (depname, p, i);
    543                           memcpy (depname + i, "$*", 2);
    544                           memcpy (depname + i + 2, p2 + 1, len - i - 1);
    545                           depname[len + 2 - 1] = '\0';
    546 
    547                           if (check_lastslash)
    548                             add_dir = 1;
    549 
    550                           had_stem = 1;
    551                         }
    552                       else
    553                         {
    554                           memcpy (depname, p, len);
    555                           depname[len] = '\0';
    556                         }
    557 
    558                       /* Set file variables. Note that we cannot do it once
    559                          at the beginning of the function because of the stem
    560                          value.  */
    561                       if (!file_variables_set)
    562                         {
     605                    {
     606                      memcpy (depname, nptr, len);
     607                      depname[len] = '\0';
     608                    }
     609                  else
     610                    {
     611                      unsigned int i = p - nptr;
     612                      memcpy (depname, nptr, i);
     613                      memcpy (depname + i, "$*", 2);
     614                      memcpy (depname + i + 2, p + 1, len - i - 1);
     615                      depname[len + 2 - 1] = '\0';
     616
     617                      if (check_lastslash)
     618                        add_dir = 1;
     619                    }
     620
     621                  /* Initialize and set file variables if we haven't already
     622                     done so. */
     623                  if (!file_vars_initialized)
     624                    {
     625                      initialize_file_variables (file, 0);
    563626#if defined(CONFIG_WITH_COMMANDS_FUNC) || defined (CONFIG_WITH_DOT_MUST_MAKE)
    564                           set_file_variables (file, 0 /* real call */);
     627                      set_file_variables (file, 0 /* real call */);
    565628#else
    566                           set_file_variables (file);
     629                      set_file_variables (file);
    567630#endif
    568                           file_variables_set = 1;
    569                         }
    570 
    571                       p2 = variable_expand_for_file (depname, file);
    572                     }
    573                   else
    574                     {
    575                        if (p2 < p + len)
    576                         {
    577                           unsigned int i = p2 - p;
    578                           memcpy (depname, p, i);
    579                           memcpy (depname + i, stem_str, stemlen);
    580                           memcpy (depname + i + stemlen, p2 + 1, len - i - 1);
    581                           depname[len + stemlen - 1] = '\0';
    582 
    583                           if (check_lastslash)
    584                             add_dir = 1;
    585 
    586                           had_stem = 1;
    587                         }
    588                       else
    589                         {
    590                           memcpy (depname, p, len);
    591                           depname[len] = '\0';
    592                         }
    593 
    594                        p2 = depname;
    595                     }
    596 
    597                   /* Parse the dependencies. */
    598 
    599                   while (1)
    600                     {
    601                       id_ptr = &deps;
    602 
    603                       for (; *id_ptr; id_ptr = &(*id_ptr)->next)
    604                         ;
    605 
    606 #ifndef CONFIG_WITH_ALLOC_CACHES
    607                       *id_ptr = (struct idep *)
    608                         multi_glob (
    609                           parse_file_seq (&p2,
    610                                           order_only ? '\0' : '|',
    611                                           sizeof (struct idep),
    612                                           1), sizeof (struct idep));
    613 #else
    614                       *id_ptr = (struct idep *)
    615                         multi_glob (
    616                           parse_file_seq (&p2,
    617                                           order_only ? '\0' : '|',
    618                                           &idep_cache, 1),
    619                           &idep_cache);
    620 #endif
    621 
    622                       /* @@ It would be nice to teach parse_file_seq or
    623                          multi_glob to add prefix. This would save us some
    624                          reallocations. */
    625 
    626                       if (order_only || add_dir || had_stem)
    627                         {
    628                           unsigned long l = lastslash - filename + 1;
    629 
    630                           for (d = *id_ptr; d != 0; d = d->next)
    631                             {
    632                               if (order_only)
    633                                 d->ignore_mtime = 1;
    634 
    635                               if (add_dir)
    636                                 {
    637                                   char *n = alloca (strlen (d->name) + l + 1);
    638                                   memcpy (n, filename, l);
    639                                   memcpy (n+l, d->name, strlen (d->name) + 1);
    640                                   d->name = strcache_add (n);
    641                                 }
    642 
    643                               if (had_stem)
    644                                 d->had_stem = 1;
    645                             }
    646                         }
    647 
    648                       if (!order_only && *p2)
     631                      file_vars_initialized = 1;
     632                    }
     633                  /* Update the stem value in $* for this rule.  */
     634                  else if (!file_variables_set)
     635                    {
     636                      define_variable_for_file (
     637                        "*", 1, file->stem, o_automatic, 0, file);
     638                      file_variables_set = 1;
     639                    }
     640
     641                  /* Perform the 2nd expansion.  */
     642                  p = variable_expand_for_file (depname, file);
     643
     644                  /* Parse the expanded string. */
     645                  dl = PARSE_FILE_SEQ (&p, struct dep, order_only ? '\0' : '|',
     646                                       add_dir ? dir : NULL, 0);
     647
     648                  for (d = dl; d != NULL; d = d->next)
     649                    {
     650                      ++deps_found;
     651                      if (order_only)
     652                        d->ignore_mtime = 1;
     653                    }
     654
     655                  /* Set up for the next word.  */
     656                  nptr += len;
     657                }
     658
     659              /* If there are more than max_pattern_deps prerequisites (due to
     660                 2nd expansion), reset it and realloc the arrays.  */
     661
     662              if (deps_found > max_pattern_deps)
     663                {
     664                  unsigned int l = pat - deplist;
     665                  deplist = xrealloc (deplist,
     666                                      deps_found * sizeof (struct patdeps));
     667                  pat = deplist + l;
     668                  max_pattern_deps = deps_found;
     669                }
     670
     671              /* Go through the nameseq and handle each as a prereq name.  */
     672              for (d = dl; d != 0; d = d->next)
     673                {
     674                  struct dep *expl_d;
     675                  int is_rule = d->name == dep_name (dep);
     676
     677                  if (file_impossible_p (d->name))
     678                    {
     679                      /* If this prereq has already been ruled "impossible",
     680                         then the rule fails.  Don't bother trying it on the
     681                         second pass either since we know that will fail.  */
     682                      DBS (DB_IMPLICIT,
     683                           (is_rule
     684                            ? _("Rejecting impossible rule prerequisite `%s'.\n")
     685                            : _("Rejecting impossible implicit prerequisite `%s'.\n"),
     686                            d->name));
     687                      tryrules[ri].rule = 0;
     688
     689                      failed = 1;
     690                      break;
     691                    }
     692
     693                  memset (pat, '\0', sizeof (struct patdeps));
     694                  pat->ignore_mtime = d->ignore_mtime;
     695
     696                  DBS (DB_IMPLICIT,
     697                       (is_rule
     698                        ? _("Trying rule prerequisite `%s'.\n")
     699                        : _("Trying implicit prerequisite `%s'.\n"), d->name));
     700
     701                  /* If this prereq is also explicitly mentioned for FILE,
     702                     skip all tests below since it must be built no matter
     703                     which implicit rule we choose. */
     704
     705                  for (expl_d = file->deps; expl_d != 0; expl_d = expl_d->next)
     706                    if (streq (dep_name (expl_d), d->name))
     707                      break;
     708                  if (expl_d != 0)
     709                    {
     710                      (pat++)->name = d->name;
     711                      continue;
     712                    }
     713
     714                  /* The DEP->changed flag says that this dependency resides
     715                     in a nonexistent directory.  So we normally can skip
     716                     looking for the file.  However, if CHECK_LASTSLASH is
     717                     set, then the dependency file we are actually looking for
     718                     is in a different directory (the one gotten by prepending
     719                     FILENAME's directory), so it might actually exist.  */
     720
     721                  /* @@ dep->changed check is disabled. */
     722                  if (lookup_file (d->name) != 0
     723                      /*|| ((!dep->changed || check_lastslash) && */
     724                      || file_exists_p (d->name))
     725                    {
     726                      (pat++)->name = d->name;
     727                      continue;
     728                    }
     729
     730                  /* This code, given FILENAME = "lib/foo.o", dependency name
     731                     "lib/foo.c", and VPATH=src, searches for
     732                     "src/lib/foo.c".  */
     733                  {
     734                    const char *vname = vpath_search (d->name, 0, NULL, NULL);
     735                    if (vname)
    649736                      {
    650                         ++p2;
    651                         order_only = 1;
     737                        DBS (DB_IMPLICIT,
     738                             (_("Found prerequisite `%s' as VPATH `%s'\n"),
     739                              d->name, vname));
     740                        (pat++)->name = d->name;
    652741                        continue;
    653742                      }
    654 
    655                       break;
    656                     }
    657 
    658                   p += len;
    659                   p = get_next_word (p, &len);
    660                 }
    661             }
    662 
    663           /* Reset the stem in FILE. */
    664 
    665           file->stem = 0;
    666 
    667           /* @@ This loop can be combined with the previous one. I do
    668              it separately for now for transparency.*/
    669 
    670           for (d = deps; d != 0; d = d->next)
    671             {
    672               const char *name = d->name;
    673 
    674               if (file_impossible_p (name))
    675                 {
    676                   /* If this dependency has already been ruled "impossible",
    677                      then the rule fails and don't bother trying it on the
    678                      second pass either since we know that will fail too.  */
    679                   DBS (DB_IMPLICIT,
    680                        (d->had_stem
    681                         ? _("Rejecting impossible implicit prerequisite `%s'.\n")
    682                         : _("Rejecting impossible rule prerequisite `%s'.\n"),
    683                         name));
    684                   tryrules[ri] = 0;
    685 
     743                  }
     744
     745                  /* We could not find the file in any place we should look.
     746                     Try to make this dependency as an intermediate file, but
     747                     only on the second pass.  */
     748
     749                  if (intermed_ok)
     750                    {
     751                      DBS (DB_IMPLICIT,
     752                           (_("Looking for a rule with intermediate file `%s'.\n"),
     753                            d->name));
     754
     755                      if (int_file == 0)
     756                        int_file = alloca (sizeof (struct file));
     757                      memset (int_file, '\0', sizeof (struct file));
     758                      int_file->name = d->name;
     759
     760                      if (pattern_search (int_file,
     761                                          0,
     762                                          depth + 1,
     763                                          recursions + 1))
     764                        {
     765                          pat->pattern = int_file->name;
     766                          int_file->name = d->name;
     767                          pat->file = int_file;
     768                          (pat++)->name = d->name;
     769                          int_file = 0;
     770                          continue;
     771                        }
     772
     773                      /* If we have tried to find P as an intermediate file
     774                         and failed, mark that name as impossible so we won't
     775                         go through the search again later.  */
     776                      if (int_file->variables)
     777                        free_variable_set (int_file->variables);
     778                      if (int_file->pat_variables)
     779                        free_variable_set (int_file->pat_variables);
     780                      file_impossible (d->name);
     781                    }
     782
     783                  /* A dependency of this rule does not exist. Therefore, this
     784                     rule fails.  */
    686785                  failed = 1;
    687786                  break;
    688787                }
    689788
    690               DBS (DB_IMPLICIT,
    691                    (d->had_stem
    692                     ? _("Trying implicit prerequisite `%s'.\n")
    693                     : _("Trying rule prerequisite `%s'.\n"), name));
    694 
    695               /* If this prerequisite also happened to be explicitly mentioned
    696                  for FILE skip all the test below since it it has to be built
    697                  anyway, no matter which implicit rule we choose. */
    698 
    699               for (expl_d = file->deps; expl_d != 0; expl_d = expl_d->next)
    700                 if (streq (dep_name (expl_d), name))
    701                   break;
    702               if (expl_d != 0)
    703                 continue;
    704 
    705               /* The DEP->changed flag says that this dependency resides in a
    706                  nonexistent directory.  So we normally can skip looking for
    707                  the file.  However, if CHECK_LASTSLASH is set, then the
    708                  dependency file we are actually looking for is in a different
    709                  directory (the one gotten by prepending FILENAME's directory),
    710                  so it might actually exist.  */
    711 
    712               /* @@ dep->changed check is disabled. */
    713               if (((f = lookup_file (name)) != 0 && f->is_target)
    714                   /*|| ((!dep->changed || check_lastslash) && */
    715                   || file_exists_p (name))
    716                 continue;
    717 
    718               /* This code, given FILENAME = "lib/foo.o", dependency name
    719                  "lib/foo.c", and VPATH=src, searches for "src/lib/foo.c".  */
    720               {
    721                 const char *vname = vpath_search (name, 0);
    722                 if (vname)
    723                   {
    724                     DBS (DB_IMPLICIT,
    725                          (_("Found prerequisite `%s' as VPATH `%s'\n"),
    726                           name, vname));
    727                     continue;
    728                   }
    729               }
    730 
    731 
    732               /* We could not find the file in any place we should look.  Try
    733                  to make this dependency as an intermediate file, but only on
    734                  the second pass.  */
    735 
    736               if (intermed_ok)
    737                 {
    738                   if (intermediate_file == 0)
    739                     intermediate_file = alloca (sizeof (struct file));
    740 
    741                   DBS (DB_IMPLICIT,
    742                        (_("Looking for a rule with intermediate file `%s'.\n"),
    743                         name));
    744 
    745                   memset (intermediate_file, '\0', sizeof (struct file));
    746                   intermediate_file->name = name;
    747                   if (pattern_search (intermediate_file,
    748                                       0,
    749                                       depth + 1,
    750                                       recursions + 1))
    751                     {
    752                       d->intermediate_pattern = intermediate_file->name;
    753                       intermediate_file->name = strcache_add (name);
    754                       d->intermediate_file = intermediate_file;
    755                       intermediate_file = 0;
    756 
    757                       continue;
    758                     }
    759 
    760                   /* If we have tried to find P as an intermediate
    761                      file and failed, mark that name as impossible
    762                      so we won't go through the search again later.  */
    763                   if (intermediate_file->variables)
    764                     free_variable_set (intermediate_file->variables);
    765                   file_impossible (name);
    766                 }
    767 
    768               /* A dependency of this rule does not exist. Therefore,
    769                  this rule fails.  */
    770               failed = 1;
    771               break;
     789              /* Free the ns chain.  */
     790              if (dl != &dep_simple)
     791                free_dep_chain (dl);
     792
     793              if (failed)
     794                break;
    772795            }
    773796
     797          /* Reset the stem in FILE. */
     798
     799          file->stem = 0;
     800
    774801          /* This rule is no longer `in use' for recursive searches.  */
    775           rule->in_use = 0;
    776 
    777           if (failed)
    778             {
    779               /* This pattern rule does not apply. If some of its
    780                  dependencies succeeded, free the data structure
    781                  describing them.  */
    782               free_idep_chain (deps);
    783               deps = 0;
    784             }
    785           else
    786             /* This pattern rule does apply.  Stop looking for one.  */
    787             break;
    788         }
    789 
    790       /* If we found an applicable rule without
    791          intermediate files, don't try with them.  */
     802          rule->in_use = 0;
     803
     804          if (! failed)
     805            /* This pattern rule does apply.  Stop looking for one.  */
     806            break;
     807
     808          /* This pattern rule does not apply. If some of its dependencies
     809             succeeded, free the data structure describing them.  */
     810          /* free_idep_chain (deps); */
     811          deps = 0;
     812        }
     813
     814      /* If we found an applicable rule without intermediate files, don't try
     815         with them.  */
    792816      if (ri < nrules)
    793         break;
     817        break;
    794818
    795819      rule = 0;
    796820    }
    797821
    798   /* RULE is nil if the loop went all the way
    799      through the list and everything failed.  */
     822  /* RULE is nil if the loop went through the list but everything failed.  */
    800823  if (rule == 0)
    801824    goto done;
     
    803826  foundrule = ri;
    804827
    805   /* If we are recursing, store the pattern that matched
    806      FILENAME in FILE->name for use in upper levels.  */
     828  /* If we are recursing, store the pattern that matched FILENAME in
     829     FILE->name for use in upper levels.  */
    807830
    808831  if (recursions > 0)
    809832    /* Kludge-o-matic */
    810     file->name = rule->targets[matches[foundrule]];
    811 
    812   /* FOUND_FILES lists the dependencies for the rule we found.
    813      This includes the intermediate files, if any.
    814      Convert them into entries on the deps-chain of FILE.  */
    815 
    816   if (remove_explicit_deps)
     833    file->name = rule->targets[tryrules[foundrule].matches];
     834
     835  /* DEPLIST lists the prerequisites for the rule we found.  This includes the
     836     intermediate files, if any.  Convert them into entries on the deps-chain
     837     of FILE.  */
     838
     839  while (pat-- > deplist)
    817840    {
    818       /* Remove all the dependencies that didn't come from
    819          this implicit rule. */
    820 
    821       dep = file->deps;
    822       while (dep != 0)
     841      struct dep *dep;
     842      const char *s;
     843
     844      if (pat->file != 0)
    823845        {
    824           struct dep *next = dep->next;
    825           free_dep (dep);
    826           dep = next;
    827         }
    828       file->deps = 0;
    829   }
    830 
    831   expl_d = file->deps; /* We will add them at the end. */
    832   d_ptr = &file->deps;
    833 
    834   for (d = deps; d != 0; d = d->next)
    835     {
    836       const char *s;
    837 
    838       if (d->intermediate_file != 0)
    839         {
    840           /* If we need to use an intermediate file,
    841              make sure it is entered as a target, with the info that was
    842              found for it in the recursive pattern_search call.
    843              We know that the intermediate file did not already exist as
    844              a target; therefore we can assume that the deps and cmds
    845              of F below are null before we change them.  */
    846 
    847           struct file *imf = d->intermediate_file;
    848           register struct file *f = lookup_file (imf->name);
     846          /* If we need to use an intermediate file, make sure it is entered
     847             as a target, with the info that was found for it in the recursive
     848             pattern_search call.  We know that the intermediate file did not
     849             already exist as a target; therefore we can assume that the deps
     850             and cmds of F below are null before we change them.  */
     851
     852          struct file *imf = pat->file;
     853          struct file *f = lookup_file (imf->name);
    849854
    850855          /* We don't want to delete an intermediate file that happened
     
    854859            f->precious = 1;
    855860          else
    856             f = enter_file (strcache_add (imf->name));
    857 
    858           f->deps = imf->deps;
    859           f->cmds = imf->cmds;
    860           f->stem = imf->stem;
     861            f = enter_file (imf->name);
     862
     863          f->deps = imf->deps;
     864          f->cmds = imf->cmds;
     865          f->stem = imf->stem;
     866          f->variables = imf->variables;
     867          f->pat_variables = imf->pat_variables;
     868          f->pat_searched = imf->pat_searched;
    861869          f->also_make = imf->also_make;
    862870          f->is_target = 1;
    863 
    864           if (!f->precious)
     871          f->intermediate = 1;
     872          f->tried_implicit = 1;
     873
     874          imf = lookup_file (pat->pattern);
     875          if (imf != 0 && imf->precious)
     876            f->precious = 1;
     877
     878          for (dep = f->deps; dep != 0; dep = dep->next)
    865879            {
    866               imf = lookup_file (d->intermediate_pattern);
    867               if (imf != 0 && imf->precious)
    868                 f->precious = 1;
     880              dep->file = enter_file (dep->name);
     881              dep->name = 0;
     882              dep->file->tried_implicit |= dep->changed;
    869883            }
    870 
    871           f->intermediate = 1;
    872           f->tried_implicit = 1;
    873           for (dep = f->deps; dep != 0; dep = dep->next)
    874             {
    875               dep->file = enter_file (dep->name);
    876               dep->name = 0;
    877               dep->file->tried_implicit |= dep->changed;
    878             }
    879         }
     884        }
    880885
    881886      dep = alloc_dep ();
    882       dep->ignore_mtime = d->ignore_mtime;
    883       s = d->name; /* Hijacking the name. */
    884       d->name = 0;
    885       if (recursions == 0)
    886         {
    887           dep->file = lookup_file (s);
    888           if (dep->file == 0)
    889             dep->file = enter_file (s);
    890         }
     887      dep->ignore_mtime = pat->ignore_mtime;
     888      s = strcache_add (pat->name);
     889      if (recursions)
     890        dep->name = s;
    891891      else
    892         dep->name = s;
    893 
    894       if (d->intermediate_file == 0 && tryrules[foundrule]->terminal)
    895         {
    896           /* If the file actually existed (was not an intermediate file),
    897              and the rule that found it was a terminal one, then we want
    898              to mark the found file so that it will not have implicit rule
    899              search done for it.  If we are not entering a `struct file' for
    900              it now, we indicate this with the `changed' flag.  */
    901           if (dep->file == 0)
    902             dep->changed = 1;
    903           else
    904             dep->file->tried_implicit = 1;
    905         }
    906 
    907       *d_ptr = dep;
    908       d_ptr = &dep->next;
     892        {
     893          dep->file = lookup_file (s);
     894          if (dep->file == 0)
     895            dep->file = enter_file (s);
     896        }
     897
     898      if (pat->file == 0 && tryrules[foundrule].rule->terminal)
     899        {
     900          /* If the file actually existed (was not an intermediate file), and
     901             the rule that found it was a terminal one, then we want to mark
     902             the found file so that it will not have implicit rule search done
     903             for it.  If we are not entering a `struct file' for it now, we
     904             indicate this with the `changed' flag.  */
     905          if (dep->file == 0)
     906            dep->changed = 1;
     907          else
     908            dep->file->tried_implicit = 1;
     909        }
     910
     911      dep->next = file->deps;
     912      file->deps = dep;
    909913    }
    910914
    911   *d_ptr = expl_d;
    912 
    913   if (!checked_lastslash[foundrule])
     915  if (!tryrules[foundrule].checked_lastslash)
    914916    {
    915       /* Always allocate new storage, since STEM might be
    916          on the stack for an intermediate file.  */
     917      /* Always allocate new storage, since STEM might be on the stack for an
     918         intermediate file.  */
    917919      file->stem = strcache_add_len (stem, stemlen);
    918920      fullstemlen = stemlen;
     
    924926
    925927      /* We want to prepend the directory from
    926         the original FILENAME onto the stem.  */
     928        the original FILENAME onto the stem.  */
    927929      fullstemlen = dirlen + stemlen;
    928930      sp = alloca (fullstemlen + 1);
     
    942944  /* Set precious flag. */
    943945  {
    944     struct file *f = lookup_file (rule->targets[matches[foundrule]]);
     946    struct file *f = lookup_file (rule->targets[tryrules[foundrule].matches]);
    945947    if (f && f->precious)
    946948      file->precious = 1;
     
    952954  if (rule->num > 1)
    953955    for (ri = 0; ri < rule->num; ++ri)
    954       if (ri != matches[foundrule])
    955         {
    956           char *p = alloca (rule->lens[ri] + fullstemlen + 1);
    957           struct file *f;
    958           struct dep *new = alloc_dep ();
    959 
    960           /* GKM FIMXE: handle '|' here too */
    961           memcpy (p, rule->targets[ri],
     956      if (ri != tryrules[foundrule].matches)
     957        {
     958          char *nm = alloca (rule->lens[ri] + fullstemlen + 1);
     959          char *p = nm;
     960          struct file *f;
     961          struct dep *new = alloc_dep ();
     962
     963          /* GKM FIMXE: handle '|' here too */
     964          memcpy (p, rule->targets[ri],
    962965                  rule->suffixes[ri] - rule->targets[ri] - 1);
    963           p += rule->suffixes[ri] - rule->targets[ri] - 1;
    964           memcpy (p, file->stem, fullstemlen);
    965           p += fullstemlen;
    966           memcpy (p, rule->suffixes[ri],
     966          p += rule->suffixes[ri] - rule->targets[ri] - 1;
     967          memcpy (p, file->stem, fullstemlen);
     968          p += fullstemlen;
     969          memcpy (p, rule->suffixes[ri],
    967970                  rule->lens[ri] - (rule->suffixes[ri] - rule->targets[ri])+1);
    968           new->name = strcache_add (p);
    969           new->file = enter_file (new->name);
    970           new->next = file->also_make;
    971 
    972           /* Set precious flag. */
    973           f = lookup_file (rule->targets[ri]);
    974           if (f && f->precious)
     971          new->name = strcache_add (nm);
     972          new->file = enter_file (new->name);
     973          new->next = file->also_make;
     974
     975          /* Set precious flag. */
     976          f = lookup_file (rule->targets[ri]);
     977          if (f && f->precious)
    975978            new->file->precious = 1;
    976979
    977           /* Set the is_target flag so that this file is not treated
    978              as intermediate by the pattern rule search algorithm and
     980          /* Set the is_target flag so that this file is not treated as
     981             intermediate by the pattern rule search algorithm and
    979982             file_exists_p cannot pick it up yet.  */
    980983          new->file->is_target = 1;
    981984
    982           file->also_make = new;
    983         }
     985          file->also_make = new;
     986        }
    984987
    985988 done:
    986   free_idep_chain (deps);
    987989  free (tryrules);
     990  free (deplist);
    988991
    989992  return rule != 0;
Note: See TracChangeset for help on using the changeset viewer.