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