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