Changeset 2596 for vendor/gnumake/current/remake.c
- Timestamp:
- Jun 20, 2012, 12:44:52 AM (13 years ago)
- Location:
- vendor/gnumake/current
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/gnumake/current
- Property svn:ignore deleted
-
vendor/gnumake/current/remake.c
r1989 r2596 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 … … 84 84 { 85 85 int t = touch_flag, q = question_flag, n = just_print_flag; 86 unsigned int j = job_slots;87 86 int status = -1; 88 87 … … 136 135 unsigned int ocommands_started; 137 136 int x; 137 138 file->dontcare = g->dontcare; 139 138 140 check_renamed (file); 139 141 if (rebuilding_makefiles) … … 209 211 any_not_updated |= !file->updated; 210 212 213 file->dontcare = 0; 214 211 215 if (stop) 212 216 break; … … 265 269 question_flag = q; 266 270 just_print_flag = n; 267 job_slots = j;268 271 } 269 272 … … 298 301 if (f->considered == considered) 299 302 { 300 DBF (DB_VERBOSE, _("Pruning file `%s'.\n")); 301 return f->command_state == cs_finished ? f->update_status : 0; 303 /* Check for the case where a target has been tried and failed but 304 the diagnostics hasn't been issued. If we need the diagnostics 305 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; 310 } 302 311 } 303 312 … … 316 325 /* If we got an error, don't bother with double_colon etc. */ 317 326 if (status != 0 && !keep_going_flag) 318 327 return status; 319 328 320 329 if (f->command_state == cs_running … … 348 357 349 358 static void 350 complain ( conststruct file *file)359 complain (struct file *file) 351 360 { 352 361 const char *msg_noparent … … 355 364 = _("%sNo rule to make target `%s', needed by `%s'%s"); 356 365 357 if (!keep_going_flag) 358 { 366 /* If this file has no_diag set then it means we tried to update it 367 before in the dontcare mode and failed. The target that actually 368 failed is not necessarily this file but could be one of its direct 369 or indirect dependencies. So traverse this file's dependencies and 370 find the one that actually caused the failure. */ 371 372 struct dep *d; 373 374 for (d = file->deps; d != 0; d = d->next) 375 { 376 if (d->file->updated && d->file->update_status > 0 && file->no_diag) 377 { 378 complain (d->file); 379 break; 380 } 381 } 382 383 if (d == 0) 384 { 385 /* 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 359 394 if (file->parent == 0) 360 fatal (NILF, msg_noparent, "", file->name, ""); 361 362 fatal (NILF, msg_parent, "", file->name, file->parent->name, ""); 363 } 364 365 if (file->parent == 0) 366 error (NILF, msg_noparent, "*** ", file->name, "."); 367 else 368 error (NILF, msg_parent, "*** ", file->name, file->parent->name, "."); 395 error (NILF, msg_noparent, "*** ", file->name, "."); 396 else 397 error (NILF, msg_parent, "*** ", file->name, file->parent->name, "."); 398 399 file->no_diag = 0; 400 } 369 401 } 370 402 … … 374 406 update_file_1 (struct file *file, unsigned int depth) 375 407 { 376 registerFILE_TIMESTAMP this_mtime;408 FILE_TIMESTAMP this_mtime; 377 409 int noexist, must_make, deps_changed; 378 410 int dep_status = 0; 379 register struct dep *d, *lastd; 411 struct file *ofile; 412 struct dep *d, *ad; 413 struct dep amake; 380 414 int running = 0; 381 415 … … 389 423 _("Recently tried and failed to update file `%s'.\n")); 390 424 391 /* If the file we tried to make is marked dontcarethen no message425 /* If the file we tried to make is marked no_diag then no message 392 426 was printed about it when it failed during the makefile rebuild. 393 427 If we're trying to build it again in the normal rebuild, print a 394 428 message now. */ 395 if (file->dontcare && !rebuilding_makefiles) 396 { 397 file->dontcare = 0; 429 if (file->no_diag && !file->dontcare) 398 430 complain (file); 399 }400 431 401 432 return file->update_status; … … 421 452 } 422 453 454 /* Determine whether the diagnostics will be issued should this update 455 fail. */ 456 file->no_diag = file->dontcare; 457 423 458 ++depth; 424 459 425 460 /* Notice recursive update of the same file. */ 426 461 start_updating (file); 462 463 /* We might change file if we find a different one via vpath; 464 remember this one to turn off updating. */ 465 ofile = file; 427 466 428 467 /* Looking at the file's modtime beforehand allows the possibility … … 468 507 } 469 508 470 /* 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) 509 /* Update all non-intermediate files we depend on, if necessary, and see 510 whether any of them is more recent than this file. We need to walk our 511 deps, AND the deps of any also_make targets to ensure everything happens 512 in the correct order. */ 513 514 amake.file = file; 515 amake.next = file->also_make; 516 ad = &amake; 517 while (ad) 518 { 519 struct dep *lastd = 0; 520 521 /* Find the deps we're scanning */ 522 d = ad->file->deps; 523 ad = ad->next; 524 525 while (d) 506 526 { 507 dontcare = d->file->dontcare; 508 d->file->dontcare = file->dontcare; 527 FILE_TIMESTAMP mtime; 528 int maybe_make; 529 int dontcare = 0; 530 531 check_renamed (d->file); 532 533 mtime = file_mtime (d->file); 534 check_renamed (d->file); 535 536 if (is_updating (d->file)) 537 { 538 error (NILF, _("Circular %s <- %s dependency dropped."), 539 file->name, d->file->name); 540 /* We cannot free D here because our the caller will still have 541 a reference to it when we were called recursively via 542 check_dep below. */ 543 if (lastd == 0) 544 file->deps = d->next; 545 else 546 lastd->next = d->next; 547 d = d->next; 548 continue; 549 } 550 551 d->file->parent = file; 552 maybe_make = must_make; 553 554 /* Inherit dontcare flag from our parent. */ 555 if (rebuilding_makefiles) 556 { 557 dontcare = d->file->dontcare; 558 d->file->dontcare = file->dontcare; 559 } 560 561 dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make); 562 563 /* Restore original dontcare flag. */ 564 if (rebuilding_makefiles) 565 d->file->dontcare = dontcare; 566 567 if (! d->ignore_mtime) 568 must_make = maybe_make; 569 570 check_renamed (d->file); 571 572 { 573 register struct file *f = d->file; 574 if (f->double_colon) 575 f = f->double_colon; 576 do 577 { 578 running |= (f->command_state == cs_running 579 || f->command_state == cs_deps_running); 580 f = f->prev; 581 } 582 while (f != 0); 583 } 584 585 if (dep_status != 0 && !keep_going_flag) 586 break; 587 588 if (!running) 589 /* The prereq is considered changed if the timestamp has changed while 590 it was built, OR it doesn't exist. */ 591 d->changed = ((file_mtime (d->file) != mtime) 592 || (mtime == NONEXISTENT_MTIME)); 593 594 lastd = d; 595 d = d->next; 509 596 } 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 do528 {529 running |= (f->command_state == cs_running530 || f->command_state == cs_deps_running);531 f = f->prev;532 }533 while (f != 0);534 }535 536 if (dep_status != 0 && !keep_going_flag)537 break;538 539 if (!running)540 /* The prereq is considered changed if the timestamp has changed while541 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 597 } 548 598 … … 600 650 601 651 finish_updating (file); 652 finish_updating (ofile); 602 653 603 654 DBF (DB_VERBOSE, _("Finished prerequisites of target file `%s'.\n")); … … 859 910 would have been updated. */ 860 911 861 if ( question_flag || just_print_flag || touch_flag)912 if ((question_flag || just_print_flag || touch_flag) && file->cmds) 862 913 { 863 914 for (i = file->cmds->ncommand_lines; i > 0; --i) … … 937 988 FILE_TIMESTAMP this_mtime, int *must_make_ptr) 938 989 { 990 struct file *ofile; 939 991 struct dep *d; 940 992 int dep_status = 0; … … 942 994 ++depth; 943 995 start_updating (file); 996 997 /* We might change file if we find a different one via vpath; 998 remember this one to turn off updating. */ 999 ofile = file; 944 1000 945 1001 if (file->phony || !file->intermediate) … … 987 1043 necessary, and see whether any of them is more recent than the 988 1044 file on whose behalf we are checking. */ 989 struct dep *l astd;1045 struct dep *ld; 990 1046 int deps_running = 0; 991 1047 992 /* Reset this target's state so that we check it fresh. It could be993 that it's already beenchecked as part of an order-only1048 /* If this target is not running, set it's state so that we check it 1049 fresh. It could be it was checked as part of an order-only 994 1050 prerequisite and so wasn't rebuilt then, but should be now. */ 995 set_command_state (file, cs_not_started); 996 997 lastd = 0; 1051 if (file->command_state != cs_running) 1052 set_command_state (file, cs_not_started); 1053 1054 ld = 0; 998 1055 d = file->deps; 999 1056 while (d != 0) … … 1005 1062 error (NILF, _("Circular %s <- %s dependency dropped."), 1006 1063 file->name, d->file->name); 1007 if (l astd == 0)1064 if (ld == 0) 1008 1065 { 1009 1066 file->deps = d->next; … … 1013 1070 else 1014 1071 { 1015 l astd->next = d->next;1072 ld->next = d->next; 1016 1073 free_dep (d); 1017 d = l astd->next;1074 d = ld->next; 1018 1075 } 1019 1076 continue; … … 1034 1091 deps_running = 1; 1035 1092 1036 l astd = d;1093 ld = d; 1037 1094 d = d->next; 1038 1095 } … … 1047 1104 1048 1105 finish_updating (file); 1106 finish_updating (ofile); 1107 1049 1108 return dep_status; 1050 1109 } … … 1230 1289 { 1231 1290 /* If name_mtime failed, search VPATH. */ 1232 const char *name = vpath_search (file->name, &mtime );1291 const char *name = vpath_search (file->name, &mtime, NULL, NULL); 1233 1292 if (name 1234 1293 /* Last resort, is it a library (-lxxx)? */ … … 1473 1532 }; 1474 1533 1475 static char *libpatterns = NULL; 1476 1477 const char *libname = lib+2; /* Name without the '-l'. */ 1534 const char *file = 0; 1535 char *libpatterns; 1478 1536 FILE_TIMESTAMP mtime; 1479 1537 … … 1482 1540 const char *p2; 1483 1541 unsigned int len; 1542 unsigned int liblen; 1543 1544 /* Information about the earliest (in the vpath sequence) match. */ 1545 unsigned int best_vpath, best_path; 1546 unsigned int std_dirs = 0; 1484 1547 1485 1548 char **dp; 1486 1549 1487 /* If we don't have libpatterns, get it. */ 1488 if (!libpatterns) 1489 { 1490 int save = warn_undefined_variables_flag; 1491 warn_undefined_variables_flag = 0; 1492 1493 libpatterns = xstrdup (variable_expand ("$(strip $(.LIBPATTERNS))")); 1494 1495 warn_undefined_variables_flag = save; 1496 } 1497 1498 /* Loop through all the patterns in .LIBPATTERNS, and search on each one. */ 1550 libpatterns = xstrdup (variable_expand ("$(.LIBPATTERNS)")); 1551 1552 /* Skip the '-l'. */ 1553 lib += 2; 1554 liblen = strlen (lib); 1555 1556 /* Loop through all the patterns in .LIBPATTERNS, and search on each one. 1557 To implement the linker-compatible behavior we have to search through 1558 all entries in .LIBPATTERNS and choose the "earliest" one. */ 1499 1559 p2 = libpatterns; 1500 1560 while ((p = find_next_token (&p2, &len)) != 0) … … 1505 1565 char *libbuf = variable_expand (""); 1506 1566 1507 /* Expand the pattern using LIB NAMEas a replacement. */1567 /* Expand the pattern using LIB as a replacement. */ 1508 1568 { 1509 1569 char c = p[len]; … … 1514 1574 if (!p3) 1515 1575 { 1516 /* Give a warning if there is no pattern, then remove the 1517 pattern so it's ignored next time. */ 1576 /* Give a warning if there is no pattern. */ 1518 1577 error (NILF, _(".LIBPATTERNS element `%s' is not a pattern"), p); 1519 for (; len; --len, ++p) 1520 *p = ' '; 1521 *p = c; 1578 p[len] = c; 1522 1579 continue; 1523 1580 } 1524 1581 p4 = variable_buffer_output (libbuf, p, p3-p); 1525 p4 = variable_buffer_output (p4, lib name, strlen (libname));1582 p4 = variable_buffer_output (p4, lib, liblen); 1526 1583 p4 = variable_buffer_output (p4, p3+1, len - (p3-p)); 1527 1584 p[len] = c; … … 1534 1591 if (mtime_ptr != 0) 1535 1592 *mtime_ptr = mtime; 1536 return strcache_add (libbuf); 1593 file = strcache_add (libbuf); 1594 /* This by definition will have the best index, so stop now. */ 1595 break; 1537 1596 } 1538 1597 … … 1540 1599 1541 1600 { 1542 const char *file = vpath_search (libbuf, mtime_ptr); 1543 if (file) 1544 return file; 1601 unsigned int vpath_index, path_index; 1602 const char* f = vpath_search (libbuf, mtime_ptr ? &mtime : NULL, 1603 &vpath_index, &path_index); 1604 if (f) 1605 { 1606 /* If we have a better match, record it. */ 1607 if (file == 0 || 1608 vpath_index < best_vpath || 1609 (vpath_index == best_vpath && path_index < best_path)) 1610 { 1611 file = f; 1612 best_vpath = vpath_index; 1613 best_path = path_index; 1614 1615 if (mtime_ptr != 0) 1616 *mtime_ptr = mtime; 1617 } 1618 } 1545 1619 } 1546 1620 … … 1548 1622 1549 1623 if (!buflen) 1550 { 1551 for (dp = dirs; *dp != 0; ++dp) 1552 { 1553 int l = strlen (*dp); 1554 if (l > libdir_maxlen) 1555 libdir_maxlen = l; 1556 } 1557 buflen = strlen (libbuf); 1558 buf = xmalloc(libdir_maxlen + buflen + 2); 1559 } 1624 { 1625 for (dp = dirs; *dp != 0; ++dp) 1626 { 1627 int l = strlen (*dp); 1628 if (l > libdir_maxlen) 1629 libdir_maxlen = l; 1630 std_dirs++; 1631 } 1632 buflen = strlen (libbuf); 1633 buf = xmalloc(libdir_maxlen + buflen + 2); 1634 } 1560 1635 else if (buflen < strlen (libbuf)) 1561 { 1562 buflen = strlen (libbuf); 1563 buf = xrealloc (buf, libdir_maxlen + buflen + 2); 1564 } 1565 1566 for (dp = dirs; *dp != 0; ++dp) 1567 { 1568 sprintf (buf, "%s/%s", *dp, libbuf); 1569 mtime = name_mtime (buf); 1570 if (mtime != NONEXISTENT_MTIME) 1571 { 1572 if (mtime_ptr != 0) 1573 *mtime_ptr = mtime; 1574 return strcache_add (buf); 1575 } 1576 } 1577 } 1578 1579 return 0; 1636 { 1637 buflen = strlen (libbuf); 1638 buf = xrealloc (buf, libdir_maxlen + buflen + 2); 1639 } 1640 1641 { 1642 /* Use the last std_dirs index for standard directories. This 1643 was it will always be greater than the VPATH index. */ 1644 unsigned int vpath_index = ~((unsigned int)0) - std_dirs; 1645 1646 for (dp = dirs; *dp != 0; ++dp) 1647 { 1648 sprintf (buf, "%s/%s", *dp, libbuf); 1649 mtime = name_mtime (buf); 1650 if (mtime != NONEXISTENT_MTIME) 1651 { 1652 if (file == 0 || vpath_index < best_vpath) 1653 { 1654 file = strcache_add (buf); 1655 best_vpath = vpath_index; 1656 1657 if (mtime_ptr != 0) 1658 *mtime_ptr = mtime; 1659 } 1660 } 1661 1662 vpath_index++; 1663 } 1664 } 1665 1666 } 1667 1668 free (libpatterns); 1669 return file; 1580 1670 }
Note:
See TracChangeset
for help on using the changeset viewer.