Changeset 3140 for trunk/src/kmk/remake.c
- Timestamp:
- Mar 14, 2018, 10:28:10 PM (7 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk
-
Property svn:mergeinfo
set to
/vendor/gnumake/current merged eligible
-
Property svn:mergeinfo
set to
-
trunk/src/kmk/remake.c
r2857 r3140 1 1 /* 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. 2 Copyright (C) 1988-2016 Free Software Foundation, Inc. 5 3 This file is part of GNU Make. 6 4 … … 17 15 this program. If not, see <http://www.gnu.org/licenses/>. */ 18 16 19 #include "make .h"17 #include "makeint.h" 20 18 #include "filedef.h" 21 19 #include "job.h" … … 40 38 #endif 41 39 42 extern int try_implicit_rule (struct file *file, unsigned int depth);43 44 40 45 41 /* The test for circular dependencies is based on the 'updating' bit in 46 `struct file'. However, double colon targets have seperate `struct42 'struct file'. However, double colon targets have separate 'struct 47 43 file's; make sure we always use the base of the double colon chain. */ 48 44 … … 58 54 unsigned int commands_started = 0; 59 55 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 #ifdef CONFIG_WITH_DOT_MUST_MAKE 68 static int call_must_make_target_var (struct file *file, unsigned int depth); 69 #endif 70 #ifdef CONFIG_WITH_DOT_IS_CHANGED 71 static int call_is_changed_target_var (struct file *file); 72 #endif 73 static int touch_file (struct file *file); 56 /* Set to the goal dependency. Mostly needed for remaking makefiles. */ 57 static struct goaldep *goal_list; 58 static struct dep *goal_dep; 59 60 /* Current value for pruning the scan of the goal chain. 61 All files start with considered == 0. */ 62 static unsigned int considered = 0; 63 64 static enum update_status update_file (struct file *file, unsigned int depth); 65 static enum update_status update_file_1 (struct file *file, unsigned int depth); 66 static enum update_status check_dep (struct file *file, unsigned int depth, 67 FILE_TIMESTAMP this_mtime, int *must_make); 68 static enum update_status touch_file (struct file *file); 74 69 static void remake_file (struct file *file); 75 70 static FILE_TIMESTAMP name_mtime (const char *name); 76 71 static const char *library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr); 77 72 78 79 80 /* Remake all the goals in the `struct dep' chain GOALS. Return -1 if nothing 73 #ifdef CONFIG_WITH_DOT_MUST_MAKE 74 static int call_must_make_target_var (struct file *file, unsigned int depth); 75 #endif 76 #ifdef CONFIG_WITH_DOT_IS_CHANGED 77 static int call_is_changed_target_var (struct file *file); 78 #endif 79 80 81 82 /* Remake all the goals in the 'struct dep' chain GOALS. Return -1 if nothing 81 83 was done, 0 if all goals were updated successfully, or 1 if a goal failed. 82 84 … … 84 86 and -n should be disabled for them unless they were also command-line 85 87 targets, and we should only make one goal at a time and return as soon as 86 one goal whose `changed' member is nonzero is successfully made. */87 88 int 89 update_goal_chain (struct dep *goals)88 one goal whose 'changed' member is nonzero is successfully made. */ 89 90 enum update_status 91 update_goal_chain (struct goaldep *goaldeps) 90 92 { 91 93 int t = touch_flag, q = question_flag, n = just_print_flag; 92 int status = -1; 93 94 #define MTIME(file) (rebuilding_makefiles ? file_mtime_no_search (file) \ 95 : file_mtime (file)) 94 enum update_status status = us_none; 96 95 97 96 /* Duplicate the chain so we can remove things from it. */ 98 97 99 goals = copy_dep_chain (goals); 100 101 { 102 /* Clear the `changed' flag of each goal in the chain. 103 We will use the flag below to notice when any commands 104 have actually been run for a target. When no commands 105 have been run, we give an "up to date" diagnostic. */ 106 107 struct dep *g; 108 for (g = goals; g != 0; g = g->next) 109 g->changed = 0; 110 } 111 112 /* All files start with the considered bit 0, so the global value is 1. */ 113 considered = 1; 98 struct dep *goals = copy_dep_chain ((struct dep *)goaldeps); 99 100 goal_list = rebuilding_makefiles ? goaldeps : NULL; 101 102 #define MTIME(file) (rebuilding_makefiles ? file_mtime_no_search (file) \ 103 : file_mtime (file)) 104 105 /* Start a fresh batch of consideration. */ 106 ++considered; 114 107 115 108 /* Update all the goals until they are all finished. */ … … 130 123 g = goals; 131 124 while (g != 0) 132 { 133 /* Iterate over all double-colon entries for this file. */ 134 struct file *file; 135 int stop = 0, any_not_updated = 0; 136 137 for (file = g->file->double_colon ? g->file->double_colon : g->file; 138 file != NULL; 139 file = file->prev) 140 { 141 unsigned int ocommands_started; 142 int x; 143 144 file->dontcare = g->dontcare; 145 146 check_renamed (file); 147 if (rebuilding_makefiles) 148 { 149 if (file->cmd_target) 150 { 151 touch_flag = t; 152 question_flag = q; 153 just_print_flag = n; 154 } 155 else 156 touch_flag = question_flag = just_print_flag = 0; 157 } 158 159 /* Save the old value of `commands_started' so we can compare 160 later. It will be incremented when any commands are 161 actually run. */ 162 ocommands_started = commands_started; 163 164 x = update_file (file, rebuilding_makefiles ? 1 : 0); 165 check_renamed (file); 166 167 /* Set the goal's `changed' flag if any commands were started 168 by calling update_file above. We check this flag below to 169 decide when to give an "up to date" diagnostic. */ 125 { 126 /* Iterate over all double-colon entries for this file. */ 127 struct file *file; 128 int stop = 0, any_not_updated = 0; 129 130 goal_dep = g; 131 132 for (file = g->file->double_colon ? g->file->double_colon : g->file; 133 file != NULL; 134 file = file->prev) 135 { 136 unsigned int ocommands_started; 137 enum update_status fail; 138 139 file->dontcare = ANY_SET (g->flags, RM_DONTCARE); 140 141 check_renamed (file); 142 if (rebuilding_makefiles) 143 { 144 if (file->cmd_target) 145 { 146 touch_flag = t; 147 question_flag = q; 148 just_print_flag = n; 149 } 150 else 151 touch_flag = question_flag = just_print_flag = 0; 152 } 153 154 /* Save the old value of 'commands_started' so we can compare 155 later. It will be incremented when any commands are 156 actually run. */ 157 ocommands_started = commands_started; 158 159 fail = update_file (file, rebuilding_makefiles ? 1 : 0); 160 check_renamed (file); 161 162 /* Set the goal's 'changed' flag if any commands were started 163 by calling update_file above. We check this flag below to 164 decide when to give an "up to date" diagnostic. */ 170 165 if (commands_started > ocommands_started) 171 166 g->changed = 1; 172 167 173 /* If we updated a file and STATUS was not already 1, set it to 174 1 if updating failed, or to 0 if updating succeeded. Leave 175 STATUS as it is if no updating was done. */ 176 177 stop = 0; 178 if ((x != 0 || file->updated) && status < 1) 168 stop = 0; 169 if ((fail || file->updated) && status < us_question) 179 170 { 180 if (file->update_status != 0) 171 /* We updated this goal. Update STATUS and decide whether 172 to stop. */ 173 if (file->update_status) 181 174 { 182 175 /* Updating failed, or -q triggered. The STATUS value … … 205 198 if (!rebuilding_makefiles 206 199 || (!just_print_flag && !question_flag)) 207 status = 0;200 status = us_success; 208 201 if (rebuilding_makefiles && file->dontcare) 209 202 /* This is a default makefile; stop remaking. */ … … 213 206 } 214 207 215 208 /* Keep track if any double-colon entry is not finished. 216 209 When they are all finished, the goal is finished. */ 217 210 any_not_updated |= !file->updated; 218 211 219 212 file->dontcare = 0; 220 213 221 222 223 224 225 226 227 228 229 230 231 232 233 234 /* If the update_status is zero, we updated successfully235 236 237 && file->update_status == 0&& !g->changed238 239 240 message (1, ((file->phony || file->cmds == 0)241 ? _("Nothing to be done for `%s'.")242 : _("`%s' is up to date.")),243 244 245 246 247 248 249 250 251 214 if (stop) 215 break; 216 } 217 218 /* Reset FILE since it is null at the end of the loop. */ 219 file = g->file; 220 221 if (stop || !any_not_updated) 222 { 223 /* If we have found nothing whatever to do for the goal, 224 print a message saying nothing needs doing. */ 225 226 if (!rebuilding_makefiles 227 /* If the update_status is success, we updated successfully 228 or not at all. G->changed will have been set above if 229 any commands were actually started for this goal. */ 230 && file->update_status == us_success && !g->changed 231 /* Never give a message under -s or -q. */ 232 && !silent_flag && !question_flag) 233 OS (message, 1, ((file->phony || file->cmds == 0) 234 ? _("Nothing to be done for '%s'.") 235 : _("'%s' is up to date.")), 236 file->name); 237 238 /* This goal is finished. Remove it from the chain. */ 239 if (lastgoal == 0) 240 goals = g->next; 241 else 242 lastgoal->next = g->next; 243 244 /* Free the storage. */ 252 245 #ifndef CONFIG_WITH_ALLOC_CACHES 253 246 free (g); 254 247 #else 255 248 free_dep (g); 256 249 #endif 257 250 258 259 260 261 262 263 264 265 266 267 268 269 270 /* If we reached the end of the dependency graph toggle the considered271 f lag for the next pass. */251 g = lastgoal == 0 ? goals : lastgoal->next; 252 253 if (stop) 254 break; 255 } 256 else 257 { 258 lastgoal = g; 259 g = g->next; 260 } 261 } 262 263 /* If we reached the end of the dependency graph update CONSIDERED 264 for the next pass. */ 272 265 if (g == 0) 273 considered = !considered;266 ++considered; 274 267 } 275 268 … … 285 278 286 279 280 /* If we're rebuilding an included makefile that failed, and we care 281 about errors, show an error message the first time. */ 282 283 void 284 show_goal_error (void) 285 { 286 struct goaldep *goal; 287 288 if ((goal_dep->flags & (RM_INCLUDED|RM_DONTCARE)) != RM_INCLUDED) 289 return; 290 291 for (goal = goal_list; goal; goal = goal->next) 292 if (goal_dep->file == goal->file) 293 { 294 if (goal->error) 295 { 296 OSS (error, &goal->floc, "%s: %s", 297 goal->file->name, strerror ((int)goal->error)); 298 goal->error = 0; 299 } 300 return; 301 } 302 } 303 304 287 305 /* If FILE is not up to date, execute the commands for it. 288 Return 0 if successful, 1if unsuccessful;289 but with some flag settings, just call `exit' if unsuccessful.306 Return 0 if successful, non-0 if unsuccessful; 307 but with some flag settings, just call 'exit' if unsuccessful. 290 308 291 309 DEPTH is the depth in recursions of this function. … … 297 315 each is considered in turn. */ 298 316 299 static int317 static enum update_status 300 318 update_file (struct file *file, unsigned int depth) 301 319 { 302 register int status = 0;303 registerstruct file *f;320 enum update_status status = us_success; 321 struct file *f; 304 322 305 323 f = file->double_colon ? file->double_colon : file; … … 312 330 { 313 331 /* Check for the case where a target has been tried and failed but 314 the diagnostics ha sn't been issued. If we need the diagnostics332 the diagnostics haven't been issued. If we need the diagnostics 315 333 then we will have to continue. */ 316 if (!(f->updated && f->update_status > 0 && !f->dontcare && f->no_diag)) 317 { 318 DBF (DB_VERBOSE, _("Pruning file `%s'.\n")); 319 return f->command_state == cs_finished ? f->update_status : 0; 334 if (!(f->updated && f->update_status > us_none 335 && !f->dontcare && f->no_diag)) 336 { 337 DBF (DB_VERBOSE, _("Pruning file '%s'.\n")); 338 return f->command_state == cs_finished ? f->update_status : us_success; 320 339 } 321 340 } … … 325 344 for (; f != 0; f = f->prev) 326 345 { 346 enum update_status new; 347 327 348 f->considered = considered; 328 349 329 status |= update_file_1 (f, depth);350 new = update_file_1 (f, depth); 330 351 check_renamed (f); 331 352 … … 334 355 335 356 /* If we got an error, don't bother with double_colon etc. */ 336 if ( status != 0&& !keep_going_flag)337 return status;357 if (new && !keep_going_flag) 358 return new; 338 359 339 360 if (f->command_state == cs_running 340 361 || f->command_state == cs_deps_running) 341 {342 /* Don't run the other :: rules for this 343 file until this rule is finished. */ 344 status = 0; 345 break;346 }362 /* Don't run other :: rules for this target until 363 this rule is finished. */ 364 return us_success; 365 366 if (new > status) 367 status = new; 347 368 } 348 369 … … 357 378 358 379 for (d = f->deps; d != 0; d = d->next) 359 status |= update_file (d->file, depth + 1); 380 { 381 enum update_status new = update_file (d->file, depth + 1); 382 if (new > status) 383 status = new; 384 } 360 385 } 361 386 … … 369 394 complain (struct file *file) 370 395 { 371 const char *msg_noparent372 = _("%sNo rule to make target `%s'%s");373 const char *msg_parent374 = _("%sNo rule to make target `%s', needed by `%s'%s");375 376 396 /* If this file has no_diag set then it means we tried to update it 377 397 before in the dontcare mode and failed. The target that actually … … 384 404 for (d = file->deps; d != 0; d = d->next) 385 405 { 386 if (d->file->updated && d->file->update_status > 0&& file->no_diag)406 if (d->file->updated && d->file->update_status > us_none && file->no_diag) 387 407 { 388 408 complain (d->file); … … 393 413 if (d == 0) 394 414 { 415 show_goal_error (); 416 395 417 /* Didn't find any dependencies to complain about. */ 396 418 … … 435 457 #endif /* KMK */ 436 458 437 if ( !keep_going_flag)438 { 439 if (file->parent == 0)440 fatal (NILF, msg_noparent, "", file->name, "");441 442 fatal (NILF, msg_parent, "", file->name, file->parent->name, "");443 }444 445 if (file->parent == 0)446 error (NILF, msg_noparent, "*** ", file->name, ".");459 if (file->parent) 460 { 461 size_t l = strlen (file->name) + strlen (file->parent->name) + 4; 462 const char *m = _("%sNo rule to make target '%s', needed by '%s'%s"); 463 464 if (!keep_going_flag) 465 fatal (NILF, l, m, "", file->name, file->parent->name, ""); 466 467 error (NILF, l, m, "*** ", file->name, file->parent->name, "."); 468 } 447 469 else 448 error (NILF, msg_parent, "*** ", file->name, file->parent->name, "."); 470 { 471 size_t l = strlen (file->name) + 4; 472 const char *m = _("%sNo rule to make target '%s'%s"); 473 474 if (!keep_going_flag) 475 fatal (NILF, l, m, "", file->name, ""); 476 477 error (NILF, l, m, "*** ", file->name, "."); 478 } 449 479 450 480 file->no_diag = 0; … … 452 482 } 453 483 454 /* Consider a single `struct file' and update it as appropriate. */ 455 456 static int 484 /* Consider a single 'struct file' and update it as appropriate. 485 Return 0 on success, or non-0 on failure. */ 486 487 static enum update_status 457 488 update_file_1 (struct file *file, unsigned int depth) 458 489 { 490 enum update_status dep_status = us_success; 459 491 FILE_TIMESTAMP this_mtime; 460 492 int noexist, must_make, deps_changed; 461 int dep_status = 0;462 493 struct file *ofile; 463 494 struct dep *d, *ad; … … 482 513 { 483 514 if (file->multi_head == file) 484 DBS (DB_VERBOSE, (_("Considering target file `%s' (multi head).\n"), file->name));515 DBS (DB_VERBOSE, (_("Considering target file '%s' (multi head).\n"), file->name)); 485 516 else 486 517 { 487 518 org_file = file = file->multi_head; 488 DBS (DB_VERBOSE, (_("Considering target file `%s' -> multi head `%s'.\n"),519 DBS (DB_VERBOSE, (_("Considering target file '%s' -> multi head '%s'.\n"), 489 520 req_file->name, file->name)); 490 521 assert (file->multi_head == file); … … 493 524 else 494 525 #endif /* CONFIG_WITH_EXPLICIT_MULTITARGET */ 495 DBF (DB_VERBOSE, _("Considering target file `%s'.\n"));526 DBF (DB_VERBOSE, _("Considering target file '%s'.\n")); 496 527 497 528 if (file->updated) 498 529 { 499 if (file->update_status > 0)500 501 502 _("Recently tried and failed to update file `%s'.\n"));530 if (file->update_status > us_none) 531 { 532 DBF (DB_VERBOSE, 533 _("Recently tried and failed to update file '%s'.\n")); 503 534 504 535 /* If the file we tried to make is marked no_diag then no message … … 509 540 complain (file); 510 541 511 512 513 514 DBF (DB_VERBOSE, _("File `%s' was considered already.\n"));542 return file->update_status; 543 } 544 545 DBF (DB_VERBOSE, _("File '%s' was considered already.\n")); 515 546 return 0; 516 547 } … … 522 553 break; 523 554 case cs_running: 524 DBF (DB_VERBOSE, _("Still updating file `%s'.\n"));555 DBF (DB_VERBOSE, _("Still updating file '%s'.\n")); 525 556 return 0; 526 557 case cs_finished: 527 DBF (DB_VERBOSE, _("Finished updating file `%s'.\n"));558 DBF (DB_VERBOSE, _("Finished updating file '%s'.\n")); 528 559 return file->update_status; 529 560 default: … … 582 613 noexist = this_mtime == NONEXISTENT_MTIME; 583 614 if (noexist) 584 DBS (DB_BASIC, (_("File `%s' does not exist.\n"), f3->name));615 DBS (DB_BASIC, (_("File '%s' does not exist.\n"), f3->name)); 585 616 #else /* !CONFIG_WITH_EXPLICIT_MULTITARGET */ 586 617 this_mtime = file_mtime (file); … … 588 619 noexist = this_mtime == NONEXISTENT_MTIME; 589 620 if (noexist) 590 DBF (DB_BASIC, _("File `%s' does not exist.\n"));621 DBF (DB_BASIC, _("File '%s' does not exist.\n")); 591 622 #endif /* !CONFIG_WITH_EXPLICIT_MULTITARGET */ 592 623 else if (ORDINARY_MTIME_MIN <= this_mtime && this_mtime <= ORDINARY_MTIME_MAX 593 624 && file->low_resolution_time) 594 625 { 595 626 /* Avoid spurious rebuilds due to low resolution time stamps. */ 596 627 int ns = FILE_TIMESTAMP_NS (this_mtime); 597 628 if (ns != 0) 598 error (NILF, _("*** Warning: .LOW_RESOLUTION_TIME file `%s' has a high resolution time stamp"), 599 file->name); 629 OS (error, NILF, 630 _("*** Warning: .LOW_RESOLUTION_TIME file '%s' has a high resolution time stamp"), 631 file->name); 600 632 this_mtime += FILE_TIMESTAMPS_PER_S - 1 - ns; 601 633 } … … 609 641 { 610 642 if (try_implicit_rule (file, depth)) 611 DBF (DB_IMPLICIT, _("Found an implicit rule for `%s'.\n"));643 DBF (DB_IMPLICIT, _("Found an implicit rule for '%s'.\n")); 612 644 else 613 DBF (DB_IMPLICIT, _("No implicit rule found for `%s'.\n"));645 DBF (DB_IMPLICIT, _("No implicit rule found for '%s'.\n")); 614 646 file->tried_implicit = 1; 615 647 } … … 617 649 && default_file != 0 && default_file->cmds != 0) 618 650 { 619 DBF (DB_IMPLICIT, _("Using default recipe for `%s'.\n"));651 DBF (DB_IMPLICIT, _("Using default recipe for '%s'.\n")); 620 652 file->cmds = default_file->cmds; 621 653 } … … 648 680 while (d) 649 681 { 682 enum update_status new; 650 683 FILE_TIMESTAMP mtime; 651 684 int maybe_make; … … 669 702 #endif 670 703 671 error (NILF, _("Circular %s <- %s dependency dropped."),672 704 OSS (error, NILF, _("Circular %s <- %s dependency dropped."), 705 file->name, d->file->name); 673 706 /* We cannot free D here because our the caller will still have 674 707 a reference to it when we were called recursively via … … 692 725 } 693 726 694 dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make); 727 new = check_dep (d->file, depth, this_mtime, &maybe_make); 728 if (new > dep_status) 729 dep_status = new; 695 730 696 731 /* Restore original dontcare flag. */ … … 716 751 } 717 752 718 if (dep_status != 0&& !keep_going_flag)753 if (dep_status && !keep_going_flag) 719 754 break; 720 755 721 756 if (!running) 722 /* The prereq is considered changed if the timestamp has changed while723 it was built, OR it doesn't exist. */757 /* The prereq is considered changed if the timestamp has changed 758 while it was built, OR it doesn't exist. */ 724 759 d->changed = ((file_mtime (d->file) != mtime) 725 760 || (mtime == NONEXISTENT_MTIME)); … … 757 792 { 758 793 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 759 for (file = f2 = org_file; f2; file = f2 = f2->multi_next) 760 #endif 761 for (d = file->deps; d != 0; d = d->next) 762 if (d->file->intermediate) 794 for (file = f2 = org_file; f2; file = f2 = f2->multi_next) 795 #endif 796 for (d = file->deps; d != 0; d = d->next) 797 if (d->file->intermediate) 798 { 799 enum update_status new; 800 int dontcare = 0; 801 802 FILE_TIMESTAMP mtime = file_mtime (d->file); 803 check_renamed (d->file); 804 d->file->parent = file; 805 806 /* Inherit dontcare flag from our parent. */ 807 if (rebuilding_makefiles) 808 { 809 dontcare = d->file->dontcare; 810 d->file->dontcare = file->dontcare; 811 } 812 813 /* We may have already considered this file, when we didn't know 814 we'd need to update it. Force update_file() to consider it and 815 not prune it. */ 816 d->file->considered = 0; 817 818 new = update_file (d->file, depth); 819 if (new > dep_status) 820 dep_status = new; 821 822 /* Restore original dontcare flag. */ 823 if (rebuilding_makefiles) 824 d->file->dontcare = dontcare; 825 826 check_renamed (d->file); 827 763 828 { 764 int dontcare = 0; 765 766 FILE_TIMESTAMP mtime = file_mtime (d->file); 767 check_renamed (d->file); 768 d->file->parent = file; 769 770 /* Inherit dontcare flag from our parent. */ 771 if (rebuilding_makefiles) 829 register struct file *f = d->file; 830 if (f->double_colon) 831 f = f->double_colon; 832 do 772 833 { 773 dontcare = d->file->dontcare; 774 d->file->dontcare = file->dontcare; 834 running |= (f->command_state == cs_running 835 || f->command_state == cs_deps_running); 836 f = f->prev; 775 837 } 776 777 778 dep_status |= update_file (d->file, depth); 779 780 /* Restore original dontcare flag. */ 781 if (rebuilding_makefiles) 782 d->file->dontcare = dontcare; 783 784 check_renamed (d->file); 785 786 { 787 register struct file *f = d->file; 788 if (f->double_colon) 789 f = f->double_colon; 790 do 791 { 792 running |= (f->command_state == cs_running 793 || f->command_state == cs_deps_running); 794 f = f->prev; 795 } 796 while (f != 0); 797 } 798 799 if (dep_status != 0 && !keep_going_flag) 800 break; 801 802 if (!running) 803 d->changed = ((file->phony && file->cmds != 0) 804 || file_mtime (d->file) != mtime); 838 while (f != 0); 805 839 } 840 841 if (dep_status && !keep_going_flag) 842 break; 843 844 if (!running) 845 d->changed = ((file->phony && file->cmds != 0) 846 || file_mtime (d->file) != mtime); 847 } 806 848 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 807 849 file = org_file; … … 812 854 finish_updating (ofile); 813 855 814 DBF (DB_VERBOSE, _("Finished prerequisites of target file `%s'.\n"));856 DBF (DB_VERBOSE, _("Finished prerequisites of target file '%s'.\n")); 815 857 816 858 if (running) … … 818 860 set_command_state (file, cs_deps_running); 819 861 --depth; 820 DBF (DB_VERBOSE, _("The prerequisites of `%s' are being made.\n"));862 DBF (DB_VERBOSE, _("The prerequisites of '%s' are being made.\n")); 821 863 return 0; 822 864 } … … 824 866 /* If any dependency failed, give up now. */ 825 867 826 if (dep_status != 0) 827 { 828 file->update_status = dep_status; 868 if (dep_status) 869 { 870 /* I'm not sure if we can't just assign dep_status... */ 871 file->update_status = dep_status == us_none ? us_failed : dep_status; 829 872 notice_finished_file (file); 830 873 831 874 --depth; 832 875 833 DBF (DB_VERBOSE, _("Giving up on target file `%s'.\n"));876 DBF (DB_VERBOSE, _("Giving up on target file '%s'.\n")); 834 877 835 878 if (depth == 0 && keep_going_flag 836 837 error (NILF,838 _("Target `%s' not remade because of errors."), file->name);879 && !just_print_flag && !question_flag) 880 OS (error, NILF, 881 _("Target '%s' not remade because of errors."), file->name); 839 882 840 883 return dep_status; … … 857 900 deps_changed = 0; 858 901 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 859 860 #endif 861 862 863 902 for (file = f2 = org_file; f2; file = f2 = f2->multi_next) 903 #endif 904 for (d = file->deps; d != 0; d = d->next) 905 { 906 FILE_TIMESTAMP d_mtime = file_mtime (d->file); 864 907 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 865 908 if (d->file == file && file->multi_maybe) 866 909 continue; 867 910 #endif 868 869 870 871 911 check_renamed (d->file); 912 913 if (! d->ignore_mtime) 914 { 872 915 #if 1 873 874 875 876 877 878 879 880 #endif 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 fmt = _("Prerequisite `%s' is order-only for target `%s'.\n");898 899 900 901 902 fmt = _("Prerequisite `%s' of target `%s' does not exist.\n");903 904 905 906 907 fmt = _("Prerequisite `%s' is newer than target `%s'.\n");908 909 910 fmt = _("Prerequisite `%s' is older than target `%s'.\n");911 912 913 914 915 916 917 918 919 916 /* %%% In version 4, remove this code completely to 917 implement not remaking deps if their deps are newer 918 than their parents. */ 919 if (d_mtime == NONEXISTENT_MTIME && !d->file->intermediate) 920 /* We must remake if this dep does not 921 exist and is not intermediate. */ 922 must_make = 1; 923 #endif 924 925 /* Set DEPS_CHANGED if this dep actually changed. */ 926 deps_changed |= d->changed; 927 } 928 929 /* Set D->changed if either this dep actually changed, 930 or its dependent, FILE, is older or does not exist. */ 931 d->changed |= noexist || d_mtime > this_mtime; 932 933 if (!noexist && ISDB (DB_BASIC|DB_VERBOSE)) 934 { 935 const char *fmt = 0; 936 937 if (d->ignore_mtime) 938 { 939 if (ISDB (DB_VERBOSE)) 940 fmt = _("Prerequisite '%s' is order-only for target '%s'.\n"); 941 } 942 else if (d_mtime == NONEXISTENT_MTIME) 943 { 944 if (ISDB (DB_BASIC)) 945 fmt = _("Prerequisite '%s' of target '%s' does not exist.\n"); 946 } 947 else if (d->changed) 948 { 949 if (ISDB (DB_BASIC)) 950 fmt = _("Prerequisite '%s' is newer than target '%s'.\n"); 951 } 952 else if (ISDB (DB_VERBOSE)) 953 fmt = _("Prerequisite '%s' is older than target '%s'.\n"); 954 955 if (fmt) 956 { 957 print_spaces (depth); 958 printf (fmt, dep_name (d), file->name); 959 fflush (stdout); 960 } 961 } 962 } 920 963 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 921 964 file = org_file; … … 929 972 must_make = 1; 930 973 DBF (DB_BASIC, 931 _("Target `%s' is double-colon and has no prerequisites.\n"));974 _("Target '%s' is double-colon and has no prerequisites.\n")); 932 975 } 933 976 else if (!noexist && file->is_target && !deps_changed && file->cmds == 0 … … 936 979 must_make = 0; 937 980 DBF (DB_VERBOSE, 938 _("No recipe for `%s' and no prerequisites actually changed.\n"));981 _("No recipe for '%s' and no prerequisites actually changed.\n")); 939 982 } 940 983 else if (!must_make && file->cmds != 0 && always_make_flag) 941 984 { 942 985 must_make = 1; 943 DBF (DB_VERBOSE, _("Making `%s' due to always-make flag.\n"));986 DBF (DB_VERBOSE, _("Making '%s' due to always-make flag.\n")); 944 987 } 945 988 … … 949 992 { 950 993 print_spaces (depth); 951 printf (_("No need to remake target `%s'"), file->name);994 printf (_("No need to remake target '%s'"), file->name); 952 995 if (!streq (file->name, file->hname)) 953 printf (_("; using VPATH name `%s'"), file->hname);996 printf (_("; using VPATH name '%s'"), file->hname); 954 997 puts ("."); 955 998 fflush (stdout); … … 971 1014 } 972 1015 973 DBF (DB_BASIC, _("Must remake target `%s'.\n"));1016 DBF (DB_BASIC, _("Must remake target '%s'.\n")); 974 1017 975 1018 /* It needs to be remade. If it's VPATH and not reset via GPATH, toss the 976 1019 VPATH. */ 977 if (!streq (file->name, file->hname))978 { 979 DB (DB_BASIC, (_(" Ignoring VPATH name `%s'.\n"), file->hname));1020 if (!streq (file->name, file->hname)) 1021 { 1022 DB (DB_BASIC, (_(" Ignoring VPATH name '%s'.\n"), file->hname)); 980 1023 file->ignore_vpath = 1; 981 1024 } … … 986 1029 if (file->command_state != cs_finished) 987 1030 { 988 DBF (DB_VERBOSE, _("Recipe of `%s' is being run.\n"));1031 DBF (DB_VERBOSE, _("Recipe of '%s' is being run.\n")); 989 1032 return 0; 990 1033 } … … 992 1035 switch (file->update_status) 993 1036 { 994 case 2:995 DBF (DB_BASIC, _("Failed to remake target file `%s'.\n"));1037 case us_failed: 1038 DBF (DB_BASIC, _("Failed to remake target file '%s'.\n")); 996 1039 break; 997 case 0:998 DBF (DB_BASIC, _("Successfully remade target file `%s'.\n"));1040 case us_success: 1041 DBF (DB_BASIC, _("Successfully remade target file '%s'.\n")); 999 1042 break; 1000 case 1:1001 DBF (DB_BASIC, _("Target file `%s' needsremade under -q.\n"));1043 case us_question: 1044 DBF (DB_BASIC, _("Target file '%s' needs to be remade under -q.\n")); 1002 1045 break; 1003 default: 1004 assert (file->update_status >= 0 && file->update_status <= 2); 1046 case us_none: 1005 1047 break; 1006 1048 } … … 1009 1051 return file->update_status; 1010 1052 } 1053 1054 1011 1055 #ifdef CONFIG_WITH_DOT_MUST_MAKE 1012 1013 1014 1056 /* Consider the .MUST_MAKE target variable if present. 1015 1057 … … 1048 1090 1049 1091 ch = *str; 1050 while ( isspace(ch))1092 while (ISSPACE (ch)) 1051 1093 ch = *++str; 1052 1094 … … 1066 1108 } 1067 1109 #endif /* CONFIG_WITH_DOT_MUST_MAKE */ 1110 1111 1068 1112 #ifdef CONFIG_WITH_DOT_IS_CHANGED 1069 1070 1071 1113 /* Consider the .IS_CHANGED target variable if present. 1072 1114 … … 1104 1146 do 1105 1147 ch = *str++; 1106 while ( isspace(ch));1148 while (ISSPACE (ch)); 1107 1149 1108 1150 return (ch != '\0'); … … 1114 1156 1115 1157 1116 /* Set FILE's `updated' flag and re-check its mtime and the mtime's of all1117 files listed in its `also_make' member. Under -t, this function also1158 /* Set FILE's 'updated' flag and re-check its mtime and the mtime's of all 1159 files listed in its 'also_make' member. Under -t, this function also 1118 1160 touches FILE. 1119 1161 1120 On return, FILE->update_status will no longer be -1if it was. */1162 On return, FILE->update_status will no longer be us_none if it was. */ 1121 1163 1122 1164 void … … 1161 1203 if (touch_flag 1162 1204 /* The update status will be: 1163 -1 if this target was not remade;1164 0 if 0 or more commands (+ or ${MAKE}) were run and won;1165 1if some commands were run and lost.1166 1167 1168 && file->update_status == 0)1205 us_success if 0 or more commands (+ or ${MAKE}) were run and won; 1206 us_none if this target was not remade; 1207 >us_none if some commands were run and lost. 1208 We touch the target if it has commands which either were not run 1209 or won when they ran (i.e. status is 0). */ 1210 && file->update_status == us_success) 1169 1211 { 1170 1212 if (file->cmds != 0 && file->cmds->any_recurse) 1171 1172 1173 1174 1175 1176 1177 1178 1213 { 1214 /* If all the command lines were recursive, 1215 we don't want to do the touching. */ 1216 unsigned int i; 1217 for (i = 0; i < file->cmds->ncommand_lines; ++i) 1218 if (!(file->cmds->lines_flags[i] & COMMANDS_RECURSE)) 1219 goto have_nonrecursing; 1220 } 1179 1221 else 1180 1181 1182 1222 { 1223 have_nonrecursing: 1224 if (file->phony) 1183 1225 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 1184 1226 { 1185 file->update_status = 0;1227 file->update_status = us_success; 1186 1228 if (file->multi_head) 1187 1229 for (f2 = file->multi_next; f2 != 0; f2 = f2->multi_next) 1188 f2->update_status = 0;1230 f2->update_status = us_success; 1189 1231 } 1190 1232 #else 1191 file->update_status = 0;1233 file->update_status = us_success; 1192 1234 #endif 1193 1235 /* According to POSIX, -t doesn't affect targets with no cmds. */ 1194 1236 else if (file->cmds != 0) 1195 1237 { 1196 1238 /* Should set file's modification date and do nothing else. */ … … 1205 1247 1206 1248 /* Pretend we ran a real touch command, to suppress the 1207 " `foo' is up to date" message. */1249 "'foo' is up to date" message. */ 1208 1250 commands_started++; 1209 1251 … … 1214 1256 touched = 1; 1215 1257 } 1216 1258 } 1217 1259 } 1218 1260 … … 1244 1286 1245 1287 else if (file->is_target && file->cmds == 0) 1246 1288 i = 1; 1247 1289 1248 1290 file->last_mtime = i == 0 ? UNKNOWN_MTIME : NEW_MTIME; … … 1282 1324 } 1283 1325 1284 if (ran && file->update_status != -1)1326 if (ran && file->update_status != us_none) 1285 1327 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 1286 1287 #endif 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1328 { 1329 #endif 1330 /* We actually tried to update FILE, which has 1331 updated its also_make's as well (if it worked). 1332 If it didn't work, it wouldn't work again for them. 1333 So mark them as updated with the same status. */ 1334 for (d = file->also_make; d != 0; d = d->next) 1335 { 1336 d->file->command_state = cs_finished; 1337 d->file->updated = 1; 1338 d->file->update_status = file->update_status; 1339 1340 if (ran && !d->file->phony) 1341 /* Fetch the new modification time. 1342 We do this instead of just invalidating the cached time 1343 so that a vpath_search can happen. Otherwise, it would 1344 never be done because the target is already updated. */ 1345 f_mtime (d->file, 0); 1346 } 1305 1347 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 #endif 1316 else if (file->update_status == -1)1348 /* Same as above but for explicit multi target rules. */ 1349 if (file->multi_head) 1350 for (f2 = file->multi_next; f2 != 0; f2 = f2->multi_next) 1351 { 1352 f2->update_status = file->update_status; 1353 if (!f2->phony) 1354 f_mtime (f2, 0); 1355 } 1356 } 1357 #endif 1358 else if (file->update_status == us_none) 1317 1359 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 1318 1360 { … … 1327 1369 /* Nothing was done for FILE, but it needed nothing done. 1328 1370 So mark it now as "succeeded". */ 1329 file->update_status = 0;1371 file->update_status = us_success; 1330 1372 #endif 1331 1373 … … 1345 1387 failed. */ 1346 1388 1347 static int1389 static enum update_status 1348 1390 check_dep (struct file *file, unsigned int depth, 1349 1391 FILE_TIMESTAMP this_mtime, int *must_make_ptr) … … 1351 1393 struct file *ofile; 1352 1394 struct dep *d; 1353 int dep_status = 0;1395 enum update_status dep_status = us_success; 1354 1396 1355 1397 ++depth; … … 1370 1412 check_renamed (file); 1371 1413 if (mtime == NONEXISTENT_MTIME || mtime > this_mtime) 1372 1414 *must_make_ptr = 1; 1373 1415 #ifdef CONFIG_WITH_DOT_IS_CHANGED 1374 1416 else if ( *must_make_ptr == 0 … … 1383 1425 1384 1426 if (!file->phony && file->cmds == 0 && !file->tried_implicit) 1385 1386 1387 DBF (DB_IMPLICIT, _("Found an implicit rule for `%s'.\n"));1388 1389 DBF (DB_IMPLICIT, _("No implicit rule found for `%s'.\n"));1390 1391 1427 { 1428 if (try_implicit_rule (file, depth)) 1429 DBF (DB_IMPLICIT, _("Found an implicit rule for '%s'.\n")); 1430 else 1431 DBF (DB_IMPLICIT, _("No implicit rule found for '%s'.\n")); 1432 file->tried_implicit = 1; 1433 } 1392 1434 if (file->cmds == 0 && !file->is_target 1393 1394 1395 DBF (DB_IMPLICIT, _("Using default commands for `%s'.\n"));1396 1397 1435 && default_file != 0 && default_file->cmds != 0) 1436 { 1437 DBF (DB_IMPLICIT, _("Using default commands for '%s'.\n")); 1438 file->cmds = default_file->cmds; 1439 } 1398 1440 1399 1441 check_renamed (file); … … 1403 1445 /* If the intermediate file actually exists and is newer, then we 1404 1446 should remake from it. */ 1405 1447 *must_make_ptr = 1; 1406 1448 else 1407 1449 { 1408 1450 /* Otherwise, update all non-intermediate files we depend on, if 1409 1451 necessary, and see whether any of them is more recent than the 1410 1452 file on whose behalf we are checking. */ 1411 1453 struct dep *ld; 1412 1454 int deps_running = 0; 1413 1455 … … 1416 1458 prerequisite and so wasn't rebuilt then, but should be now. */ 1417 1459 if (file->command_state != cs_running) 1418 set_command_state (file, cs_not_started); 1419 1420 ld = 0; 1421 d = file->deps; 1422 while (d != 0) 1423 { 1460 { 1461 /* If the target was waiting for a dependency it has to be 1462 reconsidered, as that dependency might have finished. */ 1463 if (file->command_state == cs_deps_running) 1464 file->considered = 0; 1465 1466 set_command_state (file, cs_not_started); 1467 } 1468 1469 ld = 0; 1470 d = file->deps; 1471 while (d != 0) 1472 { 1473 enum update_status new; 1424 1474 int maybe_make; 1425 1475 1426 1427 1428 error (NILF, _("Circular %s <- %s dependency dropped."),1429 1430 1431 1432 1476 if (is_updating (d->file)) 1477 { 1478 OSS (error, NILF, _("Circular %s <- %s dependency dropped."), 1479 file->name, d->file->name); 1480 if (ld == 0) 1481 { 1482 file->deps = d->next; 1433 1483 free_dep (d); 1434 1435 1436 1437 1438 1484 d = file->deps; 1485 } 1486 else 1487 { 1488 ld->next = d->next; 1439 1489 free_dep (d); 1440 1441 1442 1443 1444 1445 1490 d = ld->next; 1491 } 1492 continue; 1493 } 1494 1495 d->file->parent = file; 1446 1496 maybe_make = *must_make_ptr; 1447 dep_status |= check_dep (d->file, depth, this_mtime, 1448 &maybe_make); 1497 new = check_dep (d->file, depth, this_mtime, &maybe_make); 1498 if (new > dep_status) 1499 dep_status = new; 1500 1449 1501 if (! d->ignore_mtime) 1450 1502 *must_make_ptr = maybe_make; 1451 1452 if (dep_status != 0&& !keep_going_flag)1453 1454 1455 1456 1457 1458 1459 1460 1461 1503 check_renamed (d->file); 1504 if (dep_status && !keep_going_flag) 1505 break; 1506 1507 if (d->file->command_state == cs_running 1508 || d->file->command_state == cs_deps_running) 1509 deps_running = 1; 1510 1511 ld = d; 1512 d = d->next; 1513 } 1462 1514 1463 1515 if (deps_running) … … 1466 1518 commands are finished. */ 1467 1519 set_command_state (file, cs_deps_running); 1468 1520 } 1469 1521 } 1470 1522 … … 1476 1528 1477 1529 1478 /* Touch FILE. Return zero if successful, one if not. */ 1479 1480 #define TOUCH_ERROR(call) return (perror_with_name (call, file->name), 1) 1481 1482 static int 1530 /* Touch FILE. Return us_success if successful, us_failed if not. */ 1531 1532 #define TOUCH_ERROR(call) do{ perror_with_name ((call), file->name); \ 1533 return us_failed; }while(0) 1534 1535 static enum update_status 1483 1536 touch_file (struct file *file) 1484 1537 { 1485 1538 if (!silent_flag) 1486 message (0, "touch %s", file->name); 1487 1488 #ifndef NO_ARCHIVES 1539 OS (message, 0, "touch %s", file->name); 1540 1541 /* Print-only (-n) takes precedence over touch (-t). */ 1542 if (just_print_flag) 1543 return us_success; 1544 1545 #ifndef NO_ARCHIVES 1489 1546 if (ar_name (file->name)) 1490 return ar_touch (file->name) ;1547 return ar_touch (file->name) ? us_failed : us_success; 1491 1548 else 1492 1549 #endif 1493 1550 { 1494 int fd = open (file->name, O_RDWR | O_CREAT, 0666); 1495 1551 int fd; 1552 1553 EINTRLOOP (fd, open (file->name, O_RDWR | O_CREAT, 0666)); 1496 1554 if (fd < 0) 1497 1555 TOUCH_ERROR ("touch: open: "); 1498 1556 else 1499 1500 1501 1557 { 1558 struct stat statbuf; 1559 char buf = 'x'; 1502 1560 int e; 1503 1561 1504 1562 EINTRLOOP (e, fstat (fd, &statbuf)); 1505 if (e < 0) 1506 TOUCH_ERROR ("touch: fstat: "); 1507 /* Rewrite character 0 same as it already is. */ 1508 if (read (fd, &buf, 1) < 0) 1509 TOUCH_ERROR ("touch: read: "); 1510 if (lseek (fd, 0L, 0) < 0L) 1511 TOUCH_ERROR ("touch: lseek: "); 1512 if (write (fd, &buf, 1) < 0) 1513 TOUCH_ERROR ("touch: write: "); 1514 /* If file length was 0, we just 1515 changed it, so change it back. */ 1516 if (statbuf.st_size == 0) 1517 { 1518 (void) close (fd); 1519 fd = open (file->name, O_RDWR | O_TRUNC, 0666); 1520 if (fd < 0) 1521 TOUCH_ERROR ("touch: open: "); 1522 } 1523 (void) close (fd); 1524 } 1525 } 1526 1527 return 0; 1563 if (e < 0) 1564 TOUCH_ERROR ("touch: fstat: "); 1565 /* Rewrite character 0 same as it already is. */ 1566 EINTRLOOP (e, read (fd, &buf, 1)); 1567 if (e < 0) 1568 TOUCH_ERROR ("touch: read: "); 1569 { 1570 off_t o; 1571 EINTRLOOP (o, lseek (fd, 0L, 0)); 1572 if (o < 0L) 1573 TOUCH_ERROR ("touch: lseek: "); 1574 } 1575 EINTRLOOP (e, write (fd, &buf, 1)); 1576 if (e < 0) 1577 TOUCH_ERROR ("touch: write: "); 1578 1579 /* If file length was 0, we just changed it, so change it back. */ 1580 if (statbuf.st_size == 0) 1581 { 1582 (void) close (fd); 1583 EINTRLOOP (fd, open (file->name, O_RDWR | O_TRUNC, 0666)); 1584 if (fd < 0) 1585 TOUCH_ERROR ("touch: open: "); 1586 } 1587 (void) close (fd); 1588 } 1589 } 1590 1591 return us_success; 1528 1592 } 1529 1593 … … 1543 1607 { 1544 1608 if (file->phony) 1545 1546 file->update_status = 0;1609 /* Phony target. Pretend it succeeded. */ 1610 file->update_status = us_success; 1547 1611 else if (file->is_target) 1548 1549 1550 file->update_status = 0;1612 /* This is a nonexistent target file we cannot make. 1613 Pretend it was successfully remade. */ 1614 file->update_status = us_success; 1551 1615 else 1552 1616 { … … 1554 1618 if (!rebuilding_makefiles || !file->dontcare) 1555 1619 complain (file); 1556 file->update_status = 2;1620 file->update_status = us_failed; 1557 1621 } 1558 1622 } … … 1563 1627 /* The normal case: start some commands. */ 1564 1628 if (!touch_flag || file->cmds->any_recurse) 1565 1566 1567 1568 1629 { 1630 execute_file_commands (file); 1631 return; 1632 } 1569 1633 1570 1634 /* This tells notice_finished_file it is ok to touch the file. */ 1571 file->update_status = 0;1635 file->update_status = us_success; 1572 1636 } 1573 1637 … … 1577 1641 1578 1642 1579 /* Return the mtime of a file, given a `struct file'.1643 /* Return the mtime of a file, given a 'struct file'. 1580 1644 Caches the time in the struct file to avoid excess stat calls. 1581 1645 … … 1589 1653 { 1590 1654 FILE_TIMESTAMP mtime; 1655 int propagate_timestamp; 1591 1656 1592 1657 /* File's mtime is not known; must get it from the system. */ 1593 1658 1594 #ifndef 1659 #ifndef NO_ARCHIVES 1595 1660 if (ar_name (file->name)) 1596 1661 { … … 1605 1670 1606 1671 /* Find the modification time of the archive itself. 1607 1672 Also allow for its name to be changed via VPATH search. */ 1608 1673 arfile = lookup_file (arname); 1609 1674 if (arfile == 0) … … 1612 1677 check_renamed (arfile); 1613 1678 if (search && strcmp (arfile->hname, arname)) 1614 1615 1616 1679 { 1680 /* The archive's name has changed. 1681 Change the archive-member reference accordingly. */ 1617 1682 1618 1683 char *name; 1619 1620 1621 1622 1623 1624 name = xmalloc(arlen + 1 + memlen + 2);1625 1626 1627 1628 1629 1684 unsigned int arlen, memlen; 1685 1686 arlen = strlen (arfile->hname); 1687 memlen = strlen (memname); 1688 1689 name = alloca (arlen + 1 + memlen + 2); 1690 memcpy (name, arfile->hname, arlen); 1691 name[arlen] = '('; 1692 memcpy (name + arlen + 1, memname, memlen); 1693 name[arlen + 1 + memlen] = ')'; 1694 name[arlen + 1 + memlen + 1] = '\0'; 1630 1695 1631 1696 /* If the archive was found with GPATH, make the change permanent; 1632 1697 otherwise defer it until later. */ 1633 1698 if (arfile->name == arfile->hname) 1634 rename_file (file, name);1699 rename_file (file, strcache_add (name)); 1635 1700 else 1636 rehash_file (file, name);1701 rehash_file (file, strcache_add (name)); 1637 1702 check_renamed (file); 1638 1703 } 1639 1704 1640 1705 free (arname); … … 1643 1708 1644 1709 if (mtime == NONEXISTENT_MTIME) 1645 1646 1710 /* The archive doesn't exist, so its members don't exist either. */ 1711 return NONEXISTENT_MTIME; 1647 1712 1648 1713 member_date = ar_member_date (file->hname); … … 1657 1722 1658 1723 if (mtime == NONEXISTENT_MTIME && search && !file->ignore_vpath) 1659 { 1660 /* If name_mtime failed, search VPATH. */ 1661 const char *name = vpath_search (file->name, &mtime, NULL, NULL); 1662 if (name 1663 /* Last resort, is it a library (-lxxx)? */ 1664 || (file->name[0] == '-' && file->name[1] == 'l' 1665 && (name = library_search (file->name, &mtime)) != 0)) 1666 { 1667 if (mtime != UNKNOWN_MTIME) 1668 /* vpath_search and library_search store UNKNOWN_MTIME 1669 if they didn't need to do a stat call for their work. */ 1670 file->last_mtime = mtime; 1724 { 1725 /* If name_mtime failed, search VPATH. */ 1726 const char *name = vpath_search (file->name, &mtime, NULL, NULL); 1727 if (name 1728 /* Last resort, is it a library (-lxxx)? */ 1729 || (file->name[0] == '-' && file->name[1] == 'l' 1730 && (name = library_search (file->name, &mtime)) != 0)) 1731 { 1732 int name_len; 1733 1734 if (mtime != UNKNOWN_MTIME) 1735 /* vpath_search and library_search store UNKNOWN_MTIME 1736 if they didn't need to do a stat call for their work. */ 1737 file->last_mtime = mtime; 1671 1738 1672 1739 /* If we found it in VPATH, see if it's in GPATH too; if so, 1673 1740 change the name right now; if not, defer until after the 1674 1741 dependencies are updated. */ 1675 if (gpath_search (name, strlen(name) - strlen(file->name) - 1)) 1742 #ifndef VMS 1743 name_len = strlen (name) - strlen (file->name) - 1; 1744 #else 1745 name_len = strlen (name) - strlen (file->name); 1746 if (name[name_len - 1] == '/') 1747 name_len--; 1748 #endif 1749 if (gpath_search (name, name_len)) 1676 1750 { 1677 1751 rename_file (file, name); … … 1680 1754 } 1681 1755 1682 1683 1756 rehash_file (file, name); 1757 check_renamed (file); 1684 1758 /* If the result of a vpath search is -o or -W, preserve it. 1685 1759 Otherwise, find the mtime of the resulting file. */ 1686 1760 if (mtime != OLD_MTIME && mtime != NEW_MTIME) 1687 1761 mtime = name_mtime (name); 1688 1689 1762 } 1763 } 1690 1764 } 1691 1765 … … 1733 1807 { 1734 1808 #ifdef NO_FLOAT 1735 error (NILF, _("Warning: File `%s' has modification time in the future"), 1736 file->name); 1809 OS (error, NILF, 1810 _("Warning: File '%s' has modification time in the future"), 1811 file->name); 1737 1812 #else 1738 1813 double from_now = … … 1746 1821 else 1747 1822 sprintf (from_now_string, "%.2g", from_now); 1748 error (NILF, _("Warning: File `%s' has modification time %s s in the future"), 1749 file->name, from_now_string); 1823 OSS (error, NILF, 1824 _("Warning: File '%s' has modification time %s s in the future"), 1825 file->name, from_now_string); 1750 1826 #endif 1751 1827 clock_skew_detected = 1; … … 1754 1830 } 1755 1831 1756 /* Store the mtime into all the entries for this file. */ 1832 /* Store the mtime into all the entries for this file for which it is safe 1833 to do so: avoid propagating timestamps to double-colon rules that haven't 1834 been examined so they're run or not based on the pre-update timestamp. */ 1757 1835 if (file->double_colon) 1758 1836 file = file->double_colon; 1759 1837 1838 propagate_timestamp = file->updated; 1760 1839 do 1761 1840 { 1762 1841 /* If this file is not implicit but it is intermediate then it was 1763 1764 1765 1766 1842 made so by the .INTERMEDIATE target. If this file has never 1843 been built by us but was found now, it existed before make 1844 started. So, turn off the intermediate bit so make doesn't 1845 delete it, since it didn't create it. */ 1767 1846 if (mtime != NONEXISTENT_MTIME && file->command_state == cs_not_started 1768 && file->command_state == cs_not_started 1769 && !file->tried_implicit && file->intermediate) 1770 file->intermediate = 0; 1771 1772 file->last_mtime = mtime;1847 && !file->tried_implicit && file->intermediate) 1848 file->intermediate = 0; 1849 1850 if (file->updated == propagate_timestamp) 1851 file->last_mtime = mtime; 1773 1852 file = file->prev; 1774 1853 } … … 1890 1969 library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr) 1891 1970 { 1892 static c har *dirs[] =1971 static const char *dirs[] = 1893 1972 { 1894 1973 #ifdef KMK … … 1907 1986 #endif 1908 1987 # ifdef LIBDIR /* bird */ 1909 LIBDIR, 1988 LIBDIR, /* Defined by configuration. */ 1910 1989 # else /* bird */ 1911 1990 ".", /* bird */ … … 1926 2005 1927 2006 /* Information about the earliest (in the vpath sequence) match. */ 1928 unsigned int best_vpath = 0, best_path = 0; /* bird: gcc maybe used uninitialized (both) */ 1929 unsigned int std_dirs = 0; 1930 1931 char **dp; 2007 unsigned int best_vpath = 0, best_path = 0; 2008 2009 const char **dp; 1932 2010 1933 2011 libpatterns = xstrdup (variable_expand ("$(.LIBPATTERNS)")); … … 1946 2024 static unsigned int buflen = 0; 1947 2025 static int libdir_maxlen = -1; 2026 static unsigned int std_dirs = 0; 1948 2027 char *libbuf = variable_expand (""); 1949 2028 const size_t libbuf_offset = libbuf - variable_buffer; /* bird */ … … 1951 2030 /* Expand the pattern using LIB as a replacement. */ 1952 2031 { 1953 char c = p[len]; 1954 char *p3, *p4; 1955 1956 p[len] = '\0'; 1957 p3 = find_percent (p); 1958 if (!p3) 1959 { 1960 /* Give a warning if there is no pattern. */ 1961 error (NILF, _(".LIBPATTERNS element `%s' is not a pattern"), p); 2032 char c = p[len]; 2033 char *p3, *p4; 2034 2035 p[len] = '\0'; 2036 p3 = find_percent (p); 2037 if (!p3) 2038 { 2039 /* Give a warning if there is no pattern. */ 2040 OS (error, NILF, 2041 _(".LIBPATTERNS element '%s' is not a pattern"), p); 1962 2042 p[len] = c; 1963 1964 1965 1966 1967 1968 1969 libbuf = variable_buffer + libbuf_offset; /* bird - variable_buffer may have been reallocated. */2043 continue; 2044 } 2045 p4 = variable_buffer_output (libbuf, p, p3-p); 2046 p4 = variable_buffer_output (p4, lib, liblen); 2047 p4 = variable_buffer_output (p4, p3+1, len - (p3-p)); 2048 p[len] = c; 2049 libbuf = variable_buffer + libbuf_offset; /* bird - variable_buffer may have been reallocated. UPSTREAM */ 1970 2050 } 1971 2051 1972 /* Look first for `libNAME.a' in the current directory. */2052 /* Look first for 'libNAME.a' in the current directory. */ 1973 2053 mtime = name_mtime (libbuf); 1974 2054 if (mtime != NONEXISTENT_MTIME) 1975 1976 1977 1978 2055 { 2056 if (mtime_ptr != 0) 2057 *mtime_ptr = mtime; 2058 file = strcache_add (libbuf); 1979 2059 /* This by definition will have the best index, so stop now. */ 1980 2060 break; 1981 2061 } 1982 2062 1983 2063 /* Now try VPATH search on that. */ … … 2016 2096 } 2017 2097 buflen = strlen (libbuf); 2018 buf = xmalloc (libdir_maxlen + buflen + 2);2098 buf = xmalloc (libdir_maxlen + buflen + 2); 2019 2099 } 2020 2100 else if (buflen < strlen (libbuf)) … … 2030 2110 2031 2111 for (dp = dirs; *dp != 0; ++dp) 2032 2112 { 2033 2113 sprintf (buf, "%s/%s", *dp, libbuf); 2034 2114 mtime = name_mtime (buf); 2035 2115 if (mtime != NONEXISTENT_MTIME) 2036 2116 { 2037 2117 if (file == 0 || vpath_index < best_vpath) 2038 2118 {
Note:
See TracChangeset
for help on using the changeset viewer.