Changeset 503 for trunk/src/gmake/remake.c
- Timestamp:
- Sep 15, 2006, 7:09:38 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gmake/remake.c
r352 r503 1 1 /* 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. 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software 4 Foundation, Inc. 4 5 This file is part of GNU Make. 5 6 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. */ 7 GNU Make is free software; you can redistribute it and/or modify it under the 8 terms of the GNU General Public License as published by the Free Software 9 Foundation; either version 2, or (at your option) any later version. 10 11 GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY 12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 13 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License along with 16 GNU Make; see the file COPYING. If not, write to the Free Software 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ 20 18 21 19 #include "make.h" … … 161 159 by calling update_file above. We check this flag below to 162 160 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; 164 163 165 164 /* If we updated a file and STATUS was not already 1, set it to … … 267 266 job_slots = j; 268 267 } 268 269 269 return status; 270 270 } … … 309 309 status |= update_file_1 (f, depth); 310 310 check_renamed (f); 311 312 /* Clean up any alloca() used during the update. */ 313 alloca (0); 311 314 312 315 /* If we got an error, don't bother with double_colon etc. */ … … 534 537 535 538 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) */); 537 545 538 546 lastd = d; … … 857 865 if ((ran && !file->phony) || touched) 858 866 { 859 struct file *f;860 867 int i = 0; 861 868 … … 877 884 878 885 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; 884 914 } 885 915 … … 987 1017 { 988 1018 file->deps = d->next; 989 free ((char *)d);1019 free_dep (d); 990 1020 d = file->deps; 991 1021 } … … 993 1023 { 994 1024 lastd->next = d->next; 995 free ((char *)d);1025 free_dep (d); 996 1026 d = lastd->next; 997 1027 } … … 1244 1274 rehash_file (file, name); 1245 1275 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); 1247 1280 } 1248 1281 } 1249 1282 } 1250 1283 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; 1265 1297 1266 1298 #if defined(WINDOWS32) || defined(__MSDOS__) 1267 1268 1299 /* Experimentation has shown that FAT filesystems can set file times 1300 up to 3 seconds into the future! Play it safe. */ 1269 1301 1270 1302 #define FAT_ADJ_OFFSET (FILE_TIMESTAMP) 3 1271 1303 1272 1273 1274 1304 FILE_TIMESTAMP adjustment = FAT_ADJ_OFFSET << FILE_TIMESTAMP_LO_BITS; 1305 if (ORDINARY_MTIME_MIN + adjustment <= adjusted_mtime) 1306 adjusted_mtime -= adjustment; 1275 1307 #elif defined(__EMX__) 1276 1277 1278 1279 1280 1281 1282 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); 1283 1315 #endif 1284 1316 1285 1286 1287 1288 1289 1290 1291 1292 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 { 1294 1326 #ifdef NO_FLOAT 1295 1296 1327 error (NILF, _("Warning: File `%s' has modification time in the future"), 1328 file->name); 1297 1329 #else 1298 1299 1300 1301 1302 1303 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); 1304 1336 #endif 1305 clock_skew_detected = 1; 1306 } 1307 } 1308 } 1309 } 1337 clock_skew_detected = 1; 1338 } 1339 } 1340 } 1310 1341 1311 1342 /* Store the mtime into all the entries for this file. */ … … 1350 1381 1351 1382 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); 1356 1390 return NONEXISTENT_MTIME; 1357 1391 } 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. */ 1359 1395 1360 1396 #ifdef MAKE_SYMLINKS … … 1383 1419 if (e) 1384 1420 { 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); 1387 1424 break; 1388 1425 }
Note:
See TracChangeset
for help on using the changeset viewer.