Changeset 287 for trunk/src/gmake/remake.c
- Timestamp:
- May 17, 2005, 1:34:55 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gmake/remake.c
r218 r287 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 … … 856 925 start_updating (file); 857 926 858 if ( !file->intermediate)859 /* If this is a non-intermediate file, update it and record860 whether it is newer than THIS_MTIME. */861 {927 if (file->phony || !file->intermediate) 928 { 929 /* If this is a non-intermediate file, update it and record 930 whether it is newer than THIS_MTIME. */ 862 931 FILE_TIMESTAMP mtime; 863 932 dep_status = update_file (file, depth); … … 1026 1095 else 1027 1096 { 1028 const char *msg_noparent1029 = _("%sNo rule to make target `%s'%s");1030 const char *msg_parent1031 = _("%sNo rule to make target `%s', needed by `%s'%s");1032 1033 1097 /* This is a dependency file we cannot remake. Fail. */ 1034 if (!keep_going_flag && !file->dontcare) 1035 { 1036 if (file->parent == 0) 1037 fatal (NILF, msg_noparent, "", file->name, ""); 1038 1039 fatal (NILF, msg_parent, "", file->name, file->parent->name, ""); 1040 } 1041 1042 if (!file->dontcare) 1043 { 1044 if (file->parent == 0) 1045 error (NILF, msg_noparent, "*** ", file->name, "."); 1046 else 1047 error (NILF, msg_parent, "*** ", 1048 file->name, file->parent->name, "."); 1049 } 1098 if (!rebuilding_makefiles || !file->dontcare) 1099 complain (file); 1050 1100 file->update_status = 2; 1051 1101 } … … 1283 1333 /* Return the mtime of the file or archive-member reference NAME. */ 1284 1334 1335 /* First, we check with stat(). If the file does not exist, then we return 1336 NONEXISTENT_MTIME. If it does, and the symlink check flag is set, then 1337 examine each indirection of the symlink and find the newest mtime. 1338 This causes one duplicate stat() when -L is being used, but the code is 1339 much cleaner. */ 1340 1285 1341 static FILE_TIMESTAMP 1286 1342 name_mtime (char *name) 1287 1343 { 1344 FILE_TIMESTAMP mtime; 1288 1345 struct stat st; 1289 1346 int e; … … 1293 1350 { 1294 1351 if (errno != ENOENT && errno != ENOTDIR) 1295 perror_with_name ("stat: ", name);1352 perror_with_name ("stat: ", name); 1296 1353 return NONEXISTENT_MTIME; 1297 1354 } 1298 1299 return FILE_TIMESTAMP_STAT_MODTIME (name, st); 1355 mtime = FILE_TIMESTAMP_STAT_MODTIME (name, st); 1356 1357 #ifdef MAKE_SYMLINKS 1358 #ifndef S_ISLNK 1359 # define S_ISLNK(_m) (((_m)&S_IFMT)==S_IFLNK) 1360 #endif 1361 if (check_symlink_flag) 1362 { 1363 PATH_VAR (lpath); 1364 1365 /* Check each symbolic link segment (if any). Find the latest mtime 1366 amongst all of them (and the target file of course). 1367 Note that we have already successfully dereferenced all the links 1368 above. So, if we run into any error trying to lstat(), or 1369 readlink(), or whatever, something bizarre-o happened. Just give up 1370 and use whatever mtime we've already computed at that point. */ 1371 strcpy (lpath, name); 1372 while (1) 1373 { 1374 FILE_TIMESTAMP ltime; 1375 PATH_VAR (lbuf); 1376 long llen; 1377 char *p; 1378 1379 EINTRLOOP (e, lstat (lpath, &st)); 1380 if (e) 1381 { 1382 /* Eh? Just take what we have. */ 1383 perror_with_name ("lstat: ", lpath); 1384 break; 1385 } 1386 1387 /* If this is not a symlink, we're done (we started with the real 1388 file's mtime so we don't need to test it again). */ 1389 if (!S_ISLNK (st.st_mode)) 1390 break; 1391 1392 /* If this mtime is newer than what we had, keep the new one. */ 1393 ltime = FILE_TIMESTAMP_STAT_MODTIME (lpath, st); 1394 if (ltime > mtime) 1395 mtime = ltime; 1396 1397 /* Set up to check the file pointed to by this link. */ 1398 EINTRLOOP (llen, readlink (lpath, lbuf, GET_PATH_MAX)); 1399 if (llen < 0) 1400 { 1401 /* Eh? Just take what we have. */ 1402 perror_with_name ("readlink: ", lpath); 1403 break; 1404 } 1405 lbuf[llen] = '\0'; 1406 1407 /* If the target is fully-qualified or the source is just a 1408 filename, then the new path is the target. Otherwise it's the 1409 source directory plus the target. */ 1410 if (lbuf[0] == '/' || (p = strrchr (lpath, '/')) == NULL) 1411 strcpy (lpath, lbuf); 1412 else if ((p - lpath) + llen + 2 > GET_PATH_MAX) 1413 /* Eh? Path too long! Again, just go with what we have. */ 1414 break; 1415 else 1416 /* Create the next step in the symlink chain. */ 1417 strcpy (p+1, lbuf); 1418 } 1419 } 1420 #endif 1421 1422 return mtime; 1300 1423 } 1301 1424
Note:
See TracChangeset
for help on using the changeset viewer.