Ignore:
Timestamp:
Sep 15, 2006, 7:09:38 AM (19 years ago)
Author:
bird
Message:

Untested merge with GNU Make v3.81 (vendor/gnumake/2005-05-16 -> vendor/gnumake/current).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gmake/remake.c

    r352 r503  
    11/* Basic dependency engine for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999,
    3 2002 Free Software Foundation, Inc.
     2Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
     4Foundation, Inc.
    45This file is part of GNU Make.
    56
    6 GNU Make is free software; you can redistribute it and/or modify
    7 it under the terms of the GNU General Public License as published by
    8 the Free Software Foundation; either version 2, or (at your option)
    9 any later version.
    10 
    11 GNU Make is distributed in the hope that it will be useful,
    12 but WITHOUT ANY WARRANTY; without even the implied warranty of
    13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14 GNU General Public License for more details.
    15 
    16 You should have received a copy of the GNU General Public License
    17 along with GNU Make; see the file COPYING.  If not, write to
    18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    19 Boston, MA 02111-1307, USA.  */
     7GNU Make is free software; you can redistribute it and/or modify it under the
     8terms of the GNU General Public License as published by the Free Software
     9Foundation; either version 2, or (at your option) any later version.
     10
     11GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
     12WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     13A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     14
     15You should have received a copy of the GNU General Public License along with
     16GNU Make; see the file COPYING.  If not, write to the Free Software
     17Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.  */
    2018
    2119#include "make.h"
     
    161159                 by calling update_file above.  We check this flag below to
    162160                 decide when to give an "up to date" diagnostic.  */
    163               g->changed += commands_started - ocommands_started;
     161              if (commands_started > ocommands_started)
     162                g->changed = 1;
    164163
    165164              /* If we updated a file and STATUS was not already 1, set it to
     
    267266      job_slots = j;
    268267    }
     268
    269269  return status;
    270270}
     
    309309      status |= update_file_1 (f, depth);
    310310      check_renamed (f);
     311
     312      /* Clean up any alloca() used during the update.  */
     313      alloca (0);
    311314
    312315      /* If we got an error, don't bother with double_colon etc.  */
     
    534537
    535538      if (!running)
    536         d->changed = file_mtime (d->file) != mtime;
     539        /* The prereq is considered changed if the timestamp has changed while
     540           it was built, OR it doesn't exist.
     541           This causes the Linux kernel build to break.  We'll defer this
     542           fix until GNU make 3.82 to give them time to update.  */
     543        d->changed = ((file_mtime (d->file) != mtime)
     544                      /* || (mtime == NONEXISTENT_MTIME) */);
    537545
    538546      lastd = d;
     
    857865  if ((ran && !file->phony) || touched)
    858866    {
    859       struct file *f;
    860867      int i = 0;
    861868
     
    877884
    878885      file->last_mtime = i == 0 ? UNKNOWN_MTIME : NEW_MTIME;
    879 
    880       /* Propagate the change of modification time to all the double-colon
    881          entries for this file.  */
    882       for (f = file->double_colon; f != 0; f = f->prev)
    883         f->last_mtime = file->last_mtime;
     886    }
     887
     888  if (file->double_colon)
     889    {
     890      /* If this is a double colon rule and it is the last one to be
     891         updated, propagate the change of modification time to all the
     892         double-colon entries for this file.
     893
     894         We do it on the last update because it is important to handle
     895         individual entries as separate rules with separate timestamps
     896         while they are treated as targets and then as one rule with the
     897         unified timestamp when they are considered as a prerequisite
     898         of some target.  */
     899
     900      struct file *f;
     901      FILE_TIMESTAMP max_mtime = file->last_mtime;
     902
     903      /* Check that all rules were updated and at the same time find
     904         the max timestamp.  We assume UNKNOWN_MTIME is newer then
     905         any other value.  */
     906      for (f = file->double_colon; f != 0 && f->updated; f = f->prev)
     907        if (max_mtime != UNKNOWN_MTIME
     908            && (f->last_mtime == UNKNOWN_MTIME || f->last_mtime > max_mtime))
     909          max_mtime = f->last_mtime;
     910
     911      if (f == 0)
     912        for (f = file->double_colon; f != 0; f = f->prev)
     913          f->last_mtime = max_mtime;
    884914    }
    885915
     
    9871017                    {
    9881018                      file->deps = d->next;
    989                       free ((char *) d);
     1019                      free_dep (d);
    9901020                      d = file->deps;
    9911021                    }
     
    9931023                    {
    9941024                      lastd->next = d->next;
    995                       free ((char *) d);
     1025                      free_dep (d);
    9961026                      d = lastd->next;
    9971027                    }
     
    12441274              rehash_file (file, name);
    12451275              check_renamed (file);
    1246               mtime = name_mtime (name);
     1276              /* If the result of a vpath search is -o or -W, preserve it.
     1277                 Otherwise, find the mtime of the resulting file.  */
     1278              if (mtime != OLD_MTIME && mtime != NEW_MTIME)
     1279                mtime = name_mtime (name);
    12471280            }
    12481281        }
    12491282    }
    12501283
    1251   {
    1252     /* Files can have bogus timestamps that nothing newly made will be
    1253        "newer" than.  Updating their dependents could just result in loops.
    1254        So notify the user of the anomaly with a warning.
    1255 
    1256        We only need to do this once, for now. */
    1257 
    1258     if (!clock_skew_detected
    1259         && mtime != NONEXISTENT_MTIME
    1260         && !file->updated)
    1261       {
    1262         static FILE_TIMESTAMP adjusted_now;
    1263 
    1264         FILE_TIMESTAMP adjusted_mtime = mtime;
     1284  /* Files can have bogus timestamps that nothing newly made will be
     1285     "newer" than.  Updating their dependents could just result in loops.
     1286     So notify the user of the anomaly with a warning.
     1287
     1288     We only need to do this once, for now. */
     1289
     1290  if (!clock_skew_detected
     1291      && mtime != NONEXISTENT_MTIME && mtime != NEW_MTIME
     1292      && !file->updated)
     1293    {
     1294      static FILE_TIMESTAMP adjusted_now;
     1295
     1296      FILE_TIMESTAMP adjusted_mtime = mtime;
    12651297
    12661298#if defined(WINDOWS32) || defined(__MSDOS__)
    1267         /* Experimentation has shown that FAT filesystems can set file times
    1268            up to 3 seconds into the future!  Play it safe.  */
     1299      /* Experimentation has shown that FAT filesystems can set file times
     1300         up to 3 seconds into the future!  Play it safe.  */
    12691301
    12701302#define FAT_ADJ_OFFSET  (FILE_TIMESTAMP) 3
    12711303
    1272         FILE_TIMESTAMP adjustment = FAT_ADJ_OFFSET << FILE_TIMESTAMP_LO_BITS;
    1273         if (ORDINARY_MTIME_MIN + adjustment <= adjusted_mtime)
    1274           adjusted_mtime -= adjustment;
     1304      FILE_TIMESTAMP adjustment = FAT_ADJ_OFFSET << FILE_TIMESTAMP_LO_BITS;
     1305      if (ORDINARY_MTIME_MIN + adjustment <= adjusted_mtime)
     1306        adjusted_mtime -= adjustment;
    12751307#elif defined(__EMX__)
    1276         /* FAT filesystems round time to the nearest even second!
    1277            Allow for any file (NTFS or FAT) to perhaps suffer from this
    1278            brain damage.  */
    1279         FILE_TIMESTAMP adjustment = (((FILE_TIMESTAMP_S (adjusted_mtime) & 1) == 0
    1280                        && FILE_TIMESTAMP_NS (adjusted_mtime) == 0)
    1281                       ? (FILE_TIMESTAMP) 1 << FILE_TIMESTAMP_LO_BITS
    1282                       : 0);
     1308      /* FAT filesystems round time to the nearest even second!
     1309         Allow for any file (NTFS or FAT) to perhaps suffer from this
     1310         brain damage.  */
     1311      FILE_TIMESTAMP adjustment = (((FILE_TIMESTAMP_S (adjusted_mtime) & 1) == 0
     1312                     && FILE_TIMESTAMP_NS (adjusted_mtime) == 0)
     1313                    ? (FILE_TIMESTAMP) 1 << FILE_TIMESTAMP_LO_BITS
     1314                    : 0);
    12831315#endif
    12841316
    1285         /* If the file's time appears to be in the future, update our
    1286            concept of the present and try once more.  */
    1287         if (adjusted_now < adjusted_mtime)
    1288           {
    1289             int resolution;
    1290             FILE_TIMESTAMP now = file_timestamp_now (&resolution);
    1291             adjusted_now = now + (resolution - 1);
    1292             if (adjusted_now < adjusted_mtime)
    1293               {
     1317      /* If the file's time appears to be in the future, update our
     1318         concept of the present and try once more.  */
     1319      if (adjusted_now < adjusted_mtime)
     1320        {
     1321          int resolution;
     1322          FILE_TIMESTAMP now = file_timestamp_now (&resolution);
     1323          adjusted_now = now + (resolution - 1);
     1324          if (adjusted_now < adjusted_mtime)
     1325            {
    12941326#ifdef NO_FLOAT
    1295                 error (NILF, _("Warning: File `%s' has modification time in the future"),
    1296                        file->name);
     1327              error (NILF, _("Warning: File `%s' has modification time in the future"),
     1328                     file->name);
    12971329#else
    1298                 double from_now =
    1299                   (FILE_TIMESTAMP_S (mtime) - FILE_TIMESTAMP_S (now)
    1300                    + ((FILE_TIMESTAMP_NS (mtime) - FILE_TIMESTAMP_NS (now))
    1301                       / 1e9));
    1302                 error (NILF, _("Warning: File `%s' has modification time %.2g s in the future"),
    1303                        file->name, from_now);
     1330              double from_now =
     1331                (FILE_TIMESTAMP_S (mtime) - FILE_TIMESTAMP_S (now)
     1332                 + ((FILE_TIMESTAMP_NS (mtime) - FILE_TIMESTAMP_NS (now))
     1333                    / 1e9));
     1334              error (NILF, _("Warning: File `%s' has modification time %.2g s in the future"),
     1335                     file->name, from_now);
    13041336#endif
    1305                 clock_skew_detected = 1;
    1306               }
    1307           }
    1308       }
    1309   }
     1337              clock_skew_detected = 1;
     1338            }
     1339        }
     1340    }
    13101341
    13111342  /* Store the mtime into all the entries for this file.  */
     
    13501381
    13511382  EINTRLOOP (e, stat (name, &st));
    1352   if (e != 0)
    1353     {
    1354       if (errno != ENOENT && errno != ENOTDIR)
    1355         perror_with_name ("stat: ", name);
     1383  if (e == 0)
     1384    mtime = FILE_TIMESTAMP_STAT_MODTIME (name, st);
     1385  else if (errno == ENOENT || errno == ENOTDIR)
     1386    mtime = NONEXISTENT_MTIME;
     1387  else
     1388    {
     1389      perror_with_name ("stat: ", name);
    13561390      return NONEXISTENT_MTIME;
    13571391    }
    1358   mtime = FILE_TIMESTAMP_STAT_MODTIME (name, st);
     1392
     1393  /* If we get here we either found it, or it doesn't exist.
     1394     If it doesn't exist see if we can use a symlink mtime instead.  */
    13591395
    13601396#ifdef MAKE_SYMLINKS
     
    13831419          if (e)
    13841420            {
    1385               /* Eh?  Just take what we have.  */
    1386               perror_with_name ("lstat: ", lpath);
     1421              /* Just take what we have so far.  */
     1422              if (errno != ENOENT && errno != ENOTDIR)
     1423                perror_with_name ("lstat: ", lpath);
    13871424              break;
    13881425            }
Note: See TracChangeset for help on using the changeset viewer.