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