diff options
author | Marc Espie <espie@cvs.openbsd.org> | 1998-12-05 00:06:34 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 1998-12-05 00:06:34 +0000 |
commit | 32435087c5f42cf9f9b6c2202ccb5159532977d7 (patch) | |
tree | 53783d2c1632360b0c896962e2fe75001677d4a1 /usr.bin/make | |
parent | b3d8393fedf5aa80bf2e2f94079440ad857cc199 (diff) |
Modifications from netbsd:
- don't interfere with MACHINE/MACHINE_ARCH defines for bootstrap
- type clean-up, time_t, and printing `unknown' ints
- fix TARGET/MEMBER bug in archive rules
- memmove...
- cleaner Error handler.
- reentrant brk_string
- .MAKE env variable
- preliminary scaffolding for .NOPATH
Other improvements:
- efree
- shellneed streamlined
- display Stop in .CURDIR after an error.
- document most features and misfeatures.
- add a few OpenBSD notes to the tutorial.
Diffstat (limited to 'usr.bin/make')
62 files changed, 452 insertions, 305 deletions
diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile index e5ed07d8d27..f7ce2d7ba89 100644 --- a/usr.bin/make/Makefile +++ b/usr.bin/make/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.7 1998/03/07 18:43:08 millert Exp $ +# $OpenBSD: Makefile,v 1.8 1998/12/05 00:06:26 espie Exp $ PROG= make CFLAGS+= -I${.CURDIR} -Wall -Wno-char-subscripts -Wno-unused #-Wmissing-prototypes -Wstrict-prototypes diff --git a/usr.bin/make/Makefile.boot b/usr.bin/make/Makefile.boot index 20ddcaeda53..4ab8d5791b9 100644 --- a/usr.bin/make/Makefile.boot +++ b/usr.bin/make/Makefile.boot @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.boot,v 1.5 1997/09/21 11:49:53 deraadt Exp $ +# $OpenBSD: Makefile.boot,v 1.6 1998/12/05 00:06:26 espie Exp $ # # a very simple makefile... # @@ -12,7 +12,7 @@ MACHINE=sun MACHINE_ARCH=sparc -CFLAGS= -I. -DMACHINE=\"${MACHINE}\" -DMACHINE_ARCH=\"${MACHINE_ARCH}\" \ +CFLAGS= -I. -DTARGET_MACHINE=\"${MACHINE}\" -DTARGET_MACHINE_ARCH=\"${MACHINE_ARCH}\" \ -DMAKE_BOOTSTRAP LIBS= diff --git a/usr.bin/make/PSD.doc/Makefile b/usr.bin/make/PSD.doc/Makefile index 03035172233..d7403559e60 100644 --- a/usr.bin/make/PSD.doc/Makefile +++ b/usr.bin/make/PSD.doc/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.2 1996/06/26 05:36:40 deraadt Exp $ +# $OpenBSD: Makefile,v 1.3 1998/12/05 00:06:30 espie Exp $ # $NetBSD: Makefile,v 1.2 1995/06/14 15:20:23 christos Exp $ DIR= psd/12.make diff --git a/usr.bin/make/PSD.doc/tutorial.ms b/usr.bin/make/PSD.doc/tutorial.ms index 67a7c2cc05b..7345fadcf1f 100644 --- a/usr.bin/make/PSD.doc/tutorial.ms +++ b/usr.bin/make/PSD.doc/tutorial.ms @@ -1,4 +1,4 @@ -.\" $OpenBSD: tutorial.ms,v 1.3 1996/03/27 19:32:44 niklas Exp $ +.\" $OpenBSD: tutorial.ms,v 1.4 1998/12/05 00:06:30 espie Exp $ .\" $NetBSD: tutorial.ms,v 1.3 1996/03/06 00:15:31 christos Exp $ .\" Copyright (c) 1988, 1989 by Adam de Boor .\" Copyright (c) 1989 by Berkeley Softworks diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c index a682e1220fb..f2bdc417796 100644 --- a/usr.bin/make/arch.c +++ b/usr.bin/make/arch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arch.c,v 1.13 1998/07/13 00:41:34 millert Exp $ */ +/* $OpenBSD: arch.c,v 1.14 1998/12/05 00:06:26 espie Exp $ */ /* $NetBSD: arch.c,v 1.17 1996/11/06 17:58:59 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94"; #else -static char rcsid[] = "$OpenBSD: arch.c,v 1.13 1998/07/13 00:41:34 millert Exp $"; +static char rcsid[] = "$OpenBSD: arch.c,v 1.14 1998/12/05 00:06:26 espie Exp $"; #endif #endif /* not lint */ @@ -110,6 +110,15 @@ static char rcsid[] = "$OpenBSD: arch.c,v 1.13 1998/07/13 00:41:34 millert Exp $ #include "dir.h" #include "config.h" +#ifdef TARGET_MACHINE +#undef MACHINE +#define MACHINE TARGET_MACHINE +#endif +#ifdef TARGET_MACHINE_ARCH +#undef MACHINE_ARCH +#define MACHINE_ARCH TARGET_MACHINE_ARCH +#endif + static Lst archives; /* Lst of archives we've already examined */ typedef struct Arch { @@ -159,8 +168,7 @@ ArchFree(ap) free((Address) Hash_GetValue (entry)); free(a->name); - if (a->fnametab) - free(a->fnametab); + efree(a->fnametab); Hash_DeleteTable(&a->members); free((Address) a); } @@ -650,8 +658,7 @@ ArchStatMember (archive, member, hash) badarch: fclose (arch); Hash_DeleteTable (&ar->members); - if (ar->fnametab) - free(ar->fnametab); + efree(ar->fnametab); free ((Address)ar); return (NULL); } @@ -727,7 +734,8 @@ ArchSVR4Entry(ar, name, size, arch) break; } if (DEBUG(ARCH)) { - printf("Found svr4 archive name table with %d entries\n", entry); + printf("Found svr4 archive name table with %lu entries\n", + (u_long)entry); } return 0; } @@ -744,8 +752,8 @@ ArchSVR4Entry(ar, name, size, arch) } if (entry >= ar->fnamesize) { if (DEBUG(ARCH)) { - printf("SVR4 entry offset %s is greater than %d\n", - name, ar->fnamesize); + printf("SVR4 entry offset %s is greater than %lu\n", + name, (u_long)ar->fnamesize); } return 2; } @@ -932,12 +940,10 @@ Arch_Touch (gn) char *p1, *p2; arch = ArchFindMember(Var_Value (ARCHIVE, gn, &p1), - Var_Value (TARGET, gn, &p2), + Var_Value (MEMBER, gn, &p2), &arh, "r+"); - if (p1) - free(p1); - if (p2) - free(p2); + efree(p1); + efree(p2); sprintf(arh.ar_date, "%-12ld", (long) now); if (arch != NULL) { @@ -997,24 +1003,22 @@ Arch_TouchLib (gn) * *----------------------------------------------------------------------- */ -int +time_t Arch_MTime (gn) GNode *gn; /* Node describing archive member */ { struct ar_hdr *arhPtr; /* Header of desired member */ - int modTime; /* Modification time as an integer */ + time_t modTime; /* Modification time as an integer */ char *p1, *p2; arhPtr = ArchStatMember (Var_Value (ARCHIVE, gn, &p1), - Var_Value (TARGET, gn, &p2), + Var_Value (MEMBER, gn, &p2), TRUE); - if (p1) - free(p1); - if (p2) - free(p2); + efree(p1); + efree(p2); if (arhPtr != NULL) { - modTime = (int) strtol(arhPtr->ar_date, NULL, 10); + modTime = (time_t) strtol(arhPtr->ar_date, NULL, 10); } else { modTime = 0; } @@ -1037,7 +1041,7 @@ Arch_MTime (gn) * *----------------------------------------------------------------------- */ -int +time_t Arch_MemMTime (gn) GNode *gn; { @@ -1061,10 +1065,14 @@ Arch_MemMTime (gn) * child. We keep searching its parents in case some other * parent requires this child to exist... */ - nameStart = strchr (pgn->name, '(') + 1; - nameEnd = strchr (nameStart, ')'); - - if (pgn->make && nameStart != (char *)1 && nameEnd != NULL && + /* OpenBSD: less ugly check for nameStart == NULL */ + if ((nameStart = strchr (pgn->name, '(') ) != NULL) { + nameStart++; + nameEnd = strchr (nameStart, ')'); + } else + nameEnd = NULL; + + if (pgn->make && nameEnd != NULL && strncmp(nameStart, gn->name, nameEnd - nameStart) == 0) { gn->mtime = Arch_MTime(pgn); } diff --git a/usr.bin/make/bit.h b/usr.bin/make/bit.h index 09fb78fcffe..e8165439389 100644 --- a/usr.bin/make/bit.h +++ b/usr.bin/make/bit.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bit.h,v 1.4 1996/11/30 21:08:50 millert Exp $ */ +/* $OpenBSD: bit.h,v 1.5 1998/12/05 00:06:27 espie Exp $ */ /* $NetBSD: bit.h,v 1.5 1995/11/08 02:30:53 christos Exp $ */ /* @@ -87,11 +87,11 @@ (!(Bit_IsSet((numBits), (bitArrayPtr)))) #define Bit_Copy(numBits, srcArrayPtr, destArrayPtr) \ - bcopy((char *)(srcArrayPtr), (char *)(destArrayPtr), \ + memmove((char *)(destArrayPtr), (char *)(srcArrayPtr), \ Bit_NumBytes(numBits)) #define Bit_Zero(numBits, bitArrayPtr) \ - bzero((char *)(bitArrayPtr), Bit_NumBytes(numBits)) + memset((char *)(bitArrayPtr), 0, Bit_NumBytes(numBits)) extern int Bit_FindFirstSet(); extern int Bit_FindFirstClear(); diff --git a/usr.bin/make/buf.c b/usr.bin/make/buf.c index c9feb117f37..537db661b47 100644 --- a/usr.bin/make/buf.c +++ b/usr.bin/make/buf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.c,v 1.5 1997/04/01 07:28:05 millert Exp $ */ +/* $OpenBSD: buf.c,v 1.6 1998/12/05 00:06:27 espie Exp $ */ /* $NetBSD: buf.c,v 1.9 1996/12/31 17:53:21 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)buf.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: buf.c,v 1.5 1997/04/01 07:28:05 millert Exp $"; +static char rcsid[] = "$OpenBSD: buf.c,v 1.6 1998/12/05 00:06:27 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/buf.h b/usr.bin/make/buf.h index bc753c78549..4f14acce609 100644 --- a/usr.bin/make/buf.h +++ b/usr.bin/make/buf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.h,v 1.4 1997/04/01 07:28:07 millert Exp $ */ +/* $OpenBSD: buf.h,v 1.5 1998/12/05 00:06:27 espie Exp $ */ /* $NetBSD: buf.h,v 1.7 1996/12/31 17:53:22 christos Exp $ */ /* diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c index 52811c83222..6766167845b 100644 --- a/usr.bin/make/compat.c +++ b/usr.bin/make/compat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: compat.c,v 1.11 1998/05/13 06:54:58 deraadt Exp $ */ +/* $OpenBSD: compat.c,v 1.12 1998/12/05 00:06:27 espie Exp $ */ /* $NetBSD: compat.c,v 1.14 1996/11/06 17:59:01 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; #else -static char rcsid[] = "$OpenBSD: compat.c,v 1.11 1998/05/13 06:54:58 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: compat.c,v 1.12 1998/12/05 00:06:27 espie Exp $"; #endif #endif /* not lint */ @@ -114,10 +114,9 @@ CompatInterrupt (signo) char *file = Var_Value (TARGET, curTarg, &p1); if (!noExecute && eunlink(file) != -1) { - printf ("*** %s removed\n", file); + Error("*** %s removed\n", file); } - if (p1) - free(p1); + efree(p1); /* * Run .INTERRUPT only if hit with interrupt signal @@ -138,49 +137,49 @@ CompatInterrupt (signo) * shellneed -- * * Results: - * Returns 1 if a specified line must be executed by the shell, - * 0 if it can be run via execve, and -1 if the command is a no-op. + * Returns 1 if a specified set of arguments + * must be executed by the shell, + * 0 if it can be run via execve, and -1 if the command can be + * handled internally * * Side Effects: - * None. + * May modify the process umask * *----------------------------------------------------------------------- */ static int -shellneed (cmd) - char *cmd; +shellneed (av) + char **av; { char *runsh[] = { "alias", "cd", "eval", "exec", "exit", "read", "set", "ulimit", - "unalias", "unset", "wait", ":", + "unalias", "unset", "wait", NULL }; - char **av, **p; - int ac; - - av = brk_string(cmd, &ac, TRUE); + char **p; + /* FIXME most of these ARE actual no-ops */ for (p = runsh; *p; p++) - if (strcmp(av[1], *p) == 0) + if (strcmp(av[0], *p) == 0) return (1); - if (strcmp(av[1], "umask") == 0) { + if (strcmp(av[0], "umask") == 0) { long umi; char *ep = NULL; mode_t um; - if (av[2] != NULL) { - umi = strtol(av[2], &ep, 8); + if (av[1] != NULL) { + umi = strtol(av[1], &ep, 8); if (ep == NULL) return (1); um = umi; - (void) umask(um); - return (-1); } - um = umask(0); + else { + um = umask(0); + printf("%o\n", um); + } (void) umask(um); - printf("%o\n", um); return (-1); } @@ -207,7 +206,7 @@ CompatRunCommand (cmdp, gnp) ClientData gnp; /* Node from which the command came */ { char *cmdStart; /* Start of expanded command */ - register char *cp; + char *cp, *bp = NULL; Boolean silent, /* Don't print command */ errCheck; /* Check errors */ int reason; /* Reason for child's death */ @@ -220,9 +219,9 @@ CompatRunCommand (cmdp, gnp) * dynamically allocated */ Boolean local; /* TRUE if command should be executed * locally */ - int internal; /* Various values.. */ char *cmd = (char *) cmdp; GNode *gn = (GNode *) gnp; + static char *shargv[4] = { "/bin/sh" }; /* * Avoid clobbered variable warnings by forcing the compiler @@ -239,7 +238,7 @@ CompatRunCommand (cmdp, gnp) cmdStart = Var_Subst (NULL, cmd, gn, FALSE); /* - * brk_string will return an argv with a NULL in av[1], thus causing + * brk_string will return an argv with a NULL in av[0], thus causing * execvp to choke and die horribly. Besides, how can we execute a null * command? In any case, we warn the user that the command expanded to * nothing (is this the right thing to do?). @@ -307,24 +306,6 @@ CompatRunCommand (cmdp, gnp) * -e flag as well as -c if it's supposed to exit when it hits an * error. */ - static char *shargv[4] = { "/bin/sh" }; - - shargv[1] = (errCheck ? "-ec" : "-c"); - shargv[2] = cmd; - shargv[3] = (char *)NULL; - av = shargv; - argc = 0; - } else if ((internal = shellneed(cmd))) { - /* - * This command must be passed by the shell for other reasons.. - * or.. possibly not at all. - */ - static char *shargv[4] = { "/bin/sh" }; - - if (internal == -1) { - /* Command does not need to be executed */ - return (0); - } shargv[1] = (errCheck ? "-ec" : "-c"); shargv[2] = cmd; @@ -333,13 +314,26 @@ CompatRunCommand (cmdp, gnp) argc = 0; } else { /* - * No meta-characters, so no need to exec a shell. Break the command - * into words to form an argument vector we can execute. - * brk_string sticks our name in av[0], so we have to - * skip over it... + * No meta-characters, so probably no need to exec a shell. + * Break the command into words to form an argument vector + * we can execute. */ - av = brk_string(cmd, &argc, TRUE); - av += 1; + av = brk_string(cmd, &argc, TRUE, &bp); + switch(shellneed(av)) { + case -1: /* handled internally */ + free(bp); + free(av); + return 0; + case 1: + shargv[1] = (errCheck ? "-ec" : "-c"); + shargv[2] = cmd; + shargv[3] = (char *)NULL; + av = shargv; + argc = 0; + break; + default: /* nothing needed */ + break; + } } local = TRUE; @@ -361,6 +355,10 @@ CompatRunCommand (cmdp, gnp) } _exit(1); } + if (bp) { + free(av); + free(bp); + } free(cmdStart); Lst_Replace (cmdNode, (ClientData) NULL); @@ -468,8 +466,7 @@ CompatMake (gnp, pgnp) if (Lst_Member (gn->iParents, pgn) != NILLNODE) { char *p1; Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn); - if (p1) - free(p1); + efree(p1); } /* @@ -606,7 +603,10 @@ CompatMake (gnp, pgnp) } else if (keepgoing) { pgn->make = FALSE; } else { - printf ("\n\nStop.\n"); + char *p1; + + printf ("\n\nStop in %s.\n", Var_Value(".CURDIR", gn, &p1)); + efree(p1); exit (1); } } else if (gn->made == ERROR) { @@ -619,8 +619,7 @@ CompatMake (gnp, pgnp) if (Lst_Member (gn->iParents, pgn) != NILLNODE) { char *p1; Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn); - if (p1) - free(p1); + efree(p1); } switch(gn->made) { case BEINGMADE: diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c index 6842efbf87d..144a87a276c 100644 --- a/usr.bin/make/cond.c +++ b/usr.bin/make/cond.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cond.c,v 1.3 1996/11/30 21:08:52 millert Exp $ */ +/* $OpenBSD: cond.c,v 1.4 1998/12/05 00:06:27 espie Exp $ */ /* $NetBSD: cond.c,v 1.7 1996/11/06 17:59:02 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; #else -static char rcsid[] = "$OpenBSD: cond.c,v 1.3 1996/11/30 21:08:52 millert Exp $"; +static char rcsid[] = "$OpenBSD: cond.c,v 1.4 1998/12/05 00:06:27 espie Exp $"; #endif #endif /* not lint */ @@ -295,8 +295,7 @@ CondDoDefined (argLen, arg) } else { result = FALSE; } - if (p1) - free(p1); + efree(p1); arg[argLen] = savec; return (result); } diff --git a/usr.bin/make/config.h b/usr.bin/make/config.h index 0426bee7c1c..71c83fd7153 100644 --- a/usr.bin/make/config.h +++ b/usr.bin/make/config.h @@ -1,4 +1,4 @@ -/* $OpenBSD: config.h,v 1.8 1996/12/22 20:15:35 rahnds Exp $ */ +/* $OpenBSD: config.h,v 1.9 1998/12/05 00:06:27 espie Exp $ */ /* $NetBSD: config.h,v 1.7 1996/11/06 17:59:03 christos Exp $ */ /* diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c index 185c3207025..86c7eaa218c 100644 --- a/usr.bin/make/dir.c +++ b/usr.bin/make/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.7 1997/04/01 07:28:11 millert Exp $ */ +/* $OpenBSD: dir.c,v 1.8 1998/12/05 00:06:27 espie Exp $ */ /* $NetBSD: dir.c,v 1.14 1997/03/29 16:51:26 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; #else -static char rcsid[] = "$OpenBSD: dir.c,v 1.7 1997/04/01 07:28:11 millert Exp $"; +static char rcsid[] = "$OpenBSD: dir.c,v 1.8 1998/12/05 00:06:27 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/dir.h b/usr.bin/make/dir.h index 3e47c6b64fa..f1351500112 100644 --- a/usr.bin/make/dir.h +++ b/usr.bin/make/dir.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.h,v 1.3 1996/11/30 21:08:54 millert Exp $ */ +/* $OpenBSD: dir.h,v 1.4 1998/12/05 00:06:27 espie Exp $ */ /* $NetBSD: dir.h,v 1.4 1996/11/06 17:59:05 christos Exp $ */ /* diff --git a/usr.bin/make/extern.h b/usr.bin/make/extern.h index 92903a76439..5b3b2833145 100644 --- a/usr.bin/make/extern.h +++ b/usr.bin/make/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.6 1996/11/30 21:09:01 millert Exp $ */ +/* $OpenBSD: extern.h,v 1.7 1998/12/05 00:06:28 espie Exp $ */ /* $NetBSD: nonints.h,v 1.12 1996/11/06 17:59:19 christos Exp $ */ /*- @@ -45,8 +45,8 @@ ReturnStatus Arch_ParseArchive __P((char **, Lst, GNode *)); void Arch_Touch __P((GNode *)); void Arch_TouchLib __P((GNode *)); -int Arch_MTime __P((GNode *)); -int Arch_MemMTime __P((GNode *)); +time_t Arch_MTime __P((GNode *)); +time_t Arch_MemMTime __P((GNode *)); void Arch_FindLib __P((GNode *, Lst)); Boolean Arch_LibOODate __P((GNode *)); void Arch_Init __P((void)); @@ -76,6 +76,9 @@ int PrintAddr __P((ClientData, ClientData)); void Finish __P((int)); char *estrdup __P((const char *)); void *emalloc __P((size_t)); +/* efree(x) works when x==NULL. STDC behavior, may need some different + * definition for cross-builds on deficient systems */ +#define efree free void *erealloc __P((void *, size_t)); void enomem __P((void)); int eunlink __P((const char *)); @@ -96,7 +99,7 @@ Lst Parse_MainName __P((void)); void str_init __P((void)); void str_end __P((void)); char *str_concat __P((char *, char *, int)); -char **brk_string __P((char *, int *, Boolean)); +char **brk_string __P((char *, int *, Boolean, char **)); char *Str_FindSubstring __P((char *, char *)); int Str_Match __P((char *, char *)); char *Str_SYSVMatch __P((char *, char *, int *len)); diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c index bce82a1e381..d90c0cf2561 100644 --- a/usr.bin/make/for.c +++ b/usr.bin/make/for.c @@ -1,4 +1,4 @@ -/* $OpenBSD: for.c,v 1.3 1996/11/30 21:08:54 millert Exp $ */ +/* $OpenBSD: for.c,v 1.4 1998/12/05 00:06:27 espie Exp $ */ /* $NetBSD: for.c,v 1.4 1996/11/06 17:59:05 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: for.c,v 1.3 1996/11/30 21:08:54 millert Exp $"; +static char rcsid[] = "$OpenBSD: for.c,v 1.4 1998/12/05 00:06:27 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/hash.c b/usr.bin/make/hash.c index 56d49c83d7c..be030e5984b 100644 --- a/usr.bin/make/hash.c +++ b/usr.bin/make/hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash.c,v 1.3 1996/11/30 21:08:55 millert Exp $ */ +/* $OpenBSD: hash.c,v 1.4 1998/12/05 00:06:27 espie Exp $ */ /* $NetBSD: hash.c,v 1.6 1996/11/06 17:59:06 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)hash.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: hash.c,v 1.3 1996/11/30 21:08:55 millert Exp $"; +static char rcsid[] = "$OpenBSD: hash.c,v 1.4 1998/12/05 00:06:27 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/hash.h b/usr.bin/make/hash.h index 92111641e2a..5992b3441ba 100644 --- a/usr.bin/make/hash.h +++ b/usr.bin/make/hash.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hash.h,v 1.3 1996/11/30 21:08:55 millert Exp $ */ +/* $OpenBSD: hash.h,v 1.4 1998/12/05 00:06:27 espie Exp $ */ /* $NetBSD: hash.h,v 1.5 1996/11/06 17:59:07 christos Exp $ */ /* diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index 4a7e78f8f73..175c5f412fa 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -1,4 +1,4 @@ -/* $OpenBSD: job.c,v 1.11 1998/07/13 02:11:37 millert Exp $ */ +/* $OpenBSD: job.c,v 1.12 1998/12/05 00:06:27 espie Exp $ */ /* $NetBSD: job.c,v 1.16 1996/11/06 17:59:08 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; #else -static char rcsid[] = "$OpenBSD: job.c,v 1.11 1998/07/13 02:11:37 millert Exp $"; +static char rcsid[] = "$OpenBSD: job.c,v 1.12 1998/12/05 00:06:27 espie Exp $"; #endif #endif /* not lint */ @@ -75,6 +75,8 @@ static char rcsid[] = "$OpenBSD: job.c,v 1.11 1998/07/13 02:11:37 millert Exp $" * Hence, the makefile must have been parsed * before this function is called. * + * Job_End Cleanup any memory used. + * * Job_Full Return TRUE if the job table is filled. * * Job_Empty Return TRUE if the job table is completely @@ -84,7 +86,7 @@ static char rcsid[] = "$OpenBSD: job.c,v 1.11 1998/07/13 02:11:37 millert Exp $" * the line as a shell specification. Returns * FAILURE if the spec was incorrect. * - * Job_End Perform any final processing which needs doing. + * Job_Finish Perform any final processing which needs doing. * This includes the execution of any commands * which have been/were attached to the .END * target. It should only be called when the @@ -215,7 +217,8 @@ static Shell *commandShell = &shells[DEFSHELL];/* this is the shell to * Job_ParseShell function */ static char *shellPath = NULL, /* full pathname of * executable image */ - *shellName; /* last component of shell */ + *shellName = NULL, /* last component of shell */ + *shellArgv = NULL; /* Custom shell args */ static int maxJobs; /* The most children we can run at once */ @@ -1111,8 +1114,7 @@ Job_CheckCommands(gn, abortProc) */ Make_HandleUse(DEFAULT, gn); Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn); - if (p1) - free(p1); + efree(p1); } else if (Dir_MTime(gn) == 0) { /* * The node wasn't the target of an operator we have no .DEFAULT @@ -2681,14 +2683,17 @@ Job_ParseShell(line) while (isspace(*line)) { line++; } - words = brk_string(line, &wordCount, TRUE); + + efree(shellArgv); + + words = brk_string(line, &wordCount, TRUE, &shellArgv); memset((Address)&newShell, 0, sizeof(newShell)); /* * Parse the specification by keyword */ - for (path = NULL, argc = wordCount - 1, argv = words + 1; + for (path = NULL, argc = wordCount - 1, argv = words; argc != 0; argc--, argv++) { if (strncmp(*argv, "path=", 5) == 0) { @@ -2718,6 +2723,7 @@ Job_ParseShell(line) } else { Parse_Error(PARSE_FATAL, "Unknown keyword \"%s\"", *argv); + free(words); return(FAILURE); } fullSpec = TRUE; @@ -2937,7 +2943,7 @@ JobInterrupt(runINTERRUPT, signo) /* *----------------------------------------------------------------------- - * Job_End -- + * Job_Finish -- * Do final processing such as the running of the commands * attached to the .END target. * @@ -2950,7 +2956,7 @@ JobInterrupt(runINTERRUPT, signo) *----------------------------------------------------------------------- */ int -Job_End() +Job_Finish() { if (postCommands != NILGNODE && !Lst_IsEmpty(postCommands->commands)) { if (errors) { @@ -2972,6 +2978,24 @@ Job_End() /*- *----------------------------------------------------------------------- + * Job_End -- + * Cleanup any memory used by the jobs module + * + * Results: + * None. + * + * Side Effects: + * Memory is freed + *----------------------------------------------------------------------- + */ +void +Job_End() +{ + efree(shellArgv); +} + +/*- + *----------------------------------------------------------------------- * Job_Wait -- * Waits for all running jobs to finish and returns. Sets 'aborting' * to ABORT_WAIT to prevent other jobs from starting. diff --git a/usr.bin/make/job.h b/usr.bin/make/job.h index bfc9b07dcec..3305bb00ca6 100644 --- a/usr.bin/make/job.h +++ b/usr.bin/make/job.h @@ -1,4 +1,4 @@ -/* $OpenBSD: job.h,v 1.4 1997/06/15 21:29:23 millert Exp $ */ +/* $OpenBSD: job.h,v 1.5 1998/12/05 00:06:28 espie Exp $ */ /* $NetBSD: job.h,v 1.5 1996/11/06 17:59:10 christos Exp $ */ /* @@ -228,7 +228,8 @@ void Job_Init __P((int, int)); Boolean Job_Full __P((void)); Boolean Job_Empty __P((void)); ReturnStatus Job_ParseShell __P((char *)); -int Job_End __P((void)); +int Job_Finish __P((void)); +void Job_End __P((void)); void Job_Wait __P((void)); void Job_AbortAll __P((void)); void JobFlagForMigration __P((int)); diff --git a/usr.bin/make/list.h b/usr.bin/make/list.h index 593e3c8530a..1bdf9e72df6 100644 --- a/usr.bin/make/list.h +++ b/usr.bin/make/list.h @@ -1,4 +1,4 @@ -/* $OpenBSD: list.h,v 1.3 1996/11/30 21:08:58 millert Exp $ */ +/* $OpenBSD: list.h,v 1.4 1998/12/05 00:06:28 espie Exp $ */ /* $NetBSD: list.h,v 1.5 1996/11/06 17:59:11 christos Exp $ */ /* diff --git a/usr.bin/make/lst.h b/usr.bin/make/lst.h index a316a04a42e..52cedbf0252 100644 --- a/usr.bin/make/lst.h +++ b/usr.bin/make/lst.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lst.h,v 1.5 1997/07/25 21:05:34 mickey Exp $ */ +/* $OpenBSD: lst.h,v 1.6 1998/12/05 00:06:28 espie Exp $ */ /* $NetBSD: lst.h,v 1.7 1996/11/06 17:59:12 christos Exp $ */ /* diff --git a/usr.bin/make/lst.lib/Makefile b/usr.bin/make/lst.lib/Makefile index 5c528259f58..b682876f8cb 100644 --- a/usr.bin/make/lst.lib/Makefile +++ b/usr.bin/make/lst.lib/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.4 1997/03/03 05:21:32 flipk Exp $ +# $OpenBSD: Makefile,v 1.5 1998/12/05 00:06:31 espie Exp $ # $NetBSD: Makefile,v 1.4 1996/11/06 17:59:31 christos Exp $ OBJ=lstAppend.o lstDupl.o lstInit.o lstOpen.o lstAtEnd.o lstEnQueue.o \ diff --git a/usr.bin/make/lst.lib/lstAppend.c b/usr.bin/make/lst.lib/lstAppend.c index bbb45def67b..65d9a3ae41e 100644 --- a/usr.bin/make/lst.lib/lstAppend.c +++ b/usr.bin/make/lst.lib/lstAppend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstAppend.c,v 1.3 1996/11/30 21:09:09 millert Exp $ */ +/* $OpenBSD: lstAppend.c,v 1.4 1998/12/05 00:06:31 espie Exp $ */ /* $NetBSD: lstAppend.c,v 1.5 1996/11/06 17:59:31 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstAppend.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstAppend.c,v 1.3 1996/11/30 21:09:09 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstAppend.c,v 1.4 1998/12/05 00:06:31 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstAtEnd.c b/usr.bin/make/lst.lib/lstAtEnd.c index e21edd19e89..b726d6097ce 100644 --- a/usr.bin/make/lst.lib/lstAtEnd.c +++ b/usr.bin/make/lst.lib/lstAtEnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstAtEnd.c,v 1.3 1996/11/30 21:09:10 millert Exp $ */ +/* $OpenBSD: lstAtEnd.c,v 1.4 1998/12/05 00:06:31 espie Exp $ */ /* $NetBSD: lstAtEnd.c,v 1.5 1996/11/06 17:59:32 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstAtEnd.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstAtEnd.c,v 1.3 1996/11/30 21:09:10 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstAtEnd.c,v 1.4 1998/12/05 00:06:31 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstAtFront.c b/usr.bin/make/lst.lib/lstAtFront.c index 968bb9b8ad3..af79fd7332b 100644 --- a/usr.bin/make/lst.lib/lstAtFront.c +++ b/usr.bin/make/lst.lib/lstAtFront.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstAtFront.c,v 1.3 1996/11/30 21:09:10 millert Exp $ */ +/* $OpenBSD: lstAtFront.c,v 1.4 1998/12/05 00:06:31 espie Exp $ */ /* $NetBSD: lstAtFront.c,v 1.5 1996/11/06 17:59:33 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstAtFront.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstAtFront.c,v 1.3 1996/11/30 21:09:10 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstAtFront.c,v 1.4 1998/12/05 00:06:31 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstClose.c b/usr.bin/make/lst.lib/lstClose.c index 19a0dee5abc..ce517f83cc4 100644 --- a/usr.bin/make/lst.lib/lstClose.c +++ b/usr.bin/make/lst.lib/lstClose.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstClose.c,v 1.3 1996/11/30 21:09:11 millert Exp $ */ +/* $OpenBSD: lstClose.c,v 1.4 1998/12/05 00:06:31 espie Exp $ */ /* $NetBSD: lstClose.c,v 1.5 1996/11/06 17:59:34 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstClose.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstClose.c,v 1.3 1996/11/30 21:09:11 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstClose.c,v 1.4 1998/12/05 00:06:31 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstConcat.c b/usr.bin/make/lst.lib/lstConcat.c index 2e3d20e9ea3..a503dddd85e 100644 --- a/usr.bin/make/lst.lib/lstConcat.c +++ b/usr.bin/make/lst.lib/lstConcat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstConcat.c,v 1.3 1996/11/30 21:09:11 millert Exp $ */ +/* $OpenBSD: lstConcat.c,v 1.4 1998/12/05 00:06:31 espie Exp $ */ /* $NetBSD: lstConcat.c,v 1.6 1996/11/06 17:59:34 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstConcat.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstConcat.c,v 1.3 1996/11/30 21:09:11 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstConcat.c,v 1.4 1998/12/05 00:06:31 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstDatum.c b/usr.bin/make/lst.lib/lstDatum.c index 411b8eba670..fbfbdcdf13c 100644 --- a/usr.bin/make/lst.lib/lstDatum.c +++ b/usr.bin/make/lst.lib/lstDatum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstDatum.c,v 1.3 1996/11/30 21:09:12 millert Exp $ */ +/* $OpenBSD: lstDatum.c,v 1.4 1998/12/05 00:06:31 espie Exp $ */ /* $NetBSD: lstDatum.c,v 1.5 1996/11/06 17:59:35 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstDatum.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstDatum.c,v 1.3 1996/11/30 21:09:12 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstDatum.c,v 1.4 1998/12/05 00:06:31 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstDeQueue.c b/usr.bin/make/lst.lib/lstDeQueue.c index 09843863392..a77ae583feb 100644 --- a/usr.bin/make/lst.lib/lstDeQueue.c +++ b/usr.bin/make/lst.lib/lstDeQueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstDeQueue.c,v 1.3 1996/11/30 21:09:12 millert Exp $ */ +/* $OpenBSD: lstDeQueue.c,v 1.4 1998/12/05 00:06:31 espie Exp $ */ /* $NetBSD: lstDeQueue.c,v 1.5 1996/11/06 17:59:36 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstDeQueue.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstDeQueue.c,v 1.3 1996/11/30 21:09:12 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstDeQueue.c,v 1.4 1998/12/05 00:06:31 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstDestroy.c b/usr.bin/make/lst.lib/lstDestroy.c index 169d25f35d2..0b63720645c 100644 --- a/usr.bin/make/lst.lib/lstDestroy.c +++ b/usr.bin/make/lst.lib/lstDestroy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstDestroy.c,v 1.3 1996/11/30 21:09:13 millert Exp $ */ +/* $OpenBSD: lstDestroy.c,v 1.4 1998/12/05 00:06:31 espie Exp $ */ /* $NetBSD: lstDestroy.c,v 1.6 1996/11/06 17:59:37 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstDestroy.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstDestroy.c,v 1.3 1996/11/30 21:09:13 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstDestroy.c,v 1.4 1998/12/05 00:06:31 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstDupl.c b/usr.bin/make/lst.lib/lstDupl.c index 0d2772df449..fdf9d9bc448 100644 --- a/usr.bin/make/lst.lib/lstDupl.c +++ b/usr.bin/make/lst.lib/lstDupl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstDupl.c,v 1.3 1996/11/30 21:09:13 millert Exp $ */ +/* $OpenBSD: lstDupl.c,v 1.4 1998/12/05 00:06:31 espie Exp $ */ /* $NetBSD: lstDupl.c,v 1.6 1996/11/06 17:59:37 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstDupl.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstDupl.c,v 1.3 1996/11/30 21:09:13 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstDupl.c,v 1.4 1998/12/05 00:06:31 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstEnQueue.c b/usr.bin/make/lst.lib/lstEnQueue.c index 1ba605b9637..cabe4330941 100644 --- a/usr.bin/make/lst.lib/lstEnQueue.c +++ b/usr.bin/make/lst.lib/lstEnQueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstEnQueue.c,v 1.3 1996/11/30 21:09:14 millert Exp $ */ +/* $OpenBSD: lstEnQueue.c,v 1.4 1998/12/05 00:06:31 espie Exp $ */ /* $NetBSD: lstEnQueue.c,v 1.5 1996/11/06 17:59:38 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstEnQueue.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstEnQueue.c,v 1.3 1996/11/30 21:09:14 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstEnQueue.c,v 1.4 1998/12/05 00:06:31 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstFind.c b/usr.bin/make/lst.lib/lstFind.c index 5b8a28b6335..2b0a9e0cc38 100644 --- a/usr.bin/make/lst.lib/lstFind.c +++ b/usr.bin/make/lst.lib/lstFind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstFind.c,v 1.3 1996/11/30 21:09:14 millert Exp $ */ +/* $OpenBSD: lstFind.c,v 1.4 1998/12/05 00:06:31 espie Exp $ */ /* $NetBSD: lstFind.c,v 1.6 1996/11/06 17:59:39 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstFind.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstFind.c,v 1.3 1996/11/30 21:09:14 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstFind.c,v 1.4 1998/12/05 00:06:31 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstFindFrom.c b/usr.bin/make/lst.lib/lstFindFrom.c index b96765265c1..38a9aebc949 100644 --- a/usr.bin/make/lst.lib/lstFindFrom.c +++ b/usr.bin/make/lst.lib/lstFindFrom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstFindFrom.c,v 1.3 1996/11/30 21:09:15 millert Exp $ */ +/* $OpenBSD: lstFindFrom.c,v 1.4 1998/12/05 00:06:32 espie Exp $ */ /* $NetBSD: lstFindFrom.c,v 1.6 1996/11/06 17:59:40 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstFindFrom.c 8.1 (Berkeley) 6/6/93"; #else -static char *rcsid = "$OpenBSD: lstFindFrom.c,v 1.3 1996/11/30 21:09:15 millert Exp $"; +static char *rcsid = "$OpenBSD: lstFindFrom.c,v 1.4 1998/12/05 00:06:32 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstFirst.c b/usr.bin/make/lst.lib/lstFirst.c index c1991800932..37d13a5b706 100644 --- a/usr.bin/make/lst.lib/lstFirst.c +++ b/usr.bin/make/lst.lib/lstFirst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstFirst.c,v 1.3 1996/11/30 21:09:15 millert Exp $ */ +/* $OpenBSD: lstFirst.c,v 1.4 1998/12/05 00:06:32 espie Exp $ */ /* $NetBSD: lstFirst.c,v 1.5 1996/11/06 17:59:41 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstFirst.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstFirst.c,v 1.3 1996/11/30 21:09:15 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstFirst.c,v 1.4 1998/12/05 00:06:32 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstForEach.c b/usr.bin/make/lst.lib/lstForEach.c index 981b8ca550c..dbf275c66a7 100644 --- a/usr.bin/make/lst.lib/lstForEach.c +++ b/usr.bin/make/lst.lib/lstForEach.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstForEach.c,v 1.3 1996/11/30 21:09:16 millert Exp $ */ +/* $OpenBSD: lstForEach.c,v 1.4 1998/12/05 00:06:32 espie Exp $ */ /* $NetBSD: lstForEach.c,v 1.6 1996/11/06 17:59:41 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstForEach.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstForEach.c,v 1.3 1996/11/30 21:09:16 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstForEach.c,v 1.4 1998/12/05 00:06:32 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstForEachFrom.c b/usr.bin/make/lst.lib/lstForEachFrom.c index 6e6ffff6d6a..12ae71acce3 100644 --- a/usr.bin/make/lst.lib/lstForEachFrom.c +++ b/usr.bin/make/lst.lib/lstForEachFrom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstForEachFrom.c,v 1.3 1996/11/30 21:09:16 millert Exp $ */ +/* $OpenBSD: lstForEachFrom.c,v 1.4 1998/12/05 00:06:32 espie Exp $ */ /* $NetBSD: lstForEachFrom.c,v 1.5 1996/11/06 17:59:42 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstForEachFrom.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstForEachFrom.c,v 1.3 1996/11/30 21:09:16 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstForEachFrom.c,v 1.4 1998/12/05 00:06:32 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstInit.c b/usr.bin/make/lst.lib/lstInit.c index bbead4bf4c6..9a6f2b235af 100644 --- a/usr.bin/make/lst.lib/lstInit.c +++ b/usr.bin/make/lst.lib/lstInit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstInit.c,v 1.3 1996/11/30 21:09:17 millert Exp $ */ +/* $OpenBSD: lstInit.c,v 1.4 1998/12/05 00:06:32 espie Exp $ */ /* $NetBSD: lstInit.c,v 1.5 1996/11/06 17:59:43 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstInit.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstInit.c,v 1.3 1996/11/30 21:09:17 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstInit.c,v 1.4 1998/12/05 00:06:32 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstInsert.c b/usr.bin/make/lst.lib/lstInsert.c index 194f65b0bb5..30bd4cac670 100644 --- a/usr.bin/make/lst.lib/lstInsert.c +++ b/usr.bin/make/lst.lib/lstInsert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstInsert.c,v 1.3 1996/11/30 21:09:17 millert Exp $ */ +/* $OpenBSD: lstInsert.c,v 1.4 1998/12/05 00:06:32 espie Exp $ */ /* $NetBSD: lstInsert.c,v 1.5 1996/11/06 17:59:44 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstInsert.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstInsert.c,v 1.3 1996/11/30 21:09:17 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstInsert.c,v 1.4 1998/12/05 00:06:32 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstInt.h b/usr.bin/make/lst.lib/lstInt.h index aa1c424d466..1691757518a 100644 --- a/usr.bin/make/lst.lib/lstInt.h +++ b/usr.bin/make/lst.lib/lstInt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lstInt.h,v 1.5 1998/02/22 19:57:36 mickey Exp $ */ +/* $OpenBSD: lstInt.h,v 1.6 1998/12/05 00:06:32 espie Exp $ */ /* $NetBSD: lstInt.h,v 1.7 1996/11/06 17:59:44 christos Exp $ */ /* diff --git a/usr.bin/make/lst.lib/lstIsAtEnd.c b/usr.bin/make/lst.lib/lstIsAtEnd.c index 296d6ddd505..87cf6ad0416 100644 --- a/usr.bin/make/lst.lib/lstIsAtEnd.c +++ b/usr.bin/make/lst.lib/lstIsAtEnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstIsAtEnd.c,v 1.3 1996/11/30 21:09:18 millert Exp $ */ +/* $OpenBSD: lstIsAtEnd.c,v 1.4 1998/12/05 00:06:32 espie Exp $ */ /* $NetBSD: lstIsAtEnd.c,v 1.5 1996/11/06 17:59:45 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstIsAtEnd.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstIsAtEnd.c,v 1.3 1996/11/30 21:09:18 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstIsAtEnd.c,v 1.4 1998/12/05 00:06:32 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstIsEmpty.c b/usr.bin/make/lst.lib/lstIsEmpty.c index 907adba101b..aabec4e5978 100644 --- a/usr.bin/make/lst.lib/lstIsEmpty.c +++ b/usr.bin/make/lst.lib/lstIsEmpty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstIsEmpty.c,v 1.3 1996/11/30 21:09:19 millert Exp $ */ +/* $OpenBSD: lstIsEmpty.c,v 1.4 1998/12/05 00:06:32 espie Exp $ */ /* $NetBSD: lstIsEmpty.c,v 1.5 1996/11/06 17:59:47 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstIsEmpty.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstIsEmpty.c,v 1.3 1996/11/30 21:09:19 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstIsEmpty.c,v 1.4 1998/12/05 00:06:32 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstLast.c b/usr.bin/make/lst.lib/lstLast.c index 87feb544384..6c4e9b5cf5a 100644 --- a/usr.bin/make/lst.lib/lstLast.c +++ b/usr.bin/make/lst.lib/lstLast.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstLast.c,v 1.3 1996/11/30 21:09:19 millert Exp $ */ +/* $OpenBSD: lstLast.c,v 1.4 1998/12/05 00:06:32 espie Exp $ */ /* $NetBSD: lstLast.c,v 1.5 1996/11/06 17:59:48 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstLast.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstLast.c,v 1.3 1996/11/30 21:09:19 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstLast.c,v 1.4 1998/12/05 00:06:32 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstMember.c b/usr.bin/make/lst.lib/lstMember.c index 679d04ae417..af8eb15354c 100644 --- a/usr.bin/make/lst.lib/lstMember.c +++ b/usr.bin/make/lst.lib/lstMember.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstMember.c,v 1.3 1996/11/30 21:09:20 millert Exp $ */ +/* $OpenBSD: lstMember.c,v 1.4 1998/12/05 00:06:32 espie Exp $ */ /* $NetBSD: lstMember.c,v 1.5 1996/11/06 17:59:48 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstMember.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstMember.c,v 1.3 1996/11/30 21:09:20 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstMember.c,v 1.4 1998/12/05 00:06:32 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstNext.c b/usr.bin/make/lst.lib/lstNext.c index 0fc297e4d01..db43d37164e 100644 --- a/usr.bin/make/lst.lib/lstNext.c +++ b/usr.bin/make/lst.lib/lstNext.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstNext.c,v 1.3 1996/11/30 21:09:20 millert Exp $ */ +/* $OpenBSD: lstNext.c,v 1.4 1998/12/05 00:06:32 espie Exp $ */ /* $NetBSD: lstNext.c,v 1.5 1996/11/06 17:59:49 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstNext.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstNext.c,v 1.3 1996/11/30 21:09:20 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstNext.c,v 1.4 1998/12/05 00:06:32 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstOpen.c b/usr.bin/make/lst.lib/lstOpen.c index ef7d44d764d..72a89642618 100644 --- a/usr.bin/make/lst.lib/lstOpen.c +++ b/usr.bin/make/lst.lib/lstOpen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstOpen.c,v 1.3 1996/11/30 21:09:21 millert Exp $ */ +/* $OpenBSD: lstOpen.c,v 1.4 1998/12/05 00:06:32 espie Exp $ */ /* $NetBSD: lstOpen.c,v 1.5 1996/11/06 17:59:50 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstOpen.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstOpen.c,v 1.3 1996/11/30 21:09:21 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstOpen.c,v 1.4 1998/12/05 00:06:32 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstRemove.c b/usr.bin/make/lst.lib/lstRemove.c index 3efdbc5760b..5f54142ed5f 100644 --- a/usr.bin/make/lst.lib/lstRemove.c +++ b/usr.bin/make/lst.lib/lstRemove.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstRemove.c,v 1.3 1996/11/30 21:09:21 millert Exp $ */ +/* $OpenBSD: lstRemove.c,v 1.4 1998/12/05 00:06:32 espie Exp $ */ /* $NetBSD: lstRemove.c,v 1.5 1996/11/06 17:59:50 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstRemove.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstRemove.c,v 1.3 1996/11/30 21:09:21 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstRemove.c,v 1.4 1998/12/05 00:06:32 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstReplace.c b/usr.bin/make/lst.lib/lstReplace.c index 122a68c5541..178f42822b4 100644 --- a/usr.bin/make/lst.lib/lstReplace.c +++ b/usr.bin/make/lst.lib/lstReplace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstReplace.c,v 1.3 1996/11/30 21:09:22 millert Exp $ */ +/* $OpenBSD: lstReplace.c,v 1.4 1998/12/05 00:06:33 espie Exp $ */ /* $NetBSD: lstReplace.c,v 1.5 1996/11/06 17:59:51 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstReplace.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstReplace.c,v 1.3 1996/11/30 21:09:22 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstReplace.c,v 1.4 1998/12/05 00:06:33 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/lst.lib/lstSucc.c b/usr.bin/make/lst.lib/lstSucc.c index 435720957bf..089382e56be 100644 --- a/usr.bin/make/lst.lib/lstSucc.c +++ b/usr.bin/make/lst.lib/lstSucc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lstSucc.c,v 1.3 1996/11/30 21:09:22 millert Exp $ */ +/* $OpenBSD: lstSucc.c,v 1.4 1998/12/05 00:06:33 espie Exp $ */ /* $NetBSD: lstSucc.c,v 1.5 1996/11/06 17:59:52 christos Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)lstSucc.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: lstSucc.c,v 1.3 1996/11/30 21:09:22 millert Exp $"; +static char rcsid[] = "$OpenBSD: lstSucc.c,v 1.4 1998/12/05 00:06:33 espie Exp $"; #endif #endif /* not lint */ diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index b23ed55fbaa..ccf4cfa859a 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.13 1998/01/28 12:41:50 niklas Exp $ */ +/* $OpenBSD: main.c,v 1.14 1998/12/05 00:06:28 espie Exp $ */ /* $NetBSD: main.c,v 1.34 1997/03/24 20:56:36 gwr Exp $ */ /* @@ -49,7 +49,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #else -static char rcsid[] = "$OpenBSD: main.c,v 1.13 1998/01/28 12:41:50 niklas Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.14 1998/12/05 00:06:28 espie Exp $"; #endif #endif /* not lint */ @@ -94,6 +94,7 @@ static char rcsid[] = "$OpenBSD: main.c,v 1.13 1998/01/28 12:41:50 niklas Exp $" #include <fcntl.h> #include <stdio.h> #include <stdlib.h> +#include <time.h> #ifdef __STDC__ #include <stdarg.h> #else @@ -375,6 +376,9 @@ Main_ParseArgLine(line) { char **argv; /* Manufactured argument vector */ int argc; /* Number of arguments in argv */ + char *args; /* Space used by the args */ + char *buf, *p1; + char *argv0 = Var_Value(".MAKE", VAR_GLOBAL, &p1); if (line == NULL) return; @@ -383,8 +387,16 @@ Main_ParseArgLine(line) if (!*line) return; - argv = brk_string(line, &argc, TRUE); + buf = emalloc(strlen(line) + strlen(argv0) + 2); + (void)sprintf(buf, "%s %s", argv0, line); + efree(p1); + + argv = brk_string(buf, &argc, TRUE, &args); + free(buf); MainParseArgs(argc, argv); + + free(args); + free(argv); } char * @@ -592,7 +604,6 @@ main(argc, argv) * directories */ Var_Init(); /* As well as the lists of variables for * parsing arguments */ - str_init(); if (objdir != curdir) Dir_AddDir(dirSearchPath, curdir); Var_Set(".CURDIR", curdir, VAR_GLOBAL); @@ -605,6 +616,7 @@ main(argc, argv) * MFLAGS also gets initialized empty, for compatibility. */ Var_Set("MAKE", argv[0], VAR_GLOBAL); + Var_Set(".MAKE", argv[0], VAR_GLOBAL); Var_Set(MAKEFLAGS, "", VAR_GLOBAL); Var_Set("MFLAGS", "", VAR_GLOBAL); Var_Set("MACHINE", machine, VAR_GLOBAL); @@ -700,8 +712,7 @@ main(argc, argv) (void)ReadMakefile(".depend", NULL); Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1), VAR_GLOBAL); - if (p1) - free(p1); + efree(p1); /* Install all the flags into the MAKE envariable. */ if (((p = Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1)) != NULL) && *p) @@ -710,8 +721,7 @@ main(argc, argv) #else setenv("MAKE", p, 1); #endif - if (p1) - free(p1); + efree(p1); /* * For compatibility, look at the directories in the VPATH variable @@ -765,8 +775,7 @@ main(argc, argv) VAR_GLOBAL, &p1); printf("%s\n", value ? value : ""); - if (p1) - free(p1); + efree(p1); } } @@ -816,10 +825,10 @@ main(argc, argv) Suff_End(); Targ_End(); Arch_End(); - str_end(); Var_End(); Parse_End(); Dir_End(); + Job_End(); if (queryFlag && outOfDate) return(1); diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1 index 84b2d80377a..ce5af73b906 100644 --- a/usr.bin/make/make.1 +++ b/usr.bin/make/make.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: make.1,v 1.14 1998/09/26 19:55:05 aaron Exp $ +.\" $OpenBSD: make.1,v 1.15 1998/12/05 00:06:28 espie Exp $ .\" $NetBSD: make.1,v 1.18 1997/03/10 21:19:53 christos Exp $ .\" .\" Copyright (c) 1990, 1993 @@ -42,7 +42,7 @@ .Nd maintain program dependencies .Sh SYNOPSIS .Nm make -.Op Fl Beiknqrst +.Op Fl BPSeiknqrst .Op Fl D Ar variable .Op Fl d Ar flags .Op Fl f Ar makefile @@ -83,6 +83,9 @@ The options are as follows: .It Fl B Try to be backwards compatible by executing a single shell per command and by executing the commands to make the sources of a dependency line in sequence. +This is turned on by default unless +.Fl j +is used. .It Fl D Ar variable Define .Ar variable @@ -103,6 +106,9 @@ Print debugging information about archive searching and caching. Print debugging information about conditional evaluation. .It Ar d Print debugging information about directory searching and caching. +.It Ar f +Print debugging information about the execution of for loops. Currently a +no-op. .It Ar "g1" Print the input graph before making anything. .It Ar "g2" @@ -165,11 +171,22 @@ option). .It Fl n Display the commands that would have been executed, but do not actually execute them. +.It Fl P +Collate the output of a given job and display it only when the job finishes, +instead of mixing the output of parallel jobs together. +This option has no effect unless +.Fl j +is used too. .It Fl q Do not execute any commands, but exit 0 if the specified targets are up-to-date and 1, otherwise. .It Fl r Do not use the built-in rules specified in the system makefile. +.It Fl S +Stop processing when an error is encountered. Default +behavior. This is needed to negate the +.Fl k +option during recursive builds. .It Fl s Do not echo any commands as they are executed. Equivalent to specifying @@ -240,13 +257,13 @@ The target will not be removed if is interrupted. .El .Pp -Targets and sources may contain the shell wildcard values +Targets and sources may contain the shell wildcard expressions .Ql ? , .Ql * , .Ql [] and .Ql {} . -The values +The expressions .Ql ? , .Ql * and @@ -254,7 +271,7 @@ and may only be used as part of the final component of the target or source, and must be used to describe existing files. -The value +The expression .Ql {} need not necessarily be used to describe existing files. Expansion is in directory order, not alphabetically as done in the shell. @@ -347,13 +364,15 @@ The seven local variables are as follows: The list of all sources for this target; also known as .Ql Va \&> . .It Va .ARCHIVE -The name of the archive file. +The name of the archive file; also known as +.Ql Va \&! . .It Va .IMPSRC The name/path of the source from which the target is to be transformed (the ``implied'' source); also known as .Ql Va \&< . .It Va .MEMBER -The name of the archive member. +The name of the archive member; also known as +.Ql Va \&% . .It Va .OODATE The list of sources for this target that were deemed out-of-date; also known as @@ -369,6 +388,9 @@ The name of the target; also known as .Pp The shorter forms .Ql Va @ , +.Ql Va ! , +.Ql Va \&< , +.Ql Va \&% , .Ql Va ? , .Ql Va \&> , and @@ -396,10 +418,12 @@ These variables are .Ql Va .ARCHIVE , and .Ql Va .MEMBER . +.El .Pp In addition, .Nm make -sets or knows about the following variables: +sets or knows about the following internal variables, or environment +variables: .Bl -tag -width MAKEFLAGS .It Va \&$ A single dollar sign @@ -423,8 +447,14 @@ At startup, .Nm make searches for an alternate directory to place target files -- it will attempt to change into this special directory. -.Nm make -first tries to change into the directory named by the environment +.Nm make +first tries to change into the prepend the path named by the environment +variable +.Ev MAKEOBJDIRPREFIX +to +.Va .CURDIR . +If that fails, it then +tries to change into the directory named by the environment variable .Ev MAKEOBJDIR . If that fails, it tries to change into the directory named @@ -441,21 +471,29 @@ directory, it next tries the directory named Finally, if none of the above directories are available .Nm make will settle for and use the current directory. -.It Ev MAKEFLAGS +.It Va .MAKEFLAGS The environment variable .Ev MAKEFLAGS may contain anything that may be specified on .Nm make Ns 's -command line. +command line. Its contents are stored in +.Nm make Ns 's +.Va .MAKEFLAGS +variable. Anything specified on .Nm make Ns 's command line is appended to the -.Ev MAKEFLAGS +.Va .MAKEFLAGS variable which is then -entered into the environment for all programs which +entered into the environment as +.Ev MAKEFLAGS +for all programs which .Nm make executes. +.It Va MFLAGS +A shorter synonym for +.Va .MAKEFLAGS . .It Ev PWD Alternate path to the current directory. .Nm make @@ -473,11 +511,21 @@ to the value of .Ev PWD instead. .Ev PWD -is set to the value of +is always set to the value of .Ql Va .OBJDIR for all programs which .Nm make executes. +.It Va .TARGETS +todo +.It Va .INCLUDES +todo +.It Va .LIBS +todo +.It Va MACHINE +todo +.It Va MACHINE_ARCH +todo .El .Pp Variable expansion may be modified to select or modify each word of the @@ -1001,19 +1049,35 @@ command in the file. Each source specifies a suffix to .Nm make . If no sources are specified, any previous specified suffices are deleted. +.Sh COMPATIBILITY +Older versions of +.Nm make +used +.Ev MAKE +instead of +.Ev MAKEFLAGS . +This was removed for POSIX compatibility. +The internal variable +.Va MAKE +is set to the same value as +.Va .MAKE , +support for this may be removed in the future. .Sh ENVIRONMENT .Nm make -utilizes the following environment variables, if they exist: +uses the following environment variables, if they exist: .Ev MACHINE , -.Ev MAKE , +.Ev MACHINE_ARCH , .Ev MAKEFLAGS , .Ev MAKEOBJDIR , +.Ev MAKEOBJDIRPREFIX , and .Ev PWD . .Sh FILES .Bl -tag -width /usr/share/mk -compact .It Pa .depend list of dependencies +.It Pa BSDmakefile +list of dependencies .It Pa Makefile list of dependencies .It Pa makefile @@ -1022,6 +1086,9 @@ list of dependencies system makefile .It Pa /usr/share/mk system makefile directory +.IT Pa /usr/obj +default +.Ev MAKEOBJDIRPREFIX directory. .El .Sh SEE ALSO .Xr mkdep 1 diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c index 6d6bffad38b..c0fe1372015 100644 --- a/usr.bin/make/make.c +++ b/usr.bin/make/make.c @@ -1,4 +1,4 @@ -/* $OpenBSD: make.c,v 1.6 1997/04/28 01:52:38 millert Exp $ */ +/* $OpenBSD: make.c,v 1.7 1998/12/05 00:06:28 espie Exp $ */ /* $NetBSD: make.c,v 1.10 1996/11/06 17:59:15 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: make.c,v 1.6 1997/04/28 01:52:38 millert Exp $"; +static char rcsid[] = "$OpenBSD: make.c,v 1.7 1998/12/05 00:06:28 espie Exp $"; #endif #endif /* not lint */ @@ -129,7 +129,7 @@ MakeTimeStamp (pgn, cgn) ClientData pgn; /* the current parent */ ClientData cgn; /* the child we've just examined */ { - return (Make_TimeStamp((GNode *) pgn, (GNode *) cgn)); + return Make_TimeStamp((GNode *) pgn, (GNode *) cgn); } /*- @@ -376,7 +376,7 @@ MakeHandleUse (pgn, cgn) ClientData pgn; /* the current parent */ ClientData cgn; /* the child we've just examined */ { - return (Make_HandleUse((GNode *) pgn, (GNode *) cgn)); + return Make_HandleUse((GNode *) pgn, (GNode *) cgn); } /*- @@ -414,8 +414,7 @@ Make_Update (cgn) char *p1; cname = Var_Value (TARGET, cgn, &p1); - if (p1) - free(p1); + efree(p1); /* * If the child was actually made, see what its modification time is @@ -544,8 +543,7 @@ Make_Update (cgn) Var_Set (PREFIX, cpref, pgn); } } - if (p1) - free(p1); + efree(p1); Lst_Close (cgn->iParents); } } @@ -616,8 +614,7 @@ MakeAddAllSrc (cgnp, pgnp) */ Var_Append(OODATE, child, pgn); } - if (p1) - free(p1); + efree(p1); } return (0); } @@ -660,8 +657,7 @@ Make_DoAllVar (gn) if (gn->type & OP_JOIN) { char *p1; Var_Set (TARGET, Var_Value (ALLSRC, gn, &p1), gn); - if (p1) - free(p1); + efree(p1); } } @@ -906,7 +902,7 @@ Make_Run (targs) (void)MakeStartJobs(); } - errors = Job_End(); + errors = Job_Finish(); /* * Print the final status of each target. E.g. if it wasn't made diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h index 2c144ff7efd..0be1c93abc1 100644 --- a/usr.bin/make/make.h +++ b/usr.bin/make/make.h @@ -1,4 +1,4 @@ -/* $OpenBSD: make.h,v 1.12 1998/06/29 19:57:10 art Exp $ */ +/* $OpenBSD: make.h,v 1.13 1998/12/05 00:06:28 espie Exp $ */ /* $NetBSD: make.h,v 1.15 1997/03/10 21:20:00 christos Exp $ */ /* @@ -146,8 +146,8 @@ typedef struct GNode { * made */ int unmade; /* The number of unmade children */ - int mtime; /* Its modification time */ - int cmtime; /* The modification time of its youngest + time_t mtime; /* Its modification time */ + time_t cmtime; /* The modification time of its youngest * child */ Lst iParents; /* Links to parents for which this is an @@ -212,6 +212,7 @@ typedef struct GNode { #define OP_NOTMAIN 0x00008000 /* The node is exempt from normal 'main * target' processing in parse.c */ #define OP_PHONY 0x00010000 /* Not a file target; run always */ +#define OP_NOPATH 0x00020000 /* Don't search for file in the path */ /* Attributes applied by PMake */ #define OP_TRANSFORM 0x80000000 /* The node is a transformation rule */ #define OP_MEMBER 0x40000000 /* Target is a member of an archive */ @@ -229,6 +230,8 @@ typedef struct GNode { */ #define OP_NOP(t) (((t) & OP_OPMASK) == 0x00000000) +#define OP_NOTARGET (OP_NOTMAIN|OP_USE|OP_EXEC|OP_TRANSFORM) + /* * The TARG_ constants are used when calling the Targ_FindNode and * Targ_FindList functions in targ.c. They simply tell the functions what to diff --git a/usr.bin/make/nonints.h b/usr.bin/make/nonints.h index 56c4265241f..d3eda26293c 100644 --- a/usr.bin/make/nonints.h +++ b/usr.bin/make/nonints.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nonints.h,v 1.6 1996/11/30 21:09:01 millert Exp $ */ +/* $OpenBSD: nonints.h,v 1.7 1998/12/05 00:06:28 espie Exp $ */ /* $NetBSD: nonints.h,v 1.12 1996/11/06 17:59:19 christos Exp $ */ /*- @@ -45,8 +45,8 @@ ReturnStatus Arch_ParseArchive __P((char **, Lst, GNode *)); void Arch_Touch __P((GNode *)); void Arch_TouchLib __P((GNode *)); -int Arch_MTime __P((GNode *)); -int Arch_MemMTime __P((GNode *)); +time_t Arch_MTime __P((GNode *)); +time_t Arch_MemMTime __P((GNode *)); void Arch_FindLib __P((GNode *, Lst)); Boolean Arch_LibOODate __P((GNode *)); void Arch_Init __P((void)); @@ -76,6 +76,9 @@ int PrintAddr __P((ClientData, ClientData)); void Finish __P((int)); char *estrdup __P((const char *)); void *emalloc __P((size_t)); +/* efree(x) works when x==NULL. STDC behavior, may need some different + * definition for cross-builds on deficient systems */ +#define efree free void *erealloc __P((void *, size_t)); void enomem __P((void)); int eunlink __P((const char *)); @@ -96,7 +99,7 @@ Lst Parse_MainName __P((void)); void str_init __P((void)); void str_end __P((void)); char *str_concat __P((char *, char *, int)); -char **brk_string __P((char *, int *, Boolean)); +char **brk_string __P((char *, int *, Boolean, char **)); char *Str_FindSubstring __P((char *, char *)); int Str_Match __P((char *, char *)); char *Str_SYSVMatch __P((char *, char *, int *len)); diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 2372691bfbb..4005be97714 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.16 1998/07/02 20:47:26 millert Exp $ */ +/* $OpenBSD: parse.c,v 1.17 1998/12/05 00:06:29 espie Exp $ */ /* $NetBSD: parse.c,v 1.29 1997/03/10 21:20:04 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; #else -static char rcsid[] = "$OpenBSD: parse.c,v 1.16 1998/07/02 20:47:26 millert Exp $"; +static char rcsid[] = "$OpenBSD: parse.c,v 1.17 1998/12/05 00:06:29 espie Exp $"; #endif #endif /* not lint */ @@ -164,6 +164,7 @@ typedef enum { Main, /* .MAIN and we don't have anything user-specified to * make */ NoExport, /* .NOEXPORT */ + NoPath, /* .NOPATH */ Not, /* Not special */ NotParallel, /* .NOTPARALELL */ Null, /* .NULL */ @@ -216,6 +217,9 @@ static struct { { ".MAKE", Attribute, OP_MAKE }, { ".MAKEFLAGS", MFlags, 0 }, { ".MFLAGS", MFlags, 0 }, +#if 0 /* basic scaffolding for NOPATH, not working yet */ +{ ".NOPATH", NoPath, OP_NOPATH }, +#endif { ".NOTMAIN", Attribute, OP_NOTMAIN }, { ".NOTPARALLEL", NotParallel, 0 }, { ".NO_PARALLEL", NotParallel, 0 }, @@ -235,6 +239,8 @@ static struct { { ".WAIT", Wait, 0 }, }; +static void ParseErrorInternal __P((char *, size_t, int, char *, ...)); +static void ParseVErrorInternal __P((char *, size_t, int, char *, va_list)); static int ParseFindKeyword __P((char *)); static int ParseLinkSrc __P((ClientData, ClientData)); static int ParseDoOp __P((ClientData, ClientData)); @@ -297,7 +303,7 @@ ParseFindKeyword (str) } /*- - * Parse_Error -- + * ParseVErrorInternal -- * Error message abort function for parsing. Prints out the context * of the error (line number and file) as well as the message with * two optional arguments. @@ -309,6 +315,77 @@ ParseFindKeyword (str) * "fatals" is incremented if the level is PARSE_FATAL. */ /* VARARGS */ +static void +#ifdef __STDC__ +ParseVErrorInternal(char *cfname, size_t clineno, int type, char *fmt, + va_list ap) +#else +ParseVErrorInternal(va_alist) + va_dcl +#endif +{ + (void)fprintf(stderr, "\"%s\", line %d: ", cfname, (int) clineno); + if (type == PARSE_WARNING) + (void)fprintf(stderr, "warning: "); + (void)vfprintf(stderr, fmt, ap); + va_end(ap); + (void)fprintf(stderr, "\n"); + (void)fflush(stderr); + if (type == PARSE_FATAL) + fatals += 1; +} + +/*- + * ParseErrorInternal -- + * Error function + * + * Results: + * None + * + * Side Effects: + * None + */ +/* VARARGS */ +static void +#ifdef __STDC__ +ParseErrorInternal(char *cfname, size_t clineno, int type, char *fmt, ...) +#else +ParseErrorInternal(va_alist) + va_dcl +#endif +{ + va_list ap; +#ifdef __STDC__ + va_start(ap, fmt); +#else + int type; /* Error type (PARSE_WARNING, PARSE_FATAL) */ + char *fmt; + char *cfname; + size_t clineno; + + va_start(ap); + cfname = va_arg(ap, char *); + clineno = va_arg(ap, size_t); + type = va_arg(ap, int); + fmt = va_arg(ap, char *); +#endif + + ParseVErrorInternal(cfname, clineno, type, fmt, ap); + va_end(ap); +} + +/*- + * Parse_Error -- + * External interface to ParseErrorInternal; uses the default filename + * Line number. + * + * Results: + * None + * + * Side Effects: + * None + */ +/* VARARGS */ void #ifdef __STDC__ Parse_Error(int type, char *fmt, ...) @@ -329,15 +406,7 @@ Parse_Error(va_alist) fmt = va_arg(ap, char *); #endif - (void)fprintf(stderr, "\"%s\", line %d: ", fname, lineno); - if (type == PARSE_WARNING) - (void)fprintf(stderr, "warning: "); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); - (void)fflush(stderr); - if (type == PARSE_FATAL) - fatals += 1; + ParseVErrorInternal(fname, lineno, type, fmt, ap); } /*- @@ -627,7 +696,7 @@ ParseFindMain(gnp, dummy) ClientData dummy; { GNode *gn = (GNode *) gnp; - if ((gn->type & (OP_NOTMAIN|OP_USE|OP_EXEC|OP_TRANSFORM)) == 0) { + if ((gn->type & OP_NOTARGET) == 0) { mainNode = gn; Targ_SetMain(gn); return (dummy ? 1 : 1); @@ -836,6 +905,7 @@ ParseDoDependency (line) * use Make_HandleUse to actually * apply the .DEFAULT commands. * .PHONY The list of targets + * .NOPATH Don't search for file in the path * .BEGIN * .END * .INTERRUPT Are not to be considered the diff --git a/usr.bin/make/pathnames.h b/usr.bin/make/pathnames.h index e97ea94b00b..e21f8e31e26 100644 --- a/usr.bin/make/pathnames.h +++ b/usr.bin/make/pathnames.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pathnames.h,v 1.6 1996/11/30 21:09:03 millert Exp $ */ +/* $OpenBSD: pathnames.h,v 1.7 1998/12/05 00:06:29 espie Exp $ */ /* $NetBSD: pathnames.h,v 1.6 1996/11/06 17:59:21 christos Exp $ */ /* diff --git a/usr.bin/make/sprite.h b/usr.bin/make/sprite.h index b0ca5f8db15..ca035620ebd 100644 --- a/usr.bin/make/sprite.h +++ b/usr.bin/make/sprite.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sprite.h,v 1.4 1998/02/22 19:57:34 mickey Exp $ */ +/* $OpenBSD: sprite.h,v 1.5 1998/12/05 00:06:29 espie Exp $ */ /* $NetBSD: sprite.h,v 1.6 1996/11/06 17:59:22 christos Exp $ */ /* diff --git a/usr.bin/make/str.c b/usr.bin/make/str.c index 5c44eae1e54..2d2eece77bc 100644 --- a/usr.bin/make/str.c +++ b/usr.bin/make/str.c @@ -1,4 +1,4 @@ -/* $OpenBSD: str.c,v 1.6 1998/03/07 18:34:50 millert Exp $ */ +/* $OpenBSD: str.c,v 1.7 1998/12/05 00:06:29 espie Exp $ */ /* $NetBSD: str.c,v 1.13 1996/11/06 17:59:23 christos Exp $ */ /*- @@ -43,46 +43,12 @@ #if 0 static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90"; #else -static char rcsid[] = "$OpenBSD: str.c,v 1.6 1998/03/07 18:34:50 millert Exp $"; +static char rcsid[] = "$OpenBSD: str.c,v 1.7 1998/12/05 00:06:29 espie Exp $"; #endif #endif /* not lint */ #include "make.h" -static char **argv, *buffer; -static int argmax, curlen; - -/* - * str_init -- - * Initialize the strings package - * - */ -void -str_init() -{ - char *p1; - argv = (char **)emalloc(((argmax = 50) + 1) * sizeof(char *)); - argv[0] = Var_Value(".MAKE", VAR_GLOBAL, &p1); -} - - -/* - * str_end -- - * Cleanup the strings package - * - */ -void -str_end() -{ - if (argv) { - if (argv[0]) - free(argv[0]); - free((Address) argv); - } - if (buffer) - free(buffer); -} - /*- * str_concat -- * concatenate the two strings, inserting a space or slash between them, @@ -140,33 +106,33 @@ str_concat(s1, s2, flags) * the first word is always the value of the .MAKE variable. */ char ** -brk_string(str, store_argc, expand) +brk_string(str, store_argc, expand, buffer) register char *str; int *store_argc; Boolean expand; + char **buffer; { register int argc, ch; register char inquote, *p, *start, *t; int len; + int argmax = 50, curlen = 0; + char **argv = (char **)emalloc((argmax + 1) * sizeof(char *)); /* skip leading space chars. */ for (; *str == ' ' || *str == '\t'; ++str) continue; /* allocate room for a copy of the string */ - if ((len = strlen(str) + 1) > curlen) { - if (buffer) - free(buffer); - buffer = emalloc(curlen = len); - } + if ((len = strlen(str) + 1) > curlen) + *buffer = emalloc(curlen = len); /* * copy the string; at the same time, parse backslashes, * quotes and build the argument list. */ - argc = 1; + argc = 0; inquote = '\0'; - for (p = str, start = t = buffer;; ++p) { + for (p = str, start = t = *buffer;; ++p) { switch(ch = *p) { case '"': case '\'': diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index c39efb5bceb..fd2c2485a47 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: suff.c,v 1.10 1998/07/03 18:51:14 millert Exp $ */ +/* $OpenBSD: suff.c,v 1.11 1998/12/05 00:06:29 espie Exp $ */ /* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94"; #else -static char rcsid[] = "$OpenBSD: suff.c,v 1.10 1998/07/03 18:51:14 millert Exp $"; +static char rcsid[] = "$OpenBSD: suff.c,v 1.11 1998/12/05 00:06:29 espie Exp $"; #endif #endif /* not lint */ @@ -1730,8 +1730,7 @@ SuffFindArchiveDeps(gn, slst) for (i = (sizeof(copy)/sizeof(copy[0]))-1; i >= 0; i--) { char *p1; Var_Set(copy[i], Var_Value(copy[i], mem, &p1), gn); - if (p1) - free(p1); + efree(p1); } @@ -2065,8 +2064,7 @@ sfnd_abort: gn->suffix = (targ == NULL) ? NULL : targ->suff; if (gn->suffix) gn->suffix->refCount++; - if (gn->path != NULL) - free(gn->path); + efree(gn->path); gn->path = estrdup(gn->name); } @@ -2166,8 +2164,7 @@ sfnd_abort: /* * So Dir_MTime doesn't go questing for it... */ - if (gn->path) - free(gn->path); + efree(gn->path); gn->path = estrdup(gn->name); /* diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c index 1549927f920..469896d4871 100644 --- a/usr.bin/make/targ.c +++ b/usr.bin/make/targ.c @@ -1,4 +1,4 @@ -/* $OpenBSD: targ.c,v 1.8 1998/03/30 06:59:38 deraadt Exp $ */ +/* $OpenBSD: targ.c,v 1.9 1998/12/05 00:06:29 espie Exp $ */ /* $NetBSD: targ.c,v 1.11 1997/02/20 16:51:50 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94"; #else -static char *rcsid = "$OpenBSD: targ.c,v 1.8 1998/03/30 06:59:38 deraadt Exp $"; +static char *rcsid = "$OpenBSD: targ.c,v 1.9 1998/12/05 00:06:29 espie Exp $"; #endif #endif /* not lint */ @@ -215,8 +215,7 @@ TargFreeGN (gnp) free(gn->name); - if (gn->path) - free(gn->path); + efree(gn->path); Lst_Destroy(gn->iParents, NOFREE); Lst_Destroy(gn->cohorts, NOFREE); diff --git a/usr.bin/make/util.c b/usr.bin/make/util.c index 4dd028b428c..4c8879748d9 100644 --- a/usr.bin/make/util.c +++ b/usr.bin/make/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.8 1998/06/03 17:00:04 deraadt Exp $ */ +/* $OpenBSD: util.c,v 1.9 1998/12/05 00:06:29 espie Exp $ */ /* $NetBSD: util.c,v 1.10 1996/12/31 17:56:04 christos Exp $ */ /* @@ -6,7 +6,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: util.c,v 1.8 1998/06/03 17:00:04 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: util.c,v 1.9 1998/12/05 00:06:29 espie Exp $"; #endif #include <stdio.h> diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 2e70f46611b..c25c1ec2e07 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,4 +1,4 @@ -/* $OpenBSD: var.c,v 1.9 1998/07/23 18:49:05 deraadt Exp $ */ +/* $OpenBSD: var.c,v 1.10 1998/12/05 00:06:29 espie Exp $ */ /* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */ /* @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -static char rcsid[] = "$OpenBSD: var.c,v 1.9 1998/07/23 18:49:05 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: var.c,v 1.10 1998/12/05 00:06:29 espie Exp $"; #endif #endif /* not lint */ @@ -1236,17 +1236,20 @@ VarModify (str, modProc, datum) Boolean addSpace; /* TRUE if need to add a space to the * buffer before adding the trimmed * word */ - char **av; /* word list [first word does not count] */ + char **av; /* word list */ + char *as; /* word list memory */ int ac, i; buf = Buf_Init (0); addSpace = FALSE; - av = brk_string(str, &ac, FALSE); + av = brk_string(str, &ac, FALSE, &as); - for (i = 1; i < ac; i++) + for (i = 0; i < ac; i++) addSpace = (*modProc)(av[i], addSpace, buf, datum); + free(as); + free(av); Buf_AddByte (buf, '\0'); str = (char *)Buf_GetAll (buf, (int *)NULL); Buf_Destroy (buf, FALSE); @@ -1261,7 +1264,7 @@ VarModify (str, modProc, datum) * uninterpreted) and 2) unescaped $'s that aren't before * the delimiter (expand the variable substitution). * Return the expanded string or NULL if the delimiter was missing - * If pattern is specified, handle escaped ampersants, and replace + * If pattern is specified, handle escaped ampersands, and replace * unescaped ampersands with the lhs of the pattern. * * Results: |