Changeset 24 for branches/FREEBSD/src/kmk/compat.c
- Timestamp:
- Nov 26, 2002, 10:24:54 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FREEBSD/src/kmk/compat.c
r10 r24 1 1 /* 2 * Copyright (c) 1988, 1989, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 2 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 4 3 * Copyright (c) 1988, 1989 by Adam de Boor 5 4 * Copyright (c) 1989 by Berkeley Softworks … … 36 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 36 * SUCH DAMAGE. 38 *39 * @(#)compat.c 8.2 (Berkeley) 3/19/9440 37 */ 41 38 42 #include <sys/cdefs.h> 43 __FBSDID("$FreeBSD: src/usr.bin/make/compat.c,v 1.34 2002/10/09 03:42:09 jmallett Exp $"); 39 #ifndef lint 40 #if 0 41 static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; 42 #else 43 static const char rcsid[] = 44 "$FreeBSD: src/usr.bin/make/compat.c,v 1.16.2.2 2000/07/01 12:24:21 ps Exp $"; 45 #endif 46 #endif /* not lint */ 44 47 45 48 /*- … … 63 66 #include <errno.h> 64 67 #include <signal.h> 65 #include <unistd.h>66 68 #include "make.h" 67 69 #include "hash.h" … … 78 80 static char meta[256]; 79 81 80 static GNode *curTarg = N ULL;82 static GNode *curTarg = NILGNODE; 81 83 static GNode *ENDNode; 82 static void CompatInterrupt(int); 83 static int CompatRunCommand(void *, void *); 84 static int CompatMake(void *, void *); 85 static int shellneed(char *); 84 static void CompatInterrupt __P((int)); 85 static int CompatRunCommand __P((ClientData, ClientData)); 86 static int CompatMake __P((ClientData, ClientData)); 86 87 87 88 static char *sh_builtin[] = { … … 105 106 */ 106 107 static void 107 CompatInterrupt (int signo) 108 CompatInterrupt (signo) 109 int signo; 108 110 { 109 111 GNode *gn; 110 112 111 if ((curTarg != N ULL) && !Targ_Precious (curTarg)) {113 if ((curTarg != NILGNODE) && !Targ_Precious (curTarg)) { 112 114 char *p1; 113 115 char *file = Var_Value (TARGET, curTarg, &p1); … … 123 125 if (signo == SIGINT) { 124 126 gn = Targ_FindNode(".INTERRUPT", TARG_NOCREATE); 125 if (gn != N ULL) {126 Lst_ForEach(gn->commands, CompatRunCommand, ( void *)gn);127 if (gn != NILGNODE) { 128 Lst_ForEach(gn->commands, CompatRunCommand, (ClientData)gn); 127 129 } 128 130 } … … 150 152 */ 151 153 static int 152 shellneed (char *cmd) 154 shellneed (cmd) 155 char *cmd; 153 156 { 154 157 char **av, **p; … … 168 171 * Execute the next command for a target. If the command returns an 169 172 * error, the node's made field is set to ERROR and creation stops. 170 * The node from which the command came is also given.171 173 * 172 174 * Results: … … 179 181 */ 180 182 static int 181 CompatRunCommand (void *cmdp, void *gnp) 183 CompatRunCommand (cmdp, gnp) 184 ClientData cmdp; /* Command to execute */ 185 ClientData gnp; /* Node from which the command came */ 182 186 { 183 187 char *cmdStart; /* Start of expanded command */ 184 char*cp;188 register char *cp; 185 189 Boolean silent, /* Don't print command */ 186 190 errCheck; /* Check errors */ … … 188 192 int status; /* Description of child's death */ 189 193 int cpid; /* Child actually found */ 190 ReturnStatus rstat;/* Status of fork */194 ReturnStatus stat; /* Status of fork */ 191 195 LstNode cmdNode; /* Node where current command is located */ 192 196 char **av; /* Argument vector for thing to exec */ 193 197 int argc; /* Number of arguments in av or 0 if not 194 198 * dynamically allocated */ 199 Boolean local; /* TRUE if command should be executed 200 * locally */ 195 201 int internal; /* Various values.. */ 196 202 char *cmd = (char *) cmdp; … … 208 214 errCheck = !(gn->type & OP_IGNORE); 209 215 210 cmdNode = Lst_Member (gn->commands, ( void *)cmd);216 cmdNode = Lst_Member (gn->commands, (ClientData)cmd); 211 217 cmdStart = Var_Subst (NULL, cmd, gn, FALSE); 212 218 … … 225 231 cmd = cmdStart; 226 232 } 227 Lst_Replace (cmdNode, ( void *)cmdStart);233 Lst_Replace (cmdNode, (ClientData)cmdStart); 228 234 229 235 if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) { 230 (void)Lst_AtEnd(ENDNode->commands, ( void *)cmdStart);236 (void)Lst_AtEnd(ENDNode->commands, (ClientData)cmdStart); 231 237 return(0); 232 238 } else if (strcmp(cmdStart, "...") == 0) { … … 315 321 } 316 322 323 local = TRUE; 324 317 325 /* 318 326 * Fork and execute the single command. If the fork fails, we abort. … … 323 331 } 324 332 if (cpid == 0) { 325 execvp(av[0], av); 326 (void) write (STDERR_FILENO, av[0], strlen (av[0])); 327 (void) write (STDERR_FILENO, ":", 1); 328 (void) write (STDERR_FILENO, strerror(errno), strlen(strerror(errno))); 329 (void) write (STDERR_FILENO, "\n", 1); 333 if (local) { 334 execvp(av[0], av); 335 (void) write (2, av[0], strlen (av[0])); 336 (void) write (2, ":", 1); 337 (void) write (2, strerror(errno), strlen(strerror(errno))); 338 (void) write (2, "\n", 1); 339 } else { 340 (void)execv(av[0], av); 341 } 330 342 exit(1); 331 343 } … … 347 359 while (1) { 348 360 349 while (( rstat = wait(&reason)) != cpid) {350 if ( rstat == -1 && errno != EINTR) {361 while ((stat = wait(&reason)) != cpid) { 362 if (stat == -1 && errno != EINTR) { 351 363 break; 352 364 } 353 365 } 354 366 355 if ( rstat > -1) {367 if (stat > -1) { 356 368 if (WIFSTOPPED(reason)) { 357 369 status = WSTOPSIG(reason); /* stopped */ … … 388 400 break; 389 401 } else { 390 Fatal ("error in wait: %d", rstat);402 Fatal ("error in wait: %d", stat); 391 403 /*NOTREACHED*/ 392 404 } … … 400 412 *----------------------------------------------------------------------- 401 413 * CompatMake -- 402 * Make a target , given the parent, to abort if necessary.414 * Make a target. 403 415 * 404 416 * Results: … … 411 423 */ 412 424 static int 413 CompatMake (void *gnp, void *pgnp) 425 CompatMake (gnp, pgnp) 426 ClientData gnp; /* The node to make */ 427 ClientData pgnp; /* Parent to abort if necessary */ 414 428 { 415 429 GNode *gn = (GNode *) gnp; … … 429 443 gn->made = BEINGMADE; 430 444 Suff_FindDeps (gn); 431 Lst_ForEach (gn->children, CompatMake, ( void *)gn);445 Lst_ForEach (gn->children, CompatMake, (ClientData)gn); 432 446 if (!gn->make) { 433 447 gn->made = ABORTED; … … 436 450 } 437 451 438 if (Lst_Member (gn->iParents, pgn) != N ULL) {452 if (Lst_Member (gn->iParents, pgn) != NILLNODE) { 439 453 char *p1; 440 454 Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn); … … 448 462 * Make_OODate function. 449 463 */ 450 DEBUGF(MAKE, ("Examining %s...", gn->name)); 464 if (DEBUG(MAKE)) { 465 printf("Examining %s...", gn->name); 466 } 451 467 if (! Make_OODate(gn)) { 452 468 gn->made = UPTODATE; 453 DEBUGF(MAKE, ("up-to-date.\n")); 469 if (DEBUG(MAKE)) { 470 printf("up-to-date.\n"); 471 } 454 472 return (0); 455 } else {456 DEBUGF(MAKE, ("out-of-date.\n"));473 } else if (DEBUG(MAKE)) { 474 printf("out-of-date.\n"); 457 475 } 458 476 … … 490 508 if (!touchFlag) { 491 509 curTarg = gn; 492 Lst_ForEach (gn->commands, CompatRunCommand, ( void *)gn);493 curTarg = N ULL;510 Lst_ForEach (gn->commands, CompatRunCommand, (ClientData)gn); 511 curTarg = NILGNODE; 494 512 } else { 495 513 Job_Touch (gn, gn->type & OP_SILENT); … … 561 579 if (gn->cmtime > gn->mtime) 562 580 gn->mtime = gn->cmtime; 563 DEBUGF(MAKE, ("update time: %s\n", Targ_FmtTime(gn->mtime))); 581 if (DEBUG(MAKE)) { 582 printf("update time: %s\n", Targ_FmtTime(gn->mtime)); 583 } 564 584 #endif 565 585 if (!(gn->type & OP_EXEC)) { … … 583 603 pgn->make = FALSE; 584 604 } else { 585 if (Lst_Member (gn->iParents, pgn) != N ULL) {605 if (Lst_Member (gn->iParents, pgn) != NILLNODE) { 586 606 char *p1; 587 607 Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn); … … 617 637 *----------------------------------------------------------------------- 618 638 * Compat_Run -- 619 * Start making again, given a list of target nodes.639 * Initialize this mode and start making. 620 640 * 621 641 * Results: … … 628 648 */ 629 649 void 630 Compat_Run(Lst targs) 650 Compat_Run(targs) 651 Lst targs; /* List of target nodes to re-create */ 631 652 { 632 653 char *cp; /* Pointer to string of shell meta-characters */ … … 662 683 if (!queryFlag) { 663 684 gn = Targ_FindNode(".BEGIN", TARG_NOCREATE); 664 if (gn != N ULL) {665 Lst_ForEach(gn->commands, CompatRunCommand, ( void *)gn);685 if (gn != NILGNODE) { 686 Lst_ForEach(gn->commands, CompatRunCommand, (ClientData)gn); 666 687 if (gn->made == ERROR) { 667 688 printf("\n\nStop.\n"); … … 698 719 */ 699 720 if (errors == 0) { 700 Lst_ForEach(ENDNode->commands, CompatRunCommand, ( void *)gn);721 Lst_ForEach(ENDNode->commands, CompatRunCommand, (ClientData)gn); 701 722 } 702 723 }
Note:
See TracChangeset
for help on using the changeset viewer.