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