Changeset 280 for branches/GNU/src/gmake/remake.c
- Timestamp:
- May 16, 2005, 6:54:02 PM (20 years ago)
- Location:
- branches/GNU/src/gmake
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/gmake
- Property svn:ignore
-
old new 34 34 README.DOS 35 35 README.W32 36 README.OS2 36 37 aclocal.m4 37 38 autom4te.cache
-
- Property svn:ignore
-
branches/GNU/src/gmake/remake.c
r153 r280 75 75 /* Remake all the goals in the `struct dep' chain GOALS. Return -1 if nothing 76 76 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. */ 81 82 82 83 int 83 update_goal_chain (struct dep *goals , int makefiles)84 update_goal_chain (struct dep *goals) 84 85 { 85 86 int t = touch_flag, q = question_flag, n = just_print_flag; … … 87 88 int status = -1; 88 89 89 #define MTIME(file) ( makefiles ? file_mtime_no_search (file) \90 #define MTIME(file) (rebuilding_makefiles ? file_mtime_no_search (file) \ 90 91 : file_mtime (file)) 91 92 … … 137 138 int x; 138 139 check_renamed (file); 139 if ( makefiles)140 if (rebuilding_makefiles) 140 141 { 141 142 if (file->cmd_target) … … 154 155 ocommands_started = commands_started; 155 156 156 x = update_file (file, makefiles ? 1 : 0);157 x = update_file (file, rebuilding_makefiles ? 1 : 0); 157 158 check_renamed (file); 158 159 … … 177 178 matter how much more we run, since we already know 178 179 the answer to return. */ 179 stop = ( !keep_going_flag && !question_flag180 && ! makefiles);180 stop = (question_flag && !keep_going_flag 181 && !rebuilding_makefiles); 181 182 } 182 183 else … … 194 195 If STATUS is changed, we will get re-exec'd, and 195 196 enter an infinite loop. */ 196 if (! makefiles197 if (!rebuilding_makefiles 197 198 || (!just_print_flag && !question_flag)) 198 199 status = 0; 199 if ( makefiles && file->dontcare)200 if (rebuilding_makefiles && file->dontcare) 200 201 /* This is a default makefile; stop remaking. */ 201 202 stop = 1; … … 220 221 print a message saying nothing needs doing. */ 221 222 222 if (! makefiles223 if (!rebuilding_makefiles 223 224 /* If the update_status is zero, we updated successfully 224 225 or not at all. G->changed will have been set above if … … 259 260 } 260 261 261 if ( makefiles)262 if (rebuilding_makefiles) 262 263 { 263 264 touch_flag = t; … … 309 310 check_renamed (f); 310 311 312 /* If we got an error, don't bother with double_colon etc. */ 311 313 if (status != 0 && !keep_going_flag) 312 break;314 return status; 313 315 314 316 if (f->command_state == cs_running … … 324 326 /* Process the remaining rules in the double colon chain so they're marked 325 327 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 } 335 338 336 339 return status; 337 340 } 338 341 342 343 /* Show a message stating the target failed to build. */ 344 345 static void 346 complain (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 } 339 366 340 367 /* Consider a single `struct file' and update it as appropriate. */ … … 357 384 DBF (DB_VERBOSE, 358 385 _("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 359 397 return file->update_status; 360 398 } … … 435 473 FILE_TIMESTAMP mtime; 436 474 int maybe_make; 475 int dontcare = 0; 437 476 438 477 check_renamed (d->file); … … 458 497 d->file->parent = file; 459 498 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 460 508 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 461 514 if (! d->ignore_mtime) 462 515 must_make = maybe_make; … … 495 548 if (d->file->intermediate) 496 549 { 550 int dontcare = 0; 551 497 552 FILE_TIMESTAMP mtime = file_mtime (d->file); 498 553 check_renamed (d->file); 499 554 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 500 564 dep_status |= update_file (d->file, depth); 565 566 /* Restore original dontcare flag. */ 567 if (rebuilding_makefiles) 568 d->file->dontcare = dontcare; 569 501 570 check_renamed (d->file); 502 571 … … 846 915 start_updating (file); 847 916 848 if ( !file->intermediate)849 /* If this is a non-intermediate file, update it and record850 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. */ 852 921 FILE_TIMESTAMP mtime; 853 922 dep_status = update_file (file, depth); … … 1016 1085 else 1017 1086 { 1018 const char *msg_noparent1019 = _("%sNo rule to make target `%s'%s");1020 const char *msg_parent1021 = _("%sNo rule to make target `%s', needed by `%s'%s");1022 1023 1087 /* 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); 1040 1090 file->update_status = 2; 1041 1091 } … … 1273 1323 /* Return the mtime of the file or archive-member reference NAME. */ 1274 1324 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 1275 1331 static FILE_TIMESTAMP 1276 1332 name_mtime (char *name) 1277 1333 { 1334 FILE_TIMESTAMP mtime; 1278 1335 struct stat st; 1279 1336 int e; … … 1283 1340 { 1284 1341 if (errno != ENOENT && errno != ENOTDIR) 1285 perror_with_name ("stat: ", name);1342 perror_with_name ("stat: ", name); 1286 1343 return NONEXISTENT_MTIME; 1287 1344 } 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; 1290 1413 } 1291 1414
Note:
See TracChangeset
for help on using the changeset viewer.