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