[BACK]Return to targ.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Annotation of src/usr.bin/make/targ.c, Revision 1.38

1.31      espie       1: /*     $OpenPackages$ */
1.38    ! millert     2: /*     $OpenBSD: targ.c,v 1.37 2003/01/03 17:44:48 espie Exp $ */
1.6       millert     3: /*     $NetBSD: targ.c,v 1.11 1997/02/20 16:51:50 christos Exp $       */
1.1       deraadt     4:
                      5: /*
1.31      espie       6:  * Copyright (c) 1999 Marc Espie.
                      7:  *
                      8:  * Extensive code changes for the OpenBSD project.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  *
                     19:  * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
                     20:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
                     21:  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
                     22:  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OPENBSD
                     23:  * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
                     24:  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
                     25:  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     26:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     27:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     28:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
                     29:  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     30:  */
                     31: /*
1.5       millert    32:  * Copyright (c) 1988, 1989, 1990, 1993
                     33:  *     The Regents of the University of California.  All rights reserved.
1.1       deraadt    34:  * Copyright (c) 1989 by Berkeley Softworks
                     35:  * All rights reserved.
                     36:  *
                     37:  * This code is derived from software contributed to Berkeley by
                     38:  * Adam de Boor.
                     39:  *
                     40:  * Redistribution and use in source and binary forms, with or without
                     41:  * modification, are permitted provided that the following conditions
                     42:  * are met:
                     43:  * 1. Redistributions of source code must retain the above copyright
                     44:  *    notice, this list of conditions and the following disclaimer.
                     45:  * 2. Redistributions in binary form must reproduce the above copyright
                     46:  *    notice, this list of conditions and the following disclaimer in the
                     47:  *    documentation and/or other materials provided with the distribution.
1.38    ! millert    48:  * 3. Neither the name of the University nor the names of its contributors
1.1       deraadt    49:  *    may be used to endorse or promote products derived from this software
                     50:  *    without specific prior written permission.
                     51:  *
                     52:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     53:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     54:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     55:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     56:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     57:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     58:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     59:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     60:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     61:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     62:  * SUCH DAMAGE.
                     63:  */
                     64:
                     65: /*-
                     66:  * targ.c --
1.27      espie      67:  *             Target nodes are kept into a hash table.
1.1       deraadt    68:  *
                     69:  * Interface:
1.31      espie      70:  *     Targ_Init               Initialization procedure.
1.1       deraadt    71:  *
1.31      espie      72:  *     Targ_End                Cleanup the module
1.1       deraadt    73:  *
1.31      espie      74:  *     Targ_NewGN              Create a new GNode for the passed target
                     75:  *                             (string). The node is *not* placed in the
                     76:  *                             hash table, though all its fields are
                     77:  *                             initialized.
1.1       deraadt    78:  *
1.31      espie      79:  *     Targ_FindNode           Find the node for a given target, creating
                     80:  *                             and storing it if it doesn't exist and the
                     81:  *                             flags are right (TARG_CREATE)
1.1       deraadt    82:  *
1.31      espie      83:  *     Targ_FindList           Given a list of names, find nodes for all
                     84:  *                             of them, creating nodes if needed.
1.1       deraadt    85:  *
1.32      espie      86:  *     Targ_Ignore             Return true if errors should be ignored when
1.31      espie      87:  *                             creating the given target.
1.1       deraadt    88:  *
1.32      espie      89:  *     Targ_Silent             Return true if we should be silent when
1.31      espie      90:  *                             creating the given target.
1.1       deraadt    91:  *
1.32      espie      92:  *     Targ_Precious           Return true if the target is precious and
1.31      espie      93:  *                             should not be removed if we are interrupted.
1.1       deraadt    94:  *
                     95:  * Debugging:
1.31      espie      96:  *     Targ_PrintGraph         Print out the entire graphm all variables
                     97:  *                             and statistics for the directory cache. Should
                     98:  *                             print something for suffixes, too, but...
1.1       deraadt    99:  */
                    100:
1.32      espie     101: #include <sys/types.h>
1.34      espie     102: #include <limits.h>
1.32      espie     103: #include <stddef.h>
                    104: #include <stdio.h>
1.33      espie     105: #include <string.h>
1.32      espie     106: #include "config.h"
                    107: #include "defines.h"
                    108: #include "ohash.h"
                    109: #include "stats.h"
                    110: #include "suff.h"
                    111: #include "var.h"
                    112: #include "targ.h"
                    113: #include "memory.h"
                    114: #include "gnode.h"
                    115: #include "extern.h"
                    116: #include "timestamp.h"
                    117: #include "lst.h"
