Changeset 2591 in kBuild for trunk/src/kmk/remake.c
- Timestamp:
- Jun 17, 2012 8:45:31 PM (13 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk
- Property svn:ignore
-
old new 13 13 stamp-* 14 14 makebook* 15 15 16 .*gdbinit 17 .gdb_history 18 16 19 *.dep 17 20 *.dvi … … 31 34 *.pg 32 35 *.pgs 36 33 37 README 34 38 README.DOS 35 39 README.W32 40 README.OS2 36 41 aclocal.m4 37 42 autom4te.cache … … 52 57 config.h.W32 53 58 config.h-vms 59 54 60 loadavg 55 61 loadavg.c 56 62 make 63 57 64 .deps 58 65 .dep_segment 66 ID 67 TAGS 68 59 69 _* 60 70 sun4 … … 72 82 sol2 73 83 i486-linux 84 74 85 customs 86 75 87 install-sh 76 88 mkinstalldirs 89 90 .directive.asc
-
- Property svn:ignore
-
trunk/src/kmk/remake.c
r2100 r2591 1 1 /* Basic dependency engine for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 90 90 { 91 91 int t = touch_flag, q = question_flag, n = just_print_flag; 92 unsigned int j = job_slots;93 92 int status = -1; 94 93 … … 142 141 unsigned int ocommands_started; 143 142 int x; 143 144 file->dontcare = g->dontcare; 145 144 146 check_renamed (file); 145 147 if (rebuilding_makefiles) … … 215 217 any_not_updated |= !file->updated; 216 218 219 file->dontcare = 0; 220 217 221 if (stop) 218 222 break; … … 275 279 question_flag = q; 276 280 just_print_flag = n; 277 job_slots = j;278 281 } 279 282 … … 308 311 if (f->considered == considered) 309 312 { 310 DBF (DB_VERBOSE, _("Pruning file `%s'.\n")); 311 return f->command_state == cs_finished ? f->update_status : 0; 313 /* Check for the case where a target has been tried and failed but 314 the diagnostics hasn't been issued. If we need the diagnostics 315 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; 320 } 312 321 } 313 322 … … 326 335 /* If we got an error, don't bother with double_colon etc. */ 327 336 if (status != 0 && !keep_going_flag) 328 337 return status; 329 338 330 339 if (f->command_state == cs_running … … 358 367 359 368 static void 360 complain ( conststruct file *file)369 complain (struct file *file) 361 370 { 362 371 const char *msg_noparent … … 365 374 = _("%sNo rule to make target `%s', needed by `%s'%s"); 366 375 376 /* If this file has no_diag set then it means we tried to update it 377 before in the dontcare mode and failed. The target that actually 378 failed is not necessarily this file but could be one of its direct 379 or indirect dependencies. So traverse this file's dependencies and 380 find the one that actually caused the failure. */ 381 382 struct dep *d; 383 384 for (d = file->deps; d != 0; d = d->next) 385 { 386 if (d->file->updated && d->file->update_status > 0 && file->no_diag) 387 { 388 complain (d->file); 389 break; 390 } 391 } 392 393 if (d == 0) 394 { 395 /* Didn't find any dependencies to complain about. */ 396 367 397 #ifdef KMK 368 /* jokes */369 if (!keep_going_flag && file->parent == 0)370 {371 const char *msg_joke = 0;372 extern struct dep *goals;373 374 /* classics */375 if (!strcmp (file->name, "fire")376 || !strcmp (file->name, "Fire"))377 msg_joke = "No matches.\n";378 else if (!strcmp (file->name, "love")379 || !strcmp (file->name, "Love")380 || !strcmp (file->name, "peace")381 || !strcmp (file->name, "Peace"))382 msg_joke = "Not war.\n";383 else if (!strcmp (file->name, "war"))384 msg_joke = "Don't know how to make war.\n";385 386 /* http://xkcd.com/149/ - GNU Make bug #23273. */387 else if (( !strcmp (file->name, "me")388 && goals != 0389 && !strcmp (dep_name(goals), "me")390 && goals->next != 0391 && !strcmp (dep_name(goals->next), "a")392 && goals->next->next != 0)393 || !strncmp (file->name, "me a ", 5))394 msg_joke =398 /* jokes */ 399 if (!keep_going_flag && file->parent == 0) 400 { 401 const char *msg_joke = 0; 402 extern struct dep *goals; 403 404 /* classics */ 405 if (!strcmp (file->name, "fire") 406 || !strcmp (file->name, "Fire")) 407 msg_joke = "No matches.\n"; 408 else if (!strcmp (file->name, "love") 409 || !strcmp (file->name, "Love") 410 || !strcmp (file->name, "peace") 411 || !strcmp (file->name, "Peace")) 412 msg_joke = "Not war.\n"; 413 else if (!strcmp (file->name, "war")) 414 msg_joke = "Don't know how to make war.\n"; 415 416 /* http://xkcd.com/149/ - GNU Make bug #23273. */ 417 else if (( !strcmp (file->name, "me") 418 && goals != 0 419 && !strcmp (dep_name(goals), "me") 420 && goals->next != 0 421 && !strcmp (dep_name(goals->next), "a") 422 && goals->next->next != 0) 423 || !strncmp (file->name, "me a ", 5)) 424 msg_joke = 395 425 # ifdef HAVE_UNISTD_H 396 426 getuid () == 0 ? "Okay.\n" : 397 427 # endif 398 "What? Make it yourself!\n"; 399 if (msg_joke) 428 "What? Make it yourself!\n"; 429 if (msg_joke) 430 { 431 fputs (msg_joke, stderr); 432 die (2); 433 } 434 } 435 #endif /* KMK */ 436 437 if (!keep_going_flag) 400 438 { 401 fputs (msg_joke, stderr); 402 die (2); 439 if (file->parent == 0) 440 fatal (NILF, msg_noparent, "", file->name, ""); 441 442 fatal (NILF, msg_parent, "", file->name, file->parent->name, ""); 403 443 } 404 } 405 #endif /* KMK */ 406 407 if (!keep_going_flag) 408 { 444 409 445 if (file->parent == 0) 410 fatal (NILF, msg_noparent, "", file->name, ""); 411 412 fatal (NILF, msg_parent, "", file->name, file->parent->name, ""); 413 } 414 415 if (file->parent == 0) 416 error (NILF, msg_noparent, "*** ", file->name, "."); 417 else 418 error (NILF, msg_parent, "*** ", file->name, file->parent->name, "."); 446 error (NILF, msg_noparent, "*** ", file->name, "."); 447 else 448 error (NILF, msg_parent, "*** ", file->name, file->parent->name, "."); 449 450 file->no_diag = 0; 451 } 419 452 } 420 453 … … 424 457 update_file_1 (struct file *file, unsigned int depth) 425 458 { 426 registerFILE_TIMESTAMP this_mtime;459 FILE_TIMESTAMP this_mtime; 427 460 int noexist, must_make, deps_changed; 428 461 int dep_status = 0; 429 register struct dep *d, *lastd; 462 struct file *ofile; 463 struct dep *d, *ad; 464 struct dep amake; 430 465 int running = 0; 431 466 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 467 struct file *org_file = file; 432 468 struct file *f2, *f3; 433 469 … … 438 474 DBS (DB_VERBOSE, (_("Considering target file `%s' -> multi head `%s'.\n"), 439 475 file->name, file->multi_head->name)); 440 file = file->multi_head;476 org_file = file = file->multi_head; 441 477 } 442 478 else … … 451 487 _("Recently tried and failed to update file `%s'.\n")); 452 488 453 /* If the file we tried to make is marked dontcarethen no message489 /* If the file we tried to make is marked no_diag then no message 454 490 was printed about it when it failed during the makefile rebuild. 455 491 If we're trying to build it again in the normal rebuild, print a 456 492 message now. */ 457 if (file->dontcare && !rebuilding_makefiles) 458 { 459 file->dontcare = 0; 493 if (file->no_diag && !file->dontcare) 460 494 complain (file); 461 }462 495 463 496 return file->update_status; … … 483 516 } 484 517 518 /* Determine whether the diagnostics will be issued should this update 519 fail. */ 520 file->no_diag = file->dontcare; 521 485 522 ++depth; 486 523 487 524 /* Notice recursive update of the same file. */ 488 525 start_updating (file); 526 527 /* We might change file if we find a different one via vpath; 528 remember this one to turn off updating. */ 529 ofile = file; 489 530 490 531 /* Looking at the file's modtime beforehand allows the possibility … … 554 595 } 555 596 556 /* Update all non-intermediate files we depend on, if necessary, 557 and see whether any of them is more recent than this file. 558 For explicit multitarget rules we must iterate all the output 597 /* Update all non-intermediate files we depend on, if necessary, and see 598 whether any of them is more recent than this file. We need to walk our 599 deps, AND the deps of any also_make targets to ensure everything happens 600 in the correct order. 601 602 bird: For explicit multitarget rules we must iterate all the output 559 603 files to get the correct picture. The special .MUST_MAKE 560 target variable call is also done from this context. 604 target variable call is also done from this context. */ 561 605 562 606 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 563 for (f2 = file; f2; f2 = f2->multi_next) 564 { 565 lastd = 0; 566 d = f2->deps; 567 #else 568 lastd = 0; 569 d = file->deps; 570 #endif 571 while (d != 0) 607 assert (file == org_file); 608 for (f2 = file; f2; file = f2 = f2->multi_next) 609 { 610 #endif 611 amake.file = file; 612 amake.next = file->also_make; 613 ad = &amake; 614 while (ad) 615 { 616 struct dep *lastd = 0; 617 618 /* Find the deps we're scanning */ 619 d = ad->file->deps; 620 ad = ad->next; 621 622 while (d) 572 623 { 573 624 FILE_TIMESTAMP mtime; … … 584 635 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 585 636 /* silently ignore the order-only dep hack. */ 586 if (f 2->multi_maybe && d->file ==file)637 if (file->multi_maybe && d->file == org_file) 587 638 { 588 639 lastd = d; … … 593 644 594 645 error (NILF, _("Circular %s <- %s dependency dropped."), 595 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET596 f2->name, d->file->name);597 #else598 646 file->name, d->file->name); 599 #endif600 647 /* We cannot free D here because our the caller will still have 601 648 a reference to it when we were called recursively via 602 649 check_dep below. */ 603 650 if (lastd == 0) 604 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET605 f2->deps = d->next;606 #else607 651 file->deps = d->next; 608 #endif609 652 else 610 653 lastd->next = d->next; … … 613 656 } 614 657 615 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET616 d->file->parent = f2;617 #else618 658 d->file->parent = file; 619 #endif620 659 maybe_make = must_make; 621 660 … … 626 665 d->file->dontcare = file->dontcare; 627 666 } 628 629 667 630 668 dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make); … … 664 702 d = d->next; 665 703 } 704 } 666 705 667 706 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 668 if (dep_status != 0 && !keep_going_flag) 669 break; 670 } 707 if (dep_status != 0 && !keep_going_flag) 708 break; 709 } 710 file = org_file; 671 711 #endif 672 712 … … 677 717 # ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 678 718 if (!must_make) 679 for (f2 = file; f2 && !must_make; f2 = f2->multi_next)719 for (f2 = org_file; f2 && !must_make; f2 = f2->multi_next) 680 720 must_make = call_must_make_target_var (f2, depth); 681 721 # else … … 691 731 { 692 732 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 693 for (f2 = file; f2; f2 = f2->multi_next) 694 for (d = f2->deps; d != 0; d = d->next) 695 #else 733 for (file = f2 = org_file; f2; file = f2 = f2->multi_next) 734 #endif 696 735 for (d = file->deps; d != 0; d = d->next) 697 #endif698 736 if (d->file->intermediate) 699 737 { … … 702 740 FILE_TIMESTAMP mtime = file_mtime (d->file); 703 741 check_renamed (d->file); 704 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET705 d->file->parent = f2;706 #else707 742 d->file->parent = file; 708 #endif709 743 710 744 /* Inherit dontcare flag from our parent. */ … … 741 775 742 776 if (!running) 743 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET744 d->changed = ((f2->phony && f2->cmds != 0)745 #else746 777 d->changed = ((file->phony && file->cmds != 0) 747 #endif748 778 || file_mtime (d->file) != mtime); 749 779 } 780 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 781 file = org_file; 782 #endif 750 783 } 751 784 752 785 finish_updating (file); 786 finish_updating (ofile); 753 787 754 788 DBF (DB_VERBOSE, _("Finished prerequisites of target file `%s'.\n")); … … 797 831 deps_changed = 0; 798 832 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 799 for (f 2 = file; f2;f2 = f2->multi_next)833 for (file = f2 = org_file; f2; file = f2 = f2->multi_next) 800 834 #endif 801 835 for (d = file->deps; d != 0; d = d->next) … … 803 837 FILE_TIMESTAMP d_mtime = file_mtime (d->file); 804 838 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 805 if (d->file == file && f 2->multi_maybe)839 if (d->file == file && file->multi_maybe) 806 840 continue; 807 841 #endif … … 858 892 } 859 893 } 894 #ifdef CONFIG_WITH_EXPLICIT_MULTITARGET 895 file = org_file; 896 #endif 860 897 861 898 /* Here depth returns to the value it had when we were called. */ … … 1170 1207 would have been updated. */ 1171 1208 1172 if ( question_flag || just_print_flag || touch_flag)1209 if ((question_flag || just_print_flag || touch_flag) && file->cmds) 1173 1210 { 1174 1211 for (i = file->cmds->ncommand_lines; i > 0; --i) … … 1278 1315 FILE_TIMESTAMP this_mtime, int *must_make_ptr) 1279 1316 { 1317 struct file *ofile; 1280 1318 struct dep *d; 1281 1319 int dep_status = 0; … … 1283 1321 ++depth; 1284 1322 start_updating (file); 1323 1324 /* We might change file if we find a different one via vpath; 1325 remember this one to turn off updating. */ 1326 ofile = file; 1285 1327 1286 1328 if (file->phony || !file->intermediate) … … 1333 1375 necessary, and see whether any of them is more recent than the 1334 1376 file on whose behalf we are checking. */ 1335 struct dep *l astd;1377 struct dep *ld; 1336 1378 int deps_running = 0; 1337 1379 1338 /* Reset this target's state so that we check it fresh. It could be 1339 that it's already been checked as part of an order-only 1340 prerequisite and so wasn't rebuilt then, but should be now. 1341 1342 bird: What if we're already running the recipe? We don't wish 1343 it to be started once again do we? This happens with the 1344 SECONDARY Test #9 here now... If the idea is to re-evaluate 1345 the target regardless of whether it's running or no, then 1346 perhaps saving and restoring is a better idea? 1347 See bug #15919. */ 1348 if (file->command_state != cs_running) /* bird */ 1380 /* If this target is not running, set it's state so that we check it 1381 fresh. It could be it was checked as part of an order-only 1382 prerequisite and so wasn't rebuilt then, but should be now. */ 1383 if (file->command_state != cs_running) 1349 1384 set_command_state (file, cs_not_started); 1350 1385 1351 l astd = 0;1386 ld = 0; 1352 1387 d = file->deps; 1353 1388 while (d != 0) … … 1359 1394 error (NILF, _("Circular %s <- %s dependency dropped."), 1360 1395 file->name, d->file->name); 1361 if (l astd == 0)1396 if (ld == 0) 1362 1397 { 1363 1398 file->deps = d->next; … … 1367 1402 else 1368 1403 { 1369 l astd->next = d->next;1404 ld->next = d->next; 1370 1405 free_dep (d); 1371 d = l astd->next;1406 d = ld->next; 1372 1407 } 1373 1408 continue; … … 1388 1423 deps_running = 1; 1389 1424 1390 l astd = d;1425 ld = d; 1391 1426 d = d->next; 1392 1427 } … … 1401 1436 1402 1437 finish_updating (file); 1438 finish_updating (ofile); 1439 1403 1440 return dep_status; 1404 1441 } … … 1588 1625 { 1589 1626 /* If name_mtime failed, search VPATH. */ 1590 const char *name = vpath_search (file->name, &mtime );1627 const char *name = vpath_search (file->name, &mtime, NULL, NULL); 1591 1628 if (name 1592 1629 /* Last resort, is it a library (-lxxx)? */ … … 1839 1876 }; 1840 1877 1841 static char *libpatterns = NULL; 1842 1843 const char *libname = lib+2; /* Name without the '-l'. */ 1878 const char *file = 0; 1879 char *libpatterns; 1844 1880 FILE_TIMESTAMP mtime; 1845 1881 … … 1848 1884 const char *p2; 1849 1885 unsigned int len; 1886 unsigned int liblen; 1887 1888 /* Information about the earliest (in the vpath sequence) match. */ 1889 unsigned int best_vpath = 0, best_path = 0; /* bird: gcc maybe used uninitialized (both) */ 1890 unsigned int std_dirs = 0; 1850 1891 1851 1892 char **dp; 1852 1893 1853 /* If we don't have libpatterns, get it. */ 1854 if (!libpatterns) 1855 { 1856 int save = warn_undefined_variables_flag; 1857 warn_undefined_variables_flag = 0; 1858 1859 libpatterns = xstrdup (variable_expand ("$(strip $(.LIBPATTERNS))")); 1860 1861 warn_undefined_variables_flag = save; 1862 } 1863 1864 /* Loop through all the patterns in .LIBPATTERNS, and search on each one. */ 1894 libpatterns = xstrdup (variable_expand ("$(.LIBPATTERNS)")); 1895 1896 /* Skip the '-l'. */ 1897 lib += 2; 1898 liblen = strlen (lib); 1899 1900 /* Loop through all the patterns in .LIBPATTERNS, and search on each one. 1901 To implement the linker-compatible behavior we have to search through 1902 all entries in .LIBPATTERNS and choose the "earliest" one. */ 1865 1903 p2 = libpatterns; 1866 1904 while ((p = find_next_token (&p2, &len)) != 0) … … 1872 1910 const size_t libbuf_offset = libbuf - variable_buffer; /* bird */ 1873 1911 1874 /* Expand the pattern using LIB NAMEas a replacement. */1912 /* Expand the pattern using LIB as a replacement. */ 1875 1913 { 1876 1914 char c = p[len]; … … 1881 1919 if (!p3) 1882 1920 { 1883 /* Give a warning if there is no pattern, then remove the 1884 pattern so it's ignored next time. */ 1921 /* Give a warning if there is no pattern. */ 1885 1922 error (NILF, _(".LIBPATTERNS element `%s' is not a pattern"), p); 1886 for (; len; --len, ++p) 1887 *p = ' '; 1888 *p = c; 1923 p[len] = c; 1889 1924 continue; 1890 1925 } 1891 1926 p4 = variable_buffer_output (libbuf, p, p3-p); 1892 p4 = variable_buffer_output (p4, lib name, strlen (libname));1927 p4 = variable_buffer_output (p4, lib, liblen); 1893 1928 p4 = variable_buffer_output (p4, p3+1, len - (p3-p)); 1894 1929 p[len] = c; … … 1902 1937 if (mtime_ptr != 0) 1903 1938 *mtime_ptr = mtime; 1904 return strcache_add (libbuf); 1939 file = strcache_add (libbuf); 1940 /* This by definition will have the best index, so stop now. */ 1941 break; 1905 1942 } 1906 1943 … … 1908 1945 1909 1946 { 1910 const char *file = vpath_search (libbuf, mtime_ptr); 1911 if (file) 1912 return file; 1947 unsigned int vpath_index, path_index; 1948 const char* f = vpath_search (libbuf, mtime_ptr ? &mtime : NULL, 1949 &vpath_index, &path_index); 1950 if (f) 1951 { 1952 /* If we have a better match, record it. */ 1953 if (file == 0 || 1954 vpath_index < best_vpath || 1955 (vpath_index == best_vpath && path_index < best_path)) 1956 { 1957 file = f; 1958 best_vpath = vpath_index; 1959 best_path = path_index; 1960 1961 if (mtime_ptr != 0) 1962 *mtime_ptr = mtime; 1963 } 1964 } 1913 1965 } 1914 1966 … … 1916 1968 1917 1969 if (!buflen) 1918 { 1919 for (dp = dirs; *dp != 0; ++dp) 1920 { 1921 int l = strlen (*dp); 1922 if (l > libdir_maxlen) 1923 libdir_maxlen = l; 1924 } 1925 buflen = strlen (libbuf); 1926 buf = xmalloc(libdir_maxlen + buflen + 2); 1927 } 1970 { 1971 for (dp = dirs; *dp != 0; ++dp) 1972 { 1973 int l = strlen (*dp); 1974 if (l > libdir_maxlen) 1975 libdir_maxlen = l; 1976 std_dirs++; 1977 } 1978 buflen = strlen (libbuf); 1979 buf = xmalloc(libdir_maxlen + buflen + 2); 1980 } 1928 1981 else if (buflen < strlen (libbuf)) 1929 { 1930 buflen = strlen (libbuf); 1931 buf = xrealloc (buf, libdir_maxlen + buflen + 2); 1932 } 1933 1934 for (dp = dirs; *dp != 0; ++dp) 1935 { 1936 sprintf (buf, "%s/%s", *dp, libbuf); 1937 mtime = name_mtime (buf); 1938 if (mtime != NONEXISTENT_MTIME) 1939 { 1940 if (mtime_ptr != 0) 1941 *mtime_ptr = mtime; 1942 return strcache_add (buf); 1943 } 1944 } 1945 } 1946 1947 return 0; 1982 { 1983 buflen = strlen (libbuf); 1984 buf = xrealloc (buf, libdir_maxlen + buflen + 2); 1985 } 1986 1987 { 1988 /* Use the last std_dirs index for standard directories. This 1989 was it will always be greater than the VPATH index. */ 1990 unsigned int vpath_index = ~((unsigned int)0) - std_dirs; 1991 1992 for (dp = dirs; *dp != 0; ++dp) 1993 { 1994 sprintf (buf, "%s/%s", *dp, libbuf); 1995 mtime = name_mtime (buf); 1996 if (mtime != NONEXISTENT_MTIME) 1997 { 1998 if (file == 0 || vpath_index < best_vpath) 1999 { 2000 file = strcache_add (buf); 2001 best_vpath = vpath_index; 2002 2003 if (mtime_ptr != 0) 2004 *mtime_ptr = mtime; 2005 } 2006 } 2007 2008 vpath_index++; 2009 } 2010 } 2011 2012 } 2013 2014 free (libpatterns); 2015 return file; 1948 2016 }
Note:
See TracChangeset
for help on using the changeset viewer.