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