1.37      espie     118: #ifdef CLEANUP
                    119: #include <stdlib.h>
                    120: #endif
1.31      espie     121:
                    122: static struct ohash targets;   /* a hash table of same */
                    123: static struct ohash_info gnode_info = {
                    124:        offsetof(GNode, name),
1.27      espie     125:     NULL, hash_alloc, hash_free, element_alloc };
1.1       deraadt   126:
1.31      espie     127: static void TargPrintOnlySrc(GNode *);
                    128: static void TargPrintName(void *);
                    129: static void TargPrintNode(GNode *, int);
1.10      espie     130: #ifdef CLEANUP
1.37      espie     131: static LIST allTargets;
1.31      espie     132: static void TargFreeGN(void *);
1.10      espie     133: #endif
1.1       deraadt   134:
                    135: /*-
                    136:  *-----------------------------------------------------------------------
                    137:  * Targ_Init --
                    138:  *     Initialize this module
                    139:  *
1.31      espie     140:  * Side Effects:
1.27      espie     141:  *     The targets hash table is initialized
1.1       deraadt   142:  *-----------------------------------------------------------------------
                    143:  */
                    144: void
1.19      espie     145: Targ_Init()
1.1       deraadt   146: {
1.27      espie     147:     /* A small make file already creates 200 targets.  */
1.30      espie     148:     ohash_init(&targets, 10, &gnode_info);
1.37      espie     149: #ifdef CLEANUP
                    150:     Lst_Init(&allTargets);
                    151: #endif
1.1       deraadt   152: }
                    153:
                    154: /*-
                    155:  *-----------------------------------------------------------------------
                    156:  * Targ_End --
                    157:  *     Finalize this module
                    158:  *
                    159:  * Side Effects:
                    160:  *     All lists and gnodes are cleared
                    161:  *-----------------------------------------------------------------------
                    162:  */
1.32      espie     163: #ifdef CLEANUP
1.1       deraadt   164: void
1.31      espie     165: Targ_End()
1.1       deraadt   166: {
1.37      espie     167:     Lst_Every(&allTargets, TargFreeGN);
1.30      espie     168:     ohash_delete(&targets);
1.32      espie     169: }
1.10      espie     170: #endif
1.1       deraadt   171:
                    172: /*-
                    173:  *-----------------------------------------------------------------------
1.32      espie     174:  * Targ_NewGNi  --
1.1       deraadt   175:  *     Create and initialize a new graph node
                    176:  *
                    177:  * Results:
                    178:  *     An initialized graph node with the name field filled with a copy
                    179:  *     of the passed name
                    180:  *
1.37      espie     181:  * Side effect:
                    182:  *     add targets to list of all targets if CLEANUP
1.1       deraadt   183:  *-----------------------------------------------------------------------
                    184:  */
                    185: GNode *
1.32      espie     186: Targ_NewGNi(name, end)
1.31      espie     187:     const char *name;  /* the name to stick in the new node */
                    188:     const char *end;
1.1       deraadt   189: {
1.31      espie     190:     GNode *gn;
1.1       deraadt   191:
1.30      espie     192:     gn = ohash_create_entry(&gnode_info, name, &end);
1.27      espie     193:     gn->path = NULL;
1.1       deraadt   194:     if (name[0] == '-' && name[1] == 'l') {
                    195:        gn->type = OP_LIB;
                    196:     } else {
                    197:        gn->type = 0;
                    198:     }
1.31      espie     199:     gn->unmade =       0;
1.32      espie     200:     gn->make =         false;
1.31      espie     201:     gn->made =         UNMADE;
1.32      espie     202:     gn->childMade =    false;
1.31      espie     203:     gn->order =        0;
1.32      espie     204:     ts_set_out_of_date(gn->mtime);
                    205:     ts_set_out_of_date(gn->cmtime);
1.19      espie     206:     Lst_Init(&gn->iParents);
                    207:     Lst_Init(&gn->cohorts);
                    208:     Lst_Init(&gn->parents);
                    209:     Lst_Init(&gn->children);
                    210:     Lst_Init(&gn->successors);
                    211:     Lst_Init(&gn->preds);
1.25      espie     212:     SymTable_Init(&gn->context);
1.16      espie     213:     gn->lineno = 0;
                    214:     gn->fname = NULL;
1.19      espie     215:     Lst_Init(&gn->commands);
1.1       deraadt   216:     gn->suffix =       NULL;
                    217:
1.31      espie     218: #ifdef STATS_GN_CREATION
                    219:     STAT_GN_COUNT++;
1.10      espie     220: #endif
1.1       deraadt   221:
1.37      espie     222: #ifdef CLEANUP
                    223:     Lst_AtEnd(&allTargets, gn);
                    224: #endif
1.27      espie     225:     return gn;
1.1       deraadt   226: }
                    227:
