Changeset 24 in kBuild for branches/FREEBSD/src/kmk/make.c
- Timestamp:
- Nov 26, 2002 9:24:54 PM (22 years ago)
- File:
-
- 1 edited
-
branches/FREEBSD/src/kmk/make.c (modified) (35 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/FREEBSD/src/kmk/make.c
r10 r24 35 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 36 * 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 41 static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93"; 42 #else 43 static 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 */ 43 47 44 48 /*- … … 88 92 * TRUE, there's a cycle in the graph */ 89 93 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 *);94 static int MakeAddChild __P((ClientData, ClientData)); 95 static int MakeAddAllSrc __P((ClientData, ClientData)); 96 static int MakeTimeStamp __P((ClientData, ClientData)); 97 static int MakeHandleUse __P((ClientData, ClientData)); 98 static Boolean MakeStartJobs __P((void)); 99 static int MakePrintStatus __P((ClientData, ClientData)); 96 100 /*- 97 101 *----------------------------------------------------------------------- … … 109 113 */ 110 114 int 111 Make_TimeStamp (GNode *pgn, GNode *cgn) 115 Make_TimeStamp (pgn, cgn) 116 GNode *pgn; /* the current parent */ 117 GNode *cgn; /* the child we've just examined */ 112 118 { 113 119 if (cgn->mtime > pgn->cmtime) { … … 118 124 119 125 static int 120 MakeTimeStamp (void *pgn, void *cgn) 126 MakeTimeStamp (pgn, cgn) 127 ClientData pgn; /* the current parent */ 128 ClientData cgn; /* the child we've just examined */ 121 129 { 122 130 return Make_TimeStamp((GNode *) pgn, (GNode *) cgn); … … 143 151 */ 144 152 Boolean 145 Make_OODate (GNode *gn) 153 Make_OODate (gn) 154 register GNode *gn; /* the node to check */ 146 155 { 147 156 Boolean oodate; … … 153 162 if ((gn->type & (OP_JOIN|OP_USE|OP_EXEC)) == 0) { 154 163 (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 } 159 170 } 160 171 } … … 179 190 * no matter *what*. 180 191 */ 181 DEBUGF(MAKE, (".USE node...")); 192 if (DEBUG(MAKE)) { 193 printf(".USE node..."); 194 } 182 195 oodate = FALSE; 183 196 } else if (gn->type & OP_LIB) { 184 DEBUGF(MAKE, ("library...")); 197 if (DEBUG(MAKE)) { 198 printf("library..."); 199 } 185 200 186 201 /* … … 195 210 * out-of-date if any of its children was out-of-date. 196 211 */ 197 DEBUGF(MAKE, (".JOIN node...")); 212 if (DEBUG(MAKE)) { 213 printf(".JOIN node..."); 214 } 198 215 oodate = gn->childMade; 199 216 } else if (gn->type & (OP_FORCE|OP_EXEC|OP_PHONY)) { … … 202 219 * the .EXEC attribute is always considered out-of-date. 203 220 */ 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 } 210 229 } 211 230 oodate = TRUE; … … 221 240 * it. 222 241 */ 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 } 229 250 } 230 251 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 232 260 oodate = FALSE; 261 #endif /* 0 */ 262 } 233 263 234 264 /* … … 240 270 */ 241 271 if (!oodate) { 242 Lst_ForEach (gn->parents, MakeTimeStamp, ( void *)gn);272 Lst_ForEach (gn->parents, MakeTimeStamp, (ClientData)gn); 243 273 } 244 274 … … 261 291 */ 262 292 static int 263 MakeAddChild (void *gnp, void *lp) 293 MakeAddChild (gnp, lp) 294 ClientData gnp; /* the node to add */ 295 ClientData lp; /* the list to which to add it */ 264 296 { 265 297 GNode *gn = (GNode *) gnp; … … 267 299 268 300 if (!gn->make && !(gn->type & OP_USE)) { 269 (void)Lst_EnQueue (l, ( void *)gn);301 (void)Lst_EnQueue (l, (ClientData)gn); 270 302 } 271 303 return (0); … … 297 329 */ 298 330 int 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 */ 331 Make_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 */ 303 337 304 338 if (cgn->type & (OP_USE|OP_TRANSFORM)) { … … 312 346 313 347 if (Lst_Open (cgn->children) == SUCCESS) { 314 while ((ln = Lst_Next (cgn->children)) != N ULL) {348 while ((ln = Lst_Next (cgn->children)) != NILLNODE) { 315 349 gn = (GNode *)Lst_Datum (ln); 316 350 317 if (Lst_Member (pgn->children, gn) == N ULL) {351 if (Lst_Member (pgn->children, gn) == NILLNODE) { 318 352 (void) Lst_AtEnd (pgn->children, gn); 319 353 (void) Lst_AtEnd (gn->parents, pgn); … … 340 374 } 341 375 static int 342 MakeHandleUse (void *pgn, void *cgn) 376 MakeHandleUse (pgn, cgn) 377 ClientData pgn; /* the current parent */ 378 ClientData cgn; /* the child we've just examined */ 343 379 { 344 380 return Make_HandleUse((GNode *) pgn, (GNode *) cgn); … … 372 408 */ 373 409 void 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; 410 Make_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; 380 417 381 418 cname = Var_Value (TARGET, cgn, &p1); … … 443 480 cgn->mtime = now; 444 481 } 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 } 446 485 #endif 447 486 } 448 487 449 488 if (Lst_Open (cgn->parents) == SUCCESS) { 450 while ((ln = Lst_Next (cgn->parents)) != N ULL) {489 while ((ln = Lst_Next (cgn->parents)) != NILLNODE) { 451 490 pgn = (GNode *)Lst_Datum (ln); 452 491 if (pgn->make) { … … 468 507 * be dealt with in MakeStartJobs. 469 508 */ 470 (void)Lst_EnQueue (toBeMade, ( void *)pgn);509 (void)Lst_EnQueue (toBeMade, (ClientData)pgn); 471 510 } else if (pgn->unmade < 0) { 472 511 Error ("Graph cycles through %s", pgn->name); … … 482 521 * before. 483 522 */ 484 for (ln = Lst_First(cgn->successors); ln != N ULL; ln = Lst_Succ(ln)) {523 for (ln = Lst_First(cgn->successors); ln != NILLNODE; ln = Lst_Succ(ln)) { 485 524 GNode *succ = (GNode *)Lst_Datum(ln); 486 525 487 526 if (succ->make && succ->unmade == 0 && succ->made == UNMADE && 488 Lst_Member(toBeMade, ( void *)succ) == NULL)527 Lst_Member(toBeMade, (ClientData)succ) == NILLNODE) 489 528 { 490 (void)Lst_EnQueue(toBeMade, ( void *)succ);529 (void)Lst_EnQueue(toBeMade, (ClientData)succ); 491 530 } 492 531 } … … 497 536 */ 498 537 if (Lst_Open (cgn->iParents) == SUCCESS) { 499 char *p tr;500 char *cpref = Var_Value(PREFIX, cgn, &p tr);501 502 while ((ln = Lst_Next (cgn->iParents)) != N ULL) {538 char *p1; 539 char *cpref = Var_Value(PREFIX, cgn, &p1); 540 541 while ((ln = Lst_Next (cgn->iParents)) != NILLNODE) { 503 542 pgn = (GNode *)Lst_Datum (ln); 504 543 if (pgn->make) { … … 507 546 } 508 547 } 509 efree(p tr);548 efree(p1); 510 549 Lst_Close (cgn->iParents); 511 550 } … … 534 573 */ 535 574 static int 536 MakeAddAllSrc (void *cgnp, void *pgnp) 575 MakeAddAllSrc (cgnp, pgnp) 576 ClientData cgnp; /* The child to add */ 577 ClientData pgnp; /* The parent to whose ALLSRC variable it should be */ 578 /* added */ 537 579 { 538 580 GNode *cgn = (GNode *) cgnp; … … 605 647 */ 606 648 void 607 Make_DoAllVar (GNode *gn) 608 { 609 Lst_ForEach (gn->children, MakeAddAllSrc, (void *) gn); 649 Make_DoAllVar (gn) 650 GNode *gn; 651 { 652 Lst_ForEach (gn->children, MakeAddAllSrc, (ClientData) gn); 610 653 611 654 if (!Var_Exists (OODATE, gn)) { … … 641 684 */ 642 685 static Boolean 643 MakeStartJobs ( void)644 { 645 GNode *gn;686 MakeStartJobs () 687 { 688 register GNode *gn; 646 689 647 690 while (!Job_Full() && !Lst_IsEmpty (toBeMade)) { 648 691 gn = (GNode *) Lst_DeQueue (toBeMade); 649 DEBUGF(MAKE, ("Examining %s...", gn->name)); 692 if (DEBUG(MAKE)) { 693 printf ("Examining %s...", gn->name); 694 } 650 695 /* 651 696 * Make sure any and all predecessors that are going to be made, … … 655 700 LstNode ln; 656 701 657 for (ln = Lst_First(gn->preds); ln != N ULL; ln = Lst_Succ(ln)){702 for (ln = Lst_First(gn->preds); ln != NILLNODE; ln = Lst_Succ(ln)){ 658 703 GNode *pgn = (GNode *)Lst_Datum(ln); 659 704 660 705 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 } 662 709 break; 663 710 } 664 711 } 665 712 /* 666 * If ln isn't NULL, there's a predecessor as yet unmade, so we713 * If ln isn't nil, there's a predecessor as yet unmade, so we 667 714 * just drop this node on the floor. When the node in question 668 715 * has been made, it will notice this node as being ready to 669 716 * make but as yet unmade and will place the node on the queue. 670 717 */ 671 if (ln != N ULL) {718 if (ln != NILLNODE) { 672 719 continue; 673 720 } … … 676 723 numNodes--; 677 724 if (Make_OODate (gn)) { 678 DEBUGF(MAKE, ("out-of-date\n")); 725 if (DEBUG(MAKE)) { 726 printf ("out-of-date\n"); 727 } 679 728 if (queryFlag) { 680 729 return (TRUE); … … 683 732 Job_Make (gn); 684 733 } else { 685 DEBUGF(MAKE, ("up-to-date\n")); 734 if (DEBUG(MAKE)) { 735 printf ("up-to-date\n"); 736 } 686 737 gn->made = UPTODATE; 687 738 if (gn->type & OP_JOIN) { … … 707 758 * Print the status of a top-level node, viz. it being up-to-date 708 759 * 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. 712 761 * 713 762 * Results: … … 720 769 */ 721 770 static int 722 MakePrintStatus(void *gnp, void *cyclep) 771 MakePrintStatus(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 */ 723 776 { 724 777 GNode *gn = (GNode *) gnp; … … 742 795 Error("Graph cycles through `%s'", gn->name); 743 796 gn->made = ENDCYCLE; 744 Lst_ForEach(gn->children, MakePrintStatus, ( void *) &t);797 Lst_ForEach(gn->children, MakePrintStatus, (ClientData) &t); 745 798 gn->made = UNMADE; 746 799 } else if (gn->made != ENDCYCLE) { 747 800 gn->made = CYCLE; 748 Lst_ForEach(gn->children, MakePrintStatus, ( void *) &t);801 Lst_ForEach(gn->children, MakePrintStatus, (ClientData) &t); 749 802 } 750 803 } else { … … 778 831 */ 779 832 Boolean 780 Make_Run (Lst targs) 781 { 782 GNode *gn; /* a temporary pointer */ 783 Lst examine; /* List of targets to examine */ 833 Make_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 */ 784 838 int errors; /* Number of errors the Job module reports */ 785 839 … … 808 862 * to make sure everything has commands that should... 809 863 */ 810 Lst_ForEach (gn->children, MakeHandleUse, ( void *)gn);864 Lst_ForEach (gn->children, MakeHandleUse, (ClientData)gn); 811 865 Suff_FindDeps (gn); 812 866 813 867 if (gn->unmade != 0) { 814 Lst_ForEach (gn->children, MakeAddChild, ( void *)examine);868 Lst_ForEach (gn->children, MakeAddChild, (ClientData)examine); 815 869 } else { 816 (void)Lst_EnQueue (toBeMade, ( void *)gn);870 (void)Lst_EnQueue (toBeMade, (ClientData)gn); 817 871 } 818 872 } … … 855 909 } 856 910 857 errors = Job_ Finish();911 errors = Job_End(); 858 912 859 913 /* … … 862 916 */ 863 917 errors = ((errors == 0) && (numNodes != 0)); 864 Lst_ForEach(targs, MakePrintStatus, ( void *) &errors);918 Lst_ForEach(targs, MakePrintStatus, (ClientData) &errors); 865 919 866 920 return (TRUE);
Note:
See TracChangeset
for help on using the changeset viewer.

