/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* state.c
*
* This file contains the routines that write the .make.state file
*/
/*
* Included files
*/
#include <setjmp.h> /* setjmp() */
#include <unistd.h> /* getpid() */
#include <errno.h> /* errno */
#include <locale.h> /* MB_CUR_MAX */
/*
* Defined macros
*/
}
/*
* typedefs & structs
*/
/*
* Static variables
*/
/*
* File table of contents
*/
{
int pos = 0;
wchar_t wc;
int pp = 0;
if(n < 0) { // error - this shouldn't happen
}
if(wc == dollar_char) {
} else {
for(int j=0;j<n;j++) {
}
}
pos += n;
}
return buff;
} else {
}
}
static void print_auto_depes(register Dependency dependency, register FILE *fd, register Boolean built_this_run, register int *line_length, register char *target_name, jmp_buf long_jump);
/*
* write_state_file(report_recursive, exiting)
*
* Write a new version of .make.state
*
* Parameters:
* report_recursive Should only be done at end of run
* exiting true if called from the exit handler
*
* Global variables used:
* built_last_make_run The Name ".BUILT_LAST_MAKE_RUN", written
* command_changed If no command changed we do not need to write
* current_make_version The Name "<current version>", written
* do_not_exec_rule If -n is on we do not write statefile
* hashtab The hashtable that contains all names
* keep_state If .KEEP_STATE is no on we do not write file
* make_state The Name ".make.state", used for opening file
* make_version The Name ".MAKE_VERSION", written
* recursive_name The Name ".RECURSIVE", written
* rewrite_statefile Indicates that something changed
*/
void
{
int lock_err;
register int attempts = 0;
register int m;
char *target_name;
int line_length;
if (!rewrite_statefile ||
!command_changed ||
!keep_state ||
(report_dependencies_level > 0)) {
return;
}
/* Lock the file for writing. */
(void) sprintf(make_state_lockfile,
"%s.lock",
(int *) &make_state_locked, 0)) {
/*
* We need to make sure that we are not being
* called by the exit handler so we don't call
* it again.
*/
if (exiting) {
report_pwd = true;
gettext("Could not open statefile `%s': %s"),
return;
}
} else {
report_pwd = true;
}
}
(void) sprintf(make_state_tempfile,
"%s.tmp",
/* Delete old temporary statefile (in case it exists) */
(void) unlink(make_state_tempfile);
(void) unlink(make_state_lockfile);
make_state_locked = false;
}
/*
* Set a trap for failed writes. If a write fails, the routine
* will try saving the .make.state file under another name in /tmp.
*/
if (attempts++ > 5) {
if ((make_state_lockfile != NULL) &&
(void) unlink(make_state_lockfile);
make_state_locked = false;
}
}
sleep(10);
}
buffer);
}
/* Write the version stamp. */
fd);
fd);
/*
* Go through all the targets, dump their dependencies and
* command used.
*/
/*
* If the target has no command used nor dependencies,
* we can go to the next one.
*/
continue;
}
/* If this target is a special target, don't print. */
continue;
}
/*
* Find out if any of the targets dependencies should
* be written to .make.state.
*/
dependency != NULL;
if (m = !dependency->stale
#ifndef PRINT_EXPLICIT_DEPEN
&& dependency->automatic
#endif
) {
break;
}
}
/* Only print if dependencies listed. */
name_printed = false;
/*
* If this target was built during this make run,
* we mark it.
*/
built_this_run = false;
built_this_run = true;
fd);
}
/* If the target has dependencies, we dump them. */
if (np->has_long_member_name) {
}
if (m) {
name_printed = true;
line_length = 0;
for (dependency =
dependency != NULL;
fd,
}
}
/* If there is a command used, we dump it. */
/*
* Only write the target name if it
* wasn't done for the dependencies.
*/
if (!name_printed) {
}
/*
* Write the command lines.
* Prefix each textual line with a tab.
*/
char *csp;
int n;
n > 0;
n--, csp++) {
if (*csp ==
(int) newline_char) {
fd);
}
}
}
}
}
(void)free(target_name);
}
}
}
if (attempts == 0) {
/* Delete temporary statefile */
(void) unlink(make_state_tempfile);
(void) unlink(make_state_lockfile);
make_state_locked = false;
}
/* Delete temporary statefile */
(void) unlink(make_state_tempfile);
(void) unlink(make_state_lockfile);
make_state_locked = false;
}
}
(void) unlink(make_state_lockfile);
make_state_locked = false;
}
}
/*
* print_auto_depes(dependency, fd, built_this_run,
* line_length, target_name, long_jump)
*
* Will print a dependency list for automatic entries.
*
* Parameters:
* dependency The dependency to print
* fd The file to print it to
* built_this_run If on we prefix each line with .BUILT_THIS...
* line_length Pointer to line length var that we update
* target_name We need this when we restart line
*
* Global variables used:
* built_last_make_run The Name ".BUILT_LAST_MAKE_RUN", written
* force The Name " FORCE", compared against
*/
static void
print_auto_depes(register Dependency dependency, register FILE *fd, register Boolean built_this_run, register int *line_length, register char *target_name, jmp_buf long_jump)
{
if (!dependency->automatic ||
dependency->stale ||
return;
}
fd);
/*
* Check if the dependency line is too long.
* If so, break it and start a new one.
*/
*line_length = 0;
if (built_this_run) {
}
} else {
}
return;
}