1.10      espie     228: #ifdef CLEANUP
1.1       deraadt   229: /*-
                    230:  *-----------------------------------------------------------------------
                    231:  * TargFreeGN  --
                    232:  *     Destroy a GNode
                    233:  *-----------------------------------------------------------------------
                    234:  */
                    235: static void
1.18      espie     236: TargFreeGN(gnp)
                    237:     void *gnp;
1.1       deraadt   238: {
1.31      espie     239:     GNode *gn = (GNode *)gnp;
1.1       deraadt   240:
1.9       espie     241:     efree(gn->path);
1.24      espie     242:     Lst_Destroy(&gn->iParents, NOFREE);
                    243:     Lst_Destroy(&gn->cohorts, NOFREE);
                    244:     Lst_Destroy(&gn->parents, NOFREE);
                    245:     Lst_Destroy(&gn->children, NOFREE);
                    246:     Lst_Destroy(&gn->successors, NOFREE);
                    247:     Lst_Destroy(&gn->preds, NOFREE);
1.31      espie     248:     Lst_Destroy(&gn->commands, NOFREE);
1.25      espie     249:     SymTable_Destroy(&gn->context);
1.18      espie     250:     free(gn);
1.1       deraadt   251: }
1.10      espie     252: #endif
1.1       deraadt   253:
                    254:
                    255: /*-
                    256:  *-----------------------------------------------------------------------
1.32      espie     257:  * Targ_FindNodei  --
1.1       deraadt   258:  *     Find a node in the list using the given name for matching
                    259:  *
                    260:  * Results:
1.31      espie     261:  *     The node in the list if it was. If it wasn't, return NULL if
1.1       deraadt   262:  *     flags was TARG_NOCREATE or the newly created and initialized node
1.31      espie     263:  *     if flags was TARG_CREATE
1.1       deraadt   264:  *
                    265:  * Side Effects:
                    266:  *     Sometimes a node is created and added to the list
                    267:  *-----------------------------------------------------------------------
                    268:  */
                    269: GNode *
1.32      espie     270: Targ_FindNodei(name, end, flags)
1.27      espie     271:     const char         *name;  /* the name to find */
1.31      espie     272:     const char         *end;
                    273:     int                flags;  /* flags governing events when target not
1.1       deraadt   274:                                 * found */
                    275: {
1.31      espie     276:     GNode              *gn;    /* node in that element */
1.27      espie     277:     unsigned int       slot;
                    278:
1.30      espie     279:     slot = ohash_qlookupi(&targets, name, &end);
1.27      espie     280:
1.30      espie     281:     gn = ohash_find(&targets, slot);
1.31      espie     282:
1.27      espie     283:     if (gn == NULL && (flags & TARG_CREATE)) {
1.32      espie     284:        gn = Targ_NewGNi(name, end);
1.30      espie     285:        ohash_insert(&targets, slot, gn);
1.1       deraadt   286:     }
                    287:
1.27      espie     288:     return gn;
1.1       deraadt   289: }
                    290:
                    291: /*-
                    292:  *-----------------------------------------------------------------------
                    293:  * Targ_FindList --
1.5       millert   294:  *     Make a complete list of GNodes from the given list of names
1.1       deraadt   295:  *
1.20      espie     296:  * Side Effects:
1.31      espie     297:  *     Nodes will be created for all names in names which do not yet have graph
1.20      espie     298:  *     nodes.
1.1       deraadt   299:  *
1.31      espie     300:  *     A complete list of graph nodes corresponding to all instances of all
                    301:  *     the names in names is added to nodes.
1.1       deraadt   302:  * -----------------------------------------------------------------------
                    303:  */
1.20      espie     304: void
                    305: Targ_FindList(nodes, names)
1.31      espie     306:     Lst           nodes;       /* result list */
                    307:     Lst           names;       /* list of names to find */
1.1       deraadt   308: {
1.31      espie     309:     LstNode       ln;          /* name list element */
                    310:     GNode        *gn;          /* node in tLn */
                    311:     char         *name;
1.1       deraadt   312:
1.22      espie     313:     for (ln = Lst_First(names); ln != NULL; ln = Lst_Adv(ln)) {
1.1       deraadt   314:        name = (char *)Lst_Datum(ln);
1.32      espie     315:        gn = Targ_FindNode(name, TARG_CREATE);
1.31      espie     316:            /* Note: Lst_AtEnd must come before the Lst_Concat so the nodes
                    317:             * are added to the list in the order in which they were
                    318:             * encountered in the makefile.  */
1.20      espie     319:        Lst_AtEnd(nodes, gn);
                    320:        if (gn->type & OP_DOUBLEDEP)
1.21      espie     321:            Lst_Concat(nodes, &gn->cohorts);
1.1       deraadt   322:     }
                    323: }
                    324:
                    325: /*-
                    326:  *-----------------------------------------------------------------------
1.31      espie     327:  * Targ_Ignore --
1.1       deraadt   328:  *     Return true if should ignore errors when creating gn
                    329:  *-----------------------------------------------------------------------
                    330:  */
1.32      espie     331: bool
1.27      espie     332: Targ_Ignore(gn)
1.31      espie     333:     GNode         *gn;         /* node to check for */
1.1       deraadt   334: {
1.27      espie     335:     if (ignoreErrors || gn->type & OP_IGNORE)
1.32      espie     336:        return true;
1.27      espie     337:     else
1.32      espie     338:        return false;
1.1       deraadt   339: }
                    340:
                    341: /*-
                    342:  *-----------------------------------------------------------------------
1.31      espie     343:  * Targ_Silent --
1.1       deraadt   344:  *     Return true if be silent when creating gn
                    345:  *-----------------------------------------------------------------------
                    346:  */
1.32      espie     347: bool
1.27      espie     348: Targ_Silent(gn)
1.31      espie     349:     GNode         *gn;         /* node to check for */
1.1       deraadt   350: {
1.27      espie     351:     if (beSilent || gn->type & OP_SILENT)
1.32      espie     352:        return true;
1.27      espie     353:     else
1.32      espie     354:        return false;
1.1       deraadt   355: }
                    356:
                    357: /*-
                    358:  *-----------------------------------------------------------------------
                    359:  * Targ_Precious --
                    360:  *     See if the given target is precious
                    361:  *-----------------------------------------------------------------------
                    362:  */
1.32      espie     363: bool
1.31      espie     364: Targ_Precious(gn)
                    365:     GNode         *gn;         /* the node to check */
1.1       deraadt   366: {
1.27      espie     367:     if (allPrecious || (gn->type & (OP_PRECIOUS|OP_DOUBLEDEP)))
1.32      espie     368:        return true;
1.27      espie     369:     else
1.32      espie     370:        return false;
1.1       deraadt   371: }
                    372:
                    373: /******************* DEBUG INFO PRINTING ****************/
                    374:
                    375: static GNode     *mainTarg;    /* the main target, as set by Targ_SetMain */
1.5       millert   376: /*-
1.1       deraadt   377:  *-----------------------------------------------------------------------
                    378:  * Targ_SetMain --
                    379:  *     Set our idea of the main target we'll be creating. Used for
                    380:  *     debugging output.
                    381:  *
                    382:  * Side Effects:
                    383:  *     "mainTarg" is set to the main target's node.
                    384:  *-----------------------------------------------------------------------
                    385:  */
                    386: void
1.27      espie     387: Targ_SetMain(gn)
1.31      espie     388:     GNode   *gn;       /* The main target we'll create */
1.1       deraadt   389: {
                    390:     mainTarg = gn;
                    391: }
                    392:
1.17      espie     393: static void
                    394: TargPrintName(gnp)
1.18      espie     395:     void *gnp;
1.1       deraadt   396: {
1.17      espie     397:     GNode *gn = (GNode *)gnp;
                    398:     printf("%s ", gn->name);
1.1       deraadt   399: }
                    400:
                    401:
1.17      espie     402: void
                    403: Targ_PrintCmd(cmd)
1.18      espie     404:     void *cmd;
1.1       deraadt   405: {
1.17      espie     406:     printf("\t%s\n", (char *)cmd);
1.1       deraadt   407: }
                    408:
                    409: /*-
                    410:  *-----------------------------------------------------------------------
                    411:  * Targ_FmtTime --
                    412:  *     Format a modification time in some reasonable way and return it.
                    413:  *
                    414:  * Results:
                    415:  *     The time reformatted.
                    416:  *
                    417:  * Side Effects:
                    418:  *     The time is placed in a static area, so it is overwritten
                    419:  *     with each call.
                    420:  *-----------------------------------------------------------------------
                    421:  */
                    422: char *
1.27      espie     423: Targ_FmtTime(time)
1.31      espie     424:     TIMESTAMP   time;
1.1       deraadt   425: {
1.31      espie     426:     struct tm          *parts;
                    427:     static char        buf[128];
1.29      espie     428:     time_t t;
1.1       deraadt   429:
1.29      espie     430:     t = timestamp2time_t(time);
                    431:
                    432:     parts = localtime(&t);
1.31      espie     433:     strftime(buf, sizeof buf, "%H:%M:%S %b %d, %Y", parts);
1.8       deraadt   434:     buf[sizeof(buf) - 1] = '\0';
1.31      espie     435:     return buf;
1.1       deraadt   436: }
1.5       millert   437:
1.1       deraadt   438: /*-
                    439:  *-----------------------------------------------------------------------
                    440:  * Targ_PrintType --
                    441:  *     Print out a type field giving only those attributes the user can
                    442:  *     set.
                    443:  *-----------------------------------------------------------------------
                    444:  */
                    445: void
1.27      espie     446: Targ_PrintType(type)
                    447:     int    type;
1.1       deraadt   448: {
1.27      espie     449:     int    tbit;
1.5       millert   450:
1.1       deraadt   451: #define PRINTBIT(attr) case CONCAT(OP_,attr): printf("." #attr " "); break
                    452: #define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG)) printf("." #attr " "); break
                    453:
                    454:     type &= ~OP_OPMASK;
                    455:
                    456:     while (type) {
                    457:        tbit = 1 << (ffs(type) - 1);
                    458:        type &= ~tbit;
                    459:
1.31      espie     460:        switch (tbit) {
1.1       deraadt   461:            PRINTBIT(OPTIONAL);
                    462:            PRINTBIT(USE);
                    463:            PRINTBIT(EXEC);
                    464:            PRINTBIT(IGNORE);
                    465:            PRINTBIT(PRECIOUS);
                    466:            PRINTBIT(SILENT);
                    467:            PRINTBIT(MAKE);
                    468:            PRINTBIT(JOIN);
                    469:            PRINTBIT(INVISIBLE);
                    470:            PRINTBIT(NOTMAIN);
                    471:            PRINTDBIT(LIB);
                    472:            /*XXX: MEMBER is defined, so CONCAT(OP_,MEMBER) gives OP_"%" */
                    473:            case OP_MEMBER: if (DEBUG(TARG)) printf(".MEMBER "); break;
                    474:            PRINTDBIT(ARCHV);
                    475:        }
                    476:     }
                    477: }
                    478:
                    479: /*-
                    480:  *-----------------------------------------------------------------------
                    481:  * TargPrintNode --
                    482:  *     print the contents of a node
                    483:  *-----------------------------------------------------------------------
                    484:  */
1.17      espie     485: static void
1.27      espie     486: TargPrintNode(gn, pass)
1.31      espie     487:     GNode        *gn;
                    488:     int          pass;
1.1       deraadt   489: {
                    490:     if (!OP_NOP(gn->type)) {
                    491:        printf("#\n");
1.31      espie     492:        if (gn == mainTarg) {
1.1       deraadt   493:            printf("# *** MAIN TARGET ***\n");
1.31      espie     494:        }
1.1       deraadt   495:        if (pass == 2) {
1.31      espie     496:            if (gn->unmade) {
1.1       deraadt   497:                printf("# %d unmade children\n", gn->unmade);
1.31      espie     498:            } else {
1.1       deraadt   499:                printf("# No unmade children\n");
1.31      espie     500:            }
1.1       deraadt   501:            if (! (gn->type & (OP_JOIN|OP_USE|OP_EXEC))) {
1.31      espie     502:                if (!is_out_of_date(gn->mtime)) {
1.1       deraadt   503:                    printf("# last modified %s: %s\n",
                    504:                              Targ_FmtTime(gn->mtime),
                    505:                              (gn->made == UNMADE ? "unmade" :
                    506:                               (gn->made == MADE ? "made" :
                    507:                                (gn->made == UPTODATE ? "up-to-date" :
                    508:                                 "error when made"))));
1.31      espie     509:                } else if (gn->made != UNMADE) {
1.1       deraadt   510:                    printf("# non-existent (maybe): %s\n",
                    511:                              (gn->made == MADE ? "made" :
                    512:                               (gn->made == UPTODATE ? "up-to-date" :
                    513:                                (gn->made == ERROR ? "error when made" :
                    514:                                 "aborted"))));
1.31      espie     515:                } else {
1.1       deraadt   516:                    printf("# unmade\n");
1.31      espie     517:                }
1.1       deraadt   518:            }
1.19      espie     519:            if (!Lst_IsEmpty(&gn->iParents)) {
1.1       deraadt   520:                printf("# implicit parents: ");
1.19      espie     521:                Lst_Every(&gn->iParents, TargPrintName);
1.17      espie     522:                fputc('\n', stdout);
1.1       deraadt   523:            }
                    524:        }
1.19      espie     525:        if (!Lst_IsEmpty(&gn->parents)) {
1.1       deraadt   526:            printf("# parents: ");
1.19      espie     527:            Lst_Every(&gn->parents, TargPrintName);
1.31      espie     528:            fputc('\n', stdout);
1.1       deraadt   529:        }
1.5       millert   530:
1.1       deraadt   531:        printf("%-16s", gn->name);
                    532:        switch (gn->type & OP_OPMASK) {
                    533:            case OP_DEPENDS:
                    534:                printf(": "); break;
                    535:            case OP_FORCE:
                    536:                printf("! "); break;
                    537:            case OP_DOUBLEDEP:
                    538:                printf(":: "); break;
                    539:        }
1.17      espie     540:        Targ_PrintType(gn->type);
1.19      espie     541:        Lst_Every(&gn->children, TargPrintName);
1.17      espie     542:        fputc('\n', stdout);
1.19      espie     543:        Lst_Every(&gn->commands, Targ_PrintCmd);
1.1       deraadt   544:        printf("\n\n");
1.27      espie     545:        if (gn->type & OP_DOUBLEDEP) {
                    546:            LstNode ln;
1.31      espie     547:
                    548:            for (ln = Lst_First(&gn->cohorts); ln != NULL; ln = Lst_Adv(ln))
1.27      espie     549:                    TargPrintNode((GNode *)Lst_Datum(ln), pass);
                    550:        }
1.1       deraadt   551:     }
                    552: }
                    553:
                    554: /*-
                    555:  *-----------------------------------------------------------------------
                    556:  * TargPrintOnlySrc --
1.31      espie     557:  *     Print targets that are just a source.
1.1       deraadt   558:  *-----------------------------------------------------------------------
                    559:  */
1.17      espie     560: static void
1.27      espie     561: TargPrintOnlySrc(gn)
1.31      espie     562:     GNode *gn;
1.1       deraadt   563: {
                    564:     if (OP_NOP(gn->type))
1.31      espie     565:        printf("#\t%s [%s]\n", gn->name,
                    566:            gn->path != NULL ? gn->path : gn->name);
1.1       deraadt   567: }
                    568:
                    569: /*-
                    570:  *-----------------------------------------------------------------------
                    571:  * Targ_PrintGraph --
1.27      espie     572:  *     print the entire graph.
1.1       deraadt   573:  *-----------------------------------------------------------------------
                    574:  */
                    575: void
1.27      espie     576: Targ_PrintGraph(pass)
1.31      espie     577:     int                pass;   /* Which pass this is. 1 => no processing
                    578:                                 * 2 => processing done */
1.1       deraadt   579: {
1.27      espie     580:     GNode              *gn;
                    581:     unsigned int       i;
                    582:
1.1       deraadt   583:     printf("#*** Input graph:\n");
1.31      espie     584:     for (gn = ohash_first(&targets, &i); gn != NULL;
1.30      espie     585:        gn = ohash_next(&targets, &i))
1.27      espie     586:            TargPrintNode(gn, pass);
1.1       deraadt   587:     printf("\n\n");
                    588:     printf("#\n#   Files that are only sources:\n");
1.31      espie     589:     for (gn = ohash_first(&targets, &i); gn != NULL;
1.30      espie     590:        gn = ohash_next(&targets, &i))
1.27      espie     591:                TargPrintOnlySrc(gn);
1.31      espie     592:     Var_Dump();
1.1       deraadt   593:     printf("\n");
1.32      espie     594: #ifdef DEBUG_DIRECTORY_CACHE
1.1       deraadt   595:     Dir_PrintDirectories();
                    596:     printf("\n");
1.32      espie     597: #endif
1.1       deraadt   598:     Suff_PrintAll();
                    599: }