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.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * make program main routine plus some helper routines
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Included files
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe#include <mksh/misc.h> /* getmem(), setup_char_semantics() */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe#include <unistd.h> /* execv(), unlink(), access() */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe#include <vroot/report.h> /* report_dependency(), get_report_file() */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweextern Name normalize_name(register wchar_t *name_string, register int length);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Defined macros
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * typedefs & structs
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Boolean continue_after_error_ever_seen; /* `-k' */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Boolean dmake_group_specified; /* `-g' */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Boolean dmake_max_jobs_specified; /* `-j' */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Boolean dmake_add_mode_specified; /* `-x' */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Boolean dmake_output_mode_specified; /* `-x DMAKE_OUTPUT_MODE=' */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Boolean dmake_compat_mode_specified; /* `-x SUN_MAKE_COMPAT_MODE=' */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Boolean dmake_rcfile_specified; /* `-c' */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Dependency not_auto_depen = ¬_auto_depen_struct;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Boolean pmake_cap_r_specified; /* `-R' */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Boolean pmake_machinesfile_specified; /* `-M' */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Boolean stop_after_error_ever_seen; /* `-S' */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * File table of contents
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe extern void dmake_exit_callback(void);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe extern void dmake_message_callback(char *);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweextern Name normalize_name(register wchar_t *name_string, register int length);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweextern int main(int, char * []);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void append_makeflags_string(Name, String);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void doalarm(int);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void enter_argv_values(int , char **, ASCII_Dyn_Array *);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void make_targets(int, char **, Boolean);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic int parse_command_option(char);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void read_command_options(int, char **);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void read_files_and_state(int, char **);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic Boolean read_makefile(Name, Boolean, Boolean, Boolean);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void set_sgs_support(void);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void setup_for_projectdir(void);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void setup_makeflags_argv(void);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void report_dir_enter_leave(Boolean entering);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweextern void expand_value(Name, register String , Boolean);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * main(argc, argv)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * argc You know what this is
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * argv You know what this is
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * list_all_targets make -T seen
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * trace_status make -p seen
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * debug_level Should we trace make actions?
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * keep_state Set if .KEEP_STATE seen
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * makeflags The Name "MAKEFLAGS", used to get macro
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * remote_command_name Name of remote invocation cmd ("on")
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * running_list List of parallel running processes
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * stdout_stderr_same true if stdout and stderr are the same
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * auto_dependencies The Name "SUNPRO_DEPENDENCIES"
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * temp_file_directory Set to the dir where we create tmp file
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * trace_reader Set to reflect tracing status
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * working_on_targets Set when building user targets
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * cp is a -> to the value of the MAKEFLAGS env var,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * which has to be regular chars.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe g_argv = (char **) malloc((g_argc + 1) * sizeof(char *));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (i = 0; i < argc; i++) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Set argv_zero_string to some form of argv[0] for
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursive MAKE builds.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* argv[0] starts with a slash */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (strchr(argv[0], (int) slash_char) == NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* argv[0] contains no slashes */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * argv[0] contains at least one slash,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * but doesn't start with a slash
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe tmp_string = getmem(strlen(tmp_current_path) + 1 +
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The following flags are reset if we don't have the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * (.nse_depinfo or .make.state) files locked and only set
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * AFTER the file has been locked. This ensures that if the user
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * interrupts the program while file_lock() is waiting to lock
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * the file, the interrupt handler doesn't remove a lock
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * that doesn't belong to us.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * look for last slash char in the path to look at the binary
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * name. This is to resolve the hard link and invoke make
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * in svr4 mode.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Sun OS make standart */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if(!strcmp(argv_zero_string, "/usr/xpg4/bin/make")) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (getenv(USE_SVR4_MAKE) || getenv("USE_SVID")){
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Find the dmake_compat_mode: posix, sun, svr4, or gnu_style, .
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe char * dmake_compat_mode_var = getenv("SUN_MAKE_COMPAT_MODE");
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (0 == strcasecmp(dmake_compat_mode_var, "GNU")) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe //svr4 = false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe //posix = false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Temporary directory set up.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (tmpdir_var != NULL && *tmpdir_var == '/' && strlen(tmpdir_var) < MAXPATHLEN) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (tmpdir_var = mbs_buffer+strlen(mbs_buffer);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe *(--tmpdir_var) == '/' && tmpdir_var > mbs_buffer;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (strlen(mbs_buffer) + 32 < MAXPATHLEN) { /* 32 = strlen("/dmake.stdout.%d.%d.XXXXXX") */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* find out if stdout and stderr point to the same place */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("fstat of standard out failed: %s"), errmsg(errno));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("fstat of standard error failed: %s"), errmsg(errno));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Make the vroot package scan the path using shell semantics */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If running with .KEEP_STATE, curdir will be set with
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * the connected directory.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Set command line flags
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("MAKEFLAGS value: %s\n"), cp == NULL ? "" : cp);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Find the dmake_output_mode: TXT1, TXT2 or HTML1.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe dmake_name2 = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe prop2 = get_prop(dmake_name2->prop, macro_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* DMAKE_OUTPUT_MODE not defined, default to TXT1 mode */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (IS_EQUAL(dmake_value2->string_mb, "TXT2")) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (IS_EQUAL(dmake_value2->string_mb, "HTML1")) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("Unsupported value `%s' for DMAKE_OUTPUT_MODE after -x flag (ignored)"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Find the dmake_mode: parallel, or serial.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe char *s, *b;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe dmake_name2 = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe prop2 = get_prop(dmake_name2->prop, macro_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // If we're invoked as 'make' run serially, regardless of DMAKE_MODE
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // If we're invoked as 'make' but passed -j, run parallel
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // If we're invoked as 'dmake', without DMAKE_MODE, default parallel
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // If we're invoked as 'dmake' and DMAKE_MODE is set, honour it.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* DMAKE_MODE not defined, default based on our name */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (IS_EQUAL(dmake_value2->string_mb, "parallel")) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (IS_EQUAL(dmake_value2->string_mb, "serial")) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("Unknown dmake mode argument `%s' after -m flag"), dmake_value2->string_mb);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe// If dmake is running with -t option, set dmake_mode_type to serial.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe// This is done because doname() calls touch_command() that runs serially.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe// If we do not do that, maketool will have problems.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Check whether stdout and stderr are physically same.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This is in order to decide whether we need to redirect
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * stderr separately from stdout.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This check is performed only if __DMAKE_SEPARATE_STDERR
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * is not set. This variable may be used in order to preserve
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * the 'old' behaviour.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe char * dmake_sep_var = getenv("__DMAKE_SEPARATE_STDERR");
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (dmake_sep_var == NULL || (0 != strcasecmp(dmake_sep_var, "NO"))) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe || (stdout_stat.st_ino != stderr_stat.st_ino) )
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Enable interrupt handler for alarms
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Check if make should report
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (getenv(sunpro_dependencies->string_mb) != NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((report_file != NULL) && (report_file != (FILE*)-1)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Make sure SUNPRO_DEPENDENCIES is exported (or not) properly.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe maybe_append_prop(sunpro_dependencies, macro_prop)->
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe maybe_append_prop(sunpro_dependencies, macro_prop)->
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Set temp_file_directory to the directory the .make.state
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * file is written to.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((slash_ptr = strrchr(make_state->string_mb, (int) slash_char)) == NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe temp_file_directory = strdup(get_current_path());
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) strcpy(make_state_dir, make_state->string_mb);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* when there is only one slash and it's the first
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe ** character, make_state_dir should point to '/'.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe temp_file_directory = strdup(tmp_current_path2);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* NOTREACHED */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * cleanup_after_exit()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Called from exit(), performs cleanup actions.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * status The argument exit() was called with
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * arg Address of an argument vector to
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * cleanup_after_exit()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * command_changed Set if we think .make.state should be rewritten
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * current_line Is set we set commands_changed
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_not_exec_rule
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * True if -n flag on
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * done The Name ".DONE", rule we run
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * keep_state Set if .KEEP_STATE seen
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * parallel True if building in parallel
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * quest If -q is on we do not run .DONE
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * report_dependencies
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * True if -P flag on
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * running_list List of parallel running processes
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * temp_file_name The temp file is removed, if any
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweextern "C" void
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe printf(" Strings: %ld Kb (%ld bytes)\n", getname_bytes_count/1000, getname_bytes_count);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe printf(" Structs: %ld Kb (%ld bytes)\n", getname_struct_count/1000, getname_struct_count);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe printf(" Total bytes: %ld Kb (%ld bytes)\n", getname_struct_count/1000 + getname_bytes_count/1000, getname_struct_count + getname_bytes_count);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe printf("\n Unallocated: %ld\n", freename_names_count);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe printf(" Strings: %ld Kb (%ld bytes)\n", freename_bytes_count/1000, freename_bytes_count);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe printf(" Structs: %ld Kb (%ld bytes)\n", freename_struct_count/1000, freename_struct_count);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe printf(" Total bytes: %ld Kb (%ld bytes)\n", freename_struct_count/1000 + freename_bytes_count/1000, freename_struct_count + freename_bytes_count);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe printf("\n Total used: %ld Kb (%ld bytes)\n", (getname_struct_count/1000 + getname_bytes_count/1000) - (freename_struct_count/1000 + freename_bytes_count/1000), (getname_struct_count + getname_bytes_count) - (freename_struct_count + freename_bytes_count));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe " Env (%ld): %ld Kb (%ld bytes)\n",
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If we used the SVR4_MAKE, don't build .DONE or .FAILED */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Build the target .DONE or .FAILED if we caught an error */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe failed_name = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((exit_status != 0) && (failed_name->prop != NULL)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * [tolik] switch DMake to serial mode
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Switch DMake to serial mode
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Remove the temp file utilities report dependencies thru if it
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * is still around
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Do not save the current command in .make.state if make
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * was interrupted.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * For each parallel build process running, remove the temp files
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * and zap the command line so it won't be put in .make.state
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (rp = running_list; rp != NULL; rp = rp->next) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe line = get_prop(rp->target->prop, line_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (line != NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe line->body.line.command_used = NULL;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Remove the statefile lock file if the file has been locked */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((make_state_lockfile != NULL) && (make_state_locked)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Write .make.state */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * handle_interrupt()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This is where C-C traps are caught.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used (except DMake 1.0):
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * current_target Sometimes the current target is removed
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_not_exec_rule But not if -n is on
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * quest or -q
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * running_list List of parallel running processes
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * touch Current target is not removed if -t on
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (rp = running_list; rp != NULL; rp = rp->next) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Clean up all parallel children already finished */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Make sure the processes running under us terminate first */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Delete the current targets unless they are precious */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe ((member = get_prop(current_target->prop, member_prop)) != NULL)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe !(current_target->stat.is_precious || all_precious)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe/* BID_1030811 */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe/* azv 16 Oct 95 */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (exists(current_target) != file_doesnt_exist) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe "\n*** %s ",
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (unlink(current_target->string_mb) == 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (rp = running_list; rp != NULL; rp = rp->next) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe ((member = get_prop(rp->target->prop, member_prop)) !=
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe !(rp->target->stat.is_precious || all_precious)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe "\n*** %s ",
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (unlink(rp->target->string_mb) == 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Have we locked .make.state or .nse_depinfo? */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((make_state_lockfile != NULL) && (make_state_locked)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Re-read .make.state file (it might be changed by recursive make)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * doalarm(sig, ...)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Handle the alarm interrupt but do nothing. Side effect is to
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * cause return from wait3.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * read_command_options(argc, argv)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Scan the cmd line options and process the ones that start with "-"
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * -M argument, if any
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * argc You know what this is
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * argv You know what this is
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweread_command_options(register int argc, register char **argv)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register int i;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register int j;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register int k;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * flag to note options:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * -c, f, g, j, m, o
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe extern char *optarg;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe#define SUNPRO_CMD_OPTS "-~Bbc:Ddef:g:ij:K:kM:m:NnO:o:PpqRrSsTtuVvwx:"
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe# define SVR4_CMD_OPTS "-c:ef:g:ij:km:nO:o:pqrsTtVv"
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Added V in SVR4_CMD_OPTS also, which is going to be a hidden
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * option, just to make sure that the getopt doesn't fail when some
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * users leave their USE_SVR4_MAKE set and try to use the makefiles
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * that are designed to issue commands like $(MAKE) -V. Anyway it
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * sets the same flag but ensures that getopt doesn't fail.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe last_optind=optind; /* Save optind and current_optind values */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe last_current_optind=current_optind; /* in case we have to repeat this round. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Fixing bug 4102537:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Strange behaviour of command make using -- option.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Not all argv have been processed
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Skip non-flag argv and continue processing.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Bug 5060758: getopt() changed behavior (s10_60),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * and now we have to deal with cases when options
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * with double hyphen appear here, from -$(MAKEFLAGS)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Check if this option is allowed */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (last_optind_with_double_hyphen != current_optind) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* This is first time we are trying to fix "--"
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * problem with this option. If we come here second
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * time, we will go to fatal error.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe last_optind_with_double_hyphen = current_optind;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Eliminate first hyphen character */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Repeat the processing of this argument */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe gettext("Usage : dmake [ -f makefile ][ -c dmake_rcfile ][ -g dmake_group ]\n"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe gettext(" [ -j dmake_max_jobs ][ -m dmake_mode ][ -o dmake_odir ]...\n"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe gettext(" [ -e ][ -i ][ -k ][ -n ][ -p ][ -q ][ -r ][ -s ][ -t ][ -v ]\n"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe gettext("Usage : dmake [ -f makefile ][ -c dmake_rcfile ][ -g dmake_group ]\n"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe gettext(" [ -j dmake_max_jobs ][ -K statefile ][ -m dmake_mode ][ -x MODE_NAME=VALUE ][ -o dmake_odir ]...\n"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe gettext(" [ -d ][ -dd ][ -D ][ -DD ][ -e ][ -i ][ -k ][ -n ][ -p ][ -P ][ -u ][ -w ]\n"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe gettext(" [ -q ][ -r ][ -s ][ -S ][ -t ][ -v ][ -V ][ target... ][ macro=value... ][ \"macro +=value\"... ]\n"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("Unknown option `-%c'"), optopt);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("Missing argument after `-%c'"), optopt);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If we're done processing all of the options of
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * ONE argument string...
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If there's an argument for an option... */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* This shouldn't happen */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe default: /* > 1 of -c, f, g, j, K, M, m, O, o, x seen */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("Illegal command line. More than one option requiring\nan argument given in the same argument group"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe case '[': /* Reg expr - any of a set of chars */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe case '*': /* Reg expr - any sequence of chars */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe case '\'': /* Singe quote - turn off all magic */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe case '\\': /* Escape char - turn off magic of next char */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Convert the MAKEFLAGS string value into a vector of char *, similar
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If new MAKEFLAGS format, no need to add hyphen.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If old MAKEFLAGS format, add hyphen before flags.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* New MAKEFLAGS format */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Check if MAKEFLAGS value begins with multiple
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * hyphen characters, and remove all duplicates.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Usually it happens when the next command is
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * used: $(MAKE) -$(MAKEFLAGS)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This was a workaround for BugID 5060758, but
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * appears to have survived as a fix in make.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* There are two hyphens. Skip one */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* There are hyphens only. Skip all */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Old MAKEFLAGS format */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Find the number of arguments in MAKEFLAGS */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Skip white spaces */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Increment arg count */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Go to next white space */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Allocate memory for the new MAKEFLAGS argv */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe mf_argv = (char **) malloc((mf_argc + 1) * sizeof(char *));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Convert the MAKEFLAGS string value into a vector of char *,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * similar to argv.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Skip white spaces */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Go to next white space */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // (void) strcat(mf_argv[i], cp_orig);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe //mf_argv[i] = strdup(cp_orig);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * parse_command_option(ch)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parse make command line options.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Indicates if any -f -c or -M were seen
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * ch The character to parse
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dmake_group_specified Set for make -g
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dmake_max_jobs_specified Set for make -j
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dmake_mode_specified Set for make -m
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dmake_add_mode_specified Set for make -x
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dmake_compat_mode_specified Set for make -x SUN_MAKE_COMPAT_MODE=
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dmake_output_mode_specified Set for make -x DMAKE_OUTPUT_MODE=
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dmake_odir_specified Set for make -o
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dmake_rcfile_specified Set for make -c
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * env_wins Set for make -e
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * ignore_default_mk Set for make -r
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * trace_status Set for make -p
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * .make.state path & name set for make -K
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * continue_after_error Set for make -k
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * debug_level Set for make -d
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_not_exec_rule Set for make -n
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * filter_stderr Set for make -X
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * ignore_errors_all Set for make -i
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * no_parallel Set for make -R
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * quest Set for make -q
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * read_trace_level Set for make -D
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * report_dependencies Set for make -P
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * silent_all Set for make -s
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * touch Set for make -t
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe case 'M': /* Read alternative make.machines file */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe case 'm': /* Use alternative DMake build mode */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return 1024;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe case 'O': /* Integrate with maketool, obsolete */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe case 'o': /* Use alternative dmake output dir */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fprintf(stdout, "%s: %s\n", getprogname(), verstring);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * setup_for_projectdir()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Read the PROJECTDIR variable, if defined, and set the sccs path
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * sccs_dir_path Set to point to SCCS dir to use
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Check if we should use PROJECTDIR when reading the SCCS dir. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((pwent = getpwnam(sccs_dir_path)) == NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /*empty block : it'll go & check cwd */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) sprintf(path, "%s/source", pwent->pw_dir);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) sprintf(path, "%s/%s", cwdpath,sccs_dir_path);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("Bogus PROJECTDIR '%s'"), sccs_dir_path);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((ret = readlink("/proc/self/path/a.out", origin,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic char *
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweadd_to_env(const char *var, const char *value, const char *fallback)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * set_sgs_support()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Add the libmakestate.so.1 lib to the env var SGS_SUPPORT
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * if it's not already in there.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The SGS_SUPPORT env var and libmakestate.so.1 is used by
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * the linker ld to report .make.state info back to make.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * In the new world we always will set the 32-bit and 64-bit versions of this
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * variable explicitly so that we can take into account the correct isa and our
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * prefix. So say that the prefix was /opt/local. Then we would want to search
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * /opt/local/lib/libmakestate.so.1:libmakestate.so.1. We still want to search
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * the original location just as a safety measure.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // Try the tools path
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe asprintf(&lib32, "%s/%s/%s/%s", origin, "../../lib/",
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe asprintf(&lib64, "%s/%s/64/%s", origin, "../lib",
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // Try the tools path
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe asprintf(&lib64, "%s/%s/%s/64/%s", origin, "../../lib/",
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe newpath = add_to_env(LD_SUPPORT_ENV_VAR_32, lib32, LD_SUPPORT_MAKE_LIB);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe newpath64 = add_to_env(LD_SUPPORT_ENV_VAR_64, lib64, LD_SUPPORT_MAKE_LIB);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * read_files_and_state(argc, argv)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Read the makefiles we care about and the environment
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Also read the = style command line options
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * argc You know what this is
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * argv You know what this is
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * env_wins make -e, determines if env vars are RO
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * ignore_default_mk make -r, determines if make.rules is read
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * not_auto_depen dwight
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * default_target_to_build Set to first proper target from file
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_not_exec_rule Set to false when makfile is made
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dot The Name ".", used to read current dir
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * empty_name The Name "", use as macro value
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * keep_state Set if KEEP_STATE is in environment
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * make_state The Name ".make.state", used to read file
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * makefile_type Set to type of file being read
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * makeflags The Name "MAKEFLAGS", used to set macro value
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * not_auto dwight
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * read_trace_level Checked to se if the reader should trace
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * report_dependencies If -P is on we do not read .make.state
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * trace_reader Set if reader should trace
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * virtual_root The Name "VIRTUAL_ROOT", used to check value
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register int i;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register int j;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Remember current mode. It may be changed after reading makefile
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * and we will have to correct MAKEFLAGS variable.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe keep_state_name = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe makefile_name = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe sdotmakefile_name = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe sdotMakefile = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * initialize global dependency entry for .NOT_AUTO
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe not_auto_depen->automatic = not_auto_depen->stale = false;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Read internal definitions and rules.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe default_makefile = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe default_makefile = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If the user did not redefine the MAKE macro in the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * default makefile (make.rules), then we'd like to
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * change the macro value of MAKE to be some form
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * of argv[0] for recursive MAKE builds.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe def_make_name = GETNAME(wcs_buffer, wcslen(wcs_buffer));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe def_make_macro = get_prop(def_make_name->prop, macro_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (IS_EQUAL(def_make_macro->body.macro.value->string_mb,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe new_make_value = GETNAME(wcs_buffer, wcslen(wcs_buffer));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Read environment args. Let file args which follow override unless
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * -e option seen. If -e option is not mentioned.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * We now scan mf_argv and argv to see if we need to set
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * any of the DMake-added options/variables in MAKEFLAGS.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe enter_argv_values(mf_argc, mf_argv, &makeflags_and_macro);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe enter_argv_values(argc, argv, &makeflags_and_macro);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Set MFLAGS and MAKEFLAGS
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Before reading makefile we do not know exactly which mode
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * (posix or not) is used. So prepare two MAKEFLAGS strings
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * for both posix and solaris modes because they are different.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe INIT_STRING_FROM_STACK(makeflags_string, buffer);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe INIT_STRING_FROM_STACK(makeflags_string_posix, buffer_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_char((int) hyphen_char, &makeflags_string);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_char((int) hyphen_char, &makeflags_string_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_char((int) space_char, &makeflags_string_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_char((int) hyphen_char, &makeflags_string_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_char((int) space_char, &makeflags_string_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_char((int) hyphen_char, &makeflags_string_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* -c dmake_rcfile */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe dmake_rcfile = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_makeflags_string(dmake_rcfile, &makeflags_string);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_makeflags_string(dmake_rcfile, &makeflags_string_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* -g dmake_group */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe dmake_group = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_makeflags_string(dmake_group, &makeflags_string);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_makeflags_string(dmake_group, &makeflags_string_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* -j dmake_max_jobs */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe dmake_max_jobs = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_makeflags_string(dmake_max_jobs, &makeflags_string);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_makeflags_string(dmake_max_jobs, &makeflags_string_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* -m dmake_mode */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_makeflags_string(dmake_mode, &makeflags_string);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_makeflags_string(dmake_mode, &makeflags_string_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* -x dmake_compat_mode */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe// if (dmake_compat_mode_specified) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe// MBSTOWCS(wcs_buffer, "SUN_MAKE_COMPAT_MODE");
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe// dmake_compat_mode = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe// append_makeflags_string(dmake_compat_mode, &makeflags_string);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe// append_makeflags_string(dmake_compat_mode, &makeflags_string_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* -x dmake_output_mode */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe dmake_output_mode = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_makeflags_string(dmake_output_mode, &makeflags_string);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_makeflags_string(dmake_output_mode, &makeflags_string_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* -o dmake_odir */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_makeflags_string(dmake_odir, &makeflags_string);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_makeflags_string(dmake_odir, &makeflags_string_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* -M pmake_machinesfile */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe pmake_machinesfile = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_makeflags_string(pmake_machinesfile, &makeflags_string);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_makeflags_string(pmake_machinesfile, &makeflags_string_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_char((int) space_char, &makeflags_string);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_char((int) hyphen_char, &makeflags_string);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_char((int) space_char, &makeflags_string_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_char((int) hyphen_char, &makeflags_string_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Make sure MAKEFLAGS is exported
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (makeflags_string.buffer.start[1] != (int) nul_char) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (makeflags_string.buffer.start[1] != (int) space_char) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) SETVAR(GETNAME(wcs_buffer, FIND_LENGTH),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) SETVAR(GETNAME(wcs_buffer, FIND_LENGTH),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Add command line macro to POSIX makeflags_string
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_char(tmp_char, &makeflags_string_posix);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Now set the value of MAKEFLAGS macro in accordance
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * with current mode.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe macro = maybe_append_prop(makeflags, macro_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe makeflags_string_current = &makeflags_string_posix;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (makeflags_string_current->buffer.start[1] == (int) nul_char) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe GETNAME( makeflags_string_current->buffer.start + 1
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (makeflags_string_current->buffer.start[1] != (int) space_char) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe GETNAME( makeflags_string_current->buffer.start
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe GETNAME( makeflags_string_current->buffer.start + 2
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Read command line "-f" arguments and ignore -c, g, j, K, M, m, O and o args.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("No filename argument after -f flag"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe primary_makefile = GETNAME(wcs_buffer, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) read_makefile(primary_makefile, true, true, true);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (argv[i] &&
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If no command line "-f" args then look for "makefile", and then for
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * "Makefile" if "makefile" isn't found.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (wchar_t *) NULL,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (wchar_t *) NULL);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("Both `makefile' and `Makefile' exist"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("Both `makefile' and `Makefile' exist"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe save_m_has_sccs = makefile_name->stat.has_sccs;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe makefile_name->stat.has_sccs = save_m_has_sccs;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Now get current value of MAKEFLAGS and compare it with
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * the saved value we set before reading makefile.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If they are different then MAKEFLAGS is subsequently set by
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * makefile, just leave it there. Otherwise, if make mode
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * is changed by using .POSIX target in makefile we need
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * to correct MAKEFLAGS value.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe && (!strcmp(mf_val->string_mb, makeflags_value_saved->string_mb)))
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (makeflags_string_posix.buffer.start[1] == (int) nul_char) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe GETNAME(makeflags_string_posix.buffer.start + 1,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (makeflags_string_posix.buffer.start[1] != (int) space_char) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe GETNAME(makeflags_string_posix.buffer.start + 2,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If the user did not redefine the ARFLAGS macro in the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * default makefile (make.rules), then we'd like to
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * change the macro value of ARFLAGS to be in accordance
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * with "POSIX" requirements.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe name = GETNAME(wcs_buffer, wcslen(wcs_buffer));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((macro != NULL) && /* Maybe (macro == NULL) || ? */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe value = GETNAME(wcs_buffer, wcslen(wcs_buffer));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Make sure KEEP_STATE is in the environment if KEEP_STATE is on.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe macro = get_prop(keep_state_name->prop, macro_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Read state file
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Before we read state, let's make sure we have
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe ** right state file.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* just in case macro references are used in make_state file
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe ** name, we better expand them at this stage using expand_value.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe make_state = GETNAME(dest.buffer.start, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if(!stat(make_state->string_mb, &make_state_stat)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* copy the make_state structure to the other
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe ** and then let make_state point to the new
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe memcpy(&state_filename, make_state,sizeof(state_filename));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Just a kludge to avoid two slashes back to back */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* adjust the length to reflect the appended string */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else { /* the file doesn't exist or no permission */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (slashp = strrchr(make_state->string_mb, '/')) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("directory %s for .KEEP_STATE_FILE does not exist"),tmp_path);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("can't access dir %s"),tmp_path);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe Makefile_type makefile_type_temp = makefile_type;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Scan the argv for options and "=" type args and make them readonly.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweenter_argv_values(int argc, char *argv[], ASCII_Dyn_Array *makeflags_and_macro)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register int i;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Read argv options and "=" type args and make them readonly. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (((argv[i][0] == '-') && (argv[i][1] == '-')) ||
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if ((i < opt_separator) && (argv[i][0] == (int) hyphen_char)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("No dmake rcfile argument after -c flag"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("No dmake group argument after -g flag"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("No dmake max jobs argument after -j flag"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("No pmake machinesfile argument after -M flag"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("No dmake mode argument after -m flag"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("No makestate filename argument after -K flag"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("No dmake output dir argument after -o flag"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (strncmp(argv[i+1], "SUN_MAKE_COMPAT_MODE=", length) == 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe dmake_compat_mode_specified = dmake_add_mode_specified;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (strncmp(argv[i+1], "DMAKE_OUTPUT_MODE=", length) == 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe dmake_output_mode_specified = dmake_add_mode_specified;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("Unknown argument `%s' after -x flag (ignored)"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe default: /* Shouldn't reach here */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((length = strlen(argv[i+1])) >= MAXPATHLEN) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) mbstowcs(tmp_wcs_buffer, argv[i+1], length + 1);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if ((cp = strchr(argv[i], (int) equal_char)) != NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Combine all macro in dynamic array
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_or_replace_macro_in_dyn_array(makeflags_and_macro, argv[i]);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe name = GETNAME(wcs_buffer, wcslen(wcs_buffer));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe while (isspace(*cp) && (*cp != (int) nul_char)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) mbstowcs(tmp_wcs_buffer, cp, length + 1);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Illegal MAKEFLAGS argument */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe SETVAR(name, value, false)->body.macro.read_only = true;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Append the DMake option and value to the MAKEFLAGS string.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweappend_makeflags_string(Name name, register String makeflags_string)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (strcmp(name->string_mb, "DMAKE_GROUP") == 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (strcmp(name->string_mb, "DMAKE_MAX_JOBS") == 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (strcmp(name->string_mb, "DMAKE_MODE") == 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (strcmp(name->string_mb, "DMAKE_ODIR") == 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (strcmp(name->string_mb, "DMAKE_RCFILE") == 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (strcmp(name->string_mb, "PMAKE_MACHINESFILE") == 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (strcmp(name->string_mb, "DMAKE_OUTPUT_MODE") == 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (strcmp(name->string_mb, "SUN_MAKE_COMPAT_MODE") == 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal(gettext("Internal error: name not recognized in append_makeflags_string()"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe Property prop = maybe_append_prop(name, macro_prop);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if( prop == 0 || prop->body.macro.value == 0 ||
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe strcat(mbs_value, prop->body.macro.value->string_mb);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_string(wcs_buffer, makeflags_string, FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * read_environment(read_only)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This routine reads the process environment when make starts and enters
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * it as make macros. The environment variable SHELL is ignored.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * read_only Should we make env vars read only?
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * report_pwd Set if this make was started by other make
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((length = strlen(*environment)) >= MAXPATHLEN) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) mbstowcs(tmp_wcs_buffer, *environment, length + 1);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe value = (wchar_t *) wcschr(name, (int) equal_char);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Looks like there's a bug in the system, but sometimes
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * you can get blank lines in *environment.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (IS_WEQUALN(name, wcs_buffer2, wcslen(wcs_buffer2))) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (IS_WEQUALN(name, wcs_buffer2, wcslen(wcs_buffer2))) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * In POSIX mode we do not want MAKEFLAGS to be readonly.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If the MAKEFLAGS macro is subsequently set by the makefile,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * it replaces the MAKEFLAGS variable currently found in the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * environment.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * See Assertion 50 in section 6.2.5.3 of standard P1003.3.2/D8.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * We ignore SUNPRO_DEPENDENCIES. This environment variable is
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * set by make and read by cpp which then writes info to
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * .make.dependency.xxx. When make is invoked by another make
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * (recursive make), we don't want to read this because then
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * the child make will end up writing to the parent
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * directory's .make.state and clobbering them.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (IS_WEQUALN(name, wcs_buffer2, wcslen(wcs_buffer2))) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe maybe_append_prop(macro, macro_prop)->body.macro.exported =
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((value == NULL) || ((value + 1)[0] == (int) nul_char)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * read_makefile(makefile, complain, must_exist, report_file)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Read one makefile and check the result
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * false is the read failed
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * makefile The file to read
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * complain Passed thru to read_simple_file()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * must_exist Passed thru to read_simple_file()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * report_file Passed thru to read_simple_file()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * makefile_type Set to indicate we are reading main file
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursion_level Initialized
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweread_makefile(register Name makefile, Boolean complain, Boolean must_exist, Boolean report_file)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe b = read_simple_file(makefile, true, true, complain,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * make_targets(argc, argv, parallel_flag)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Call doname on the specified targets
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * argc You know what this is
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * argv You know what this is
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * parallel_flag True if building in parallel
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * build_failed_seen Used to generated message after failed -k
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * commands_done Used to generate message "Up to date"
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * default_target_to_build First proper target in makefile
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * init The Name ".INIT", use to run command
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * parallel Global parallel building flag
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * quest make -q, suppresses messages
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursion_level Initialized, used for tracing
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * report_dependencies make -P, regroves whole process
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowemake_targets(int argc, char **argv, Boolean parallel_flag)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * make remaining args
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((report_dependencies_level == 0) && parallel) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If building targets in parallel, start all of the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * remaining args to build in parallel.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe //default_target_to_build = GETNAME(wcs_buffer,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // FIND_LENGTH);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe default_target_to_build = normalize_name(wcs_buffer,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe top_level_target = get_wstring(default_target_to_build->string_mb);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If we can't execute the current target in
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * parallel, hold off the target processing
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * to preserve the order of the targets as they appeared
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * in command line.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (!parallel_ok(default_target_to_build, false)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (/* !commands_done && */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (exists(default_target_to_build) > file_doesnt_exist) */) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("`%s': no action was taken.\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe default_target_to_build->stat.time = file_no_time;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (exists(default_target_to_build) > file_doesnt_exist)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("`%s' is up to date.\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Now wait for all of the targets to finish running */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // setjmp(jmpbuffer);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe default_target_to_build = normalize_name(wcs_buffer, wcslen(wcs_buffer));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe top_level_target = get_wstring(default_target_to_build->string_mb);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe result = (Doname) default_target_to_build->state;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("Target `%s' not remade because of errors"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (default_target_to_build->colon_splits > 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* !commands_done && */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (exists(default_target_to_build) > file_doesnt_exist) */) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("`%s': no action was taken.\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (exists(default_target_to_build) > file_doesnt_exist)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("`%s' is up to date.\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If no file arguments have been encountered,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * make the first name encountered that doesnt start with a dot
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe top_level_target = get_wstring(default_target_to_build->string_mb);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe result = doname_parallel(default_target_to_build, true, false);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe warning(gettext("Target `%s' not remade because of errors"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe default_target_to_build->stat.time = file_no_time;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (default_target_to_build->colon_splits > 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe default_target_to_build->state = build_dont_know;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (/* !commands_done && */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (exists(default_target_to_build) > file_doesnt_exist) */) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("`%s': no action was taken.\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (exists(default_target_to_build) > file_doesnt_exist)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) printf(gettext("`%s' is up to date.\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * report_recursion(target)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If this is a recursive make and the parent make has KEEP_STATE on
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * this routine reports the dependency to the parent make
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target Target to report
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * makefiles_used List of makefiles read
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * recursive_name The Name ".RECURSIVE", printed
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * report_dependency dwight
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register FILE *report_file = get_report_file();
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((report_file == NULL) || (report_file == (FILE*)-1)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This can happen when there is no makefile and
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * only implicit rules are being used.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe report_dependency(primary_makefile->string_mb);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe/* Next function "append_or_replace_macro_in_dyn_array" must be in "misc.cc". */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweappend_or_replace_macro_in_dyn_array(ASCII_Dyn_Array *Ar, char *macro)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register char *cp0; /* work pointer in macro */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register char *cp1; /* work pointer in array */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register char *cp2; /* work pointer in array */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register char *cp3; /* work pointer in array */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (!(value = strchr(name, (int) equal_char))) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* no '=' in macro */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (cp0 <= name) goto ERROR_MACRO; /* no name */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (!(cp1 = strchr(cp1, name[0]))) goto APPEND_MACRO;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (!(cp2 = strchr(cp1, (int) equal_char))) goto APPEND_MACRO;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* another name */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* another name */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (cp3 = cp1 + (cp0-name); cp3 < cp2; cp3++) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* else: another name */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Look for the next macro name in array */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* internal error */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (!(cp3 = strchr(cp3+1, (int) doublequote_char))) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* internal error */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* check next name */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (len_array=0; len_array < Ar->size; len_array++) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe esc_value = (char*)malloc(strlen(value)*2 + 1);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (len_array + len_macro + esc_len + 5 >= Ar->size) goto ALLOC_ARRAY;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe strncat(Ar->start, esc_value, strlen(esc_value));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Macro without '=' or with invalid left/right part */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe sprintf(mlev, "MAKELEVEL=%d", make_level_val + 1);