Ignore:
Timestamp:
Jun 20, 2012, 12:44:52 AM (13 years ago)
Author:
bird
Message:

gnumake/current -> 3.82-cvs.

Location:
vendor/gnumake/current
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • vendor/gnumake/current

    • Property svn:ignore deleted
  • vendor/gnumake/current/remake.c

    r1989 r2596  
    11/* Basic dependency engine 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
     
    8484{
    8585  int t = touch_flag, q = question_flag, n = just_print_flag;
    86   unsigned int j = job_slots;
    8786  int status = -1;
    8887
     
    136135              unsigned int ocommands_started;
    137136              int x;
     137
     138              file->dontcare = g->dontcare;
     139
    138140              check_renamed (file);
    139141              if (rebuilding_makefiles)
     
    209211              any_not_updated |= !file->updated;
    210212
     213              file->dontcare = 0;
     214
    211215              if (stop)
    212216                break;
     
    265269      question_flag = q;
    266270      just_print_flag = n;
    267       job_slots = j;
    268271    }
    269272
     
    298301  if (f->considered == considered)
    299302    {
    300       DBF (DB_VERBOSE, _("Pruning file `%s'.\n"));
    301       return f->command_state == cs_finished ? f->update_status : 0;
     303      /* Check for the case where a target has been tried and failed but
     304         the diagnostics hasn't been issued. If we need the diagnostics
     305         then we will have to continue. */
     306      if (!(f->updated && f->update_status > 0 && !f->dontcare && f->no_diag))
     307        {
     308          DBF (DB_VERBOSE, _("Pruning file `%s'.\n"));
     309          return f->command_state == cs_finished ? f->update_status : 0;
     310        }
    302311    }
    303312
     
    316325      /* If we got an error, don't bother with double_colon etc.  */
    317326      if (status != 0 && !keep_going_flag)
    318         return status;
     327        return status;
    319328
    320329      if (f->command_state == cs_running
     
    348357
    349358static void
    350 complain (const struct file *file)
     359complain (struct file *file)
    351360{
    352361  const char *msg_noparent
     
    355364    = _("%sNo rule to make target `%s', needed by `%s'%s");
    356365
    357   if (!keep_going_flag)
    358     {
     366  /* If this file has no_diag set then it means we tried to update it
     367     before in the dontcare mode and failed. The target that actually
     368     failed is not necessarily this file but could be one of its direct
     369     or indirect dependencies. So traverse this file's dependencies and
     370     find the one that actually caused the failure. */
     371
     372  struct dep *d;
     373
     374  for (d = file->deps; d != 0; d = d->next)
     375    {
     376      if (d->file->updated && d->file->update_status > 0 && file->no_diag)
     377        {
     378          complain (d->file);
     379          break;
     380        }
     381    }
     382
     383  if (d == 0)
     384    {
     385      /* Didn't find any dependencies to complain about. */
     386      if (!keep_going_flag)
     387        {
     388          if (file->parent == 0)
     389            fatal (NILF, msg_noparent, "", file->name, "");
     390
     391          fatal (NILF, msg_parent, "", file->name, file->parent->name, "");
     392        }
     393
    359394      if (file->parent == 0)
    360         fatal (NILF, msg_noparent, "", file->name, "");
    361 
    362       fatal (NILF, msg_parent, "", file->name, file->parent->name, "");
    363     }
    364 
    365   if (file->parent == 0)
    366     error (NILF, msg_noparent, "*** ", file->name, ".");
    367   else
    368     error (NILF, msg_parent, "*** ", file->name, file->parent->name, ".");
     395        error (NILF, msg_noparent, "*** ", file->name, ".");
     396      else
     397        error (NILF, msg_parent, "*** ", file->name, file->parent->name, ".");
     398
     399      file->no_diag = 0;
     400    }
    369401}
    370402
     
    374406update_file_1 (struct file *file, unsigned int depth)
    375407{
    376   register FILE_TIMESTAMP this_mtime;
     408  FILE_TIMESTAMP this_mtime;
    377409  int noexist, must_make, deps_changed;
    378410  int dep_status = 0;
    379   register struct dep *d, *lastd;
     411  struct file *ofile;
     412  struct dep *d, *ad;
     413  struct dep amake;
    380414  int running = 0;
    381415
     
    389423               _("Recently tried and failed to update file `%s'.\n"));
    390424
    391           /* If the file we tried to make is marked dontcare then no message
     425          /* If the file we tried to make is marked no_diag then no message
    392426             was printed about it when it failed during the makefile rebuild.
    393427             If we're trying to build it again in the normal rebuild, print a
    394428             message now.  */
    395           if (file->dontcare && !rebuilding_makefiles)
    396             {
    397               file->dontcare = 0;
     429          if (file->no_diag && !file->dontcare)
    398430              complain (file);
    399             }
    400431
    401432          return file->update_status;
     
    421452    }
    422453
     454  /* Determine whether the diagnostics will be issued should this update
     455     fail. */
     456  file->no_diag = file->dontcare;
     457
    423458  ++depth;
    424459
    425460  /* Notice recursive update of the same file.  */
    426461  start_updating (file);
     462
     463  /* We might change file if we find a different one via vpath;
     464     remember this one to turn off updating.  */
     465  ofile = file;
    427466
    428467  /* Looking at the file's modtime beforehand allows the possibility
     
    468507    }
    469508
    470   /* Update all non-intermediate files we depend on, if necessary,
    471      and see whether any of them is more recent than this file.  */
    472 
    473   lastd = 0;
    474   d = file->deps;
    475   while (d != 0)
    476     {
    477       FILE_TIMESTAMP mtime;
    478       int maybe_make;
    479       int dontcare = 0;
    480 
    481       check_renamed (d->file);
    482 
    483       mtime = file_mtime (d->file);
    484       check_renamed (d->file);
    485 
    486       if (is_updating (d->file))
    487         {
    488           error (NILF, _("Circular %s <- %s dependency dropped."),
    489                  file->name, d->file->name);
    490           /* We cannot free D here because our the caller will still have
    491              a reference to it when we were called recursively via
    492              check_dep below.  */
    493           if (lastd == 0)
    494             file->deps = d->next;
    495           else
    496             lastd->next = d->next;
    497           d = d->next;
    498           continue;
    499         }
    500 
    501       d->file->parent = file;
    502       maybe_make = must_make;
    503 
    504       /* Inherit dontcare flag from our parent. */
    505       if (rebuilding_makefiles)
     509  /* Update all non-intermediate files we depend on, if necessary, and see
     510     whether any of them is more recent than this file.  We need to walk our
     511     deps, AND the deps of any also_make targets to ensure everything happens
     512     in the correct order.  */
     513
     514  amake.file = file;
     515  amake.next = file->also_make;
     516  ad = &amake;
     517  while (ad)
     518    {
     519      struct dep *lastd = 0;
     520
     521      /* Find the deps we're scanning */
     522      d = ad->file->deps;
     523      ad = ad->next;
     524
     525      while (d)
    506526        {
    507           dontcare = d->file->dontcare;
    508           d->file->dontcare = file->dontcare;
     527          FILE_TIMESTAMP mtime;
     528          int maybe_make;
     529          int dontcare = 0;
     530
     531          check_renamed (d->file);
     532
     533          mtime = file_mtime (d->file);
     534          check_renamed (d->file);
     535
     536          if (is_updating (d->file))
     537            {
     538              error (NILF, _("Circular %s <- %s dependency dropped."),
     539                     file->name, d->file->name);
     540              /* We cannot free D here because our the caller will still have
     541                 a reference to it when we were called recursively via
     542                 check_dep below.  */
     543              if (lastd == 0)
     544                file->deps = d->next;
     545              else
     546                lastd->next = d->next;
     547              d = d->next;
     548              continue;
     549            }
     550
     551          d->file->parent = file;
     552          maybe_make = must_make;
     553
     554          /* Inherit dontcare flag from our parent. */
     555          if (rebuilding_makefiles)
     556            {
     557              dontcare = d->file->dontcare;
     558              d->file->dontcare = file->dontcare;
     559            }
     560
     561          dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make);
     562
     563          /* Restore original dontcare flag. */
     564          if (rebuilding_makefiles)
     565            d->file->dontcare = dontcare;
     566
     567          if (! d->ignore_mtime)
     568            must_make = maybe_make;
     569
     570          check_renamed (d->file);
     571
     572          {
     573            register struct file *f = d->file;
     574            if (f->double_colon)
     575              f = f->double_colon;
     576            do
     577              {
     578                running |= (f->command_state == cs_running
     579                            || f->command_state == cs_deps_running);
     580                f = f->prev;
     581              }
     582            while (f != 0);
     583          }
     584
     585          if (dep_status != 0 && !keep_going_flag)
     586            break;
     587
     588          if (!running)
     589            /* The prereq is considered changed if the timestamp has changed while
     590               it was built, OR it doesn't exist.  */
     591            d->changed = ((file_mtime (d->file) != mtime)
     592                          || (mtime == NONEXISTENT_MTIME));
     593
     594          lastd = d;
     595          d = d->next;
    509596        }
    510 
    511 
    512       dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make);
    513 
    514       /* Restore original dontcare flag. */
    515       if (rebuilding_makefiles)
    516         d->file->dontcare = dontcare;
    517 
    518       if (! d->ignore_mtime)
    519         must_make = maybe_make;
    520 
    521       check_renamed (d->file);
    522 
    523       {
    524         register struct file *f = d->file;
    525         if (f->double_colon)
    526           f = f->double_colon;
    527         do
    528           {
    529             running |= (f->command_state == cs_running
    530                         || f->command_state == cs_deps_running);
    531             f = f->prev;
    532           }
    533         while (f != 0);
    534       }
    535 
    536       if (dep_status != 0 && !keep_going_flag)
    537         break;
    538 
    539       if (!running)
    540         /* The prereq is considered changed if the timestamp has changed while
    541            it was built, OR it doesn't exist.  */
    542         d->changed = ((file_mtime (d->file) != mtime)
    543                       || (mtime == NONEXISTENT_MTIME));
    544 
    545       lastd = d;
    546       d = d->next;
    547597    }
    548598
     
    600650
    601651  finish_updating (file);
     652  finish_updating (ofile);
    602653
    603654  DBF (DB_VERBOSE, _("Finished prerequisites of target file `%s'.\n"));
     
    859910         would have been updated. */
    860911
    861       if (question_flag || just_print_flag || touch_flag)
     912      if ((question_flag || just_print_flag || touch_flag) && file->cmds)
    862913        {
    863914          for (i = file->cmds->ncommand_lines; i > 0; --i)
     
    937988           FILE_TIMESTAMP this_mtime, int *must_make_ptr)
    938989{
     990  struct file *ofile;
    939991  struct dep *d;
    940992  int dep_status = 0;
     
    942994  ++depth;
    943995  start_updating (file);
     996
     997  /* We might change file if we find a different one via vpath;
     998     remember this one to turn off updating.  */
     999  ofile = file;
    9441000
    9451001  if (file->phony || !file->intermediate)
     
    9871043             necessary, and see whether any of them is more recent than the
    9881044             file on whose behalf we are checking.  */
    989           struct dep *lastd;
     1045          struct dep *ld;
    9901046          int deps_running = 0;
    9911047
    992           /* Reset this target's state so that we check it fresh.  It could be
    993              that it's already been checked as part of an order-only
     1048          /* If this target is not running, set it's state so that we check it
     1049             fresh.  It could be it was checked as part of an order-only
    9941050             prerequisite and so wasn't rebuilt then, but should be now.  */
    995           set_command_state (file, cs_not_started);
    996 
    997           lastd = 0;
     1051          if (file->command_state != cs_running)
     1052            set_command_state (file, cs_not_started);
     1053
     1054          ld = 0;
    9981055          d = file->deps;
    9991056          while (d != 0)
     
    10051062                  error (NILF, _("Circular %s <- %s dependency dropped."),
    10061063                         file->name, d->file->name);
    1007                   if (lastd == 0)
     1064                  if (ld == 0)
    10081065                    {
    10091066                      file->deps = d->next;
     
    10131070                  else
    10141071                    {
    1015                       lastd->next = d->next;
     1072                      ld->next = d->next;
    10161073                      free_dep (d);
    1017                       d = lastd->next;
     1074                      d = ld->next;
    10181075                    }
    10191076                  continue;
     
    10341091                deps_running = 1;
    10351092
    1036               lastd = d;
     1093              ld = d;
    10371094              d = d->next;
    10381095            }
     
    10471104
    10481105  finish_updating (file);
     1106  finish_updating (ofile);
     1107
    10491108  return dep_status;
    10501109}
     
    12301289        {
    12311290          /* If name_mtime failed, search VPATH.  */
    1232           const char *name = vpath_search (file->name, &mtime);
     1291          const char *name = vpath_search (file->name, &mtime, NULL, NULL);
    12331292          if (name
    12341293              /* Last resort, is it a library (-lxxx)?  */
     
    14731532    };
    14741533
    1475   static char *libpatterns = NULL;
    1476 
    1477   const char *libname = lib+2;  /* Name without the '-l'.  */
     1534  const char *file = 0;
     1535  char *libpatterns;
    14781536  FILE_TIMESTAMP mtime;
    14791537
     
    14821540  const char *p2;
    14831541  unsigned int len;
     1542  unsigned int liblen;
     1543
     1544  /* Information about the earliest (in the vpath sequence) match.  */
     1545  unsigned int best_vpath, best_path;
     1546  unsigned int std_dirs = 0;
    14841547
    14851548  char **dp;
    14861549
    1487   /* If we don't have libpatterns, get it.  */
    1488   if (!libpatterns)
    1489     {
    1490       int save = warn_undefined_variables_flag;
    1491       warn_undefined_variables_flag = 0;
    1492 
    1493       libpatterns = xstrdup (variable_expand ("$(strip $(.LIBPATTERNS))"));
    1494 
    1495       warn_undefined_variables_flag = save;
    1496     }
    1497 
    1498   /* Loop through all the patterns in .LIBPATTERNS, and search on each one.  */
     1550  libpatterns = xstrdup (variable_expand ("$(.LIBPATTERNS)"));
     1551
     1552  /* Skip the '-l'.  */
     1553  lib += 2;
     1554  liblen = strlen (lib);
     1555
     1556  /* Loop through all the patterns in .LIBPATTERNS, and search on each one.
     1557     To implement the linker-compatible behavior we have to search through
     1558     all entries in .LIBPATTERNS and choose the "earliest" one.  */
    14991559  p2 = libpatterns;
    15001560  while ((p = find_next_token (&p2, &len)) != 0)
     
    15051565      char *libbuf = variable_expand ("");
    15061566
    1507       /* Expand the pattern using LIBNAME as a replacement.  */
     1567      /* Expand the pattern using LIB as a replacement.  */
    15081568      {
    15091569        char c = p[len];
     
    15141574        if (!p3)
    15151575          {
    1516             /* Give a warning if there is no pattern, then remove the
    1517                pattern so it's ignored next time.  */
     1576            /* Give a warning if there is no pattern.  */
    15181577            error (NILF, _(".LIBPATTERNS element `%s' is not a pattern"), p);
    1519             for (; len; --len, ++p)
    1520               *p = ' ';
    1521             *p = c;
     1578            p[len] = c;
    15221579            continue;
    15231580          }
    15241581        p4 = variable_buffer_output (libbuf, p, p3-p);
    1525         p4 = variable_buffer_output (p4, libname, strlen (libname));
     1582        p4 = variable_buffer_output (p4, lib, liblen);
    15261583        p4 = variable_buffer_output (p4, p3+1, len - (p3-p));
    15271584        p[len] = c;
     
    15341591          if (mtime_ptr != 0)
    15351592            *mtime_ptr = mtime;
    1536           return strcache_add (libbuf);
     1593          file = strcache_add (libbuf);
     1594          /* This by definition will have the best index, so stop now.  */
     1595          break;
    15371596        }
    15381597
     
    15401599
    15411600      {
    1542         const char *file = vpath_search (libbuf, mtime_ptr);
    1543         if (file)
    1544           return file;
     1601        unsigned int vpath_index, path_index;
     1602        const char* f = vpath_search (libbuf, mtime_ptr ? &mtime : NULL,
     1603                                      &vpath_index, &path_index);
     1604        if (f)
     1605          {
     1606            /* If we have a better match, record it.  */
     1607            if (file == 0 ||
     1608                vpath_index < best_vpath ||
     1609                (vpath_index == best_vpath && path_index < best_path))
     1610              {
     1611                file = f;
     1612                best_vpath = vpath_index;
     1613                best_path = path_index;
     1614
     1615                if (mtime_ptr != 0)
     1616                  *mtime_ptr = mtime;
     1617              }
     1618          }
    15451619      }
    15461620
     
    15481622
    15491623      if (!buflen)
    1550         {
    1551           for (dp = dirs; *dp != 0; ++dp)
    1552             {
    1553               int l = strlen (*dp);
    1554               if (l > libdir_maxlen)
    1555                 libdir_maxlen = l;
    1556             }
    1557           buflen = strlen (libbuf);
    1558           buf = xmalloc(libdir_maxlen + buflen + 2);
    1559         }
     1624        {
     1625          for (dp = dirs; *dp != 0; ++dp)
     1626            {
     1627              int l = strlen (*dp);
     1628              if (l > libdir_maxlen)
     1629                libdir_maxlen = l;
     1630              std_dirs++;
     1631            }
     1632          buflen = strlen (libbuf);
     1633          buf = xmalloc(libdir_maxlen + buflen + 2);
     1634        }
    15601635      else if (buflen < strlen (libbuf))
    1561         {
    1562           buflen = strlen (libbuf);
    1563           buf = xrealloc (buf, libdir_maxlen + buflen + 2);
    1564         }
    1565 
    1566       for (dp = dirs; *dp != 0; ++dp)
    1567         {
    1568           sprintf (buf, "%s/%s", *dp, libbuf);
    1569           mtime = name_mtime (buf);
    1570           if (mtime != NONEXISTENT_MTIME)
    1571             {
    1572               if (mtime_ptr != 0)
    1573                 *mtime_ptr = mtime;
    1574               return strcache_add (buf);
    1575             }
    1576         }
    1577     }
    1578 
    1579   return 0;
     1636        {
     1637          buflen = strlen (libbuf);
     1638          buf = xrealloc (buf, libdir_maxlen + buflen + 2);
     1639        }
     1640
     1641      {
     1642        /* Use the last std_dirs index for standard directories. This
     1643           was it will always be greater than the VPATH index.  */
     1644        unsigned int vpath_index = ~((unsigned int)0) - std_dirs;
     1645
     1646        for (dp = dirs; *dp != 0; ++dp)
     1647          {
     1648            sprintf (buf, "%s/%s", *dp, libbuf);
     1649            mtime = name_mtime (buf);
     1650            if (mtime != NONEXISTENT_MTIME)
     1651              {
     1652                if (file == 0 || vpath_index < best_vpath)
     1653                  {
     1654                    file = strcache_add (buf);
     1655                    best_vpath = vpath_index;
     1656
     1657                    if (mtime_ptr != 0)
     1658                      *mtime_ptr = mtime;
     1659                  }
     1660              }
     1661
     1662            vpath_index++;
     1663          }
     1664      }
     1665
     1666    }
     1667
     1668  free (libpatterns);
     1669  return file;
    15801670}
Note: See TracChangeset for help on using the changeset viewer.