VirtualBox

Changeset 51 in kBuild for trunk/src/kmk/targ.c


Ignore:
Timestamp:
Apr 7, 2003 1:30:32 AM (22 years ago)
Author:
bird
Message:

kMk and porting to kLib.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/targ.c

    r47 r51  
    11/*
    22 * Copyright (c) 1988, 1989, 1990, 1993
    3  *      The Regents of the University of California.  All rights reserved.
     3 *      The Regents of the University of California.  All rights reserved.
    44 * Copyright (c) 1989 by Berkeley Softworks
    55 * All rights reserved.
     
    1818 * 3. All advertising materials mentioning features or use of this software
    1919 *    must display the following acknowledgement:
    20  *      This product includes software developed by the University of
    21  *      California, Berkeley and its contributors.
     20 *      This product includes software developed by the University of
     21 *      California, Berkeley and its contributors.
    2222 * 4. Neither the name of the University nor the names of its contributors
    2323 *    may be used to endorse or promote products derived from this software
     
    3939#ifndef lint
    4040#if 0
    41 static char sccsid[] = "@(#)targ.c      8.2 (Berkeley) 3/19/94";
     41static char sccsid[] = "@(#)targ.c      8.2 (Berkeley) 3/19/94";
    4242#else
    4343static const char rcsid[] =
    4444  "$FreeBSD: src/usr.bin/make/targ.c,v 1.10 1999/09/11 13:08:02 hoek Exp $";
    4545#endif
     46#define KLIBFILEDEF rcsid
    4647#endif /* not lint */
    4748
    4849/*-
    4950 * targ.c --
    50  *      Functions for maintaining the Lst allTargets. Target nodes are
     51 *      Functions for maintaining the Lst allTargets. Target nodes are
    5152 * kept in two structures: a Lst, maintained by the list library, and a
    5253 * hash table, maintained by the hash library.
    5354 *
    5455 * Interface:
    55  *      Targ_Init               Initialization procedure.
    56  *
    57  *      Targ_End                Cleanup the module
    58  *
    59  *      Targ_NewGN              Create a new GNode for the passed target
    60  *                              (string). The node is *not* placed in the
    61  *                              hash table, though all its fields are
    62  *                              initialized.
    63  *
    64  *      Targ_FindNode           Find the node for a given target, creating
    65  *                              and storing it if it doesn't exist and the
    66  *                              flags are right (TARG_CREATE)
    67  *
    68  *      Targ_FindList           Given a list of names, find nodes for all
    69  *                              of them. If a name doesn't exist and the
    70  *                              TARG_NOCREATE flag was given, an error message
    71  *                              is printed. Else, if a name doesn't exist,
    72  *                              its node is created.
    73  *
    74  *      Targ_Ignore             Return TRUE if errors should be ignored when
    75  *                              creating the given target.
    76  *
    77  *      Targ_Silent             Return TRUE if we should be silent when
    78  *                              creating the given target.
    79  *
    80  *      Targ_Precious           Return TRUE if the target is precious and
    81  *                              should not be removed if we are interrupted.
     56 *      Targ_Init               Initialization procedure.
     57 *
     58 *      Targ_End                Cleanup the module
     59 *
     60 *      Targ_NewGN              Create a new GNode for the passed target
     61 *                              (string). The node is *not* placed in the
     62 *                              hash table, though all its fields are
     63 *                              initialized.
     64 *
     65 *      Targ_FindNode           Find the node for a given target, creating
     66 *                              and storing it if it doesn't exist and the
     67 *                              flags are right (TARG_CREATE)
     68 *
     69 *      Targ_FindList           Given a list of names, find nodes for all
     70 *                              of them. If a name doesn't exist and the
     71 *                              TARG_NOCREATE flag was given, an error message
     72 *                              is printed. Else, if a name doesn't exist,
     73 *                              its node is created.
     74 *
     75 *      Targ_Ignore             Return TRUE if errors should be ignored when
     76 *                              creating the given target.
     77 *
     78 *      Targ_Silent             Return TRUE if we should be silent when
     79 *                              creating the given target.
     80 *
     81 *      Targ_Precious           Return TRUE if the target is precious and
     82 *                              should not be removed if we are interrupted.
    8283 *
    8384 * Debugging:
    84  *      Targ_PrintGraph         Print out the entire graphm all variables
    85  *                              and statistics for the directory cache. Should
    86  *                              print something for suffixes, too, but...
    87  */
    88 
    89 #include          <stdio.h>
    90 #include          <time.h>
    91 #include          "make.h"
    92 #include          "hash.h"
    93 #include          "dir.h"
    94 
    95 static Lst        allTargets;   /* the list of all targets found so far */
    96 static Lst        allGNs;       /* List of all the GNodes */
    97 static Hash_Table targets;      /* a hash table of same */
    98 
    99 #define HTSIZE  191             /* initial size of hash table */
     85 *      Targ_PrintGraph         Print out the entire graphm all variables
     86 *                              and statistics for the directory cache. Should
     87 *                              print something for suffixes, too, but...
     88 */
     89
     90#include          <stdio.h>
     91#include          <time.h>
     92#include          <strings.h>
     93#include          "make.h"
     94#include          "hash.h"
     95#include          "dir.h"
     96
     97static Lst        allTargets;   /* the list of all targets found so far */
     98static Lst        allGNs;       /* List of all the GNodes */
     99static Hash_Table targets;      /* a hash table of same */
     100
     101#define HTSIZE  191             /* initial size of hash table */
    100102
    101103static int TargPrintOnlySrc __P((ClientData, ClientData));
     
    107109 *-----------------------------------------------------------------------
    108110 * Targ_Init --
    109  *      Initialize this module
    110  *
    111  * Results:
    112  *      None
    113  *
    114  * Side Effects:
    115  *      The allTargets list and the targets hash table are initialized
     111 *      Initialize this module
     112 *
     113 * Results:
     114 *      None
     115 *
     116 * Side Effects:
     117 *      The allTargets list and the targets hash table are initialized
    116118 *-----------------------------------------------------------------------
    117119 */
     
    126128 *-----------------------------------------------------------------------
    127129 * Targ_End --
    128  *      Finalize this module
    129  *
    130  * Results:
    131  *      None
    132  *
    133  * Side Effects:
    134  *      All lists and gnodes are cleared
     130 *      Finalize this module
     131 *
     132 * Results:
     133 *      None
     134 *
     135 * Side Effects:
     136 *      All lists and gnodes are cleared
    135137 *-----------------------------------------------------------------------
    136138 */
     
    140142    Lst_Destroy(allTargets, NOFREE);
    141143    if (allGNs)
    142         Lst_Destroy(allGNs, TargFreeGN);
     144        Lst_Destroy(allGNs, TargFreeGN);
    143145    Hash_DeleteTable(&targets);
    144146}
     
    147149 *-----------------------------------------------------------------------
    148150 * Targ_NewGN  --
    149  *      Create and initialize a new graph node
    150  *
    151  * Results:
    152  *      An initialized graph node with the name field filled with a copy
    153  *      of the passed name
    154  *
    155  * Side Effects:
    156  *      The gnode is added to the list of all gnodes.
     151 *      Create and initialize a new graph node
     152 *
     153 * Results:
     154 *      An initialized graph node with the name field filled with a copy
     155 *      of the passed name
     156 *
     157 * Side Effects:
     158 *      The gnode is added to the list of all gnodes.
    157159 *-----------------------------------------------------------------------
    158160 */
    159161GNode *
    160162Targ_NewGN (name)
    161     char           *name;       /* the name to stick in the new node */
     163    char           *name;       /* the name to stick in the new node */
    162164{
    163165    register GNode *gn;
     
    168170#ifdef USE_ARCHIVES
    169171    if (name[0] == '-' && name[1] == 'l') {
    170         gn->type = OP_LIB;
     172        gn->type = OP_LIB;
    171173    } else {
    172         gn->type = 0;
     174        gn->type = 0;
    173175    }
    174176#else
    175177    gn->type = 0;
    176178#endif
    177     gn->unmade =        0;
    178     gn->make =          FALSE;
    179     gn->made =          UNMADE;
    180     gn->childMade =     FALSE;
    181     gn->order =         0;
     179    gn->unmade =        0;
     180    gn->make =          FALSE;
     181    gn->made =          UNMADE;
     182    gn->childMade =     FALSE;
     183    gn->order =         0;
    182184    gn->mtime = gn->cmtime = 0;
    183     gn->iParents =      Lst_Init (FALSE);
    184     gn->cohorts =       Lst_Init (FALSE);
    185     gn->parents =       Lst_Init (FALSE);
    186     gn->children =      Lst_Init (FALSE);
    187     gn->successors =    Lst_Init (FALSE);
    188     gn->preds =         Lst_Init (FALSE);
    189     gn->context =       Lst_Init (FALSE);
    190     gn->commands =      Lst_Init (FALSE);
    191     gn->suffix =        NULL;
     185    gn->iParents =      Lst_Init (FALSE);
     186    gn->cohorts =       Lst_Init (FALSE);
     187    gn->parents =       Lst_Init (FALSE);
     188    gn->children =      Lst_Init (FALSE);
     189    gn->successors =    Lst_Init (FALSE);
     190    gn->preds =         Lst_Init (FALSE);
     191    gn->context =       Lst_Init (FALSE);
     192    gn->commands =      Lst_Init (FALSE);
     193    gn->suffix =        NULL;
    192194
    193195    if (allGNs == NULL)
    194         allGNs = Lst_Init(FALSE);
     196        allGNs = Lst_Init(FALSE);
    195197    Lst_AtEnd(allGNs, (ClientData) gn);
    196198
     
    201203 *-----------------------------------------------------------------------
    202204 * TargFreeGN  --
    203  *      Destroy a GNode
    204  *
    205  * Results:
    206  *      None.
    207  *
    208  * Side Effects:
    209  *      None.
     205 *      Destroy a GNode
     206 *
     207 * Results:
     208 *      None.
     209 *
     210 * Side Effects:
     211 *      None.
    210212 *-----------------------------------------------------------------------
    211213 */
     
    235237 *-----------------------------------------------------------------------
    236238 * Targ_FindNode  --
    237  *      Find a node in the list using the given name for matching
    238  *
    239  * Results:
    240  *      The node in the list if it was. If it wasn't, return NILGNODE of
    241  *      flags was TARG_NOCREATE or the newly created and initialized node
    242  *      if it was TARG_CREATE
    243  *
    244  * Side Effects:
    245  *      Sometimes a node is created and added to the list
     239 *      Find a node in the list using the given name for matching
     240 *
     241 * Results:
     242 *      The node in the list if it was. If it wasn't, return NILGNODE of
     243 *      flags was TARG_NOCREATE or the newly created and initialized node
     244 *      if it was TARG_CREATE
     245 *
     246 * Side Effects:
     247 *      Sometimes a node is created and added to the list
    246248 *-----------------------------------------------------------------------
    247249 */
    248250GNode *
    249251Targ_FindNode (name, flags)
    250     char           *name;       /* the name to find */
    251     int             flags;      /* flags governing events when target not
    252                                 * found */
    253 {
    254     GNode         *gn;        /* node in that element */
    255     Hash_Entry    *he;        /* New or used hash entry for node */
    256     Boolean       isNew;      /* Set TRUE if Hash_CreateEntry had to create */
    257                               /* an entry for the node */
     252    char           *name;       /* the name to find */
     253    int             flags;      /* flags governing events when target not
     254                                * found */
     255{
     256    GNode         *gn;        /* node in that element */
     257    Hash_Entry    *he;        /* New or used hash entry for node */
     258    Boolean       isNew;      /* Set TRUE if Hash_CreateEntry had to create */
     259                              /* an entry for the node */
    258260
    259261
    260262    if (flags & TARG_CREATE) {
    261         he = Hash_CreateEntry (&targets, name, &isNew);
    262         if (isNew) {
    263             gn = Targ_NewGN (name);
    264             Hash_SetValue (he, gn);
    265             (void) Lst_AtEnd (allTargets, (ClientData)gn);
    266         }
     263        he = Hash_CreateEntry (&targets, name, &isNew);
     264        if (isNew) {
     265            gn = Targ_NewGN (name);
     266            Hash_SetValue (he, gn);
     267            (void) Lst_AtEnd (allTargets, (ClientData)gn);
     268        }
    267269    } else {
    268         he = Hash_FindEntry (&targets, name);
     270        he = Hash_FindEntry (&targets, name);
    269271    }
    270272
    271273    if (he == (Hash_Entry *) NULL) {
    272         return (NILGNODE);
     274        return (NILGNODE);
    273275    } else {
    274         return ((GNode *) Hash_GetValue (he));
     276        return ((GNode *) Hash_GetValue (he));
    275277    }
    276278}
     
    279281 *-----------------------------------------------------------------------
    280282 * Targ_FindList --
    281  *      Make a complete list of GNodes from the given list of names
    282  *
    283  * Results:
    284  *      A complete list of graph nodes corresponding to all instances of all
    285  *      the names in names.
    286  *
    287  * Side Effects:
    288  *      If flags is TARG_CREATE, nodes will be created for all names in
    289  *      names which do not yet have graph nodes. If flags is TARG_NOCREATE,
    290  *      an error message will be printed for each name which can't be found.
     283 *      Make a complete list of GNodes from the given list of names
     284 *
     285 * Results:
     286 *      A complete list of graph nodes corresponding to all instances of all
     287 *      the names in names.
     288 *
     289 * Side Effects:
     290 *      If flags is TARG_CREATE, nodes will be created for all names in
     291 *      names which do not yet have graph nodes. If flags is TARG_NOCREATE,
     292 *      an error message will be printed for each name which can't be found.
    291293 * -----------------------------------------------------------------------
    292294 */
    293295Lst
    294296Targ_FindList (names, flags)
    295     Lst            names;       /* list of names to find */
    296     int            flags;       /* flags used if no node is found for a given
    297                                 * name */
    298 {
    299     Lst            nodes;       /* result list */
    300     register LstNode  ln;               /* name list element */
    301     register GNode *gn;         /* node in tLn */
    302     char          *name;
     297    Lst            names;       /* list of names to find */
     298    int            flags;       /* flags used if no node is found for a given
     299                                * name */
     300{
     301    Lst            nodes;       /* result list */
     302    register LstNode  ln;               /* name list element */
     303    register GNode *gn;         /* node in tLn */
     304    char          *name;
    303305
    304306    nodes = Lst_Init (FALSE);
    305307
    306308    if (Lst_Open (names) == FAILURE) {
    307         return (nodes);
     309        return (nodes);
    308310    }
    309311    while ((ln = Lst_Next (names)) != NILLNODE) {
    310         name = (char *)Lst_Datum(ln);
    311         gn = Targ_FindNode (name, flags);
    312         if (gn != NILGNODE) {
    313             /*
    314              * Note: Lst_AtEnd must come before the Lst_Concat so the nodes
    315              * are added to the list in the order in which they were
    316              * encountered in the makefile.
    317              */
    318             (void) Lst_AtEnd (nodes, (ClientData)gn);
    319             if (gn->type & OP_DOUBLEDEP) {
    320                 (void)Lst_Concat (nodes, gn->cohorts, LST_CONCNEW);
    321             }
    322         } else if (flags == TARG_NOCREATE) {
    323             Error ("\"%s\" -- target unknown.", name);
    324         }
     312        name = (char *)Lst_Datum(ln);
     313        gn = Targ_FindNode (name, flags);
     314        if (gn != NILGNODE) {
     315            /*
     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.
     319             */
     320            (void) Lst_AtEnd (nodes, (ClientData)gn);
     321            if (gn->type & OP_DOUBLEDEP) {
     322                (void)Lst_Concat (nodes, gn->cohorts, LST_CONCNEW);
     323            }
     324        } else if (flags == TARG_NOCREATE) {
     325            Error ("\"%s\" -- target unknown.", name);
     326        }
    325327    }
    326328    Lst_Close (names);
     
    331333 *-----------------------------------------------------------------------
    332334 * Targ_Ignore  --
    333  *      Return true if should ignore errors when creating gn
    334  *
    335  * Results:
    336  *      TRUE if should ignore errors
    337  *
    338  * Side Effects:
    339  *      None
     335 *      Return true if should ignore errors when creating gn
     336 *
     337 * Results:
     338 *      TRUE if should ignore errors
     339 *
     340 * Side Effects:
     341 *      None
    340342 *-----------------------------------------------------------------------
    341343 */
    342344Boolean
    343345Targ_Ignore (gn)
    344     GNode          *gn;         /* node to check for */
     346    GNode          *gn;         /* node to check for */
    345347{
    346348    if (ignoreErrors || gn->type & OP_IGNORE) {
    347         return (TRUE);
     349        return (TRUE);
    348350    } else {
    349         return (FALSE);
     351        return (FALSE);
    350352    }
    351353}
     
    354356 *-----------------------------------------------------------------------
    355357 * Targ_Silent  --
    356  *      Return true if be silent when creating gn
    357  *
    358  * Results:
    359  *      TRUE if should be silent
    360  *
    361  * Side Effects:
    362  *      None
     358 *      Return true if be silent when creating gn
     359 *
     360 * Results:
     361 *      TRUE if should be silent
     362 *
     363 * Side Effects:
     364 *      None
    363365 *-----------------------------------------------------------------------
    364366 */
    365367Boolean
    366368Targ_Silent (gn)
    367     GNode          *gn;         /* node to check for */
     369    GNode          *gn;         /* node to check for */
    368370{
    369371    if (beSilent || gn->type & OP_SILENT) {
    370         return (TRUE);
     372        return (TRUE);
    371373    } else {
    372         return (FALSE);
     374        return (FALSE);
    373375    }
    374376}
     
    377379 *-----------------------------------------------------------------------
    378380 * Targ_Precious --
    379  *      See if the given target is precious
    380  *
    381  * Results:
    382  *      TRUE if it is precious. FALSE otherwise
    383  *
    384  * Side Effects:
    385  *      None
     381 *      See if the given target is precious
     382 *
     383 * Results:
     384 *      TRUE if it is precious. FALSE otherwise
     385 *
     386 * Side Effects:
     387 *      None
    386388 *-----------------------------------------------------------------------
    387389 */
    388390Boolean
    389391Targ_Precious (gn)
    390     GNode          *gn;         /* the node to check */
     392    GNode          *gn;         /* the node to check */
    391393{
    392394    if (allPrecious || (gn->type & (OP_PRECIOUS|OP_DOUBLEDEP))) {
    393         return (TRUE);
     395        return (TRUE);
    394396    } else {
    395         return (FALSE);
     397        return (FALSE);
    396398    }
    397399}
     
    399401/******************* DEBUG INFO PRINTING ****************/
    400402
    401 static GNode      *mainTarg;    /* the main target, as set by Targ_SetMain */
     403static GNode      *mainTarg;    /* the main target, as set by Targ_SetMain */
    402404/*-
    403405 *-----------------------------------------------------------------------
    404406 * Targ_SetMain --
    405  *      Set our idea of the main target we'll be creating. Used for
    406  *      debugging output.
    407  *
    408  * Results:
    409  *      None.
    410  *
    411  * Side Effects:
    412  *      "mainTarg" is set to the main target's node.
     407 *      Set our idea of the main target we'll be creating. Used for
     408 *      debugging output.
     409 *
     410 * Results:
     411 *      None.
     412 *
     413 * Side Effects:
     414 *      "mainTarg" is set to the main target's node.
    413415 *-----------------------------------------------------------------------
    414416 */
    415417void
    416418Targ_SetMain (gn)
    417     GNode   *gn;        /* The main target we'll create */
     419    GNode   *gn;        /* The main target we'll create */
    418420{
    419421    mainTarg = gn;
     
    423425TargPrintName (gnp, ppath)
    424426    ClientData     gnp;
    425     ClientData      ppath;
     427    ClientData      ppath;
    426428{
    427429    GNode *gn = (GNode *) gnp;
     
    429431#ifdef notdef
    430432    if (ppath) {
    431         if (gn->path) {
    432             printf ("[%s]  ", gn->path);
    433         }
    434         if (gn == mainTarg) {
    435             printf ("(MAIN NAME)  ");
    436         }
     433        if (gn->path) {
     434            printf ("[%s]  ", gn->path);
     435        }
     436        if (gn == mainTarg) {
     437            printf ("(MAIN NAME)  ");
     438        }
    437439    }
    438440#endif /* notdef */
     
    453455 *-----------------------------------------------------------------------
    454456 * Targ_FmtTime --
    455  *      Format a modification time in some reasonable way and return it.
    456  *
    457  * Results:
    458  *      The time reformatted.
    459  *
    460  * Side Effects:
    461  *      The time is placed in a static area, so it is overwritten
    462  *      with each call.
     457 *      Format a modification time in some reasonable way and return it.
     458 *
     459 * Results:
     460 *      The time reformatted.
     461 *
     462 * Side Effects:
     463 *      The time is placed in a static area, so it is overwritten
     464 *      with each call.
    463465 *
    464466 *-----------------------------------------------------------------------
     
    468470    time_t    time;
    469471{
    470     struct tm           *parts;
    471     static char         buf[128];
     472    struct tm           *parts;
     473    static char         buf[128];
    472474
    473475    parts = localtime(&time);
     
    487489 *-----------------------------------------------------------------------
    488490 * Targ_PrintType --
    489  *      Print out a type field giving only those attributes the user can
    490  *      set.
     491 *      Print out a type field giving only those attributes the user can
     492 *      set.
    491493 *
    492494 * Results:
     
    502504    register int    tbit;
    503505
    504 #ifdef __STDC__
    505 #define PRINTBIT(attr)  case CONCAT(OP_,attr): printf("." #attr " "); break
     506#if defined(__STDC__) || defined(__IBMC__)
     507#define PRINTBIT(attr)  case CONCAT(OP_,attr): printf("." #attr " "); break
    506508#define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG)) printf("." #attr " "); break
    507509#else
    508 #define PRINTBIT(attr)  case CONCAT(OP_,attr): printf(".attr "); break
    509 #define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG)) printf(".attr "); break
     510#define PRINTBIT(attr)  case CONCAT(OP_,attr): printf(".attr "); break
     511#define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG)) printf(".attr "); break
    510512#endif /* __STDC__ */
    511513
     
    513515
    514516    while (type) {
    515         tbit = 1 << (ffs(type) - 1);
    516         type &= ~tbit;
    517 
    518         switch(tbit) {
    519             PRINTBIT(OPTIONAL);
    520             PRINTBIT(USE);
    521             PRINTBIT(EXEC);
    522             PRINTBIT(IGNORE);
    523             PRINTBIT(PRECIOUS);
    524             PRINTBIT(SILENT);
    525             PRINTBIT(MAKE);
    526             PRINTBIT(JOIN);
    527             PRINTBIT(INVISIBLE);
    528             PRINTBIT(NOTMAIN);
     517        tbit = 1 << (ffs(type) - 1);
     518        type &= ~tbit;
     519
     520        switch(tbit) {
     521            PRINTBIT(OPTIONAL);
     522            PRINTBIT(USE);
     523            PRINTBIT(EXEC);
     524            PRINTBIT(IGNORE);
     525            PRINTBIT(PRECIOUS);
     526            PRINTBIT(SILENT);
     527            PRINTBIT(MAKE);
     528            PRINTBIT(JOIN);
     529            PRINTBIT(INVISIBLE);
     530            PRINTBIT(NOTMAIN);
    529531#ifdef USE_ARCHIVES
    530             PRINTDBIT(LIB);
     532            PRINTDBIT(LIB);
    531533            /*XXX: MEMBER is defined, so CONCAT(OP_,MEMBER) gives OP_"%" */
    532             case OP_MEMBER: if (DEBUG(TARG)) printf(".MEMBER "); break;
    533             PRINTDBIT(ARCHV);
     534            case OP_MEMBER: if (DEBUG(TARG)) printf(".MEMBER "); break;
     535            PRINTDBIT(ARCHV);
    534536#endif
    535         }
     537        }
    536538    }
    537539}
     
    540542 *-----------------------------------------------------------------------
    541543 * TargPrintNode --
    542  *      print the contents of a node
     544 *      print the contents of a node
    543545 *-----------------------------------------------------------------------
    544546 */
     
    546548TargPrintNode (gnp, passp)
    547549    ClientData   gnp;
    548     ClientData  passp;
     550    ClientData  passp;
    549551{
    550552    GNode         *gn = (GNode *) gnp;
    551     int           pass = *(int *) passp;
     553    int           pass = *(int *) passp;
    552554    if (!OP_NOP(gn->type)) {
    553         printf("#\n");
    554         if (gn == mainTarg) {
    555             printf("# *** MAIN TARGET ***\n");
    556         }
    557         if (pass == 2) {
    558             if (gn->unmade) {
    559                 printf("# %d unmade children\n", gn->unmade);
    560             } else {
    561                 printf("# No unmade children\n");
    562             }
    563             if (! (gn->type & (OP_JOIN|OP_USE|OP_EXEC))) {
    564                 if (gn->mtime != 0) {
    565                     printf("# last modified %s: %s\n",
    566                               Targ_FmtTime(gn->mtime),
    567                               (gn->made == UNMADE ? "unmade" :
    568                                (gn->made == MADE ? "made" :
    569                                 (gn->made == UPTODATE ? "up-to-date" :
    570                                 "error when made"))));
    571                 } else if (gn->made != UNMADE) {
    572                     printf("# non-existent (maybe): %s\n",
    573                               (gn->made == MADE ? "made" :
    574                                (gn->made == UPTODATE ? "up-to-date" :
    575                                 (gn->made == ERROR ? "error when made" :
    576                                 "aborted"))));
    577                 } else {
    578                     printf("# unmade\n");
    579                 }
    580             }
    581             if (!Lst_IsEmpty (gn->iParents)) {
    582                 printf("# implicit parents: ");
    583                 Lst_ForEach (gn->iParents, TargPrintName, (ClientData)0);
    584                 fputc ('\n', stdout);
    585             }
    586         }
    587         if (!Lst_IsEmpty (gn->parents)) {
    588             printf("# parents: ");
    589             Lst_ForEach (gn->parents, TargPrintName, (ClientData)0);
    590             fputc ('\n', stdout);
    591         }
    592 
    593         printf("%-16s", gn->name);
    594         switch (gn->type & OP_OPMASK) {
    595             case OP_DEPENDS:
    596                 printf(": "); break;
    597             case OP_FORCE:
    598                 printf("! "); break;
    599             case OP_DOUBLEDEP:
    600                 printf(":: "); break;
    601         }
    602         Targ_PrintType (gn->type);
    603         Lst_ForEach (gn->children, TargPrintName, (ClientData)0);
    604         fputc ('\n', stdout);
    605         Lst_ForEach (gn->commands, Targ_PrintCmd, (ClientData)0);
    606         printf("\n\n");
    607         if (gn->type & OP_DOUBLEDEP) {
    608             Lst_ForEach (gn->cohorts, TargPrintNode, (ClientData)&pass);
    609         }
     555        printf("#\n");
     556        if (gn == mainTarg) {
     557            printf("# *** MAIN TARGET ***\n");
     558        }
     559        if (pass == 2) {
     560            if (gn->unmade) {
     561                printf("# %d unmade children\n", gn->unmade);
     562            } else {
     563                printf("# No unmade children\n");
     564            }
     565            if (! (gn->type & (OP_JOIN|OP_USE|OP_EXEC))) {
     566                if (gn->mtime != 0) {
     567                    printf("# last modified %s: %s\n",
     568                              Targ_FmtTime(gn->mtime),
     569                              (gn->made == UNMADE ? "unmade" :
     570                               (gn->made == MADE ? "made" :
     571                                (gn->made == UPTODATE ? "up-to-date" :
     572                                "error when made"))));
     573                } else if (gn->made != UNMADE) {
     574                    printf("# non-existent (maybe): %s\n",
     575                              (gn->made == MADE ? "made" :
     576                               (gn->made == UPTODATE ? "up-to-date" :
     577                                (gn->made == ERROR ? "error when made" :
     578                                "aborted"))));
     579                } else {
     580                    printf("# unmade\n");
     581                }
     582            }
     583            if (!Lst_IsEmpty (gn->iParents)) {
     584                printf("# implicit parents: ");
     585                Lst_ForEach (gn->iParents, TargPrintName, (ClientData)0);
     586                fputc ('\n', stdout);
     587            }
     588        }
     589        if (!Lst_IsEmpty (gn->parents)) {
     590            printf("# parents: ");
     591            Lst_ForEach (gn->parents, TargPrintName, (ClientData)0);
     592            fputc ('\n', stdout);
     593        }
     594
     595        printf("%-16s", gn->name);
     596        switch (gn->type & OP_OPMASK) {
     597            case OP_DEPENDS:
     598                printf(": "); break;
     599            case OP_FORCE:
     600                printf("! "); break;
     601            case OP_DOUBLEDEP:
     602                printf(":: "); break;
     603        }
     604        Targ_PrintType (gn->type);
     605        Lst_ForEach (gn->children, TargPrintName, (ClientData)0);
     606        fputc ('\n', stdout);
     607        Lst_ForEach (gn->commands, Targ_PrintCmd, (ClientData)0);
     608        printf("\n\n");
     609        if (gn->type & OP_DOUBLEDEP) {
     610            Lst_ForEach (gn->cohorts, TargPrintNode, (ClientData)&pass);
     611        }
    610612    }
    611613    return (0);
     
    615617 *-----------------------------------------------------------------------
    616618 * TargPrintOnlySrc --
    617  *      Print only those targets that are just a source.
    618  *
    619  * Results:
    620  *      0.
    621  *
    622  * Side Effects:
    623  *      The name of each file is printed preceeded by #\t
     619 *      Print only those targets that are just a source.
     620 *
     621 * Results:
     622 *      0.
     623 *
     624 * Side Effects:
     625 *      The name of each file is printed preceeded by #\t
    624626 *
    625627 *-----------------------------------------------------------------------
     
    627629static int
    628630TargPrintOnlySrc(gnp, dummy)
    629     ClientData    gnp;
    630     ClientData    dummy;
    631 {
    632     GNode         *gn = (GNode *) gnp;
     631    ClientData    gnp;
     632    ClientData    dummy;
     633{
     634    GNode         *gn = (GNode *) gnp;
    633635    if (OP_NOP(gn->type))
    634         printf("#\t%s [%s]\n", gn->name, gn->path ? gn->path : gn->name);
     636        printf("#\t%s [%s]\n", gn->name, gn->path ? gn->path : gn->name);
    635637
    636638    return (dummy ? 0 : 0);
     
    640642 *-----------------------------------------------------------------------
    641643 * Targ_PrintGraph --
    642  *      print the entire graph. heh heh
    643  *
    644  * Results:
    645  *      none
    646  *
    647  * Side Effects:
    648  *      lots o' output
     644 *      print the entire graph. heh heh
     645 *
     646 * Results:
     647 *      none
     648 *
     649 * Side Effects:
     650 *      lots o' output
    649651 *-----------------------------------------------------------------------
    650652 */
    651653void
    652654Targ_PrintGraph (pass)
    653     int     pass;       /* Which pass this is. 1 => no processing
    654                         * 2 => processing done */
     655    int     pass;       /* Which pass this is. 1 => no processing
     656                        * 2 => processing done */
    655657{
    656658    printf("#*** Input graph:\n");
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette