10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * CDDL HEADER START
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The contents of this file are subject to the terms of the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Common Development and Distribution License (the "License").
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * You may not use this file except in compliance with the License.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * See the License for the specific language governing permissions
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * and limitations under the License.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * When distributing Covered Code, include this CDDL HEADER in each
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If applicable, add the following below this CDDL HEADER, with the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * fields enclosed by brackets "[]" replaced with your own identifying
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * information: Portions Copyright [yyyy] [name of copyright owner]
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * CDDL HEADER END
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Use is subject to license terms.
67c3092ccd4e8c261df7eded9df072ff9c4e330bAndrew Stormont * Copyright 2016 RackTop Systems.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Figure out which targets are out of date and rebuild them
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Included files
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe#include <mksh/i18n.h> /* get_char_semantics_value() */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe#include <mksh/macro.h> /* getvar(), expand_value() */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Defined macros
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe// Sleep for .1 seconds between stat()'s
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * typedefs & structs
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * File table of contents
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweextern Doname doname_check(register Name target, register Boolean do_get, register Boolean implicit, register Boolean automatic);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweextern Doname doname(register Name target, register Boolean do_get, register Boolean implicit, register Boolean automatic);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Boolean 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);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Doname run_command(register Property line, Boolean print_machine);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweextern Name vpath_translation(register Name cmd);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void read_dependency_file(register Name filename);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void check_read_state_file(void);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void do_assign(register Name line, register Name target);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void build_command_strings(Name target, register Property line);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Doname touch_command(register Property line, register Name target, Doname result);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweextern void update_target(Property line, Doname result);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Doname sccs_get(register Name target, register Property *command);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweextern void read_directory_of_file(register Name file);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void add_pattern_conditionals(register Name target);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweextern void set_locals(register Name target, register Property old_locals);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweextern void reset_locals(register Name target, register Property old_locals, register Property conditional, register int index);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweextern Boolean check_auto_dependencies(Name target, int auto_count, Name *automatics);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweextern Name normalize_name(register wchar_t *name_string, register int length);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * doname_check(target, do_get, implicit, automatic)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Will call doname() and then inspect the return value
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Indication if the build failed or not
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target The target to build
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_get Passed thru to doname()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * implicit Passed thru to doname()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * automatic Are we building a hidden dependency?
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * build_failed_seen Set if -k is on and error occurs
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * continue_after_error Indicates that -k is on
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * report_dependencies No error msg if -P is on
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowedoname_check(register Name target, register Boolean do_get, register Boolean implicit, register Boolean automatic)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe switch (doname(target, do_get, implicit, automatic)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("Target `%s' not remade because of errors"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If we can't figure out how to build an automatic
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * (hidden) dependency, we just ignore it.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * We later declare the target to be out of date just in
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * case something changed.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Also, don't complain if just reporting the dependencies
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * and not building anything.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (automatic || (report_dependencies_level > 0)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("Don't know how to make target `%s'"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("Don't know how to make target `%s'"), target->string_mb);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweenter_explicit_rule_from_dynamic_rule(Name target, Name source)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe source_line = get_prop(source->prop, line_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (line->body.line.command_template == NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe line->body.line.command_template = source_line->body.line.command_template;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (dependency = source_line->body.line.dependencies;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe enter_dependency(line, dependency->name, false);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (p = dyntarget_list; p != NULL; p = p->next) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe enter_explicit_rule_from_dynamic_rule(target, p->name);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe enter_explicit_rule_from_dynamic_rule(target, p->name);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * doname(target, do_get, implicit)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Chases all files the target depends on and builds any that
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * are out of date. If the target is out of date it is then rebuilt.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Indiates if build failed or nt
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target Target to build
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_get Run sccs get is nessecary
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * implicit doname is trying to find an implicit rule
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * assign_done True if command line assgnment has happened
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * commands_done Preserved for the case that we need local value
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * debug_level Should we trace make's actions?
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * default_rule The rule for ".DEFAULT", used as last resort
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * empty_name The Name "", used when looking for single sfx
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * keep_state Indicates that .KEEP_STATE is on
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * parallel True if building in parallel
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursion_level Used for tracing
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * report_dependencies make -P is on
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowedoname(register Name target, register Boolean do_get, register Boolean implicit, register Boolean automatic)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If this target is a member of target group and one of the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * other members of the group is running, mark this target
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * as running.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (target_group = line->body.line.target_group;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If the target is a constructed one for a "::" target,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * we need to consider that.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Make sure we have a valid time for :: targets */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If the target has been processed, we don't need to do it again,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * unless it depends on conditional macros or a delayed assignment,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * or it has been done when KEEP_STATE is on.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if((!keep_state || (!target->depends_on_conditional && !assign_done))) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* A dynamic macro subtree is being built */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This target has been started before and therefore
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * not all dependencies have to be built.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (parallel &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe keep_state &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (target->conditional_cnt > 0)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (!parallel_ok(target, false)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe add_subtree(target, recursion_level, do_get, implicit);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe target->state = build_running;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return build_running;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If KEEP_STATE is on, we have to rebuild the target if the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * building of it caused new automatic dependencies to be reported.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This is where we restart the build.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Init all local variables */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If this target has never been built before, mark all
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * of the dependencies as never built.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (dependency = line->body.line.dependencies;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Save the set of automatic depes defined for this target */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * First run thru the dependency list to see how many
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * autos there are.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (dependency = line->body.line.dependencies;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (dependency->automatic && !dependency->stale) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Create vector to hold the current autos */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (Name *) alloca((int) (auto_count * sizeof (Name)));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Copy them */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (p = automatics, dependency = line->body.line.dependencies;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (dependency->automatic && !dependency->stale) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Avoid infinite loops */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("Infinite loop: Target `%s' depends on itself"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Activate conditional macros for the target */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe old_locals = (Property) alloca(target->conditional_cnt *
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * after making the call to dynamic_dependecies unconditional we can handle
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target names that are same as file name. In this case $$@ in the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dependencies did not mean anything. WIth this change it expands it
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * as expected.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * FIRST SECTION -- GO THROUGH DEPENDENCIES AND COLLECT EXPLICIT
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * COMMANDS TO RUN
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((line = get_prop(target->prop, line_prop)) != NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If the target is a :: type, do not try to find the rule for the target,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * all actions will be taken by separate branches.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Else, we try to find an implicit rule using various methods,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * we quit as soon as one is found.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * [tolik, 12 Sep 2002] Do not try to find implicit rule for the target
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * being rechecked - the target is being rechecked means that it already
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * has explicit dependencies derived from an implicit rule found
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * in previous step.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (target->colon_splits == 0 && !rechecking_target) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Look for percent matched rule */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Look for double suffix rule */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe ((member = get_prop(target->prop, member_prop)) !=
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* ALWAYS bind $% for old style */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* ar rules */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Look for single suffix rule */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * I commented !implicit to fix bug 1247448: Suffix Rules failed when combine with Pattern Matching Rules.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This caused problem with SVR4 tilde rules (infinite recursion). So I made some changes in "implicit.cc"
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe/* /tolik, 06.21.96/
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Regression! See BugId 1255360
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If more than one percent rules are defined for the same target then
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * the behaviour of 'make' with my previous fix may be different from one
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * of the 'old make'.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The global variable second_pass (maybe it should be an argument to doname())
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * is intended to avoid this regression. It is set in doname_check().
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * First, 'make' will work as it worked before. Only when it is
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * going to say "don't know how to make target" it sets second_pass to true and
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * run 'doname' again but now trying to use Single Suffix Rules.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((result == build_dont_know) && !automatic && (!implicit || second_pass) &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe !line->body.line.target->has_regular_dependency))) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Try to sccs get */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Use .DEFAULT rule if it is defined. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Make sure we have a line prop */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe out_of_date = (Boolean) OUT_OF_DATE_SEC(true_target->stat.time,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe out_of_date = (Boolean) OUT_OF_DATE(true_target->stat.time,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("%*sBuilding %s using .DEFAULT because it is out of date\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe line->body.line.command_template = default_rule;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* We say "target up to date" if no cmd were executed for the target */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe ignore_errors = (Boolean) target->ignore_error_mode;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Run commands if any. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (command->body.line.command_template != NULL)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (Boolean) ((parallel || save_parallel) && !silent));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If all went OK set a nice timestamp */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (true_target->stat.time == file_doesnt_exist) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If no command was found for the target, and it doesn't
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * exist, and it is mentioned as a target in the makefile,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * we say it is extremely new and that it is OK.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (true_target->stat.time == file_doesnt_exist){
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Trying dynamic targets.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((line = get_prop(target->prop, line_prop)) != NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If the file exists, it is OK that we couldnt figure
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * out how to build it.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((target->stat.time != file_doesnt_exist) &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Some of the following is duplicated in the function finish_doname.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If anything is changed here, check to see if it needs to be
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * changed there.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((line = get_prop(target->prop, line_prop)) != NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Propagate the timestamp from the member file to the member*/
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe ((member = get_prop(target->prop, member_prop)) != NULL) &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (exists(member->body.member.member) > file_doesnt_exist)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Check if we found any new auto dependencies when we
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * built the target.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((result == build_ok) && check_auto_dependencies(target,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("%*sTarget `%s' acquired new dependencies from build, rechecking all dependencies\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * check_dependencies(result, line, do_get,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target, true_target, doing_subtree, out_of_date_tail,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * old_locals, implicit, command, less, rechecking_target)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * True returned if some dependencies left running
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * result Pointer to cell we update if build failed
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * line We get the dependencies from here
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_get Allow use of sccs get in recursive doname()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target The target to chase dependencies for
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * true_target The real one for :: and lib(member)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * doing_subtree True if building a conditional macro subtree
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * out_of_date_tail Used to set the $? list
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * old_locals Used for resetting the local macros
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * implicit Called when scanning for implicit rules?
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * command Place to stuff command
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * less Set to $< value
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * command_changed Set if we suspect .make.state needs rewrite
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * debug_level Should we trace actions?
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * force The Name " FORCE", compared against
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursion_level Used for tracing
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * rewrite_statefile Set if .make.state needs rewriting
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * wait_name The Name ".WAIT", compared against
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowecheck_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)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe line->body.line.dependency_time = file_doesnt_exist;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Run thru all the dependencies and call doname() recursively
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * on each of them.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (dependency = line->body.line.dependencies;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (rechecking_target || target->rechecking_target)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * We only bother with the autos when rechecking
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The special target .WAIT means finish all of
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * the prior dependencies before continuing.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if ((!parallel_ok(dependency->name, false)) &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If we can't execute the current dependency in
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * parallel, hold off the dependency processing
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * to preserve the order of the dependencies.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (true_target->is_member || dependency->name->is_member) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* should compare only secs, cause lib members does not have nsec time resolution */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (depe_time.tv_sec != dependency->name->stat.time.tv_sec) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (depe_time != dependency->name->stat.time) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If make can't figure out how to make a dependency, maybe the dependency
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * is out of date. In this case, we just declare the target out of date
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * and go on. If we really need the dependency, the make'ing of the target
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * will fail. This will only happen for automatic (hidden) dependencies.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Make sure the dependency is not saved
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * in the state file.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("Target %s rebuilt because dependency %s does not exist\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (dependency->name->depends_on_conditional) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Propagate new timestamp from "member" to
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * "lib.a(member)".
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Collect the timestamp of the youngest dependency */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Correction: do not consider nanosecs for members */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if(true_target->is_member || dependency->name->is_member) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (dependency->name->stat.time > line->body.line.dependency_time) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("%*sDate-dependencies(%s) set to %s\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Build the $? list */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe true_target->stat.time = dependency->name->stat.time;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The next statement is commented
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * out as a fix for bug #1051032.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * if dependency hasn't changed
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * then there's no need to invalidate
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * true_target. This statemnt causes
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * make to take much longer to process
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * an already-built archive. Soren
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * said it was a quick fix for some
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * problem he doesn't remember.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe true_target->stat.time = file_no_time;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (true_target->is_member || dependency->name->is_member) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe out_of_date = (Boolean) OUT_OF_DATE_SEC(true_target->stat.time,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe out_of_date = (Boolean) OUT_OF_DATE(true_target->stat.time,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (dependency->name->stat.time == file_max_time) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("%*sBuilding %s because %s does not exist\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("%*sBuilding %s because it is out of date relative to %s\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return true;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return true;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Collect the timestamp of the youngest double colon target
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dependency.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (dependency = line->body.line.dependencies;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((tmp_line = get_prop(dependency->name->prop, line_prop)) != NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if(tmp_line->body.line.dependency_time != file_max_time) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((true_target->is_member) && (dependency_changed == true)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * After scanning all the dependencies, we check the rule
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * if we found one.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (line->body.line.command_template != NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (line->body.line.command_template_redefined) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("Too many rules defined for target %s"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Check if the target is out of date */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe out_of_date = (Boolean) OUT_OF_DATE_SEC(true_target->stat.time,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe out_of_date = (Boolean) OUT_OF_DATE(true_target->stat.time,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // set $< for explicit rule
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // set $* for explicit rule
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe ((member = get_prop(target->prop, member_prop)) !=
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe target_end = targ_string.get_string() + tt->hash.length;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (suffix = suffixes; suffix != NULL; suffix = suffix->next) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (!IS_WEQUALN(suf_string.get_string(),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // set result = build_ok so that implicit rules are not used.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dynamic_dependencies(target)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Checks if any dependency contains a macro ref
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If so, it replaces the dependency with the expanded version.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Here, "$@" gets translated to target->string. That is
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * the current name on the left of the colon in the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * makefile. Thus,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * xyz: s.$@.c
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * translates into
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Also, "$(@F)" translates to the same thing without a preceeding
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * directory path (if one exists).
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Note, to enter "$@" on a dependency line in a makefile
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * "$$@" must be typed. This is because make expands
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * macros in dependency lists upon reading them.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dynamic_dependencies() also expands file wildcards.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If there are any Shell meta characters in the name,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * search the directory, and replace the dependency
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * with the set of files the pattern matches
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target Target to sanitize dependencies for
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * c_at The Name "@", used to set macro value
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * debug_level Should we trace actions?
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dot The Name ".", used to read directory
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursion_level Used for tracing
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register wchar_t *p;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((line = get_prop(target->prop, line_prop)) == NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If the target is constructed from a "::" target we consider that */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Scan all dependencies and process the ones that contain "$" chars */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (dependency = line->body.line.dependencies;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* The make macro $@ is bound to the target name once per */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* invocation of dynamic_dependencies() */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Expand this dependency string */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe expand_value(dependency->name, &string, false);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Scan the expanded string. It could contain whitespace */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* which mean it expands to several dependencies */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Remove the cell (later) if the macro was empty */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe/* azv 10/26/95 to fix bug BID_1170218 */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* We use the original dependency cell for the first */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* dependency from the expansion */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* We also have to deal with dependencies that expand to */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* lib.a(members) notation */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((*p == (int) parenleft_char)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* First skip whitespace */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((*p == (int) nul_char) ||
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (*p == (int) parenright_char)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Enter dependency from expansion */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Create new dependency cell if */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* this is not the first dependency */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* picked from the expansion */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Internalize the dependency name */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // tolik. Fix for bug 4110429: inconsistent expansion for macros that
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // include "//" and "/./"
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe //dependency->name = GETNAME(start, p - start);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe dependency->name = normalize_name(start, p - start);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("%*sDynamic dependency `%s' for target `%s'\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } while ((*p != (int) nul_char) &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (*p != (int) parenright_char));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If the expansion was of lib.a(members) format we now */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* enter the proper member cells */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Scan the new dependencies and transform them from */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* "foo" to "lib.a(foo)" */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Build "lib.a(foo)" name */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Replace "foo" with "lib.a(foo)" */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("%*sDynamic dependency `%s' for target `%s'\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe first_member->name->is_member = lib->is_member;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Add member property to member */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Then scan all the dependencies again. This time we want to expand */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* shell file wildcards */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (remove = &line->body.line.dependencies, dependency = *remove;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If dependency name string contains shell wildcards */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* replace the name with the expansion */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((start = (wchar_t *) wcschr(wcb.get_string(),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* lib(*) type pattern */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe(int) (dependency->name->hash.length-(start-wcb.get_string())-2));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe start = (wchar_t *) wcsrchr(pattern, (int) slash_char);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* The expansion is handled by the read_dir() routine*/
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Then unbind $@ */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * run_command(line)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Takes one Cmd_line and runs the commands from it.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Indicates if the command failed or not
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * line The command line to run
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * commands_done Set if we do run command
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * current_line Set to the line we run a command from
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * current_target Set to the target we run a command for
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * file_number Used to form temp file name
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * keep_state Indicates that .KEEP_STATE is on
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * make_state The Name ".make.state", used to check timestamp
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * parallel True if currently building in parallel
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * parallel_process_cnt Count of parallel processes running
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * quest Indicates that make -q is on
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * rewrite_statefile Set if we do run a command
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * sunpro_dependencies The Name "SUNPRO_DEPENDENCIES", set value
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * temp_file_directory Used to form temp fie name
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * temp_file_name Set to the name of the temp file
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * touch Indicates that make -t is on
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (!line->body.line.is_out_of_date && target->rechecking_target) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Build the command if we know the target is out of date,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * or if we want to check cmd consistency.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (line->body.line.is_out_of_date || keep_state) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Hack for handling conditional macros in DMake. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (!line->body.line.dont_rebuild_command_used) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Never mind */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If quest, then exit(1) because the target is out of date */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* We actually had to do something this time */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If this is an sccs command, we have to do some extra checking
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * and possibly complain. If the file can't be gotten because it's
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * checked out, we complain and behave as if the command was
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * executed eventhough we ignored the command.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("%s is writable so it cannot be sccs gotten"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If KEEP_STATE is on, we make sure we have the timestamp for
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * .make.state. If .make.state changes during the command run,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * we reread .make.state after the command. We also setup the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * environment variable that asks utilities to report dependencies.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe "%s/.make.dependency.%08x.%d.%d",
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe temp_file_name = getname_fn(wcs_buffer, FIND_LENGTH, false, &fnd);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe int len = 2*MAXPATHLEN + strlen(target->string_mb) + 2;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (wchar_t *from = wcs_buffer; *from != (int) nul_char; ) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe Name sprodep_name = getname_fn(string, FIND_LENGTH, false, &fnd);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * In case we are interrupted, we need to know what was going on.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * We also need to be able to save an empty command instead of the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * interrupted one in .make.state.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Empty block!!! */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (touch) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If this is not a touch run, we need to execute the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * proper command(s) for the target.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * We are building in parallel, but
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * this target must be built in serial.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If nothing else is building,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do this one, else wait.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe result = execute_parallel(line, true, target->localhost);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe line->body.line.command_used = NULL;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe line->body.line.dont_rebuild_command_used = true;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe result = execute_parallel(line, true, target->localhost);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe result = execute_parallel(line, true, target->localhost);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * execute_serial(line)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Runs thru the command line for the target and
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * executes the rules one by one.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The result of the command build
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * line The command to execute
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * continue_after_error -k flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_not_exec_rule -n flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * report_dependencies -P flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * silent Don't echo commands before executing
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * temp_file_name Temp file for auto dependencies
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * vpath_defined If true, translate path for command
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // We have to create a copy of the rules chain for processing because
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // the original one can be destroyed during .make.state file rereading.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (rule = command; rule != NULL; rule = rule->next) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (posix && (touch || quest) && !rule->always_exec) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Echo command line, maybe. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf("%s\n", rule->command_line->string_mb);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Do assignment if command line prefixed with "=" */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (report_dependencies_level == 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Execute command line. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* ds 98.04.23 bug #4085164. make should always show error messages */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* BOOLEAN(rule->silent &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe rule->ignore_error), */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("The following command caused the error:\n%s\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("Command failed for target `%s'"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Make sure a failing command is not
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * saved in .make.state.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (rule = command; rule != NULL; rule = cmd_tail) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe Property spro = get_prop(sunpro_dependencies->prop, macro_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe spro = get_prop(sunpro_dependencies->prop, env_mem_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Do not return memory allocated for SUNPRO_DEPENDENCIES
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * It will be returned in setvar_daemon() in macro.cc
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // retmem_mb(val);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * vpath_translation(cmd)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Translates one command line by
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * checking each word. If the word has an alias it is translated.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The translated command
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * cmd Command to translate
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (!vpath_defined || (cmd == NULL) || (cmd->hash.length == 0)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe while (*p != (int) nul_char) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe while (iswspace(*p) && (*p != (int) nul_char)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe while (!iswspace(*p) && (*p != (int) nul_char)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe cmd = GETNAME(new_cmd.buffer.start, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * check_state(temp_file_name)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Reads and checks the state changed by the previously executed command.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * temp_file_name The auto dependency temp file
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Then read the temp file that now might
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * contain dependency reports from utilities
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * And reread .make.state if it
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * changed (the command ran recursive makes)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * read_dependency_file(filename)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Read the temp file used for reporting dependencies to make
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * filename The name of the file with the state info
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * makefile_type The type of makefile being read
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * read_trace_level Debug flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * temp_file_number The always increasing number for unique files
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * trace_reader Debug flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * check_read_state_file()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Check if .make.state has changed
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If it has we reread it
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * make_state Make state file name
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * makefile_type Type of makefile being read
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * read_trace_level Debug flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * trace_reader Debug flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((exists(make_state) == file_doesnt_exist) ||
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Make sure we clear the old cached contents of .make.state */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe makefile = maybe_append_prop(make_state, makefile_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (makefile->body.makefile.contents != NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_assign(line, target)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Handles runtime assignments for command lines prefixed with "=".
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * line The command that contains an assignment
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target The Name of the target, used for error reports
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * assign_done Set to indicate doname needs to reprocess
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowedo_assign(register Name line, register Name target)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If any runtime assignments are done, doname() must reprocess all
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * targets in the future since the macro values used to build the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * command lines for the targets might have changed.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Skip white space. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Find "+=" or "=". */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Internalize macro name. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Skip over "+=" "=". */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("= expected in rule `%s' for target `%s'"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Skip over whitespace in front of value. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Enter new macro value. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe GETNAME(equal, wcb.get_string() + line->hash.length - equal),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * build_command_strings(target, line)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Builds the command string to used when
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * building a target. If the string is different from the previous one
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * is_out_of_date is set.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target Target to build commands for
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * line Where to stuff result
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * c_at The Name "@", used to set macro value
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * command_changed Set if command is different from old
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * debug_level Should we trace activities?
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_not_exec_rule Always echo when running -n
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * empty_name The Name "", used for empty rule
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * funny Semantics of characters
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * ignore_errors Used to init field for line
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * is_conditional Set to false befor evaling macro, checked
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * after expanding macros
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * keep_state Indicates that .KEEP_STATE is on
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * make_word_mentioned Set by macro eval, inits field for cmd
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * query The Name "?", used to set macro value
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * query_mentioned Set by macro eval, inits field for cmd
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursion_level Used for tracing
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * silent Used to init field for line
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowebuild_command_strings(Name target, register Property line)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register Cmd_line command_template = line->body.line.command_template;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register Cmd_line *insert = &line->body.line.command_used;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register Boolean ignore_all_command_dependency = true;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe percent_name = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* We have to check if a target depends on conditional macros */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Targets that do must be reprocessed by doname() each time around */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* since the macro values used when building the target might have */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* changed */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If we are building a lib.a(member) target $@ should be bound */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* to lib.a */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe ((member = get_prop(target->prop, member_prop)) != NULL)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If we are building a "::" help target $@ should be bound to */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* the real target name */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* A lib.a(member) target is never :: */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Bind the magic macros that make supplies */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe tmp_name = get_prop(tmp_name->prop, vpath_alias_prop)->
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe tmp_name = get_prop(tmp_name->prop, vpath_alias_prop)->
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe tmp_name = get_prop(tmp_name->prop, vpath_alias_prop)->
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe tmp_name = get_prop(tmp_name->prop, vpath_alias_prop)->
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* $? is seldom used and it is expensive to build */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* so we store the list form and build the string on demand */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (Chain ch = line->body.line.query; ch != NULL; ch = ch->next) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((*query_list_tail)->name->has_vpath_alias_prop) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* build $^ */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (Dependency dependency = line->body.line.dependencies;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* skip automatic dependencies */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (get_prop(dependency->name->prop, member_prop) != NULL)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((*hat_list_tail)->name->has_vpath_alias_prop) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe/* We have two command sequences we need to handle */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe/* The old one that we probably read from .make.state */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe/* and the new one we are building that will replace the old one */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe/* Even when KEEP_STATE is not on we build a new command sequence and store */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe/* it in the line prop. This command sequence is then executed by */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe/* run_command(). If KEEP_STATE is on it is also later written to */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe/* .make.state. The routine replaces the old command line by line with the */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe/* new one trying to reuse Cmd_lines */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If there is no old command_used we have to start creating */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Cmd_lines to keep the new cmd in */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Run thru the template for the new command and build the expanded */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* new command lines */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe command_template = command_template->next, insert = &used->next, used = *insert) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If there is no old command_used Cmd_line we need to */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* create one and say that cmd consistency failed */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Prepare the Cmd_line for the processing */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* The command line prefixes "@-=?" are stripped and that */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* information is saved in the Cmd_line */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Expand the macros in the command line */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe expand_value(command_template->command_line, &command_line, true);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If the macro $(MAKE) is mentioned in the command */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* "make -n" runs actually execute the command */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe used->ignore_command_dependency = query_mentioned;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Strip the prefixes */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (get_char_semantics_value(*start) & (int) command_prefix_sem);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If all command lines of the template are prefixed with "?"*/
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* the VIRTUAL_ROOT is not used for cmd consistency checks */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Internalize the expanded and stripped command line */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe new_command_line = GETNAME(start, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Compare it with the old one for command consistency */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe Name vpath_translated = vpath_translation(new_command_line);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe !used->ignore_command_dependency && (vpath_translated != used->command_line)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("%*sBuilding %s because new command \n\t%s\n%*sdifferent from old\n\t%s\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("%*sBuilding %s because new command \n\t%s\n%*sdifferent from empty old command\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Check if the old command is longer than the new for */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* command consistency */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("%*sBuilding %s because new command shorter than old\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Check if the new command is longer than the old command for */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* command consistency */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("%*sBuilding %s because new command longer than old\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Unbind the magic macros */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) SETVAR(percent_name, (Name) NULL, false);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe target->conditional_macro_list = cond_macro_list;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * touch_command(line, target, result)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If this is an "make -t" run we do this.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * We touch all targets in the target group ("foo + fie:") if any.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Indicates if the command failed or not
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * line The command line to update
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target The target we are touching
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * result Initial value for the result we return
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_not_exec_rule Indicates that -n is on
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * silent Do not echo commands
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowetouch_command(register Property line, register Name target, Doname result)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (name = target, target_group = NULL; name != NULL;) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Build a touch command that can be passed
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * to dosys(). If KEEP_STATE is on, "make -t"
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * will save the proper command, not the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * "touch" in .make.state.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_string(wcs_buffer, &touch_string, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Run the touch command, or simulate it */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * update_target(line, result)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * updates the status of a target after executing its commands.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * line The command line block to update
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * result Indicates that build is OK so can update
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_not_exec_rule Indicates that -n is on
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * touch Fake the new timestamp if we are just touching
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * [tolik] Additional fix for bug 1063790. It was fixed
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * for serial make long ago, but DMake dumps core when
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target is a symlink and sccs file is newer then target.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * In this case, finish_children() calls update_target()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * with line==NULL.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* XXX. Should we do anything here? */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((result == build_ok) && (line->body.line.command_used != NULL)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (line->body.line.command_template->command_line->string_mb[0] == 0) &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (line->body.line.command_template->next == NULL))) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If we are simulating execution we need to fake a */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* new timestamp for the target we didnt build */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If we really built the target we read the new
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * timestamp.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Fix for bug #1110906: if .c file is newer than
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * the corresponding .o file which is in an archive
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * file, make will compile the .c file but it won't
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * update the object in the .a file.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe target->stat.time = member->body.member.library->stat.time;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If the target is part of a group we need to propagate the */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* result of the run to all members */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (target_group = line->body.line.target_group;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe target_group->name->stat.time = target->stat.time;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * sccs_get(target, command)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Figures out if it possible to sccs get a file
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * and builds the command to do it if it is.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Indicates if sccs get failed or not
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target Target to get
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * command Where to deposit command to use
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * debug_level Should we trace activities?
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursion_level Used for tracing
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * sccs_get_rule The rule to used for sccs getting
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowesccs_get(register Name target, register Property *command)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register wchar_t *p;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* For sccs, we need to chase symlinks. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("Can't read symbolic link `%s': Number of symbolic links encountered during path name traversal exceeds 90."),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Read the value of the link. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("Can't read symbolic link `%s': %s"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Use the value to build the proper filename. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe ((p = (wchar_t *) wcsrchr(wcb.get_string(), slash_char)) != NULL)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_string(wcb.get_string(), &string, p - wcb.get_string() + 1);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Replace the old name with the translated name. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe target = normalize_name(string.buffer.start, string.text.p - string.buffer.start);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * read_dir() also reads the ?/SCCS dir and saves information
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * about which files have SCSC/s. files.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* We dont know by now there is no SCCS/s.* */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If there is no SCCS/s.* but the plain file exists,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * we say things are OK.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If we cant find the plain file, we give up. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Pay dirt. We now need to figure out if the plain file
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * is out of date relative to the SCCS/s.* file.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* only checking */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * We provide a command line for the target. The line is a
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * "sccs get" command from default.mk.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * And only if the plain file is out of date do we
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * request execution of the command.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("%*sSccs getting %s because s. file is younger than source file\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe line->body.line.command_template = sccs_get_rule;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if((strlen(target->prop->body.sccs.file->string_mb) ==
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (target->prop->body.sccs.file->string_mb[0] == 's') &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (target->prop->body.sccs.file->string_mb[1] == '.')) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe line->body.line.command_template = get_posix_rule;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Also make sure the rule is build with $* and $<
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * bound properly.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * read_directory_of_file(file)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Reads the directory the specified file lives in.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * file The file we need to read dir for
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dot The Name ".", used as the default dir
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe usr_include = GETNAME(usr_include_buf, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe MBSTOWCS(usr_include_sys_buf, "/usr/include/sys");
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe usr_include_sys = GETNAME(usr_include_sys_buf, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If the filename contains a "/" we have to extract the path
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Else the path defaults to ".".
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Check some popular directories first to possibly
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * save time. Compare string length first to gain speed.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if ((usr_include_sys->hash.length == length) &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (wchar_t *) NULL,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (wchar_t *) NULL);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * add_pattern_conditionals(target)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Scan the list of conditionals defined for pattern targets and add any
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * that match this target to its list of conditionals.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target The target we should add conditionals for
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * conditionals The list of pattern conditionals
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (conditional = get_prop(conditionals->prop, conditional_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe conditional = get_prop(conditional->next, conditional_prop)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe wcb1.init(conditional->body.conditional.target);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe percent = (wchar_t *) wcschr(pattern, (int) percent_char);
67c3092ccd4e8c261df7eded9df072ff9c4e330bAndrew Stormont /* Check for possible buffer under-read */
67c3092ccd4e8c261df7eded9df072ff9c4e330bAndrew Stormont if ((length = wcb.length()-wcslen(percent+1)) <= 0) {
67c3092ccd4e8c261df7eded9df072ff9c4e330bAndrew Stormont !IS_WEQUAL(wcb.get_string(length), percent+1)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe new_prop = append_prop(target, conditional_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe new_prop = append_prop(&dummy, conditional_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe new_prop->body.conditional = conditional->body.conditional;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * set_locals(target, old_locals)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Sets any conditional macros for the target.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Each target carries a possibly empty set of conditional properties.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target The target to set conditional macros for
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * old_locals Space to store old values in
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * debug_level Should we trace activity?
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * is_conditional We need to preserve this value
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursion_level Used for tracing
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweset_locals(register Name target, register Property old_locals)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register int i;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe saved_conditional_macro_used = conditional_macro_used;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Scan the list of conditional properties and apply each one */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (conditional = get_prop(target->prop, conditional_prop), i = 0;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe conditional = get_prop(conditional->next, conditional_prop),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Save the old value */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe maybe_append_prop(conditional->body.conditional.name,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("%*sActivating conditional value: "),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Set the conditional value. Macros are expanded when the */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* macro is refd as usual */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((conditional->body.conditional.name != virtual_root) ||
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (conditional->body.conditional.value != virtual_root)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) SETVAR(conditional->body.conditional.name,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (Boolean) conditional->body.conditional.append);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe cond_name->name = conditional->body.conditional.name;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Put this target on the front of the chain of conditional targets */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe conditional_macro_used = saved_conditional_macro_used;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * reset_locals(target, old_locals, conditional, index)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Removes any conditional macros for the target.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target The target we are retoring values for
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * old_locals The values to restore
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * conditional The first conditional block for the target
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * index into the old_locals vector
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * debug_level Should we trace activities?
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursion_level Used for tracing
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowereset_locals(register Name target, register Property old_locals, register Property conditional, register int index)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Scan the list of conditional properties and restore the old value */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* to each one Reverse the order relative to when we assigned macros */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe this_conditional = get_prop(conditional->next, conditional_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe reset_locals(target, old_locals, this_conditional, index+1);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Remove conditional target from chain */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("Internal error: reset target not at head of condtional_targets chain"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe get_prop(conditional->body.conditional.name->prop,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe macro_prop)->body.macro = old_locals[index].body.macro;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (conditional->body.conditional.name == virtual_root) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) SETVAR(virtual_root, getvar(virtual_root), false);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (old_locals[index].body.macro.value != NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("%*sdeactivating conditional value: %s= %s\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("%*sdeactivating conditional value: %s =\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * check_auto_dependencies(target, auto_count, automatics)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Returns true if the target now has a dependency
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * it didn't previously have (saved on automatics).
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * true if new dependency found
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target Target we check
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * auto_count Number of old automatic vars
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * automatics Saved old automatics
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * keep_state Indicates that .KEEP_STATE is on
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowecheck_auto_dependencies(Name target, int auto_count, Name *automatics)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((line = get_prop(target->prop, line_prop)) == NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Go thru new list of automatic depes */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (dependency = line->body.line.dependencies;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* And make sure that each one existed before we */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* built the target */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (dependency->automatic && !dependency->stale) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If we can find it on the */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* saved list of autos we */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* are OK */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* But if we scan over the old list */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* of auto. without finding it it is */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* new and we must check it */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return true;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe// Recursively delete each of the Chain struct on the chain.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If the target is a constructed one for a "::" target,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * we need to consider that.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (true_target->stat.time != file_doesnt_exist) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* get line property for the target */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* first check for explicit rule */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (line != NULL && line->body.line.command_template != NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* try to find pattern rule */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe result = find_percent_rule(target, NULL, false);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* try to find double suffix rule */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe Property member = get_prop(target->prop, member_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (member != NULL && member->body.member.member != NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe result = find_ar_suffix_rule(target, member->body.member.member, NULL, false);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe result = find_double_suffix_rule(target, NULL, false);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe result = find_double_suffix_rule(target, NULL, false);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* try to find suffix rule */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((result == build_dont_know) && second_pass) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe result = find_suffix_rule(target, target, empty_name, NULL, false);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* check for sccs */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* try to find dyn target */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* check whether target was mentioned in makefile */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* result */