1994-05-27 12:33:43 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1988, 1989, 1990, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
* Copyright (c) 1989 by Berkeley Softworks
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Adam de Boor.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
2000-07-09 02:54:54 +00:00
|
|
|
*
|
|
|
|
* @(#)targ.c 8.2 (Berkeley) 3/19/94
|
1994-05-27 12:33:43 +00:00
|
|
|
*/
|
|
|
|
|
2000-07-09 02:54:54 +00:00
|
|
|
#include <sys/cdefs.h>
|
2002-04-13 10:17:18 +00:00
|
|
|
__FBSDID("$FreeBSD$");
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* targ.c --
|
|
|
|
* Functions for maintaining the Lst allTargets. Target nodes are
|
|
|
|
* kept in two structures: a Lst, maintained by the list library, and a
|
|
|
|
* hash table, maintained by the hash library.
|
|
|
|
*
|
|
|
|
* Interface:
|
|
|
|
* Targ_Init Initialization procedure.
|
|
|
|
*
|
1995-01-23 21:03:17 +00:00
|
|
|
* Targ_End Cleanup the module
|
|
|
|
*
|
1994-05-27 12:33:43 +00:00
|
|
|
* Targ_NewGN Create a new GNode for the passed target
|
|
|
|
* (string). The node is *not* placed in the
|
|
|
|
* hash table, though all its fields are
|
|
|
|
* initialized.
|
|
|
|
*
|
|
|
|
* Targ_FindNode Find the node for a given target, creating
|
|
|
|
* and storing it if it doesn't exist and the
|
|
|
|
* flags are right (TARG_CREATE)
|
|
|
|
*
|
|
|
|
* Targ_FindList Given a list of names, find nodes for all
|
|
|
|
* of them. If a name doesn't exist and the
|
|
|
|
* TARG_NOCREATE flag was given, an error message
|
|
|
|
* is printed. Else, if a name doesn't exist,
|
|
|
|
* its node is created.
|
|
|
|
*
|
|
|
|
* Targ_Ignore Return TRUE if errors should be ignored when
|
|
|
|
* creating the given target.
|
|
|
|
*
|
|
|
|
* Targ_Silent Return TRUE if we should be silent when
|
|
|
|
* creating the given target.
|
|
|
|
*
|
|
|
|
* Targ_Precious Return TRUE if the target is precious and
|
|
|
|
* should not be removed if we are interrupted.
|
|
|
|
*
|
|
|
|
* Debugging:
|
|
|
|
* Targ_PrintGraph Print out the entire graphm all variables
|
|
|
|
* and statistics for the directory cache. Should
|
|
|
|
* print something for suffixes, too, but...
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include "make.h"
|
|
|
|
#include "hash.h"
|
|
|
|
#include "dir.h"
|
|
|
|
|
|
|
|
static Lst allTargets; /* the list of all targets found so far */
|
1995-01-23 21:03:17 +00:00
|
|
|
static Lst allGNs; /* List of all the GNodes */
|
1994-05-27 12:33:43 +00:00
|
|
|
static Hash_Table targets; /* a hash table of same */
|
|
|
|
|
2002-09-17 21:29:06 +00:00
|
|
|
#define HTSIZE 191 /* initial size of hash table */
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2002-03-22 01:33:25 +00:00
|
|
|
static int TargPrintOnlySrc(void *, void *);
|
|
|
|
static int TargPrintName(void *, void *);
|
|
|
|
static int TargPrintNode(void *, void *);
|
|
|
|
static void TargFreeGN(void *);
|
1995-01-23 21:03:17 +00:00
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
/*-
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
* Targ_Init --
|
|
|
|
* Initialize this module
|
|
|
|
*
|
|
|
|
* Results:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Side Effects:
|
|
|
|
* The allTargets list and the targets hash table are initialized
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2004-11-30 17:46:29 +00:00
|
|
|
Targ_Init(void)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2004-11-30 17:46:29 +00:00
|
|
|
|
2004-12-07 10:14:16 +00:00
|
|
|
allTargets = Lst_Init();
|
2004-11-30 17:46:29 +00:00
|
|
|
Hash_InitTable(&targets, HTSIZE);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
1995-01-23 21:03:17 +00:00
|
|
|
/*-
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
* Targ_End --
|
|
|
|
* Finalize this module
|
|
|
|
*
|
|
|
|
* Results:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Side Effects:
|
|
|
|
* All lists and gnodes are cleared
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2004-11-30 17:46:29 +00:00
|
|
|
Targ_End(void)
|
1995-01-23 21:03:17 +00:00
|
|
|
{
|
2004-11-30 17:46:29 +00:00
|
|
|
|
1995-01-23 21:03:17 +00:00
|
|
|
Lst_Destroy(allTargets, NOFREE);
|
|
|
|
if (allGNs)
|
|
|
|
Lst_Destroy(allGNs, TargFreeGN);
|
|
|
|
Hash_DeleteTable(&targets);
|
|
|
|
}
|
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
/*-
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
* Targ_NewGN --
|
|
|
|
* Create and initialize a new graph node
|
|
|
|
*
|
|
|
|
* Results:
|
|
|
|
* An initialized graph node with the name field filled with a copy
|
|
|
|
* of the passed name
|
|
|
|
*
|
|
|
|
* Side Effects:
|
1995-01-23 21:03:17 +00:00
|
|
|
* The gnode is added to the list of all gnodes.
|
1994-05-27 12:33:43 +00:00
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
GNode *
|
2004-11-30 17:46:29 +00:00
|
|
|
Targ_NewGN(char *name)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2002-04-13 10:05:30 +00:00
|
|
|
GNode *gn;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2004-12-01 10:29:20 +00:00
|
|
|
gn = emalloc(sizeof(GNode));
|
2004-11-30 17:46:29 +00:00
|
|
|
gn->name = estrdup(name);
|
2004-12-01 10:29:20 +00:00
|
|
|
gn->path = NULL;
|
1994-05-27 12:33:43 +00:00
|
|
|
if (name[0] == '-' && name[1] == 'l') {
|
|
|
|
gn->type = OP_LIB;
|
|
|
|
} else {
|
|
|
|
gn->type = 0;
|
|
|
|
}
|
2004-11-30 17:46:29 +00:00
|
|
|
gn->unmade = 0;
|
|
|
|
gn->make = FALSE;
|
|
|
|
gn->made = UNMADE;
|
|
|
|
gn->childMade = FALSE;
|
|
|
|
gn->order = 0;
|
1994-05-27 12:33:43 +00:00
|
|
|
gn->mtime = gn->cmtime = 0;
|
2004-12-07 10:14:16 +00:00
|
|
|
gn->iParents = Lst_Init();
|
|
|
|
gn->cohorts = Lst_Init();
|
|
|
|
gn->parents = Lst_Init();
|
|
|
|
gn->children = Lst_Init();
|
|
|
|
gn->successors = Lst_Init();
|
|
|
|
gn->preds = Lst_Init();
|
|
|
|
gn->context = Lst_Init();
|
|
|
|
gn->commands = Lst_Init();
|
2004-11-30 17:46:29 +00:00
|
|
|
gn->suffix = NULL;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
1995-01-23 21:03:17 +00:00
|
|
|
if (allGNs == NULL)
|
2004-12-07 10:14:16 +00:00
|
|
|
allGNs = Lst_Init();
|
2004-11-30 17:46:29 +00:00
|
|
|
Lst_AtEnd(allGNs, (void *)gn);
|
1995-01-23 21:03:17 +00:00
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
return (gn);
|
|
|
|
}
|
|
|
|
|
1995-01-23 21:03:17 +00:00
|
|
|
/*-
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
* TargFreeGN --
|
|
|
|
* Destroy a GNode
|
|
|
|
*
|
|
|
|
* Results:
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* Side Effects:
|
|
|
|
* None.
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static void
|
2004-11-30 17:46:29 +00:00
|
|
|
TargFreeGN(void *gnp)
|
1995-01-23 21:03:17 +00:00
|
|
|
{
|
2004-12-01 10:29:20 +00:00
|
|
|
GNode *gn = gnp;
|
1995-01-23 21:03:17 +00:00
|
|
|
|
|
|
|
free(gn->name);
|
2002-10-23 23:16:43 +00:00
|
|
|
free(gn->path);
|
1995-01-23 21:03:17 +00:00
|
|
|
|
|
|
|
Lst_Destroy(gn->iParents, NOFREE);
|
|
|
|
Lst_Destroy(gn->cohorts, NOFREE);
|
|
|
|
Lst_Destroy(gn->parents, NOFREE);
|
|
|
|
Lst_Destroy(gn->children, NOFREE);
|
|
|
|
Lst_Destroy(gn->successors, NOFREE);
|
|
|
|
Lst_Destroy(gn->preds, NOFREE);
|
|
|
|
Lst_Destroy(gn->context, NOFREE);
|
|
|
|
Lst_Destroy(gn->commands, NOFREE);
|
2000-12-02 20:24:42 +00:00
|
|
|
free(gn);
|
1995-01-23 21:03:17 +00:00
|
|
|
}
|
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
/*-
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
* Targ_FindNode --
|
|
|
|
* Find a node in the list using the given name for matching
|
|
|
|
*
|
|
|
|
* Results:
|
2000-12-02 18:58:01 +00:00
|
|
|
* The node in the list if it was. If it wasn't, return NULL of
|
1994-05-27 12:33:43 +00:00
|
|
|
* flags was TARG_NOCREATE or the newly created and initialized node
|
|
|
|
* if it was TARG_CREATE
|
|
|
|
*
|
|
|
|
* Side Effects:
|
|
|
|
* Sometimes a node is created and added to the list
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
GNode *
|
2004-11-30 17:46:29 +00:00
|
|
|
Targ_FindNode(char *name, int flags)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
|
|
|
GNode *gn; /* node in that element */
|
|
|
|
Hash_Entry *he; /* New or used hash entry for node */
|
|
|
|
Boolean isNew; /* Set TRUE if Hash_CreateEntry had to create */
|
|
|
|
/* an entry for the node */
|
|
|
|
|
|
|
|
if (flags & TARG_CREATE) {
|
2004-11-30 17:46:29 +00:00
|
|
|
he = Hash_CreateEntry(&targets, name, &isNew);
|
1994-05-27 12:33:43 +00:00
|
|
|
if (isNew) {
|
2004-11-30 17:46:29 +00:00
|
|
|
gn = Targ_NewGN(name);
|
1994-05-27 12:33:43 +00:00
|
|
|
Hash_SetValue (he, gn);
|
2004-12-01 10:29:20 +00:00
|
|
|
Lst_AtEnd(allTargets, gn);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
} else {
|
2004-11-30 17:46:29 +00:00
|
|
|
he = Hash_FindEntry(&targets, name);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
2004-12-01 10:29:20 +00:00
|
|
|
if (he == NULL) {
|
2000-12-02 18:58:01 +00:00
|
|
|
return (NULL);
|
1994-05-27 12:33:43 +00:00
|
|
|
} else {
|
2004-12-01 10:29:20 +00:00
|
|
|
return (Hash_GetValue(he));
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
* Targ_FindList --
|
1995-05-30 06:41:30 +00:00
|
|
|
* Make a complete list of GNodes from the given list of names
|
1994-05-27 12:33:43 +00:00
|
|
|
*
|
|
|
|
* Results:
|
|
|
|
* A complete list of graph nodes corresponding to all instances of all
|
1995-05-30 06:41:30 +00:00
|
|
|
* the names in names.
|
1994-05-27 12:33:43 +00:00
|
|
|
*
|
|
|
|
* Side Effects:
|
|
|
|
* If flags is TARG_CREATE, nodes will be created for all names in
|
|
|
|
* names which do not yet have graph nodes. If flags is TARG_NOCREATE,
|
|
|
|
* an error message will be printed for each name which can't be found.
|
|
|
|
* -----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
Lst
|
2004-11-30 17:46:29 +00:00
|
|
|
Targ_FindList(Lst names, int flags)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
|
|
|
Lst nodes; /* result list */
|
2002-04-13 10:05:30 +00:00
|
|
|
LstNode ln; /* name list element */
|
|
|
|
GNode *gn; /* node in tLn */
|
|
|
|
char *name;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2004-12-07 10:14:16 +00:00
|
|
|
nodes = Lst_Init();
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2004-11-30 17:46:29 +00:00
|
|
|
if (Lst_Open(names) == FAILURE) {
|
1994-05-27 12:33:43 +00:00
|
|
|
return (nodes);
|
|
|
|
}
|
2004-11-30 17:46:29 +00:00
|
|
|
while ((ln = Lst_Next(names)) != NULL) {
|
2004-12-01 10:29:20 +00:00
|
|
|
name = Lst_Datum(ln);
|
2004-11-30 17:46:29 +00:00
|
|
|
gn = Targ_FindNode(name, flags);
|
2000-12-02 18:58:01 +00:00
|
|
|
if (gn != NULL) {
|
1994-05-27 12:33:43 +00:00
|
|
|
/*
|
|
|
|
* Note: Lst_AtEnd must come before the Lst_Concat so the nodes
|
|
|
|
* are added to the list in the order in which they were
|
|
|
|
* encountered in the makefile.
|
|
|
|
*/
|
2004-12-01 10:29:20 +00:00
|
|
|
Lst_AtEnd(nodes, gn);
|
1994-05-27 12:33:43 +00:00
|
|
|
if (gn->type & OP_DOUBLEDEP) {
|
2004-11-30 17:46:29 +00:00
|
|
|
Lst_Concat(nodes, gn->cohorts, LST_CONCNEW);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
} else if (flags == TARG_NOCREATE) {
|
2004-11-30 17:46:29 +00:00
|
|
|
Error("\"%s\" -- target unknown.", name);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-30 17:46:29 +00:00
|
|
|
Lst_Close(names);
|
1994-05-27 12:33:43 +00:00
|
|
|
return (nodes);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
* Targ_Ignore --
|
|
|
|
* Return true if should ignore errors when creating gn
|
|
|
|
*
|
|
|
|
* Results:
|
|
|
|
* TRUE if should ignore errors
|
|
|
|
*
|
|
|
|
* Side Effects:
|
|
|
|
* None
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
Boolean
|
2004-11-30 17:46:29 +00:00
|
|
|
Targ_Ignore(GNode *gn)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2004-11-30 17:46:29 +00:00
|
|
|
|
|
|
|
if (ignoreErrors || (gn->type & OP_IGNORE)) {
|
1994-05-27 12:33:43 +00:00
|
|
|
return (TRUE);
|
|
|
|
} else {
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
* Targ_Silent --
|
|
|
|
* Return true if be silent when creating gn
|
|
|
|
*
|
|
|
|
* Results:
|
|
|
|
* TRUE if should be silent
|
|
|
|
*
|
|
|
|
* Side Effects:
|
|
|
|
* None
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
Boolean
|
2004-11-30 17:46:29 +00:00
|
|
|
Targ_Silent(GNode *gn)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2004-11-30 17:46:29 +00:00
|
|
|
|
|
|
|
if (beSilent || (gn->type & OP_SILENT)) {
|
1994-05-27 12:33:43 +00:00
|
|
|
return (TRUE);
|
|
|
|
} else {
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
* Targ_Precious --
|
|
|
|
* See if the given target is precious
|
|
|
|
*
|
|
|
|
* Results:
|
|
|
|
* TRUE if it is precious. FALSE otherwise
|
|
|
|
*
|
|
|
|
* Side Effects:
|
|
|
|
* None
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
Boolean
|
2004-11-30 17:46:29 +00:00
|
|
|
Targ_Precious(GNode *gn)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2004-11-30 17:46:29 +00:00
|
|
|
|
|
|
|
if (allPrecious || (gn->type & (OP_PRECIOUS | OP_DOUBLEDEP))) {
|
1994-05-27 12:33:43 +00:00
|
|
|
return (TRUE);
|
|
|
|
} else {
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************* DEBUG INFO PRINTING ****************/
|
|
|
|
|
|
|
|
static GNode *mainTarg; /* the main target, as set by Targ_SetMain */
|
2004-11-30 17:46:29 +00:00
|
|
|
|
1995-05-30 06:41:30 +00:00
|
|
|
/*-
|
1994-05-27 12:33:43 +00:00
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
* Targ_SetMain --
|
|
|
|
* Set our idea of the main target we'll be creating. Used for
|
|
|
|
* debugging output.
|
|
|
|
*
|
|
|
|
* Results:
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* Side Effects:
|
|
|
|
* "mainTarg" is set to the main target's node.
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2004-11-30 17:46:29 +00:00
|
|
|
Targ_SetMain(GNode *gn)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2004-11-30 17:46:29 +00:00
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
mainTarg = gn;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-11-30 17:46:29 +00:00
|
|
|
TargPrintName(void *gnp, void *ppath)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
1995-01-23 21:03:17 +00:00
|
|
|
GNode *gn = (GNode *) gnp;
|
2004-11-30 17:46:29 +00:00
|
|
|
|
|
|
|
printf("%s ", gn->name);
|
1994-05-27 12:33:43 +00:00
|
|
|
#ifdef notdef
|
|
|
|
if (ppath) {
|
|
|
|
if (gn->path) {
|
2004-11-30 17:46:29 +00:00
|
|
|
printf("[%s] ", gn->path);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
if (gn == mainTarg) {
|
2004-11-30 17:46:29 +00:00
|
|
|
printf("(MAIN NAME) ");
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* notdef */
|
1995-01-23 21:03:17 +00:00
|
|
|
return (ppath ? 0 : 0);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2004-11-30 17:46:29 +00:00
|
|
|
Targ_PrintCmd(void *cmd, void *dummy __unused)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2004-11-30 17:46:29 +00:00
|
|
|
|
|
|
|
printf("\t%s\n", (char *)cmd);
|
2002-10-09 03:42:10 +00:00
|
|
|
return (0);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
* Targ_FmtTime --
|
|
|
|
* Format a modification time in some reasonable way and return it.
|
|
|
|
*
|
|
|
|
* Results:
|
|
|
|
* The time reformatted.
|
|
|
|
*
|
|
|
|
* Side Effects:
|
|
|
|
* The time is placed in a static area, so it is overwritten
|
|
|
|
* with each call.
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
char *
|
2004-11-30 17:46:29 +00:00
|
|
|
Targ_FmtTime(time_t modtime)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
|
|
|
struct tm *parts;
|
1999-08-17 00:39:26 +00:00
|
|
|
static char buf[128];
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2002-09-28 23:35:07 +00:00
|
|
|
parts = localtime(&modtime);
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2002-09-26 06:40:04 +00:00
|
|
|
strftime(buf, sizeof buf, "%H:%M:%S %b %d, %Y", parts);
|
1999-08-17 00:39:26 +00:00
|
|
|
buf[sizeof(buf) - 1] = '\0';
|
2004-11-30 17:46:29 +00:00
|
|
|
return (buf);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
1995-05-30 06:41:30 +00:00
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
/*-
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
* Targ_PrintType --
|
|
|
|
* Print out a type field giving only those attributes the user can
|
|
|
|
* set.
|
|
|
|
*
|
|
|
|
* Results:
|
|
|
|
*
|
|
|
|
* Side Effects:
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2004-11-30 17:46:29 +00:00
|
|
|
Targ_PrintType(int type)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2002-04-13 10:05:30 +00:00
|
|
|
int tbit;
|
1995-05-30 06:41:30 +00:00
|
|
|
|
2002-09-17 21:29:06 +00:00
|
|
|
#define PRINTBIT(attr) case CONCAT(OP_,attr): printf("." #attr " "); break
|
2002-09-18 16:13:03 +00:00
|
|
|
#define PRINTDBIT(attr) case CONCAT(OP_,attr): DEBUGF(TARG, ("." #attr " ")); break
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
type &= ~OP_OPMASK;
|
|
|
|
|
|
|
|
while (type) {
|
|
|
|
tbit = 1 << (ffs(type) - 1);
|
|
|
|
type &= ~tbit;
|
|
|
|
|
|
|
|
switch(tbit) {
|
|
|
|
PRINTBIT(OPTIONAL);
|
|
|
|
PRINTBIT(USE);
|
|
|
|
PRINTBIT(EXEC);
|
|
|
|
PRINTBIT(IGNORE);
|
|
|
|
PRINTBIT(PRECIOUS);
|
|
|
|
PRINTBIT(SILENT);
|
|
|
|
PRINTBIT(MAKE);
|
|
|
|
PRINTBIT(JOIN);
|
|
|
|
PRINTBIT(INVISIBLE);
|
|
|
|
PRINTBIT(NOTMAIN);
|
|
|
|
PRINTDBIT(LIB);
|
|
|
|
/*XXX: MEMBER is defined, so CONCAT(OP_,MEMBER) gives OP_"%" */
|
2002-09-18 16:13:03 +00:00
|
|
|
case OP_MEMBER: DEBUGF(TARG, (".MEMBER ")); break;
|
1994-05-27 12:33:43 +00:00
|
|
|
PRINTDBIT(ARCHV);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
* TargPrintNode --
|
|
|
|
* print the contents of a node
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static int
|
2004-11-30 17:46:29 +00:00
|
|
|
TargPrintNode(void *gnp, void *passp)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2004-12-01 10:29:20 +00:00
|
|
|
GNode *gn = gnp;
|
2004-11-30 17:46:29 +00:00
|
|
|
int pass = *(int *)passp;
|
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
if (!OP_NOP(gn->type)) {
|
|
|
|
printf("#\n");
|
|
|
|
if (gn == mainTarg) {
|
|
|
|
printf("# *** MAIN TARGET ***\n");
|
|
|
|
}
|
|
|
|
if (pass == 2) {
|
|
|
|
if (gn->unmade) {
|
|
|
|
printf("# %d unmade children\n", gn->unmade);
|
|
|
|
} else {
|
|
|
|
printf("# No unmade children\n");
|
|
|
|
}
|
2004-12-01 10:29:20 +00:00
|
|
|
if (!(gn->type & (OP_JOIN | OP_USE | OP_EXEC))) {
|
1994-05-27 12:33:43 +00:00
|
|
|
if (gn->mtime != 0) {
|
|
|
|
printf("# last modified %s: %s\n",
|
|
|
|
Targ_FmtTime(gn->mtime),
|
|
|
|
(gn->made == UNMADE ? "unmade" :
|
|
|
|
(gn->made == MADE ? "made" :
|
|
|
|
(gn->made == UPTODATE ? "up-to-date" :
|
|
|
|
"error when made"))));
|
|
|
|
} else if (gn->made != UNMADE) {
|
|
|
|
printf("# non-existent (maybe): %s\n",
|
|
|
|
(gn->made == MADE ? "made" :
|
|
|
|
(gn->made == UPTODATE ? "up-to-date" :
|
|
|
|
(gn->made == ERROR ? "error when made" :
|
|
|
|
"aborted"))));
|
|
|
|
} else {
|
|
|
|
printf("# unmade\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!Lst_IsEmpty (gn->iParents)) {
|
|
|
|
printf("# implicit parents: ");
|
2004-12-01 10:29:20 +00:00
|
|
|
Lst_ForEach(gn->iParents, TargPrintName, (void *)NULL);
|
2004-11-30 17:46:29 +00:00
|
|
|
fputc('\n', stdout);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!Lst_IsEmpty (gn->parents)) {
|
|
|
|
printf("# parents: ");
|
2004-12-01 10:29:20 +00:00
|
|
|
Lst_ForEach(gn->parents, TargPrintName, (void *)NULL);
|
2004-11-30 17:46:29 +00:00
|
|
|
fputc('\n', stdout);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
1995-05-30 06:41:30 +00:00
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
printf("%-16s", gn->name);
|
|
|
|
switch (gn->type & OP_OPMASK) {
|
|
|
|
case OP_DEPENDS:
|
|
|
|
printf(": "); break;
|
|
|
|
case OP_FORCE:
|
|
|
|
printf("! "); break;
|
|
|
|
case OP_DOUBLEDEP:
|
|
|
|
printf(":: "); break;
|
2002-09-28 20:03:26 +00:00
|
|
|
default:
|
|
|
|
break;
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
2004-11-30 17:46:29 +00:00
|
|
|
Targ_PrintType(gn->type);
|
2004-12-01 10:29:20 +00:00
|
|
|
Lst_ForEach(gn->children, TargPrintName, (void *)NULL);
|
2004-11-30 17:46:29 +00:00
|
|
|
fputc('\n', stdout);
|
2004-12-01 10:29:20 +00:00
|
|
|
Lst_ForEach(gn->commands, Targ_PrintCmd, (void *)NULL);
|
1994-05-27 12:33:43 +00:00
|
|
|
printf("\n\n");
|
|
|
|
if (gn->type & OP_DOUBLEDEP) {
|
2004-12-01 10:29:20 +00:00
|
|
|
Lst_ForEach(gn->cohorts, TargPrintNode, &pass);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
* TargPrintOnlySrc --
|
|
|
|
* Print only those targets that are just a source.
|
|
|
|
*
|
|
|
|
* Results:
|
|
|
|
* 0.
|
|
|
|
*
|
|
|
|
* Side Effects:
|
2001-02-18 10:43:53 +00:00
|
|
|
* The name of each file is printed preceded by #\t
|
1994-05-27 12:33:43 +00:00
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static int
|
2002-10-09 03:42:10 +00:00
|
|
|
TargPrintOnlySrc(void *gnp, void *dummy __unused)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2004-12-01 10:29:20 +00:00
|
|
|
GNode *gn = gnp;
|
2004-11-30 17:46:29 +00:00
|
|
|
|
1995-01-23 21:03:17 +00:00
|
|
|
if (OP_NOP(gn->type))
|
|
|
|
printf("#\t%s [%s]\n", gn->name, gn->path ? gn->path : gn->name);
|
|
|
|
|
2002-10-09 03:42:10 +00:00
|
|
|
return (0);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
* Targ_PrintGraph --
|
2002-10-09 03:42:10 +00:00
|
|
|
* Print the entire graph.
|
1994-05-27 12:33:43 +00:00
|
|
|
*
|
|
|
|
* Results:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Side Effects:
|
|
|
|
* lots o' output
|
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
2004-11-30 17:46:29 +00:00
|
|
|
Targ_PrintGraph(int pass)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2004-12-01 10:29:20 +00:00
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
printf("#*** Input graph:\n");
|
2004-12-01 10:29:20 +00:00
|
|
|
Lst_ForEach(allTargets, TargPrintNode, &pass);
|
1994-05-27 12:33:43 +00:00
|
|
|
printf("\n\n");
|
|
|
|
printf("#\n# Files that are only sources:\n");
|
2004-12-01 10:29:20 +00:00
|
|
|
Lst_ForEach(allTargets, TargPrintOnlySrc, (void *)NULL);
|
1994-05-27 12:33:43 +00:00
|
|
|
printf("#*** Global Variables:\n");
|
2004-11-30 17:46:29 +00:00
|
|
|
Var_Dump(VAR_GLOBAL);
|
1994-05-27 12:33:43 +00:00
|
|
|
printf("#*** Command-line Variables:\n");
|
2004-11-30 17:46:29 +00:00
|
|
|
Var_Dump(VAR_CMD);
|
1994-05-27 12:33:43 +00:00
|
|
|
printf("\n");
|
|
|
|
Dir_PrintDirectories();
|
|
|
|
printf("\n");
|
|
|
|
Suff_PrintAll();
|
|
|
|
}
|