Ignore:
Timestamp:
May 16, 2005, 6:54:02 PM (20 years ago)
Author:
bird
Message:

Current make snaphot, 2005-05-16.

Location:
branches/GNU/src/gmake
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/gmake

    • Property svn:ignore
      •  

        old new  
        3434README.DOS
        3535README.W32
         36README.OS2
        3637aclocal.m4
        3738autom4te.cache
  • branches/GNU/src/gmake/remake.c

    r153 r280  
    7575/* Remake all the goals in the `struct dep' chain GOALS.  Return -1 if nothing
    7676   was done, 0 if all goals were updated successfully, or 1 if a goal failed.
    77    If MAKEFILES is nonzero, these goals are makefiles, so -t, -q, and -n should
    78    be disabled for them unless they were also command-line targets, and we
    79    should only make one goal at a time and return as soon as one goal whose
    80    `changed' member is nonzero is successfully made.  */
     77
     78   If rebuilding_makefiles is nonzero, these goals are makefiles, so -t, -q,
     79   and -n should be disabled for them unless they were also command-line
     80   targets, and we should only make one goal at a time and return as soon as
     81   one goal whose `changed' member is nonzero is successfully made.  */
    8182
    8283int
    83 update_goal_chain (struct dep *goals, int makefiles)
     84update_goal_chain (struct dep *goals)
    8485{
    8586  int t = touch_flag, q = question_flag, n = just_print_flag;
     
    8788  int status = -1;
    8889
    89 #define MTIME(file) (makefiles ? file_mtime_no_search (file) \
     90#define MTIME(file) (rebuilding_makefiles ? file_mtime_no_search (file) \
    9091                     : file_mtime (file))
    9192
     
    137138              int x;
    138139              check_renamed (file);
    139               if (makefiles)
     140              if (rebuilding_makefiles)
    140141                {
    141142                  if (file->cmd_target)
     
    154155              ocommands_started = commands_started;
    155156
    156               x = update_file (file, makefiles ? 1 : 0);
     157              x = update_file (file, rebuilding_makefiles ? 1 : 0);
    157158              check_renamed (file);
    158159
     
    177178                         matter how much more we run, since we already know
    178179                         the answer to return.  */
    179                       stop = (!keep_going_flag && !question_flag
    180                               && !makefiles);
     180                      stop = (question_flag && !keep_going_flag
     181                              && !rebuilding_makefiles);
    181182                    }
    182183                  else
     
    194195                             If STATUS is changed, we will get re-exec'd, and
    195196                             enter an infinite loop.  */
    196                           if (!makefiles
     197                          if (!rebuilding_makefiles
    197198                              || (!just_print_flag && !question_flag))
    198199                            status = 0;
    199                           if (makefiles && file->dontcare)
     200                          if (rebuilding_makefiles && file->dontcare)
    200201                            /* This is a default makefile; stop remaking.  */
    201202                            stop = 1;
     
    220221                 print a message saying nothing needs doing.  */
    221222
    222               if (!makefiles
     223              if (!rebuilding_makefiles
    223224                  /* If the update_status is zero, we updated successfully
    224225                     or not at all.  G->changed will have been set above if
     
    259260    }
    260261
    261   if (makefiles)
     262  if (rebuilding_makefiles)
    262263    {
    263264      touch_flag = t;
     
    309310      check_renamed (f);
    310311
     312      /* If we got an error, don't bother with double_colon etc.  */
    311313      if (status != 0 && !keep_going_flag)
    312         break;
     314        return status;
    313315
    314316      if (f->command_state == cs_running
     
    324326  /* Process the remaining rules in the double colon chain so they're marked
    325327     considered.  Start their prerequisites, too.  */
    326   for (; f != 0 ; f = f->prev)
    327     {
    328       struct dep *d;
    329 
    330       f->considered = considered;
    331 
    332       for (d = f->deps; d != 0; d = d->next)
    333         status |= update_file (d->file, depth + 1);
    334     }
     328  if (file->double_colon)
     329    for (; f != 0 ; f = f->prev)
     330      {
     331        struct dep *d;
     332
     333        f->considered = considered;
     334
     335        for (d = f->deps; d != 0; d = d->next)
     336          status |= update_file (d->file, depth + 1);
     337      }
    335338
    336339  return status;
    337340}
    338341
     342
     343/* Show a message stating the target failed to build.  */
     344
     345static void
     346complain (const struct file *file)
     347{
     348  const char *msg_noparent
     349    = _("%sNo rule to make target `%s'%s");
     350  const char *msg_parent
     351    = _("%sNo rule to make target `%s', needed by `%s'%s");
     352
     353  if (!keep_going_flag)
     354    {
     355      if (file->parent == 0)
     356        fatal (NILF, msg_noparent, "", file->name, "");
     357
     358      fatal (NILF, msg_parent, "", file->name, file->parent->name, "");
     359    }
     360
     361  if (file->parent == 0)
     362    error (NILF, msg_noparent, "*** ", file->name, ".");
     363  else
     364    error (NILF, msg_parent, "*** ", file->name, file->parent->name, ".");
     365}
    339366
    340367/* Consider a single `struct file' and update it as appropriate.  */
     
    357384          DBF (DB_VERBOSE,
    358385               _("Recently tried and failed to update file `%s'.\n"));
     386
     387          /* If the file we tried to make is marked dontcare then no message
     388             was printed about it when it failed during the makefile rebuild.
     389             If we're trying to build it again in the normal rebuild, print a
     390             message now.  */
     391          if (file->dontcare && !rebuilding_makefiles)
     392            {
     393              file->dontcare = 0;
     394              complain (file);
     395            }
     396
    359397          return file->update_status;
    360398        }
     
    435473      FILE_TIMESTAMP mtime;
    436474      int maybe_make;
     475      int dontcare = 0;
    437476
    438477      check_renamed (d->file);
     
    458497      d->file->parent = file;
    459498      maybe_make = must_make;
     499
     500      /* Inherit dontcare flag from our parent. */
     501      if (rebuilding_makefiles)
     502        {
     503          dontcare = d->file->dontcare;
     504          d->file->dontcare = file->dontcare;
     505        }
     506
     507
    460508      dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make);
     509
     510      /* Restore original dontcare flag. */
     511      if (rebuilding_makefiles)
     512        d->file->dontcare = dontcare;
     513
    461514      if (! d->ignore_mtime)
    462515        must_make = maybe_make;
     
    495548        if (d->file->intermediate)
    496549          {
     550            int dontcare = 0;
     551
    497552            FILE_TIMESTAMP mtime = file_mtime (d->file);
    498553            check_renamed (d->file);
    499554            d->file->parent = file;
     555
     556            /* Inherit dontcare flag from our parent. */
     557            if (rebuilding_makefiles)
     558              {
     559                dontcare = d->file->dontcare;
     560                d->file->dontcare = file->dontcare;
     561              }
     562
     563
    500564            dep_status |= update_file (d->file, depth);
     565
     566            /* Restore original dontcare flag. */
     567            if (rebuilding_makefiles)
     568              d->file->dontcare = dontcare;
     569
    501570            check_renamed (d->file);
    502571
     
    846915  start_updating (file);
    847916
    848   if (!file->intermediate)
    849     /* If this is a non-intermediate file, update it and record
    850        whether it is newer than THIS_MTIME.  */
    851     {
     917  if (file->phony || !file->intermediate)
     918    {
     919      /* If this is a non-intermediate file, update it and record
     920         whether it is newer than THIS_MTIME.  */
    852921      FILE_TIMESTAMP mtime;
    853922      dep_status = update_file (file, depth);
     
    10161085      else
    10171086        {
    1018           const char *msg_noparent
    1019             = _("%sNo rule to make target `%s'%s");
    1020           const char *msg_parent
    1021             = _("%sNo rule to make target `%s', needed by `%s'%s");
    1022 
    10231087          /* This is a dependency file we cannot remake.  Fail.  */
    1024           if (!keep_going_flag && !file->dontcare)
    1025             {
    1026               if (file->parent == 0)
    1027                 fatal (NILF, msg_noparent, "", file->name, "");
    1028 
    1029               fatal (NILF, msg_parent, "", file->name, file->parent->name, "");
    1030             }
    1031 
    1032           if (!file->dontcare)
    1033             {
    1034               if (file->parent == 0)
    1035                 error (NILF, msg_noparent, "*** ", file->name, ".");
    1036               else
    1037                 error (NILF, msg_parent, "*** ",
    1038                        file->name, file->parent->name, ".");
    1039             }
     1088          if (!rebuilding_makefiles || !file->dontcare)
     1089            complain (file);
    10401090          file->update_status = 2;
    10411091        }
     
    12731323/* Return the mtime of the file or archive-member reference NAME.  */
    12741324
     1325/* First, we check with stat().  If the file does not exist, then we return
     1326   NONEXISTENT_MTIME.  If it does, and the symlink check flag is set, then
     1327   examine each indirection of the symlink and find the newest mtime.
     1328   This causes one duplicate stat() when -L is being used, but the code is
     1329   much cleaner.  */
     1330
    12751331static FILE_TIMESTAMP
    12761332name_mtime (char *name)
    12771333{
     1334  FILE_TIMESTAMP mtime;
    12781335  struct stat st;
    12791336  int e;
     
    12831340    {
    12841341      if (errno != ENOENT && errno != ENOTDIR)
    1285         perror_with_name ("stat:", name);
     1342        perror_with_name ("stat: ", name);
    12861343      return NONEXISTENT_MTIME;
    12871344    }
    1288 
    1289   return FILE_TIMESTAMP_STAT_MODTIME (name, st);
     1345  mtime = FILE_TIMESTAMP_STAT_MODTIME (name, st);
     1346
     1347#ifdef MAKE_SYMLINKS
     1348#ifndef S_ISLNK
     1349# define S_ISLNK(_m)     (((_m)&S_IFMT)==S_IFLNK)
     1350#endif
     1351  if (check_symlink_flag)
     1352    {
     1353      PATH_VAR (lpath);
     1354
     1355      /* Check each symbolic link segment (if any).  Find the latest mtime
     1356         amongst all of them (and the target file of course).
     1357         Note that we have already successfully dereferenced all the links
     1358         above.  So, if we run into any error trying to lstat(), or
     1359         readlink(), or whatever, something bizarre-o happened.  Just give up
     1360         and use whatever mtime we've already computed at that point.  */
     1361      strcpy (lpath, name);
     1362      while (1)
     1363        {
     1364          FILE_TIMESTAMP ltime;
     1365          PATH_VAR (lbuf);
     1366          long llen;
     1367          char *p;
     1368
     1369          EINTRLOOP (e, lstat (lpath, &st));
     1370          if (e)
     1371            {
     1372              /* Eh?  Just take what we have.  */
     1373              perror_with_name ("lstat: ", lpath);
     1374              break;
     1375            }
     1376
     1377          /* If this is not a symlink, we're done (we started with the real
     1378             file's mtime so we don't need to test it again).  */
     1379          if (!S_ISLNK (st.st_mode))
     1380            break;
     1381
     1382          /* If this mtime is newer than what we had, keep the new one.  */
     1383          ltime = FILE_TIMESTAMP_STAT_MODTIME (lpath, st);
     1384          if (ltime > mtime)
     1385            mtime = ltime;
     1386
     1387          /* Set up to check the file pointed to by this link.  */
     1388          EINTRLOOP (llen, readlink (lpath, lbuf, GET_PATH_MAX));
     1389          if (llen < 0)
     1390            {
     1391              /* Eh?  Just take what we have.  */
     1392              perror_with_name ("readlink: ", lpath);
     1393              break;
     1394            }
     1395          lbuf[llen] = '\0';
     1396
     1397          /* If the target is fully-qualified or the source is just a
     1398             filename, then the new path is the target.  Otherwise it's the
     1399             source directory plus the target.  */
     1400          if (lbuf[0] == '/' || (p = strrchr (lpath, '/')) == NULL)
     1401            strcpy (lpath, lbuf);
     1402          else if ((p - lpath) + llen + 2 > GET_PATH_MAX)
     1403            /* Eh?  Path too long!  Again, just go with what we have.  */
     1404            break;
     1405          else
     1406            /* Create the next step in the symlink chain.  */
     1407            strcpy (p+1, lbuf);
     1408        }
     1409    }
     1410#endif
     1411
     1412  return mtime;
    12901413}
    12911414
Note: See TracChangeset for help on using the changeset viewer.