VirtualBox

Changeset 3138 in kBuild for vendor/gnumake/current/remake.c


Ignore:
Timestamp:
Mar 12, 2018 7:32:29 PM (7 years ago)
Author:
bird
Message:

Imported make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6) from https://git.savannah.gnu.org/git/make.git.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/gnumake/current/remake.c

    r2596 r3138  
    11/* Basic dependency engine for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53This file is part of GNU Make.
    64
     
    1715this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1816
    19 #include "make.h"
     17#include "makeint.h"
    2018#include "filedef.h"
    2119#include "job.h"
     
    4038#endif
    4139
    42 extern int try_implicit_rule (struct file *file, unsigned int depth);
    43 
    4440
    4541/* The test for circular dependencies is based on the 'updating' bit in
    46    `struct file'.  However, double colon targets have seperate `struct
     42   'struct file'.  However, double colon targets have separate 'struct
    4743   file's; make sure we always use the base of the double colon chain. */
    4844
     
    5854unsigned int commands_started = 0;
    5955
    60 /* Current value for pruning the scan of the goal chain (toggle 0/1).  */
    61 static unsigned int considered;
    62 
    63 static int update_file (struct file *file, unsigned int depth);
    64 static int update_file_1 (struct file *file, unsigned int depth);
    65 static int check_dep (struct file *file, unsigned int depth,
    66                       FILE_TIMESTAMP this_mtime, int *must_make_ptr);
    67 static int touch_file (struct file *file);
     56/* Set to the goal dependency.  Mostly needed for remaking makefiles.  */
     57static struct goaldep *goal_list;
     58static struct dep *goal_dep;
     59
     60/* Current value for pruning the scan of the goal chain.
     61   All files start with considered == 0.  */
     62static unsigned int considered = 0;
     63
     64static enum update_status update_file (struct file *file, unsigned int depth);
     65static enum update_status update_file_1 (struct file *file, unsigned int depth);
     66static enum update_status check_dep (struct file *file, unsigned int depth,
     67                                     FILE_TIMESTAMP this_mtime, int *must_make);
     68static enum update_status touch_file (struct file *file);
    6869static void remake_file (struct file *file);
    6970static FILE_TIMESTAMP name_mtime (const char *name);
     
    7273
    7374
    74 /* Remake all the goals in the `struct dep' chain GOALS.  Return -1 if nothing
     75/* Remake all the goals in the 'struct dep' chain GOALS.  Return -1 if nothing
    7576   was done, 0 if all goals were updated successfully, or 1 if a goal failed.
    7677
     
    7879   and -n should be disabled for them unless they were also command-line
    7980   targets, and we should only make one goal at a time and return as soon as
    80    one goal whose `changed' member is nonzero is successfully made.  */
    81 
    82 int
    83 update_goal_chain (struct dep *goals)
     81   one goal whose 'changed' member is nonzero is successfully made.  */
     82
     83enum update_status
     84update_goal_chain (struct goaldep *goaldeps)
    8485{
    8586  int t = touch_flag, q = question_flag, n = just_print_flag;
    86   int status = -1;
    87 
    88 #define MTIME(file) (rebuilding_makefiles ? file_mtime_no_search (file) \
    89                      : file_mtime (file))
     87  enum update_status status = us_none;
    9088
    9189  /* Duplicate the chain so we can remove things from it.  */
    9290
    93   goals = copy_dep_chain (goals);
    94 
    95   {
    96     /* Clear the `changed' flag of each goal in the chain.
    97        We will use the flag below to notice when any commands
    98        have actually been run for a target.  When no commands
    99        have been run, we give an "up to date" diagnostic.  */
    100 
    101     struct dep *g;
    102     for (g = goals; g != 0; g = g->next)
    103       g->changed = 0;
    104   }
    105 
    106   /* All files start with the considered bit 0, so the global value is 1.  */
    107   considered = 1;
     91  struct dep *goals = copy_dep_chain ((struct dep *)goaldeps);
     92
     93  goal_list = rebuilding_makefiles ? goaldeps : NULL;
     94
     95#define MTIME(file) (rebuilding_makefiles ? file_mtime_no_search (file) \
     96                     : file_mtime (file))
     97
     98  /* Start a fresh batch of consideration.  */
     99  ++considered;
    108100
    109101  /* Update all the goals until they are all finished.  */
     
    124116      g = goals;
    125117      while (g != 0)
    126         {
    127           /* Iterate over all double-colon entries for this file.  */
    128           struct file *file;
    129           int stop = 0, any_not_updated = 0;
    130 
    131           for (file = g->file->double_colon ? g->file->double_colon : g->file;
    132                file != NULL;
    133                file = file->prev)
    134             {
    135               unsigned int ocommands_started;
    136               int x;
    137 
    138               file->dontcare = g->dontcare;
    139 
    140               check_renamed (file);
    141               if (rebuilding_makefiles)
    142                 {
    143                   if (file->cmd_target)
    144                     {
    145                       touch_flag = t;
    146                       question_flag = q;
    147                       just_print_flag = n;
    148                     }
    149                   else
    150                     touch_flag = question_flag = just_print_flag = 0;
    151                 }
    152 
    153               /* Save the old value of `commands_started' so we can compare
    154                  later.  It will be incremented when any commands are
    155                  actually run.  */
    156               ocommands_started = commands_started;
    157 
    158               x = update_file (file, rebuilding_makefiles ? 1 : 0);
    159               check_renamed (file);
    160 
    161               /* Set the goal's `changed' flag if any commands were started
    162                  by calling update_file above.  We check this flag below to
    163                  decide when to give an "up to date" diagnostic.  */
     118        {
     119          /* Iterate over all double-colon entries for this file.  */
     120          struct file *file;
     121          int stop = 0, any_not_updated = 0;
     122
     123          goal_dep = g;
     124
     125          for (file = g->file->double_colon ? g->file->double_colon : g->file;
     126               file != NULL;
     127               file = file->prev)
     128            {
     129              unsigned int ocommands_started;
     130              enum update_status fail;
     131
     132              file->dontcare = ANY_SET (g->flags, RM_DONTCARE);
     133
     134              check_renamed (file);
     135              if (rebuilding_makefiles)
     136                {
     137                  if (file->cmd_target)
     138                    {
     139                      touch_flag = t;
     140                      question_flag = q;
     141                      just_print_flag = n;
     142                    }
     143                  else
     144                    touch_flag = question_flag = just_print_flag = 0;
     145                }
     146
     147              /* Save the old value of 'commands_started' so we can compare
     148                 later.  It will be incremented when any commands are
     149                 actually run.  */
     150              ocommands_started = commands_started;
     151
     152              fail = update_file (file, rebuilding_makefiles ? 1 : 0);
     153              check_renamed (file);
     154
     155              /* Set the goal's 'changed' flag if any commands were started
     156                 by calling update_file above.  We check this flag below to
     157                 decide when to give an "up to date" diagnostic.  */
    164158              if (commands_started > ocommands_started)
    165159                g->changed = 1;
    166160
    167               /* If we updated a file and STATUS was not already 1, set it to
    168                  1 if updating failed, or to 0 if updating succeeded.  Leave
    169                  STATUS as it is if no updating was done.  */
    170 
    171               stop = 0;
    172               if ((x != 0 || file->updated) && status < 1)
     161              stop = 0;
     162              if ((fail || file->updated) && status < us_question)
    173163                {
    174                   if (file->update_status != 0)
     164                  /* We updated this goal.  Update STATUS and decide whether
     165                     to stop.  */
     166                  if (file->update_status)
    175167                    {
    176168                      /* Updating failed, or -q triggered.  The STATUS value
     
    199191                          if (!rebuilding_makefiles
    200192                              || (!just_print_flag && !question_flag))
    201                             status = 0;
     193                            status = us_success;
    202194                          if (rebuilding_makefiles && file->dontcare)
    203195                            /* This is a default makefile; stop remaking.  */
     
    207199                }
    208200
    209               /* Keep track if any double-colon entry is not finished.
     201              /* Keep track if any double-colon entry is not finished.
    210202                 When they are all finished, the goal is finished.  */
    211               any_not_updated |= !file->updated;
     203              any_not_updated |= !file->updated;
    212204
    213205              file->dontcare = 0;
    214206
    215               if (stop)
    216                 break;
    217             }
    218 
    219           /* Reset FILE since it is null at the end of the loop.  */
    220           file = g->file;
    221 
    222           if (stop || !any_not_updated)
    223             {
    224               /* If we have found nothing whatever to do for the goal,
    225                 print a message saying nothing needs doing.  */
    226 
    227               if (!rebuilding_makefiles
    228                   /* If the update_status is zero, we updated successfully
    229                      or not at all.  G->changed will have been set above if
    230                      any commands were actually started for this goal.  */
    231                   && file->update_status == 0 && !g->changed
    232                   /* Never give a message under -s or -q.  */
    233                   && !silent_flag && !question_flag)
    234                 message (1, ((file->phony || file->cmds == 0)
    235                              ? _("Nothing to be done for `%s'.")
    236                              : _("`%s' is up to date.")),
    237                         file->name);
    238 
    239               /* This goal is finished.  Remove it from the chain.  */
    240               if (lastgoal == 0)
    241                 goals = g->next;
    242               else
    243                 lastgoal->next = g->next;
    244 
    245               /* Free the storage.  */
    246               free (g);
    247 
    248               g = lastgoal == 0 ? goals : lastgoal->next;
    249 
    250               if (stop)
    251                 break;
    252             }
    253           else
    254             {
    255               lastgoal = g;
    256               g = g->next;
    257             }
    258         }
    259 
    260       /* If we reached the end of the dependency graph toggle the considered
    261          flag for the next pass.  */
     207              if (stop)
     208                break;
     209            }
     210
     211          /* Reset FILE since it is null at the end of the loop.  */
     212          file = g->file;
     213
     214          if (stop || !any_not_updated)
     215            {
     216              /* If we have found nothing whatever to do for the goal,
     217                print a message saying nothing needs doing.  */
     218
     219              if (!rebuilding_makefiles
     220                  /* If the update_status is success, we updated successfully
     221                     or not at all.  G->changed will have been set above if
     222                     any commands were actually started for this goal.  */
     223                  && file->update_status == us_success && !g->changed
     224                  /* Never give a message under -s or -q.  */
     225                  && !silent_flag && !question_flag)
     226                OS (message, 1, ((file->phony || file->cmds == 0)
     227                                 ? _("Nothing to be done for '%s'.")
     228                                 : _("'%s' is up to date.")),
     229                    file->name);
     230
     231              /* This goal is finished.  Remove it from the chain.  */
     232              if (lastgoal == 0)
     233                goals = g->next;
     234              else
     235                lastgoal->next = g->next;
     236
     237              /* Free the storage.  */
     238              free (g);
     239
     240              g = lastgoal == 0 ? goals : lastgoal->next;
     241
     242              if (stop)
     243                break;
     244            }
     245          else
     246            {
     247              lastgoal = g;
     248              g = g->next;
     249            }
     250        }
     251
     252      /* If we reached the end of the dependency graph update CONSIDERED
     253         for the next pass.  */
    262254      if (g == 0)
    263         considered = !considered;
     255        ++considered;
    264256    }
    265257
     
    275267
    276268
     269/* If we're rebuilding an included makefile that failed, and we care
     270   about errors, show an error message the first time.  */
     271
     272void
     273show_goal_error (void)
     274{
     275  struct goaldep *goal;
     276
     277  if ((goal_dep->flags & (RM_INCLUDED|RM_DONTCARE)) != RM_INCLUDED)
     278    return;
     279
     280  for (goal = goal_list; goal; goal = goal->next)
     281    if (goal_dep->file == goal->file)
     282      {
     283        if (goal->error)
     284          {
     285            OSS (error, &goal->floc, "%s: %s",
     286                 goal->file->name, strerror ((int)goal->error));
     287            goal->error = 0;
     288          }
     289        return;
     290      }
     291}
     292
     293
    277294/* If FILE is not up to date, execute the commands for it.
    278    Return 0 if successful, 1 if unsuccessful;
    279    but with some flag settings, just call `exit' if unsuccessful.
     295   Return 0 if successful, non-0 if unsuccessful;
     296   but with some flag settings, just call 'exit' if unsuccessful.
    280297
    281298   DEPTH is the depth in recursions of this function.
     
    287304   each is considered in turn.  */
    288305
    289 static int
     306static enum update_status
    290307update_file (struct file *file, unsigned int depth)
    291308{
    292   register int status = 0;
    293   register struct file *f;
     309  enum update_status status = us_success;
     310  struct file *f;
    294311
    295312  f = file->double_colon ? file->double_colon : file;
     
    302319    {
    303320      /* 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
     321         the diagnostics haven't been issued. If we need the diagnostics
    305322         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;
     323      if (!(f->updated && f->update_status > us_none
     324            && !f->dontcare && f->no_diag))
     325        {
     326          DBF (DB_VERBOSE, _("Pruning file '%s'.\n"));
     327          return f->command_state == cs_finished ? f->update_status : us_success;
    310328        }
    311329    }
     
    315333  for (; f != 0; f = f->prev)
    316334    {
     335      enum update_status new;
     336
    317337      f->considered = considered;
    318338
    319       status |= update_file_1 (f, depth);
     339      new = update_file_1 (f, depth);
    320340      check_renamed (f);
    321341
     
    324344
    325345      /* If we got an error, don't bother with double_colon etc.  */
    326       if (status != 0 && !keep_going_flag)
    327         return status;
     346      if (new && !keep_going_flag)
     347        return new;
    328348
    329349      if (f->command_state == cs_running
    330350          || f->command_state == cs_deps_running)
    331         {
    332           /* Don't run the other :: rules for this
    333              file until this rule is finished.  */
    334           status = 0;
    335           break;
    336         }
     351        /* Don't run other :: rules for this target until
     352           this rule is finished.  */
     353        return us_success;
     354
     355      if (new > status)
     356        status = new;
    337357    }
    338358
     
    347367
    348368        for (d = f->deps; d != 0; d = d->next)
    349           status |= update_file (d->file, depth + 1);
     369          {
     370            enum update_status new = update_file (d->file, depth + 1);
     371            if (new > status)
     372              status = new;
     373          }
    350374      }
    351375
     
    359383complain (struct file *file)
    360384{
    361   const char *msg_noparent
    362     = _("%sNo rule to make target `%s'%s");
    363   const char *msg_parent
    364     = _("%sNo rule to make target `%s', needed by `%s'%s");
    365 
    366385  /* If this file has no_diag set then it means we tried to update it
    367386     before in the dontcare mode and failed. The target that actually
     
    374393  for (d = file->deps; d != 0; d = d->next)
    375394    {
    376       if (d->file->updated && d->file->update_status > 0 && file->no_diag)
     395      if (d->file->updated && d->file->update_status > us_none && file->no_diag)
    377396        {
    378397          complain (d->file);
     
    383402  if (d == 0)
    384403    {
     404      show_goal_error ();
     405
    385406      /* 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 
    394       if (file->parent == 0)
    395         error (NILF, msg_noparent, "*** ", file->name, ".");
     407      if (file->parent)
     408        {
     409          size_t l = strlen (file->name) + strlen (file->parent->name) + 4;
     410          const char *m = _("%sNo rule to make target '%s', needed by '%s'%s");
     411
     412          if (!keep_going_flag)
     413            fatal (NILF, l, m, "", file->name, file->parent->name, "");
     414
     415          error (NILF, l, m, "*** ", file->name, file->parent->name, ".");
     416        }
    396417      else
    397         error (NILF, msg_parent, "*** ", file->name, file->parent->name, ".");
     418        {
     419          size_t l = strlen (file->name) + 4;
     420          const char *m = _("%sNo rule to make target '%s'%s");
     421
     422          if (!keep_going_flag)
     423            fatal (NILF, l, m, "", file->name, "");
     424
     425          error (NILF, l, m, "*** ", file->name, ".");
     426        }
    398427
    399428      file->no_diag = 0;
     
    401430}
    402431
    403 /* Consider a single `struct file' and update it as appropriate.  */
    404 
    405 static int
     432/* Consider a single 'struct file' and update it as appropriate.
     433   Return 0 on success, or non-0 on failure.  */
     434
     435static enum update_status
    406436update_file_1 (struct file *file, unsigned int depth)
    407437{
     438  enum update_status dep_status = us_success;
    408439  FILE_TIMESTAMP this_mtime;
    409440  int noexist, must_make, deps_changed;
    410   int dep_status = 0;
    411441  struct file *ofile;
    412442  struct dep *d, *ad;
     
    414444  int running = 0;
    415445
    416   DBF (DB_VERBOSE, _("Considering target file `%s'.\n"));
     446  DBF (DB_VERBOSE, _("Considering target file '%s'.\n"));
    417447
    418448  if (file->updated)
    419449    {
    420       if (file->update_status > 0)
    421         {
    422           DBF (DB_VERBOSE,
    423                _("Recently tried and failed to update file `%s'.\n"));
     450      if (file->update_status > us_none)
     451        {
     452          DBF (DB_VERBOSE,
     453               _("Recently tried and failed to update file '%s'.\n"));
    424454
    425455          /* If the file we tried to make is marked no_diag then no message
     
    430460              complain (file);
    431461
    432           return file->update_status;
    433         }
    434 
    435       DBF (DB_VERBOSE, _("File `%s' was considered already.\n"));
     462          return file->update_status;
     463        }
     464
     465      DBF (DB_VERBOSE, _("File '%s' was considered already.\n"));
    436466      return 0;
    437467    }
     
    443473      break;
    444474    case cs_running:
    445       DBF (DB_VERBOSE, _("Still updating file `%s'.\n"));
     475      DBF (DB_VERBOSE, _("Still updating file '%s'.\n"));
    446476      return 0;
    447477    case cs_finished:
    448       DBF (DB_VERBOSE, _("Finished updating file `%s'.\n"));
     478      DBF (DB_VERBOSE, _("Finished updating file '%s'.\n"));
    449479      return file->update_status;
    450480    default:
     
    475505  noexist = this_mtime == NONEXISTENT_MTIME;
    476506  if (noexist)
    477     DBF (DB_BASIC, _("File `%s' does not exist.\n"));
     507    DBF (DB_BASIC, _("File '%s' does not exist.\n"));
    478508  else if (ORDINARY_MTIME_MIN <= this_mtime && this_mtime <= ORDINARY_MTIME_MAX
    479            && file->low_resolution_time)
     509           && file->low_resolution_time)
    480510    {
    481511      /* Avoid spurious rebuilds due to low resolution time stamps.  */
    482512      int ns = FILE_TIMESTAMP_NS (this_mtime);
    483513      if (ns != 0)
    484         error (NILF, _("*** Warning: .LOW_RESOLUTION_TIME file `%s' has a high resolution time stamp"),
    485                file->name);
     514        OS (error, NILF,
     515            _("*** Warning: .LOW_RESOLUTION_TIME file '%s' has a high resolution time stamp"),
     516            file->name);
    486517      this_mtime += FILE_TIMESTAMPS_PER_S - 1 - ns;
    487518    }
     
    495526    {
    496527      if (try_implicit_rule (file, depth))
    497         DBF (DB_IMPLICIT, _("Found an implicit rule for `%s'.\n"));
     528        DBF (DB_IMPLICIT, _("Found an implicit rule for '%s'.\n"));
    498529      else
    499         DBF (DB_IMPLICIT, _("No implicit rule found for `%s'.\n"));
     530        DBF (DB_IMPLICIT, _("No implicit rule found for '%s'.\n"));
    500531      file->tried_implicit = 1;
    501532    }
     
    503534      && default_file != 0 && default_file->cmds != 0)
    504535    {
    505       DBF (DB_IMPLICIT, _("Using default recipe for `%s'.\n"));
     536      DBF (DB_IMPLICIT, _("Using default recipe for '%s'.\n"));
    506537      file->cmds = default_file->cmds;
    507538    }
     
    525556      while (d)
    526557        {
     558          enum update_status new;
    527559          FILE_TIMESTAMP mtime;
    528560          int maybe_make;
     
    536568          if (is_updating (d->file))
    537569            {
    538               error (NILF, _("Circular %s <- %s dependency dropped."),
    539                      file->name, d->file->name);
     570              OSS (error, NILF, _("Circular %s <- %s dependency dropped."),
     571                   file->name, d->file->name);
    540572              /* We cannot free D here because our the caller will still have
    541573                 a reference to it when we were called recursively via
     
    559591            }
    560592
    561           dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make);
     593          new = check_dep (d->file, depth, this_mtime, &maybe_make);
     594          if (new > dep_status)
     595            dep_status = new;
    562596
    563597          /* Restore original dontcare flag. */
     
    583617          }
    584618
    585           if (dep_status != 0 && !keep_going_flag)
     619          if (dep_status && !keep_going_flag)
    586620            break;
    587621
    588622          if (!running)
    589             /* The prereq is considered changed if the timestamp has changed while
    590                it was built, OR it doesn't exist.  */
     623            /* The prereq is considered changed if the timestamp has changed
     624               while it was built, OR it doesn't exist.  */
    591625            d->changed = ((file_mtime (d->file) != mtime)
    592626                          || (mtime == NONEXISTENT_MTIME));
     
    603637    {
    604638      for (d = file->deps; d != 0; d = d->next)
    605         if (d->file->intermediate)
    606           {
     639        if (d->file->intermediate)
     640          {
     641            enum update_status new;
    607642            int dontcare = 0;
    608643
    609             FILE_TIMESTAMP mtime = file_mtime (d->file);
    610             check_renamed (d->file);
    611             d->file->parent = file;
     644            FILE_TIMESTAMP mtime = file_mtime (d->file);
     645            check_renamed (d->file);
     646            d->file->parent = file;
    612647
    613648            /* Inherit dontcare flag from our parent. */
     
    618653              }
    619654
    620 
    621             dep_status |= update_file (d->file, depth);
     655            /* We may have already considered this file, when we didn't know
     656               we'd need to update it.  Force update_file() to consider it and
     657               not prune it.  */
     658            d->file->considered = 0;
     659
     660            new = update_file (d->file, depth);
     661            if (new > dep_status)
     662              dep_status = new;
    622663
    623664            /* Restore original dontcare flag. */
     
    625666              d->file->dontcare = dontcare;
    626667
    627             check_renamed (d->file);
    628 
    629             {
    630               register struct file *f = d->file;
    631               if (f->double_colon)
    632                 f = f->double_colon;
    633               do
    634                 {
    635                   running |= (f->command_state == cs_running
    636                               || f->command_state == cs_deps_running);
    637                   f = f->prev;
    638                 }
    639               while (f != 0);
    640             }
    641 
    642             if (dep_status != 0 && !keep_going_flag)
    643               break;
    644 
    645             if (!running)
    646               d->changed = ((file->phony && file->cmds != 0)
    647                             || file_mtime (d->file) != mtime);
    648           }
     668            check_renamed (d->file);
     669
     670            {
     671              register struct file *f = d->file;
     672              if (f->double_colon)
     673                f = f->double_colon;
     674              do
     675                {
     676                  running |= (f->command_state == cs_running
     677                              || f->command_state == cs_deps_running);
     678                  f = f->prev;
     679                }
     680              while (f != 0);
     681            }
     682
     683            if (dep_status && !keep_going_flag)
     684              break;
     685
     686            if (!running)
     687              d->changed = ((file->phony && file->cmds != 0)
     688                            || file_mtime (d->file) != mtime);
     689          }
    649690    }
    650691
     
    652693  finish_updating (ofile);
    653694
    654   DBF (DB_VERBOSE, _("Finished prerequisites of target file `%s'.\n"));
     695  DBF (DB_VERBOSE, _("Finished prerequisites of target file '%s'.\n"));
    655696
    656697  if (running)
     
    658699      set_command_state (file, cs_deps_running);
    659700      --depth;
    660       DBF (DB_VERBOSE, _("The prerequisites of `%s' are being made.\n"));
     701      DBF (DB_VERBOSE, _("The prerequisites of '%s' are being made.\n"));
    661702      return 0;
    662703    }
     
    664705  /* If any dependency failed, give up now.  */
    665706
    666   if (dep_status != 0)
    667     {
    668       file->update_status = dep_status;
     707  if (dep_status)
     708    {
     709      /* I'm not sure if we can't just assign dep_status...  */
     710      file->update_status = dep_status == us_none ? us_failed : dep_status;
    669711      notice_finished_file (file);
    670712
    671713      --depth;
    672714
    673       DBF (DB_VERBOSE, _("Giving up on target file `%s'.\n"));
     715      DBF (DB_VERBOSE, _("Giving up on target file '%s'.\n"));
    674716
    675717      if (depth == 0 && keep_going_flag
    676           && !just_print_flag && !question_flag)
    677         error (NILF,
    678                _("Target `%s' not remade because of errors."), file->name);
     718          && !just_print_flag && !question_flag)
     719        OS (error, NILF,
     720            _("Target '%s' not remade because of errors."), file->name);
    679721
    680722      return dep_status;
     
    705747#if 1
    706748          /* %%% In version 4, remove this code completely to
    707            implement not remaking deps if their deps are newer
    708            than their parents.  */
     749           implement not remaking deps if their deps are newer
     750           than their parents.  */
    709751          if (d_mtime == NONEXISTENT_MTIME && !d->file->intermediate)
    710752            /* We must remake if this dep does not
     
    718760
    719761      /* Set D->changed if either this dep actually changed,
    720         or its dependent, FILE, is older or does not exist.  */
     762        or its dependent, FILE, is older or does not exist.  */
    721763      d->changed |= noexist || d_mtime > this_mtime;
    722764
    723765      if (!noexist && ISDB (DB_BASIC|DB_VERBOSE))
    724         {
     766        {
    725767          const char *fmt = 0;
    726768
     
    728770            {
    729771              if (ISDB (DB_VERBOSE))
    730                 fmt = _("Prerequisite `%s' is order-only for target `%s'.\n");
     772                fmt = _("Prerequisite '%s' is order-only for target '%s'.\n");
    731773            }
    732774          else if (d_mtime == NONEXISTENT_MTIME)
    733775            {
    734776              if (ISDB (DB_BASIC))
    735                 fmt = _("Prerequisite `%s' of target `%s' does not exist.\n");
    736             }
    737           else if (d->changed)
     777                fmt = _("Prerequisite '%s' of target '%s' does not exist.\n");
     778            }
     779          else if (d->changed)
    738780            {
    739781              if (ISDB (DB_BASIC))
    740                 fmt = _("Prerequisite `%s' is newer than target `%s'.\n");
     782                fmt = _("Prerequisite '%s' is newer than target '%s'.\n");
    741783            }
    742784          else if (ISDB (DB_VERBOSE))
    743             fmt = _("Prerequisite `%s' is older than target `%s'.\n");
     785            fmt = _("Prerequisite '%s' is older than target '%s'.\n");
    744786
    745787          if (fmt)
     
    749791              fflush (stdout);
    750792            }
    751         }
     793        }
    752794    }
    753795
     
    759801      must_make = 1;
    760802      DBF (DB_BASIC,
    761            _("Target `%s' is double-colon and has no prerequisites.\n"));
     803           _("Target '%s' is double-colon and has no prerequisites.\n"));
    762804    }
    763805  else if (!noexist && file->is_target && !deps_changed && file->cmds == 0
     
    766808      must_make = 0;
    767809      DBF (DB_VERBOSE,
    768            _("No recipe for `%s' and no prerequisites actually changed.\n"));
     810           _("No recipe for '%s' and no prerequisites actually changed.\n"));
    769811    }
    770812  else if (!must_make && file->cmds != 0 && always_make_flag)
    771813    {
    772814      must_make = 1;
    773       DBF (DB_VERBOSE, _("Making `%s' due to always-make flag.\n"));
     815      DBF (DB_VERBOSE, _("Making '%s' due to always-make flag.\n"));
    774816    }
    775817
     
    779821        {
    780822          print_spaces (depth);
    781           printf (_("No need to remake target `%s'"), file->name);
     823          printf (_("No need to remake target '%s'"), file->name);
    782824          if (!streq (file->name, file->hname))
    783               printf (_("; using VPATH name `%s'"), file->hname);
     825              printf (_("; using VPATH name '%s'"), file->hname);
    784826          puts (".");
    785827          fflush (stdout);
     
    801843    }
    802844
    803   DBF (DB_BASIC, _("Must remake target `%s'.\n"));
     845  DBF (DB_BASIC, _("Must remake target '%s'.\n"));
    804846
    805847  /* It needs to be remade.  If it's VPATH and not reset via GPATH, toss the
    806848     VPATH.  */
    807   if (!streq(file->name, file->hname))
    808     {
    809       DB (DB_BASIC, (_("  Ignoring VPATH name `%s'.\n"), file->hname));
     849  if (!streq (file->name, file->hname))
     850    {
     851      DB (DB_BASIC, (_("  Ignoring VPATH name '%s'.\n"), file->hname));
    810852      file->ignore_vpath = 1;
    811853    }
     
    816858  if (file->command_state != cs_finished)
    817859    {
    818       DBF (DB_VERBOSE, _("Recipe of `%s' is being run.\n"));
     860      DBF (DB_VERBOSE, _("Recipe of '%s' is being run.\n"));
    819861      return 0;
    820862    }
     
    822864  switch (file->update_status)
    823865    {
    824     case 2:
    825       DBF (DB_BASIC, _("Failed to remake target file `%s'.\n"));
     866    case us_failed:
     867      DBF (DB_BASIC, _("Failed to remake target file '%s'.\n"));
    826868      break;
    827     case 0:
    828       DBF (DB_BASIC, _("Successfully remade target file `%s'.\n"));
     869    case us_success:
     870      DBF (DB_BASIC, _("Successfully remade target file '%s'.\n"));
    829871      break;
    830     case 1:
    831       DBF (DB_BASIC, _("Target file `%s' needs remade under -q.\n"));
     872    case us_question:
     873      DBF (DB_BASIC, _("Target file '%s' needs to be remade under -q.\n"));
    832874      break;
    833     default:
    834       assert (file->update_status >= 0 && file->update_status <= 2);
     875    case us_none:
    835876      break;
    836877    }
     
    841882
    842883
    843 /* Set FILE's `updated' flag and re-check its mtime and the mtime's of all
    844    files listed in its `also_make' member.  Under -t, this function also
     884/* Set FILE's 'updated' flag and re-check its mtime and the mtime's of all
     885   files listed in its 'also_make' member.  Under -t, this function also
    845886   touches FILE.
    846887
    847    On return, FILE->update_status will no longer be -1 if it was.  */
     888   On return, FILE->update_status will no longer be us_none if it was.  */
    848889
    849890void
     
    859900  if (touch_flag
    860901      /* The update status will be:
    861                 -1      if this target was not remade;
    862                 0       if 0 or more commands (+ or ${MAKE}) were run and won;
    863                 1       if some commands were run and lost.
    864         We touch the target if it has commands which either were not run
    865         or won when they ran (i.e. status is 0).  */
    866       && file->update_status == 0)
     902           us_success   if 0 or more commands (+ or ${MAKE}) were run and won;
     903           us_none      if this target was not remade;
     904           >us_none     if some commands were run and lost.
     905        We touch the target if it has commands which either were not run
     906        or won when they ran (i.e. status is 0).  */
     907      && file->update_status == us_success)
    867908    {
    868909      if (file->cmds != 0 && file->cmds->any_recurse)
    869         {
    870           /* If all the command lines were recursive,
    871              we don't want to do the touching.  */
    872           unsigned int i;
    873           for (i = 0; i < file->cmds->ncommand_lines; ++i)
    874             if (!(file->cmds->lines_flags[i] & COMMANDS_RECURSE))
    875               goto have_nonrecursing;
    876         }
     910        {
     911          /* If all the command lines were recursive,
     912             we don't want to do the touching.  */
     913          unsigned int i;
     914          for (i = 0; i < file->cmds->ncommand_lines; ++i)
     915            if (!(file->cmds->lines_flags[i] & COMMANDS_RECURSE))
     916              goto have_nonrecursing;
     917        }
    877918      else
    878         {
    879         have_nonrecursing:
    880           if (file->phony)
    881             file->update_status = 0;
     919        {
     920        have_nonrecursing:
     921          if (file->phony)
     922            file->update_status = us_success;
    882923          /* According to POSIX, -t doesn't affect targets with no cmds.  */
    883           else if (file->cmds != 0)
     924          else if (file->cmds != 0)
    884925            {
    885926              /* Should set file's modification date and do nothing else.  */
     
    887928
    888929              /* Pretend we ran a real touch command, to suppress the
    889                  "`foo' is up to date" message.  */
     930                 "'foo' is up to date" message.  */
    890931              commands_started++;
    891932
     
    896937              touched = 1;
    897938            }
    898         }
     939        }
    899940    }
    900941
     
    920961
    921962      else if (file->is_target && file->cmds == 0)
    922         i = 1;
     963        i = 1;
    923964
    924965      file->last_mtime = i == 0 ? UNKNOWN_MTIME : NEW_MTIME;
     
    953994    }
    954995
    955   if (ran && file->update_status != -1)
     996  if (ran && file->update_status != us_none)
    956997    /* We actually tried to update FILE, which has
    957998       updated its also_make's as well (if it worked).
     
    9601001    for (d = file->also_make; d != 0; d = d->next)
    9611002      {
    962         d->file->command_state = cs_finished;
    963         d->file->updated = 1;
    964         d->file->update_status = file->update_status;
    965 
    966         if (ran && !d->file->phony)
    967           /* Fetch the new modification time.
    968              We do this instead of just invalidating the cached time
    969              so that a vpath_search can happen.  Otherwise, it would
    970              never be done because the target is already updated.  */
    971           f_mtime (d->file, 0);
     1003        d->file->command_state = cs_finished;
     1004        d->file->updated = 1;
     1005        d->file->update_status = file->update_status;
     1006
     1007        if (ran && !d->file->phony)
     1008          /* Fetch the new modification time.
     1009             We do this instead of just invalidating the cached time
     1010             so that a vpath_search can happen.  Otherwise, it would
     1011             never be done because the target is already updated.  */
     1012          f_mtime (d->file, 0);
    9721013      }
    973   else if (file->update_status == -1)
     1014  else if (file->update_status == us_none)
    9741015    /* Nothing was done for FILE, but it needed nothing done.
    9751016       So mark it now as "succeeded".  */
    976     file->update_status = 0;
     1017    file->update_status = us_success;
    9771018}
    9781019
     
    9841025   failed.  */
    9851026
    986 static int
     1027static enum update_status
    9871028check_dep (struct file *file, unsigned int depth,
    9881029           FILE_TIMESTAMP this_mtime, int *must_make_ptr)
     
    9901031  struct file *ofile;
    9911032  struct dep *d;
    992   int dep_status = 0;
     1033  enum update_status dep_status = us_success;
    9931034
    9941035  ++depth;
     
    10091050      check_renamed (file);
    10101051      if (mtime == NONEXISTENT_MTIME || mtime > this_mtime)
    1011         *must_make_ptr = 1;
     1052        *must_make_ptr = 1;
    10121053    }
    10131054  else
     
    10171058
    10181059      if (!file->phony && file->cmds == 0 && !file->tried_implicit)
    1019         {
    1020           if (try_implicit_rule (file, depth))
    1021             DBF (DB_IMPLICIT, _("Found an implicit rule for `%s'.\n"));
    1022           else
    1023             DBF (DB_IMPLICIT, _("No implicit rule found for `%s'.\n"));
    1024           file->tried_implicit = 1;
    1025         }
     1060        {
     1061          if (try_implicit_rule (file, depth))
     1062            DBF (DB_IMPLICIT, _("Found an implicit rule for '%s'.\n"));
     1063          else
     1064            DBF (DB_IMPLICIT, _("No implicit rule found for '%s'.\n"));
     1065          file->tried_implicit = 1;
     1066        }
    10261067      if (file->cmds == 0 && !file->is_target
    1027           && default_file != 0 && default_file->cmds != 0)
    1028         {
    1029           DBF (DB_IMPLICIT, _("Using default commands for `%s'.\n"));
    1030           file->cmds = default_file->cmds;
    1031         }
     1068          && default_file != 0 && default_file->cmds != 0)
     1069        {
     1070          DBF (DB_IMPLICIT, _("Using default commands for '%s'.\n"));
     1071          file->cmds = default_file->cmds;
     1072        }
    10321073
    10331074      check_renamed (file);
     
    10371078        /* If the intermediate file actually exists and is newer, then we
    10381079           should remake from it.  */
    1039         *must_make_ptr = 1;
     1080        *must_make_ptr = 1;
    10401081      else
    1041         {
     1082        {
    10421083          /* Otherwise, update all non-intermediate files we depend on, if
    10431084             necessary, and see whether any of them is more recent than the
    10441085             file on whose behalf we are checking.  */
    1045           struct dep *ld;
     1086          struct dep *ld;
    10461087          int deps_running = 0;
    10471088
     
    10501091             prerequisite and so wasn't rebuilt then, but should be now.  */
    10511092          if (file->command_state != cs_running)
    1052             set_command_state (file, cs_not_started);
    1053 
    1054           ld = 0;
    1055           d = file->deps;
    1056           while (d != 0)
    1057             {
     1093            {
     1094              /* If the target was waiting for a dependency it has to be
     1095                 reconsidered, as that dependency might have finished.  */
     1096              if (file->command_state == cs_deps_running)
     1097                file->considered = 0;
     1098
     1099              set_command_state (file, cs_not_started);
     1100            }
     1101
     1102          ld = 0;
     1103          d = file->deps;
     1104          while (d != 0)
     1105            {
     1106              enum update_status new;
    10581107              int maybe_make;
    10591108
    1060               if (is_updating (d->file))
    1061                 {
    1062                   error (NILF, _("Circular %s <- %s dependency dropped."),
    1063                         file->name, d->file->name);
    1064                   if (ld == 0)
    1065                     {
    1066                       file->deps = d->next;
     1109              if (is_updating (d->file))
     1110                {
     1111                  OSS (error, NILF, _("Circular %s <- %s dependency dropped."),
     1112                      file->name, d->file->name);
     1113                  if (ld == 0)
     1114                    {
     1115                      file->deps = d->next;
    10671116                      free_dep (d);
    1068                       d = file->deps;
    1069                     }
    1070                   else
    1071                     {
    1072                       ld->next = d->next;
     1117                      d = file->deps;
     1118                    }
     1119                  else
     1120                    {
     1121                      ld->next = d->next;
    10731122                      free_dep (d);
    1074                       d = ld->next;
    1075                     }
    1076                   continue;
    1077                 }
    1078 
    1079               d->file->parent = file;
     1123                      d = ld->next;
     1124                    }
     1125                  continue;
     1126                }
     1127
     1128              d->file->parent = file;
    10801129              maybe_make = *must_make_ptr;
    1081               dep_status |= check_dep (d->file, depth, this_mtime,
    1082                                        &maybe_make);
     1130              new = check_dep (d->file, depth, this_mtime, &maybe_make);
     1131              if (new > dep_status)
     1132                dep_status = new;
     1133
    10831134              if (! d->ignore_mtime)
    10841135                *must_make_ptr = maybe_make;
    1085               check_renamed (d->file);
    1086               if (dep_status != 0 && !keep_going_flag)
    1087                 break;
    1088 
    1089               if (d->file->command_state == cs_running
    1090                   || d->file->command_state == cs_deps_running)
    1091                 deps_running = 1;
    1092 
    1093               ld = d;
    1094               d = d->next;
    1095             }
     1136              check_renamed (d->file);
     1137              if (dep_status && !keep_going_flag)
     1138                break;
     1139
     1140              if (d->file->command_state == cs_running
     1141                  || d->file->command_state == cs_deps_running)
     1142                deps_running = 1;
     1143
     1144              ld = d;
     1145              d = d->next;
     1146            }
    10961147
    10971148          if (deps_running)
     
    11001151               commands are finished.  */
    11011152            set_command_state (file, cs_deps_running);
    1102         }
     1153        }
    11031154    }
    11041155
     
    11101161
    11111162
    1112 /* Touch FILE.  Return zero if successful, one if not.  */
    1113 
    1114 #define TOUCH_ERROR(call) return (perror_with_name (call, file->name), 1)
    1115 
    1116 static int
     1163/* Touch FILE.  Return us_success if successful, us_failed if not.  */
     1164
     1165#define TOUCH_ERROR(call) do{ perror_with_name ((call), file->name);    \
     1166                              return us_failed; }while(0)
     1167
     1168static enum update_status
    11171169touch_file (struct file *file)
    11181170{
    11191171  if (!silent_flag)
    1120     message (0, "touch %s", file->name);
    1121 
    1122 #ifndef NO_ARCHIVES
     1172    OS (message, 0, "touch %s", file->name);
     1173
     1174  /* Print-only (-n) takes precedence over touch (-t).  */
     1175  if (just_print_flag)
     1176    return us_success;
     1177
     1178#ifndef NO_ARCHIVES
    11231179  if (ar_name (file->name))
    1124     return ar_touch (file->name);
     1180    return ar_touch (file->name) ? us_failed : us_success;
    11251181  else
    11261182#endif
    11271183    {
    1128       int fd = open (file->name, O_RDWR | O_CREAT, 0666);
    1129 
     1184      int fd;
     1185
     1186      EINTRLOOP (fd, open (file->name, O_RDWR | O_CREAT, 0666));
    11301187      if (fd < 0)
    1131         TOUCH_ERROR ("touch: open: ");
     1188        TOUCH_ERROR ("touch: open: ");
    11321189      else
    1133         {
    1134           struct stat statbuf;
    1135           char buf = 'x';
     1190        {
     1191          struct stat statbuf;
     1192          char buf = 'x';
    11361193          int e;
    11371194
    11381195          EINTRLOOP (e, fstat (fd, &statbuf));
    1139           if (e < 0)
    1140             TOUCH_ERROR ("touch: fstat: ");
    1141           /* Rewrite character 0 same as it already is.  */
    1142           if (read (fd, &buf, 1) < 0)
    1143             TOUCH_ERROR ("touch: read: ");
    1144           if (lseek (fd, 0L, 0) < 0L)
    1145             TOUCH_ERROR ("touch: lseek: ");
    1146           if (write (fd, &buf, 1) < 0)
    1147             TOUCH_ERROR ("touch: write: ");
    1148           /* If file length was 0, we just
    1149              changed it, so change it back.  */
    1150           if (statbuf.st_size == 0)
    1151             {
    1152               (void) close (fd);
    1153               fd = open (file->name, O_RDWR | O_TRUNC, 0666);
    1154               if (fd < 0)
    1155                 TOUCH_ERROR ("touch: open: ");
    1156             }
    1157           (void) close (fd);
    1158         }
    1159     }
    1160 
    1161   return 0;
     1196          if (e < 0)
     1197            TOUCH_ERROR ("touch: fstat: ");
     1198          /* Rewrite character 0 same as it already is.  */
     1199          EINTRLOOP (e, read (fd, &buf, 1));
     1200          if (e < 0)
     1201            TOUCH_ERROR ("touch: read: ");
     1202          {
     1203            off_t o;
     1204            EINTRLOOP (o, lseek (fd, 0L, 0));
     1205            if (o < 0L)
     1206              TOUCH_ERROR ("touch: lseek: ");
     1207          }
     1208          EINTRLOOP (e, write (fd, &buf, 1));
     1209          if (e < 0)
     1210            TOUCH_ERROR ("touch: write: ");
     1211
     1212          /* If file length was 0, we just changed it, so change it back.  */
     1213          if (statbuf.st_size == 0)
     1214            {
     1215              (void) close (fd);
     1216              EINTRLOOP (fd, open (file->name, O_RDWR | O_TRUNC, 0666));
     1217              if (fd < 0)
     1218                TOUCH_ERROR ("touch: open: ");
     1219            }
     1220          (void) close (fd);
     1221        }
     1222    }
     1223
     1224  return us_success;
    11621225}
    11631226
     
    11731236    {
    11741237      if (file->phony)
    1175         /* Phony target.  Pretend it succeeded.  */
    1176         file->update_status = 0;
     1238        /* Phony target.  Pretend it succeeded.  */
     1239        file->update_status = us_success;
    11771240      else if (file->is_target)
    1178         /* This is a nonexistent target file we cannot make.
    1179            Pretend it was successfully remade.  */
    1180         file->update_status = 0;
     1241        /* This is a nonexistent target file we cannot make.
     1242           Pretend it was successfully remade.  */
     1243        file->update_status = us_success;
    11811244      else
    11821245        {
     
    11841247          if (!rebuilding_makefiles || !file->dontcare)
    11851248            complain (file);
    1186           file->update_status = 2;
     1249          file->update_status = us_failed;
    11871250        }
    11881251    }
     
    11931256      /* The normal case: start some commands.  */
    11941257      if (!touch_flag || file->cmds->any_recurse)
    1195         {
    1196           execute_file_commands (file);
    1197           return;
    1198         }
     1258        {
     1259          execute_file_commands (file);
     1260          return;
     1261        }
    11991262
    12001263      /* This tells notice_finished_file it is ok to touch the file.  */
    1201       file->update_status = 0;
     1264      file->update_status = us_success;
    12021265    }
    12031266
     
    12071270
    12081271
    1209 /* Return the mtime of a file, given a `struct file'.
     1272/* Return the mtime of a file, given a 'struct file'.
    12101273   Caches the time in the struct file to avoid excess stat calls.
    12111274
     
    12191282{
    12201283  FILE_TIMESTAMP mtime;
     1284  int propagate_timestamp;
    12211285
    12221286  /* File's mtime is not known; must get it from the system.  */
    12231287
    1224 #ifndef NO_ARCHIVES
     1288#ifndef NO_ARCHIVES
    12251289  if (ar_name (file->name))
    12261290    {
     
    12351299
    12361300      /* Find the modification time of the archive itself.
    1237         Also allow for its name to be changed via VPATH search.  */
     1301        Also allow for its name to be changed via VPATH search.  */
    12381302      arfile = lookup_file (arname);
    12391303      if (arfile == 0)
     
    12421306      check_renamed (arfile);
    12431307      if (search && strcmp (arfile->hname, arname))
    1244         {
    1245           /* The archive's name has changed.
    1246              Change the archive-member reference accordingly.  */
     1308        {
     1309          /* The archive's name has changed.
     1310             Change the archive-member reference accordingly.  */
    12471311
    12481312          char *name;
    1249           unsigned int arlen, memlen;
    1250 
    1251           arlen = strlen (arfile->hname);
    1252           memlen = strlen (memname);
    1253 
    1254           name = xmalloc (arlen + 1 + memlen + 2);
    1255           memcpy (name, arfile->hname, arlen);
    1256           name[arlen] = '(';
    1257           memcpy (name + arlen + 1, memname, memlen);
    1258           name[arlen + 1 + memlen] = ')';
    1259           name[arlen + 1 + memlen + 1] = '\0';
     1313          unsigned int arlen, memlen;
     1314
     1315          arlen = strlen (arfile->hname);
     1316          memlen = strlen (memname);
     1317
     1318          name = alloca (arlen + 1 + memlen + 2);
     1319          memcpy (name, arfile->hname, arlen);
     1320          name[arlen] = '(';
     1321          memcpy (name + arlen + 1, memname, memlen);
     1322          name[arlen + 1 + memlen] = ')';
     1323          name[arlen + 1 + memlen + 1] = '\0';
    12601324
    12611325          /* If the archive was found with GPATH, make the change permanent;
    12621326             otherwise defer it until later.  */
    12631327          if (arfile->name == arfile->hname)
    1264             rename_file (file, name);
     1328            rename_file (file, strcache_add (name));
    12651329          else
    1266             rehash_file (file, name);
     1330            rehash_file (file, strcache_add (name));
    12671331          check_renamed (file);
    1268         }
     1332        }
    12691333
    12701334      free (arname);
     
    12731337
    12741338      if (mtime == NONEXISTENT_MTIME)
    1275         /* The archive doesn't exist, so its members don't exist either.  */
    1276         return NONEXISTENT_MTIME;
     1339        /* The archive doesn't exist, so its members don't exist either.  */
     1340        return NONEXISTENT_MTIME;
    12771341
    12781342      member_date = ar_member_date (file->hname);
     
    12871351
    12881352      if (mtime == NONEXISTENT_MTIME && search && !file->ignore_vpath)
    1289         {
    1290           /* If name_mtime failed, search VPATH.  */
    1291           const char *name = vpath_search (file->name, &mtime, NULL, NULL);
    1292           if (name
    1293               /* Last resort, is it a library (-lxxx)?  */
    1294               || (file->name[0] == '-' && file->name[1] == 'l'
    1295                   && (name = library_search (file->name, &mtime)) != 0))
    1296             {
    1297               if (mtime != UNKNOWN_MTIME)
    1298                 /* vpath_search and library_search store UNKNOWN_MTIME
    1299                    if they didn't need to do a stat call for their work.  */
    1300                 file->last_mtime = mtime;
     1353        {
     1354          /* If name_mtime failed, search VPATH.  */
     1355          const char *name = vpath_search (file->name, &mtime, NULL, NULL);
     1356          if (name
     1357              /* Last resort, is it a library (-lxxx)?  */
     1358              || (file->name[0] == '-' && file->name[1] == 'l'
     1359                  && (name = library_search (file->name, &mtime)) != 0))
     1360            {
     1361              int name_len;
     1362
     1363              if (mtime != UNKNOWN_MTIME)
     1364                /* vpath_search and library_search store UNKNOWN_MTIME
     1365                   if they didn't need to do a stat call for their work.  */
     1366                file->last_mtime = mtime;
    13011367
    13021368              /* If we found it in VPATH, see if it's in GPATH too; if so,
    13031369                 change the name right now; if not, defer until after the
    13041370                 dependencies are updated. */
    1305               if (gpath_search (name, strlen(name) - strlen(file->name) - 1))
     1371#ifndef VMS
     1372              name_len = strlen (name) - strlen (file->name) - 1;
     1373#else
     1374              name_len = strlen (name) - strlen (file->name);
     1375              if (name[name_len - 1] == '/')
     1376                  name_len--;
     1377#endif
     1378              if (gpath_search (name, name_len))
    13061379                {
    13071380                  rename_file (file, name);
     
    13101383                }
    13111384
    1312               rehash_file (file, name);
    1313               check_renamed (file);
     1385              rehash_file (file, name);
     1386              check_renamed (file);
    13141387              /* If the result of a vpath search is -o or -W, preserve it.
    13151388                 Otherwise, find the mtime of the resulting file.  */
    13161389              if (mtime != OLD_MTIME && mtime != NEW_MTIME)
    13171390                mtime = name_mtime (name);
    1318             }
    1319         }
     1391            }
     1392        }
    13201393    }
    13211394
     
    13631436            {
    13641437#ifdef NO_FLOAT
    1365               error (NILF, _("Warning: File `%s' has modification time in the future"),
    1366                      file->name);
     1438              OS (error, NILF,
     1439                  _("Warning: File '%s' has modification time in the future"),
     1440                  file->name);
    13671441#else
    13681442              double from_now =
     
    13761450              else
    13771451                sprintf (from_now_string, "%.2g", from_now);
    1378               error (NILF, _("Warning: File `%s' has modification time %s s in the future"),
    1379                      file->name, from_now_string);
     1452              OSS (error, NILF,
     1453                   _("Warning: File '%s' has modification time %s s in the future"),
     1454                   file->name, from_now_string);
    13801455#endif
    13811456              clock_skew_detected = 1;
     
    13841459    }
    13851460
    1386   /* Store the mtime into all the entries for this file.  */
     1461  /* Store the mtime into all the entries for this file for which it is safe
     1462     to do so: avoid propagating timestamps to double-colon rules that haven't
     1463     been examined so they're run or not based on the pre-update timestamp.  */
    13871464  if (file->double_colon)
    13881465    file = file->double_colon;
    13891466
     1467  propagate_timestamp = file->updated;
    13901468  do
    13911469    {
    13921470      /* If this file is not implicit but it is intermediate then it was
    1393         made so by the .INTERMEDIATE target.  If this file has never
    1394         been built by us but was found now, it existed before make
    1395         started.  So, turn off the intermediate bit so make doesn't
    1396         delete it, since it didn't create it.  */
     1471        made so by the .INTERMEDIATE target.  If this file has never
     1472        been built by us but was found now, it existed before make
     1473        started.  So, turn off the intermediate bit so make doesn't
     1474        delete it, since it didn't create it.  */
    13971475      if (mtime != NONEXISTENT_MTIME && file->command_state == cs_not_started
    1398           && file->command_state == cs_not_started
    1399           && !file->tried_implicit && file->intermediate)
    1400         file->intermediate = 0;
    1401 
    1402       file->last_mtime = mtime;
     1476          && !file->tried_implicit && file->intermediate)
     1477        file->intermediate = 0;
     1478
     1479      if (file->updated == propagate_timestamp)
     1480        file->last_mtime = mtime;
    14031481      file = file->prev;
    14041482    }
     
    15151593library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr)
    15161594{
    1517   static char *dirs[] =
     1595  static const char *dirs[] =
    15181596    {
    15191597#ifndef _AMIGA
     
    15281606#define LIBDIR "."
    15291607#endif
    1530       LIBDIR,                   /* Defined by configuration.  */
     1608      LIBDIR,                   /* Defined by configuration.  */
    15311609      0
    15321610    };
     
    15431621
    15441622  /* Information about the earliest (in the vpath sequence) match.  */
    1545   unsigned int best_vpath, best_path;
    1546   unsigned int std_dirs = 0;
    1547 
    1548   char **dp;
     1623  unsigned int best_vpath = 0, best_path = 0;
     1624
     1625  const char **dp;
    15491626
    15501627  libpatterns = xstrdup (variable_expand ("$(.LIBPATTERNS)"));
     
    15631640      static unsigned int buflen = 0;
    15641641      static int libdir_maxlen = -1;
     1642      static unsigned int std_dirs = 0;
    15651643      char *libbuf = variable_expand ("");
    15661644
    15671645      /* Expand the pattern using LIB as a replacement.  */
    15681646      {
    1569         char c = p[len];
    1570         char *p3, *p4;
    1571 
    1572         p[len] = '\0';
    1573         p3 = find_percent (p);
    1574         if (!p3)
    1575           {
    1576             /* Give a warning if there is no pattern.  */
    1577             error (NILF, _(".LIBPATTERNS element `%s' is not a pattern"), p);
     1647        char c = p[len];
     1648        char *p3, *p4;
     1649
     1650        p[len] = '\0';
     1651        p3 = find_percent (p);
     1652        if (!p3)
     1653          {
     1654            /* Give a warning if there is no pattern.  */
     1655            OS (error, NILF,
     1656                _(".LIBPATTERNS element '%s' is not a pattern"), p);
    15781657            p[len] = c;
    1579             continue;
    1580           }
    1581         p4 = variable_buffer_output (libbuf, p, p3-p);
    1582         p4 = variable_buffer_output (p4, lib, liblen);
    1583         p4 = variable_buffer_output (p4, p3+1, len - (p3-p));
    1584         p[len] = c;
     1658            continue;
     1659          }
     1660        p4 = variable_buffer_output (libbuf, p, p3-p);
     1661        p4 = variable_buffer_output (p4, lib, liblen);
     1662        p4 = variable_buffer_output (p4, p3+1, len - (p3-p));
     1663        p[len] = c;
    15851664      }
    15861665
    1587       /* Look first for `libNAME.a' in the current directory.  */
     1666      /* Look first for 'libNAME.a' in the current directory.  */
    15881667      mtime = name_mtime (libbuf);
    15891668      if (mtime != NONEXISTENT_MTIME)
    1590         {
    1591           if (mtime_ptr != 0)
    1592             *mtime_ptr = mtime;
    1593           file = strcache_add (libbuf);
     1669        {
     1670          if (mtime_ptr != 0)
     1671            *mtime_ptr = mtime;
     1672          file = strcache_add (libbuf);
    15941673          /* This by definition will have the best index, so stop now.  */
    15951674          break;
    1596         }
     1675        }
    15971676
    15981677      /* Now try VPATH search on that.  */
     
    16311710            }
    16321711          buflen = strlen (libbuf);
    1633           buf = xmalloc(libdir_maxlen + buflen + 2);
     1712          buf = xmalloc (libdir_maxlen + buflen + 2);
    16341713        }
    16351714      else if (buflen < strlen (libbuf))
     
    16451724
    16461725        for (dp = dirs; *dp != 0; ++dp)
    1647           {
     1726          {
    16481727            sprintf (buf, "%s/%s", *dp, libbuf);
    16491728            mtime = name_mtime (buf);
    16501729            if (mtime != NONEXISTENT_MTIME)
    1651               {
     1730              {
    16521731                if (file == 0 || vpath_index < best_vpath)
    16531732                  {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette