Print this page
make: unifdef for TEAMWARE_MAKE_CMN (defined)


 272  *              target          Target to build
 273  *              do_get          Run sccs get is nessecary
 274  *              implicit        doname is trying to find an implicit rule
 275  *
 276  *      Global variables used:
 277  *              assign_done     True if command line assgnment has happened
 278  *              commands_done   Preserved for the case that we need local value
 279  *              debug_level     Should we trace make's actions?
 280  *              default_rule    The rule for ".DEFAULT", used as last resort
 281  *              empty_name      The Name "", used when looking for single sfx
 282  *              keep_state      Indicates that .KEEP_STATE is on
 283  *              parallel        True if building in parallel
 284  *              recursion_level Used for tracing
 285  *              report_dependencies make -P is on
 286  */
 287 Doname
 288 doname(register Name target, register Boolean do_get, register Boolean implicit, register Boolean automatic)
 289 {
 290         Doname                  result = build_dont_know;
 291         Chain                   out_of_date_list = NULL;
 292 #ifdef TEAMWARE_MAKE_CMN
 293         Chain                   target_group;
 294 #endif
 295         Property                old_locals = NULL;
 296         register Property       line;
 297         Property                command = NULL;
 298         register Dependency     dependency;
 299         Name                    less = NULL;
 300         Name                    true_target = target;
 301         Name                    *automatics = NULL;
 302         register int            auto_count;
 303         Boolean                 rechecking_target = false;
 304         Boolean                 saved_commands_done;
 305         Boolean                 restart = false;
 306         Boolean                 save_parallel = parallel;
 307         Boolean                 doing_subtree = false;
 308 
 309         Boolean                 recheck_conditionals = false;
 310 
 311         if (target->state == build_running) {
 312                 return build_running;
 313         }
 314         line = get_prop(target->prop, line_prop);
 315 #ifdef TEAMWARE_MAKE_CMN
 316         if (line != NULL) {
 317                 /*
 318                  * If this target is a member of target group and one of the
 319                  * other members of the group is running, mark this target
 320                  * as running.
 321                  */
 322                 for (target_group = line->body.line.target_group;
 323                      target_group != NULL;
 324                      target_group = target_group->next) {
 325                         if (is_running(target_group->name)) {
 326                                 target->state = build_running;
 327                                 add_pending(target,
 328                                             recursion_level,
 329                                             do_get,
 330                                             implicit,
 331                                             false);
 332                                 return build_running;
 333                         }
 334                 }
 335         }
 336 #endif
 337         /*
 338          * If the target is a constructed one for a "::" target,
 339          * we need to consider that.
 340          */
 341         if (target->has_target_prop) {
 342                 true_target = get_prop(target->prop,
 343                                        target_prop)->body.target.target;
 344                 if (true_target->colon_splits > 0) {
 345                         /* Make sure we have a valid time for :: targets */
 346                         Property        time;
 347 
 348                         time = get_prop(true_target->prop, time_prop);
 349                         if (time != NULL) {
 350                                 true_target->stat.time = time->body.time.time;
 351                         }
 352                 }
 353         }
 354         (void) exists(true_target);
 355         /*
 356          * If the target has been processed, we don't need to do it again,


 362                         return build_ok;
 363                 } else {
 364                         recheck_conditionals = true;
 365                 }
 366         }
 367         if (target->state == build_subtree) {
 368                 /* A dynamic macro subtree is being built */
 369                 target->state = build_dont_know;
 370                 doing_subtree = true;
 371                 if (!target->checking_subtree) {
 372                         /*
 373                          * This target has been started before and therefore
 374                          * not all dependencies have to be built.
 375                          */
 376                         restart = true;
 377                 }
 378         } else if (target->state == build_pending) {
 379                 target->state = build_dont_know;
 380                 restart = true;
 381 /*
 382 #ifdef TEAMWARE_MAKE_CMN
 383         } else if (parallel &&
 384                    keep_state &&
 385                    (target->conditional_cnt > 0)) {
 386             if (!parallel_ok(target, false)) {
 387                 add_subtree(target, recursion_level, do_get, implicit);
 388                 target->state = build_running;
 389                 return build_running;
 390             }
 391 #endif
 392  */
 393         }
 394         /*
 395          * If KEEP_STATE is on, we have to rebuild the target if the
 396          * building of it caused new automatic dependencies to be reported.
 397          * This is where we restart the build.
 398          */
 399         if (line != NULL) {
 400                 line->body.line.percent = NULL;
 401         }
 402 recheck_target:
 403         /* Init all local variables */
 404         result = build_dont_know;
 405         out_of_date_list = NULL;
 406         command = NULL;
 407         less = NULL;
 408         auto_count = 0;
 409         if (!restart && line != NULL) {
 410                 /*
 411                  * If this target has never been built before, mark all


 515  * all actions will be taken by separate branches.
 516  * Else, we try to find an implicit rule using various methods,
 517  * we quit as soon as one is found.
 518  *
 519  * [tolik, 12 Sep 2002] Do not try to find implicit rule for the target
 520  * being rechecked - the target is being rechecked means that it already
 521  * has explicit dependencies derived from an implicit rule found
 522  * in previous step.
 523  */
 524         if (target->colon_splits == 0 && !rechecking_target) {
 525                 /* Look for percent matched rule */
 526                 if ((result == build_dont_know) &&
 527                     (command == NULL)) {
 528                         switch (find_percent_rule(
 529                                         target,
 530                                         &command,
 531                                         recheck_conditionals)) {
 532                         case build_failed:
 533                                 result = build_failed;
 534                                 break;
 535 #ifdef TEAMWARE_MAKE_CMN
 536                         case build_running:
 537                                 target->state = build_running;
 538                                 add_pending(target,
 539                                             --recursion_level,
 540                                             do_get,
 541                                             implicit,
 542                                             false);
 543                                 if (target->conditional_cnt > 0) {
 544                                         reset_locals(target,
 545                                                      old_locals,
 546                                                      get_prop(target->prop,
 547                                                              conditional_prop),
 548                                                      0);
 549                                 }
 550                                 return build_running;
 551 #endif
 552                         case build_ok:
 553                                 result = build_ok;
 554                                 break;
 555                         }
 556                 }
 557                 /* Look for double suffix rule */
 558                 if (result == build_dont_know) {
 559                         Property member;
 560 
 561                         if (target->is_member &&
 562                             ((member = get_prop(target->prop, member_prop)) !=
 563                              NULL)) {
 564                                 switch (find_ar_suffix_rule(target,
 565                                                 member->body.
 566                                                 member.member,
 567                                                 &command,
 568                                                 recheck_conditionals)) {
 569                                 case build_failed:
 570                                         result = build_failed;
 571                                         break;
 572 #ifdef TEAMWARE_MAKE_CMN
 573                                 case build_running:
 574                                         target->state = build_running;
 575                                         add_pending(target,
 576                                                     --recursion_level,
 577                                                     do_get,
 578                                                     implicit,
 579                                                     false);
 580                                     if (target->conditional_cnt > 0) {
 581                                             reset_locals(target,
 582                                                          old_locals,
 583                                                          get_prop(target->prop,
 584                                                              conditional_prop),
 585                                                          0);
 586                                     }
 587                                         return build_running;
 588 #endif
 589                                 default:
 590                                         /* ALWAYS bind $% for old style */
 591                                         /* ar rules */
 592                                         if (line == NULL) {
 593                                                 line =
 594                                                   maybe_append_prop(target,
 595                                                                     line_prop);
 596                                         }
 597                                         line->body.line.percent =
 598                                           member->body.member.member;
 599                                         break;
 600                                 }
 601                         } else {
 602                                 switch (find_double_suffix_rule(target,
 603                                                 &command,
 604                                                 recheck_conditionals)) {
 605                                 case build_failed:
 606                                         result = build_failed;
 607                                         break;
 608 #ifdef TEAMWARE_MAKE_CMN
 609                                 case build_running:
 610                                         target->state = build_running;
 611                                         add_pending(target,
 612                                                     --recursion_level,
 613                                                     do_get,
 614                                                     implicit,
 615                                                     false);
 616                                         if (target->conditional_cnt > 0) {
 617                                                 reset_locals(target,
 618                                                              old_locals,
 619                                                              get_prop(target->
 620                                                                       prop,
 621                                                                       conditional_prop),
 622                                                              0);
 623                                         }
 624                                         return build_running;
 625 #endif
 626                                 }
 627                         }
 628                 }
 629                 /* Look for single suffix rule */
 630 
 631 /* /tolik/
 632  * I commented !implicit to fix bug 1247448: Suffix Rules failed when combine with Pattern Matching Rules.
 633  * This caused problem with SVR4 tilde rules (infinite recursion). So I made some changes in "implicit.cc"
 634  */
 635 /* /tolik, 06.21.96/
 636  * Regression! See BugId 1255360
 637  * If more than one percent rules are defined for the same target then
 638  * the behaviour of 'make' with my previous fix may be different from one
 639  * of the 'old make'. 
 640  * The global variable second_pass (maybe it should be an argument to doname())
 641  * is intended to avoid this regression. It is set in doname_check().
 642  * First, 'make' will work as it worked before. Only when it is
 643  * going to say "don't know how to make target" it sets second_pass to true and
 644  * run 'doname' again but now trying to use Single Suffix Rules.
 645  */
 646                 if ((result == build_dont_know) && !automatic && (!implicit || second_pass) &&
 647                     ((line == NULL) ||
 648                      ((line->body.line.target != NULL) &&
 649                       !line->body.line.target->has_regular_dependency))) {
 650                         switch (find_suffix_rule(target,
 651                                                  target,
 652                                                  empty_name,
 653                                                  &command,
 654                                                  recheck_conditionals)) {
 655                         case build_failed:
 656                                 result = build_failed;
 657                                 break;
 658 #ifdef TEAMWARE_MAKE_CMN
 659                         case build_running:
 660                                 target->state = build_running;
 661                                 add_pending(target,
 662                                             --recursion_level,
 663                                             do_get,
 664                                             implicit,
 665                                             false);
 666                                 if (target->conditional_cnt > 0) {
 667                                         reset_locals(target,
 668                                                      old_locals,
 669                                                      get_prop(target->prop,
 670                                                              conditional_prop),
 671                                                      0);
 672                                 }
 673                                 return build_running;
 674 #endif
 675                         }
 676                 }
 677                 /* Try to sccs get */
 678                 if ((command == NULL) &&
 679                     (result == build_dont_know) &&
 680                     do_get) {
 681                         result = sccs_get(target, &command);
 682                 }
 683 
 684                 /* Use .DEFAULT rule if it is defined. */
 685                 if ((command == NULL) &&
 686                     (result == build_dont_know) &&
 687                     (true_target->colons == no_colon) &&
 688                     default_rule &&
 689                     !implicit) {
 690                         /* Make sure we have a line prop */
 691                         line = maybe_append_prop(target, line_prop);
 692                         command = line;
 693                         Boolean out_of_date;
 694                         if (true_target->is_member) {


 728           if  (!silent)
 729           {
 730             silent = (Boolean) target->silent_mode;
 731           }
 732           if  (!ignore_errors)
 733           {
 734             ignore_errors = (Boolean) target->ignore_error_mode;
 735           }
 736         }
 737 
 738         int doname_dyntarget = 0;
 739 r_command:
 740         /* Run commands if any. */
 741         if ((command != NULL) &&
 742             (command->body.line.command_template != NULL)) {
 743                 if (result != build_failed) {
 744                         result = run_command(command, 
 745                                              (Boolean) ((parallel || save_parallel) && !silent));
 746                 }
 747                 switch (result) {
 748 #ifdef TEAMWARE_MAKE_CMN
 749                 case build_running:
 750                         add_running(target,
 751                                     true_target,
 752                                     command,
 753                                     --recursion_level,
 754                                     auto_count,
 755                                     automatics,
 756                                     do_get,
 757                                     implicit);
 758                         target->state = build_running;
 759                         if ((line = get_prop(target->prop,
 760                                              line_prop)) != NULL) {
 761                                 if (line->body.line.query != NULL) {
 762                                         delete_query_chain(line->body.line.query);
 763                                 }
 764                                 line->body.line.query = NULL;
 765                         }
 766                         if (target->conditional_cnt > 0) {
 767                                 reset_locals(target,
 768                                              old_locals,


 775                         add_serial(target,
 776                                    --recursion_level,
 777                                    do_get,
 778                                    implicit);
 779                         target->state = build_running;
 780                         line = get_prop(target->prop, line_prop);
 781                         if (line != NULL) {
 782                                 if (line->body.line.query != NULL) {
 783                                         delete_query_chain(line->body.line.query);
 784                                 }
 785                                 line->body.line.query = NULL;
 786                         }
 787                         if (target->conditional_cnt > 0) {
 788                                 reset_locals(target,
 789                                              old_locals,
 790                                              get_prop(target->prop,
 791                                                      conditional_prop),
 792                                              0);
 793                         }
 794                         return build_running;
 795 #endif
 796                 case build_ok:
 797                         /* If all went OK set a nice timestamp */
 798                         if (true_target->stat.time == file_doesnt_exist) {
 799                                 true_target->stat.time = file_max_time;
 800                         }
 801                         break;
 802                 }
 803         } else {
 804                 /*
 805                  * If no command was found for the target, and it doesn't
 806                  * exist, and it is mentioned as a target in the makefile,
 807                  * we say it is extremely new and that it is OK.
 808                  */
 809                 if (target->colons != no_colon) {
 810                         if (true_target->stat.time == file_doesnt_exist){
 811                                 true_target->stat.time = file_max_time;
 812                         }
 813                         result = build_ok;
 814                 }
 815                 /*


 929  *              line            We get the dependencies from here
 930  *              do_get          Allow use of sccs get in recursive doname()
 931  *              target          The target to chase dependencies for
 932  *              true_target     The real one for :: and lib(member)
 933  *              doing_subtree   True if building a conditional macro subtree
 934  *              out_of_date_tail Used to set the $? list
 935  *              old_locals      Used for resetting the local macros
 936  *              implicit        Called when scanning for implicit rules?
 937  *              command         Place to stuff command
 938  *              less            Set to $< value
 939  *
 940  *      Global variables used:
 941  *              command_changed Set if we suspect .make.state needs rewrite
 942  *              debug_level     Should we trace actions?
 943  *              force           The Name " FORCE", compared against
 944  *              recursion_level Used for tracing
 945  *              rewrite_statefile Set if .make.state needs rewriting
 946  *              wait_name       The Name ".WAIT", compared against
 947  */
 948 static Boolean
 949 #ifdef TEAMWARE_MAKE_CMN
 950 check_dependencies(Doname *result, Property line, Boolean do_get, Name target, Name true_target, Boolean doing_subtree, Chain *out_of_date_tail, Property old_locals, Boolean implicit, Property *command, Name less, Boolean rechecking_target, Boolean recheck_conditionals)
 951 #else
 952 check_dependencies(Doname *result, Property line, Boolean do_get, Name target, Name true_target, Boolean, Chain *out_of_date_tail, Property, Boolean, Property *command, Name less, Boolean rechecking_target, Boolean recheck_conditionals)
 953 #endif
 954 {
 955         Boolean                 dependencies_running;
 956         register Dependency     dependency;
 957         Doname                  dep_result;
 958         Boolean                 dependency_changed = false;
 959 
 960         line->body.line.dependency_time = file_doesnt_exist;
 961         if (line->body.line.query != NULL) {
 962                 delete_query_chain(line->body.line.query);
 963         }
 964         line->body.line.query = NULL;
 965         line->body.line.is_out_of_date = false;
 966         dependencies_running = false;
 967         /*
 968          * Run thru all the dependencies and call doname() recursively
 969          * on each of them.
 970          */
 971         for (dependency = line->body.line.dependencies;
 972              dependency != NULL;
 973              dependency = dependency->next) {


1146                                                               recursion_level,
1147                                                               "",
1148                                                               true_target->string_mb,
1149                                                               dependency->name->string_mb);
1150                                         } else {
1151                                                 (void) printf(catgets(catd, 1, 23, "%*sBuilding %s because it is out of date relative to %s\n"),
1152                                                               recursion_level,
1153                                                               "",
1154                                                               true_target->string_mb,
1155                                                               dependency->name->string_mb);
1156                                         }
1157                                 }
1158                         }
1159                         if (dependency->name == force) {
1160                                 force->stat.time =
1161                                   file_max_time;
1162                                 force->state = build_dont_know;
1163                         }
1164                 }
1165         }
1166 #ifdef TEAMWARE_MAKE_CMN
1167         if (dependencies_running) {
1168                 if (doing_subtree) {
1169                         if (target->conditional_cnt > 0) {
1170                                 reset_locals(target,
1171                                              old_locals,
1172                                              get_prop(target->prop,
1173                                                       conditional_prop),
1174                                              0);
1175                         }
1176                         return true;
1177                 } else {
1178                         target->state = build_running;
1179                         add_pending(target,
1180                                     --recursion_level,
1181                                     do_get,
1182                                     implicit,
1183                                     false);
1184                         if (target->conditional_cnt > 0) {
1185                                 reset_locals(target,
1186                                              old_locals,
1187                                              get_prop(target->prop,
1188                                                       conditional_prop),
1189                                              0);
1190                         }
1191                         return true;
1192                 }
1193         }
1194 #endif
1195         /*
1196          * Collect the timestamp of the youngest double colon target
1197          * dependency.
1198          */
1199         if (target->is_double_colon_parent) {
1200                 for (dependency = line->body.line.dependencies;
1201                      dependency != NULL;
1202                      dependency = dependency->next) {
1203                         Property        tmp_line;
1204 
1205                         if ((tmp_line = get_prop(dependency->name->prop, line_prop)) != NULL) {
1206                                 if(tmp_line->body.line.dependency_time != file_max_time) {
1207                                         target->stat.time =
1208                                           MAX(tmp_line->body.line.dependency_time,
1209                                               target->stat.time);
1210                                 }
1211                         }
1212                 }
1213         }
1214         if ((true_target->is_member) && (dependency_changed == true)) {


1598                 return build_ok;
1599         }
1600 
1601         /*
1602          * Build the command if we know the target is out of date,
1603          * or if we want to check cmd consistency.
1604          */
1605         if (line->body.line.is_out_of_date || keep_state) {
1606                 /* Hack for handling conditional macros in DMake. */
1607                 if (!line->body.line.dont_rebuild_command_used) {
1608                         build_command_strings(target, line);
1609                 }
1610         }
1611         /* Never mind */
1612         if (!line->body.line.is_out_of_date) {
1613                 return build_ok;
1614         }
1615         /* If quest, then exit(1) because the target is out of date */
1616         if (quest) {
1617                 if (posix) {
1618 #ifdef TEAMWARE_MAKE_CMN
1619                         result = execute_parallel(line, true);
1620 #else
1621                         result = execute_serial(line);
1622 #endif
1623                 }
1624                 exit_status = 1;
1625                 exit(1);
1626         }
1627         /* We actually had to do something this time */
1628         rewrite_statefile = commands_done = true;
1629         /*
1630          * If this is an sccs command, we have to do some extra checking
1631          * and possibly complain. If the file can't be gotten because it's
1632          * checked out, we complain and behave as if the command was
1633          * executed eventhough we ignored the command.
1634          */
1635         if (!touch &&
1636             line->body.line.sccs_command &&
1637             (target->stat.time != file_doesnt_exist) &&
1638             ((target->stat.mode & 0222) != 0)) {
1639                 fatal(catgets(catd, 1, 27, "%s is writable so it cannot be sccs gotten"),
1640                       target->string_mb);
1641                 target->has_complained = remember_only = true;
1642         }


1682                               false);
1683                 retmem(string);
1684         } else {
1685                 temp_file_name = NULL;
1686         }
1687 
1688         /*
1689          * In case we are interrupted, we need to know what was going on.
1690          */
1691         current_target = target;
1692         /*
1693          * We also need to be able to save an empty command instead of the
1694          * interrupted one in .make.state.
1695          */
1696         current_line = line;
1697         if (remember_only) {
1698                 /* Empty block!!! */
1699         } else if (touch) {
1700                 result = touch_command(line, target, result);
1701                 if (posix) {
1702 #ifdef TEAMWARE_MAKE_CMN
1703                         result = execute_parallel(line, true);
1704 #else
1705                         result = execute_serial(line);
1706 #endif
1707                 }
1708         } else {
1709                 /*
1710                  * If this is not a touch run, we need to execute the
1711                  * proper command(s) for the target.
1712                  */
1713 #ifdef TEAMWARE_MAKE_CMN
1714                 if (parallel) {
1715                         if (!parallel_ok(target, true)) {
1716                                 /*
1717                                  * We are building in parallel, but
1718                                  * this target must be built in serial.
1719                                  */
1720                                 /*
1721                                  * If nothing else is building,
1722                                  * do this one, else wait.
1723                                  */
1724                                 if (parallel_process_cnt == 0) {
1725 #ifdef TEAMWARE_MAKE_CMN
1726                                         result = execute_parallel(line, true, target->localhost);
1727 #else
1728                                         result = execute_serial(line);
1729 #endif
1730                                 } else {
1731                                         current_target = NULL;
1732                                         current_line = NULL;
1733 /*
1734                                         line->body.line.command_used = NULL;
1735  */
1736                                         line->body.line.dont_rebuild_command_used = true;
1737                                         return build_serial;
1738                                 }
1739                         } else {
1740                                 result = execute_parallel(line, false);
1741                                 switch (result) {
1742                                 case build_running:
1743                                         return build_running;
1744                                 case build_serial:
1745                                         if (parallel_process_cnt == 0) {
1746 #ifdef TEAMWARE_MAKE_CMN
1747                                                 result = execute_parallel(line, true, target->localhost);
1748 #else
1749                                                 result = execute_serial(line);
1750 #endif
1751                                         } else {
1752                                                 current_target = NULL;
1753                                                 current_line = NULL;
1754                                                 target->parallel = false;
1755                                                 line->body.line.command_used =
1756                                                                         NULL;
1757                                                 return build_serial;
1758                                         }
1759                                 }
1760                         }
1761                 } else {
1762 #endif
1763 #ifdef TEAMWARE_MAKE_CMN
1764                         result = execute_parallel(line, true, target->localhost);
1765 #else
1766                         result = execute_serial(line);
1767 #endif
1768 #ifdef TEAMWARE_MAKE_CMN
1769                 }
1770 #endif
1771         }
1772         temp_file_name = NULL;
1773         if (report_dependencies_level == 0){
1774                 update_target(line, result);
1775         }
1776         current_target = NULL;
1777         current_line = NULL;
1778         return result;
1779 }
1780 
1781 /*
1782  *      execute_serial(line)
1783  *
1784  *      Runs thru the command line for the target and
1785  *      executes the rules one by one.
1786  *
1787  *      Return value:
1788  *                              The result of the command build
1789  *
1790  *      Parameters:     




 272  *              target          Target to build
 273  *              do_get          Run sccs get is nessecary
 274  *              implicit        doname is trying to find an implicit rule
 275  *
 276  *      Global variables used:
 277  *              assign_done     True if command line assgnment has happened
 278  *              commands_done   Preserved for the case that we need local value
 279  *              debug_level     Should we trace make's actions?
 280  *              default_rule    The rule for ".DEFAULT", used as last resort
 281  *              empty_name      The Name "", used when looking for single sfx
 282  *              keep_state      Indicates that .KEEP_STATE is on
 283  *              parallel        True if building in parallel
 284  *              recursion_level Used for tracing
 285  *              report_dependencies make -P is on
 286  */
 287 Doname
 288 doname(register Name target, register Boolean do_get, register Boolean implicit, register Boolean automatic)
 289 {
 290         Doname                  result = build_dont_know;
 291         Chain                   out_of_date_list = NULL;

 292         Chain                   target_group;

 293         Property                old_locals = NULL;
 294         register Property       line;
 295         Property                command = NULL;
 296         register Dependency     dependency;
 297         Name                    less = NULL;
 298         Name                    true_target = target;
 299         Name                    *automatics = NULL;
 300         register int            auto_count;
 301         Boolean                 rechecking_target = false;
 302         Boolean                 saved_commands_done;
 303         Boolean                 restart = false;
 304         Boolean                 save_parallel = parallel;
 305         Boolean                 doing_subtree = false;
 306 
 307         Boolean                 recheck_conditionals = false;
 308 
 309         if (target->state == build_running) {
 310                 return build_running;
 311         }
 312         line = get_prop(target->prop, line_prop);

 313         if (line != NULL) {
 314                 /*
 315                  * If this target is a member of target group and one of the
 316                  * other members of the group is running, mark this target
 317                  * as running.
 318                  */
 319                 for (target_group = line->body.line.target_group;
 320                      target_group != NULL;
 321                      target_group = target_group->next) {
 322                         if (is_running(target_group->name)) {
 323                                 target->state = build_running;
 324                                 add_pending(target,
 325                                             recursion_level,
 326                                             do_get,
 327                                             implicit,
 328                                             false);
 329                                 return build_running;
 330                         }
 331                 }
 332         }

 333         /*
 334          * If the target is a constructed one for a "::" target,
 335          * we need to consider that.
 336          */
 337         if (target->has_target_prop) {
 338                 true_target = get_prop(target->prop,
 339                                        target_prop)->body.target.target;
 340                 if (true_target->colon_splits > 0) {
 341                         /* Make sure we have a valid time for :: targets */
 342                         Property        time;
 343 
 344                         time = get_prop(true_target->prop, time_prop);
 345                         if (time != NULL) {
 346                                 true_target->stat.time = time->body.time.time;
 347                         }
 348                 }
 349         }
 350         (void) exists(true_target);
 351         /*
 352          * If the target has been processed, we don't need to do it again,


 358                         return build_ok;
 359                 } else {
 360                         recheck_conditionals = true;
 361                 }
 362         }
 363         if (target->state == build_subtree) {
 364                 /* A dynamic macro subtree is being built */
 365                 target->state = build_dont_know;
 366                 doing_subtree = true;
 367                 if (!target->checking_subtree) {
 368                         /*
 369                          * This target has been started before and therefore
 370                          * not all dependencies have to be built.
 371                          */
 372                         restart = true;
 373                 }
 374         } else if (target->state == build_pending) {
 375                 target->state = build_dont_know;
 376                 restart = true;
 377 /*

 378         } else if (parallel &&
 379                    keep_state &&
 380                    (target->conditional_cnt > 0)) {
 381             if (!parallel_ok(target, false)) {
 382                 add_subtree(target, recursion_level, do_get, implicit);
 383                 target->state = build_running;
 384                 return build_running;
 385             }

 386  */
 387         }
 388         /*
 389          * If KEEP_STATE is on, we have to rebuild the target if the
 390          * building of it caused new automatic dependencies to be reported.
 391          * This is where we restart the build.
 392          */
 393         if (line != NULL) {
 394                 line->body.line.percent = NULL;
 395         }
 396 recheck_target:
 397         /* Init all local variables */
 398         result = build_dont_know;
 399         out_of_date_list = NULL;
 400         command = NULL;
 401         less = NULL;
 402         auto_count = 0;
 403         if (!restart && line != NULL) {
 404                 /*
 405                  * If this target has never been built before, mark all


 509  * all actions will be taken by separate branches.
 510  * Else, we try to find an implicit rule using various methods,
 511  * we quit as soon as one is found.
 512  *
 513  * [tolik, 12 Sep 2002] Do not try to find implicit rule for the target
 514  * being rechecked - the target is being rechecked means that it already
 515  * has explicit dependencies derived from an implicit rule found
 516  * in previous step.
 517  */
 518         if (target->colon_splits == 0 && !rechecking_target) {
 519                 /* Look for percent matched rule */
 520                 if ((result == build_dont_know) &&
 521                     (command == NULL)) {
 522                         switch (find_percent_rule(
 523                                         target,
 524                                         &command,
 525                                         recheck_conditionals)) {
 526                         case build_failed:
 527                                 result = build_failed;
 528                                 break;

 529                         case build_running:
 530                                 target->state = build_running;
 531                                 add_pending(target,
 532                                             --recursion_level,
 533                                             do_get,
 534                                             implicit,
 535                                             false);
 536                                 if (target->conditional_cnt > 0) {
 537                                         reset_locals(target,
 538                                                      old_locals,
 539                                                      get_prop(target->prop,
 540                                                              conditional_prop),
 541                                                      0);
 542                                 }
 543                                 return build_running;

 544                         case build_ok:
 545                                 result = build_ok;
 546                                 break;
 547                         }
 548                 }
 549                 /* Look for double suffix rule */
 550                 if (result == build_dont_know) {
 551                         Property member;
 552 
 553                         if (target->is_member &&
 554                             ((member = get_prop(target->prop, member_prop)) !=
 555                              NULL)) {
 556                                 switch (find_ar_suffix_rule(target,
 557                                                 member->body.
 558                                                 member.member,
 559                                                 &command,
 560                                                 recheck_conditionals)) {
 561                                 case build_failed:
 562                                         result = build_failed;
 563                                         break;

 564                                 case build_running:
 565                                         target->state = build_running;
 566                                         add_pending(target,
 567                                                     --recursion_level,
 568                                                     do_get,
 569                                                     implicit,
 570                                                     false);
 571                                     if (target->conditional_cnt > 0) {
 572                                             reset_locals(target,
 573                                                          old_locals,
 574                                                          get_prop(target->prop,
 575                                                              conditional_prop),
 576                                                          0);
 577                                     }
 578                                         return build_running;

 579                                 default:
 580                                         /* ALWAYS bind $% for old style */
 581                                         /* ar rules */
 582                                         if (line == NULL) {
 583                                                 line =
 584                                                   maybe_append_prop(target,
 585                                                                     line_prop);
 586                                         }
 587                                         line->body.line.percent =
 588                                           member->body.member.member;
 589                                         break;
 590                                 }
 591                         } else {
 592                                 switch (find_double_suffix_rule(target,
 593                                                 &command,
 594                                                 recheck_conditionals)) {
 595                                 case build_failed:
 596                                         result = build_failed;
 597                                         break;

 598                                 case build_running:
 599                                         target->state = build_running;
 600                                         add_pending(target,
 601                                                     --recursion_level,
 602                                                     do_get,
 603                                                     implicit,
 604                                                     false);
 605                                         if (target->conditional_cnt > 0) {
 606                                                 reset_locals(target,
 607                                                              old_locals,
 608                                                              get_prop(target->
 609                                                                       prop,
 610                                                                       conditional_prop),
 611                                                              0);
 612                                         }
 613                                         return build_running;

 614                                 }
 615                         }
 616                 }
 617                 /* Look for single suffix rule */
 618 
 619 /* /tolik/
 620  * I commented !implicit to fix bug 1247448: Suffix Rules failed when combine with Pattern Matching Rules.
 621  * This caused problem with SVR4 tilde rules (infinite recursion). So I made some changes in "implicit.cc"
 622  */
 623 /* /tolik, 06.21.96/
 624  * Regression! See BugId 1255360
 625  * If more than one percent rules are defined for the same target then
 626  * the behaviour of 'make' with my previous fix may be different from one
 627  * of the 'old make'. 
 628  * The global variable second_pass (maybe it should be an argument to doname())
 629  * is intended to avoid this regression. It is set in doname_check().
 630  * First, 'make' will work as it worked before. Only when it is
 631  * going to say "don't know how to make target" it sets second_pass to true and
 632  * run 'doname' again but now trying to use Single Suffix Rules.
 633  */
 634                 if ((result == build_dont_know) && !automatic && (!implicit || second_pass) &&
 635                     ((line == NULL) ||
 636                      ((line->body.line.target != NULL) &&
 637                       !line->body.line.target->has_regular_dependency))) {
 638                         switch (find_suffix_rule(target,
 639                                                  target,
 640                                                  empty_name,
 641                                                  &command,
 642                                                  recheck_conditionals)) {
 643                         case build_failed:
 644                                 result = build_failed;
 645                                 break;

 646                         case build_running:
 647                                 target->state = build_running;
 648                                 add_pending(target,
 649                                             --recursion_level,
 650                                             do_get,
 651                                             implicit,
 652                                             false);
 653                                 if (target->conditional_cnt > 0) {
 654                                         reset_locals(target,
 655                                                      old_locals,
 656                                                      get_prop(target->prop,
 657                                                              conditional_prop),
 658                                                      0);
 659                                 }
 660                                 return build_running;

 661                         }
 662                 }
 663                 /* Try to sccs get */
 664                 if ((command == NULL) &&
 665                     (result == build_dont_know) &&
 666                     do_get) {
 667                         result = sccs_get(target, &command);
 668                 }
 669 
 670                 /* Use .DEFAULT rule if it is defined. */
 671                 if ((command == NULL) &&
 672                     (result == build_dont_know) &&
 673                     (true_target->colons == no_colon) &&
 674                     default_rule &&
 675                     !implicit) {
 676                         /* Make sure we have a line prop */
 677                         line = maybe_append_prop(target, line_prop);
 678                         command = line;
 679                         Boolean out_of_date;
 680                         if (true_target->is_member) {


 714           if  (!silent)
 715           {
 716             silent = (Boolean) target->silent_mode;
 717           }
 718           if  (!ignore_errors)
 719           {
 720             ignore_errors = (Boolean) target->ignore_error_mode;
 721           }
 722         }
 723 
 724         int doname_dyntarget = 0;
 725 r_command:
 726         /* Run commands if any. */
 727         if ((command != NULL) &&
 728             (command->body.line.command_template != NULL)) {
 729                 if (result != build_failed) {
 730                         result = run_command(command, 
 731                                              (Boolean) ((parallel || save_parallel) && !silent));
 732                 }
 733                 switch (result) {

 734                 case build_running:
 735                         add_running(target,
 736                                     true_target,
 737                                     command,
 738                                     --recursion_level,
 739                                     auto_count,
 740                                     automatics,
 741                                     do_get,
 742                                     implicit);
 743                         target->state = build_running;
 744                         if ((line = get_prop(target->prop,
 745                                              line_prop)) != NULL) {
 746                                 if (line->body.line.query != NULL) {
 747                                         delete_query_chain(line->body.line.query);
 748                                 }
 749                                 line->body.line.query = NULL;
 750                         }
 751                         if (target->conditional_cnt > 0) {
 752                                 reset_locals(target,
 753                                              old_locals,


 760                         add_serial(target,
 761                                    --recursion_level,
 762                                    do_get,
 763                                    implicit);
 764                         target->state = build_running;
 765                         line = get_prop(target->prop, line_prop);
 766                         if (line != NULL) {
 767                                 if (line->body.line.query != NULL) {
 768                                         delete_query_chain(line->body.line.query);
 769                                 }
 770                                 line->body.line.query = NULL;
 771                         }
 772                         if (target->conditional_cnt > 0) {
 773                                 reset_locals(target,
 774                                              old_locals,
 775                                              get_prop(target->prop,
 776                                                      conditional_prop),
 777                                              0);
 778                         }
 779                         return build_running;

 780                 case build_ok:
 781                         /* If all went OK set a nice timestamp */
 782                         if (true_target->stat.time == file_doesnt_exist) {
 783                                 true_target->stat.time = file_max_time;
 784                         }
 785                         break;
 786                 }
 787         } else {
 788                 /*
 789                  * If no command was found for the target, and it doesn't
 790                  * exist, and it is mentioned as a target in the makefile,
 791                  * we say it is extremely new and that it is OK.
 792                  */
 793                 if (target->colons != no_colon) {
 794                         if (true_target->stat.time == file_doesnt_exist){
 795                                 true_target->stat.time = file_max_time;
 796                         }
 797                         result = build_ok;
 798                 }
 799                 /*


 913  *              line            We get the dependencies from here
 914  *              do_get          Allow use of sccs get in recursive doname()
 915  *              target          The target to chase dependencies for
 916  *              true_target     The real one for :: and lib(member)
 917  *              doing_subtree   True if building a conditional macro subtree
 918  *              out_of_date_tail Used to set the $? list
 919  *              old_locals      Used for resetting the local macros
 920  *              implicit        Called when scanning for implicit rules?
 921  *              command         Place to stuff command
 922  *              less            Set to $< value
 923  *
 924  *      Global variables used:
 925  *              command_changed Set if we suspect .make.state needs rewrite
 926  *              debug_level     Should we trace actions?
 927  *              force           The Name " FORCE", compared against
 928  *              recursion_level Used for tracing
 929  *              rewrite_statefile Set if .make.state needs rewriting
 930  *              wait_name       The Name ".WAIT", compared against
 931  */
 932 static Boolean

 933 check_dependencies(Doname *result, Property line, Boolean do_get, Name target, Name true_target, Boolean doing_subtree, Chain *out_of_date_tail, Property old_locals, Boolean implicit, Property *command, Name less, Boolean rechecking_target, Boolean recheck_conditionals)



 934 {
 935         Boolean                 dependencies_running;
 936         register Dependency     dependency;
 937         Doname                  dep_result;
 938         Boolean                 dependency_changed = false;
 939 
 940         line->body.line.dependency_time = file_doesnt_exist;
 941         if (line->body.line.query != NULL) {
 942                 delete_query_chain(line->body.line.query);
 943         }
 944         line->body.line.query = NULL;
 945         line->body.line.is_out_of_date = false;
 946         dependencies_running = false;
 947         /*
 948          * Run thru all the dependencies and call doname() recursively
 949          * on each of them.
 950          */
 951         for (dependency = line->body.line.dependencies;
 952              dependency != NULL;
 953              dependency = dependency->next) {


1126                                                               recursion_level,
1127                                                               "",
1128                                                               true_target->string_mb,
1129                                                               dependency->name->string_mb);
1130                                         } else {
1131                                                 (void) printf(catgets(catd, 1, 23, "%*sBuilding %s because it is out of date relative to %s\n"),
1132                                                               recursion_level,
1133                                                               "",
1134                                                               true_target->string_mb,
1135                                                               dependency->name->string_mb);
1136                                         }
1137                                 }
1138                         }
1139                         if (dependency->name == force) {
1140                                 force->stat.time =
1141                                   file_max_time;
1142                                 force->state = build_dont_know;
1143                         }
1144                 }
1145         }

1146         if (dependencies_running) {
1147                 if (doing_subtree) {
1148                         if (target->conditional_cnt > 0) {
1149                                 reset_locals(target,
1150                                              old_locals,
1151                                              get_prop(target->prop,
1152                                                       conditional_prop),
1153                                              0);
1154                         }
1155                         return true;
1156                 } else {
1157                         target->state = build_running;
1158                         add_pending(target,
1159                                     --recursion_level,
1160                                     do_get,
1161                                     implicit,
1162                                     false);
1163                         if (target->conditional_cnt > 0) {
1164                                 reset_locals(target,
1165                                              old_locals,
1166                                              get_prop(target->prop,
1167                                                       conditional_prop),
1168                                              0);
1169                         }
1170                         return true;
1171                 }
1172         }

1173         /*
1174          * Collect the timestamp of the youngest double colon target
1175          * dependency.
1176          */
1177         if (target->is_double_colon_parent) {
1178                 for (dependency = line->body.line.dependencies;
1179                      dependency != NULL;
1180                      dependency = dependency->next) {
1181                         Property        tmp_line;
1182 
1183                         if ((tmp_line = get_prop(dependency->name->prop, line_prop)) != NULL) {
1184                                 if(tmp_line->body.line.dependency_time != file_max_time) {
1185                                         target->stat.time =
1186                                           MAX(tmp_line->body.line.dependency_time,
1187                                               target->stat.time);
1188                                 }
1189                         }
1190                 }
1191         }
1192         if ((true_target->is_member) && (dependency_changed == true)) {


1576                 return build_ok;
1577         }
1578 
1579         /*
1580          * Build the command if we know the target is out of date,
1581          * or if we want to check cmd consistency.
1582          */
1583         if (line->body.line.is_out_of_date || keep_state) {
1584                 /* Hack for handling conditional macros in DMake. */
1585                 if (!line->body.line.dont_rebuild_command_used) {
1586                         build_command_strings(target, line);
1587                 }
1588         }
1589         /* Never mind */
1590         if (!line->body.line.is_out_of_date) {
1591                 return build_ok;
1592         }
1593         /* If quest, then exit(1) because the target is out of date */
1594         if (quest) {
1595                 if (posix) {

1596                         result = execute_parallel(line, true);



1597                 }
1598                 exit_status = 1;
1599                 exit(1);
1600         }
1601         /* We actually had to do something this time */
1602         rewrite_statefile = commands_done = true;
1603         /*
1604          * If this is an sccs command, we have to do some extra checking
1605          * and possibly complain. If the file can't be gotten because it's
1606          * checked out, we complain and behave as if the command was
1607          * executed eventhough we ignored the command.
1608          */
1609         if (!touch &&
1610             line->body.line.sccs_command &&
1611             (target->stat.time != file_doesnt_exist) &&
1612             ((target->stat.mode & 0222) != 0)) {
1613                 fatal(catgets(catd, 1, 27, "%s is writable so it cannot be sccs gotten"),
1614                       target->string_mb);
1615                 target->has_complained = remember_only = true;
1616         }


1656                               false);
1657                 retmem(string);
1658         } else {
1659                 temp_file_name = NULL;
1660         }
1661 
1662         /*
1663          * In case we are interrupted, we need to know what was going on.
1664          */
1665         current_target = target;
1666         /*
1667          * We also need to be able to save an empty command instead of the
1668          * interrupted one in .make.state.
1669          */
1670         current_line = line;
1671         if (remember_only) {
1672                 /* Empty block!!! */
1673         } else if (touch) {
1674                 result = touch_command(line, target, result);
1675                 if (posix) {

1676                         result = execute_parallel(line, true);



1677                 }
1678         } else {
1679                 /*
1680                  * If this is not a touch run, we need to execute the
1681                  * proper command(s) for the target.
1682                  */

1683                 if (parallel) {
1684                         if (!parallel_ok(target, true)) {
1685                                 /*
1686                                  * We are building in parallel, but
1687                                  * this target must be built in serial.
1688                                  */
1689                                 /*
1690                                  * If nothing else is building,
1691                                  * do this one, else wait.
1692                                  */
1693                                 if (parallel_process_cnt == 0) {

1694                                         result = execute_parallel(line, true, target->localhost);



1695                                 } else {
1696                                         current_target = NULL;
1697                                         current_line = NULL;
1698 /*
1699                                         line->body.line.command_used = NULL;
1700  */
1701                                         line->body.line.dont_rebuild_command_used = true;
1702                                         return build_serial;
1703                                 }
1704                         } else {
1705                                 result = execute_parallel(line, false);
1706                                 switch (result) {
1707                                 case build_running:
1708                                         return build_running;
1709                                 case build_serial:
1710                                         if (parallel_process_cnt == 0) {

1711                                                 result = execute_parallel(line, true, target->localhost);



1712                                         } else {
1713                                                 current_target = NULL;
1714                                                 current_line = NULL;
1715                                                 target->parallel = false;
1716                                                 line->body.line.command_used =
1717                                                                         NULL;
1718                                                 return build_serial;
1719                                         }
1720                                 }
1721                         }
1722                 } else {


1723                         result = execute_parallel(line, true, target->localhost);




1724                 }

1725         }
1726         temp_file_name = NULL;
1727         if (report_dependencies_level == 0){
1728                 update_target(line, result);
1729         }
1730         current_target = NULL;
1731         current_line = NULL;
1732         return result;
1733 }
1734 
1735 /*
1736  *      execute_serial(line)
1737  *
1738  *      Runs thru the command line for the target and
1739  *      executes the rules one by one.
1740  *
1741  *      Return value:
1742  *                              The result of the command build
1743  *
1744  *      Parameters: