Annotation of src/usr.bin/make/compat.c, Revision 1.55
1.36 espie 1: /* $OpenPackages$ */
1.55 ! espie 2: /* $OpenBSD: compat.c,v 1.54 2007/09/16 09:46:14 espie Exp $ */
1.8 millert 3: /* $NetBSD: compat.c,v 1.14 1996/11/06 17:59:01 christos Exp $ */
1.1 deraadt 4:
5: /*
6: * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
7: * Copyright (c) 1988, 1989 by Adam de Boor
8: * Copyright (c) 1989 by Berkeley Softworks
9: * All rights reserved.
10: *
11: * This code is derived from software contributed to Berkeley by
12: * Adam de Boor.
13: *
14: * Redistribution and use in source and binary forms, with or without
15: * modification, are permitted provided that the following conditions
16: * are met:
17: * 1. Redistributions of source code must retain the above copyright
18: * notice, this list of conditions and the following disclaimer.
19: * 2. Redistributions in binary form must reproduce the above copyright
20: * notice, this list of conditions and the following disclaimer in the
21: * documentation and/or other materials provided with the distribution.
1.49 millert 22: * 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 23: * may be used to endorse or promote products derived from this software
24: * without specific prior written permission.
25: *
26: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36: * SUCH DAMAGE.
37: */
38:
1.37 espie 39: #include <sys/types.h>
40: #include <sys/stat.h>
41: #include <sys/wait.h>
42: #include <ctype.h>
43: #include <errno.h>
1.39 espie 44: #include <limits.h>
1.37 espie 45: #include <signal.h>
46: #include <stddef.h>
47: #include <stdio.h>
1.39 espie 48: #include <stdlib.h>
1.38 espie 49: #include <string.h>
1.37 espie 50: #include <unistd.h>
51: #include "config.h"
52: #include "defines.h"
53: #include "dir.h"
1.55 ! espie 54: #include "engine.h"
1.37 espie 55: #include "compat.h"
56: #include "suff.h"
57: #include "var.h"
58: #include "targ.h"
59: #include "error.h"
60: #include "str.h"
61: #include "extern.h"
62: #include "memory.h"
63: #include "gnode.h"
64: #include "make.h"
65: #include "timestamp.h"
66: #include "lst.h"
67: #include "pathnames.h"
1.1 deraadt 68:
1.36 espie 69: /* The following array is used to make a fast determination of which
1.1 deraadt 70: * characters are interpreted specially by the shell. If a command
71: * contains any of these characters, it is executed by the shell, not
1.36 espie 72: * directly by us. */
1.1 deraadt 73:
1.36 espie 74: static char meta[256];
1.1 deraadt 75:
76: static GNode *ENDNode;
1.36 espie 77: static void CompatInterrupt(int);
1.51 espie 78: static int CompatRunCommand(LstNode, void *);
1.36 espie 79: static void CompatMake(void *, void *);
80: static int shellneed(char **);
1.1 deraadt 81:
1.45 espie 82: static volatile sig_atomic_t interrupted;
83:
84: static void
1.50 espie 85: CompatInterrupt(int signo)
1.1 deraadt 86: {
1.45 espie 87: if (interrupted != SIGINT)
88: interrupted = signo;
1.1 deraadt 89: }
1.36 espie 90:
1.1 deraadt 91: /*-
92: *-----------------------------------------------------------------------
1.10 deraadt 93: * shellneed --
1.36 espie 94: *
1.10 deraadt 95: * Results:
1.36 espie 96: * Returns 1 if a specified set of arguments
97: * must be executed by the shell,
1.12 espie 98: * 0 if it can be run via execve, and -1 if the command can be
1.36 espie 99: * handled internally
1.10 deraadt 100: *
101: * Side Effects:
1.12 espie 102: * May modify the process umask
1.10 deraadt 103: *-----------------------------------------------------------------------
104: */
105: static int
1.50 espie 106: shellneed(char **av)
1.10 deraadt 107: {
1.36 espie 108: char *runsh[] = {
1.11 deraadt 109: "alias", "cd", "eval", "exec", "exit", "read", "set", "ulimit",
1.36 espie 110: "unalias", "unset", "wait",
1.11 deraadt 111: NULL
112: };
113:
1.12 espie 114: char **p;
1.11 deraadt 115:
1.12 espie 116: /* FIXME most of these ARE actual no-ops */
1.11 deraadt 117: for (p = runsh; *p; p++)
1.12 espie 118: if (strcmp(av[0], *p) == 0)
1.36 espie 119: return 1;
1.11 deraadt 120:
1.12 espie 121: if (strcmp(av[0], "umask") == 0) {
1.10 deraadt 122: long umi;
123: char *ep = NULL;
124: mode_t um;
125:
1.12 espie 126: if (av[1] != NULL) {
127: umi = strtol(av[1], &ep, 8);
1.10 deraadt 128: if (ep == NULL)
1.36 espie 129: return 1;
1.10 deraadt 130: um = umi;
131: }
1.12 espie 132: else {
133: um = umask(0);
134: printf("%o\n", um);
135: }
1.36 espie 136: (void)umask(um);
137: return -1;
1.10 deraadt 138: }
139:
1.36 espie 140: return 0;
1.10 deraadt 141: }
1.36 espie 142:
1.10 deraadt 143: /*-
144: *-----------------------------------------------------------------------
1.1 deraadt 145: * CompatRunCommand --
146: * Execute the next command for a target. If the command returns an
147: * error, the node's made field is set to ERROR and creation stops.
148: *
149: * Results:
1.36 espie 150: * 0 in case of error, 1 if ok.
1.1 deraadt 151: *
152: * Side Effects:
153: * The node's 'made' field may be set to ERROR.
154: *-----------------------------------------------------------------------
155: */
156: static int
1.51 espie 157: CompatRunCommand(LstNode cmdNode,/* Command to execute */
1.50 espie 158: void *gnp) /* Node from which the command came */
1.1 deraadt 159: {
1.36 espie 160: char *cmdStart; /* Start of expanded command */
1.12 espie 161: char *cp, *bp = NULL;
1.37 espie 162: bool silent, /* Don't print command */
1.32 espie 163: doExecute; /* Execute the command */
1.46 millert 164: volatile bool errCheck; /* Check errors */
1.36 espie 165: int reason; /* Reason for child's death */
166: int status; /* Description of child's death */
1.47 mpech 167: pid_t cpid; /* Child actually found */
168: pid_t stat; /* Status of fork */
1.46 millert 169: char ** volatile av; /* Argument vector for thing to exec */
1.36 espie 170: int argc; /* Number of arguments in av or 0 if not
1.1 deraadt 171: * dynamically allocated */
1.51 espie 172: char *cmd = (char *)Lst_Datum(cmdNode);
1.36 espie 173: GNode *gn = (GNode *)gnp;
1.37 espie 174: static char *shargv[4] = { _PATH_BSHELL };
1.36 espie 175:
1.1 deraadt 176: silent = gn->type & OP_SILENT;
177: errCheck = !(gn->type & OP_IGNORE);
1.32 espie 178: doExecute = !noExecute;
1.1 deraadt 179:
1.37 espie 180: cmdStart = Var_Subst(cmd, &gn->context, false);
1.1 deraadt 181:
1.36 espie 182: /* brk_string will return an argv with a NULL in av[0], thus causing
1.1 deraadt 183: * execvp to choke and die horribly. Besides, how can we execute a null
184: * command? In any case, we warn the user that the command expanded to
1.36 espie 185: * nothing (is this the right thing to do?). */
1.4 millert 186:
1.1 deraadt 187: if (*cmdStart == '\0') {
188: free(cmdStart);
189: Error("%s expands to empty string", cmd);
1.25 espie 190: return 1;
1.36 espie 191: } else
1.1 deraadt 192: cmd = cmdStart;
1.23 espie 193: Lst_Replace(cmdNode, cmdStart);
1.1 deraadt 194:
195: if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) {
1.28 espie 196: Lst_AtEnd(&ENDNode->commands, cmdStart);
1.25 espie 197: return 1;
1.1 deraadt 198: } else if (strcmp(cmdStart, "...") == 0) {
199: gn->type |= OP_SAVE_CMDS;
1.25 espie 200: return 1;
1.1 deraadt 201: }
202:
1.32 espie 203: for (;; cmd++) {
1.36 espie 204: if (*cmd == '@')
1.37 espie 205: silent = DEBUG(LOUD) ? false : true;
1.32 espie 206: else if (*cmd == '-')
1.37 espie 207: errCheck = false;
1.32 espie 208: else if (*cmd == '+')
1.37 espie 209: doExecute = true;
1.32 espie 210: else
211: break;
1.1 deraadt 212: }
213:
1.36 espie 214: while (isspace(*cmd))
1.1 deraadt 215: cmd++;
1.4 millert 216:
1.36 espie 217: /* Search for meta characters in the command. If there are no meta
1.1 deraadt 218: * characters, there's no need to execute a shell to execute the
1.36 espie 219: * command. */
1.1 deraadt 220: for (cp = cmd; !meta[(unsigned char)*cp]; cp++) {
221: continue;
222: }
223:
1.36 espie 224: /* Print the command before echoing if we're not supposed to be quiet for
225: * this one. We also print the command if -n given. */
1.1 deraadt 226: if (!silent || noExecute) {
1.36 espie 227: printf("%s\n", cmd);
1.1 deraadt 228: fflush(stdout);
229: }
230:
1.36 espie 231: /* If we're not supposed to execute any commands, this is as far as
232: * we go... */
1.32 espie 233: if (!doExecute)
1.25 espie 234: return 1;
1.4 millert 235:
1.1 deraadt 236: if (*cp != '\0') {
1.36 espie 237: /* If *cp isn't the null character, we hit a "meta" character and
1.1 deraadt 238: * need to pass the command off to the shell. We give the shell the
239: * -e flag as well as -c if it's supposed to exit when it hits an
1.36 espie 240: * error. */
1.10 deraadt 241:
1.36 espie 242: shargv[1] = errCheck ? "-ec" : "-c";
1.10 deraadt 243: shargv[2] = cmd;
1.36 espie 244: shargv[3] = NULL;
1.10 deraadt 245: av = shargv;
246: argc = 0;
1.12 espie 247: } else {
1.36 espie 248: /* No meta-characters, so probably no need to exec a shell.
249: * Break the command into words to form an argument vector
250: * we can execute. */
251: av = brk_string(cmd, &argc, &bp);
252: switch (shellneed(av)) {
1.12 espie 253: case -1: /* handled internally */
254: free(bp);
255: free(av);
1.25 espie 256: return 1;
1.12 espie 257: case 1:
1.36 espie 258: shargv[1] = errCheck ? "-ec" : "-c";
1.12 espie 259: shargv[2] = cmd;
1.36 espie 260: shargv[3] = NULL;
261: free(av);
1.14 espie 262: free(bp);
263: bp = NULL;
1.12 espie 264: av = shargv;
265: argc = 0;
266: break;
267: default: /* nothing needed */
268: break;
1.10 deraadt 269: }
1.1 deraadt 270: }
1.4 millert 271:
1.36 espie 272: /* Fork and execute the single command. If the fork fails, we abort. */
1.48 mickey 273: cpid = fork();
1.36 espie 274: if (cpid == -1)
1.1 deraadt 275: Fatal("Could not fork");
276: if (cpid == 0) {
277: execvp(av[0], av);
1.17 espie 278: if (errno == ENOENT)
1.36 espie 279: fprintf(stderr, "%s: not found\n", av[0]);
1.17 espie 280: else
281: perror(av[0]);
1.52 espie 282: _exit(1);
1.1 deraadt 283: }
1.12 espie 284: if (bp) {
1.36 espie 285: free(av);
1.12 espie 286: free(bp);
287: }
1.1 deraadt 288: free(cmdStart);
1.23 espie 289: Lst_Replace(cmdNode, NULL);
1.4 millert 290:
1.36 espie 291: /* The child is off and running. Now all we can do is wait... */
1.1 deraadt 292: while (1) {
293:
1.2 deraadt 294: while ((stat = wait(&reason)) != cpid) {
1.36 espie 295: if (stat == -1 && errno != EINTR)
1.1 deraadt 296: break;
297: }
1.4 millert 298:
1.45 espie 299: if (interrupted)
300: break;
301:
1.36 espie 302: if (stat != -1) {
303: if (WIFSTOPPED(reason))
1.2 deraadt 304: status = WSTOPSIG(reason); /* stopped */
1.36 espie 305: else if (WIFEXITED(reason)) {
1.2 deraadt 306: status = WEXITSTATUS(reason); /* exited */
1.36 espie 307: if (status != 0)
308: printf("*** Error code %d", status);
1.1 deraadt 309: } else {
1.2 deraadt 310: status = WTERMSIG(reason); /* signaled */
1.36 espie 311: printf("*** Signal %d", status);
1.4 millert 312: }
313:
1.1 deraadt 314:
1.36 espie 315: if (!WIFEXITED(reason) || status != 0) {
1.1 deraadt 316: if (errCheck) {
317: gn->made = ERROR;
1.36 espie 318: if (keepgoing)
319: /* Abort the current target, but let others
320: * continue. */
321: printf(" (continuing)\n");
1.1 deraadt 322: } else {
1.36 espie 323: /* Continue executing commands for this target.
324: * If we return 0, this will happen... */
325: printf(" (ignored)\n");
1.1 deraadt 326: status = 0;
327: }
328: }
1.45 espie 329: return !status;
1.36 espie 330: } else
331: Fatal("error in wait: %d", stat);
1.1 deraadt 332: /*NOTREACHED*/
333: }
334:
1.45 espie 335: /* This is reached only if interrupted */
336: if (!Targ_Precious(gn)) {
337: char *file = Varq_Value(TARGET_INDEX, gn);
338:
339: if (!noExecute && eunlink(file) != -1)
340: Error("*** %s removed\n", file);
341: }
342: if (interrupted == SIGINT) {
343: GNode *i = Targ_FindNode(".INTERRUPT", TARG_NOCREATE);
344: signal(SIGINT, SIG_IGN);
345: signal(SIGTERM, SIG_IGN);
346: signal(SIGHUP, SIG_IGN);
347: signal(SIGQUIT, SIG_IGN);
348: interrupted = 0;
349: if (i != NULL)
1.51 espie 350: Lst_ForEachNodeWhile(&i->commands, CompatRunCommand, i);
1.45 espie 351: exit(SIGINT);
352: }
353: exit(interrupted);
1.1 deraadt 354: }
1.36 espie 355:
1.1 deraadt 356: /*-
357: *-----------------------------------------------------------------------
358: * CompatMake --
359: * Make a target.
360: *
361: * Side Effects:
362: * If an error is detected and not being ignored, the process exits.
363: *-----------------------------------------------------------------------
364: */
1.26 espie 365: static void
1.50 espie 366: CompatMake(void *gnp, /* The node to make */
367: void *pgnp) /* Parent to abort if necessary */
1.1 deraadt 368: {
1.36 espie 369: GNode *gn = (GNode *)gnp;
370: GNode *pgn = (GNode *)pgnp;
1.5 millert 371:
1.7 deraadt 372: if (pgn->type & OP_MADE) {
1.35 espie 373: (void)Dir_MTime(gn);
1.7 deraadt 374: gn->made = UPTODATE;
375: }
376:
1.8 millert 377: if (gn->type & OP_USE) {
378: Make_HandleUse(gn, pgn);
379: } else if (gn->made == UNMADE) {
1.36 espie 380: /* First mark ourselves to be made, then apply whatever transformations
1.1 deraadt 381: * the suffix module thinks are necessary. Once that's done, we can
382: * descend and make all our children. If any of them has an error
1.37 espie 383: * but the -k flag was given, our 'make' field will be set false again.
1.1 deraadt 384: * This is our signal to not attempt to do anything but abort our
1.36 espie 385: * parent as well. */
1.37 espie 386: gn->make = true;
1.1 deraadt 387: gn->made = BEINGMADE;
1.36 espie 388: Suff_FindDeps(gn);
1.28 espie 389: Lst_ForEach(&gn->children, CompatMake, gn);
1.1 deraadt 390: if (!gn->make) {
391: gn->made = ABORTED;
1.37 espie 392: pgn->make = false;
1.26 espie 393: return;
1.1 deraadt 394: }
395:
1.44 deraadt 396: if (Lst_Member(&gn->iParents, pgn) != NULL) {
397: Varq_Set(IMPSRC_INDEX, Varq_Value(TARGET_INDEX, gn), pgn);
398: }
1.4 millert 399:
1.36 espie 400: /* All the children were made ok. Now cmtime contains the modification
1.1 deraadt 401: * time of the newest child, we need to find out if we exist and when
402: * we were modified last. The criteria for datedness are defined by the
1.36 espie 403: * Make_OODate function. */
404: if (DEBUG(MAKE))
1.1 deraadt 405: printf("Examining %s...", gn->name);
406: if (! Make_OODate(gn)) {
407: gn->made = UPTODATE;
1.36 espie 408: if (DEBUG(MAKE))
1.1 deraadt 409: printf("up-to-date.\n");
1.26 espie 410: return;
1.36 espie 411: } else if (DEBUG(MAKE))
1.1 deraadt 412: printf("out-of-date.\n");
413:
1.36 espie 414: /* If the user is just seeing if something is out-of-date, exit now
415: * to tell him/her "yes". */
416: if (queryFlag)
417: exit(-1);
1.1 deraadt 418:
1.36 espie 419: /* We need to be re-made. We also have to make sure we've got a $?
1.1 deraadt 420: * variable. To be nice, we also define the $> variable using
1.36 espie 421: * Make_DoAllVar(). */
1.1 deraadt 422: Make_DoAllVar(gn);
1.4 millert 423:
1.36 espie 424: /* Alter our type to tell if errors should be ignored or things
425: * should not be printed so CompatRunCommand knows what to do. */
426: if (Targ_Ignore(gn))
1.1 deraadt 427: gn->type |= OP_IGNORE;
1.36 espie 428: if (Targ_Silent(gn))
1.1 deraadt 429: gn->type |= OP_SILENT;
430:
1.36 espie 431: if (Job_CheckCommands(gn, Fatal)) {
432: /* Our commands are ok, but we still have to worry about the -t
433: * flag... */
1.45 espie 434: if (!touchFlag)
1.51 espie 435: Lst_ForEachNodeWhile(&gn->commands, CompatRunCommand, gn);
1.45 espie 436: else
1.36 espie 437: Job_Touch(gn, gn->type & OP_SILENT);
438: } else
1.1 deraadt 439: gn->made = ERROR;
440:
441: if (gn->made != ERROR) {
1.36 espie 442: /* If the node was made successfully, mark it so, update
1.1 deraadt 443: * its modification time and timestamp all its parents. Note
444: * that for .ZEROTIME targets, the timestamping isn't done.
1.36 espie 445: * This is to keep its state from affecting that of its parent. */
1.1 deraadt 446: gn->made = MADE;
1.36 espie 447: /* This is what Make does and it's actually a good thing, as it
1.1 deraadt 448: * allows rules like
449: *
450: * cmp -s y.tab.h parse.h || cp y.tab.h parse.h
451: *
452: * to function as intended. Unfortunately, thanks to the stateless
453: * nature of NFS (and the speed of this program), there are times
454: * when the modification time of a file created on a remote
455: * machine will not be modified before the stat() implied by
456: * the Dir_MTime occurs, thus leading us to believe that the file
457: * is unchanged, wreaking havoc with files that depend on this one.
458: *
459: * I have decided it is better to make too much than to make too
460: * little, so this stuff is commented out unless you're sure it's
461: * ok.
462: * -- ardeb 1/12/88
463: */
1.35 espie 464: if (noExecute || is_out_of_date(Dir_MTime(gn)))
1.1 deraadt 465: gn->mtime = now;
1.37 espie 466: if (is_strictly_before(gn->mtime, gn->cmtime))
1.1 deraadt 467: gn->mtime = gn->cmtime;
1.36 espie 468: if (DEBUG(MAKE))
1.1 deraadt 469: printf("update time: %s\n", Targ_FmtTime(gn->mtime));
470: if (!(gn->type & OP_EXEC)) {
1.37 espie 471: pgn->childMade = true;
1.1 deraadt 472: Make_TimeStamp(pgn, gn);
473: }
1.36 espie 474: } else if (keepgoing)
1.37 espie 475: pgn->make = false;
1.36 espie 476: else {
477:
1.24 espie 478: if (gn->lineno)
1.36 espie 479: printf("\n\nStop in %s (line %lu of %s).\n",
480: Var_Value(".CURDIR"),
1.24 espie 481: (unsigned long)gn->lineno,
482: gn->fname);
483: else
1.36 espie 484: printf("\n\nStop in %s.\n", Var_Value(".CURDIR"));
485: exit(1);
1.1 deraadt 486: }
1.36 espie 487: } else if (gn->made == ERROR)
488: /* Already had an error when making this beastie. Tell the parent
489: * to abort. */
1.37 espie 490: pgn->make = false;
1.36 espie 491: else {
1.44 deraadt 492: if (Lst_Member(&gn->iParents, pgn) != NULL) {
493: Varq_Set(IMPSRC_INDEX, Varq_Value(TARGET_INDEX, gn), pgn);
494: }
1.36 espie 495: switch (gn->made) {
1.1 deraadt 496: case BEINGMADE:
497: Error("Graph cycles through %s\n", gn->name);
498: gn->made = ERROR;
1.37 espie 499: pgn->make = false;
1.1 deraadt 500: break;
501: case MADE:
502: if ((gn->type & OP_EXEC) == 0) {
1.37 espie 503: pgn->childMade = true;
1.1 deraadt 504: Make_TimeStamp(pgn, gn);
505: }
506: break;
507: case UPTODATE:
1.36 espie 508: if ((gn->type & OP_EXEC) == 0)
1.1 deraadt 509: Make_TimeStamp(pgn, gn);
510: break;
511: default:
512: break;
513: }
514: }
515: }
1.36 espie 516:
1.1 deraadt 517: void
1.50 espie 518: Compat_Run(Lst targs) /* List of target nodes to re-create */
1.1 deraadt 519: {
1.50 espie 520: char *cp; /* Pointer to string of shell meta-characters */
521: GNode *gn = NULL; /* Current root target */
522: int errors; /* Number of targets not remade due to errors */
1.1 deraadt 523:
1.45 espie 524: signal(SIGINT, CompatInterrupt);
525: signal(SIGTERM, CompatInterrupt);
526: signal(SIGHUP, CompatInterrupt);
527: signal(SIGQUIT, CompatInterrupt);
1.1 deraadt 528:
1.36 espie 529: for (cp = "#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++)
1.1 deraadt 530: meta[(unsigned char) *cp] = 1;
1.36 espie 531: /* The null character serves as a sentinel in the string. */
1.1 deraadt 532: meta[0] = 1;
533:
1.37 espie 534: ENDNode = Targ_FindNode(".END", TARG_CREATE);
1.36 espie 535: /* If the user has defined a .BEGIN target, execute the commands attached
536: * to it. */
1.1 deraadt 537: if (!queryFlag) {
1.37 espie 538: gn = Targ_FindNode(".BEGIN", TARG_NOCREATE);
1.18 espie 539: if (gn != NULL) {
1.51 espie 540: Lst_ForEachNodeWhile(&gn->commands, CompatRunCommand, gn);
1.36 espie 541: if (gn->made == ERROR) {
542: printf("\n\nStop.\n");
543: exit(1);
544: }
1.1 deraadt 545: }
546: }
547:
1.36 espie 548: /* For each entry in the list of targets to create, call CompatMake on
1.1 deraadt 549: * it to create the thing. CompatMake will leave the 'made' field of gn
550: * in one of several states:
551: * UPTODATE gn was already up-to-date
1.36 espie 552: * MADE gn was recreated successfully
553: * ERROR An error occurred while gn was being created
1.1 deraadt 554: * ABORTED gn was not remade because one of its inferiors
1.36 espie 555: * could not be made due to errors. */
1.1 deraadt 556: errors = 0;
1.19 espie 557: while ((gn = (GNode *)Lst_DeQueue(targs)) != NULL) {
1.26 espie 558: CompatMake(gn, gn);
1.1 deraadt 559:
1.36 espie 560: if (gn->made == UPTODATE)
561: printf("`%s' is up to date.\n", gn->name);
562: else if (gn->made == ABORTED) {
563: printf("`%s' not remade because of errors.\n", gn->name);
1.1 deraadt 564: errors += 1;
565: }
566: }
567:
1.36 espie 568: /* If the user has defined a .END target, run its commands. */
569: if (errors == 0)
1.51 espie 570: Lst_ForEachNodeWhile(&ENDNode->commands, CompatRunCommand, ENDNode);
1.1 deraadt 571: }