[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.37

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