Annotation of src/usr.bin/make/compat.c, Revision 1.20
1.20 ! espie 1: /* $OpenBSD: compat.c,v 1.19 1999/12/18 21:56:07 espie Exp $ */
1.8 millert 2: /* $NetBSD: compat.c,v 1.14 1996/11/06 17:59:01 christos Exp $ */
1.1 deraadt 3:
4: /*
5: * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
6: * Copyright (c) 1988, 1989 by Adam de Boor
7: * Copyright (c) 1989 by Berkeley Softworks
8: * All rights reserved.
9: *
10: * This code is derived from software contributed to Berkeley by
11: * Adam de Boor.
12: *
13: * Redistribution and use in source and binary forms, with or without
14: * modification, are permitted provided that the following conditions
15: * are met:
16: * 1. Redistributions of source code must retain the above copyright
17: * notice, this list of conditions and the following disclaimer.
18: * 2. Redistributions in binary form must reproduce the above copyright
19: * notice, this list of conditions and the following disclaimer in the
20: * documentation and/or other materials provided with the distribution.
21: * 3. All advertising materials mentioning features or use of this software
22: * must display the following acknowledgement:
23: * This product includes software developed by the University of
24: * California, Berkeley and its contributors.
25: * 4. Neither the name of the University nor the names of its contributors
26: * may be used to endorse or promote products derived from this software
27: * without specific prior written permission.
28: *
29: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39: * SUCH DAMAGE.
40: */
41:
42: #ifndef lint
43: #if 0
1.4 millert 44: static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
1.1 deraadt 45: #else
1.20 ! espie 46: static char rcsid[] = "$OpenBSD: compat.c,v 1.19 1999/12/18 21:56:07 espie Exp $";
1.1 deraadt 47: #endif
48: #endif /* not lint */
49:
50: /*-
51: * compat.c --
52: * The routines in this file implement the full-compatibility
53: * mode of PMake. Most of the special functionality of PMake
54: * is available in this mode. Things not supported:
55: * - different shells.
56: * - friendly variable substitution.
57: *
58: * Interface:
59: * Compat_Run Initialize things for this module and recreate
60: * thems as need creatin'
61: */
62:
63: #include <stdio.h>
64: #include <sys/types.h>
65: #include <sys/stat.h>
66: #include <sys/wait.h>
67: #include <ctype.h>
68: #include <errno.h>
69: #include <signal.h>
70: #include "make.h"
71: #include "hash.h"
72: #include "dir.h"
73: #include "job.h"
74: extern int errno;
75:
76: /*
77: * The following array is used to make a fast determination of which
78: * characters are interpreted specially by the shell. If a command
79: * contains any of these characters, it is executed by the shell, not
80: * directly by us.
81: */
82:
83: static char meta[256];
84:
1.18 espie 85: static GNode *curTarg = NULL;
1.1 deraadt 86: static GNode *ENDNode;
87: static void CompatInterrupt __P((int));
88: static int CompatRunCommand __P((ClientData, ClientData));
89: static int CompatMake __P((ClientData, ClientData));
1.13 espie 90: static int shellneed __P((char **av));
1.1 deraadt 91:
92: /*-
93: *-----------------------------------------------------------------------
94: * CompatInterrupt --
95: * Interrupt the creation of the current target and remove it if
96: * it ain't precious.
97: *
98: * Results:
99: * None.
100: *
101: * Side Effects:
102: * The target is removed and the process exits. If .INTERRUPT exists,
103: * its commands are run first WITH INTERRUPTS IGNORED..
104: *
105: *-----------------------------------------------------------------------
106: */
107: static void
108: CompatInterrupt (signo)
109: int signo;
110: {
111: GNode *gn;
1.4 millert 112:
1.18 espie 113: if ((curTarg != NULL) && !Targ_Precious (curTarg)) {
1.15 espie 114: char *file = Var_Value(TARGET, curTarg);
1.1 deraadt 115:
1.2 deraadt 116: if (!noExecute && eunlink(file) != -1) {
1.12 espie 117: Error("*** %s removed\n", file);
1.1 deraadt 118: }
119:
120: /*
121: * Run .INTERRUPT only if hit with interrupt signal
122: */
123: if (signo == SIGINT) {
124: gn = Targ_FindNode(".INTERRUPT", TARG_NOCREATE);
1.18 espie 125: if (gn != NULL) {
1.1 deraadt 126: Lst_ForEach(gn->commands, CompatRunCommand, (ClientData)gn);
127: }
128: }
129:
130: }
131: exit (signo);
132: }
133:
134: /*-
135: *-----------------------------------------------------------------------
1.10 deraadt 136: * shellneed --
137: *
138: * Results:
1.12 espie 139: * Returns 1 if a specified set of arguments
140: * must be executed by the shell,
141: * 0 if it can be run via execve, and -1 if the command can be
142: * handled internally
1.10 deraadt 143: *
144: * Side Effects:
1.12 espie 145: * May modify the process umask
1.10 deraadt 146: *
147: *-----------------------------------------------------------------------
148: */
149: static int
1.12 espie 150: shellneed (av)
151: char **av;
1.10 deraadt 152: {
1.11 deraadt 153: char *runsh[] = {
154: "alias", "cd", "eval", "exec", "exit", "read", "set", "ulimit",
1.12 espie 155: "unalias", "unset", "wait",
1.11 deraadt 156: NULL
157: };
158:
1.12 espie 159: char **p;
1.11 deraadt 160:
1.12 espie 161: /* FIXME most of these ARE actual no-ops */
1.11 deraadt 162: for (p = runsh; *p; p++)
1.12 espie 163: if (strcmp(av[0], *p) == 0)
1.11 deraadt 164: return (1);
165:
1.12 espie 166: if (strcmp(av[0], "umask") == 0) {
1.10 deraadt 167: long umi;
168: char *ep = NULL;
169: mode_t um;
170:
1.12 espie 171: if (av[1] != NULL) {
172: umi = strtol(av[1], &ep, 8);
1.10 deraadt 173: if (ep == NULL)
174: return (1);
175: um = umi;
176: }
1.12 espie 177: else {
178: um = umask(0);
179: printf("%o\n", um);
180: }
1.10 deraadt 181: (void) umask(um);
182: return (-1);
183: }
184:
185: return (0);
186: }
187:
188: /*-
189: *-----------------------------------------------------------------------
1.1 deraadt 190: * CompatRunCommand --
191: * Execute the next command for a target. If the command returns an
192: * error, the node's made field is set to ERROR and creation stops.
193: *
194: * Results:
195: * 0 if the command succeeded, 1 if an error occurred.
196: *
197: * Side Effects:
198: * The node's 'made' field may be set to ERROR.
199: *
200: *-----------------------------------------------------------------------
201: */
202: static int
203: CompatRunCommand (cmdp, gnp)
204: ClientData cmdp; /* Command to execute */
205: ClientData gnp; /* Node from which the command came */
206: {
207: char *cmdStart; /* Start of expanded command */
1.12 espie 208: char *cp, *bp = NULL;
1.1 deraadt 209: Boolean silent, /* Don't print command */
210: errCheck; /* Check errors */
1.2 deraadt 211: int reason; /* Reason for child's death */
1.1 deraadt 212: int status; /* Description of child's death */
213: int cpid; /* Child actually found */
214: ReturnStatus stat; /* Status of fork */
215: LstNode cmdNode; /* Node where current command is located */
216: char **av; /* Argument vector for thing to exec */
217: int argc; /* Number of arguments in av or 0 if not
218: * dynamically allocated */
219: Boolean local; /* TRUE if command should be executed
220: * locally */
221: char *cmd = (char *) cmdp;
222: GNode *gn = (GNode *) gnp;
1.12 espie 223: static char *shargv[4] = { "/bin/sh" };
1.1 deraadt 224:
1.4 millert 225: /*
1.1 deraadt 226: * Avoid clobbered variable warnings by forcing the compiler
227: * to ``unregister'' variables
228: */
229: #if __GNUC__
230: (void) &av;
231: (void) &errCheck;
232: #endif
233: silent = gn->type & OP_SILENT;
234: errCheck = !(gn->type & OP_IGNORE);
235:
236: cmdNode = Lst_Member (gn->commands, (ClientData)cmd);
1.16 espie 237: cmdStart = Var_Subst(cmd, gn, FALSE);
1.1 deraadt 238:
239: /*
1.12 espie 240: * brk_string will return an argv with a NULL in av[0], thus causing
1.1 deraadt 241: * execvp to choke and die horribly. Besides, how can we execute a null
242: * command? In any case, we warn the user that the command expanded to
243: * nothing (is this the right thing to do?).
244: */
1.4 millert 245:
1.1 deraadt 246: if (*cmdStart == '\0') {
247: free(cmdStart);
248: Error("%s expands to empty string", cmd);
249: return(0);
250: } else {
251: cmd = cmdStart;
252: }
253: Lst_Replace (cmdNode, (ClientData)cmdStart);
254:
255: if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) {
1.20 ! espie 256: Lst_AtEnd(ENDNode->commands, (ClientData)cmdStart);
1.1 deraadt 257: return(0);
258: } else if (strcmp(cmdStart, "...") == 0) {
259: gn->type |= OP_SAVE_CMDS;
260: return(0);
261: }
262:
263: while ((*cmd == '@') || (*cmd == '-')) {
264: if (*cmd == '@') {
265: silent = TRUE;
266: } else {
267: errCheck = FALSE;
268: }
269: cmd++;
270: }
271:
272: while (isspace((unsigned char)*cmd))
273: cmd++;
1.4 millert 274:
1.1 deraadt 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: for (cp = cmd; !meta[(unsigned char)*cp]; cp++) {
281: continue;
282: }
283:
284: /*
285: * Print the command before echoing if we're not supposed to be quiet for
286: * this one. We also print the command if -n given.
287: */
288: if (!silent || noExecute) {
289: printf ("%s\n", cmd);
290: fflush(stdout);
291: }
292:
293: /*
294: * If we're not supposed to execute any commands, this is as far as
295: * we go...
296: */
297: if (noExecute) {
298: return (0);
299: }
1.4 millert 300:
1.1 deraadt 301: if (*cp != '\0') {
302: /*
303: * If *cp isn't the null character, we hit a "meta" character and
304: * need to pass the command off to the shell. We give the shell the
305: * -e flag as well as -c if it's supposed to exit when it hits an
306: * error.
307: */
1.10 deraadt 308:
309: shargv[1] = (errCheck ? "-ec" : "-c");
310: shargv[2] = cmd;
311: shargv[3] = (char *)NULL;
312: av = shargv;
313: argc = 0;
1.12 espie 314: } else {
1.10 deraadt 315: /*
1.12 espie 316: * No meta-characters, so probably no need to exec a shell.
317: * Break the command into words to form an argument vector
318: * we can execute.
1.10 deraadt 319: */
1.12 espie 320: av = brk_string(cmd, &argc, TRUE, &bp);
321: switch(shellneed(av)) {
322: case -1: /* handled internally */
323: free(bp);
324: free(av);
325: return 0;
326: case 1:
327: shargv[1] = (errCheck ? "-ec" : "-c");
328: shargv[2] = cmd;
329: shargv[3] = (char *)NULL;
1.14 espie 330: free(bp);
331: free(av);
332: bp = NULL;
1.12 espie 333: av = shargv;
334: argc = 0;
335: break;
336: default: /* nothing needed */
337: break;
1.10 deraadt 338: }
1.1 deraadt 339: }
1.4 millert 340:
1.1 deraadt 341: local = TRUE;
342:
343: /*
344: * Fork and execute the single command. If the fork fails, we abort.
345: */
346: cpid = vfork();
347: if (cpid < 0) {
348: Fatal("Could not fork");
349: }
350: if (cpid == 0) {
351: if (local) {
352: execvp(av[0], av);
1.17 espie 353: if (errno == ENOENT)
354: fprintf(stderr, "%s: not found\n", av[0]);
355: else
356: perror(av[0]);
1.1 deraadt 357: } else {
358: (void)execv(av[0], av);
359: }
1.9 deraadt 360: _exit(1);
1.1 deraadt 361: }
1.12 espie 362: if (bp) {
363: free(av);
364: free(bp);
365: }
1.1 deraadt 366: free(cmdStart);
1.20 ! espie 367: Lst_Replace(cmdNode, (ClientData)NULL);
1.4 millert 368:
1.1 deraadt 369: /*
370: * The child is off and running. Now all we can do is wait...
371: */
372: while (1) {
373:
1.2 deraadt 374: while ((stat = wait(&reason)) != cpid) {
1.1 deraadt 375: if (stat == -1 && errno != EINTR) {
376: break;
377: }
378: }
1.4 millert 379:
1.1 deraadt 380: if (stat > -1) {
381: if (WIFSTOPPED(reason)) {
1.2 deraadt 382: status = WSTOPSIG(reason); /* stopped */
1.1 deraadt 383: } else if (WIFEXITED(reason)) {
1.2 deraadt 384: status = WEXITSTATUS(reason); /* exited */
1.1 deraadt 385: if (status != 0) {
386: printf ("*** Error code %d", status);
387: }
388: } else {
1.2 deraadt 389: status = WTERMSIG(reason); /* signaled */
1.1 deraadt 390: printf ("*** Signal %d", status);
1.4 millert 391: }
392:
1.1 deraadt 393:
394: if (!WIFEXITED(reason) || (status != 0)) {
395: if (errCheck) {
396: gn->made = ERROR;
397: if (keepgoing) {
398: /*
399: * Abort the current target, but let others
400: * continue.
401: */
402: printf (" (continuing)\n");
403: }
404: } else {
405: /*
406: * Continue executing commands for this target.
407: * If we return 0, this will happen...
408: */
409: printf (" (ignored)\n");
410: status = 0;
411: }
412: }
413: break;
414: } else {
415: Fatal ("error in wait: %d", stat);
416: /*NOTREACHED*/
417: }
418: }
419:
420: return (status);
421: }
422:
423: /*-
424: *-----------------------------------------------------------------------
425: * CompatMake --
426: * Make a target.
427: *
428: * Results:
429: * 0
430: *
431: * Side Effects:
432: * If an error is detected and not being ignored, the process exits.
433: *
434: *-----------------------------------------------------------------------
435: */
436: static int
437: CompatMake (gnp, pgnp)
438: ClientData gnp; /* The node to make */
439: ClientData pgnp; /* Parent to abort if necessary */
440: {
441: GNode *gn = (GNode *) gnp;
442: GNode *pgn = (GNode *) pgnp;
1.5 millert 443:
1.7 deraadt 444: if (pgn->type & OP_MADE) {
445: (void) Dir_MTime(gn);
446: gn->made = UPTODATE;
447: }
448:
1.8 millert 449: if (gn->type & OP_USE) {
450: Make_HandleUse(gn, pgn);
451: } else if (gn->made == UNMADE) {
1.1 deraadt 452: /*
453: * First mark ourselves to be made, then apply whatever transformations
454: * the suffix module thinks are necessary. Once that's done, we can
455: * descend and make all our children. If any of them has an error
456: * but the -k flag was given, our 'make' field will be set FALSE again.
457: * This is our signal to not attempt to do anything but abort our
458: * parent as well.
459: */
460: gn->make = TRUE;
461: gn->made = BEINGMADE;
462: Suff_FindDeps (gn);
463: Lst_ForEach (gn->children, CompatMake, (ClientData)gn);
464: if (!gn->make) {
465: gn->made = ABORTED;
466: pgn->make = FALSE;
467: return (0);
468: }
469:
1.18 espie 470: if (Lst_Member (gn->iParents, pgn) != NULL) {
1.15 espie 471: Var_Set(IMPSRC, Var_Value(TARGET, gn), pgn);
1.1 deraadt 472: }
1.4 millert 473:
1.1 deraadt 474: /*
475: * All the children were made ok. Now cmtime contains the modification
476: * time of the newest child, we need to find out if we exist and when
477: * we were modified last. The criteria for datedness are defined by the
478: * Make_OODate function.
479: */
480: if (DEBUG(MAKE)) {
481: printf("Examining %s...", gn->name);
482: }
483: if (! Make_OODate(gn)) {
484: gn->made = UPTODATE;
485: if (DEBUG(MAKE)) {
486: printf("up-to-date.\n");
487: }
488: return (0);
489: } else if (DEBUG(MAKE)) {
490: printf("out-of-date.\n");
491: }
492:
493: /*
494: * If the user is just seeing if something is out-of-date, exit now
495: * to tell him/her "yes".
496: */
497: if (queryFlag) {
498: exit (-1);
499: }
500:
501: /*
502: * We need to be re-made. We also have to make sure we've got a $?
503: * variable. To be nice, we also define the $> variable using
504: * Make_DoAllVar().
505: */
506: Make_DoAllVar(gn);
1.4 millert 507:
1.1 deraadt 508: /*
509: * Alter our type to tell if errors should be ignored or things
510: * should not be printed so CompatRunCommand knows what to do.
511: */
512: if (Targ_Ignore (gn)) {
513: gn->type |= OP_IGNORE;
514: }
515: if (Targ_Silent (gn)) {
516: gn->type |= OP_SILENT;
517: }
518:
519: if (Job_CheckCommands (gn, Fatal)) {
520: /*
521: * Our commands are ok, but we still have to worry about the -t
522: * flag...
523: */
524: if (!touchFlag) {
525: curTarg = gn;
526: Lst_ForEach (gn->commands, CompatRunCommand, (ClientData)gn);
1.18 espie 527: curTarg = NULL;
1.1 deraadt 528: } else {
529: Job_Touch (gn, gn->type & OP_SILENT);
530: }
531: } else {
532: gn->made = ERROR;
533: }
534:
535: if (gn->made != ERROR) {
536: /*
537: * If the node was made successfully, mark it so, update
538: * its modification time and timestamp all its parents. Note
539: * that for .ZEROTIME targets, the timestamping isn't done.
540: * This is to keep its state from affecting that of its parent.
541: */
542: gn->made = MADE;
543: #ifndef RECHECK
544: /*
545: * We can't re-stat the thing, but we can at least take care of
546: * rules where a target depends on a source that actually creates
547: * the target, but only if it has changed, e.g.
548: *
549: * parse.h : parse.o
550: *
551: * parse.o : parse.y
552: * yacc -d parse.y
553: * cc -c y.tab.c
554: * mv y.tab.o parse.o
555: * cmp -s y.tab.h parse.h || mv y.tab.h parse.h
556: *
557: * In this case, if the definitions produced by yacc haven't
558: * changed from before, parse.h won't have been updated and
559: * gn->mtime will reflect the current modification time for
560: * parse.h. This is something of a kludge, I admit, but it's a
561: * useful one..
562: *
563: * XXX: People like to use a rule like
564: *
565: * FRC:
566: *
567: * To force things that depend on FRC to be made, so we have to
568: * check for gn->children being empty as well...
569: */
570: if (!Lst_IsEmpty(gn->commands) || Lst_IsEmpty(gn->children)) {
571: gn->mtime = now;
572: }
573: #else
574: /*
575: * This is what Make does and it's actually a good thing, as it
576: * allows rules like
577: *
578: * cmp -s y.tab.h parse.h || cp y.tab.h parse.h
579: *
580: * to function as intended. Unfortunately, thanks to the stateless
581: * nature of NFS (and the speed of this program), there are times
582: * when the modification time of a file created on a remote
583: * machine will not be modified before the stat() implied by
584: * the Dir_MTime occurs, thus leading us to believe that the file
585: * is unchanged, wreaking havoc with files that depend on this one.
586: *
587: * I have decided it is better to make too much than to make too
588: * little, so this stuff is commented out unless you're sure it's
589: * ok.
590: * -- ardeb 1/12/88
591: */
592: if (noExecute || Dir_MTime(gn) == 0) {
593: gn->mtime = now;
594: }
595: if (gn->cmtime > gn->mtime)
596: gn->mtime = gn->cmtime;
597: if (DEBUG(MAKE)) {
598: printf("update time: %s\n", Targ_FmtTime(gn->mtime));
599: }
600: #endif
601: if (!(gn->type & OP_EXEC)) {
602: pgn->childMade = TRUE;
603: Make_TimeStamp(pgn, gn);
604: }
605: } else if (keepgoing) {
606: pgn->make = FALSE;
607: } else {
1.15 espie 608: printf ("\n\nStop in %s.\n", Var_Value(".CURDIR", gn));
1.1 deraadt 609: exit (1);
610: }
611: } else if (gn->made == ERROR) {
612: /*
613: * Already had an error when making this beastie. Tell the parent
614: * to abort.
615: */
616: pgn->make = FALSE;
617: } else {
1.18 espie 618: if (Lst_Member (gn->iParents, pgn) != NULL)
1.15 espie 619: Var_Set (IMPSRC, Var_Value(TARGET, gn), pgn);
1.1 deraadt 620: switch(gn->made) {
621: case BEINGMADE:
622: Error("Graph cycles through %s\n", gn->name);
623: gn->made = ERROR;
624: pgn->make = FALSE;
625: break;
626: case MADE:
627: if ((gn->type & OP_EXEC) == 0) {
628: pgn->childMade = TRUE;
629: Make_TimeStamp(pgn, gn);
630: }
631: break;
632: case UPTODATE:
633: if ((gn->type & OP_EXEC) == 0) {
634: Make_TimeStamp(pgn, gn);
635: }
636: break;
637: default:
638: break;
639: }
640: }
641:
642: return (0);
643: }
1.4 millert 644:
1.1 deraadt 645: /*-
646: *-----------------------------------------------------------------------
647: * Compat_Run --
648: * Initialize this mode and start making.
649: *
650: * Results:
651: * None.
652: *
653: * Side Effects:
654: * Guess what?
655: *
656: *-----------------------------------------------------------------------
657: */
658: void
659: Compat_Run(targs)
660: Lst targs; /* List of target nodes to re-create */
661: {
662: char *cp; /* Pointer to string of shell meta-characters */
663: GNode *gn = NULL;/* Current root target */
664: int errors; /* Number of targets not remade due to errors */
665:
666: if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
667: signal(SIGINT, CompatInterrupt);
668: }
669: if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
670: signal(SIGTERM, CompatInterrupt);
671: }
672: if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
673: signal(SIGHUP, CompatInterrupt);
674: }
675: if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) {
676: signal(SIGQUIT, CompatInterrupt);
677: }
678:
679: for (cp = "#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++) {
680: meta[(unsigned char) *cp] = 1;
681: }
682: /*
683: * The null character serves as a sentinel in the string.
684: */
685: meta[0] = 1;
686:
687: ENDNode = Targ_FindNode(".END", TARG_CREATE);
688: /*
689: * If the user has defined a .BEGIN target, execute the commands attached
690: * to it.
691: */
692: if (!queryFlag) {
693: gn = Targ_FindNode(".BEGIN", TARG_NOCREATE);
1.18 espie 694: if (gn != NULL) {
1.1 deraadt 695: Lst_ForEach(gn->commands, CompatRunCommand, (ClientData)gn);
1.4 millert 696: if (gn->made == ERROR) {
697: printf("\n\nStop.\n");
698: exit(1);
699: }
1.1 deraadt 700: }
701: }
702:
703: /*
704: * For each entry in the list of targets to create, call CompatMake on
705: * it to create the thing. CompatMake will leave the 'made' field of gn
706: * in one of several states:
707: * UPTODATE gn was already up-to-date
708: * MADE gn was recreated successfully
709: * ERROR An error occurred while gn was being created
710: * ABORTED gn was not remade because one of its inferiors
711: * could not be made due to errors.
712: */
713: errors = 0;
1.19 espie 714: while ((gn = (GNode *)Lst_DeQueue(targs)) != NULL) {
1.1 deraadt 715: CompatMake (gn, gn);
716:
717: if (gn->made == UPTODATE) {
718: printf ("`%s' is up to date.\n", gn->name);
719: } else if (gn->made == ABORTED) {
720: printf ("`%s' not remade because of errors.\n", gn->name);
721: errors += 1;
722: }
723: }
724:
725: /*
726: * If the user has defined a .END target, run its commands.
727: */
728: if (errors == 0) {
729: Lst_ForEach(ENDNode->commands, CompatRunCommand, (ClientData)gn);
730: }
731: }