1 /* $NetBSD: compat.c,v 1.252 2024/01/05 23:22:06 rillig Exp $ */ 2 3 /* 4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Adam de Boor. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. Neither the name of the University nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 */ 34 35 /* 36 * Copyright (c) 1988, 1989 by Adam de Boor 37 * Copyright (c) 1989 by Berkeley Softworks 38 * All rights reserved. 39 * 40 * This code is derived from software contributed to Berkeley by 41 * Adam de Boor. 42 * 43 * Redistribution and use in source and binary forms, with or without 44 * modification, are permitted provided that the following conditions 45 * are met: 46 * 1. Redistributions of source code must retain the above copyright 47 * notice, this list of conditions and the following disclaimer. 48 * 2. Redistributions in binary form must reproduce the above copyright 49 * notice, this list of conditions and the following disclaimer in the 50 * documentation and/or other materials provided with the distribution. 51 * 3. All advertising materials mentioning features or use of this software 52 * must display the following acknowledgement: 53 * This product includes software developed by the University of 54 * California, Berkeley and its contributors. 55 * 4. Neither the name of the University nor the names of its contributors 56 * may be used to endorse or promote products derived from this software 57 * without specific prior written permission. 58 * 59 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 60 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 62 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 65 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 69 * SUCH DAMAGE. 70 */ 71 72 /* 73 * This file implements the full-compatibility mode of make, which makes the 74 * targets without parallelism and without a custom shell. 75 * 76 * Interface: 77 * Compat_MakeAll Initialize this module and make the given targets. 78 */ 79 80 #include <sys/types.h> 81 #include <sys/stat.h> 82 #include <sys/wait.h> 83 84 #include <errno.h> 85 #include <signal.h> 86 87 #include "make.h" 88 #include "dir.h" 89 #include "job.h" 90 #include "metachar.h" 91 #include "pathnames.h" 92 93 /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ 94 MAKE_RCSID("$NetBSD: compat.c,v 1.252 2024/01/05 23:22:06 rillig Exp $"); 95 96 static GNode *curTarg = NULL; 97 static pid_t compatChild; 98 static int compatSigno; 99 100 /* 101 * Delete the file of a failed, interrupted, or otherwise duffed target, 102 * unless inhibited by .PRECIOUS. 103 */ 104 static void 105 CompatDeleteTarget(GNode *gn) 106 { 107 if (gn != NULL && !GNode_IsPrecious(gn) && 108 (gn->type & OP_PHONY) == 0) { 109 const char *file = GNode_VarTarget(gn); 110 if (!opts.noExecute && unlink_file(file) == 0) 111 Error("*** %s removed", file); 112 } 113 } 114 115 /* 116 * Interrupt the creation of the current target and remove it if it ain't 117 * precious. Then exit. 118 * 119 * If .INTERRUPT exists, its commands are run first WITH INTERRUPTS IGNORED. 120 * 121 * XXX: is .PRECIOUS supposed to inhibit .INTERRUPT? I doubt it, but I've 122 * left the logic alone for now. - dholland 20160826 123 */ 124 static void 125 CompatInterrupt(int signo) 126 { 127 CompatDeleteTarget(curTarg); 128 129 if (curTarg != NULL && !GNode_IsPrecious(curTarg)) { 130 /* Run .INTERRUPT only if hit with interrupt signal. */ 131 if (signo == SIGINT) { 132 GNode *gn = Targ_FindNode(".INTERRUPT"); 133 if (gn != NULL) 134 Compat_Make(gn, gn); 135 } 136 } 137 138 if (signo == SIGQUIT) 139 _exit(signo); 140 141 /* 142 * If there is a child running, pass the signal on. 143 * We will exist after it has exited. 144 */ 145 compatSigno = signo; 146 if (compatChild > 0) { 147 KILLPG(compatChild, signo); 148 } else { 149 bmake_signal(signo, SIG_DFL); 150 kill(myPid, signo); 151 } 152 } 153 154 static void 155 DebugFailedTarget(const char *cmd, const GNode *gn) 156 { 157 const char *p = cmd; 158 debug_printf("\n*** Failed target: %s\n*** Failed command: ", 159 gn->name); 160 161 /* 162 * Replace runs of whitespace with a single space, to reduce the 163 * amount of whitespace for multi-line command lines. 164 */ 165 while (*p != '\0') { 166 if (ch_isspace(*p)) { 167 debug_printf(" "); 168 cpp_skip_whitespace(&p); 169 } else { 170 debug_printf("%c", *p); 171 p++; 172 } 173 } 174 debug_printf("\n"); 175 } 176 177 static bool 178 UseShell(const char *cmd MAKE_ATTR_UNUSED) 179 { 180 #if !defined(MAKE_NATIVE) 181 /* 182 * In a non-native build, the host environment might be weird enough 183 * that it's necessary to go through a shell to get the correct 184 * behaviour. Or perhaps the shell has been replaced with something 185 * that does extra logging, and that should not be bypassed. 186 */ 187 return true; 188 #else 189 /* 190 * Search for meta characters in the command. If there are no meta 191 * characters, there's no need to execute a shell to execute the 192 * command. 193 * 194 * Additionally variable assignments and empty commands 195 * go to the shell. Therefore treat '=' and ':' like shell 196 * meta characters as documented in make(1). 197 */ 198 199 return needshell(cmd); 200 #endif 201 } 202 203 /* 204 * Execute the next command for a target. If the command returns an error, 205 * the node's made field is set to ERROR and creation stops. 206 * 207 * Input: 208 * cmdp Command to execute 209 * gn Node from which the command came 210 * ln List node that contains the command 211 * 212 * Results: 213 * true if the command succeeded. 214 */ 215 bool 216 Compat_RunCommand(const char *cmdp, GNode *gn, StringListNode *ln) 217 { 218 char *cmdStart; /* Start of expanded command */ 219 char *volatile bp; 220 bool silent; /* Don't print command */ 221 bool doIt; /* Execute even if -n */ 222 volatile bool errCheck; /* Check errors */ 223 int reason; /* Reason for child's death */ 224 int status; /* Description of child's death */ 225 pid_t cpid; /* Child actually found */ 226 pid_t retstat; /* Result of wait */ 227 const char **volatile av; /* Argument vector for thing to exec */ 228 char **volatile mav; /* Copy of the argument vector for freeing */ 229 bool useShell; /* True if command should be executed using a 230 * shell */ 231 const char *volatile cmd = cmdp; 232 233 silent = (gn->type & OP_SILENT) != OP_NONE; 234 errCheck = !(gn->type & OP_IGNORE); 235 doIt = false; 236 237 cmdStart = Var_Subst(cmd, gn, VARE_WANTRES); 238 /* TODO: handle errors */ 239 240 if (cmdStart[0] == '\0') { 241 free(cmdStart); 242 return true; 243 } 244 cmd = cmdStart; 245 LstNode_Set(ln, cmdStart); 246 247 if (gn->type & OP_SAVE_CMDS) { 248 GNode *endNode = Targ_GetEndNode(); 249 if (gn != endNode) { 250 /* 251 * Append the expanded command, to prevent the 252 * local variables from being interpreted in the 253 * scope of the .END node. 254 * 255 * A probably unintended side effect of this is that 256 * the expanded command will be expanded again in the 257 * .END node. Therefore, a literal '$' in these 258 * commands must be written as '$$$$' instead of the 259 * usual '$$'. 260 */ 261 Lst_Append(&endNode->commands, cmdStart); 262 return true; 263 } 264 } 265 if (strcmp(cmdStart, "...") == 0) { 266 gn->type |= OP_SAVE_CMDS; 267 return true; 268 } 269 270 for (;;) { 271 if (*cmd == '@') 272 silent = !DEBUG(LOUD); 273 else if (*cmd == '-') 274 errCheck = false; 275 else if (*cmd == '+') 276 doIt = true; 277 else if (!ch_isspace(*cmd)) 278 /* Ignore whitespace for compatibility with gnu make */ 279 break; 280 cmd++; 281 } 282 283 while (ch_isspace(*cmd)) 284 cmd++; 285 if (cmd[0] == '\0') 286 return true; 287 288 useShell = UseShell(cmd); 289 290 if (!silent || !GNode_ShouldExecute(gn)) { 291 printf("%s\n", cmd); 292 fflush(stdout); 293 } 294 295 if (!doIt && !GNode_ShouldExecute(gn)) 296 return true; 297 298 DEBUG1(JOB, "Execute: '%s'\n", cmd); 299 300 if (useShell && shellPath == NULL) 301 Shell_Init(); /* we need shellPath */ 302 303 if (useShell) { 304 static const char *shargv[5]; 305 306 /* The following work for any of the builtin shell specs. */ 307 int shargc = 0; 308 shargv[shargc++] = shellPath; 309 if (errCheck && shellErrFlag != NULL) 310 shargv[shargc++] = shellErrFlag; 311 shargv[shargc++] = DEBUG(SHELL) ? "-xc" : "-c"; 312 shargv[shargc++] = cmd; 313 shargv[shargc] = NULL; 314 av = shargv; 315 bp = NULL; 316 mav = NULL; 317 } else { 318 Words words = Str_Words(cmd, false); 319 mav = words.words; 320 bp = words.freeIt; 321 av = (void *)mav; 322 } 323 324 #ifdef USE_META 325 if (useMeta) 326 meta_compat_start(); 327 #endif 328 329 Var_ReexportVars(); 330 331 compatChild = cpid = vfork(); 332 if (cpid < 0) 333 Fatal("Could not fork"); 334 335 if (cpid == 0) { 336 #ifdef USE_META 337 if (useMeta) 338 meta_compat_child(); 339 #endif 340 (void)execvp(av[0], (char *const *)UNCONST(av)); 341 execDie("exec", av[0]); 342 } 343 344 free(mav); 345 free(bp); 346 347 /* XXX: Memory management looks suspicious here. */ 348 /* XXX: Setting a list item to NULL is unexpected. */ 349 LstNode_SetNull(ln); 350 351 #ifdef USE_META 352 if (useMeta) 353 meta_compat_parent(cpid); 354 #endif 355 356 /* The child is off and running. Now all we can do is wait... */ 357 while ((retstat = wait(&reason)) != cpid) { 358 if (retstat > 0) 359 JobReapChild(retstat, reason, false); /* not ours? */ 360 if (retstat == -1 && errno != EINTR) 361 break; 362 } 363 364 if (retstat < 0) 365 Fatal("error in wait: %d: %s", retstat, strerror(errno)); 366 367 if (WIFSTOPPED(reason)) { 368 status = WSTOPSIG(reason); 369 } else if (WIFEXITED(reason)) { 370 status = WEXITSTATUS(reason); 371 #if defined(USE_META) && defined(USE_FILEMON_ONCE) 372 if (useMeta) 373 meta_cmd_finish(NULL); 374 #endif 375 if (status != 0) { 376 if (DEBUG(ERROR)) 377 DebugFailedTarget(cmd, gn); 378 printf("*** Error code %d", status); 379 } 380 } else { 381 status = WTERMSIG(reason); 382 printf("*** Signal %d", status); 383 } 384 385 386 if (!WIFEXITED(reason) || status != 0) { 387 if (errCheck) { 388 #ifdef USE_META 389 if (useMeta) 390 meta_job_error(NULL, gn, false, status); 391 #endif 392 gn->made = ERROR; 393 if (opts.keepgoing) { 394 /* 395 * Abort the current target, 396 * but let others continue. 397 */ 398 printf(" (continuing)\n"); 399 } else { 400 printf("\n"); 401 } 402 if (deleteOnError) 403 CompatDeleteTarget(gn); 404 } else { 405 /* 406 * Continue executing commands for this target. 407 * If we return 0, this will happen... 408 */ 409 printf(" (ignored)\n"); 410 status = 0; 411 } 412 fflush(stdout); 413 } 414 415 free(cmdStart); 416 compatChild = 0; 417 if (compatSigno != 0) { 418 bmake_signal(compatSigno, SIG_DFL); 419 kill(myPid, compatSigno); 420 } 421 422 return status == 0; 423 } 424 425 static void 426 RunCommands(GNode *gn) 427 { 428 StringListNode *ln; 429 430 for (ln = gn->commands.first; ln != NULL; ln = ln->next) { 431 const char *cmd = ln->datum; 432 if (!Compat_RunCommand(cmd, gn, ln)) 433 break; 434 } 435 } 436 437 static void 438 MakeInRandomOrder(GNode **gnodes, GNode **end, GNode *pgn) 439 { 440 GNode **it; 441 size_t r; 442 443 for (r = (size_t)(end - gnodes); r >= 2; r--) { 444 /* Biased, but irrelevant in practice. */ 445 size_t i = (size_t)random() % r; 446 GNode *t = gnodes[r - 1]; 447 gnodes[r - 1] = gnodes[i]; 448 gnodes[i] = t; 449 } 450 451 for (it = gnodes; it != end; it++) 452 Compat_Make(*it, pgn); 453 } 454 455 static void 456 MakeWaitGroupsInRandomOrder(GNodeList *gnodes, GNode *pgn) 457 { 458 Vector vec; 459 GNodeListNode *ln; 460 GNode **nodes; 461 size_t i, n, start; 462 463 Vector_Init(&vec, sizeof(GNode *)); 464 for (ln = gnodes->first; ln != NULL; ln = ln->next) 465 *(GNode **)Vector_Push(&vec) = ln->datum; 466 nodes = vec.items; 467 n = vec.len; 468 469 start = 0; 470 for (i = 0; i < n; i++) { 471 if (nodes[i]->type & OP_WAIT) { 472 MakeInRandomOrder(nodes + start, nodes + i, pgn); 473 Compat_Make(nodes[i], pgn); 474 start = i + 1; 475 } 476 } 477 MakeInRandomOrder(nodes + start, nodes + i, pgn); 478 479 Vector_Done(&vec); 480 } 481 482 static void 483 MakeNodes(GNodeList *gnodes, GNode *pgn) 484 { 485 GNodeListNode *ln; 486 487 if (Lst_IsEmpty(gnodes)) 488 return; 489 if (opts.randomizeTargets) { 490 MakeWaitGroupsInRandomOrder(gnodes, pgn); 491 return; 492 } 493 494 for (ln = gnodes->first; ln != NULL; ln = ln->next) { 495 GNode *cgn = ln->datum; 496 Compat_Make(cgn, pgn); 497 } 498 } 499 500 static bool 501 MakeUnmade(GNode *gn, GNode *pgn) 502 { 503 504 assert(gn->made == UNMADE); 505 506 /* 507 * First mark ourselves to be made, then apply whatever transformations 508 * the suffix module thinks are necessary. Once that's done, we can 509 * descend and make all our children. If any of them has an error 510 * but the -k flag was given, our 'make' field will be set to false 511 * again. This is our signal to not attempt to do anything but abort 512 * our parent as well. 513 */ 514 gn->flags.remake = true; 515 gn->made = BEINGMADE; 516 517 if (!(gn->type & OP_MADE)) 518 Suff_FindDeps(gn); 519 520 MakeNodes(&gn->children, gn); 521 522 if (!gn->flags.remake) { 523 gn->made = ABORTED; 524 pgn->flags.remake = false; 525 return false; 526 } 527 528 if (Lst_FindDatum(&gn->implicitParents, pgn) != NULL) 529 Var_Set(pgn, IMPSRC, GNode_VarTarget(gn)); 530 531 /* 532 * All the children were made ok. Now youngestChild->mtime contains the 533 * modification time of the newest child, we need to find out if we 534 * exist and when we were modified last. The criteria for datedness 535 * are defined by GNode_IsOODate. 536 */ 537 DEBUG1(MAKE, "Examining %s...", gn->name); 538 if (!GNode_IsOODate(gn)) { 539 gn->made = UPTODATE; 540 DEBUG0(MAKE, "up-to-date.\n"); 541 return false; 542 } 543 544 /* 545 * If the user is just seeing if something is out-of-date, exit now 546 * to tell him/her "yes". 547 */ 548 DEBUG0(MAKE, "out-of-date.\n"); 549 if (opts.query && gn != Targ_GetEndNode()) 550 exit(1); 551 552 /* 553 * We need to be re-made. 554 * Ensure that $? (.OODATE) and $> (.ALLSRC) are both set. 555 */ 556 GNode_SetLocalVars(gn); 557 558 /* 559 * Alter our type to tell if errors should be ignored or things 560 * should not be printed so Compat_RunCommand knows what to do. 561 */ 562 if (opts.ignoreErrors) 563 gn->type |= OP_IGNORE; 564 if (opts.silent) 565 gn->type |= OP_SILENT; 566 567 if (Job_CheckCommands(gn, Fatal)) { 568 if (!opts.touch || (gn->type & OP_MAKE)) { 569 curTarg = gn; 570 #ifdef USE_META 571 if (useMeta && GNode_ShouldExecute(gn)) 572 meta_job_start(NULL, gn); 573 #endif 574 RunCommands(gn); 575 curTarg = NULL; 576 } else { 577 Job_Touch(gn, (gn->type & OP_SILENT) != OP_NONE); 578 } 579 } else { 580 gn->made = ERROR; 581 } 582 #ifdef USE_META 583 if (useMeta && GNode_ShouldExecute(gn)) { 584 if (meta_job_finish(NULL) != 0) 585 gn->made = ERROR; 586 } 587 #endif 588 589 if (gn->made != ERROR) { 590 /* 591 * If the node was made successfully, mark it so, update 592 * its modification time and timestamp all its parents. 593 * This is to keep its state from affecting that of its parent. 594 */ 595 gn->made = MADE; 596 if (Make_Recheck(gn) == 0) 597 pgn->flags.force = true; 598 if (!(gn->type & OP_EXEC)) { 599 pgn->flags.childMade = true; 600 GNode_UpdateYoungestChild(pgn, gn); 601 } 602 } else if (opts.keepgoing) { 603 pgn->flags.remake = false; 604 } else { 605 PrintOnError(gn, "\nStop.\n"); 606 exit(1); 607 } 608 return true; 609 } 610 611 static void 612 MakeOther(GNode *gn, GNode *pgn) 613 { 614 615 if (Lst_FindDatum(&gn->implicitParents, pgn) != NULL) { 616 const char *target = GNode_VarTarget(gn); 617 Var_Set(pgn, IMPSRC, target != NULL ? target : ""); 618 } 619 620 switch (gn->made) { 621 case BEINGMADE: 622 Error("Graph cycles through %s", gn->name); 623 gn->made = ERROR; 624 pgn->flags.remake = false; 625 break; 626 case MADE: 627 if (!(gn->type & OP_EXEC)) { 628 pgn->flags.childMade = true; 629 GNode_UpdateYoungestChild(pgn, gn); 630 } 631 break; 632 case UPTODATE: 633 if (!(gn->type & OP_EXEC)) 634 GNode_UpdateYoungestChild(pgn, gn); 635 break; 636 default: 637 break; 638 } 639 } 640 641 /* 642 * Make a target. 643 * 644 * If an error is detected and not being ignored, the process exits. 645 * 646 * Input: 647 * gn The node to make 648 * pgn Parent to abort if necessary 649 * 650 * Output: 651 * gn->made 652 * UPTODATE gn was already up-to-date. 653 * MADE gn was recreated successfully. 654 * ERROR An error occurred while gn was being created, 655 * either due to missing commands or in -k mode. 656 * ABORTED gn was not remade because one of its 657 * dependencies could not be made due to errors. 658 */ 659 void 660 Compat_Make(GNode *gn, GNode *pgn) 661 { 662 if (shellName == NULL) /* we came here from jobs */ 663 Shell_Init(); 664 665 if (gn->made == UNMADE && (gn == pgn || !(pgn->type & OP_MADE))) { 666 if (!MakeUnmade(gn, pgn)) 667 goto cohorts; 668 669 /* XXX: Replace with GNode_IsError(gn) */ 670 } else if (gn->made == ERROR) { 671 /* 672 * Already had an error when making this. 673 * Tell the parent to abort. 674 */ 675 pgn->flags.remake = false; 676 } else { 677 MakeOther(gn, pgn); 678 } 679 680 cohorts: 681 MakeNodes(&gn->cohorts, pgn); 682 } 683 684 static void 685 MakeBeginNode(void) 686 { 687 GNode *gn = Targ_FindNode(".BEGIN"); 688 if (gn == NULL) 689 return; 690 691 Compat_Make(gn, gn); 692 if (GNode_IsError(gn)) { 693 PrintOnError(gn, "\nStop.\n"); 694 exit(1); 695 } 696 } 697 698 static void 699 InitSignals(void) 700 { 701 if (bmake_signal(SIGINT, SIG_IGN) != SIG_IGN) 702 bmake_signal(SIGINT, CompatInterrupt); 703 if (bmake_signal(SIGTERM, SIG_IGN) != SIG_IGN) 704 bmake_signal(SIGTERM, CompatInterrupt); 705 if (bmake_signal(SIGHUP, SIG_IGN) != SIG_IGN) 706 bmake_signal(SIGHUP, CompatInterrupt); 707 if (bmake_signal(SIGQUIT, SIG_IGN) != SIG_IGN) 708 bmake_signal(SIGQUIT, CompatInterrupt); 709 } 710 711 void 712 Compat_MakeAll(GNodeList *targs) 713 { 714 GNode *errorNode = NULL; 715 716 if (shellName == NULL) 717 Shell_Init(); 718 719 InitSignals(); 720 721 /* 722 * Create the .END node now, to keep the (debug) output of the 723 * counter.mk test the same as before 2020-09-23. This 724 * implementation detail probably doesn't matter though. 725 */ 726 (void)Targ_GetEndNode(); 727 728 if (!opts.query) 729 MakeBeginNode(); 730 731 /* 732 * Expand .USE nodes right now, because they can modify the structure 733 * of the tree. 734 */ 735 Make_ExpandUse(targs); 736 737 while (!Lst_IsEmpty(targs)) { 738 GNode *gn = Lst_Dequeue(targs); 739 Compat_Make(gn, gn); 740 741 if (gn->made == UPTODATE) { 742 printf("`%s' is up to date.\n", gn->name); 743 } else if (gn->made == ABORTED) { 744 printf("`%s' not remade because of errors.\n", 745 gn->name); 746 } 747 if (GNode_IsError(gn) && errorNode == NULL) 748 errorNode = gn; 749 } 750 751 if (errorNode == NULL) { 752 GNode *endNode = Targ_GetEndNode(); 753 Compat_Make(endNode, endNode); 754 if (GNode_IsError(endNode)) 755 errorNode = endNode; 756 } 757 758 if (errorNode != NULL) { 759 if (DEBUG(GRAPH2)) 760 Targ_PrintGraph(2); 761 else if (DEBUG(GRAPH3)) 762 Targ_PrintGraph(3); 763 PrintOnError(errorNode, "\nStop.\n"); 764 exit(1); 765 } 766 } 767