Changeset 3138 in kBuild for vendor/gnumake/current/remake.c
- Timestamp:
- Mar 12, 2018 7:32:29 PM (7 years ago)
- File:
-
- 1 edited
-
vendor/gnumake/current/remake.c (modified) (79 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vendor/gnumake/current/remake.c
r2596 r3138 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 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); 68 69 static void remake_file (struct file *file); 69 70 static FILE_TIMESTAMP name_mtime (const char *name); … … 72 73 73 74 74 /* Remake all the goals in the `struct dep' chain GOALS. Return -1 if nothing75 /* Remake all the goals in the 'struct dep' chain GOALS. Return -1 if nothing 75 76 was done, 0 if all goals were updated successfully, or 1 if a goal failed. 76 77 … … 78 79 and -n should be disabled for them unless they were also command-line 79 80 targets, and we should only make one goal at a time and return as soon as 80 one goal whose `changed' member is nonzero is successfully made. */81 82 int 83 update_goal_chain (struct dep *goals)81 one goal whose 'changed' member is nonzero is successfully made. */ 82 83 enum update_status 84 update_goal_chain (struct goaldep *goaldeps) 84 85 { 85 86 int t = touch_flag, q = question_flag, n = just_print_flag; 86 int status = -1; 87 88 #define MTIME(file) (rebuilding_makefiles ? file_mtime_no_search (file) \ 89 : file_mtime (file)) 87 enum update_status status = us_none; 90 88 91 89 /* Duplicate the chain so we can remove things from it. */ 92 90 93 goals = copy_dep_chain (goals); 94 95 { 96 /* Clear the `changed' flag of each goal in the chain. 97 We will use the flag below to notice when any commands 98 have actually been run for a target. When no commands 99 have been run, we give an "up to date" diagnostic. */ 100 101 struct dep *g; 102 for (g = goals; g != 0; g = g->next) 103 g->changed = 0; 104 } 105 106 /* All files start with the considered bit 0, so the global value is 1. */ 107 considered = 1; 91 struct dep *goals = copy_dep_chain ((struct dep *)goaldeps); 92 93 goal_list = rebuilding_makefiles ? goaldeps : NULL; 94 95 #define MTIME(file) (rebuilding_makefiles ? file_mtime_no_search (file) \ 96 : file_mtime (file)) 97 98 /* Start a fresh batch of consideration. */ 99 ++considered; 108 100 109 101 /* Update all the goals until they are all finished. */ … … 124 116 g = goals; 125 117 while (g != 0) 126 { 127 /* Iterate over all double-colon entries for this file. */ 128 struct file *file; 129 int stop = 0, any_not_updated = 0; 130 131 for (file = g->file->double_colon ? g->file->double_colon : g->file; 132 file != NULL; 133 file = file->prev) 134 { 135 unsigned int ocommands_started; 136 int x; 137 138 file->dontcare = g->dontcare; 139 140 check_renamed (file); 141 if (rebuilding_makefiles) 142 { 143 if (file->cmd_target) 144 { 145 touch_flag = t; 146 question_flag = q; 147 just_print_flag = n; 148 } 149 else 150 touch_flag = question_flag = just_print_flag = 0; 151 } 152 153 /* Save the old value of `commands_started' so we can compare 154 later. It will be incremented when any commands are 155 actually run. */ 156 ocommands_started = commands_started; 157 158 x = update_file (file, rebuilding_makefiles ? 1 : 0); 159 check_renamed (file); 160 161 /* Set the goal's `changed' flag if any commands were started 162 by calling update_file above. We check this flag below to 163 decide when to give an "up to date" diagnostic. */ 118 { 119 /* Iterate over all double-colon entries for this file. */ 120 struct file *file; 121 int stop = 0, any_not_updated = 0; 122 123 goal_dep = g; 124 125 for (file = g->file->double_colon ? g->file->double_colon : g->file; 126 file != NULL; 127 file = file->prev) 128 { 129 unsigned int ocommands_started; 130 enum update_status fail; 131 132 file->dontcare = ANY_SET (g->flags, RM_DONTCARE); 133 134 check_renamed (file); 135 if (rebuilding_makefiles) 136 { 137 if (file->cmd_target) 138 { 139 touch_flag = t; 140 question_flag = q; 141 just_print_flag = n; 142 } 143 else 144 touch_flag = question_flag = just_print_flag = 0; 145 } 146 147 /* Save the old value of 'commands_started' so we can compare 148 later. It will be incremented when any commands are 149 actually run. */ 150 ocommands_started = commands_started; 151 152 fail = update_file (file, rebuilding_makefiles ? 1 : 0); 153 check_renamed (file); 154 155 /* Set the goal's 'changed' flag if any commands were started 156 by calling update_file above. We check this flag below to 157 decide when to give an "up to date" diagnostic. */ 164 158 if (commands_started > ocommands_started) 165 159 g->changed = 1; 166 160 167 /* If we updated a file and STATUS was not already 1, set it to 168 1 if updating failed, or to 0 if updating succeeded. Leave 169 STATUS as it is if no updating was done. */ 170 171 stop = 0; 172 if ((x != 0 || file->updated) && status < 1) 161 stop = 0; 162 if ((fail || file->updated) && status < us_question) 173 163 { 174 if (file->update_status != 0) 164 /* We updated this goal. Update STATUS and decide whether 165 to stop. */ 166 if (file->update_status) 175 167 { 176 168 /* Updating failed, or -q triggered. The STATUS value … … 199 191 if (!rebuilding_makefiles 200 192 || (!just_print_flag && !question_flag)) 201 status = 0;193 status = us_success; 202 194 if (rebuilding_makefiles && file->dontcare) 203 195 /* This is a default makefile; stop remaking. */ … … 207 199 } 208 200 209 /* Keep track if any double-colon entry is not finished.201 /* Keep track if any double-colon entry is not finished. 210 202 When they are all finished, the goal is finished. */ 211 any_not_updated |= !file->updated;203 any_not_updated |= !file->updated; 212 204 213 205 file->dontcare = 0; 214 206 215 if (stop)216 break;217 }218 219 /* Reset FILE since it is null at the end of the loop. */220 file = g->file;221 222 if (stop || !any_not_updated)223 {224 /* If we have found nothing whatever to do for the goal,225 print a message saying nothing needs doing. */226 227 if (!rebuilding_makefiles228 /* If the update_status is zero, we updated successfully229 or not at all. G->changed will have been set above if230 any commands were actually started for this goal. */231 && file->update_status == 0&& !g->changed232 /* Never give a message under -s or -q. */233 && !silent_flag && !question_flag)234 message (1, ((file->phony || file->cmds == 0)235 ? _("Nothing to be done for `%s'.")236 : _("`%s' is up to date.")),237 file->name);238 239 /* This goal is finished. Remove it from the chain. */240 if (lastgoal == 0)241 goals = g->next;242 else243 lastgoal->next = g->next;244 245 /* Free the storage. */246 free (g);247 248 g = lastgoal == 0 ? goals : lastgoal->next;249 250 if (stop)251 break;252 }253 else254 {255 lastgoal = g;256 g = g->next;257 }258 }259 260 /* If we reached the end of the dependency graph toggle the considered261 f lag for the next pass. */207 if (stop) 208 break; 209 } 210 211 /* Reset FILE since it is null at the end of the loop. */ 212 file = g->file; 213 214 if (stop || !any_not_updated) 215 { 216 /* If we have found nothing whatever to do for the goal, 217 print a message saying nothing needs doing. */ 218 219 if (!rebuilding_makefiles 220 /* If the update_status is success, we updated successfully 221 or not at all. G->changed will have been set above if 222 any commands were actually started for this goal. */ 223 && file->update_status == us_success && !g->changed 224 /* Never give a message under -s or -q. */ 225 && !silent_flag && !question_flag) 226 OS (message, 1, ((file->phony || file->cmds == 0) 227 ? _("Nothing to be done for '%s'.") 228 : _("'%s' is up to date.")), 229 file->name); 230 231 /* This goal is finished. Remove it from the chain. */ 232 if (lastgoal == 0) 233 goals = g->next; 234 else 235 lastgoal->next = g->next; 236 237 /* Free the storage. */ 238 free (g); 239 240 g = lastgoal == 0 ? goals : lastgoal->next; 241 242 if (stop) 243 break; 244 } 245 else 246 { 247 lastgoal = g; 248 g = g->next; 249 } 250 } 251 252 /* If we reached the end of the dependency graph update CONSIDERED 253 for the next pass. */ 262 254 if (g == 0) 263 considered = !considered;255 ++considered; 264 256 } 265 257 … … 275 267 276 268 269 /* If we're rebuilding an included makefile that failed, and we care 270 about errors, show an error message the first time. */ 271 272 void 273 show_goal_error (void) 274 { 275 struct goaldep *goal; 276 277 if ((goal_dep->flags & (RM_INCLUDED|RM_DONTCARE)) != RM_INCLUDED) 278 return; 279 280 for (goal = goal_list; goal; goal = goal->next) 281 if (goal_dep->file == goal->file) 282 { 283 if (goal->error) 284 { 285 OSS (error, &goal->floc, "%s: %s", 286 goal->file->name, strerror ((int)goal->error)); 287 goal->error = 0; 288 } 289 return; 290 } 291 } 292 293 277 294 /* If FILE is not up to date, execute the commands for it. 278 Return 0 if successful, 1if unsuccessful;279 but with some flag settings, just call `exit' if unsuccessful.295 Return 0 if successful, non-0 if unsuccessful; 296 but with some flag settings, just call 'exit' if unsuccessful. 280 297 281 298 DEPTH is the depth in recursions of this function. … … 287 304 each is considered in turn. */ 288 305 289 static int306 static enum update_status 290 307 update_file (struct file *file, unsigned int depth) 291 308 { 292 register int status = 0;293 registerstruct file *f;309 enum update_status status = us_success; 310 struct file *f; 294 311 295 312 f = file->double_colon ? file->double_colon : file; … … 302 319 { 303 320 /* Check for the case where a target has been tried and failed but 304 the diagnostics ha sn't been issued. If we need the diagnostics321 the diagnostics haven't been issued. If we need the diagnostics 305 322 then we will have to continue. */ 306 if (!(f->updated && f->update_status > 0 && !f->dontcare && f->no_diag)) 307 { 308 DBF (DB_VERBOSE, _("Pruning file `%s'.\n")); 309 return f->command_state == cs_finished ? f->update_status : 0; 323 if (!(f->updated && f->update_status > us_none 324 && !f->dontcare && f->no_diag)) 325 { 326 DBF (DB_VERBOSE, _("Pruning file '%s'.\n")); 327 return f->command_state == cs_finished ? f->update_status : us_success; 310 328 } 311 329 } … … 315 333 for (; f != 0; f = f->prev) 316 334 { 335 enum update_status new; 336 317 337 f->considered = considered; 318 338 319 status |= update_file_1 (f, depth);339 new = update_file_1 (f, depth); 320 340 check_renamed (f); 321 341 … … 324 344 325 345 /* If we got an error, don't bother with double_colon etc. */ 326 if ( status != 0&& !keep_going_flag)327 return status;346 if (new && !keep_going_flag) 347 return new; 328 348 329 349 if (f->command_state == cs_running 330 350 || f->command_state == cs_deps_running) 331 {332 /* Don't run the other :: rules for this 333 file until this rule is finished. */ 334 status = 0; 335 break;336 }351 /* Don't run other :: rules for this target until 352 this rule is finished. */ 353 return us_success; 354 355 if (new > status) 356 status = new; 337 357 } 338 358 … … 347 367 348 368 for (d = f->deps; d != 0; d = d->next) 349 status |= update_file (d->file, depth + 1); 369 { 370 enum update_status new = update_file (d->file, depth + 1); 371 if (new > status) 372 status = new; 373 } 350 374 } 351 375 … … 359 383 complain (struct file *file) 360 384 { 361 const char *msg_noparent362 = _("%sNo rule to make target `%s'%s");363 const char *msg_parent364 = _("%sNo rule to make target `%s', needed by `%s'%s");365 366 385 /* If this file has no_diag set then it means we tried to update it 367 386 before in the dontcare mode and failed. The target that actually … … 374 393 for (d = file->deps; d != 0; d = d->next) 375 394 { 376 if (d->file->updated && d->file->update_status > 0&& file->no_diag)395 if (d->file->updated && d->file->update_status > us_none && file->no_diag) 377 396 { 378 397 complain (d->file); … … 383 402 if (d == 0) 384 403 { 404 show_goal_error (); 405 385 406 /* Didn't find any dependencies to complain about. */ 386 if ( !keep_going_flag)387 { 388 if (file->parent == 0)389 fatal (NILF, msg_noparent, "", file->name, "");390 391 fatal (NILF, msg_parent, "", file->name, file->parent->name, "");392 }393 394 if (file->parent == 0)395 error (NILF, msg_noparent, "*** ", file->name, ".");407 if (file->parent) 408 { 409 size_t l = strlen (file->name) + strlen (file->parent->name) + 4; 410 const char *m = _("%sNo rule to make target '%s', needed by '%s'%s"); 411 412 if (!keep_going_flag) 413 fatal (NILF, l, m, "", file->name, file->parent->name, ""); 414 415 error (NILF, l, m, "*** ", file->name, file->parent->name, "."); 416 } 396 417 else 397 error (NILF, msg_parent, "*** ", file->name, file->parent->name, "."); 418 { 419 size_t l = strlen (file->name) + 4; 420 const char *m = _("%sNo rule to make target '%s'%s"); 421 422 if (!keep_going_flag) 423 fatal (NILF, l, m, "", file->name, ""); 424 425 error (NILF, l, m, "*** ", file->name, "."); 426 } 398 427 399 428 file->no_diag = 0; … … 401 430 } 402 431 403 /* Consider a single `struct file' and update it as appropriate. */ 404 405 static int 432 /* Consider a single 'struct file' and update it as appropriate. 433 Return 0 on success, or non-0 on failure. */ 434 435 static enum update_status 406 436 update_file_1 (struct file *file, unsigned int depth) 407 437 { 438 enum update_status dep_status = us_success; 408 439 FILE_TIMESTAMP this_mtime; 409 440 int noexist, must_make, deps_changed; 410 int dep_status = 0;411 441 struct file *ofile; 412 442 struct dep *d, *ad; … … 414 444 int running = 0; 415 445 416 DBF (DB_VERBOSE, _("Considering target file `%s'.\n"));446 DBF (DB_VERBOSE, _("Considering target file '%s'.\n")); 417 447 418 448 if (file->updated) 419 449 { 420 if (file->update_status > 0)421 {422 DBF (DB_VERBOSE,423 _("Recently tried and failed to update file `%s'.\n"));450 if (file->update_status > us_none) 451 { 452 DBF (DB_VERBOSE, 453 _("Recently tried and failed to update file '%s'.\n")); 424 454 425 455 /* If the file we tried to make is marked no_diag then no message … … 430 460 complain (file); 431 461 432 return file->update_status;433 }434 435 DBF (DB_VERBOSE, _("File `%s' was considered already.\n"));462 return file->update_status; 463 } 464 465 DBF (DB_VERBOSE, _("File '%s' was considered already.\n")); 436 466 return 0; 437 467 } … … 443 473 break; 444 474 case cs_running: 445 DBF (DB_VERBOSE, _("Still updating file `%s'.\n"));475 DBF (DB_VERBOSE, _("Still updating file '%s'.\n")); 446 476 return 0; 447 477 case cs_finished: 448 DBF (DB_VERBOSE, _("Finished updating file `%s'.\n"));478 DBF (DB_VERBOSE, _("Finished updating file '%s'.\n")); 449 479 return file->update_status; 450 480 default: … … 475 505 noexist = this_mtime == NONEXISTENT_MTIME; 476 506 if (noexist) 477 DBF (DB_BASIC, _("File `%s' does not exist.\n"));507 DBF (DB_BASIC, _("File '%s' does not exist.\n")); 478 508 else if (ORDINARY_MTIME_MIN <= this_mtime && this_mtime <= ORDINARY_MTIME_MAX 479 && file->low_resolution_time)509 && file->low_resolution_time) 480 510 { 481 511 /* Avoid spurious rebuilds due to low resolution time stamps. */ 482 512 int ns = FILE_TIMESTAMP_NS (this_mtime); 483 513 if (ns != 0) 484 error (NILF, _("*** Warning: .LOW_RESOLUTION_TIME file `%s' has a high resolution time stamp"), 485 file->name); 514 OS (error, NILF, 515 _("*** Warning: .LOW_RESOLUTION_TIME file '%s' has a high resolution time stamp"), 516 file->name); 486 517 this_mtime += FILE_TIMESTAMPS_PER_S - 1 - ns; 487 518 } … … 495 526 { 496 527 if (try_implicit_rule (file, depth)) 497 DBF (DB_IMPLICIT, _("Found an implicit rule for `%s'.\n"));528 DBF (DB_IMPLICIT, _("Found an implicit rule for '%s'.\n")); 498 529 else 499 DBF (DB_IMPLICIT, _("No implicit rule found for `%s'.\n"));530 DBF (DB_IMPLICIT, _("No implicit rule found for '%s'.\n")); 500 531 file->tried_implicit = 1; 501 532 } … … 503 534 && default_file != 0 && default_file->cmds != 0) 504 535 { 505 DBF (DB_IMPLICIT, _("Using default recipe for `%s'.\n"));536 DBF (DB_IMPLICIT, _("Using default recipe for '%s'.\n")); 506 537 file->cmds = default_file->cmds; 507 538 } … … 525 556 while (d) 526 557 { 558 enum update_status new; 527 559 FILE_TIMESTAMP mtime; 528 560 int maybe_make; … … 536 568 if (is_updating (d->file)) 537 569 { 538 error (NILF, _("Circular %s <- %s dependency dropped."),539 file->name, d->file->name);570 OSS (error, NILF, _("Circular %s <- %s dependency dropped."), 571 file->name, d->file->name); 540 572 /* We cannot free D here because our the caller will still have 541 573 a reference to it when we were called recursively via … … 559 591 } 560 592 561 dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make); 593 new = check_dep (d->file, depth, this_mtime, &maybe_make); 594 if (new > dep_status) 595 dep_status = new; 562 596 563 597 /* Restore original dontcare flag. */ … … 583 617 } 584 618 585 if (dep_status != 0&& !keep_going_flag)619 if (dep_status && !keep_going_flag) 586 620 break; 587 621 588 622 if (!running) 589 /* The prereq is considered changed if the timestamp has changed while590 it was built, OR it doesn't exist. */623 /* The prereq is considered changed if the timestamp has changed 624 while it was built, OR it doesn't exist. */ 591 625 d->changed = ((file_mtime (d->file) != mtime) 592 626 || (mtime == NONEXISTENT_MTIME)); … … 603 637 { 604 638 for (d = file->deps; d != 0; d = d->next) 605 if (d->file->intermediate) 606 { 639 if (d->file->intermediate) 640 { 641 enum update_status new; 607 642 int dontcare = 0; 608 643 609 FILE_TIMESTAMP mtime = file_mtime (d->file);610 check_renamed (d->file);611 d->file->parent = file;644 FILE_TIMESTAMP mtime = file_mtime (d->file); 645 check_renamed (d->file); 646 d->file->parent = file; 612 647 613 648 /* Inherit dontcare flag from our parent. */ … … 618 653 } 619 654 620 621 dep_status |= update_file (d->file, depth); 655 /* We may have already considered this file, when we didn't know 656 we'd need to update it. Force update_file() to consider it and 657 not prune it. */ 658 d->file->considered = 0; 659 660 new = update_file (d->file, depth); 661 if (new > dep_status) 662 dep_status = new; 622 663 623 664 /* Restore original dontcare flag. */ … … 625 666 d->file->dontcare = dontcare; 626 667 627 check_renamed (d->file);628 629 {630 register struct file *f = d->file;631 if (f->double_colon)632 f = f->double_colon;633 do634 {635 running |= (f->command_state == cs_running636 || f->command_state == cs_deps_running);637 f = f->prev;638 }639 while (f != 0);640 }641 642 if (dep_status != 0&& !keep_going_flag)643 break;644 645 if (!running)646 d->changed = ((file->phony && file->cmds != 0)647 || file_mtime (d->file) != mtime);648 }668 check_renamed (d->file); 669 670 { 671 register struct file *f = d->file; 672 if (f->double_colon) 673 f = f->double_colon; 674 do 675 { 676 running |= (f->command_state == cs_running 677 || f->command_state == cs_deps_running); 678 f = f->prev; 679 } 680 while (f != 0); 681 } 682 683 if (dep_status && !keep_going_flag) 684 break; 685 686 if (!running) 687 d->changed = ((file->phony && file->cmds != 0) 688 || file_mtime (d->file) != mtime); 689 } 649 690 } 650 691 … … 652 693 finish_updating (ofile); 653 694 654 DBF (DB_VERBOSE, _("Finished prerequisites of target file `%s'.\n"));695 DBF (DB_VERBOSE, _("Finished prerequisites of target file '%s'.\n")); 655 696 656 697 if (running) … … 658 699 set_command_state (file, cs_deps_running); 659 700 --depth; 660 DBF (DB_VERBOSE, _("The prerequisites of `%s' are being made.\n"));701 DBF (DB_VERBOSE, _("The prerequisites of '%s' are being made.\n")); 661 702 return 0; 662 703 } … … 664 705 /* If any dependency failed, give up now. */ 665 706 666 if (dep_status != 0) 667 { 668 file->update_status = dep_status; 707 if (dep_status) 708 { 709 /* I'm not sure if we can't just assign dep_status... */ 710 file->update_status = dep_status == us_none ? us_failed : dep_status; 669 711 notice_finished_file (file); 670 712 671 713 --depth; 672 714 673 DBF (DB_VERBOSE, _("Giving up on target file `%s'.\n"));715 DBF (DB_VERBOSE, _("Giving up on target file '%s'.\n")); 674 716 675 717 if (depth == 0 && keep_going_flag 676 && !just_print_flag && !question_flag)677 error (NILF,678 _("Target `%s' not remade because of errors."), file->name);718 && !just_print_flag && !question_flag) 719 OS (error, NILF, 720 _("Target '%s' not remade because of errors."), file->name); 679 721 680 722 return dep_status; … … 705 747 #if 1 706 748 /* %%% In version 4, remove this code completely to 707 implement not remaking deps if their deps are newer708 than their parents. */749 implement not remaking deps if their deps are newer 750 than their parents. */ 709 751 if (d_mtime == NONEXISTENT_MTIME && !d->file->intermediate) 710 752 /* We must remake if this dep does not … … 718 760 719 761 /* Set D->changed if either this dep actually changed, 720 or its dependent, FILE, is older or does not exist. */762 or its dependent, FILE, is older or does not exist. */ 721 763 d->changed |= noexist || d_mtime > this_mtime; 722 764 723 765 if (!noexist && ISDB (DB_BASIC|DB_VERBOSE)) 724 {766 { 725 767 const char *fmt = 0; 726 768 … … 728 770 { 729 771 if (ISDB (DB_VERBOSE)) 730 fmt = _("Prerequisite `%s' is order-only for target `%s'.\n");772 fmt = _("Prerequisite '%s' is order-only for target '%s'.\n"); 731 773 } 732 774 else if (d_mtime == NONEXISTENT_MTIME) 733 775 { 734 776 if (ISDB (DB_BASIC)) 735 fmt = _("Prerequisite `%s' of target `%s' does not exist.\n");736 } 737 else if (d->changed)777 fmt = _("Prerequisite '%s' of target '%s' does not exist.\n"); 778 } 779 else if (d->changed) 738 780 { 739 781 if (ISDB (DB_BASIC)) 740 fmt = _("Prerequisite `%s' is newer than target `%s'.\n");782 fmt = _("Prerequisite '%s' is newer than target '%s'.\n"); 741 783 } 742 784 else if (ISDB (DB_VERBOSE)) 743 fmt = _("Prerequisite `%s' is older than target `%s'.\n");785 fmt = _("Prerequisite '%s' is older than target '%s'.\n"); 744 786 745 787 if (fmt) … … 749 791 fflush (stdout); 750 792 } 751 }793 } 752 794 } 753 795 … … 759 801 must_make = 1; 760 802 DBF (DB_BASIC, 761 _("Target `%s' is double-colon and has no prerequisites.\n"));803 _("Target '%s' is double-colon and has no prerequisites.\n")); 762 804 } 763 805 else if (!noexist && file->is_target && !deps_changed && file->cmds == 0 … … 766 808 must_make = 0; 767 809 DBF (DB_VERBOSE, 768 _("No recipe for `%s' and no prerequisites actually changed.\n"));810 _("No recipe for '%s' and no prerequisites actually changed.\n")); 769 811 } 770 812 else if (!must_make && file->cmds != 0 && always_make_flag) 771 813 { 772 814 must_make = 1; 773 DBF (DB_VERBOSE, _("Making `%s' due to always-make flag.\n"));815 DBF (DB_VERBOSE, _("Making '%s' due to always-make flag.\n")); 774 816 } 775 817 … … 779 821 { 780 822 print_spaces (depth); 781 printf (_("No need to remake target `%s'"), file->name);823 printf (_("No need to remake target '%s'"), file->name); 782 824 if (!streq (file->name, file->hname)) 783 printf (_("; using VPATH name `%s'"), file->hname);825 printf (_("; using VPATH name '%s'"), file->hname); 784 826 puts ("."); 785 827 fflush (stdout); … … 801 843 } 802 844 803 DBF (DB_BASIC, _("Must remake target `%s'.\n"));845 DBF (DB_BASIC, _("Must remake target '%s'.\n")); 804 846 805 847 /* It needs to be remade. If it's VPATH and not reset via GPATH, toss the 806 848 VPATH. */ 807 if (!streq (file->name, file->hname))808 { 809 DB (DB_BASIC, (_(" Ignoring VPATH name `%s'.\n"), file->hname));849 if (!streq (file->name, file->hname)) 850 { 851 DB (DB_BASIC, (_(" Ignoring VPATH name '%s'.\n"), file->hname)); 810 852 file->ignore_vpath = 1; 811 853 } … … 816 858 if (file->command_state != cs_finished) 817 859 { 818 DBF (DB_VERBOSE, _("Recipe of `%s' is being run.\n"));860 DBF (DB_VERBOSE, _("Recipe of '%s' is being run.\n")); 819 861 return 0; 820 862 } … … 822 864 switch (file->update_status) 823 865 { 824 case 2:825 DBF (DB_BASIC, _("Failed to remake target file `%s'.\n"));866 case us_failed: 867 DBF (DB_BASIC, _("Failed to remake target file '%s'.\n")); 826 868 break; 827 case 0:828 DBF (DB_BASIC, _("Successfully remade target file `%s'.\n"));869 case us_success: 870 DBF (DB_BASIC, _("Successfully remade target file '%s'.\n")); 829 871 break; 830 case 1:831 DBF (DB_BASIC, _("Target file `%s' needsremade under -q.\n"));872 case us_question: 873 DBF (DB_BASIC, _("Target file '%s' needs to be remade under -q.\n")); 832 874 break; 833 default: 834 assert (file->update_status >= 0 && file->update_status <= 2); 875 case us_none: 835 876 break; 836 877 } … … 841 882 842 883 843 /* Set FILE's `updated' flag and re-check its mtime and the mtime's of all844 files listed in its `also_make' member. Under -t, this function also884 /* Set FILE's 'updated' flag and re-check its mtime and the mtime's of all 885 files listed in its 'also_make' member. Under -t, this function also 845 886 touches FILE. 846 887 847 On return, FILE->update_status will no longer be -1if it was. */888 On return, FILE->update_status will no longer be us_none if it was. */ 848 889 849 890 void … … 859 900 if (touch_flag 860 901 /* The update status will be: 861 -1 if this target was not remade;862 0 if 0 or more commands (+ or ${MAKE}) were run and won;863 1if some commands were run and lost.864 We touch the target if it has commands which either were not run865 or won when they ran (i.e. status is 0). */866 && file->update_status == 0)902 us_success if 0 or more commands (+ or ${MAKE}) were run and won; 903 us_none if this target was not remade; 904 >us_none if some commands were run and lost. 905 We touch the target if it has commands which either were not run 906 or won when they ran (i.e. status is 0). */ 907 && file->update_status == us_success) 867 908 { 868 909 if (file->cmds != 0 && file->cmds->any_recurse) 869 {870 /* If all the command lines were recursive,871 we don't want to do the touching. */872 unsigned int i;873 for (i = 0; i < file->cmds->ncommand_lines; ++i)874 if (!(file->cmds->lines_flags[i] & COMMANDS_RECURSE))875 goto have_nonrecursing;876 }910 { 911 /* If all the command lines were recursive, 912 we don't want to do the touching. */ 913 unsigned int i; 914 for (i = 0; i < file->cmds->ncommand_lines; ++i) 915 if (!(file->cmds->lines_flags[i] & COMMANDS_RECURSE)) 916 goto have_nonrecursing; 917 } 877 918 else 878 {879 have_nonrecursing:880 if (file->phony)881 file->update_status = 0;919 { 920 have_nonrecursing: 921 if (file->phony) 922 file->update_status = us_success; 882 923 /* According to POSIX, -t doesn't affect targets with no cmds. */ 883 else if (file->cmds != 0)924 else if (file->cmds != 0) 884 925 { 885 926 /* Should set file's modification date and do nothing else. */ … … 887 928 888 929 /* Pretend we ran a real touch command, to suppress the 889 " `foo' is up to date" message. */930 "'foo' is up to date" message. */ 890 931 commands_started++; 891 932 … … 896 937 touched = 1; 897 938 } 898 }939 } 899 940 } 900 941 … … 920 961 921 962 else if (file->is_target && file->cmds == 0) 922 i = 1;963 i = 1; 923 964 924 965 file->last_mtime = i == 0 ? UNKNOWN_MTIME : NEW_MTIME; … … 953 994 } 954 995 955 if (ran && file->update_status != -1)996 if (ran && file->update_status != us_none) 956 997 /* We actually tried to update FILE, which has 957 998 updated its also_make's as well (if it worked). … … 960 1001 for (d = file->also_make; d != 0; d = d->next) 961 1002 { 962 d->file->command_state = cs_finished;963 d->file->updated = 1;964 d->file->update_status = file->update_status;965 966 if (ran && !d->file->phony)967 /* Fetch the new modification time.968 We do this instead of just invalidating the cached time969 so that a vpath_search can happen. Otherwise, it would970 never be done because the target is already updated. */971 f_mtime (d->file, 0);1003 d->file->command_state = cs_finished; 1004 d->file->updated = 1; 1005 d->file->update_status = file->update_status; 1006 1007 if (ran && !d->file->phony) 1008 /* Fetch the new modification time. 1009 We do this instead of just invalidating the cached time 1010 so that a vpath_search can happen. Otherwise, it would 1011 never be done because the target is already updated. */ 1012 f_mtime (d->file, 0); 972 1013 } 973 else if (file->update_status == -1)1014 else if (file->update_status == us_none) 974 1015 /* Nothing was done for FILE, but it needed nothing done. 975 1016 So mark it now as "succeeded". */ 976 file->update_status = 0;1017 file->update_status = us_success; 977 1018 } 978 1019 … … 984 1025 failed. */ 985 1026 986 static int1027 static enum update_status 987 1028 check_dep (struct file *file, unsigned int depth, 988 1029 FILE_TIMESTAMP this_mtime, int *must_make_ptr) … … 990 1031 struct file *ofile; 991 1032 struct dep *d; 992 int dep_status = 0;1033 enum update_status dep_status = us_success; 993 1034 994 1035 ++depth; … … 1009 1050 check_renamed (file); 1010 1051 if (mtime == NONEXISTENT_MTIME || mtime > this_mtime) 1011 *must_make_ptr = 1;1052 *must_make_ptr = 1; 1012 1053 } 1013 1054 else … … 1017 1058 1018 1059 if (!file->phony && file->cmds == 0 && !file->tried_implicit) 1019 {1020 if (try_implicit_rule (file, depth))1021 DBF (DB_IMPLICIT, _("Found an implicit rule for `%s'.\n"));1022 else1023 DBF (DB_IMPLICIT, _("No implicit rule found for `%s'.\n"));1024 file->tried_implicit = 1;1025 }1060 { 1061 if (try_implicit_rule (file, depth)) 1062 DBF (DB_IMPLICIT, _("Found an implicit rule for '%s'.\n")); 1063 else 1064 DBF (DB_IMPLICIT, _("No implicit rule found for '%s'.\n")); 1065 file->tried_implicit = 1; 1066 } 1026 1067 if (file->cmds == 0 && !file->is_target 1027 && default_file != 0 && default_file->cmds != 0)1028 {1029 DBF (DB_IMPLICIT, _("Using default commands for `%s'.\n"));1030 file->cmds = default_file->cmds;1031 }1068 && default_file != 0 && default_file->cmds != 0) 1069 { 1070 DBF (DB_IMPLICIT, _("Using default commands for '%s'.\n")); 1071 file->cmds = default_file->cmds; 1072 } 1032 1073 1033 1074 check_renamed (file); … … 1037 1078 /* If the intermediate file actually exists and is newer, then we 1038 1079 should remake from it. */ 1039 *must_make_ptr = 1;1080 *must_make_ptr = 1; 1040 1081 else 1041 {1082 { 1042 1083 /* Otherwise, update all non-intermediate files we depend on, if 1043 1084 necessary, and see whether any of them is more recent than the 1044 1085 file on whose behalf we are checking. */ 1045 struct dep *ld;1086 struct dep *ld; 1046 1087 int deps_running = 0; 1047 1088 … … 1050 1091 prerequisite and so wasn't rebuilt then, but should be now. */ 1051 1092 if (file->command_state != cs_running) 1052 set_command_state (file, cs_not_started); 1053 1054 ld = 0; 1055 d = file->deps; 1056 while (d != 0) 1057 { 1093 { 1094 /* If the target was waiting for a dependency it has to be 1095 reconsidered, as that dependency might have finished. */ 1096 if (file->command_state == cs_deps_running) 1097 file->considered = 0; 1098 1099 set_command_state (file, cs_not_started); 1100 } 1101 1102 ld = 0; 1103 d = file->deps; 1104 while (d != 0) 1105 { 1106 enum update_status new; 1058 1107 int maybe_make; 1059 1108 1060 if (is_updating (d->file))1061 {1062 error (NILF, _("Circular %s <- %s dependency dropped."),1063 file->name, d->file->name);1064 if (ld == 0)1065 {1066 file->deps = d->next;1109 if (is_updating (d->file)) 1110 { 1111 OSS (error, NILF, _("Circular %s <- %s dependency dropped."), 1112 file->name, d->file->name); 1113 if (ld == 0) 1114 { 1115 file->deps = d->next; 1067 1116 free_dep (d); 1068 d = file->deps;1069 }1070 else1071 {1072 ld->next = d->next;1117 d = file->deps; 1118 } 1119 else 1120 { 1121 ld->next = d->next; 1073 1122 free_dep (d); 1074 d = ld->next;1075 }1076 continue;1077 }1078 1079 d->file->parent = file;1123 d = ld->next; 1124 } 1125 continue; 1126 } 1127 1128 d->file->parent = file; 1080 1129 maybe_make = *must_make_ptr; 1081 dep_status |= check_dep (d->file, depth, this_mtime, 1082 &maybe_make); 1130 new = check_dep (d->file, depth, this_mtime, &maybe_make); 1131 if (new > dep_status) 1132 dep_status = new; 1133 1083 1134 if (! d->ignore_mtime) 1084 1135 *must_make_ptr = maybe_make; 1085 check_renamed (d->file);1086 if (dep_status != 0&& !keep_going_flag)1087 break;1088 1089 if (d->file->command_state == cs_running1090 || d->file->command_state == cs_deps_running)1091 deps_running = 1;1092 1093 ld = d;1094 d = d->next;1095 }1136 check_renamed (d->file); 1137 if (dep_status && !keep_going_flag) 1138 break; 1139 1140 if (d->file->command_state == cs_running 1141 || d->file->command_state == cs_deps_running) 1142 deps_running = 1; 1143 1144 ld = d; 1145 d = d->next; 1146 } 1096 1147 1097 1148 if (deps_running) … … 1100 1151 commands are finished. */ 1101 1152 set_command_state (file, cs_deps_running); 1102 }1153 } 1103 1154 } 1104 1155 … … 1110 1161 1111 1162 1112 /* Touch FILE. Return zero if successful, one if not. */ 1113 1114 #define TOUCH_ERROR(call) return (perror_with_name (call, file->name), 1) 1115 1116 static int 1163 /* Touch FILE. Return us_success if successful, us_failed if not. */ 1164 1165 #define TOUCH_ERROR(call) do{ perror_with_name ((call), file->name); \ 1166 return us_failed; }while(0) 1167 1168 static enum update_status 1117 1169 touch_file (struct file *file) 1118 1170 { 1119 1171 if (!silent_flag) 1120 message (0, "touch %s", file->name); 1121 1122 #ifndef NO_ARCHIVES 1172 OS (message, 0, "touch %s", file->name); 1173 1174 /* Print-only (-n) takes precedence over touch (-t). */ 1175 if (just_print_flag) 1176 return us_success; 1177 1178 #ifndef NO_ARCHIVES 1123 1179 if (ar_name (file->name)) 1124 return ar_touch (file->name) ;1180 return ar_touch (file->name) ? us_failed : us_success; 1125 1181 else 1126 1182 #endif 1127 1183 { 1128 int fd = open (file->name, O_RDWR | O_CREAT, 0666); 1129 1184 int fd; 1185 1186 EINTRLOOP (fd, open (file->name, O_RDWR | O_CREAT, 0666)); 1130 1187 if (fd < 0) 1131 TOUCH_ERROR ("touch: open: ");1188 TOUCH_ERROR ("touch: open: "); 1132 1189 else 1133 {1134 struct stat statbuf;1135 char buf = 'x';1190 { 1191 struct stat statbuf; 1192 char buf = 'x'; 1136 1193 int e; 1137 1194 1138 1195 EINTRLOOP (e, fstat (fd, &statbuf)); 1139 if (e < 0) 1140 TOUCH_ERROR ("touch: fstat: "); 1141 /* Rewrite character 0 same as it already is. */ 1142 if (read (fd, &buf, 1) < 0) 1143 TOUCH_ERROR ("touch: read: "); 1144 if (lseek (fd, 0L, 0) < 0L) 1145 TOUCH_ERROR ("touch: lseek: "); 1146 if (write (fd, &buf, 1) < 0) 1147 TOUCH_ERROR ("touch: write: "); 1148 /* If file length was 0, we just 1149 changed it, so change it back. */ 1150 if (statbuf.st_size == 0) 1151 { 1152 (void) close (fd); 1153 fd = open (file->name, O_RDWR | O_TRUNC, 0666); 1154 if (fd < 0) 1155 TOUCH_ERROR ("touch: open: "); 1156 } 1157 (void) close (fd); 1158 } 1159 } 1160 1161 return 0; 1196 if (e < 0) 1197 TOUCH_ERROR ("touch: fstat: "); 1198 /* Rewrite character 0 same as it already is. */ 1199 EINTRLOOP (e, read (fd, &buf, 1)); 1200 if (e < 0) 1201 TOUCH_ERROR ("touch: read: "); 1202 { 1203 off_t o; 1204 EINTRLOOP (o, lseek (fd, 0L, 0)); 1205 if (o < 0L) 1206 TOUCH_ERROR ("touch: lseek: "); 1207 } 1208 EINTRLOOP (e, write (fd, &buf, 1)); 1209 if (e < 0) 1210 TOUCH_ERROR ("touch: write: "); 1211 1212 /* If file length was 0, we just changed it, so change it back. */ 1213 if (statbuf.st_size == 0) 1214 { 1215 (void) close (fd); 1216 EINTRLOOP (fd, open (file->name, O_RDWR | O_TRUNC, 0666)); 1217 if (fd < 0) 1218 TOUCH_ERROR ("touch: open: "); 1219 } 1220 (void) close (fd); 1221 } 1222 } 1223 1224 return us_success; 1162 1225 } 1163 1226 … … 1173 1236 { 1174 1237 if (file->phony) 1175 /* Phony target. Pretend it succeeded. */1176 file->update_status = 0;1238 /* Phony target. Pretend it succeeded. */ 1239 file->update_status = us_success; 1177 1240 else if (file->is_target) 1178 /* This is a nonexistent target file we cannot make.1179 Pretend it was successfully remade. */1180 file->update_status = 0;1241 /* This is a nonexistent target file we cannot make. 1242 Pretend it was successfully remade. */ 1243 file->update_status = us_success; 1181 1244 else 1182 1245 { … … 1184 1247 if (!rebuilding_makefiles || !file->dontcare) 1185 1248 complain (file); 1186 file->update_status = 2;1249 file->update_status = us_failed; 1187 1250 } 1188 1251 } … … 1193 1256 /* The normal case: start some commands. */ 1194 1257 if (!touch_flag || file->cmds->any_recurse) 1195 {1196 execute_file_commands (file);1197 return;1198 }1258 { 1259 execute_file_commands (file); 1260 return; 1261 } 1199 1262 1200 1263 /* This tells notice_finished_file it is ok to touch the file. */ 1201 file->update_status = 0;1264 file->update_status = us_success; 1202 1265 } 1203 1266 … … 1207 1270 1208 1271 1209 /* Return the mtime of a file, given a `struct file'.1272 /* Return the mtime of a file, given a 'struct file'. 1210 1273 Caches the time in the struct file to avoid excess stat calls. 1211 1274 … … 1219 1282 { 1220 1283 FILE_TIMESTAMP mtime; 1284 int propagate_timestamp; 1221 1285 1222 1286 /* File's mtime is not known; must get it from the system. */ 1223 1287 1224 #ifndef NO_ARCHIVES1288 #ifndef NO_ARCHIVES 1225 1289 if (ar_name (file->name)) 1226 1290 { … … 1235 1299 1236 1300 /* Find the modification time of the archive itself. 1237 Also allow for its name to be changed via VPATH search. */1301 Also allow for its name to be changed via VPATH search. */ 1238 1302 arfile = lookup_file (arname); 1239 1303 if (arfile == 0) … … 1242 1306 check_renamed (arfile); 1243 1307 if (search && strcmp (arfile->hname, arname)) 1244 {1245 /* The archive's name has changed.1246 Change the archive-member reference accordingly. */1308 { 1309 /* The archive's name has changed. 1310 Change the archive-member reference accordingly. */ 1247 1311 1248 1312 char *name; 1249 unsigned int arlen, memlen;1250 1251 arlen = strlen (arfile->hname);1252 memlen = strlen (memname);1253 1254 name = xmalloc(arlen + 1 + memlen + 2);1255 memcpy (name, arfile->hname, arlen);1256 name[arlen] = '(';1257 memcpy (name + arlen + 1, memname, memlen);1258 name[arlen + 1 + memlen] = ')';1259 name[arlen + 1 + memlen + 1] = '\0';1313 unsigned int arlen, memlen; 1314 1315 arlen = strlen (arfile->hname); 1316 memlen = strlen (memname); 1317 1318 name = alloca (arlen + 1 + memlen + 2); 1319 memcpy (name, arfile->hname, arlen); 1320 name[arlen] = '('; 1321 memcpy (name + arlen + 1, memname, memlen); 1322 name[arlen + 1 + memlen] = ')'; 1323 name[arlen + 1 + memlen + 1] = '\0'; 1260 1324 1261 1325 /* If the archive was found with GPATH, make the change permanent; 1262 1326 otherwise defer it until later. */ 1263 1327 if (arfile->name == arfile->hname) 1264 rename_file (file, name);1328 rename_file (file, strcache_add (name)); 1265 1329 else 1266 rehash_file (file, name);1330 rehash_file (file, strcache_add (name)); 1267 1331 check_renamed (file); 1268 }1332 } 1269 1333 1270 1334 free (arname); … … 1273 1337 1274 1338 if (mtime == NONEXISTENT_MTIME) 1275 /* The archive doesn't exist, so its members don't exist either. */1276 return NONEXISTENT_MTIME;1339 /* The archive doesn't exist, so its members don't exist either. */ 1340 return NONEXISTENT_MTIME; 1277 1341 1278 1342 member_date = ar_member_date (file->hname); … … 1287 1351 1288 1352 if (mtime == NONEXISTENT_MTIME && search && !file->ignore_vpath) 1289 { 1290 /* If name_mtime failed, search VPATH. */ 1291 const char *name = vpath_search (file->name, &mtime, NULL, NULL); 1292 if (name 1293 /* Last resort, is it a library (-lxxx)? */ 1294 || (file->name[0] == '-' && file->name[1] == 'l' 1295 && (name = library_search (file->name, &mtime)) != 0)) 1296 { 1297 if (mtime != UNKNOWN_MTIME) 1298 /* vpath_search and library_search store UNKNOWN_MTIME 1299 if they didn't need to do a stat call for their work. */ 1300 file->last_mtime = mtime; 1353 { 1354 /* If name_mtime failed, search VPATH. */ 1355 const char *name = vpath_search (file->name, &mtime, NULL, NULL); 1356 if (name 1357 /* Last resort, is it a library (-lxxx)? */ 1358 || (file->name[0] == '-' && file->name[1] == 'l' 1359 && (name = library_search (file->name, &mtime)) != 0)) 1360 { 1361 int name_len; 1362 1363 if (mtime != UNKNOWN_MTIME) 1364 /* vpath_search and library_search store UNKNOWN_MTIME 1365 if they didn't need to do a stat call for their work. */ 1366 file->last_mtime = mtime; 1301 1367 1302 1368 /* If we found it in VPATH, see if it's in GPATH too; if so, 1303 1369 change the name right now; if not, defer until after the 1304 1370 dependencies are updated. */ 1305 if (gpath_search (name, strlen(name) - strlen(file->name) - 1)) 1371 #ifndef VMS 1372 name_len = strlen (name) - strlen (file->name) - 1; 1373 #else 1374 name_len = strlen (name) - strlen (file->name); 1375 if (name[name_len - 1] == '/') 1376 name_len--; 1377 #endif 1378 if (gpath_search (name, name_len)) 1306 1379 { 1307 1380 rename_file (file, name); … … 1310 1383 } 1311 1384 1312 rehash_file (file, name);1313 check_renamed (file);1385 rehash_file (file, name); 1386 check_renamed (file); 1314 1387 /* If the result of a vpath search is -o or -W, preserve it. 1315 1388 Otherwise, find the mtime of the resulting file. */ 1316 1389 if (mtime != OLD_MTIME && mtime != NEW_MTIME) 1317 1390 mtime = name_mtime (name); 1318 }1319 }1391 } 1392 } 1320 1393 } 1321 1394 … … 1363 1436 { 1364 1437 #ifdef NO_FLOAT 1365 error (NILF, _("Warning: File `%s' has modification time in the future"), 1366 file->name); 1438 OS (error, NILF, 1439 _("Warning: File '%s' has modification time in the future"), 1440 file->name); 1367 1441 #else 1368 1442 double from_now = … … 1376 1450 else 1377 1451 sprintf (from_now_string, "%.2g", from_now); 1378 error (NILF, _("Warning: File `%s' has modification time %s s in the future"), 1379 file->name, from_now_string); 1452 OSS (error, NILF, 1453 _("Warning: File '%s' has modification time %s s in the future"), 1454 file->name, from_now_string); 1380 1455 #endif 1381 1456 clock_skew_detected = 1; … … 1384 1459 } 1385 1460 1386 /* Store the mtime into all the entries for this file. */ 1461 /* Store the mtime into all the entries for this file for which it is safe 1462 to do so: avoid propagating timestamps to double-colon rules that haven't 1463 been examined so they're run or not based on the pre-update timestamp. */ 1387 1464 if (file->double_colon) 1388 1465 file = file->double_colon; 1389 1466 1467 propagate_timestamp = file->updated; 1390 1468 do 1391 1469 { 1392 1470 /* If this file is not implicit but it is intermediate then it was 1393 made so by the .INTERMEDIATE target. If this file has never1394 been built by us but was found now, it existed before make1395 started. So, turn off the intermediate bit so make doesn't1396 delete it, since it didn't create it. */1471 made so by the .INTERMEDIATE target. If this file has never 1472 been built by us but was found now, it existed before make 1473 started. So, turn off the intermediate bit so make doesn't 1474 delete it, since it didn't create it. */ 1397 1475 if (mtime != NONEXISTENT_MTIME && file->command_state == cs_not_started 1398 && file->command_state == cs_not_started 1399 && !file->tried_implicit && file->intermediate) 1400 file->intermediate = 0; 1401 1402 file->last_mtime = mtime;1476 && !file->tried_implicit && file->intermediate) 1477 file->intermediate = 0; 1478 1479 if (file->updated == propagate_timestamp) 1480 file->last_mtime = mtime; 1403 1481 file = file->prev; 1404 1482 } … … 1515 1593 library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr) 1516 1594 { 1517 static c har *dirs[] =1595 static const char *dirs[] = 1518 1596 { 1519 1597 #ifndef _AMIGA … … 1528 1606 #define LIBDIR "." 1529 1607 #endif 1530 LIBDIR, /* Defined by configuration. */1608 LIBDIR, /* Defined by configuration. */ 1531 1609 0 1532 1610 }; … … 1543 1621 1544 1622 /* Information about the earliest (in the vpath sequence) match. */ 1545 unsigned int best_vpath, best_path; 1546 unsigned int std_dirs = 0; 1547 1548 char **dp; 1623 unsigned int best_vpath = 0, best_path = 0; 1624 1625 const char **dp; 1549 1626 1550 1627 libpatterns = xstrdup (variable_expand ("$(.LIBPATTERNS)")); … … 1563 1640 static unsigned int buflen = 0; 1564 1641 static int libdir_maxlen = -1; 1642 static unsigned int std_dirs = 0; 1565 1643 char *libbuf = variable_expand (""); 1566 1644 1567 1645 /* Expand the pattern using LIB as a replacement. */ 1568 1646 { 1569 char c = p[len]; 1570 char *p3, *p4; 1571 1572 p[len] = '\0'; 1573 p3 = find_percent (p); 1574 if (!p3) 1575 { 1576 /* Give a warning if there is no pattern. */ 1577 error (NILF, _(".LIBPATTERNS element `%s' is not a pattern"), p); 1647 char c = p[len]; 1648 char *p3, *p4; 1649 1650 p[len] = '\0'; 1651 p3 = find_percent (p); 1652 if (!p3) 1653 { 1654 /* Give a warning if there is no pattern. */ 1655 OS (error, NILF, 1656 _(".LIBPATTERNS element '%s' is not a pattern"), p); 1578 1657 p[len] = c; 1579 continue;1580 }1581 p4 = variable_buffer_output (libbuf, p, p3-p);1582 p4 = variable_buffer_output (p4, lib, liblen);1583 p4 = variable_buffer_output (p4, p3+1, len - (p3-p));1584 p[len] = c;1658 continue; 1659 } 1660 p4 = variable_buffer_output (libbuf, p, p3-p); 1661 p4 = variable_buffer_output (p4, lib, liblen); 1662 p4 = variable_buffer_output (p4, p3+1, len - (p3-p)); 1663 p[len] = c; 1585 1664 } 1586 1665 1587 /* Look first for `libNAME.a' in the current directory. */1666 /* Look first for 'libNAME.a' in the current directory. */ 1588 1667 mtime = name_mtime (libbuf); 1589 1668 if (mtime != NONEXISTENT_MTIME) 1590 {1591 if (mtime_ptr != 0)1592 *mtime_ptr = mtime;1593 file = strcache_add (libbuf);1669 { 1670 if (mtime_ptr != 0) 1671 *mtime_ptr = mtime; 1672 file = strcache_add (libbuf); 1594 1673 /* This by definition will have the best index, so stop now. */ 1595 1674 break; 1596 }1675 } 1597 1676 1598 1677 /* Now try VPATH search on that. */ … … 1631 1710 } 1632 1711 buflen = strlen (libbuf); 1633 buf = xmalloc (libdir_maxlen + buflen + 2);1712 buf = xmalloc (libdir_maxlen + buflen + 2); 1634 1713 } 1635 1714 else if (buflen < strlen (libbuf)) … … 1645 1724 1646 1725 for (dp = dirs; *dp != 0; ++dp) 1647 {1726 { 1648 1727 sprintf (buf, "%s/%s", *dp, libbuf); 1649 1728 mtime = name_mtime (buf); 1650 1729 if (mtime != NONEXISTENT_MTIME) 1651 {1730 { 1652 1731 if (file == 0 || vpath_index < best_vpath) 1653 1732 {
Note:
See TracChangeset
for help on using the changeset viewer.

