|
|
1.1 ! root 1: /* @(#)/usr/src/cmd/make/dyndep.c 3.4 */ ! 2: /* @(#)dyndep.c 3.3 */ ! 3: #include "defs" ! 4: /* ! 5: * Dynamicdep() checks each dependency by calling runtime(). ! 6: * Runtime() determines if a dependent line contains "$@" ! 7: * or "$(@F)" or "$(@D)". If so, it makes a new dependent line ! 8: * and insert it into the dependency chain of the input name, p. ! 9: * Here, "$@" gets translated to p->namep. That is ! 10: * the current name on the left of the colon in the ! 11: * makefile. Thus, ! 12: * xyz: [email protected] ! 13: * translates into ! 14: * xyz: s.xyz.c ! 15: * ! 16: * Also, "$(@F)" translates to the same thing without a prededing ! 17: * directory path (if one exists). ! 18: * Note, to enter "$@" on a dependency line in a makefile ! 19: * "$$@" must be typed. This is because `make' expands ! 20: * macros upon reading them. ! 21: */ ! 22: ! 23: #define is_dyn(a) (any( (a), DOLLAR) ) ! 24: ! 25: ! 26: dynamicdep(p) ! 27: register NAMEBLOCK p; ! 28: { ! 29: register LINEBLOCK lp, nlp; ! 30: LINEBLOCK backlp=0; ! 31: ! 32: p->rundep = 1; ! 33: ! 34: for(lp = p->linep; lp != 0; lp = lp->nextline) ! 35: { ! 36: if( (nlp=runtime(p, lp)) != 0) ! 37: if(backlp) ! 38: backlp->nextline = nlp; ! 39: else ! 40: p->linep = nlp; ! 41: ! 42: backlp = (nlp == 0) ? lp : nlp; ! 43: } ! 44: } ! 45: ! 46: ! 47: LINEBLOCK runtime(p, lp) ! 48: NAMEBLOCK p; ! 49: register LINEBLOCK lp; ! 50: { ! 51: register union ! 52: { ! 53: int u_i; ! 54: NAMEBLOCK u_nam; ! 55: } temp; ! 56: register DEPBLOCK q, nq; ! 57: LINEBLOCK nlp; ! 58: NAMEBLOCK pc; ! 59: CHARSTAR pc1; ! 60: char c; ! 61: CHARSTAR pbuf; ! 62: char buf[128]; ! 63: ! 64: temp.u_i = NO; ! 65: for(q = lp->depp; q != 0; q = q->nextdep) ! 66: { ! 67: if((pc=q->depname) != 0) ! 68: { ! 69: if(is_dyn(pc->namep)) ! 70: { ! 71: temp.u_i = YES; ! 72: break; ! 73: } ! 74: } ! 75: } ! 76: ! 77: if(temp.u_i == NO) ! 78: { ! 79: return(0); ! 80: } ! 81: ! 82: nlp = ALLOC(lineblock); ! 83: nq = ALLOC(depblock); ! 84: ! 85: nlp->nextline = lp->nextline; ! 86: nlp->shp = lp->shp; ! 87: nlp->depp = nq; ! 88: ! 89: for(q = lp->depp; q != 0; q = q->nextdep) ! 90: { ! 91: pc1 = q->depname->namep; ! 92: if(is_dyn(pc1)) ! 93: { ! 94: subst(pc1, buf); ! 95: temp.u_nam = srchname(buf); ! 96: if(temp.u_nam == 0) ! 97: temp.u_nam = makename(copys(buf)); ! 98: nq->depname = temp.u_nam; ! 99: } ! 100: else ! 101: { ! 102: nq->depname = q->depname; ! 103: } ! 104: ! 105: if(q->nextdep == 0) ! 106: nq->nextdep = 0; ! 107: else ! 108: nq->nextdep = ALLOC(depblock); ! 109: ! 110: nq = nq->nextdep; ! 111: } ! 112: return(nlp); ! 113: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.