VirtualBox

Changeset 24 in kBuild for branches/FREEBSD/src/kmk/make.c


Ignore:
Timestamp:
Nov 26, 2002 9:24:54 PM (22 years ago)
Author:
bird
Message:

Import of RELENG_4_7_0_RELEASE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/FREEBSD/src/kmk/make.c

    r10 r24  
    3535 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    3636 * SUCH DAMAGE.
    37  *
    38  * @(#)make.c   8.1 (Berkeley) 6/6/93
    39  */
    40 
    41 #include <sys/cdefs.h>
    42 __FBSDID("$FreeBSD: src/usr.bin/make/make.c,v 1.23 2002/10/09 03:42:10 jmallett Exp $");
     37 */
     38
     39#ifndef lint
     40#if 0
     41static char sccsid[] = "@(#)make.c      8.1 (Berkeley) 6/6/93";
     42#else
     43static const char rcsid[] =
     44  "$FreeBSD: src/usr.bin/make/make.c,v 1.11 1999/09/11 13:08:01 hoek Exp $";
     45#endif
     46#endif /* not lint */
    4347
    4448/*-
     
    8892                                 * TRUE, there's a cycle in the graph */
    8993
    90 static int MakeAddChild(void *, void *);
    91 static int MakeAddAllSrc(void *, void *);
    92 static int MakeTimeStamp(void *, void *);
    93 static int MakeHandleUse(void *, void *);
    94 static Boolean MakeStartJobs(void);
    95 static int MakePrintStatus(void *, void *);
     94static int MakeAddChild __P((ClientData, ClientData));
     95static int MakeAddAllSrc __P((ClientData, ClientData));
     96static int MakeTimeStamp __P((ClientData, ClientData));
     97static int MakeHandleUse __P((ClientData, ClientData));
     98static Boolean MakeStartJobs __P((void));
     99static int MakePrintStatus __P((ClientData, ClientData));
    96100/*-
    97101 *-----------------------------------------------------------------------
     
    109113 */
    110114int
    111 Make_TimeStamp (GNode *pgn, GNode *cgn)
     115Make_TimeStamp (pgn, cgn)
     116    GNode *pgn; /* the current parent */
     117    GNode *cgn; /* the child we've just examined */
    112118{
    113119    if (cgn->mtime > pgn->cmtime) {
     
    118124
    119125static int
    120 MakeTimeStamp (void *pgn, void *cgn)
     126MakeTimeStamp (pgn, cgn)
     127    ClientData pgn;     /* the current parent */
     128    ClientData cgn;     /* the child we've just examined */
    121129{
    122130    return Make_TimeStamp((GNode *) pgn, (GNode *) cgn);
     
    143151 */
    144152Boolean
    145 Make_OODate (GNode *gn)
     153Make_OODate (gn)
     154    register GNode *gn;       /* the node to check */
    146155{
    147156    Boolean         oodate;
     
    153162    if ((gn->type & (OP_JOIN|OP_USE|OP_EXEC)) == 0) {
    154163        (void) Dir_MTime (gn);
    155         if (gn->mtime != 0) {
    156             DEBUGF(MAKE, ("modified %s...", Targ_FmtTime(gn->mtime)));
    157         } else {
    158             DEBUGF(MAKE, ("non-existent..."));
     164        if (DEBUG(MAKE)) {
     165            if (gn->mtime != 0) {
     166                printf ("modified %s...", Targ_FmtTime(gn->mtime));
     167            } else {
     168                printf ("non-existent...");
     169            }
    159170        }
    160171    }
     
    179190         * no matter *what*.
    180191         */
    181         DEBUGF(MAKE, (".USE node..."));
     192        if (DEBUG(MAKE)) {
     193            printf(".USE node...");
     194        }
    182195        oodate = FALSE;
    183196    } else if (gn->type & OP_LIB) {
    184         DEBUGF(MAKE, ("library..."));
     197        if (DEBUG(MAKE)) {
     198            printf("library...");
     199        }
    185200
    186201        /*
     
    195210         * out-of-date if any of its children was out-of-date.
    196211         */
    197         DEBUGF(MAKE, (".JOIN node..."));
     212        if (DEBUG(MAKE)) {
     213            printf(".JOIN node...");
     214        }
    198215        oodate = gn->childMade;
    199216    } else if (gn->type & (OP_FORCE|OP_EXEC|OP_PHONY)) {
     
    202219         * the .EXEC attribute is always considered out-of-date.
    203220         */
    204         if (gn->type & OP_FORCE) {
    205             DEBUGF(MAKE, ("! operator..."));
    206         } else if (gn->type & OP_PHONY) {
    207             DEBUGF(MAKE, (".PHONY node..."));
    208         } else {
    209             DEBUGF(MAKE, (".EXEC node..."));
     221        if (DEBUG(MAKE)) {
     222            if (gn->type & OP_FORCE) {
     223                printf("! operator...");
     224            } else if (gn->type & OP_PHONY) {
     225                printf(".PHONY node...");
     226            } else {
     227                printf(".EXEC node...");
     228            }
    210229        }
    211230        oodate = TRUE;
     
    221240         * it.
    222241         */
    223         if (gn->mtime < gn->cmtime) {
    224             DEBUGF(MAKE, ("modified before source..."));
    225         } else if (gn->mtime == 0) {
    226             DEBUGF(MAKE, ("non-existent and no sources..."));
    227         } else {
    228             DEBUGF(MAKE, (":: operator and no sources..."));
     242        if (DEBUG(MAKE)) {
     243            if (gn->mtime < gn->cmtime) {
     244                printf("modified before source...");
     245            } else if (gn->mtime == 0) {
     246                printf("non-existent and no sources...");
     247            } else {
     248                printf(":: operator and no sources...");
     249            }
    229250        }
    230251        oodate = TRUE;
    231     } else
     252    } else {
     253#if 0
     254        /* WHY? */
     255        if (DEBUG(MAKE)) {
     256            printf("source %smade...", gn->childMade ? "" : "not ");
     257        }
     258        oodate = gn->childMade;
     259#else
    232260        oodate = FALSE;
     261#endif /* 0 */
     262    }
    233263
    234264    /*
     
    240270     */
    241271    if (!oodate) {
    242         Lst_ForEach (gn->parents, MakeTimeStamp, (void *)gn);
     272        Lst_ForEach (gn->parents, MakeTimeStamp, (ClientData)gn);
    243273    }
    244274
     
    261291 */
    262292static int
    263 MakeAddChild (void *gnp, void *lp)
     293MakeAddChild (gnp, lp)
     294    ClientData     gnp;         /* the node to add */
     295    ClientData     lp;          /* the list to which to add it */
    264296{
    265297    GNode          *gn = (GNode *) gnp;
     
    267299
    268300    if (!gn->make && !(gn->type & OP_USE)) {
    269         (void)Lst_EnQueue (l, (void *)gn);
     301        (void)Lst_EnQueue (l, (ClientData)gn);
    270302    }
    271303    return (0);
     
    297329 */
    298330int
    299 Make_HandleUse (GNode *cgn, GNode *pgn)
    300 {
    301     GNode       *gn;            /* A child of the .USE node */
    302     LstNode     ln;             /* An element in the children list */
     331Make_HandleUse (cgn, pgn)
     332    register GNode      *cgn;   /* The .USE node */
     333    register GNode      *pgn;   /* The target of the .USE node */
     334{
     335    register GNode      *gn;    /* A child of the .USE node */
     336    register LstNode    ln;     /* An element in the children list */
    303337
    304338    if (cgn->type & (OP_USE|OP_TRANSFORM)) {
     
    312346
    313347        if (Lst_Open (cgn->children) == SUCCESS) {
    314             while ((ln = Lst_Next (cgn->children)) != NULL) {
     348            while ((ln = Lst_Next (cgn->children)) != NILLNODE) {
    315349                gn = (GNode *)Lst_Datum (ln);
    316350
    317                 if (Lst_Member (pgn->children, gn) == NULL) {
     351                if (Lst_Member (pgn->children, gn) == NILLNODE) {
    318352                    (void) Lst_AtEnd (pgn->children, gn);
    319353                    (void) Lst_AtEnd (gn->parents, pgn);
     
    340374}
    341375static int
    342 MakeHandleUse (void *pgn, void *cgn)
     376MakeHandleUse (pgn, cgn)
     377    ClientData pgn;     /* the current parent */
     378    ClientData cgn;     /* the child we've just examined */
    343379{
    344380    return Make_HandleUse((GNode *) pgn, (GNode *) cgn);
     
    372408 */
    373409void
    374 Make_Update (GNode *cgn)
    375 {
    376     GNode       *pgn;           /* the parent node */
    377     char        *cname;         /* the child's name */
    378     LstNode     ln;             /* Element in parents and iParents lists */
    379     char        *p1;
     410Make_Update (cgn)
     411    register GNode *cgn;        /* the child node */
     412{
     413    register GNode      *pgn;   /* the parent node */
     414    register char       *cname; /* the child's name */
     415    register LstNode    ln;     /* Element in parents and iParents lists */
     416    char *p1;
    380417
    381418    cname = Var_Value (TARGET, cgn, &p1);
     
    443480            cgn->mtime = now;
    444481        }
    445         DEBUGF(MAKE, ("update time: %s\n", Targ_FmtTime(cgn->mtime)));
     482        if (DEBUG(MAKE)) {
     483            printf("update time: %s\n", Targ_FmtTime(cgn->mtime));
     484        }
    446485#endif
    447486    }
    448487
    449488    if (Lst_Open (cgn->parents) == SUCCESS) {
    450         while ((ln = Lst_Next (cgn->parents)) != NULL) {
     489        while ((ln = Lst_Next (cgn->parents)) != NILLNODE) {
    451490            pgn = (GNode *)Lst_Datum (ln);
    452491            if (pgn->make) {
     
    468507                     * be dealt with in MakeStartJobs.
    469508                     */
    470                     (void)Lst_EnQueue (toBeMade, (void *)pgn);
     509                    (void)Lst_EnQueue (toBeMade, (ClientData)pgn);
    471510                } else if (pgn->unmade < 0) {
    472511                    Error ("Graph cycles through %s", pgn->name);
     
    482521     * before.
    483522     */
    484     for (ln = Lst_First(cgn->successors); ln != NULL; ln = Lst_Succ(ln)) {
     523    for (ln = Lst_First(cgn->successors); ln != NILLNODE; ln = Lst_Succ(ln)) {
    485524        GNode   *succ = (GNode *)Lst_Datum(ln);
    486525
    487526        if (succ->make && succ->unmade == 0 && succ->made == UNMADE &&
    488             Lst_Member(toBeMade, (void *)succ) == NULL)
     527            Lst_Member(toBeMade, (ClientData)succ) == NILLNODE)
    489528        {
    490             (void)Lst_EnQueue(toBeMade, (void *)succ);
     529            (void)Lst_EnQueue(toBeMade, (ClientData)succ);
    491530        }
    492531    }
     
    497536     */
    498537    if (Lst_Open (cgn->iParents) == SUCCESS) {
    499         char    *ptr;
    500         char    *cpref = Var_Value(PREFIX, cgn, &ptr);
    501 
    502         while ((ln = Lst_Next (cgn->iParents)) != NULL) {
     538        char    *p1;
     539        char    *cpref = Var_Value(PREFIX, cgn, &p1);
     540
     541        while ((ln = Lst_Next (cgn->iParents)) != NILLNODE) {
    503542            pgn = (GNode *)Lst_Datum (ln);
    504543            if (pgn->make) {
     
    507546            }
    508547        }
    509         efree(ptr);
     548        efree(p1);
    510549        Lst_Close (cgn->iParents);
    511550    }
     
    534573 */
    535574static int
    536 MakeAddAllSrc (void *cgnp, void *pgnp)
     575MakeAddAllSrc (cgnp, pgnp)
     576    ClientData  cgnp;   /* The child to add */
     577    ClientData  pgnp;   /* The parent to whose ALLSRC variable it should be */
     578                        /* added */
    537579{
    538580    GNode       *cgn = (GNode *) cgnp;
     
    605647 */
    606648void
    607 Make_DoAllVar (GNode *gn)
    608 {
    609     Lst_ForEach (gn->children, MakeAddAllSrc, (void *) gn);
     649Make_DoAllVar (gn)
     650    GNode       *gn;
     651{
     652    Lst_ForEach (gn->children, MakeAddAllSrc, (ClientData) gn);
    610653
    611654    if (!Var_Exists (OODATE, gn)) {
     
    641684 */
    642685static Boolean
    643 MakeStartJobs (void)
    644 {
    645     GNode       *gn;
     686MakeStartJobs ()
     687{
     688    register GNode      *gn;
    646689
    647690    while (!Job_Full() && !Lst_IsEmpty (toBeMade)) {
    648691        gn = (GNode *) Lst_DeQueue (toBeMade);
    649         DEBUGF(MAKE, ("Examining %s...", gn->name));
     692        if (DEBUG(MAKE)) {
     693            printf ("Examining %s...", gn->name);
     694        }
    650695        /*
    651696         * Make sure any and all predecessors that are going to be made,
     
    655700            LstNode ln;
    656701
    657             for (ln = Lst_First(gn->preds); ln != NULL; ln = Lst_Succ(ln)){
     702            for (ln = Lst_First(gn->preds); ln != NILLNODE; ln = Lst_Succ(ln)){
    658703                GNode   *pgn = (GNode *)Lst_Datum(ln);
    659704
    660705                if (pgn->make && pgn->made == UNMADE) {
    661                     DEBUGF(MAKE, ("predecessor %s not made yet.\n", pgn->name));
     706                    if (DEBUG(MAKE)) {
     707                        printf("predecessor %s not made yet.\n", pgn->name);
     708                    }
    662709                    break;
    663710                }
    664711            }
    665712            /*
    666              * If ln isn't NULL, there's a predecessor as yet unmade, so we
     713             * If ln isn't nil, there's a predecessor as yet unmade, so we
    667714             * just drop this node on the floor. When the node in question
    668715             * has been made, it will notice this node as being ready to
    669716             * make but as yet unmade and will place the node on the queue.
    670717             */
    671             if (ln != NULL) {
     718            if (ln != NILLNODE) {
    672719                continue;
    673720            }
     
    676723        numNodes--;
    677724        if (Make_OODate (gn)) {
    678             DEBUGF(MAKE, ("out-of-date\n"));
     725            if (DEBUG(MAKE)) {
     726                printf ("out-of-date\n");
     727            }
    679728            if (queryFlag) {
    680729                return (TRUE);
     
    683732            Job_Make (gn);
    684733        } else {
    685             DEBUGF(MAKE, ("up-to-date\n"));
     734            if (DEBUG(MAKE)) {
     735                printf ("up-to-date\n");
     736            }
    686737            gn->made = UPTODATE;
    687738            if (gn->type & OP_JOIN) {
     
    707758 *      Print the status of a top-level node, viz. it being up-to-date
    708759 *      already or not created due to an error in a lower level.
    709  *      Callback function for Make_Run via Lst_ForEach.  If gn->unmade is
    710  *      nonzero and that is meant to imply a cycle in the graph, then
    711  *      cycle is TRUE.
     760 *      Callback function for Make_Run via Lst_ForEach.
    712761 *
    713762 * Results:
     
    720769 */
    721770static int
    722 MakePrintStatus(void *gnp, void *cyclep)
     771MakePrintStatus(gnp, cyclep)
     772    ClientData  gnp;        /* Node to examine */
     773    ClientData  cyclep;     /* True if gn->unmade being non-zero implies
     774                             * a cycle in the graph, not an error in an
     775                             * inferior */
    723776{
    724777    GNode       *gn = (GNode *) gnp;
     
    742795                Error("Graph cycles through `%s'", gn->name);
    743796                gn->made = ENDCYCLE;
    744                 Lst_ForEach(gn->children, MakePrintStatus, (void *) &t);
     797                Lst_ForEach(gn->children, MakePrintStatus, (ClientData) &t);
    745798                gn->made = UNMADE;
    746799            } else if (gn->made != ENDCYCLE) {
    747800                gn->made = CYCLE;
    748                 Lst_ForEach(gn->children, MakePrintStatus, (void *) &t);
     801                Lst_ForEach(gn->children, MakePrintStatus, (ClientData) &t);
    749802            }
    750803        } else {
     
    778831 */
    779832Boolean
    780 Make_Run (Lst targs)
    781 {
    782     GNode           *gn;        /* a temporary pointer */
    783     Lst             examine;    /* List of targets to examine */
     833Make_Run (targs)
     834    Lst             targs;      /* the initial list of targets */
     835{
     836    register GNode  *gn;        /* a temporary pointer */
     837    register Lst    examine;    /* List of targets to examine */
    784838    int             errors;     /* Number of errors the Job module reports */
    785839
     
    808862             * to make sure everything has commands that should...
    809863             */
    810             Lst_ForEach (gn->children, MakeHandleUse, (void *)gn);
     864            Lst_ForEach (gn->children, MakeHandleUse, (ClientData)gn);
    811865            Suff_FindDeps (gn);
    812866
    813867            if (gn->unmade != 0) {
    814                 Lst_ForEach (gn->children, MakeAddChild, (void *)examine);
     868                Lst_ForEach (gn->children, MakeAddChild, (ClientData)examine);
    815869            } else {
    816                 (void)Lst_EnQueue (toBeMade, (void *)gn);
     870                (void)Lst_EnQueue (toBeMade, (ClientData)gn);
    817871            }
    818872        }
     
    855909    }
    856910
    857     errors = Job_Finish();
     911    errors = Job_End();
    858912
    859913    /*
     
    862916     */
    863917    errors = ((errors == 0) && (numNodes != 0));
    864     Lst_ForEach(targs, MakePrintStatus, (void *) &errors);
     918    Lst_ForEach(targs, MakePrintStatus, (ClientData) &errors);
    865919
    866920    return (TRUE);
Note: See TracChangeset for help on using the changeset viewer.

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