Annotation of src/usr.bin/make/compat.c, Revision 1.14
1.14 ! espie 1: /* $OpenBSD: compat.c,v 1.13 1999/11/10 14:11:49 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.14 ! espie 46: static char rcsid[] = "$OpenBSD: compat.c,v 1.13 1999/11/10 14:11:49 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:
85: static GNode *curTarg = NILGNODE;
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.1 deraadt 113: if ((curTarg != NILGNODE) && !Targ_Precious (curTarg)) {
114: char *p1;
115: char *file = Var_Value (TARGET, curTarg, &p1);
116:
1.2 deraadt 117: if (!noExecute && eunlink(file) != -1) {
1.12 espie 118: Error("*** %s removed\n", file);
1.1 deraadt 119: }
1.12 espie 120: efree(p1);
1.1 deraadt 121:
122: /*
123: * Run .INTERRUPT only if hit with interrupt signal
124: */
125: if (signo == SIGINT) {
126: gn = Targ_FindNode(".INTERRUPT", TARG_NOCREATE);
127: if (gn != NILGNODE) {
128: Lst_ForEach(gn->commands, CompatRunCommand, (ClientData)gn);
129: }
130: }
131:
132: }
133: exit (signo);
134: }
135:
136: /*-
137: *-----------------------------------------------------------------------
1.10 deraadt 138: * shellneed --
139: *
140: * Results:
1.12 espie 141: * Returns 1 if a specified set of arguments
142: * must be executed by the shell,
143: * 0 if it can be run via execve, and -1 if the command can be
144: * handled internally
1.10 deraadt 145: *
146: * Side Effects:
1.12 espie 147: * May modify the process umask
1.10 deraadt 148: *
149: *-----------------------------------------------------------------------
150: */
151: static int
1.12 espie 152: shellneed (av)
153: char **av;
1.10 deraadt 154: {
1.11 deraadt 155: char *runsh[] = {
156: "alias", "cd", "eval", "exec", "exit", "read", "set", "ulimit",
1.12 espie 157: "unalias", "unset", "wait",
1.11 deraadt 158: NULL
159: };
160:
1.12 espie 161: char **p;
1.11 deraadt 162:
1.12 espie 163: /* FIXME most of these ARE actual no-ops */
1.11 deraadt 164: for (p = runsh; *p; p++)
1.12 espie 165: if (strcmp(av[0], *p) == 0)
1.11 deraadt 166: return (1);
167:
1.12 espie 168: if (strcmp(av[0], "umask") == 0) {
1.10 deraadt 169: long umi;
170: char *ep = NULL;
171: mode_t um;
172:
1.12 espie 173: if (av[1] != NULL) {
174: umi = strtol(av[1], &ep, 8);
1.10 deraadt 175: if (ep == NULL)
176: return (1);
177: um = umi;
178: }
1.12 espie 179: else {
180: um = umask(0);
181: printf("%o\n", um);
182: }
1.10 deraadt 183: (void) umask(um);
184: return (-1);
185: }
186:
187: return (0);
188: }
189:
190: /*-
191: *-----------------------------------------------------------------------
1.1 deraadt 192: * CompatRunCommand --
193: * Execute the next command for a target. If the command returns an
194: * error, the node's made field is set to ERROR and creation stops.
195: *
196: * Results:
197: * 0 if the command succeeded, 1 if an error occurred.
198: *
199: * Side Effects:
200: * The node's 'made' field may be set to ERROR.
201: *
202: *-----------------------------------------------------------------------
203: */
204: static int
205: CompatRunCommand (cmdp, gnp)
206: ClientData cmdp; /* Command to execute */
207: ClientData gnp; /* Node from which the command came */
208: {
209: char *cmdStart; /* Start of expanded command */
1.12 espie 210: char *cp, *bp = NULL;
1.1 deraadt 211: Boolean silent, /* Don't print command */
212: errCheck; /* Check errors */
1.2 deraadt 213: int reason; /* Reason for child's death */
1.1 deraadt 214: int status; /* Description of child's death */
215: int cpid; /* Child actually found */
216: ReturnStatus stat; /* Status of fork */
217: LstNode cmdNode; /* Node where current command is located */
218: char **av; /* Argument vector for thing to exec */
219: int argc; /* Number of arguments in av or 0 if not
220: * dynamically allocated */
221: Boolean local; /* TRUE if command should be executed
222: * locally */
223: char *cmd = (char *) cmdp;
224: GNode *gn = (GNode *) gnp;
1.12 espie 225: static char *shargv[4] = { "/bin/sh" };
1.1 deraadt 226:
1.4 millert 227: /*
1.1 deraadt 228: * Avoid clobbered variable warnings by forcing the compiler
229: * to ``unregister'' variables
230: */
231: #if __GNUC__
232: (void) &av;
233: (void) &errCheck;
234: #endif
235: silent = gn->type & OP_SILENT;
236: errCheck = !(gn->type & OP_IGNORE);
237:
238: cmdNode = Lst_Member (gn->commands, (ClientData)cmd);
239: cmdStart = Var_Subst (NULL, cmd, gn, FALSE);
240:
241: /*
1.12 espie 242: * brk_string will return an argv with a NULL in av[0], thus causing
1.1 deraadt 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: */
1.4 millert 247:
1.1 deraadt 248: if (*cmdStart == '\0') {
249: free(cmdStart);
250: Error("%s expands to empty string", cmd);
251: return(0);
252: } else {
253: cmd = cmdStart;
254: }
255: Lst_Replace (cmdNode, (ClientData)cmdStart);
256:
257: if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) {
258: (void)Lst_AtEnd(ENDNode->commands, (ClientData)cmdStart);
259: return(0);
260: } else if (strcmp(cmdStart, "...") == 0) {
261: gn->type |= OP_SAVE_CMDS;
262: return(0);
263: }
264:
265: while ((*cmd == '@') || (*cmd == '-')) {
266: if (*cmd == '@') {
267: silent = TRUE;
268: } else {
269: errCheck = FALSE;
270: }
271: cmd++;
272: }
273:
274: while (isspace((unsigned char)*cmd))
275: cmd++;
1.4 millert 276:
1.1 deraadt 277: /*
278: * Search for meta characters in the command. If there are no meta
279: * characters, there's no need to execute a shell to execute the
280: * command.
281: */
282: for (cp = cmd; !meta[(unsigned char)*cp]; cp++) {
283: continue;
284: }
285:
286: /*
287: * Print the command before echoing if we're not supposed to be quiet for
288: * this one. We also print the command if -n given.
289: */
290: if (!silent || noExecute) {
291: printf ("%s\n", cmd);
292: fflush(stdout);
293: }
294:
295: /*
296: * If we're not supposed to execute any commands, this is as far as
297: * we go...
298: */
299: if (noExecute) {
300: return (0);
301: }
1.4 millert 302:
1.1 deraadt 303: if (*cp != '\0') {
304: /*
305: * If *cp isn't the null character, we hit a "meta" character and
306: * need to pass the command off to the shell. We give the shell the
307: * -e flag as well as -c if it's supposed to exit when it hits an
308: * error.
309: */
1.10 deraadt 310:
311: shargv[1] = (errCheck ? "-ec" : "-c");
312: shargv[2] = cmd;
313: shargv[3] = (char *)NULL;
314: av = shargv;
315: argc = 0;
1.12 espie 316: } else {
1.10 deraadt 317: /*
1.12 espie 318: * No meta-characters, so probably no need to exec a shell.
319: * Break the command into words to form an argument vector
320: * we can execute.
1.10 deraadt 321: */
1.12 espie 322: av = brk_string(cmd, &argc, TRUE, &bp);
323: switch(shellneed(av)) {
324: case -1: /* handled internally */
325: free(bp);
326: free(av);
327: return 0;
328: case 1:
329: shargv[1] = (errCheck ? "-ec" : "-c");
330: shargv[2] = cmd;
331: shargv[3] = (char *)NULL;
1.14 ! espie 332: free(bp);
! 333: free(av);
! 334: bp = NULL;
1.12 espie 335: av = shargv;
336: argc = 0;
337: break;
338: default: /* nothing needed */
339: break;
1.10 deraadt 340: }
1.1 deraadt 341: }
1.4 millert 342:
1.1 deraadt 343: local = TRUE;
344:
345: /*
346: * Fork and execute the single command. If the fork fails, we abort.
347: */
348: cpid = vfork();
349: if (cpid < 0) {
350: Fatal("Could not fork");
351: }
352: if (cpid == 0) {
353: if (local) {
354: execvp(av[0], av);
355: (void) write (2, av[0], strlen (av[0]));
356: (void) write (2, ": not found\n", sizeof(": not found"));
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);
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:
470: if (Lst_Member (gn->iParents, pgn) != NILLNODE) {
471: char *p1;
472: Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
1.12 espie 473: efree(p1);
1.1 deraadt 474: }
1.4 millert 475:
1.1 deraadt 476: /*
477: * All the children were made ok. Now cmtime contains the modification
478: * time of the newest child, we need to find out if we exist and when
479: * we were modified last. The criteria for datedness are defined by the
480: * Make_OODate function.
481: */
482: if (DEBUG(MAKE)) {
483: printf("Examining %s...", gn->name);
484: }
485: if (! Make_OODate(gn)) {
486: gn->made = UPTODATE;
487: if (DEBUG(MAKE)) {
488: printf("up-to-date.\n");
489: }
490: return (0);
491: } else if (DEBUG(MAKE)) {
492: printf("out-of-date.\n");
493: }
494:
495: /*
496: * If the user is just seeing if something is out-of-date, exit now
497: * to tell him/her "yes".
498: */
499: if (queryFlag) {
500: exit (-1);
501: }
502:
503: /*
504: * We need to be re-made. We also have to make sure we've got a $?
505: * variable. To be nice, we also define the $> variable using
506: * Make_DoAllVar().
507: */
508: Make_DoAllVar(gn);
1.4 millert 509:
1.1 deraadt 510: /*
511: * Alter our type to tell if errors should be ignored or things
512: * should not be printed so CompatRunCommand knows what to do.
513: */
514: if (Targ_Ignore (gn)) {
515: gn->type |= OP_IGNORE;
516: }
517: if (Targ_Silent (gn)) {
518: gn->type |= OP_SILENT;
519: }
520:
521: if (Job_CheckCommands (gn, Fatal)) {
522: /*
523: * Our commands are ok, but we still have to worry about the -t
524: * flag...
525: */
526: if (!touchFlag) {
527: curTarg = gn;
528: Lst_ForEach (gn->commands, CompatRunCommand, (ClientData)gn);
529: curTarg = NILGNODE;
530: } else {
531: Job_Touch (gn, gn->type & OP_SILENT);
532: }
533: } else {
534: gn->made = ERROR;
535: }
536:
537: if (gn->made != ERROR) {
538: /*
539: * If the node was made successfully, mark it so, update
540: * its modification time and timestamp all its parents. Note
541: * that for .ZEROTIME targets, the timestamping isn't done.
542: * This is to keep its state from affecting that of its parent.
543: */
544: gn->made = MADE;
545: #ifndef RECHECK
546: /*
547: * We can't re-stat the thing, but we can at least take care of
548: * rules where a target depends on a source that actually creates
549: * the target, but only if it has changed, e.g.
550: *
551: * parse.h : parse.o
552: *
553: * parse.o : parse.y
554: * yacc -d parse.y
555: * cc -c y.tab.c
556: * mv y.tab.o parse.o
557: * cmp -s y.tab.h parse.h || mv y.tab.h parse.h
558: *
559: * In this case, if the definitions produced by yacc haven't
560: * changed from before, parse.h won't have been updated and
561: * gn->mtime will reflect the current modification time for
562: * parse.h. This is something of a kludge, I admit, but it's a
563: * useful one..
564: *
565: * XXX: People like to use a rule like
566: *
567: * FRC:
568: *
569: * To force things that depend on FRC to be made, so we have to
570: * check for gn->children being empty as well...
571: */
572: if (!Lst_IsEmpty(gn->commands) || Lst_IsEmpty(gn->children)) {
573: gn->mtime = now;
574: }
575: #else
576: /*
577: * This is what Make does and it's actually a good thing, as it
578: * allows rules like
579: *
580: * cmp -s y.tab.h parse.h || cp y.tab.h parse.h
581: *
582: * to function as intended. Unfortunately, thanks to the stateless
583: * nature of NFS (and the speed of this program), there are times
584: * when the modification time of a file created on a remote
585: * machine will not be modified before the stat() implied by
586: * the Dir_MTime occurs, thus leading us to believe that the file
587: * is unchanged, wreaking havoc with files that depend on this one.
588: *
589: * I have decided it is better to make too much than to make too
590: * little, so this stuff is commented out unless you're sure it's
591: * ok.
592: * -- ardeb 1/12/88
593: */
594: if (noExecute || Dir_MTime(gn) == 0) {
595: gn->mtime = now;
596: }
597: if (gn->cmtime > gn->mtime)
598: gn->mtime = gn->cmtime;
599: if (DEBUG(MAKE)) {
600: printf("update time: %s\n", Targ_FmtTime(gn->mtime));
601: }
602: #endif
603: if (!(gn->type & OP_EXEC)) {
604: pgn->childMade = TRUE;
605: Make_TimeStamp(pgn, gn);
606: }
607: } else if (keepgoing) {
608: pgn->make = FALSE;
609: } else {
1.12 espie 610: char *p1;
611:
612: printf ("\n\nStop in %s.\n", Var_Value(".CURDIR", gn, &p1));
613: efree(p1);
1.1 deraadt 614: exit (1);
615: }
616: } else if (gn->made == ERROR) {
617: /*
618: * Already had an error when making this beastie. Tell the parent
619: * to abort.
620: */
621: pgn->make = FALSE;
622: } else {
623: if (Lst_Member (gn->iParents, pgn) != NILLNODE) {
624: char *p1;
625: Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
1.12 espie 626: efree(p1);
1.1 deraadt 627: }
628: switch(gn->made) {
629: case BEINGMADE:
630: Error("Graph cycles through %s\n", gn->name);
631: gn->made = ERROR;
632: pgn->make = FALSE;
633: break;
634: case MADE:
635: if ((gn->type & OP_EXEC) == 0) {
636: pgn->childMade = TRUE;
637: Make_TimeStamp(pgn, gn);
638: }
639: break;
640: case UPTODATE:
641: if ((gn->type & OP_EXEC) == 0) {
642: Make_TimeStamp(pgn, gn);
643: }
644: break;
645: default:
646: break;
647: }
648: }
649:
650: return (0);
651: }
1.4 millert 652:
1.1 deraadt 653: /*-
654: *-----------------------------------------------------------------------
655: * Compat_Run --
656: * Initialize this mode and start making.
657: *
658: * Results:
659: * None.
660: *
661: * Side Effects:
662: * Guess what?
663: *
664: *-----------------------------------------------------------------------
665: */
666: void
667: Compat_Run(targs)
668: Lst targs; /* List of target nodes to re-create */
669: {
670: char *cp; /* Pointer to string of shell meta-characters */
671: GNode *gn = NULL;/* Current root target */
672: int errors; /* Number of targets not remade due to errors */
673:
674: if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
675: signal(SIGINT, CompatInterrupt);
676: }
677: if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
678: signal(SIGTERM, CompatInterrupt);
679: }
680: if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
681: signal(SIGHUP, CompatInterrupt);
682: }
683: if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) {
684: signal(SIGQUIT, CompatInterrupt);
685: }
686:
687: for (cp = "#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++) {
688: meta[(unsigned char) *cp] = 1;
689: }
690: /*
691: * The null character serves as a sentinel in the string.
692: */
693: meta[0] = 1;
694:
695: ENDNode = Targ_FindNode(".END", TARG_CREATE);
696: /*
697: * If the user has defined a .BEGIN target, execute the commands attached
698: * to it.
699: */
700: if (!queryFlag) {
701: gn = Targ_FindNode(".BEGIN", TARG_NOCREATE);
702: if (gn != NILGNODE) {
703: Lst_ForEach(gn->commands, CompatRunCommand, (ClientData)gn);
1.4 millert 704: if (gn->made == ERROR) {
705: printf("\n\nStop.\n");
706: exit(1);
707: }
1.1 deraadt 708: }
709: }
710:
711: /*
712: * For each entry in the list of targets to create, call CompatMake on
713: * it to create the thing. CompatMake 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 = (GNode *) Lst_DeQueue (targs);
724: CompatMake (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: Lst_ForEach(ENDNode->commands, CompatRunCommand, (ClientData)gn);
739: }
740: }