Changeset 1018 in kBuild
- Timestamp:
- Jun 3, 2007 10:49:29 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/remake.c
r923 r1018 379 379 register struct dep *d, *lastd; 380 380 int running = 0; 381 382 DBF (DB_VERBOSE, _("Considering target file `%s'.\n")); 381 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 382 struct file *dep_file; 383 384 /* Always work on the primary multi target file, unless of course, if it's 385 a multi-maybe file with its order only dependency on the primary file. */ 386 if (file->multi_head != NULL && file->multi_head != file) 387 { 388 if (!file->multi_maybe) 389 { 390 DBS (DB_VERBOSE, (_("Considering target file `%s' -> switching to multi head `%s'.\n"), 391 file->name, file->multi_head->name)); 392 file = file->multi_head; 393 } 394 else 395 DBF (DB_VERBOSE, _("Considering target file `%s'. (multi-maybe)\n")); 396 /* XXX: optimize dependencies. */ 397 } 398 else 399 #endif /* CONFIG_WITH_EXPLICIT_MULTITARGET */ 400 DBF (DB_VERBOSE, _("Considering target file `%s'.\n")); 383 401 384 402 if (file->updated) … … 469 487 470 488 /* Update all non-intermediate files we depend on, if necessary, 471 and see whether any of them is more recent than this file. */ 472 473 lastd = 0; 474 d = file->deps; 475 while (d != 0) 476 { 477 FILE_TIMESTAMP mtime; 478 int maybe_make; 479 int dontcare = 0; 480 481 check_renamed (d->file); 482 483 mtime = file_mtime (d->file); 484 check_renamed (d->file); 485 486 if (is_updating (d->file)) 487 { 488 error (NILF, _("Circular %s <- %s dependency dropped."), 489 file->name, d->file->name); 490 /* We cannot free D here because our the caller will still have 491 a reference to it when we were called recursively via 492 check_dep below. */ 493 if (lastd == 0) 494 file->deps = d->next; 495 else 496 lastd->next = d->next; 497 d = d->next; 498 continue; 499 } 500 501 d->file->parent = file; 502 maybe_make = must_make; 503 504 /* Inherit dontcare flag from our parent. */ 505 if (rebuilding_makefiles) 489 and see whether any of them is more recent than this file. 490 For explicit multitarget rules we must iterate all the output 491 files to get the correct picture (this means re-evaluating 492 shared dependencies - bad). */ 493 494 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 495 for (dep_file = file; dep_file; 496 dep_file = file == file->multi_head ? dep_file->multi_next : NULL) 497 { 498 lastd = 0; 499 d = dep_file->deps; 500 #else 501 lastd = 0; 502 d = file->deps; 503 #endif 504 while (d != 0) 506 505 { 507 dontcare = d->file->dontcare; 508 d->file->dontcare = file->dontcare; 506 FILE_TIMESTAMP mtime; 507 int maybe_make; 508 int dontcare = 0; 509 510 check_renamed (d->file); 511 512 mtime = file_mtime (d->file); 513 check_renamed (d->file); 514 515 if (is_updating (d->file)) 516 { 517 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 518 /* silently ignore the order-only dep hack. */ 519 if (dep_file->multi_maybe && d->file == file) 520 { 521 lastd = d; 522 d = d->next; 523 continue; 524 } 525 #endif 526 527 error (NILF, _("Circular %s <- %s dependency dropped."), 528 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 529 dep_file->name, d->file->name); 530 #else 531 file->name, d->file->name); 532 #endif 533 /* We cannot free D here because our the caller will still have 534 a reference to it when we were called recursively via 535 check_dep below. */ 536 if (lastd == 0) 537 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 538 dep_file->deps = d->next; 539 #else 540 file->deps = d->next; 541 #endif 542 else 543 lastd->next = d->next; 544 d = d->next; 545 continue; 546 } 547 548 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 549 d->file->parent = dep_file; 550 #else 551 d->file->parent = file; 552 #endif 553 maybe_make = must_make; 554 555 /* Inherit dontcare flag from our parent. */ 556 if (rebuilding_makefiles) 557 { 558 dontcare = d->file->dontcare; 559 d->file->dontcare = file->dontcare; 560 } 561 562 563 dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make); 564 565 /* Restore original dontcare flag. */ 566 if (rebuilding_makefiles) 567 d->file->dontcare = dontcare; 568 569 if (! d->ignore_mtime) 570 must_make = maybe_make; 571 572 check_renamed (d->file); 573 574 { 575 register struct file *f = d->file; 576 if (f->double_colon) 577 f = f->double_colon; 578 do 579 { 580 running |= (f->command_state == cs_running 581 || f->command_state == cs_deps_running); 582 f = f->prev; 583 } 584 while (f != 0); 585 } 586 587 if (dep_status != 0 && !keep_going_flag) 588 break; 589 590 if (!running) 591 /* The prereq is considered changed if the timestamp has changed while 592 it was built, OR it doesn't exist. */ 593 d->changed = ((file_mtime (d->file) != mtime) 594 || (mtime == NONEXISTENT_MTIME)); 595 596 lastd = d; 597 d = d->next; 509 598 } 510 511 512 dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make); 513 514 /* Restore original dontcare flag. */ 515 if (rebuilding_makefiles) 516 d->file->dontcare = dontcare; 517 518 if (! d->ignore_mtime) 519 must_make = maybe_make; 520 521 check_renamed (d->file); 522 523 { 524 register struct file *f = d->file; 525 if (f->double_colon) 526 f = f->double_colon; 527 do 528 { 529 running |= (f->command_state == cs_running 530 || f->command_state == cs_deps_running); 531 f = f->prev; 532 } 533 while (f != 0); 534 } 535 599 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 536 600 if (dep_status != 0 && !keep_going_flag) 537 break; 538 539 if (!running) 540 /* The prereq is considered changed if the timestamp has changed while 541 it was built, OR it doesn't exist. */ 542 d->changed = ((file_mtime (d->file) != mtime) 543 || (mtime == NONEXISTENT_MTIME)); 544 545 lastd = d; 546 d = d->next; 547 } 601 break; 602 } 603 #endif 548 604 549 605 /* Now we know whether this target needs updating. … … 552 608 if (must_make || always_make_flag) 553 609 { 554 for (d = file->deps; d != 0; d = d->next) 555 if (d->file->intermediate) 556 { 557 int dontcare = 0; 558 559 FILE_TIMESTAMP mtime = file_mtime (d->file); 560 check_renamed (d->file); 561 d->file->parent = file; 562 563 /* Inherit dontcare flag from our parent. */ 564 if (rebuilding_makefiles) 610 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 611 for (dep_file = file; dep_file; 612 dep_file = file == file->multi_head ? dep_file->multi_next : NULL) 613 for (d = dep_file->deps; d != 0; d = d->next) 614 #else 615 for (d = file->deps; d != 0; d = d->next) 616 #endif 617 if (d->file->intermediate) 618 { 619 int dontcare = 0; 620 621 FILE_TIMESTAMP mtime = file_mtime (d->file); 622 check_renamed (d->file); 623 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 624 d->file->parent = dep_file; 625 #else 626 d->file->parent = file; 627 #endif 628 629 /* Inherit dontcare flag from our parent. */ 630 if (rebuilding_makefiles) 631 { 632 dontcare = d->file->dontcare; 633 d->file->dontcare = file->dontcare; 634 } 635 636 637 dep_status |= update_file (d->file, depth); 638 639 /* Restore original dontcare flag. */ 640 if (rebuilding_makefiles) 641 d->file->dontcare = dontcare; 642 643 check_renamed (d->file); 644 565 645 { 566 dontcare = d->file->dontcare; 567 d->file->dontcare = file->dontcare; 646 register struct file *f = d->file; 647 if (f->double_colon) 648 f = f->double_colon; 649 do 650 { 651 running |= (f->command_state == cs_running 652 || f->command_state == cs_deps_running); 653 f = f->prev; 654 } 655 while (f != 0); 568 656 } 569 570 571 dep_status |= update_file (d->file, depth); 572 573 /* Restore original dontcare flag. */ 574 if (rebuilding_makefiles) 575 d->file->dontcare = dontcare; 576 577 check_renamed (d->file); 578 579 { 580 register struct file *f = d->file; 581 if (f->double_colon) 582 f = f->double_colon; 583 do 584 { 585 running |= (f->command_state == cs_running 586 || f->command_state == cs_deps_running); 587 f = f->prev; 588 } 589 while (f != 0); 590 } 591 592 if (dep_status != 0 && !keep_going_flag) 593 break; 594 595 if (!running) 596 d->changed = ((file->phony && file->cmds != 0) 597 || file_mtime (d->file) != mtime); 598 } 657 658 if (dep_status != 0 && !keep_going_flag) 659 break; 660 661 if (!running) 662 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 663 d->changed = ((dep_file->phony && dep_file->cmds != 0) 664 #else 665 d->changed = ((file->phony && file->cmds != 0) 666 #endif 667 || file_mtime (d->file) != mtime); 668 } 599 669 } 600 670 … … 645 715 646 716 deps_changed = 0; 647 for (d = file->deps; d != 0; d = d->next) 648 { 649 FILE_TIMESTAMP d_mtime = file_mtime (d->file); 650 check_renamed (d->file); 651 652 if (! d->ignore_mtime) 653 { 717 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 718 for (dep_file = file; dep_file; 719 dep_file = file == file->multi_head ? dep_file->multi_next : NULL) 720 #endif 721 for (d = file->deps; d != 0; d = d->next) 722 { 723 FILE_TIMESTAMP d_mtime = file_mtime (d->file); 724 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 725 if (d->file == file && dep_file->multi_maybe) 726 continue; 727 #endif 728 check_renamed (d->file); 729 730 if (! d->ignore_mtime) 731 { 654 732 #if 1 655 /* %%% In version 4, remove this code completely to656 657 658 if (d_mtime == NONEXISTENT_MTIME && !d->file->intermediate)659 /* We must remake if this dep does not660 exist and is not intermediate. */661 must_make = 1;662 #endif 663 664 /* Set DEPS_CHANGED if this dep actually changed. */665 deps_changed |= d->changed;666 }667 668 /* Set D->changed if either this dep actually changed,669 670 d->changed |= noexist || d_mtime > this_mtime;671 672 if (!noexist && ISDB (DB_BASIC|DB_VERBOSE))673 674 const char *fmt = 0;675 676 if (d->ignore_mtime)677 {678 if (ISDB (DB_VERBOSE))679 fmt = _("Prerequisite `%s' is order-only for target `%s'.\n");680 }681 else if (d_mtime == NONEXISTENT_MTIME)682 {683 if (ISDB (DB_BASIC))684 fmt = _("Prerequisite `%s' of target `%s' does not exist.\n");685 }686 687 {688 if (ISDB (DB_BASIC))689 fmt = _("Prerequisite `%s' is newer than target `%s'.\n");690 }691 else if (ISDB (DB_VERBOSE))692 fmt = _("Prerequisite `%s' is older than target `%s'.\n");693 694 if (fmt)695 {696 print_spaces (depth);697 printf (fmt, dep_name (d), file->name);698 fflush (stdout);699 }700 701 }733 /* %%% In version 4, remove this code completely to 734 implement not remaking deps if their deps are newer 735 than their parents. */ 736 if (d_mtime == NONEXISTENT_MTIME && !d->file->intermediate) 737 /* We must remake if this dep does not 738 exist and is not intermediate. */ 739 must_make = 1; 740 #endif 741 742 /* Set DEPS_CHANGED if this dep actually changed. */ 743 deps_changed |= d->changed; 744 } 745 746 /* Set D->changed if either this dep actually changed, 747 or its dependent, FILE, is older or does not exist. */ 748 d->changed |= noexist || d_mtime > this_mtime; 749 750 if (!noexist && ISDB (DB_BASIC|DB_VERBOSE)) 751 { 752 const char *fmt = 0; 753 754 if (d->ignore_mtime) 755 { 756 if (ISDB (DB_VERBOSE)) 757 fmt = _("Prerequisite `%s' is order-only for target `%s'.\n"); 758 } 759 else if (d_mtime == NONEXISTENT_MTIME) 760 { 761 if (ISDB (DB_BASIC)) 762 fmt = _("Prerequisite `%s' of target `%s' does not exist.\n"); 763 } 764 else if (d->changed) 765 { 766 if (ISDB (DB_BASIC)) 767 fmt = _("Prerequisite `%s' is newer than target `%s'.\n"); 768 } 769 else if (ISDB (DB_VERBOSE)) 770 fmt = _("Prerequisite `%s' is older than target `%s'.\n"); 771 772 if (fmt) 773 { 774 print_spaces (depth); 775 printf (fmt, dep_name (d), file->name); 776 fflush (stdout); 777 } 778 } 779 } 702 780 703 781 /* Here depth returns to the value it had when we were called. */ … … 706 784 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 707 785 /* maybe-update targets in a multi target should have been remade 708 by now, so return before we remake it again. 709 710 XXX What if there are extra dependencies for this file that 711 triggers a remake when the primary target doesn't need remaking? 712 Current solution is: Don't do that! */ 786 by now, so return before we remake it again. */ 713 787 if (file->multi_maybe) 714 788 {
Note:
See TracChangeset
for help on using the changeset viewer.