1 /* $NetBSD: compat.c,v 1.254 2024/03/10 02:53:37 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 #ifdef HAVE_CONFIG_H 81 # include "config.h" 82 #endif 83 #include <sys/types.h> 84 #include <sys/stat.h> 85 #include "wait.h" 86 87 #include <errno.h> 88 #include <signal.h> 89 90 #include "make.h" 91 #include "dir.h" 92 #include "job.h" 93 #include "metachar.h" 94 #include "pathnames.h" 95 96 /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ 97 MAKE_RCSID("$NetBSD: compat.c,v 1.254 2024/03/10 02:53:37 sjg Exp $"); 98 99 static GNode *curTarg = NULL; 100 static pid_t compatChild; 101 static int compatSigno; 102 103 /* 104 * Delete the file of a failed, interrupted, or otherwise duffed target, 105 * unless inhibited by .PRECIOUS. 106 */ 107 static void 108 CompatDeleteTarget(GNode *gn) 109 { 110 if (gn != NULL && !GNode_IsPrecious(gn) && 111 (gn->type & OP_PHONY) == 0) { 112 const char *file = GNode_VarTarget(gn); 113 if (!opts.noExecute && unlink_file(file) == 0) 114 Error("*** %s removed", file); 115 } 116 } 117 118 /* 119 * Interrupt the creation of the current target and remove it if it ain't 120 * precious. Then exit. 121 * 122 * If .INTERRUPT exists, its commands are run first WITH INTERRUPTS IGNORED. 123 * 124 * XXX: is .PRECIOUS supposed to inhibit .INTERRUPT? I doubt it, but I've 125 * left the logic alone for now. - dholland 20160826 126 */ 127 static void 128 CompatInterrupt(int signo) 129 { 130 CompatDeleteTarget(curTarg); 131 132 if (curTarg != NULL && !GNode_IsPrecious(curTarg)) { 133 /* Run .INTERRUPT only if hit with interrupt signal. */ 134 if (signo == SIGINT) { 135 GNode *gn = Targ_FindNode(".INTERRUPT"); 136 if (gn != NULL) 137 Compat_Make(gn, gn); 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(FORCE_USE_SHELL) || !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 WAIT_T reason; /* Reason for child's death */ 227 WAIT_T 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(gn); 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 if (retstat < 0) 368 Fatal("error in wait: %d: %s", retstat, strerror(errno)); 369 370 if (WIFSTOPPED(reason)) { 371 status = WSTOPSIG(reason); 372 } else if (WIFEXITED(reason)) { 373 status = WEXITSTATUS(reason); 374 #if defined(USE_META) && defined(USE_FILEMON_ONCE) 375 if (useMeta) 376 meta_cmd_finish(NULL); 377 #endif 378 if (status != 0) { 379 if (DEBUG(ERROR)) 380 DebugFailedTarget(cmd, gn); 381 printf("*** Error code %d", status); 382 } 383 } else { 384 status = WTERMSIG(reason); 385 printf("*** Signal %d", status); 386 } 387 388 389 if (!WIFEXITED(reason) || status != 0) { 390 if (errCheck) { 391 #ifdef USE_META 392 if (useMeta) 393 meta_job_error(NULL, gn, false, status); 394 #endif 395 gn->made = ERROR; 396 if (WIFEXITED(reason)) 397 gn->exit_status = status; 398 if (opts.keepgoing) { 399 /* 400 * Abort the current target, 401 * but let others continue. 402 */ 403 printf(" (continuing)\n"); 404 } else { 405 printf("\n"); 406 } 407 if (deleteOnError) 408 CompatDeleteTarget(gn); 409 } else { 410 /* 411 * Continue executing commands for this target. 412 * If we return 0, this will happen... 413 */ 414 printf(" (ignored)\n"); 415 status = 0; 416 } 417 fflush(stdout); 418 } 419 420 free(cmdStart); 421 compatChild = 0; 422 if (compatSigno != 0) { 423 bmake_signal(compatSigno, SIG_DFL); 424 kill(myPid, compatSigno); 425 } 426 427 return status == 0; 428 } 429 430 static void 431 RunCommands(GNode *gn) 432 { 433 StringListNode *ln; 434 435 for (ln = gn->commands.first; ln != NULL; ln = ln->next) { 436 const char *cmd = ln->datum; 437 if (!Compat_RunCommand(cmd, gn, ln)) 438 break; 439 } 440 } 441 442 static void 443 MakeInRandomOrder(GNode **gnodes, GNode **end, GNode *pgn) 444 { 445 GNode **it; 446 size_t r; 447 448 for (r = (size_t)(end - gnodes); r >= 2; r--) { 449 /* Biased, but irrelevant in practice. */ 450 size_t i = (size_t)random() % r; 451 GNode *t = gnodes[r - 1]; 452 gnodes[r - 1] = gnodes[i]; 453 gnodes[i] = t; 454 } 455 456 for (it = gnodes; it != end; it++) 457 Compat_Make(*it, pgn); 458 } 459 460 static void 461 MakeWaitGroupsInRandomOrder(GNodeList *gnodes, GNode *pgn) 462 { 463 Vector vec; 464 GNodeListNode *ln; 465 GNode **nodes; 466 size_t i, n, start; 467 468 Vector_Init(&vec, sizeof(GNode *)); 469 for (ln = gnodes->first; ln != NULL; ln = ln->next) 470 *(GNode **)Vector_Push(&vec) = ln->datum; 471 nodes = vec.items; 472 n = vec.len; 473 474 start = 0; 475 for (i = 0; i < n; i++) { 476 if (nodes[i]->type & OP_WAIT) { 477 MakeInRandomOrder(nodes + start, nodes + i, pgn); 478 Compat_Make(nodes[i], pgn); 479 start = i + 1; 480 } 481 } 482 MakeInRandomOrder(nodes + start, nodes + i, pgn); 483 484 Vector_Done(&vec); 485 } 486 487 static void 488 MakeNodes(GNodeList *gnodes, GNode *pgn) 489 { 490 GNodeListNode *ln; 491 492 if (Lst_IsEmpty(gnodes)) 493 return; 494 if (opts.randomizeTargets) { 495 MakeWaitGroupsInRandomOrder(gnodes, pgn); 496 return; 497 } 498 499 for (ln = gnodes->first; ln != NULL; ln = ln->next) { 500 GNode *cgn = ln->datum; 501 Compat_Make(cgn, pgn); 502 } 503 } 504 505 static bool 506 MakeUnmade(GNode *gn, GNode *pgn) 507 { 508 509 assert(gn->made == UNMADE); 510 511 /* 512 * First mark ourselves to be made, then apply whatever transformations 513 * the suffix module thinks are necessary. Once that's done, we can 514 * descend and make all our children. If any of them has an error 515 * but the -k flag was given, our 'make' field will be set to false 516 * again. This is our signal to not attempt to do anything but abort 517 * our parent as well. 518 */ 519 gn->flags.remake = true; 520 gn->made = BEINGMADE; 521 522 if (!(gn->type & OP_MADE)) 523 Suff_FindDeps(gn); 524 525 MakeNodes(&gn->children, gn); 526 527 if (!gn->flags.remake) { 528 gn->made = ABORTED; 529 pgn->flags.remake = false; 530 return false; 531 } 532 533 if (Lst_FindDatum(&gn->implicitParents, pgn) != NULL) 534 Var_Set(pgn, IMPSRC, GNode_VarTarget(gn)); 535 536 /* 537 * All the children were made ok. Now youngestChild->mtime contains the 538 * modification time of the newest child, we need to find out if we 539 * exist and when we were modified last. The criteria for datedness 540 * are defined by GNode_IsOODate. 541 */ 542 DEBUG1(MAKE, "Examining %s...", gn->name); 543 if (!GNode_IsOODate(gn)) { 544 gn->made = UPTODATE; 545 DEBUG0(MAKE, "up-to-date.\n"); 546 return false; 547 } 548 549 /* 550 * If the user is just seeing if something is out-of-date, exit now 551 * to tell him/her "yes". 552 */ 553 DEBUG0(MAKE, "out-of-date.\n"); 554 if (opts.query && gn != Targ_GetEndNode()) 555 exit(1); 556 557 /* 558 * We need to be re-made. 559 * Ensure that $? (.OODATE) and $> (.ALLSRC) are both set. 560 */ 561 GNode_SetLocalVars(gn); 562 563 /* 564 * Alter our type to tell if errors should be ignored or things 565 * should not be printed so Compat_RunCommand knows what to do. 566 */ 567 if (opts.ignoreErrors) 568 gn->type |= OP_IGNORE; 569 if (opts.silent) 570 gn->type |= OP_SILENT; 571 572 if (Job_CheckCommands(gn, Fatal)) { 573 if (!opts.touch || (gn->type & OP_MAKE)) { 574 curTarg = gn; 575 #ifdef USE_META 576 if (useMeta && GNode_ShouldExecute(gn)) 577 meta_job_start(NULL, gn); 578 #endif 579 RunCommands(gn); 580 curTarg = NULL; 581 } else { 582 Job_Touch(gn, (gn->type & OP_SILENT) != OP_NONE); 583 } 584 } else { 585 gn->made = ERROR; 586 } 587 #ifdef USE_META 588 if (useMeta && GNode_ShouldExecute(gn)) { 589 if (meta_job_finish(NULL) != 0) 590 gn->made = ERROR; 591 } 592 #endif 593 594 if (gn->made != ERROR) { 595 /* 596 * If the node was made successfully, mark it so, update 597 * its modification time and timestamp all its parents. 598 * This is to keep its state from affecting that of its parent. 599 */ 600 gn->made = MADE; 601 if (Make_Recheck(gn) == 0) 602 pgn->flags.force = true; 603 if (!(gn->type & OP_EXEC)) { 604 pgn->flags.childMade = true; 605 GNode_UpdateYoungestChild(pgn, gn); 606 } 607 } else if (opts.keepgoing) { 608 pgn->flags.remake = false; 609 } else { 610 PrintOnError(gn, "\nStop.\n"); 611 exit(1); 612 } 613 return true; 614 } 615 616 static void 617 MakeOther(GNode *gn, GNode *pgn) 618 { 619 620 if (Lst_FindDatum(&gn->implicitParents, pgn) != NULL) { 621 const char *target = GNode_VarTarget(gn); 622 Var_Set(pgn, IMPSRC, target != NULL ? target : ""); 623 } 624 625 switch (gn->made) { 626 case BEINGMADE: 627 Error("Graph cycles through %s", gn->name); 628 gn->made = ERROR; 629 pgn->flags.remake = false; 630 break; 631 case MADE: 632 if (!(gn->type & OP_EXEC)) { 633 pgn->flags.childMade = true; 634 GNode_UpdateYoungestChild(pgn, gn); 635 } 636 break; 637 case UPTODATE: 638 if (!(gn->type & OP_EXEC)) 639 GNode_UpdateYoungestChild(pgn, gn); 640 break; 641 default: 642 break; 643 } 644 } 645 646 /* 647 * Make a target. 648 * 649 * If an error is detected and not being ignored, the process exits. 650 * 651 * Input: 652 * gn The node to make 653 * pgn Parent to abort if necessary 654 * 655 * Output: 656 * gn->made 657 * UPTODATE gn was already up-to-date. 658 * MADE gn was recreated successfully. 659 * ERROR An error occurred while gn was being created, 660 * either due to missing commands or in -k mode. 661 * ABORTED gn was not remade because one of its 662 * dependencies could not be made due to errors. 663 */ 664 void 665 Compat_Make(GNode *gn, GNode *pgn) 666 { 667 if (shellName == NULL) /* we came here from jobs */ 668 Shell_Init(); 669 670 if (gn->made == UNMADE && (gn == pgn || !(pgn->type & OP_MADE))) { 671 if (!MakeUnmade(gn, pgn)) 672 goto cohorts; 673 674 /* XXX: Replace with GNode_IsError(gn) */ 675 } else if (gn->made == ERROR) { 676 /* 677 * Already had an error when making this. 678 * Tell the parent to abort. 679 */ 680 pgn->flags.remake = false; 681 } else { 682 MakeOther(gn, pgn); 683 } 684 685 cohorts: 686 MakeNodes(&gn->cohorts, pgn); 687 } 688 689 static void 690 MakeBeginNode(void) 691 { 692 GNode *gn = Targ_FindNode(".BEGIN"); 693 if (gn == NULL) 694 return; 695 696 Compat_Make(gn, gn); 697 if (GNode_IsError(gn)) { 698 PrintOnError(gn, "\nStop.\n"); 699 exit(1); 700 } 701 } 702 703 static void 704 InitSignals(void) 705 { 706 if (bmake_signal(SIGINT, SIG_IGN) != SIG_IGN) 707 bmake_signal(SIGINT, CompatInterrupt); 708 if (bmake_signal(SIGTERM, SIG_IGN) != SIG_IGN) 709 bmake_signal(SIGTERM, CompatInterrupt); 710 if (bmake_signal(SIGHUP, SIG_IGN) != SIG_IGN) 711 bmake_signal(SIGHUP, CompatInterrupt); 712 if (bmake_signal(SIGQUIT, SIG_IGN) != SIG_IGN) 713 bmake_signal(SIGQUIT, CompatInterrupt); 714 } 715 716 void 717 Compat_MakeAll(GNodeList *targs) 718 { 719 GNode *errorNode = NULL; 720 721 if (shellName == NULL) 722 Shell_Init(); 723 724 InitSignals(); 725 726 /* 727 * Create the .END node now, to keep the (debug) output of the 728 * counter.mk test the same as before 2020-09-23. This 729 * implementation detail probably doesn't matter though. 730 */ 731 (void)Targ_GetEndNode(); 732 733 if (!opts.query) 734 MakeBeginNode(); 735 736 /* 737 * Expand .USE nodes right now, because they can modify the structure 738 * of the tree. 739 */ 740 Make_ExpandUse(targs); 741 742 while (!Lst_IsEmpty(targs)) { 743 GNode *gn = Lst_Dequeue(targs); 744 Compat_Make(gn, gn); 745 746 if (gn->made == UPTODATE) { 747 printf("`%s' is up to date.\n", gn->name); 748 } else if (gn->made == ABORTED) { 749 printf("`%s' not remade because of errors.\n", 750 gn->name); 751 } 752 if (GNode_IsError(gn) && errorNode == NULL) 753 errorNode = gn; 754 } 755 756 if (errorNode == NULL) { 757 GNode *endNode = Targ_GetEndNode(); 758 Compat_Make(endNode, endNode); 759 if (GNode_IsError(endNode)) 760 errorNode = endNode; 761 } 762 763 if (errorNode != NULL) { 764 if (DEBUG(GRAPH2)) 765 Targ_PrintGraph(2); 766 else if (DEBUG(GRAPH3)) 767 Targ_PrintGraph(3); 768 PrintOnError(errorNode, "\nStop.\n"); 769 exit(1); 770 } 771 } 772