- Timestamp:
- Jun 4, 2007 12:58:37 AM (18 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/read.c
r940 r1021 2044 2044 { 2045 2045 max_targets += 5; 2046 targets = xrealloc ( targets, max_targets * sizeof (char *));2047 target_percents = xrealloc ( target_percents,2046 targets = xrealloc ((void *)targets, max_targets * sizeof (char *)); 2047 target_percents = xrealloc ((void *)target_percents, 2048 2048 max_targets * sizeof (char *)); 2049 2049 } … … 2056 2056 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 2057 2057 /* Check for the explicit multitarget mode operators. For this to be 2058 identified as an ex cplicit multiple target rule, the first + or +|2058 identified as an explicit multiple target rule, the first + or +| 2059 2059 operator *must* appear between the first two files. If not found as 2060 2060 the 2nd file or if found as the 1st file, the rule will be rejected … … 2069 2069 cmp timestamp maybe.h || cp -f timestamp maybe.h 2070 2070 2071 This is handled below by adding replacing the prereqs of the 2072 maybe-updated by an order only dependency on the primary target 2073 (see below). This saves messing up remake.c. */ 2071 This is implemented in remake.c where we don't consider the mtime of 2072 the maybe-updated targets. */ 2074 2073 if (multi_mode != m_no && name[0] == '+' 2075 2074 && (name[1] == '\0' || (name[1] == '|' && name[2] == '\0'))) … … 2080 2079 { 2081 2080 if (multi_mode == m_unsettled) 2082 prev_file->multi_head = prev_file; 2081 { 2082 prev_file->multi_head = prev_file; 2083 2084 /* Only the primary file needs the dependencies. */ 2085 if (deps) 2086 { 2087 free_dep_chain (deps); 2088 deps = NULL; 2089 } 2090 } 2083 2091 multi_mode = name[1] == '\0' ? m_yes : m_yes_maybe; 2084 2092 continue; … … 2141 2149 if (cmds != 0) 2142 2150 f->cmds = cmds; 2143 2144 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET2145 /* If this is an explicit multi target rule, add it to the2146 target chain and set the multi_maybe flag according to2147 the current mode. This is also where we do the dependency2148 tricks for the 'maybe' targets (see above). */2149 2150 if (multi_mode >= m_yes)2151 {2152 f->multi_maybe = multi_mode == m_yes_maybe;2153 if (f->multi_maybe)2154 {2155 /* expand_deps needs the "| " bit.2156 XXX leaking memory here? */2157 size_t len = strlen (prev_file->multi_head->name) + 1;2158 char *maybe_dep = xmalloc (len + 2);2159 memcpy (maybe_dep, "| ", 2);2160 memcpy (maybe_dep + 2, prev_file->multi_head->name, len);2161 2162 free_dep_chain (this);2163 this = alloc_dep ();2164 this->name = maybe_dep;2165 this->ignore_mtime = 1;2166 }2167 prev_file->multi_next = f;2168 assert (prev_file->multi_head != 0);2169 f->multi_head = prev_file->multi_head;2170 2171 if (f == suffix_file)2172 error (flocp,2173 _(".SUFFIXES encountered in an explicit multi target rule"));2174 }2175 prev_file = f;2176 #endif2177 2151 2178 2152 /* Defining .SUFFIXES with no dependencies clears out the list of -
trunk/src/kmk/remake.c
r1020 r1021 380 380 int running = 0; 381 381 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 382 struct file * dep_file;382 struct file *f2, *f3; 383 383 384 384 /* Always work on the primary multi target file. */ 385 385 386 if (file->multi_head != NULL && file->multi_head != file) 386 387 { 387 DBS (DB_VERBOSE, (_("Considering target file `%s' -> switching tomulti head `%s'.\n"),388 DBS (DB_VERBOSE, (_("Considering target file `%s' -> multi head `%s'.\n"), 388 389 file->name, file->multi_head->name)); 389 390 file = file->multi_head; 390 /* XXX: optimize dependencies. */391 391 } 392 392 else … … 442 442 not need an implicit rule. If this were not done, the file 443 443 might get implicit commands that apply to its initial name, only 444 to have that name replaced with another found by VPATH search. */ 445 444 to have that name replaced with another found by VPATH search. 445 446 For multi target files check the other files and use the time 447 of the oldest / non-existing file. */ 448 449 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 450 this_mtime = file_mtime (file); 451 f3 = file; 452 for (f2 = file->multi_next; 453 f2 != NULL && this_mtime != NONEXISTENT_MTIME; 454 f2 = f2->multi_next) 455 if (!f2->multi_maybe) 456 { 457 FILE_TIMESTAMP second_mtime = file_mtime (f2); 458 if (second_mtime < this_mtime) 459 { 460 this_mtime = second_mtime; 461 f3 = f2; 462 } 463 } 464 check_renamed (file); 465 noexist = this_mtime == NONEXISTENT_MTIME; 466 if (noexist) 467 DBS (DB_BASIC, (_("File `%s' does not exist.\n"), f3->name)); 468 #else /* !CONFIG_WITH_EXPLICIT_MULTITARGET */ 446 469 this_mtime = file_mtime (file); 447 470 check_renamed (file); … … 449 472 if (noexist) 450 473 DBF (DB_BASIC, _("File `%s' does not exist.\n")); 474 #endif /* !CONFIG_WITH_EXPLICIT_MULTITARGET */ 451 475 else if (ORDINARY_MTIME_MIN <= this_mtime && this_mtime <= ORDINARY_MTIME_MAX 452 476 && file->low_resolution_time) … … 483 507 and see whether any of them is more recent than this file. 484 508 For explicit multitarget rules we must iterate all the output 485 files to get the correct picture (this means re-evaluating 486 shared dependencies - bad). */ 509 files to get the correct picture. */ 487 510 488 511 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 489 for ( dep_file = file; dep_file; dep_file = dep_file->multi_next)512 for (f2 = file; f2; f2 = f2->multi_next) 490 513 { 491 514 lastd = 0; 492 d = dep_file->deps;515 d = f2->deps; 493 516 #else 494 517 lastd = 0; … … 510 533 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 511 534 /* silently ignore the order-only dep hack. */ 512 if ( dep_file->multi_maybe && d->file == file)535 if (f2->multi_maybe && d->file == file) 513 536 { 514 537 lastd = d; … … 520 543 error (NILF, _("Circular %s <- %s dependency dropped."), 521 544 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 522 dep_file->name, d->file->name);545 f2->name, d->file->name); 523 546 #else 524 547 file->name, d->file->name); … … 529 552 if (lastd == 0) 530 553 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 531 dep_file->deps = d->next;554 f2->deps = d->next; 532 555 #else 533 556 file->deps = d->next; … … 540 563 541 564 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 542 d->file->parent = dep_file;565 d->file->parent = f2; 543 566 #else 544 567 d->file->parent = file; … … 602 625 { 603 626 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 604 for ( dep_file = file; dep_file; dep_file = dep_file->multi_next)605 for (d = dep_file->deps; d != 0; d = d->next)627 for (f2 = file; f2; f2 = f2->multi_next) 628 for (d = f2->deps; d != 0; d = d->next) 606 629 #else 607 630 for (d = file->deps; d != 0; d = d->next) … … 614 637 check_renamed (d->file); 615 638 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 616 d->file->parent = dep_file;639 d->file->parent = f2; 617 640 #else 618 641 d->file->parent = file; … … 653 676 if (!running) 654 677 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 655 d->changed = (( dep_file->phony && dep_file->cmds != 0)678 d->changed = ((f2->phony && f2->cmds != 0) 656 679 #else 657 680 d->changed = ((file->phony && file->cmds != 0) … … 708 731 deps_changed = 0; 709 732 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 710 for ( dep_file = file; dep_file; dep_file = dep_file->multi_next)733 for (f2 = file; f2; f2 = f2->multi_next) 711 734 #endif 712 735 for (d = file->deps; d != 0; d = d->next) … … 714 737 FILE_TIMESTAMP d_mtime = file_mtime (d->file); 715 738 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 716 if (d->file == file && dep_file->multi_maybe)739 if (d->file == file && f2->multi_maybe) 717 740 continue; 718 741 #endif … … 819 842 } 820 843 821 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 822 if (ISDB(DB_BASIC) && file->multi_head && file->multi_head != file) 823 DBS (DB_BASIC, (_("Must remake target `%s' - primary target `%s'.\n"), file->name, file->multi_head->name)); 824 else 825 #endif 826 DBF (DB_BASIC, _("Must remake target `%s'.\n")); 844 DBF (DB_BASIC, _("Must remake target `%s'.\n")); 827 845 828 846 /* It needs to be remade. If it's VPATH and not reset via GPATH, toss the … … 1212 1230 { 1213 1231 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 1214 /* Always operate on the primary file. */ 1215 if (file->multi_head && file->multi_head != file) 1216 file = file->multi_head; 1232 assert(file->multi_head == NULL || file->multi_head == file); 1217 1233 #endif 1218 1234
Note:
See TracChangeset
for help on using the changeset viewer.