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