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

Diff for /src/usr.bin/make/make.c between version 1.5 and 1.6

version 1.5, 1997/04/01 07:28:17 version 1.6, 1997/04/28 01:52:38
Line 1 
Line 1 
 /*      $OpenBSD$       */  /*      $OpenBSD$       */
 /*      $NetBSD: make.c,v 1.14 1997/03/28 22:31:21 christos Exp $       */  /*      $NetBSD: make.c,v 1.10 1996/11/06 17:59:15 christos Exp $       */
   
 /*  /*
  * Copyright (c) 1988, 1989, 1990, 1993   * Copyright (c) 1988, 1989, 1990, 1993
Line 77 
Line 77 
  *   *
  *      Make_HandleUse          See if a child is a .USE node for a parent   *      Make_HandleUse          See if a child is a .USE node for a parent
  *                              and perform the .USE actions if so.   *                              and perform the .USE actions if so.
  *  
  *      Make_ExpandUse          Expand .USE nodes and return the new list of  
  *                              targets.  
  */   */
   
 #include    "make.h"  #include    "make.h"
Line 97 
Line 94 
                                  * TRUE, there's a cycle in the graph */                                   * TRUE, there's a cycle in the graph */
   
 static int MakeAddChild __P((ClientData, ClientData));  static int MakeAddChild __P((ClientData, ClientData));
 static int MakeFindChild __P((ClientData, ClientData));  
 static int MakeAddAllSrc __P((ClientData, ClientData));  static int MakeAddAllSrc __P((ClientData, ClientData));
 static int MakeTimeStamp __P((ClientData, ClientData));  static int MakeTimeStamp __P((ClientData, ClientData));
 static int MakeHandleUse __P((ClientData, ClientData));  static int MakeHandleUse __P((ClientData, ClientData));
