Annotation of researchv10no/cmd/mk/src/recipe.c, revision 1.1.1.1

1.1       root        1: #include       "mk.h"
                      2: 
                      3: dorecipe(node)
                      4:        Node *node;
                      5: {
                      6:        char buf[BIGBLOCK];
                      7:        register Node *n;
                      8:        Rule *r = 0;
                      9:        Arc *a, *aa;
                     10:        Word head, ahead, lp, ln, *w, *ww, *aw;
                     11:        Symtab *s;
                     12:        int did = 0;
                     13:        regexp rmatch[NREGEXP];
                     14: 
                     15:        /*
                     16:                pick up the rule
                     17:        */
                     18:        for(a = node->prereqs; a; a = a->next)
                     19:                if(*a->r->recipe)
                     20:                        r = (aa = a)->r;
                     21:        /*
                     22:                no recipe? go to buggery!
                     23:        */
                     24:        if(r == 0){
                     25:                if(!(node->flags&VIRTUAL) && !(node->flags&NORECIPE)){
                     26:                        Fprint(2, "mk: no recipe to make '%s'\n", node->name);
                     27:                        Exit();
                     28:                }
                     29:                update(0, node);
                     30:                if(tflag){
                     31:                        if(!(node->flags&VIRTUAL))
                     32:                                touch(node->name);
                     33:                        else if(explain)
                     34:                                Fprint(1, "no touch of virtual '%s'\n", node->name);
                     35:                }
                     36:                return(did);
                     37:        }
                     38:        /*
                     39:                build the node list
                     40:        */
                     41:        node->next = 0;
                     42:        head.next = 0;
                     43:        ww = &head;
                     44:        ahead.next = 0;
                     45:        aw = &ahead;
                     46:        if(r->attr&REGEXP){
                     47:                ww->next = newword(node->name);
                     48:                aw->next = newword(node->name);
                     49:        } else {
                     50:                for(w = r->alltargets; w; w = w->next){
                     51:                        if(r->attr&META)
                     52:                                subst(aa->stem, w->s, buf);
                     53:                        else
                     54:                                strcpy(buf, w->s);
                     55:                        aw->next = newword(buf);
                     56:                        aw = aw->next;
                     57:                        if((s = symlook(buf, S_NODE, (char *)0)) == 0)
                     58:                                continue;       /* not a node we are interested in */
                     59:                        n = (Node *)s->value;
                     60:                        ww->next = newword(buf);
                     61:                        ww = ww->next;
                     62:                        if(n == node) continue;
                     63:                        n->next = node->next;
                     64:                        node->next = n;
                     65:                }
                     66:        }
                     67:        for(n = node; n; n = n->next)
                     68:                if((n->flags&READY) == 0)
                     69:                        return(did);
                     70:        /*
                     71:                gather the params for the job
                     72:        */
                     73:        lp.next = ln.next = 0;
                     74:        for(n = node; n; n = n->next){
                     75:                for(a = n->prereqs; a; a = a->next){
                     76:                        if(a->n){
                     77:                                addw(&lp, a->n->name);
                     78:                                if(outofdate(n, a, 0)){
                     79:                                        addw(&ln, a->n->name);
                     80:                                        if(explain)
                     81:                                                fprint(1, "%s(%ld) < %s(%ld)\n",
                     82:                                                        n->name, n->time, a->n->name, a->n->time);
                     83:                                }
                     84:                        } else {
                     85:                                if(explain)
                     86:                                        fprint(1, "%s has no prerequisites\n",
                     87:                                                        n->name);
                     88:                        }
                     89:                }
                     90:                MADESET(n, BEINGMADE);
                     91:        }
                     92: /*     print("lt=%s ln=%s lp=%s\n",wtos(head.next),wtos(ln.next),wtos(lp.next));/**/
                     93:        run(newjob(r, node, aa->stem, aa->match, lp.next, ln.next, head.next, ahead.next));
                     94:        return(1);
                     95: }
                     96: 
                     97: addw(w, s)
                     98:        register Word *w;
                     99:        char *s;
                    100: {
                    101:        register Word *lw;
                    102: 
                    103:        for(lw = w; w = w->next; lw = w){
                    104:                if(strcmp(s, w->s) == 0)
                    105:                        return;
                    106:        }
                    107:        lw->next = newword(s);
                    108: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.