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