/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* misc.cc
*
* This file contains various unclassified routines. Some main groups:
* getname
* Memory allocation
* String handling
* Property handling
* Error message handling
* Make internal state dumping
* main routine support
*/
/*
* Included files
*/
#include <errno.h>
#include <stdarg.h> /* va_list, va_start(), va_end() */
#include <libintl.h>
extern void job_adjust_fini();
/*
* Defined macros
*/
/*
* typedefs & structs
*/
/*
* Static variables
*/
/*
* File table of contents
*/
/*****************************************
*
* getname
*/
/*****************************************
*
* Memory allocation
*/
/*
* free_chain()
*
* frees a chain of Name_vector's
*
* Parameters:
* ptr Pointer to the first element in the chain
* to be freed.
*
* Global variables used:
*/
void
{
}
}
}
/*****************************************
*
* String manipulation
*/
/*****************************************
*
* Nameblock property handling
*/
/*****************************************
*
* Error message handling
*/
/*
* fatal(format, args...)
*
* Print a message and die
*
* Parameters:
* format printf type format string
* args Arguments to match the format
*
* Global variables used:
* fatal_in_progress Indicates if this is a recursive call
* parallel_process_cnt Do we need to wait for anything?
* report_pwd Should we report the current path?
*/
/*VARARGS*/
void
{
if (report_pwd) {
gettext("Current working directory %s\n"),
get_current_path());
}
if (fatal_in_progress) {
exit_status = 1;
exit(1);
}
fatal_in_progress = true;
/* Let all parallel children finish */
if ((dmake_mode_type == parallel_mode) &&
(parallel_process_cnt > 0)) {
gettext("Waiting for %d %s to finish\n"),
parallel_process_cnt == 1 ?
}
while (parallel_process_cnt > 0) {
await_parallel(true);
finish_children(false);
}
exit_status = 1;
exit(1);
}
/*
* warning(format, args...)
*
* Print a message and continue.
*
* Parameters:
* format printf type format string
* args Arguments to match the format
*
* Global variables used:
* report_pwd Should we report the current path?
*/
/*VARARGS*/
void
{
if (report_pwd) {
gettext("Current working directory %s\n"),
get_current_path());
}
}
/*
* time_to_string(time)
*
* Take a numeric time value and produce
* a proper string representation.
*
* Return value:
* The string representation of the time
*
* Parameters:
* time The time we need to translate
*
* Global variables used:
*/
char *
{
if (time == file_doesnt_exist) {
return gettext("File does not exist");
}
if (time == file_max_time) {
return gettext("Younger than any file");
}
}
/*
* get_current_path()
*
* Stuff current_path with the current path if it isnt there already.
*
* Parameters:
*
* Global variables used:
*/
char *
get_current_path(void)
{
static char *current_path;
if (current_path == NULL) {
pwd[0] = (int) slash_char;
}
}
return current_path;
}
/*****************************************
*
* Make internal state dumping
*
* This is a set of routines for dumping the internal make state
* Used for the -p option
*/
/*
* dump_make_state()
*
* Dump make's internal state to stdout
*
* Parameters:
*
* Global variables used:
* svr4 Was ".SVR4" seen in makefile?
* svr4_name The Name ".SVR4", printed
* posix Was ".POSIX" seen in makefile?
* posix_name The Name ".POSIX", printed
* default_rule Points to the .DEFAULT rule
* default_rule_name The Name ".DEFAULT", printed
* default_target_to_build The first target to print
* dot_keep_state The Name ".KEEP_STATE", printed
* dot_keep_state_file The Name ".KEEP_STATE_FILE", printed
* hashtab The make hash table for Name blocks
* ignore_errors Was ".IGNORE" seen in makefile?
* ignore_name The Name ".IGNORE", printed
* keep_state Was ".KEEP_STATE" seen in makefile?
* percent_list The list of % rules
* precious The Name ".PRECIOUS", printed
* sccs_get_name The Name ".SCCS_GET", printed
* sccs_get_posix_name The Name ".SCCS_GET_POSIX", printed
* get_name The Name ".GET", printed
* get_posix_name The Name ".GET_POSIX", printed
* sccs_get_rule Points to the ".SCCS_GET" rule
* silent Was ".SILENT" seen in makefile?
* silent_name The Name ".SILENT", printed
* suffixes The suffix list from ".SUFFIXES"
* suffixes_name The Name ".SUFFIX", printed
*/
void
dump_make_state(void)
{
/* Default target */
if (default_target_to_build != NULL) {
}
(void) printf("\n");
/* .POSIX */
if (posix) {
}
/* .DEFAULT */
if (default_rule != NULL) {
}
}
/* .IGNORE */
if (ignore_errors) {
}
/* .KEEP_STATE: */
if (keep_state) {
}
/* .PRECIOUS */
}
}
(void) printf("\n");
/* .SCCS_GET */
if (sccs_get_rule != NULL) {
}
}
/* .SILENT */
if (silent) {
}
/* .SUFFIXES: */
}
(void) printf("\n\n");
/* % rules */
for (percent = percent_list;
(void) printf("%s:",
percent_depe != NULL;
}
(void) printf("\n");
}
}
/* Suffix rules */
print_rule(p);
}
}
/* Macro assignments */
}
}
(void) printf("\n");
/* Conditional macro assignments */
(void) printf("%s := %s",
p->string_mb,
printf(" +");
}
else {
printf(" ");
}
}
}
(void) printf("\n");
/* All other dependencies */
print_rule(p);
}
}
(void) printf("\n");
}
/*
* print_rule(target)
*
* Print the rule for one target
*
* Parameters:
* target Target we print rule for
*
* Global variables used:
*/
static void
{
if (target->dependency_printed ||
return;
}
target->dependency_printed = true;
dependency != NULL;
}
(void) printf("\n");
}
}
void
dump_target_list(void)
{
((wcb[0] != (int) period_char) ||
((wcb[0] == (int) period_char) &&
}
}
}
static void
{
if (target->dependency_printed) {
return;
}
target->dependency_printed = true;
return;
}
dependency != NULL;
if (!dependency->automatic) {
}
}
}
/*****************************************
*
* main() support
*/
/*
* load_cached_names()
*
* Load the vector of cached names
*
* Parameters:
*
* Global variables used:
* Many many pointers to Name blocks.
*/
void
load_cached_names(void)
{
char *cp;
/* Load the cached_names struct */
/*
* A version of make was released with NSE 1.0 that used
* VERSION-1.1 but this version is identical to VERSION-1.0.
* The version mismatch code makes a special case for this
* situation. If the version number is changed from 1.0
* it should go to 1.2.
*/
/* Mark special targets so that the reader treats them properly */
/* The value of $$ is $ */
/* Set the value of $(SHELL) */
if (posix) {
} else {
}
/*
* Use " FORCE" to simulate a FRC dependency for :: type
* targets with no dependencies.
*/
/* Make sure VPATH is defined before current dir is read */
(void) SETVAR(vpath_name,
false);
}
/* Check if there is NO PATH variable. If not we construct one. */
vroot_path = NULL;
}
}
/*
* iterate on list of conditional macros in np, and place them in
* a String_rec starting with, and separated by the '$' character.
*/
void
{
/*
* Put the version number at the start of the string
*/
/*
* Add the rest of the conditional macros to the buffer
*/
if (np->depends_on_conditional){
}
}
}