Line 309 
Line 305 
   
 /*-  /*-
  *-----------------------------------------------------------------------   *-----------------------------------------------------------------------
  * MakeFindChild  --  
  *      Function used by Make_Run to find the pathname of a child  
  *      that was already made.  
  *  
  * Results:  
  *      Always returns 0  
  *  
  * Side Effects:  
  *      The path and mtime of the node and the cmtime of the parent are  
  *      updated  
  *-----------------------------------------------------------------------  
  */  
 static int  
 MakeFindChild (gnp, pgnp)  
     ClientData     gnp;         /* the node to find */  
     ClientData     pgnp;  
 {  
     GNode          *gn = (GNode *) gnp;  
     GNode          *pgn = (GNode *) pgnp;  
   
     (void) Dir_MTime(gn);  
     if (pgn->cmtime < gn->mtime)  
         pgn->cmtime = gn->mtime;  
     gn->made = UPTODATE;  
   
     return (0);  
 }  
   
 /*-  
  *-----------------------------------------------------------------------  
  * Make_HandleUse --   * Make_HandleUse --
  *      Function called by Make_Run and SuffApplyTransform on the downward   *      Function called by Make_Run and SuffApplyTransform on the downward
  *      pass to handle .USE and transformation nodes. A callback function   *      pass to handle .USE and transformation nodes. A callback function
Line 365 
Line 331 
     register GNode      *cgn;   /* The .USE node */      register GNode      *cgn;   /* The .USE node */
     register GNode      *pgn;   /* The target of the .USE node */      register GNode      *pgn;   /* The target of the .USE node */
 {  {
       register GNode      *gn;    /* A child of the .USE node */
     register LstNode    ln;     /* An element in the children list */      register LstNode    ln;     /* An element in the children list */
   
     if (cgn->type & (OP_USE|OP_TRANSFORM)) {      if (cgn->type & (OP_USE|OP_TRANSFORM)) {
Line 378 
Line 345 
   
         if (Lst_Open (cgn->children) == SUCCESS) {          if (Lst_Open (cgn->children) == SUCCESS) {
             while ((ln = Lst_Next (cgn->children)) != NILLNODE) {              while ((ln = Lst_Next (cgn->children)) != NILLNODE) {
                 register GNode *tgn, *gn = (GNode *)Lst_Datum (ln);                  gn = (GNode *)Lst_Datum (ln);
   
                 /*  
                  * Expand variables in the .USE node's name  
                  * and save the unexpanded form.  
                  * We don't need to do this for commands.  
                  * They get expanded properly when we execute.  
                  */  
                 if (gn->uname == NULL) {  
                     gn->uname = gn->name;  
                 } else {  
                     if (gn->name)  
                         free(gn->name);  
                 }  
                 gn->name = Var_Subst(NULL, gn->uname, pgn, FALSE);  
                 if (gn->name && gn->uname && strcmp(gn->name, gn->uname) != 0) {  
                     /* See if we have a target for this node. */  
                     tgn = Targ_FindNode(gn->name, TARG_NOCREATE);  
                     if (tgn != NILGNODE)  
                         gn = tgn;  
                 }  
   
                 if (Lst_Member (pgn->children, gn) == NILLNODE) {                  if (Lst_Member (pgn->children, gn) == NILLNODE) {
                     (void) Lst_AtEnd (pgn->children, gn);                      (void) Lst_AtEnd (pgn->children, gn);
                     (void) Lst_AtEnd (gn->parents, pgn);                      (void) Lst_AtEnd (gn->parents, pgn);
Line 418 
Line 365 
          * children the parent has. This is used by Make_Run to decide           * children the parent has. This is used by Make_Run to decide
          * whether to queue the parent or examine its children...           * whether to queue the parent or examine its children...
          */           */
         if ((cgn->type & OP_USE) &&          if (cgn->type & OP_USE) {
             (ln = Lst_Member (pgn->children, (ClientData) cgn)) != NILLNODE) {  
             Lst_Remove(pgn->children, ln);  
             pgn->unmade--;              pgn->unmade--;
         }          }
     }      }
Line 863 
Line 808 
   
 /*-  /*-
  *-----------------------------------------------------------------------   *-----------------------------------------------------------------------
  * Make_ExpandUse --   * Make_Run --
  *      Expand .USE nodes and create a new targets list   *      Initialize the nodes to remake and the list of nodes which are
    *      ready to be made by doing a breadth-first traversal of the graph
    *      starting from the nodes in the given list. Once this traversal
    *      is finished, all the 'leaves' of the graph are in the toBeMade
    *      queue.
    *      Using this queue and the Job module, work back up the graph,
    *      calling on MakeStartJobs to keep the job table as full as
    *      possible.
    *
  * Results:   * Results:
  *      The new list of targets.   *      TRUE if work was done. FALSE otherwise.
  *   *
  * Side Effects:   * Side Effects:
  *      numNodes is set to the number of elements in the list of targets.   *      The make field of all nodes involved in the creation of the given
    *      targets is set to 1. The toBeMade list is set to contain all the
    *      'leaves' of these subgraphs.
  *-----------------------------------------------------------------------   *-----------------------------------------------------------------------
  */   */
 Lst  Boolean
 Make_ExpandUse (targs)  Make_Run (targs)
     Lst             targs;      /* the initial list of targets */      Lst             targs;      /* the initial list of targets */
 {  {
     register GNode  *gn;        /* a temporary pointer */      register GNode  *gn;        /* a temporary pointer */
     register Lst    examine;    /* List of targets to examine */      register Lst    examine;    /* List of targets to examine */
     register Lst    ntargs;     /* List of new targets to be made */      int             errors;     /* Number of errors the Job module reports */
   
     ntargs = Lst_Init (FALSE);      toBeMade = Lst_Init (FALSE);
   
     examine = Lst_Duplicate(targs, NOCOPY);      examine = Lst_Duplicate(targs, NOCOPY);
     numNodes = 0;      numNodes = 0;
Line 903 
Line 858 
             /*              /*
              * Apply any .USE rules before looking for implicit dependencies               * Apply any .USE rules before looking for implicit dependencies
              * to make sure everything has commands that should...               * to make sure everything has commands that should...
              * Make sure that the TARGET is set, so that we can make  
              * expansions.  
              */               */
             Var_Set (TARGET, gn->name, gn);  
             Lst_ForEach (gn->children, MakeHandleUse, (ClientData)gn);              Lst_ForEach (gn->children, MakeHandleUse, (ClientData)gn);
             Suff_FindDeps (gn);              Suff_FindDeps (gn);
   
             if (gn->unmade != 0 && (gn->type & OP_MADE) == 0) {              if (gn->unmade != 0) {
                 Lst_ForEach (gn->children, MakeAddChild, (ClientData)examine);                  Lst_ForEach (gn->children, MakeAddChild, (ClientData)examine);
             } else {              } else {
                 (void)Lst_EnQueue (ntargs, (ClientData)gn);                  (void)Lst_EnQueue (toBeMade, (ClientData)gn);
                 if (gn->type & OP_MADE)  
                     Lst_ForEach (gn->children, MakeFindChild, (ClientData)gn);  
             }              }
         }          }
     }      }
   
     Lst_Destroy (examine, NOFREE);      Lst_Destroy (examine, NOFREE);
     return (ntargs);  
 }  
   
 /*-  
  *-----------------------------------------------------------------------  
  * Make_Run --  
  *      Initialize the nodes to remake and the list of nodes which are  
  *      ready to be made by doing a breadth-first traversal of the graph  
  *      starting from the nodes in the given list. Once this traversal  
  *      is finished, all the 'leaves' of the graph are in the toBeMade  
  *      queue.  
  *      Using this queue and the Job module, work back up the graph,  
  *      calling on MakeStartJobs to keep the job table as full as  
  *      possible.  
  *  
  * Results:  
  *      TRUE if work was done. FALSE otherwise.  
  *  
  * Side Effects:  
  *      The make field of all nodes involved in the creation of the given  
  *      targets is set to 1. The toBeMade list is set to contain all the  
  *      'leaves' of these subgraphs.  
  *-----------------------------------------------------------------------  
  */  
 Boolean  
 Make_Run (targs)  
     Lst             targs;      /* the initial list of targets */  
 {  
     int             errors;     /* Number of errors the Job module reports */  
   
     toBeMade = Make_ExpandUse (targs);  
   
     if (queryFlag) {      if (queryFlag) {
         /*          /*

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6