Index: /trunk/src/kmk/Makefile
===================================================================
--- /trunk/src/kmk/Makefile	(revision 24)
+++ /trunk/src/kmk/Makefile	(revision 25)
@@ -1,10 +1,9 @@
 #	@(#)Makefile	5.2 (Berkeley) 12/28/90
-#	$Id$
-# $FreeBSD: src/usr.bin/make/Makefile,v 1.29 2002/10/10 19:27:48 jmallett Exp $
+# $FreeBSD: src/usr.bin/make/Makefile,v 1.13.2.1 2001/05/25 08:33:40 sobomax Exp $
 
 PROG=	make
-CFLAGS+=-I${.CURDIR}
+CFLAGS+= -I${.CURDIR}
 SRCS=	arch.c buf.c compat.c cond.c dir.c for.c hash.c job.c main.c \
-	make.c parse.c str.c suff.c targ.c util.c var.c
+	make.c parse.c str.c suff.c targ.c var.c util.c
 SRCS+=	lstAppend.c lstAtEnd.c lstAtFront.c lstClose.c lstConcat.c \
 	lstDatum.c lstDeQueue.c lstDestroy.c lstDupl.c lstEnQueue.c \
@@ -16,29 +15,3 @@
 NOSHARED?=	YES
 
-CFLAGS+=-DMAKE_VERSION=\"5200209170\"
-.if defined(_UPGRADING)
-CFLAGS+=-D__FBSDID=__RCSID
-.endif
-
-# XXX: kernel currently broken
-# CFLAGS+=-DUSE_KQUEUE
-
-main.o: ${MAKEFILE}
-
-# Set the shell which make(1) uses.  Bourne is the default, but a decent
-# Korn shell works fine, and much faster.  Using the C shell for this
-# will almost certainly break everything, but it's Unix tradition to
-# allow you to shoot yourself in the foot if you want to :-)
-
-MAKE_SHELL?=	sh
-.if ${MAKE_SHELL} == "csh"
-CFLAGS+=	-DDEFSHELL=0
-.elif ${MAKE_SHELL} == "sh"
-CFLAGS+=	-DDEFSHELL=1
-.elif ${MAKE_SHELL} == "ksh"
-CFLAGS+=	-DDEFSHELL=2
-.else
-.error "MAKE_SHELL must be set to one of \"csh\", \"sh\" or \"ksh\"."
-.endif
-
 .include <bsd.prog.mk>
Index: /trunk/src/kmk/Makefile.dist
===================================================================
--- /trunk/src/kmk/Makefile.dist	(revision 24)
+++ /trunk/src/kmk/Makefile.dist	(revision 25)
@@ -1,7 +1,6 @@
-# $FreeBSD: src/usr.bin/make/Makefile.dist,v 1.2 2001/03/01 06:26:32 imp Exp $
 # a very simple makefile...
 pmake:
 	@echo 'make started.'
-	cc -DDEFSHELL=1 -I. -c *.c
+	cc -I. -c *.c
 	cd lst.lib; cc -I.. -c *.c
 	cc *.o lst.lib/*.o -o pmake
Index: /trunk/src/kmk/PSD.doc/stubs
===================================================================
--- /trunk/src/kmk/PSD.doc/stubs	(revision 24)
+++ /trunk/src/kmk/PSD.doc/stubs	(revision 25)
@@ -1,3 +1,3 @@
-.\" $FreeBSD: src/usr.bin/make/PSD.doc/stubs,v 1.1 2000/11/24 10:05:30 ru Exp $
+.\" $FreeBSD: src/usr.bin/make/PSD.doc/stubs,v 1.1.2.1 2000/11/24 10:08:45 ru Exp $
 .\"
 .de Ix
Index: /trunk/src/kmk/PSD.doc/tutorial.ms
===================================================================
--- /trunk/src/kmk/PSD.doc/tutorial.ms	(revision 24)
+++ /trunk/src/kmk/PSD.doc/tutorial.ms	(revision 25)
@@ -36,5 +36,5 @@
 .\"
 .\"	@(#)tutorial.ms	8.1 (Berkeley) 8/18/93
-.\" $FreeBSD: src/usr.bin/make/PSD.doc/tutorial.ms,v 1.12 2002/05/16 02:19:09 trhodes Exp $
+.\" $FreeBSD: src/usr.bin/make/PSD.doc/tutorial.ms,v 1.8.2.2 2000/11/24 10:08:45 ru Exp $
 .\"
 .so stubs
@@ -603,5 +603,5 @@
 .LP
 The value of a variable may be retrieved by enclosing the variable
-name in parentheses or curly braces and preceding the whole thing
+name in parentheses or curly braces and preceeding the whole thing
 with a dollar sign.
 .LP
@@ -1244,5 +1244,5 @@
 and various other information on how PMake was configured.
 .Ix 0 ref configuration
-.Ix 0 ref makefilesystem
+.Ix 0 ref makefile system
 .IP \fB\-i\fP
 .Ix 0 def flags -i
@@ -2401,5 +2401,5 @@
 .CW .h
 suffix is already marked in this way in the system makefile.
-.Ix 0 ref makefilesystem
+.Ix 0 ref makefile system
 E.g. if you have
 .DS
@@ -2641,5 +2641,5 @@
 You are allowed to use any character except
 colon or exclamation point to separate the two strings. This so-called
-delimiter character may be placed in either string by preceding it
+delimiter character may be placed in either string by preceeding it
 with a backslash.
 .IP T
Index: /trunk/src/kmk/arch.c
===================================================================
--- /trunk/src/kmk/arch.c	(revision 24)
+++ /trunk/src/kmk/arch.c	(revision 25)
@@ -35,10 +35,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * @(#)arch.c	8.2 (Berkeley) 1/2/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/arch.c,v 1.32 2002/10/09 03:42:09 jmallett Exp $");
+ */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)arch.c	8.2 (Berkeley) 1/2/94";
+#else
+static const char rcsid[] =
+  "$FreeBSD: src/usr.bin/make/arch.c,v 1.15.2.1 2001/02/13 03:13:57 will Exp $";
+#endif
+#endif /* not lint */
 
 /*-
@@ -114,11 +118,11 @@
 } Arch;
 
-static int ArchFindArchive(void *, void *);
-static void ArchFree(void *);
-static struct ar_hdr *ArchStatMember(char *, char *, Boolean);
-static FILE *ArchFindMember(char *, char *, struct ar_hdr *, char *);
+static int ArchFindArchive __P((ClientData, ClientData));
+static void ArchFree __P((ClientData));
+static struct ar_hdr *ArchStatMember __P((char *, char *, Boolean));
+static FILE *ArchFindMember __P((char *, char *, struct ar_hdr *, char *));
 #if defined(__svr4__) || defined(__SVR4) || defined(__ELF__)
-#define	SVR4ARCHIVES
-static int ArchSVR4Entry(Arch *, char *, size_t, FILE *);
+#define SVR4ARCHIVES
+static int ArchSVR4Entry __P((Arch *, char *, size_t, FILE *));
 #endif
 
@@ -137,5 +141,6 @@
  */
 static void
-ArchFree(void *ap)
+ArchFree(ap)
+    ClientData ap;
 {
     Arch *a = (Arch *) ap;
@@ -147,10 +152,10 @@
 	 entry != NULL;
 	 entry = Hash_EnumNext(&search))
-	free(Hash_GetValue(entry));
+	free((Address) Hash_GetValue (entry));
 
     free(a->name);
     efree(a->fnametab);
     Hash_DeleteTable(&a->members);
-    free(a);
+    free((Address) a);
 }
 
@@ -162,7 +167,5 @@
  *	Parse the archive specification in the given line and find/create
  *	the nodes for the specified archive members, placing their nodes
- *	on the given list, given the pointer to the start of the
- *	specification, a Lst on which to place the nodes, and a context
- *	in which to expand variables.
+ *	on the given list.
  *
  * Results:
@@ -177,7 +180,10 @@
  */
 ReturnStatus
-Arch_ParseArchive (char **linePtr, Lst nodeLst, GNode *ctxt)
-{
-    char            *cp;	    /* Pointer into line */
+Arch_ParseArchive (linePtr, nodeLst, ctxt)
+    char	    **linePtr;      /* Pointer to start of specification */
+    Lst	    	    nodeLst;   	    /* Lst on which to place the nodes */
+    GNode   	    *ctxt;  	    /* Context in which to expand variables */
+{
+    register char   *cp;	    /* Pointer into line */
     GNode	    *gn;     	    /* New node */
     char	    *libName;  	    /* Library-part of specification */
@@ -230,9 +236,9 @@
 	Boolean	doSubst = FALSE; /* TRUE if need to substitute in memName */
 
-	while (*cp != '\0' && *cp != ')' && isspace ((unsigned char) *cp)) {
+	while (*cp != '\0' && *cp != ')' && isspace (*cp)) {
 	    cp++;
 	}
 	memName = cp;
-	while (*cp != '\0' && *cp != ')' && !isspace ((unsigned char) *cp)) {
+	while (*cp != '\0' && *cp != ')' && !isspace (*cp)) {
 	    if (*cp == '$') {
 		/*
@@ -305,8 +311,6 @@
 	     * are just placed at the end of the nodeLst we're returning.
 	     */
-
 	    sz = strlen(memName) + strlen(libName) + 3;
 	    buf = sacrifice = emalloc(sz);
-
 	    snprintf(buf, sz, "%s(%s)", libName, memName);
 
@@ -319,10 +323,10 @@
 		gn = Targ_FindNode(buf, TARG_CREATE);
 
-		if (gn == NULL) {
+		if (gn == NILGNODE) {
 		    free(buf);
 		    return(FAILURE);
 		} else {
 		    gn->type |= OP_ARCHV;
-		    (void)Lst_AtEnd(nodeLst, (void *)gn);
+		    (void)Lst_AtEnd(nodeLst, (ClientData)gn);
 		}
 	    } else if (Arch_ParseArchive(&sacrifice, nodeLst, ctxt)!=SUCCESS) {
@@ -355,5 +359,5 @@
 		free(member);
 		gn = Targ_FindNode (nameBuf, TARG_CREATE);
-		if (gn == NULL) {
+		if (gn == NILGNODE) {
 		    free(nameBuf);
 		    return (FAILURE);
@@ -367,5 +371,5 @@
 		     */
 		    gn->type |= OP_ARCHV;
-		    (void) Lst_AtEnd (nodeLst, (void *)gn);
+		    (void) Lst_AtEnd (nodeLst, (ClientData)gn);
 		}
 	    }
@@ -378,5 +382,5 @@
 	    gn = Targ_FindNode (nameBuf, TARG_CREATE);
 	    free(nameBuf);
-	    if (gn == NULL) {
+	    if (gn == NILGNODE) {
 		return (FAILURE);
 	    } else {
@@ -389,5 +393,5 @@
 		 */
 		gn->type |= OP_ARCHV;
-		(void) Lst_AtEnd (nodeLst, (void *)gn);
+		(void) Lst_AtEnd (nodeLst, (ClientData)gn);
 	    }
 	}
@@ -413,5 +417,5 @@
     do {
 	cp++;
-    } while (*cp != '\0' && isspace ((unsigned char) *cp));
+    } while (*cp != '\0' && isspace (*cp));
 
     *linePtr = cp;
@@ -423,6 +427,5 @@
  * ArchFindArchive --
  *	See if the given archive is the one we are looking for. Called
- *	From ArchStatMember and ArchFindMember via Lst_Find with the
- *	current list element and the name we want.
+ *	From ArchStatMember and ArchFindMember via Lst_Find.
  *
  * Results:
@@ -435,5 +438,7 @@
  */
 static int
-ArchFindArchive (void *ar, void *archName)
+ArchFindArchive (ar, archName)
+    ClientData	  ar;	      	  /* Current list element */
+    ClientData	  archName;  	  /* Name we want */
 {
     return (strcmp ((char *) archName, ((Arch *) ar)->name));
@@ -444,6 +449,5 @@
  * ArchStatMember --
  *	Locate a member of an archive, given the path of the archive and
- *	the path of the desired member, and a boolean representing whether
- *	or not the archive should be hashed (if not already hashed).
+ *	the path of the desired member.
  *
  * Results:
@@ -459,7 +463,12 @@
  */
 static struct ar_hdr *
-ArchStatMember (char *archive, char *member, Boolean hash)
-{
-#define	AR_MAX_NAME_LEN	    (sizeof(arh.ar_name)-1)
+ArchStatMember (archive, member, hash)
+    char	  *archive;   /* Path to the archive */
+    char	  *member;    /* Name of member. If it is a path, only the
+			       * last component is used. */
+    Boolean	  hash;	      /* TRUE if archive should be hashed if not
+    			       * already so. */
+{
+#define AR_MAX_NAME_LEN	    (sizeof(arh.ar_name)-1)
     FILE *	  arch;	      /* Stream to archive */
     int		  size;       /* Size of archive member */
@@ -483,6 +492,6 @@
 	member = cp + 1;
 
-    ln = Lst_Find (archives, (void *) archive, ArchFindArchive);
-    if (ln != NULL) {
+    ln = Lst_Find (archives, (ClientData) archive, ArchFindArchive);
+    if (ln != NILLNODE) {
 	ar = (Arch *) Lst_Datum (ln);
 
@@ -494,5 +503,5 @@
 	    /* Try truncated name */
 	    char copy[AR_MAX_NAME_LEN+1];
-	    size_t len = strlen (member);
+	    int len = strlen (member);
 
 	    if (len > AR_MAX_NAME_LEN) {
@@ -615,9 +624,6 @@
 		memName[elen] = '\0';
 		fseek (arch, -elen, SEEK_CUR);
-		/* XXX Multiple levels may be asked for, make this conditional
-		 * on one, and use DEBUGF.
-		 */
 		if (DEBUG(ARCH) || DEBUG(MAKE)) {
-		    fprintf(stderr, "ArchStat: Extended format entry for %s\n", memName);
+		    printf("ArchStat: Extended format entry for %s\n", memName);
 		}
 	    }
@@ -625,6 +631,6 @@
 
 	    he = Hash_CreateEntry (&ar->members, memName, NULL);
-	    Hash_SetValue (he, (void *)emalloc (sizeof (struct ar_hdr)));
-	    memcpy (Hash_GetValue (he), &arh,
+	    Hash_SetValue (he, (ClientData)emalloc (sizeof (struct ar_hdr)));
+	    memcpy ((Address)Hash_GetValue (he), (Address)&arh,
 		sizeof (struct ar_hdr));
 	}
@@ -634,5 +640,5 @@
     fclose (arch);
 
-    (void) Lst_AtEnd (archives, (void *) ar);
+    (void) Lst_AtEnd (archives, (ClientData) ar);
 
     /*
@@ -652,5 +658,5 @@
     Hash_DeleteTable (&ar->members);
     efree(ar->fnametab);
-    free (ar);
+    free ((Address)ar);
     return (NULL);
 }
@@ -678,8 +684,12 @@
  */
 static int
-ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE *arch)
-{
-#define	ARLONGNAMES1 "//"
-#define	ARLONGNAMES2 "/ARFILENAMES"
+ArchSVR4Entry(ar, name, size, arch)
+	Arch *ar;
+	char *name;
+	size_t size;
+	FILE *arch;
+{
+#define ARLONGNAMES1 "//"
+#define ARLONGNAMES2 "/ARFILENAMES"
     size_t entry;
     char *ptr, *eptr;
@@ -689,5 +699,7 @@
 
 	if (ar->fnametab != NULL) {
-	    DEBUGF(ARCH, ("Attempted to redefine an SVR4 name table\n"));
+	    if (DEBUG(ARCH)) {
+		printf("Attempted to redefine an SVR4 name table\n");
+	    }
 	    return -1;
 	}
@@ -701,5 +713,7 @@
 
 	if (fread(ar->fnametab, size, 1, arch) != 1) {
-	    DEBUGF(ARCH, ("Reading an SVR4 name table failed\n"));
+	    if (DEBUG(ARCH)) {
+		printf("Reading an SVR4 name table failed\n");
+	    }
 	    return -1;
 	}
@@ -718,5 +732,7 @@
 		break;
 	    }
-	DEBUGF(ARCH, ("Found svr4 archive name table with %zu entries\n", entry));
+	if (DEBUG(ARCH)) {
+	    printf("Found svr4 archive name table with %d entries\n", entry);
+	}
 	return 0;
     }
@@ -727,14 +743,20 @@
     entry = (size_t) strtol(&name[1], &eptr, 0);
     if ((*eptr != ' ' && *eptr != '\0') || eptr == &name[1]) {
-	DEBUGF(ARCH, ("Could not parse SVR4 name %s\n", name));
+	if (DEBUG(ARCH)) {
+	    printf("Could not parse SVR4 name %s\n", name);
+	}
 	return 2;
     }
     if (entry >= ar->fnamesize) {
-	DEBUGF(ARCH, ("SVR4 entry offset %s is greater than %zu\n",
-	       name, ar->fnamesize));
+	if (DEBUG(ARCH)) {
+	    printf("SVR4 entry offset %s is greater than %d\n",
+		   name, ar->fnamesize);
+	}
 	return 2;
     }
 
-    DEBUGF(ARCH, ("Replaced %s with %s\n", name, &ar->fnametab[entry]));
+    if (DEBUG(ARCH)) {
+	printf("Replaced %s with %s\n", name, &ar->fnametab[entry]);
+    }
 
     (void) strncpy(name, &ar->fnametab[entry], MAXPATHLEN);
@@ -750,6 +772,5 @@
  *	Locate a member of an archive, given the path of the archive and
  *	the path of the desired member. If the archive is to be modified,
- *	the mode should be "r+", if not, it should be "r".  arhPtr is a
- *	poitner to the header structure to fill in.
+ *	the mode should be "r+", if not, it should be "r".
  *
  * Results:
@@ -764,5 +785,10 @@
  */
 static FILE *
-ArchFindMember (char *archive, char *member, struct ar_hdr *arhPtr, char *mode)
+ArchFindMember (archive, member, arhPtr, mode)
+    char	  *archive;   /* Path to the archive */
+    char	  *member;    /* Name of member. If it is a path, only the
+			       * last component is used. */
+    struct ar_hdr *arhPtr;    /* Pointer to header structure to be filled in */
+    char	  *mode;      /* The mode for opening the stream */
 {
     FILE *	  arch;	      /* Stream to archive */
@@ -770,5 +796,5 @@
     char	  *cp;	      /* Useful character pointer */
     char	  magic[SARMAG];
-    size_t	  len, tlen;
+    int		  len, tlen;
 
     arch = fopen (archive, mode);
@@ -853,7 +879,4 @@
 		}
 		ename[elen] = '\0';
-		/*
-		 * XXX choose one.
-		 */
 		if (DEBUG(ARCH) || DEBUG(MAKE)) {
 		    printf("ArchFind: Extended format entry for %s\n", ename);
@@ -907,5 +930,6 @@
  */
 void
-Arch_Touch (GNode *gn)
+Arch_Touch (gn)
+    GNode	  *gn;	  /* Node of member to touch */
 {
     FILE *	  arch;	  /* Stream open to archive, positioned properly */
@@ -942,5 +966,6 @@
  */
 void
-Arch_TouchLib (GNode *gn)
+Arch_TouchLib (gn)
+    GNode	    *gn;      	/* The node of the library to touch */
 {
 #ifdef RANLIBMAG
@@ -965,6 +990,5 @@
  *-----------------------------------------------------------------------
  * Arch_MTime --
- *	Return the modification time of a member of an archive, given its
- *	name.
+ *	Return the modification time of a member of an archive.
  *
  * Results:
@@ -978,5 +1002,6 @@
  */
 int
-Arch_MTime(GNode *gn)
+Arch_MTime (gn)
+    GNode	  *gn;	      /* Node describing archive member */
 {
     struct ar_hdr *arhPtr;    /* Header of desired member */
@@ -1015,5 +1040,6 @@
  */
 int
-Arch_MemMTime (GNode *gn)
+Arch_MemMTime (gn)
+    GNode   	  *gn;
 {
     LstNode 	  ln;
@@ -1026,5 +1052,5 @@
 	return (0);
     }
-    while ((ln = Lst_Next (gn->parents)) != NULL) {
+    while ((ln = Lst_Next (gn->parents)) != NILLNODE) {
 	pgn = (GNode *) Lst_Datum (ln);
 
@@ -1062,5 +1088,5 @@
  *-----------------------------------------------------------------------
  * Arch_FindLib --
- *	Search for a named library along the given search path.
+ *	Search for a library along the given search path.
  *
  * Results:
@@ -1080,5 +1106,7 @@
  */
 void
-Arch_FindLib (GNode *gn, Lst path)
+Arch_FindLib (gn, path)
+    GNode	    *gn;	      /* Node of library to find */
+    Lst	    	    path;	      /* Search path */
 {
     char	    *libName;   /* file name for archive */
@@ -1104,6 +1132,5 @@
  * Arch_LibOODate --
  *	Decide if a node with the OP_LIB attribute is out-of-date. Called
- *	from Make_OODate to make its life easier, with the library's
- *	graph node.
+ *	from Make_OODate to make its life easier.
  *
  *	There are several ways for a library to be out-of-date that are
@@ -1138,5 +1165,6 @@
  */
 Boolean
-Arch_LibOODate (GNode *gn)
+Arch_LibOODate (gn)
+    GNode   	  *gn;  	/* The library's graph node */
 {
     Boolean 	  oodate;
@@ -1156,5 +1184,4 @@
 	    modTimeTOC = (int) strtol(arhPtr->ar_date, NULL, 10);
 
-	    /* XXX choose one. */
 	    if (DEBUG(ARCH) || DEBUG(MAKE)) {
 		printf("%s modified %s...", RANLIBMAG, Targ_FmtTime(modTimeTOC));
@@ -1191,5 +1218,5 @@
  */
 void
-Arch_Init (void)
+Arch_Init ()
 {
     archives = Lst_Init (FALSE);
@@ -1212,5 +1239,5 @@
  */
 void
-Arch_End (void)
+Arch_End ()
 {
     Lst_Destroy(archives, ArchFree);
Index: /trunk/src/kmk/buf.c
===================================================================
--- /trunk/src/kmk/buf.c	(revision 24)
+++ /trunk/src/kmk/buf.c	(revision 25)
@@ -1,5 +1,4 @@
 /*
- * Copyright (c) 1988, 1989, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
  * Copyright (c) 1988, 1989 by Adam de Boor
  * Copyright (c) 1989 by Berkeley Softworks
@@ -36,10 +35,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * @(#)buf.c	8.1 (Berkeley) 6/6/93
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/buf.c,v 1.18 2002/10/09 03:42:09 jmallett Exp $");
+ */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)buf.c	8.1 (Berkeley) 6/6/93";
+#else
+static const char rcsid[] =
+  "$FreeBSD: src/usr.bin/make/buf.c,v 1.11 1999/09/11 13:08:01 hoek Exp $";
+#endif
+#endif /* not lint */
 
 /*-
@@ -53,5 +56,5 @@
 
 #ifndef max
-#define	max(a,b)  ((a) > (b) ? (a) : (b))
+#define max(a,b)  ((a) > (b) ? (a) : (b))
 #endif
 
@@ -63,5 +66,5 @@
  *	buffer in case it holds a string.
  */
-#define	BufExpand(bp,nb) \
+#define BufExpand(bp,nb) \
  	if (bp->left < (nb)+1) {\
 	    int newSize = (bp)->size + max((nb)+1,BUF_ADD_INC); \
@@ -75,7 +78,7 @@
 	}
 
-#define	BUF_DEF_SIZE	256 	/* Default buffer size */
-#define	BUF_ADD_INC	256 	/* Expansion increment when Adding */
-#define	BUF_UNGET_INC	16  	/* Expansion increment when Ungetting */
+#define BUF_DEF_SIZE	256 	/* Default buffer size */
+#define BUF_ADD_INC	256 	/* Expansion increment when Adding */
+#define BUF_UNGET_INC	16  	/* Expansion increment when Ungetting */
 
 /*-
@@ -93,8 +96,11 @@
  */
 void
-Buf_OvAddByte (Buffer bp, int byte)
-{
+Buf_OvAddByte (bp, byte)
+    register Buffer bp;
+    int    byte;
+{
+    int nbytes = 1;
     bp->left = 0;
-    BufExpand (bp, 1);
+    BufExpand (bp, nbytes);
 
     *bp->inPtr++ = byte;
@@ -122,5 +128,8 @@
  */
 void
-Buf_AddBytes (Buffer bp, int numBytes, const Byte *bytesPtr)
+Buf_AddBytes (bp, numBytes, bytesPtr)
+    register Buffer bp;
+    int	    numBytes;
+    const Byte *bytesPtr;
 {
 
@@ -152,5 +161,7 @@
  */
 void
-Buf_UngetByte (Buffer bp, int byte)
+Buf_UngetByte (bp, byte)
+    register Buffer bp;
+    int    byte;
 {
 
@@ -201,5 +212,8 @@
  */
 void
-Buf_UngetBytes (Buffer bp, int numBytes, Byte *bytesPtr)
+Buf_UngetBytes (bp, numBytes, bytesPtr)
+    register Buffer bp;
+    int	    numBytes;
+    Byte    *bytesPtr;
 {
 
@@ -244,5 +258,6 @@
  */
 int
-Buf_GetByte (Buffer bp)
+Buf_GetByte (bp)
+    register Buffer bp;
 {
     int	    res;
@@ -277,5 +292,8 @@
  */
 int
-Buf_GetBytes (Buffer bp, int numBytes, Byte *bytesPtr)
+Buf_GetBytes (bp, numBytes, bytesPtr)
+    register Buffer bp;
+    int	    numBytes;
+    Byte    *bytesPtr;
 {
 
@@ -309,5 +327,7 @@
  */
 Byte *
-Buf_GetAll (Buffer bp, int *numBytesPtr)
+Buf_GetAll (bp, numBytesPtr)
+    register Buffer bp;
+    int	    *numBytesPtr;
 {
 
@@ -334,5 +354,7 @@
  */
 void
-Buf_Discard (Buffer bp, int numBytes)
+Buf_Discard (bp, numBytes)
+    register Buffer bp;
+    int	    numBytes;
 {
 
@@ -362,5 +384,6 @@
  */
 int
-Buf_Size (Buffer buf)
+Buf_Size (buf)
+    Buffer  buf;
 {
     return (buf->inPtr - buf->outPtr);
@@ -384,5 +407,6 @@
  */
 Buffer
-Buf_Init (int size)
+Buf_Init (size)
+    int	    size; 	/* Initial size for the buffer */
 {
     Buffer bp;	  	/* New Buffer */
@@ -405,5 +429,5 @@
  *-----------------------------------------------------------------------
  * Buf_Destroy --
- *	Destroy a buffer, and optionally free its data, too.
+ *	Nuke a buffer and all its resources.
  *
  * Results:
@@ -416,5 +440,7 @@
  */
 void
-Buf_Destroy (Buffer buf, Boolean freeData)
+Buf_Destroy (buf, freeData)
+    Buffer  buf;  	/* Buffer to destroy */
+    Boolean freeData;	/* TRUE if the data should be destroyed as well */
 {
 
@@ -441,5 +467,7 @@
  */
 void
-Buf_ReplaceLastByte (Buffer buf, int byte)
+Buf_ReplaceLastByte (buf, byte)
+    Buffer buf;	/* buffer to augment */
+    int byte;	/* byte to be written */
 {
     if (buf->inPtr == buf->outPtr)
Index: /trunk/src/kmk/buf.h
===================================================================
--- /trunk/src/kmk/buf.h	(revision 24)
+++ /trunk/src/kmk/buf.h	(revision 25)
@@ -1,5 +1,4 @@
 /*
- * Copyright (c) 1988, 1989, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
  * Copyright (c) 1988, 1989 by Adam de Boor
  * Copyright (c) 1989 by Berkeley Softworks
@@ -37,6 +36,6 @@
  * SUCH DAMAGE.
  *
- *	@(#)buf.h	8.2 (Berkeley) 4/28/95
- * $FreeBSD: src/usr.bin/make/buf.h,v 1.12 2002/09/17 21:29:06 jmallett Exp $
+ *	from: @(#)buf.h	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/buf.h,v 1.9 1999/08/28 01:03:26 peter Exp $
  */
 
@@ -47,5 +46,5 @@
 
 #ifndef _BUF_H
-#define	_BUF_H
+#define _BUF_H
 
 #include    "sprite.h"
@@ -66,18 +65,18 @@
 		(*(bp)->inPtr++ = (byte), *(bp)->inPtr = 0), 1)
 
-#define	BUF_ERROR 256
+#define BUF_ERROR 256
 
-void Buf_OvAddByte(Buffer, int);
-void Buf_AddBytes(Buffer, int, const Byte *);
-void Buf_UngetByte(Buffer, int);
-void Buf_UngetBytes(Buffer, int, Byte *);
-int Buf_GetByte(Buffer);
-int Buf_GetBytes(Buffer, int, Byte *);
-Byte *Buf_GetAll(Buffer, int *);
-void Buf_Discard(Buffer, int);
-int Buf_Size(Buffer);
-Buffer Buf_Init(int);
-void Buf_Destroy(Buffer, Boolean);
-void Buf_ReplaceLastByte(Buffer, int);
+void Buf_OvAddByte __P((Buffer, int));
+void Buf_AddBytes __P((Buffer, int, const Byte *));
+void Buf_UngetByte __P((Buffer, int));
+void Buf_UngetBytes __P((Buffer, int, Byte *));
+int Buf_GetByte __P((Buffer));
+int Buf_GetBytes __P((Buffer, int, Byte *));
+Byte *Buf_GetAll __P((Buffer, int *));
+void Buf_Discard __P((Buffer, int));
+int Buf_Size __P((Buffer));
+Buffer Buf_Init __P((int));
+void Buf_Destroy __P((Buffer, Boolean));
+void Buf_ReplaceLastByte __P((Buffer, int));
 
 #endif /* _BUF_H */
Index: /trunk/src/kmk/compat.c
===================================================================
--- /trunk/src/kmk/compat.c	(revision 24)
+++ /trunk/src/kmk/compat.c	(revision 25)
@@ -1,5 +1,4 @@
 /*
- * Copyright (c) 1988, 1989, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
  * Copyright (c) 1988, 1989 by Adam de Boor
  * Copyright (c) 1989 by Berkeley Softworks
@@ -36,10 +35,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * @(#)compat.c	8.2 (Berkeley) 3/19/94
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/compat.c,v 1.34 2002/10/09 03:42:09 jmallett Exp $");
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)compat.c	8.2 (Berkeley) 3/19/94";
+#else
+static const char rcsid[] =
+  "$FreeBSD: src/usr.bin/make/compat.c,v 1.16.2.2 2000/07/01 12:24:21 ps Exp $";
+#endif
+#endif /* not lint */
 
 /*-
@@ -63,5 +66,4 @@
 #include    <errno.h>
 #include    <signal.h>
-#include    <unistd.h>
 #include    "make.h"
 #include    "hash.h"
@@ -78,10 +80,9 @@
 static char 	    meta[256];
 
-static GNode	    *curTarg = NULL;
+static GNode	    *curTarg = NILGNODE;
 static GNode	    *ENDNode;
-static void CompatInterrupt(int);
-static int CompatRunCommand(void *, void *);
-static int CompatMake(void *, void *);
-static int shellneed(char *);
+static void CompatInterrupt __P((int));
+static int CompatRunCommand __P((ClientData, ClientData));
+static int CompatMake __P((ClientData, ClientData));
 
 static char *sh_builtin[] = { 
@@ -105,9 +106,10 @@
  */
 static void
-CompatInterrupt (int signo)
+CompatInterrupt (signo)
+    int	    signo;
 {
     GNode   *gn;
 
-    if ((curTarg != NULL) && !Targ_Precious (curTarg)) {
+    if ((curTarg != NILGNODE) && !Targ_Precious (curTarg)) {
 	char	  *p1;
 	char 	  *file = Var_Value (TARGET, curTarg, &p1);
@@ -123,6 +125,6 @@
 	if (signo == SIGINT) {
 	    gn = Targ_FindNode(".INTERRUPT", TARG_NOCREATE);
-	    if (gn != NULL) {
-		Lst_ForEach(gn->commands, CompatRunCommand, (void *)gn);
+	    if (gn != NILGNODE) {
+		Lst_ForEach(gn->commands, CompatRunCommand, (ClientData)gn);
 	    }
 	}
@@ -150,5 +152,6 @@
  */
 static int
-shellneed (char *cmd)
+shellneed (cmd)
+	char *cmd;
 {
 	char **av, **p;
@@ -168,5 +171,4 @@
  *	Execute the next command for a target. If the command returns an
  *	error, the node's made field is set to ERROR and creation stops.
- *	The node from which the command came is also given.
  *
  * Results:
@@ -179,8 +181,10 @@
  */
 static int
-CompatRunCommand (void *cmdp, void *gnp)
+CompatRunCommand (cmdp, gnp)
+    ClientData    cmdp;	    	/* Command to execute */
+    ClientData    gnp;    	/* Node from which the command came */
 {
     char    	  *cmdStart;	/* Start of expanded command */
-    char	  *cp;
+    register char *cp;
     Boolean 	  silent,   	/* Don't print command */
 		  errCheck; 	/* Check errors */
@@ -188,9 +192,11 @@
     int	    	  status;   	/* Description of child's death */
     int	    	  cpid;	    	/* Child actually found */
-    ReturnStatus  rstat;	/* Status of fork */
+    ReturnStatus  stat;	    	/* Status of fork */
     LstNode 	  cmdNode;  	/* Node where current command is located */
     char    	  **av;	    	/* Argument vector for thing to exec */
     int	    	  argc;	    	/* Number of arguments in av or 0 if not
 				 * dynamically allocated */
+    Boolean 	  local;    	/* TRUE if command should be executed
+				 * locally */
     int		  internal;	/* Various values.. */
     char	  *cmd = (char *) cmdp;
@@ -208,5 +214,5 @@
     errCheck = !(gn->type & OP_IGNORE);
 
-    cmdNode = Lst_Member (gn->commands, (void *)cmd);
+    cmdNode = Lst_Member (gn->commands, (ClientData)cmd);
     cmdStart = Var_Subst (NULL, cmd, gn, FALSE);
 
@@ -225,8 +231,8 @@
 	cmd = cmdStart;
     }
-    Lst_Replace (cmdNode, (void *)cmdStart);
+    Lst_Replace (cmdNode, (ClientData)cmdStart);
 
     if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) {
-	(void)Lst_AtEnd(ENDNode->commands, (void *)cmdStart);
+	(void)Lst_AtEnd(ENDNode->commands, (ClientData)cmdStart);
 	return(0);
     } else if (strcmp(cmdStart, "...") == 0) {
@@ -315,4 +321,6 @@
     }
 
+    local = TRUE;
+
     /*
      * Fork and execute the single command. If the fork fails, we abort.
@@ -323,9 +331,13 @@
     }
     if (cpid == 0) {
-	execvp(av[0], av);
-	(void) write (STDERR_FILENO, av[0], strlen (av[0]));
-	(void) write (STDERR_FILENO, ":", 1);
-	(void) write (STDERR_FILENO, strerror(errno), strlen(strerror(errno)));
-	(void) write (STDERR_FILENO, "\n", 1);
+	if (local) {
+	    execvp(av[0], av);
+	    (void) write (2, av[0], strlen (av[0]));
+	    (void) write (2, ":", 1);
+	    (void) write (2, strerror(errno), strlen(strerror(errno)));
+	    (void) write (2, "\n", 1);
+	} else {
+	    (void)execv(av[0], av);
+	}
 	exit(1);
     }
@@ -347,11 +359,11 @@
     while (1) {
 
-	while ((rstat = wait(&reason)) != cpid) {
-	    if (rstat == -1 && errno != EINTR) {
+	while ((stat = wait(&reason)) != cpid) {
+	    if (stat == -1 && errno != EINTR) {
 		break;
 	    }
 	}
 
-	if (rstat > -1) {
+	if (stat > -1) {
 	    if (WIFSTOPPED(reason)) {
 		status = WSTOPSIG(reason);		/* stopped */
@@ -388,5 +400,5 @@
 	    break;
 	} else {
-	    Fatal ("error in wait: %d", rstat);
+	    Fatal ("error in wait: %d", stat);
 	    /*NOTREACHED*/
 	}
@@ -400,5 +412,5 @@
  *-----------------------------------------------------------------------
  * CompatMake --
- *	Make a target, given the parent, to abort if necessary.
+ *	Make a target.
  *
  * Results:
@@ -411,5 +423,7 @@
  */
 static int
-CompatMake (void *gnp, void *pgnp)
+CompatMake (gnp, pgnp)
+    ClientData	gnp;	    /* The node to make */
+    ClientData  pgnp;	    /* Parent to abort if necessary */
 {
     GNode *gn = (GNode *) gnp;
@@ -429,5 +443,5 @@
 	gn->made = BEINGMADE;
 	Suff_FindDeps (gn);
-	Lst_ForEach (gn->children, CompatMake, (void *)gn);
+	Lst_ForEach (gn->children, CompatMake, (ClientData)gn);
 	if (!gn->make) {
 	    gn->made = ABORTED;
@@ -436,5 +450,5 @@
 	}
 
-	if (Lst_Member (gn->iParents, pgn) != NULL) {
+	if (Lst_Member (gn->iParents, pgn) != NILLNODE) {
 	    char *p1;
 	    Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
@@ -448,11 +462,15 @@
 	 * Make_OODate function.
 	 */
-	DEBUGF(MAKE, ("Examining %s...", gn->name));
+	if (DEBUG(MAKE)) {
+	    printf("Examining %s...", gn->name);
+	}
 	if (! Make_OODate(gn)) {
 	    gn->made = UPTODATE;
-	    DEBUGF(MAKE, ("up-to-date.\n"));
+	    if (DEBUG(MAKE)) {
+		printf("up-to-date.\n");
+	    }
 	    return (0);
-	} else {
-	    DEBUGF(MAKE, ("out-of-date.\n"));
+	} else if (DEBUG(MAKE)) {
+	    printf("out-of-date.\n");
 	}
 
@@ -490,6 +508,6 @@
 	    if (!touchFlag) {
 		curTarg = gn;
-		Lst_ForEach (gn->commands, CompatRunCommand, (void *)gn);
-		curTarg = NULL;
+		Lst_ForEach (gn->commands, CompatRunCommand, (ClientData)gn);
+		curTarg = NILGNODE;
 	    } else {
 		Job_Touch (gn, gn->type & OP_SILENT);
@@ -561,5 +579,7 @@
 	    if (gn->cmtime > gn->mtime)
 		gn->mtime = gn->cmtime;
-	    DEBUGF(MAKE, ("update time: %s\n", Targ_FmtTime(gn->mtime)));
+	    if (DEBUG(MAKE)) {
+		printf("update time: %s\n", Targ_FmtTime(gn->mtime));
+	    }
 #endif
 	    if (!(gn->type & OP_EXEC)) {
@@ -583,5 +603,5 @@
 	pgn->make = FALSE;
     } else {
-	if (Lst_Member (gn->iParents, pgn) != NULL) {
+	if (Lst_Member (gn->iParents, pgn) != NILLNODE) {
 	    char *p1;
 	    Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
@@ -617,5 +637,5 @@
  *-----------------------------------------------------------------------
  * Compat_Run --
- *	Start making again, given a list of target nodes.
+ *	Initialize this mode and start making.
  *
  * Results:
@@ -628,5 +648,6 @@
  */
 void
-Compat_Run(Lst targs)
+Compat_Run(targs)
+    Lst	    	  targs;    /* List of target nodes to re-create */
 {
     char    	  *cp;	    /* Pointer to string of shell meta-characters */
@@ -662,6 +683,6 @@
     if (!queryFlag) {
 	gn = Targ_FindNode(".BEGIN", TARG_NOCREATE);
-	if (gn != NULL) {
-	    Lst_ForEach(gn->commands, CompatRunCommand, (void *)gn);
+	if (gn != NILGNODE) {
+	    Lst_ForEach(gn->commands, CompatRunCommand, (ClientData)gn);
             if (gn->made == ERROR) {
                 printf("\n\nStop.\n");
@@ -698,5 +719,5 @@
      */
     if (errors == 0) {
-	Lst_ForEach(ENDNode->commands, CompatRunCommand, (void *)gn);
+	Lst_ForEach(ENDNode->commands, CompatRunCommand, (ClientData)gn);
     }
 }
Index: /trunk/src/kmk/cond.c
===================================================================
--- /trunk/src/kmk/cond.c	(revision 24)
+++ /trunk/src/kmk/cond.c	(revision 25)
@@ -1,5 +1,4 @@
 /*
- * Copyright (c) 1988, 1989, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
  * Copyright (c) 1988, 1989 by Adam de Boor
  * Copyright (c) 1989 by Berkeley Softworks
@@ -36,10 +35,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * @(#)cond.c	8.2 (Berkeley) 1/2/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/cond.c,v 1.24 2002/10/09 03:42:09 jmallett Exp $");
+ */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)cond.c	8.2 (Berkeley) 1/2/94";
+#else
+static const char rcsid[] =
+  "$FreeBSD: src/usr.bin/make/cond.c,v 1.12 1999/09/11 13:08:01 hoek Exp $";
+#endif
+#endif /* not lint */
 
 /*-
@@ -97,16 +100,16 @@
  * last two fields are stored in condInvert and condDefProc, respectively.
  */
-static void CondPushBack(Token);
-static int CondGetArg(char **, char **, char *, Boolean);
-static Boolean CondDoDefined(int, char *);
-static int CondStrMatch(void *, void *);
-static Boolean CondDoMake(int, char *);
-static Boolean CondDoExists(int, char *);
-static Boolean CondDoTarget(int, char *);
-static char * CondCvtArg(char *, double *);
-static Token CondToken(Boolean);
-static Token CondT(Boolean);
-static Token CondF(Boolean);
-static Token CondE(Boolean);
+static void CondPushBack __P((Token));
+static int CondGetArg __P((char **, char **, char *, Boolean));
+static Boolean CondDoDefined __P((int, char *));
+static int CondStrMatch __P((ClientData, ClientData));
+static Boolean CondDoMake __P((int, char *));
+static Boolean CondDoExists __P((int, char *));
+static Boolean CondDoTarget __P((int, char *));
+static char * CondCvtArg __P((char *, double *));
+static Token CondToken __P((Boolean));
+static Token CondT __P((Boolean));
+static Token CondF __P((Boolean));
+static Token CondE __P((Boolean));
 
 static struct If {
@@ -114,5 +117,5 @@
     int		formlen;      /* Length of form */
     Boolean	doNot;	      /* TRUE if default function should be negated */
-    Boolean	(*defProc)(int, char *); /* Default function to apply */
+    Boolean	(*defProc) __P((int, char *)); /* Default function to apply */
 } ifs[] = {
     { "ifdef",	  5,	  FALSE,  CondDoDefined },
@@ -126,5 +129,5 @@
 static Boolean	  condInvert;	    	/* Invert the default function */
 static Boolean	  (*condDefProc)	/* Default function to apply */
-(int, char *);
+		    __P((int, char *));
 static char 	  *condExpr;	    	/* The expression to parse */
 static Token	  condPushBack=None;	/* Single push-back token used in
@@ -154,5 +157,6 @@
  */
 static void
-CondPushBack (Token t)
+CondPushBack (t)
+    Token   	  t;	/* Token to push back into the "stream" */
 {
     condPushBack = t;
@@ -163,6 +167,5 @@
  *-----------------------------------------------------------------------
  * CondGetArg --
- *	Find the argument of a built-in function.  parens is set to TRUE
- *	if the arguments are bounded by parens.
+ *	Find the argument of a built-in function.
  *
  * Results:
@@ -176,9 +179,13 @@
  */
 static int
-CondGetArg (char **linePtr, char **argPtr, char *func, Boolean parens)
-{
-    char	  *cp;
+CondGetArg (linePtr, argPtr, func, parens)
+    char    	  **linePtr;
+    char    	  **argPtr;
+    char    	  *func;
+    Boolean 	  parens;   	/* TRUE if arg should be bounded by parens */
+{
+    register char *cp;
     int	    	  argLen;
-    Buffer	  buf;
+    register Buffer buf;
 
     cp = *linePtr;
@@ -275,5 +282,7 @@
  */
 static Boolean
-CondDoDefined (int argLen, char *arg)
+CondDoDefined (argLen, arg)
+    int	    argLen;
+    char    *arg;
 {
     char    savec = arg[argLen];
@@ -308,5 +317,7 @@
  */
 static int
-CondStrMatch(void *string, void *pattern)
+CondStrMatch(string, pattern)
+    ClientData    string;
+    ClientData    pattern;
 {
     return(!Str_Match((char *) string,(char *) pattern));
@@ -328,5 +339,7 @@
  */
 static Boolean
-CondDoMake (int argLen, char *arg)
+CondDoMake (argLen, arg)
+    int	    argLen;
+    char    *arg;
 {
     char    savec = arg[argLen];
@@ -334,5 +347,5 @@
 
     arg[argLen] = '\0';
-    if (Lst_Find (create, (void *)arg, CondStrMatch) == NULL) {
+    if (Lst_Find (create, (ClientData)arg, CondStrMatch) == NILLNODE) {
 	result = FALSE;
     } else {
@@ -358,5 +371,7 @@
  */
 static Boolean
-CondDoExists (int argLen, char *arg)
+CondDoExists (argLen, arg)
+    int	    argLen;
+    char    *arg;
 {
     char    savec = arg[argLen];
@@ -391,5 +406,7 @@
  */
 static Boolean
-CondDoTarget (int argLen, char *arg)
+CondDoTarget (argLen, arg)
+    int	    argLen;
+    char    *arg;
 {
     char    savec = arg[argLen];
@@ -399,5 +416,5 @@
     arg[argLen] = '\0';
     gn = Targ_FindNode(arg, TARG_NOCREATE);
-    if ((gn != NULL) && !OP_NOP(gn->type)) {
+    if ((gn != NILGNODE) && !OP_NOP(gn->type)) {
 	result = TRUE;
     } else {
@@ -430,8 +447,10 @@
  */
 static char *
-CondCvtArg(char *str, double *value)
+CondCvtArg(str, value)
+    register char    	*str;
+    double		*value;
 {
     if ((*str == '0') && (str[1] == 'x')) {
-	long i;
+	register long i;
 
 	for (str += 2, i = 0; ; str++) {
@@ -470,5 +489,6 @@
  */
 static Token
-CondToken(Boolean doEval)
+CondToken(doEval)
+    Boolean doEval;
 {
     Token	  t;
@@ -649,6 +669,8 @@
 		    Buf_Destroy(buf, FALSE);
 
-		    DEBUGF(COND, ("lhs = \"%s\", rhs = \"%s\", op = %.2s\n",
-			   lhs, string, op));
+		    if (DEBUG(COND)) {
+			printf("lhs = \"%s\", rhs = \"%s\", op = %.2s\n",
+			       lhs, string, op);
+		    }
 		    /*
 		     * Null-terminate rhs and perform the comparison.
@@ -697,5 +719,5 @@
 		    } else {
 			char *c = CondCvtArg(rhs, &right);
-			if (*c != '\0' && !isspace((unsigned char) *c))
+			if (*c != '\0' && !isspace(*c))
 			    goto do_string_compare;
 			if (rhs == condExpr) {
@@ -710,6 +732,8 @@
 		    }
 
-		    DEBUGF(COND, ("left = %f, right = %f, op = %.2s\n", left,
-			   right, op));
+		    if (DEBUG(COND)) {
+			printf("left = %f, right = %f, op = %.2s\n", left,
+			       right, op);
+		    }
 		    switch(op[0]) {
 		    case '!':
@@ -743,6 +767,4 @@
 			}
 			break;
-		    default:
-			break;
 		    }
 		}
@@ -753,5 +775,5 @@
 	    }
 	    default: {
-		Boolean (*evalProc)(int, char *);
+		Boolean (*evalProc) __P((int, char *));
 		Boolean invert = FALSE;
 		char	*arg;
@@ -906,5 +928,6 @@
  */
 static Token
-CondT(Boolean doEval)
+CondT(doEval)
+    Boolean doEval;
 {
     Token   t;
@@ -955,5 +978,6 @@
  */
 static Token
-CondF(Boolean doEval)
+CondF(doEval)
+    Boolean doEval;
 {
     Token   l, o;
@@ -1002,5 +1026,6 @@
  */
 static Token
-CondE(Boolean doEval)
+CondE(doEval)
+    Boolean doEval;
 {
     Token   l, o;
@@ -1057,5 +1082,6 @@
  */
 int
-Cond_Eval (char *line)
+Cond_Eval (line)
+    char    	    *line;    /* Line to parse */
 {
     struct If	    *ifp;
@@ -1238,5 +1264,5 @@
  */
 void
-Cond_End(void)
+Cond_End()
 {
     if (condTop != MAXIF) {
Index: /trunk/src/kmk/config.h
===================================================================
--- /trunk/src/kmk/config.h	(revision 24)
+++ /trunk/src/kmk/config.h	(revision 25)
@@ -1,5 +1,4 @@
 /*
- * Copyright (c) 1988, 1989, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
  * Copyright (c) 1988, 1989 by Adam de Boor
  * Copyright (c) 1989 by Berkeley Softworks
@@ -37,7 +36,9 @@
  * SUCH DAMAGE.
  *
- *	@(#)config.h	8.2 (Berkeley) 4/28/95
- * $FreeBSD: src/usr.bin/make/config.h,v 1.12 2002/09/17 21:29:06 jmallett Exp $
+ *	from: @(#)config.h	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/config.h,v 1.9 1999/09/10 20:51:59 julian Exp $
  */
+
+#define	DEFSHELL	1			/* Bourne shell */
 
 /*
@@ -50,6 +51,6 @@
  *	to 0, nothing will ever happen...
  */
-#define	DEFMAXJOBS	4
-#define	DEFMAXLOCAL	1
+#define DEFMAXJOBS	4
+#define DEFMAXLOCAL	1
 
 /*
@@ -62,6 +63,6 @@
  *	See suff.c for more details.
  */
-#define	INCLUDES
-#define	LIBRARIES
+#define INCLUDES
+#define LIBRARIES
 
 /*
@@ -90,5 +91,5 @@
  *	- Allow empty command lines if starting with tab.
  */
-#define	POSIX
+#define POSIX
 
 /*
@@ -98,6 +99,6 @@
  *	Recognize system V like ${VAR:x=y} variable substitutions
  */
-#define	SYSVINCLUDE
-#define	SYSVVARSUB
+#define SYSVINCLUDE
+#define SYSVVARSUB
 
 /*
@@ -108,5 +109,5 @@
  *				# of ${VAR}
  */
-#define	SUNSHCMD
+#define SUNSHCMD
 
 #if !defined(__svr4__) && !defined(__SVR4) && !defined(__ELF__)
Index: /trunk/src/kmk/dir.c
===================================================================
--- /trunk/src/kmk/dir.c	(revision 24)
+++ /trunk/src/kmk/dir.c	(revision 25)
@@ -1,5 +1,4 @@
 /*
- * Copyright (c) 1988, 1989, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
  * Copyright (c) 1988, 1989 by Adam de Boor
  * Copyright (c) 1989 by Berkeley Softworks
@@ -36,10 +35,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * @(#)dir.c	8.2 (Berkeley) 1/2/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/dir.c,v 1.30 2002/10/09 03:42:10 jmallett Exp $");
+ */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)dir.c	8.2 (Berkeley) 1/2/94";
+#else
+static const char rcsid[] =
+  "$FreeBSD: src/usr.bin/make/dir.c,v 1.10.2.1 2001/02/13 03:13:57 will Exp $";
+#endif
+#endif /* not lint */
 
 /*-
@@ -88,7 +91,6 @@
 #include <stdio.h>
 #include <sys/types.h>
+#include <dirent.h>
 #include <sys/stat.h>
-#include <dirent.h>
-#include <err.h>
 #include "make.h"
 #include "hash.h"
@@ -190,10 +192,10 @@
 
 
-static int DirFindName(void *, void *);
-static int DirMatchFiles(char *, Path *, Lst);
-static void DirExpandCurly(char *, char *, Lst, Lst);
-static void DirExpandInt(char *, Lst, Lst);
-static int DirPrintWord(void *, void *);
-static int DirPrintDir(void *, void *);
+static int DirFindName __P((ClientData, ClientData));
+static int DirMatchFiles __P((char *, Path *, Lst));
+static void DirExpandCurly __P((char *, char *, Lst, Lst));
+static void DirExpandInt __P((char *, Lst, Lst));
+static int DirPrintWord __P((ClientData, ClientData));
+static int DirPrintDir __P((ClientData, ClientData));
 
 /*-
@@ -210,5 +212,5 @@
  */
 void
-Dir_Init (void)
+Dir_Init ()
 {
     dirSearchPath = Lst_Init (FALSE);
@@ -247,8 +249,8 @@
  */
 void
-Dir_End(void)
+Dir_End()
 {
     dot->refCount -= 1;
-    Dir_Destroy((void *) dot);
+    Dir_Destroy((ClientData) dot);
     Dir_ClearPath(dirSearchPath);
     Lst_Destroy(dirSearchPath, NOFREE);
@@ -273,5 +275,7 @@
  */
 static int
-DirFindName (void *p, void *dname)
+DirFindName (p, dname)
+    ClientData    p;	      /* Current name */
+    ClientData	  dname;      /* Desired name */
 {
     return (strcmp (((Path *)p)->name, (char *) dname));
@@ -281,5 +285,5 @@
  *-----------------------------------------------------------------------
  * Dir_HasWildcards  --
- *	See if the given name has any wildcard characters in it.
+ *	see if the given name has any wildcard characters in it
  *
  * Results:
@@ -291,34 +295,19 @@
  */
 Boolean
-Dir_HasWildcards (char *name)
-{
-    char *cp;
-    int wild = 0, brace = 0, bracket = 0;
+Dir_HasWildcards (name)
+    char          *name;	/* name to check */
+{
+    register char *cp;
 
     for (cp = name; *cp; cp++) {
 	switch(*cp) {
 	case '{':
-		brace++;
-		wild = 1;
-		break;
-	case '}':
-		brace--;
-		break;
 	case '[':
-		bracket++;
-		wild = 1;
-		break;
-	case ']':
-		bracket--;
-		break;
 	case '?':
 	case '*':
-		wild = 1;
-		break;
-	default:
-		break;
-	}
-    }
-    return wild && bracket == 0 && brace == 0;
+	    return (TRUE);
+	}
+    }
+    return (FALSE);
 }
 
@@ -341,5 +330,8 @@
  */
 static int
-DirMatchFiles (char *pattern, Path *p, Lst expansions)
+DirMatchFiles (pattern, p, expansions)
+    char	  *pattern;   	/* Pattern to look for */
+    Path	  *p;         	/* Directory to search */
+    Lst	    	  expansions;	/* Place to store the results */
 {
     Hash_Search	  search;   	/* Index into the directory's table */
@@ -378,8 +370,5 @@
  *	Note the special case: if after the piece of the curly brace is
  *	done there are no wildcard characters in the result, the result is
- *	placed on the list WITHOUT CHECKING FOR ITS EXISTENCE.  The
- *	given arguments are the entire word to expand, the first curly
- *	brace in the word, the search path, and the list to store the
- *	expansions in.
+ *	placed on the list WITHOUT CHECKING FOR ITS EXISTENCE.
  *
  * Results:
@@ -392,5 +381,9 @@
  */
 static void
-DirExpandCurly(char *word, char *brace, Lst path, Lst expansions)
+DirExpandCurly(word, brace, path, expansions)
+    char    	  *word;    	/* Entire word to expand */
+    char    	  *brace;   	/* First curly brace in it */
+    Lst	    	  path;	    	/* Search path to use */
+    Lst	    	  expansions;	/* Place to store the expansions */
 {
     char    	  *end;	    	/* Character after the closing brace */
@@ -466,6 +459,4 @@
 		Dir_Expand(file, path, expansions);
 		goto next;
-	    default:
-		break;
 	    }
 	}
@@ -490,6 +481,5 @@
  *	Internal expand routine. Passes through the directories in the
  *	path one by one, calling DirMatchFiles for each. NOTE: This still
- *	doesn't handle patterns in directories...  Works given a word to
- *	expand, a path to look in, and a list to store expansions in.
+ *	doesn't handle patterns in directories...
  *
  * Results:
@@ -502,5 +492,8 @@
  */
 static void
-DirExpandInt(char *word, Lst path, Lst expansions)
+DirExpandInt(word, path, expansions)
+    char    	  *word;    	/* Word to expand */
+    Lst	    	  path;	    	/* Path on which to look */
+    Lst	    	  expansions;	/* Place to store the result */
 {
     LstNode 	  ln;	    	/* Current node */
@@ -508,5 +501,5 @@
 
     if (Lst_Open(path) == SUCCESS) {
-	while ((ln = Lst_Next(path)) != NULL) {
+	while ((ln = Lst_Next(path)) != NILLNODE) {
 	    p = (Path *)Lst_Datum(ln);
 	    DirMatchFiles(word, p, expansions);
@@ -531,9 +524,11 @@
  */
 static int
-DirPrintWord(void *word, void *dummy __unused)
-{
-    DEBUGF(DIR, ("%s ", (char *) word));
-
-    return (0);
+DirPrintWord(word, dummy)
+    ClientData  word;
+    ClientData  dummy;
+{
+    printf("%s ", (char *) word);
+
+    return(dummy ? 0 : 0);
 }
 
@@ -546,5 +541,5 @@
  * Results:
  *	A list of words consisting of the files which exist along the search
- *	path matching the given pattern is placed in expansions.
+ *	path matching the given pattern.
  *
  * Side Effects:
@@ -553,9 +548,15 @@
  */
 void
-Dir_Expand (char *word, Lst path, Lst expansions)
+Dir_Expand (word, path, expansions)
+    char    *word;      /* the word to expand */
+    Lst     path;   	/* the list of directories in which to find
+			 * the resulting files */
+    Lst	    expansions;	/* the list on which to place the results */
 {
     char    	  *cp;
 
-    DEBUGF(DIR, ("expanding \"%s\"...", word));
+    if (DEBUG(DIR)) {
+	printf("expanding \"%s\"...", word);
+    }
 
     cp = strchr(word, '{');
@@ -640,6 +641,6 @@
     }
     if (DEBUG(DIR)) {
-	Lst_ForEach(expansions, DirPrintWord, (void *) 0);
-	DEBUGF(DIR, ("\n"));
+	Lst_ForEach(expansions, DirPrintWord, (ClientData) 0);
+	fputc('\n', stdout);
     }
 }
@@ -664,12 +665,14 @@
  */
 char *
-Dir_FindFile (char *name, Lst path)
-{
-    char          *p1;	    /* pointer into p->name */
-    char          *p2;	    /* pointer into name */
+Dir_FindFile (name, path)
+    char    	  *name;    /* the file to find */
+    Lst           path;	    /* the Lst of directories to search */
+{
+    register char *p1;	    /* pointer into p->name */
+    register char *p2;	    /* pointer into name */
     LstNode       ln;	    /* a list element */
-    char          *file;    /* the current filename to check */
-    Path          *p;	    /* current path member */
-    char          *cp;	    /* index of first slash, if any */
+    register char *file;    /* the current filename to check */
+    register Path *p;	    /* current path member */
+    register char *cp;	    /* index of first slash, if any */
     Boolean	  hasSlash; /* true if 'name' contains a / */
     struct stat	  stb;	    /* Buffer for stat, if necessary */
@@ -689,5 +692,7 @@
     }
 
-    DEBUGF(DIR, ("Searching for %s...", name));
+    if (DEBUG(DIR)) {
+	printf("Searching for %s...", name);
+    }
     /*
      * No matter what, we always look for the file in the current directory
@@ -698,5 +703,7 @@
     if ((!hasSlash || (cp - name == 2 && *name == '.')) &&
 	(Hash_FindEntry (&dot->files, cp) != (Hash_Entry *)NULL)) {
-	    DEBUGF(DIR, ("in '.'\n"));
+	    if (DEBUG(DIR)) {
+		printf("in '.'\n");
+	    }
 	    hits += 1;
 	    dot->hits += 1;
@@ -705,5 +712,7 @@
 
     if (Lst_Open (path) == FAILURE) {
-	DEBUGF(DIR, ("couldn't open path, file not found\n"));
+	if (DEBUG(DIR)) {
+	    printf("couldn't open path, file not found\n");
+	}
 	misses += 1;
 	return ((char *) NULL);
@@ -718,9 +727,13 @@
      * we go on to phase two...
      */
-    while ((ln = Lst_Next (path)) != NULL) {
+    while ((ln = Lst_Next (path)) != NILLNODE) {
 	p = (Path *) Lst_Datum (ln);
-	DEBUGF(DIR, ("%s...", p->name));
+	if (DEBUG(DIR)) {
+	    printf("%s...", p->name);
+	}
 	if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) {
-	    DEBUGF(DIR, ("here..."));
+	    if (DEBUG(DIR)) {
+		printf("here...");
+	    }
 	    if (hasSlash) {
 		/*
@@ -738,10 +751,14 @@
 		}
 		if (p2 >= name || (p1 >= p->name && *p1 != '/')) {
-		    DEBUGF(DIR, ("component mismatch -- continuing..."));
+		    if (DEBUG(DIR)) {
+			printf("component mismatch -- continuing...");
+		    }
 		    continue;
 		}
 	    }
 	    file = str_concat (p->name, cp, STR_ADDSLASH);
-	    DEBUGF(DIR, ("returning %s\n", file));
+	    if (DEBUG(DIR)) {
+		printf("returning %s\n", file);
+	    }
 	    Lst_Close (path);
 	    p->hits += 1;
@@ -758,5 +775,7 @@
 	    }
 	    if (*p1 == '\0' && p2 == cp - 1) {
-		DEBUGF(DIR, ("must be here but isn't -- returing NULL\n"));
+		if (DEBUG(DIR)) {
+		    printf("must be here but isn't -- returing NULL\n");
+		}
 		Lst_Close (path);
 		return ((char *) NULL);
@@ -778,5 +797,7 @@
      */
     if (!hasSlash) {
-	DEBUGF(DIR, ("failed.\n"));
+	if (DEBUG(DIR)) {
+	    printf("failed.\n");
+	}
 	misses += 1;
 	return ((char *) NULL);
@@ -786,7 +807,9 @@
 	Boolean	checkedDot = FALSE;
 
-	DEBUGF(DIR, ("failed. Trying subdirectories..."));
+	if (DEBUG(DIR)) {
+	    printf("failed. Trying subdirectories...");
+	}
 	(void) Lst_Open (path);
-	while ((ln = Lst_Next (path)) != NULL) {
+	while ((ln = Lst_Next (path)) != NILLNODE) {
 	    p = (Path *) Lst_Datum (ln);
 	    if (p != dot) {
@@ -799,8 +822,13 @@
 		checkedDot = TRUE;
 	    }
-	    DEBUGF(DIR, ("checking %s...", file));
+	    if (DEBUG(DIR)) {
+		printf("checking %s...", file);
+	    }
+
 
 	    if (stat (file, &stb) == 0) {
-		DEBUGF(DIR, ("got it.\n"));
+		if (DEBUG(DIR)) {
+		    printf("got it.\n");
+		}
 
 		Lst_Close (path);
@@ -825,5 +853,8 @@
 		 * to fetch it again.
 		 */
-		DEBUGF(DIR, ("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), file));
+		if (DEBUG(DIR)) {
+		    printf("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
+			    file);
+		}
 		entry = Hash_CreateEntry(&mtimes, (char *) file,
 					 (Boolean *)NULL);
@@ -836,5 +867,7 @@
 	}
 
-	DEBUGF(DIR, ("failed. "));
+	if (DEBUG(DIR)) {
+	    printf("failed. ");
+	}
 	Lst_Close (path);
 
@@ -844,5 +877,7 @@
 	     * so no point in proceeding...
 	     */
-	    DEBUGF(DIR, ("Checked . already, returning NULL\n"));
+	    if (DEBUG(DIR)) {
+		printf("Checked . already, returning NULL\n");
+	    }
 	    return(NULL);
 	}
@@ -873,5 +908,5 @@
     bigmisses += 1;
     ln = Lst_Last (path);
-    if (ln == NULL) {
+    if (ln == NILLNODE) {
 	return ((char *) NULL);
     } else {
@@ -885,18 +920,27 @@
     }
 #else /* !notdef */
-    DEBUGF(DIR, ("Looking for \"%s\"...", name));
+    if (DEBUG(DIR)) {
+	printf("Looking for \"%s\"...", name);
+    }
 
     bigmisses += 1;
     entry = Hash_FindEntry(&mtimes, name);
     if (entry != (Hash_Entry *)NULL) {
-	DEBUGF(DIR, ("got it (in mtime cache)\n"));
-	return (estrdup(name));
+	if (DEBUG(DIR)) {
+	    printf("got it (in mtime cache)\n");
+	}
+	return(estrdup(name));
     } else if (stat (name, &stb) == 0) {
 	entry = Hash_CreateEntry(&mtimes, name, (Boolean *)NULL);
-	DEBUGF(DIR, ("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), name));
+	if (DEBUG(DIR)) {
+	    printf("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
+		    name);
+	}
 	Hash_SetValue(entry, (long)stb.st_mtime);
 	return (estrdup (name));
     } else {
-	DEBUGF(DIR, ("failed. Returning NULL\n"));
+	if (DEBUG(DIR)) {
+	    printf("failed. Returning NULL\n");
+	}
 	return ((char *)NULL);
     }
@@ -920,5 +964,7 @@
  */
 int
-Dir_MTime (GNode *gn)
+Dir_MTime (gn)
+    GNode         *gn;	      /* the file whose modification time is
+			       * desired */
 {
     char          *fullName;  /* the full pathname of name */
@@ -943,8 +989,10 @@
 	 * Only do this once -- the second time folks are checking to
 	 * see if the file was actually updated, so we need to actually go
-	 * to the filesystem.
+	 * to the file system.
 	 */
-	DEBUGF(DIR, ("Using cached time %s for %s\n",
-	       Targ_FmtTime((time_t)(long)Hash_GetValue(entry)), fullName));
+	if (DEBUG(DIR)) {
+	    printf("Using cached time %s for %s\n",
+		    Targ_FmtTime((time_t)(long)Hash_GetValue(entry)), fullName);
+	}
 	stb.st_mtime = (time_t)(long)Hash_GetValue(entry);
 	Hash_DeleteEntry(&mtimes, entry);
@@ -982,20 +1030,26 @@
  */
 void
-Dir_AddDir (Lst path, char *name)
+Dir_AddDir (path, name)
+    Lst           path;	      /* the path to which the directory should be
+			       * added */
+    char          *name;      /* the name of the directory to add */
 {
     LstNode       ln;	      /* node in case Path structure is found */
-    Path          *p;	      /* pointer to new Path structure */
+    register Path *p;	      /* pointer to new Path structure */
     DIR     	  *d;	      /* for reading directory */
-    struct dirent *dp;	      /* entry in directory */
-
-    ln = Lst_Find (openDirectories, (void *)name, DirFindName);
-    if (ln != NULL) {
+    register struct dirent *dp; /* entry in directory */
+
+    ln = Lst_Find (openDirectories, (ClientData)name, DirFindName);
+    if (ln != NILLNODE) {
 	p = (Path *)Lst_Datum (ln);
-	if (Lst_Member(path, (void *)p) == NULL) {
+	if (Lst_Member(path, (ClientData)p) == NILLNODE) {
 	    p->refCount += 1;
-	    (void)Lst_AtEnd (path, (void *)p);
+	    (void)Lst_AtEnd (path, (ClientData)p);
 	}
     } else {
-	DEBUGF(DIR, ("Caching %s...", name));
+	if (DEBUG(DIR)) {
+	    printf("Caching %s...", name);
+	    fflush(stdout);
+	}
 
 	if ((d = opendir (name)) != (DIR *) NULL) {
@@ -1007,5 +1061,5 @@
 
 	    while ((dp = readdir (d)) != (struct dirent *) NULL) {
-#if defined(sun) && defined(d_ino) /* d_ino is a sunos4 #define	for d_fileno */
+#if defined(sun) && defined(d_ino) /* d_ino is a sunos4 #define for d_fileno */
 		/*
 		 * The sun directory library doesn't check for a 0 inode
@@ -1022,5 +1076,5 @@
 		 * that order when first going through a directory.  This is
 		 * needed for XFS over NFS filesystems since SGI does not
-		 * guarantee that these are the first two entries returned
+		 * guarantee that these are * the first two entries returned
 		 * from readdir().
 		 */
@@ -1031,8 +1085,10 @@
 	    }
 	    (void) closedir (d);
-	    (void)Lst_AtEnd (openDirectories, (void *)p);
-	    (void)Lst_AtEnd (path, (void *)p);
-	}
-	DEBUGF(DIR, ("done\n"));
+	    (void)Lst_AtEnd (openDirectories, (ClientData)p);
+	    (void)Lst_AtEnd (path, (ClientData)p);
+	}
+	if (DEBUG(DIR)) {
+	    printf("done\n");
+	}
     }
 }
@@ -1052,10 +1108,11 @@
  *-----------------------------------------------------------------------
  */
-void *
-Dir_CopyDir(void *p)
+ClientData
+Dir_CopyDir(p)
+    ClientData p;
 {
     ((Path *) p)->refCount += 1;
 
-    return ((void *)p);
+    return ((ClientData)p);
 }
 
@@ -1078,5 +1135,7 @@
  */
 char *
-Dir_MakeFlags (char *flag, Lst path)
+Dir_MakeFlags (flag, path)
+    char	  *flag;  /* flag which should precede each directory */
+    Lst	    	  path;	  /* list of directories */
 {
     char	  *str;	  /* the string which will be returned */
@@ -1088,5 +1147,5 @@
 
     if (Lst_Open (path) == SUCCESS) {
-	while ((ln = Lst_Next (path)) != NULL) {
+	while ((ln = Lst_Next (path)) != NILLNODE) {
 	    p = (Path *) Lst_Datum (ln);
 	    tstr = str_concat (flag, p->name, 0);
@@ -1115,5 +1174,6 @@
  */
 void
-Dir_Destroy (void *pp)
+Dir_Destroy (pp)
+    ClientData 	  pp;	    /* The directory descriptor to nuke */
 {
     Path    	  *p = (Path *) pp;
@@ -1123,10 +1183,10 @@
 	LstNode	ln;
 
-	ln = Lst_Member (openDirectories, (void *)p);
+	ln = Lst_Member (openDirectories, (ClientData)p);
 	(void) Lst_Remove (openDirectories, ln);
 
 	Hash_DeleteTable (&p->files);
-	free(p->name);
-	free(p);
+	free((Address)p->name);
+	free((Address)p);
     }
 }
@@ -1147,10 +1207,11 @@
  */
 void
-Dir_ClearPath(Lst path)
+Dir_ClearPath(path)
+    Lst	    path; 	/* Path to clear */
 {
     Path    *p;
     while (!Lst_IsEmpty(path)) {
 	p = (Path *)Lst_DeQueue(path);
-	Dir_Destroy((void *) p);
+	Dir_Destroy((ClientData) p);
     }
 }
@@ -1172,14 +1233,16 @@
  */
 void
-Dir_Concat(Lst path1, Lst path2)
+Dir_Concat(path1, path2)
+    Lst	    path1;  	/* Dest */
+    Lst	    path2;  	/* Source */
 {
     LstNode ln;
     Path    *p;
 
-    for (ln = Lst_First(path2); ln != NULL; ln = Lst_Succ(ln)) {
+    for (ln = Lst_First(path2); ln != NILLNODE; ln = Lst_Succ(ln)) {
 	p = (Path *)Lst_Datum(ln);
-	if (Lst_Member(path1, (void *)p) == NULL) {
+	if (Lst_Member(path1, (ClientData)p) == NILLNODE) {
 	    p->refCount += 1;
-	    (void)Lst_AtEnd(path1, (void *)p);
+	    (void)Lst_AtEnd(path1, (ClientData)p);
 	}
     }
@@ -1188,5 +1251,5 @@
 /********** DEBUG INFO **********/
 void
-Dir_PrintDirectories(void)
+Dir_PrintDirectories()
 {
     LstNode	ln;
@@ -1200,5 +1263,5 @@
     printf ("# %-20s referenced\thits\n", "directory");
     if (Lst_Open (openDirectories) == SUCCESS) {
-	while ((ln = Lst_Next (openDirectories)) != NULL) {
+	while ((ln = Lst_Next (openDirectories)) != NILLNODE) {
 	    p = (Path *) Lst_Datum (ln);
 	    printf ("# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits);
@@ -1208,15 +1271,16 @@
 }
 
-static int
-DirPrintDir (void *p, void *dummy __unused)
+static int DirPrintDir (p, dummy)
+    ClientData	p;
+    ClientData	dummy;
 {
     printf ("%s ", ((Path *) p)->name);
-
-    return (0);
+    return (dummy ? 0 : 0);
 }
 
 void
-Dir_PrintPath (Lst path)
-{
-    Lst_ForEach (path, DirPrintDir, (void *)0);
-}
+Dir_PrintPath (path)
+    Lst	path;
+{
+    Lst_ForEach (path, DirPrintDir, (ClientData)0);
+}
Index: /trunk/src/kmk/dir.h
===================================================================
--- /trunk/src/kmk/dir.h	(revision 24)
+++ /trunk/src/kmk/dir.h	(revision 25)
@@ -1,5 +1,4 @@
 /*
- * Copyright (c) 1988, 1989, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
  * Copyright (c) 1988, 1989 by Adam de Boor
  * Copyright (c) 1989 by Berkeley Softworks
@@ -37,6 +36,6 @@
  * SUCH DAMAGE.
  *
- *	@(#)dir.h	8.2 (Berkeley) 4/28/95
- * $FreeBSD: src/usr.bin/make/dir.h,v 1.10 2002/04/13 10:57:56 obrien Exp $
+ *	from: @(#)dir.h	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/dir.h,v 1.7 1999/08/28 01:03:29 peter Exp $
  */
 
@@ -55,18 +54,18 @@
 } Path;
 
-void Dir_Init(void);
-void Dir_End(void);
-Boolean Dir_HasWildcards(char *);
-void Dir_Expand(char *, Lst, Lst);
-char *Dir_FindFile(char *, Lst);
-int Dir_MTime(GNode *);
-void Dir_AddDir(Lst, char *);
-char *Dir_MakeFlags(char *, Lst);
-void Dir_ClearPath(Lst);
-void Dir_Concat(Lst, Lst);
-void Dir_PrintDirectories(void);
-void Dir_PrintPath(Lst);
-void Dir_Destroy(void *);
-void * Dir_CopyDir(void *);
+void Dir_Init __P((void));
+void Dir_End __P((void));
+Boolean Dir_HasWildcards __P((char *));
+void Dir_Expand __P((char *, Lst, Lst));
+char *Dir_FindFile __P((char *, Lst));
+int Dir_MTime __P((GNode *));
+void Dir_AddDir __P((Lst, char *));
+char *Dir_MakeFlags __P((char *, Lst));
+void Dir_ClearPath __P((Lst));
+void Dir_Concat __P((Lst, Lst));
+void Dir_PrintDirectories __P((void));
+void Dir_PrintPath __P((Lst));
+void Dir_Destroy __P((ClientData));
+ClientData Dir_CopyDir __P((ClientData));
 
 #endif /* _DIR */
Index: /trunk/src/kmk/for.c
===================================================================
--- /trunk/src/kmk/for.c	(revision 24)
+++ /trunk/src/kmk/for.c	(revision 25)
@@ -1,8 +1,5 @@
 /*
- * Copyright (c) 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Christos Zoulas.
+ * Copyright (c) 1992, The Regents of the University of California.
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -33,10 +30,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * @(#)for.c	8.1 (Berkeley) 6/6/93
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/for.c,v 1.19 2002/10/09 03:42:10 jmallett Exp $");
+ */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)for.c	8.1 (Berkeley) 6/6/93";
+#else
+static const char rcsid[] =
+  "$FreeBSD: src/usr.bin/make/for.c,v 1.10 1999/09/11 13:08:01 hoek Exp $";
+#endif
+#endif /* not lint */
 
 /*-
@@ -84,5 +85,5 @@
 } For;
 
-static int ForExec(void *, void *);
+static int ForExec	__P((ClientData, ClientData));
 
 
@@ -108,5 +109,6 @@
  */
 int
-For_Eval (char *line)
+For_Eval (line)
+    char    	    *line;    /* Line to parse */
 {
     char	    *ptr = line, *sub, *wrd;
@@ -176,8 +178,8 @@
 	sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE);
 
-#define	ADDWORD() \
+#define ADDWORD() \
 	Buf_AddBytes(buf, ptr - wrd, (Byte *) wrd), \
 	Buf_AddByte(buf, (Byte) '\0'), \
-	Lst_AtFront(forLst, (void *) Buf_GetAll(buf, &varlen)), \
+	Lst_AtFront(forLst, (ClientData) Buf_GetAll(buf, &varlen)), \
 	Buf_Destroy(buf, FALSE)
 
@@ -193,10 +195,11 @@
 		wrd = ptr--;
 	    }
-	DEBUGF(FOR, ("For: Iterator %s List %s\n", forVar, sub));
+	if (DEBUG(FOR))
+	    (void) fprintf(stderr, "For: Iterator %s List %s\n", forVar, sub);
 	if (ptr - wrd > 0)
 	    ADDWORD();
 	else
 	    Buf_Destroy(buf, TRUE);
-	free(sub);
+	free((Address) sub);
 
 	forBuf = Buf_Init(0);
@@ -211,5 +214,6 @@
 	if (strncmp(ptr, "endfor", 6) == 0 &&
 	    (isspace((unsigned char) ptr[6]) || !ptr[6])) {
-	    DEBUGF(FOR, ("For: end for %d\n", forLevel));
+	    if (DEBUG(FOR))
+		(void) fprintf(stderr, "For: end for %d\n", forLevel);
 	    if (--forLevel < 0) {
 		Parse_Error (level, "for-less endfor");
@@ -220,5 +224,6 @@
 		 isspace((unsigned char) ptr[3])) {
 	    forLevel++;
-	    DEBUGF(FOR, ("For: new loop %d\n", forLevel));
+	    if (DEBUG(FOR))
+		(void) fprintf(stderr, "For: new loop %d\n", forLevel);
 	}
     }
@@ -248,5 +253,7 @@
  */
 static int
-ForExec(void *namep, void *argp)
+ForExec(namep, argp)
+    ClientData namep;
+    ClientData argp;
 {
     char *name = (char *) namep;
@@ -254,5 +261,6 @@
     int len;
     Var_Set(arg->var, name, VAR_GLOBAL);
-    DEBUGF(FOR, ("--- %s = %s\n", arg->var, name));
+    if (DEBUG(FOR))
+	(void) fprintf(stderr, "--- %s = %s\n", arg->var, name);
     Parse_FromString(Var_Subst(arg->var, (char *) Buf_GetAll(arg->buf, &len),
 			       VAR_GLOBAL, FALSE));
@@ -278,5 +286,5 @@
  */
 void
-For_Run(void)
+For_Run()
 {
     For arg;
@@ -291,8 +299,8 @@
     forLst = NULL;
 
-    Lst_ForEach(arg.lst, ForExec, (void *) &arg);
-
-    free(arg.var);
-    Lst_Destroy(arg.lst, (void (*)(void *)) free);
+    Lst_ForEach(arg.lst, ForExec, (ClientData) &arg);
+
+    free((Address)arg.var);
+    Lst_Destroy(arg.lst, (void (*) __P((ClientData))) free);
     Buf_Destroy(arg.buf, TRUE);
 }
Index: /trunk/src/kmk/hash.c
===================================================================
--- /trunk/src/kmk/hash.c	(revision 24)
+++ /trunk/src/kmk/hash.c	(revision 25)
@@ -1,5 +1,4 @@
 /*
- * Copyright (c) 1988, 1989, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
  * Copyright (c) 1988, 1989 by Adam de Boor
  * Copyright (c) 1989 by Berkeley Softworks
@@ -36,10 +35,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * @(#)hash.c	8.1 (Berkeley) 6/6/93
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/hash.c,v 1.18 2002/10/09 03:42:10 jmallett Exp $");
+ */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)hash.c	8.1 (Berkeley) 6/6/93";
+#else
+static const char rcsid[] =
+  "$FreeBSD: src/usr.bin/make/hash.c,v 1.9 1999/09/11 13:08:01 hoek Exp $";
+#endif
+#endif /* not lint */
 
 /* hash.c --
@@ -50,5 +53,4 @@
  * 	information increases.
  */
-#include <unistd.h>
 #include "sprite.h"
 #include "make.h"
@@ -60,5 +62,5 @@
  */
 
-static void RebuildTable(Hash_Table *);
+static void RebuildTable __P((Hash_Table *));
 
 /*
@@ -67,5 +69,5 @@
  */
 
-#define	rebuildLimit 8
+#define rebuildLimit 8
 
 /*
@@ -73,9 +75,6 @@
  *
  * Hash_InitTable --
- * 
- * 	Set up the hash table t with a given number of buckets, or a
- * 	reasonable default if the number requested is less than or
- * 	equal to zero.  Hash tables will grow in size as needed.
- *
+ *
+ *	This routine just sets up the hash table.
  *
  * Results:
@@ -89,8 +88,14 @@
 
 void
-Hash_InitTable(Hash_Table *t, int numBuckets)
-{
-	int i;
-	struct Hash_Entry **hp;
+Hash_InitTable(t, numBuckets)
+	register Hash_Table *t;	/* Structure to use to hold table. */
+	int numBuckets;		/* How many buckets to create for starters.
+				 * This number is rounded up to a power of
+				 * two.   If <= 0, a reasonable default is
+				 * chosen. The table will grow in size later
+				 * as needed. */
+{
+	register int i;
+	register struct Hash_Entry **hp;
 
 	/*
@@ -130,8 +135,9 @@
 
 void
-Hash_DeleteTable(Hash_Table *t)
-{
-	struct Hash_Entry **hp, *h, *nexth = NULL;
-	int i;
+Hash_DeleteTable(t)
+	Hash_Table *t;
+{
+	register struct Hash_Entry **hp, *h, *nexth = NULL;
+	register int i;
 
 	for (hp = t->bucketPtr, i = t->size; --i >= 0;) {
@@ -169,9 +175,11 @@
 
 Hash_Entry *
-Hash_FindEntry(Hash_Table *t, char *key)
-{
-	Hash_Entry *e;
-	unsigned h;
-	char *p;
+Hash_FindEntry(t, key)
+	Hash_Table *t;		/* Hash table to search. */
+	char *key;		/* A hash key. */
+{
+	register Hash_Entry *e;
+	register unsigned h;
+	register char *p;
 
 	for (h = 0, p = key; *p;)
@@ -204,9 +212,13 @@
 
 Hash_Entry *
-Hash_CreateEntry(Hash_Table *t, char *key, Boolean *newPtr)
-{
-	Hash_Entry *e;
-	unsigned int h;
-	char *p;
+Hash_CreateEntry(t, key, newPtr)
+	register Hash_Table *t;	/* Hash table to search. */
+	char *key;		/* A hash key. */
+	Boolean *newPtr;	/* Filled in with TRUE if new entry created,
+				 * FALSE otherwise. */
+{
+	register Hash_Entry *e;
+	register unsigned h;
+	register char *p;
 	int keylen;
 	struct Hash_Entry **hp;
@@ -267,7 +279,9 @@
 
 void
-Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e)
-{
-	Hash_Entry **hp, *p;
+Hash_DeleteEntry(t, e)
+	Hash_Table *t;
+	Hash_Entry *e;
+{
+	register Hash_Entry **hp, *p;
 
 	if (e == NULL)
@@ -282,5 +296,5 @@
 		}
 	}
-	(void) write(STDERR_FILENO, "bad call to Hash_DeleteEntry\n", 29);
+	(void) write(2, "bad call to Hash_DeleteEntry\n", 29);
 	abort();
 }
@@ -306,5 +320,8 @@
 
 Hash_Entry *
-Hash_EnumFirst(Hash_Table *t, Hash_Search *searchPtr)
+Hash_EnumFirst(t, searchPtr)
+	Hash_Table *t;			/* Table to be searched. */
+	register Hash_Search *searchPtr;/* Area in which to keep state
+					 * about search.*/
 {
 	searchPtr->tablePtr = t;
@@ -333,12 +350,14 @@
 
 Hash_Entry *
-Hash_EnumNext(Hash_Search *searchPtr)
-{
-	Hash_Entry *e;
+Hash_EnumNext(searchPtr)
+	register Hash_Search *searchPtr; /* Area used to keep state about
+					    search. */
+{
+	register Hash_Entry *e;
 	Hash_Table *t = searchPtr->tablePtr;
 
 	/*
 	 * The hashEntryPtr field points to the most recently returned
-	 * entry, or is NULL if we are starting up.  If not NULL, we have
+	 * entry, or is nil if we are starting up.  If not nil, we have
 	 * to start at the next one in the chain.
 	 */
@@ -377,9 +396,10 @@
 
 static void
-RebuildTable(Hash_Table *t)
-{
-	Hash_Entry *e, *next = NULL, **hp, **xp;
-	int i, mask;
-        Hash_Entry **oldhp;
+RebuildTable(t)
+	register Hash_Table *t;
+{
+	register Hash_Entry *e, *next = NULL, **hp, **xp;
+	register int i, mask;
+        register Hash_Entry **oldhp;
 	int oldsize;
 
Index: /trunk/src/kmk/hash.h
===================================================================
--- /trunk/src/kmk/hash.h	(revision 24)
+++ /trunk/src/kmk/hash.h	(revision 25)
@@ -1,5 +1,4 @@
 /*
- * Copyright (c) 1988, 1989, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
  * Copyright (c) 1988, 1989 by Adam de Boor
  * Copyright (c) 1989 by Berkeley Softworks
@@ -37,6 +36,6 @@
  * SUCH DAMAGE.
  *
- *	@(#)hash.h	8.1 (Berkeley) 6/6/93
- * $FreeBSD: src/usr.bin/make/hash.h,v 1.12 2002/09/17 21:29:06 jmallett Exp $
+ *	from: @(#)hash.h	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/hash.h,v 1.8 1999/08/28 01:03:30 peter Exp $
  */
 
@@ -58,5 +57,5 @@
     					 * entries associated with the same
 					 * bucket. */
-    void *	      clientData;	/* Arbitrary piece of data associated
+    ClientData	      clientData;	/* Arbitrary piece of data associated
     					 * with key. */
     unsigned	      namehash;		/* hash value of key */
@@ -88,9 +87,9 @@
 
 /*
- * void * Hash_GetValue(h)
+ * ClientData Hash_GetValue(h)
  *     Hash_Entry *h;
  */
 
-#define	Hash_GetValue(h) ((h)->clientData)
+#define Hash_GetValue(h) ((h)->clientData)
 
 /*
@@ -100,5 +99,5 @@
  */
 
-#define	Hash_SetValue(h, val) ((h)->clientData = (void *) (val))
+#define Hash_SetValue(h, val) ((h)->clientData = (ClientData) (val))
 
 /*
@@ -108,11 +107,11 @@
 #define	Hash_Size(n)	(((n) + sizeof (int) - 1) / sizeof (int))
 
-void Hash_InitTable(Hash_Table *, int);
-void Hash_DeleteTable(Hash_Table *);
-Hash_Entry *Hash_FindEntry(Hash_Table *, char *);
-Hash_Entry *Hash_CreateEntry(Hash_Table *, char *, Boolean *);
-void Hash_DeleteEntry(Hash_Table *, Hash_Entry *);
-Hash_Entry *Hash_EnumFirst(Hash_Table *, Hash_Search *);
-Hash_Entry *Hash_EnumNext(Hash_Search *);
+void Hash_InitTable __P((Hash_Table *, int));
+void Hash_DeleteTable __P((Hash_Table *));
+Hash_Entry *Hash_FindEntry __P((Hash_Table *, char *));
+Hash_Entry *Hash_CreateEntry __P((Hash_Table *, char *, Boolean *));
+void Hash_DeleteEntry __P((Hash_Table *, Hash_Entry *));
+Hash_Entry *Hash_EnumFirst __P((Hash_Table *, Hash_Search *));
+Hash_Entry *Hash_EnumNext __P((Hash_Search *));
 
 #endif /* _HASH */
Index: /trunk/src/kmk/job.c
===================================================================
--- /trunk/src/kmk/job.c	(revision 24)
+++ /trunk/src/kmk/job.c	(revision 25)
@@ -1,5 +1,4 @@
 /*
- * Copyright (c) 1988, 1989, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
  * Copyright (c) 1988, 1989 by Adam de Boor
  * Copyright (c) 1989 by Berkeley Softworks
@@ -36,13 +35,17 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * @(#)job.c	8.2 (Berkeley) 3/19/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/job.c,v 1.45 2002/10/09 03:42:10 jmallett Exp $");
+ */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)job.c	8.2 (Berkeley) 3/19/94";
+#else
+static const char rcsid[] =
+  "$FreeBSD: src/usr.bin/make/job.c,v 1.17.2.2 2001/02/13 03:13:57 will Exp $";
+#endif
+#endif /* not lint */
 
 #ifndef OLD_JOKE
-#define	OLD_JOKE 0
+#define OLD_JOKE 0
 #endif /* OLD_JOKE */
 
@@ -84,5 +87,5 @@
  *	    	  	    	FAILURE if the spec was incorrect.
  *
- *	Job_Finish	  	    	Perform any final processing which needs doing.
+ *	Job_End	  	    	Perform any final processing which needs doing.
  *	    	  	    	This includes the execution of any commands
  *	    	  	    	which have been/were attached to the .END
@@ -107,14 +110,11 @@
 #include <sys/file.h>
 #include <sys/time.h>
-#include <sys/event.h>
 #include <sys/wait.h>
-#include <err.h>
+#include <fcntl.h>
 #include <errno.h>
-#include <fcntl.h>
+#include <utime.h>
 #include <stdio.h>
 #include <string.h>
 #include <signal.h>
-#include <unistd.h>
-#include <utime.h>
 #include "make.h"
 #include "hash.h"
@@ -134,7 +134,7 @@
 static int     	errors = 0;	    /* number of errors reported */
 static int    	aborting = 0;	    /* why is the make aborting? */
-#define	ABORT_ERROR	1   	    /* Because of an error */
-#define	ABORT_INTERRUPT	2   	    /* Because it was interrupted */
-#define	ABORT_WAIT	3   	    /* Waiting for jobs to finish */
+#define ABORT_ERROR	1   	    /* Because of an error */
+#define ABORT_INTERRUPT	2   	    /* Because it was interrupted */
+#define ABORT_WAIT	3   	    /* Waiting for jobs to finish */
 
 /*
@@ -142,5 +142,5 @@
  * is a char! So when we go above 127 we turn negative!
  */
-#define	FILENO(a) ((unsigned) fileno(a))
+#define FILENO(a) ((unsigned) fileno(a))
 
 /*
@@ -158,8 +158,8 @@
  * Return values from JobStart.
  */
-#define	JOB_RUNNING	0   	/* Job is running */
-#define	JOB_ERROR 	1   	/* Error in starting the job */
-#define	JOB_FINISHED	2   	/* The job is already finished */
-#define	JOB_STOPPED	3   	/* The job is stopped */
+#define JOB_RUNNING	0   	/* Job is running */
+#define JOB_ERROR 	1   	/* Error in starting the job */
+#define JOB_FINISHED	2   	/* The job is already finished */
+#define JOB_STOPPED	3   	/* The job is stopped */
 
 /*
@@ -196,14 +196,4 @@
     FALSE, "echo \"%s\"\n", "sh -c '%s || exit 0'\n",
 #endif
-    "v", "e",
-},
-    /*
-     * KSH description. The Korn shell has a superset of
-     * the Bourne shell's functionality.
-     */
-{
-    "ksh",
-    TRUE, "set -", "set -v", "set -", 5,
-    TRUE, "set -e", "set +e",
     "v", "e",
 },
@@ -239,10 +229,6 @@
 				 * nLocal equals maxLocal */
 #ifndef RMT_WILL_WATCH
-#ifdef USE_KQUEUE
-static int	kqfd;		/* File descriptor obtained by kqueue() */
-#else
 static fd_set  	outputs;    	/* Set of descriptors of pipes connected to
 				 * the output channels of children */
-#endif
 #endif
 
@@ -290,5 +276,5 @@
  * really ugly, use dramamine sparingly. You have been warned.
  */
-#define	W_SETMASKED(st, val, fun)				\
+#define W_SETMASKED(st, val, fun)				\
 	{							\
 		int sh = (int) ~0;				\
@@ -300,31 +286,31 @@
 	}
 
-#define	W_SETTERMSIG(st, val) W_SETMASKED(st, val, WTERMSIG)
-#define	W_SETEXITSTATUS(st, val) W_SETMASKED(st, val, WEXITSTATUS)
-
-
-static int JobCondPassSig(void *, void *);
-static void JobPassSig(int);
-static int JobCmpPid(void *, void *);
-static int JobPrintCommand(void *, void *);
-static int JobSaveCommand(void *, void *);
-static void JobClose(Job *);
+#define W_SETTERMSIG(st, val) W_SETMASKED(st, val, WTERMSIG)
+#define W_SETEXITSTATUS(st, val) W_SETMASKED(st, val, WEXITSTATUS)
+
+
+static int JobCondPassSig __P((ClientData, ClientData));
+static void JobPassSig __P((int));
+static int JobCmpPid __P((ClientData, ClientData));
+static int JobPrintCommand __P((ClientData, ClientData));
+static int JobSaveCommand __P((ClientData, ClientData));
+static void JobClose __P((Job *));
 #ifdef REMOTE
-static int JobCmpRmtID(Job *, int);
+static int JobCmpRmtID __P((Job *, int));
 # ifdef RMT_WILL_WATCH
-static void JobLocalInput(int, Job *);
+static void JobLocalInput __P((int, Job *));
 # endif
 #else
-static void JobFinish(Job *, int *);
-static void JobExec(Job *, char **);
-#endif
-static void JobMakeArgv(Job *, char **);
-static void JobRestart(Job *);
-static int JobStart(GNode *, int, Job *);
-static char *JobOutput(Job *, char *, char *, int);
-static void JobDoOutput(Job *, Boolean);
-static Shell *JobMatchShell(char *);
-static void JobInterrupt(int, int);
-static void JobRestartJobs(void);
+static void JobFinish __P((Job *, int *));
+static void JobExec __P((Job *, char **));
+#endif
+static void JobMakeArgv __P((Job *, char **));
+static void JobRestart __P((Job *));
+static int JobStart __P((GNode *, int, Job *));
+static char *JobOutput __P((Job *, char *, char *, int));
+static void JobDoOutput __P((Job *, Boolean));
+static Shell *JobMatchShell __P((char *));
+static void JobInterrupt __P((int, int));
+static void JobRestartJobs __P((void));
 
 /*-
@@ -343,5 +329,7 @@
  */
 static int
-JobCondPassSig(void *jobp, void *signop)
+JobCondPassSig(jobp, signop)
+    ClientData	    	jobp;	    /* Job to biff */
+    ClientData	    	signop;	    /* Signal to send it */
 {
     Job	*job = (Job *) jobp;
@@ -358,5 +346,10 @@
      * job as well.
      */
-    DEBUGF(JOB, ("JobCondPassSig passing signal %d to child %d.\n", signo, job->pid));
+    if (DEBUG(JOB)) {
+	(void) fprintf(stdout,
+		       "JobCondPassSig passing signal %d to child %d.\n",
+		       signo, job->pid);
+	(void) fflush(stdout);
+    }
     KILL(job->pid, signo);
 #endif
@@ -379,11 +372,15 @@
  */
 static void
-JobPassSig(int signo)
+JobPassSig(signo)
+    int	    signo;	/* The signal number we've received */
 {
     sigset_t nmask, omask;
     struct sigaction act;
 
-    DEBUGF(JOB, ("JobPassSig(%d) called.\n", signo));
-    Lst_ForEach(jobs, JobCondPassSig, (void *) &signo);
+    if (DEBUG(JOB)) {
+	(void) fprintf(stdout, "JobPassSig(%d) called.\n", signo);
+	(void) fflush(stdout);
+    }
+    Lst_ForEach(jobs, JobCondPassSig, (ClientData) &signo);
 
     /*
@@ -419,5 +416,10 @@
     sigaction(signo, &act, NULL);
 
-    DEBUGF(JOB, ("JobPassSig passing signal to self, mask = %x.\n", ~0 & ~(1 << (signo-1))));
+    if (DEBUG(JOB)) {
+	(void) fprintf(stdout,
+		       "JobPassSig passing signal to self, mask = %x.\n",
+		       ~0 & ~(1 << (signo-1)));
+	(void) fflush(stdout);
+    }
     (void) signal(signo, SIG_DFL);
 
@@ -425,5 +427,5 @@
 
     signo = SIGCONT;
-    Lst_ForEach(jobs, JobCondPassSig, (void *) &signo);
+    Lst_ForEach(jobs, JobCondPassSig, (ClientData) &signo);
 
     (void) sigprocmask(SIG_SETMASK, &omask, NULL);
@@ -448,5 +450,7 @@
  */
 static int
-JobCmpPid(void *job, void *pid)
+JobCmpPid(job, pid)
+    ClientData        job;	/* job to examine */
+    ClientData        pid;	/* process id desired */
 {
     return *(int *) pid - ((Job *) job)->pid;
@@ -468,5 +472,7 @@
  */
 static int
-JobCmpRmtID(void *job, void *rmtID)
+JobCmpRmtID(job, rmtID)
+    ClientData      job;	/* job to examine */
+    ClientData      rmtID;	/* remote id desired */
 {
     return(*(int *) rmtID - *(int *) job->rmtID);
@@ -487,5 +493,5 @@
  *	made and return non-zero to signal that the end of the commands
  *	was reached. These commands are later attached to the postCommands
- *	node and executed by Job_Finish when all things are done.
+ *	node and executed by Job_End when all things are done.
  *	This function is called from JobStart via Lst_ForEach.
  *
@@ -502,5 +508,7 @@
  */
 static int
-JobPrintCommand(void *cmdp, void *jobp)
+JobPrintCommand(cmdp, jobp)
+    ClientData    cmdp;	    	    /* command string to print */
+    ClientData    jobp;	    	    /* job for which to print it */
 {
     Boolean	  noSpecials;	    /* true if we shouldn't worry about
@@ -525,5 +533,5 @@
 	if ((job->flags & JOB_IGNDOTS) == 0) {
 	    job->tailCmds = Lst_Succ(Lst_Member(job->node->commands,
-						(void *)cmd));
+						(ClientData)cmd));
 	    return 1;
 	}
@@ -531,6 +539,8 @@
     }
 
-#define	DBPRINTF(fmt, arg)  			\
-   DEBUGF(JOB, (fmt, arg));			\
+#define DBPRINTF(fmt, arg) if (DEBUG(JOB)) {	\
+	(void) fprintf(stdout, fmt, arg); 	\
+	(void) fflush(stdout); 			\
+    }						\
    (void) fprintf(job->cmdFILE, fmt, arg);	\
    (void) fflush(job->cmdFILE);
@@ -542,7 +552,7 @@
      * the variables in the command.
      */
-    cmdNode = Lst_Member(job->node->commands, (void *)cmd);
+    cmdNode = Lst_Member(job->node->commands, (ClientData)cmd);
     cmdStart = cmd = Var_Subst(NULL, cmd, job->node, FALSE);
-    Lst_Replace(cmdNode, (void *)cmdStart);
+    Lst_Replace(cmdNode, (ClientData)cmdStart);
 
     cmdTemplate = "%s\n";
@@ -659,7 +669,9 @@
  */
 static int
-JobSaveCommand(void *cmd, void *gn)
-{
-    cmd = (void *) Var_Subst(NULL, (char *) cmd, (GNode *) gn, FALSE);
+JobSaveCommand(cmd, gn)
+    ClientData   cmd;
+    ClientData   gn;
+{
+    cmd = (ClientData) Var_Subst(NULL, (char *) cmd, (GNode *) gn, FALSE);
     (void) Lst_AtEnd(postCommands->commands, cmd);
     return(0);
@@ -681,10 +693,11 @@
  */
 static void
-JobClose(Job *job)
+JobClose(job)
+    Job *job;
 {
     if (usePipes) {
 #ifdef RMT_WILL_WATCH
 	Rmt_Ignore(job->inPipe);
-#elif !defined(USE_KQUEUE)
+#else
 	FD_CLR(job->inPipe, &outputs);
 #endif
@@ -725,5 +738,7 @@
 /*ARGSUSED*/
 static void
-JobFinish(Job *job, int *status)
+JobFinish(job, status)
+    Job         *job;	      	  /* job to finish */
+    int	  	*status;     	  /* sub-why job went away */
 {
     Boolean 	 done;
@@ -794,6 +809,4 @@
 	     */
 	    out = fdopen(job->outFd, "w");
-	    if (out == NULL)
-		Punt("Cannot fdopen");
 	} else {
 	    out = stdout;
@@ -801,5 +814,8 @@
 
 	if (WIFEXITED(*status)) {
-	    DEBUGF(JOB, ("Process %d exited.\n", job->pid));
+	    if (DEBUG(JOB)) {
+		(void) fprintf(stdout, "Process %d exited.\n", job->pid);
+		(void) fflush(stdout);
+	    }
 	    if (WEXITSTATUS(*status) != 0) {
 		if (usePipes && job->node != lastNode) {
@@ -822,5 +838,8 @@
 	    }
 	} else if (WIFSTOPPED(*status)) {
-	    DEBUGF(JOB, ("Process %d stopped.\n", job->pid));
+	    if (DEBUG(JOB)) {
+		(void) fprintf(stdout, "Process %d stopped.\n", job->pid);
+		(void) fflush(stdout);
+	    }
 	    if (usePipes && job->node != lastNode) {
 		MESSAGE(out, job->node);
@@ -832,5 +851,5 @@
 	    }
 	    job->flags |= JOB_RESUME;
-	    (void)Lst_AtEnd(stoppedJobs, (void *)job);
+	    (void)Lst_AtEnd(stoppedJobs, (ClientData)job);
 #ifdef REMOTE
 	    if (job->flags & JOB_REMIGRATE)
@@ -853,5 +872,10 @@
 	    }
 	    if (!(job->flags & JOB_CONTINUING)) {
-		DEBUGF(JOB, ("Warning: process %d was not continuing.\n", job->pid));
+		if (DEBUG(JOB)) {
+		    (void) fprintf(stdout,
+				   "Warning: process %d was not continuing.\n",
+				   job->pid);
+		    (void) fflush(stdout);
+		}
 #ifdef notdef
 		/*
@@ -865,13 +889,21 @@
 	    }
 	    job->flags &= ~JOB_CONTINUING;
- 	    Lst_AtEnd(jobs, (void *)job);
+ 	    Lst_AtEnd(jobs, (ClientData)job);
 	    nJobs += 1;
 	    if (!(job->flags & JOB_REMOTE)) {
-		DEBUGF(JOB, ("Process %d is continuing locally.\n", job->pid));
+		if (DEBUG(JOB)) {
+		    (void) fprintf(stdout,
+				   "Process %d is continuing locally.\n",
+				   job->pid);
+		    (void) fflush(stdout);
+  		}
 		nLocal += 1;
 	    }
 	    if (nJobs == maxJobs) {
 		jobFull = TRUE;
-		DEBUGF(JOB, ("Job queue is full.\n"));
+		if (DEBUG(JOB)) {
+		    (void) fprintf(stdout, "Job queue is full.\n");
+		    (void) fflush(stdout);
+  		}
   	    }
 	    (void) fflush(out);
@@ -913,6 +945,4 @@
 	    done = FALSE;
 	    break;
-	default:
-	    break;
 	}
     } else {
@@ -932,15 +962,15 @@
 	 * on the .END target.
 	 */
-	if (job->tailCmds != NULL) {
+	if (job->tailCmds != NILLNODE) {
 	    Lst_ForEachFrom(job->node->commands, job->tailCmds,
 			     JobSaveCommand,
-			    (void *)job->node);
+			    (ClientData)job->node);
 	}
 	job->node->made = MADE;
 	Make_Update(job->node);
-	free(job);
+	free((Address)job);
     } else if (*status != 0) {
 	errors += 1;
-	free(job);
+	free((Address)job);
     }
 
@@ -970,5 +1000,5 @@
  * Job_Touch --
  *	Touch the given target. Called by JobStart when the -t flag was
- *	given.  Prints messages unless told to be silent.
+ *	given
  *
  * Results:
@@ -981,5 +1011,7 @@
  */
 void
-Job_Touch(GNode *gn, Boolean silent)
+Job_Touch(gn, silent)
+    GNode         *gn;	      	/* the node of the file to touch */
+    Boolean 	  silent;   	/* TRUE if should not print messages */
 {
     int		  streamID;   	/* ID of stream opened to do the touch */
@@ -1022,5 +1054,5 @@
 		 */
 		if (read(streamID, &c, 1) == 1) {
-		    (void) lseek(streamID, (off_t)0, SEEK_SET);
+		    (void) lseek(streamID, 0L, SEEK_SET);
 		    (void) write(streamID, &c, 1);
 		}
@@ -1050,5 +1082,9 @@
  */
 Boolean
-Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
+Job_CheckCommands(gn, abortProc)
+    GNode          *gn;	    	    /* The target whose commands need
+				     * verifying */
+    void    	 (*abortProc) __P((char *, ...));
+			/* Function to abort with message */
 {
     if (OP_NOP(gn->type) && Lst_IsEmpty(gn->commands) &&
@@ -1058,5 +1094,5 @@
 	 * commands
 	 */
-	if ((DEFAULT != NULL) && !Lst_IsEmpty(DEFAULT->commands)) {
+	if ((DEFAULT != NILGNODE) && !Lst_IsEmpty(DEFAULT->commands)) {
 	    char *p1;
 	    /*
@@ -1118,5 +1154,7 @@
 /*ARGSUSED*/
 static void
-JobLocalInput(int stream, Job *job)
+JobLocalInput(stream, job)
+    int	    stream; 	/* Stream that's ready (ignored) */
+    Job	    *job;   	/* Job to which the stream belongs */
 {
     JobDoOutput(job, FALSE);
@@ -1140,5 +1178,7 @@
  */
 static void
-JobExec(Job *job, char **argv)
+JobExec(job, argv)
+    Job	    	  *job; 	/* Job to execute */
+    char    	  **argv;
 {
     int	    	  cpid;	    	/* ID of new child */
@@ -1147,11 +1187,12 @@
 	int 	  i;
 
-	DEBUGF(JOB, ("Running %s %sly\n", job->node->name,
-	       job->flags&JOB_REMOTE?"remote":"local"));
-	DEBUGF(JOB, ("\tCommand: "));
+	(void) fprintf(stdout, "Running %s %sly\n", job->node->name,
+		       job->flags&JOB_REMOTE?"remote":"local");
+	(void) fprintf(stdout, "\tCommand: ");
 	for (i = 0; argv[i] != NULL; i++) {
-	    DEBUGF(JOB, ("%s ", argv[i]));
-	}
-	DEBUGF(JOB, ("\n"));
+	    (void) fprintf(stdout, "%s ", argv[i]);
+	}
+ 	(void) fprintf(stdout, "\n");
+ 	(void) fflush(stdout);
     }
 
@@ -1186,5 +1227,5 @@
 	    Punt("Cannot dup2: %s", strerror(errno));
 	(void) fcntl(0, F_SETFD, 0);
-	(void) lseek(0, (off_t)0, SEEK_SET);
+	(void) lseek(0, 0, SEEK_SET);
 
 	if (usePipes) {
@@ -1234,5 +1275,5 @@
 	   (void) execv(shellPath, argv);
 
-	(void) write(STDERR_FILENO, "Could not execute shell\n",
+	(void) write(2, "Could not execute shell\n",
 		     sizeof("Could not execute shell"));
 	_exit(1);
@@ -1249,20 +1290,8 @@
 	     * stream to watch in the outputs mask
 	     */
-#ifdef USE_KQUEUE
-	    struct kevent	kev[2];
-#endif
 	    job->curPos = 0;
 
 #ifdef RMT_WILL_WATCH
 	    Rmt_Watch(job->inPipe, JobLocalInput, job);
-#elif defined(USE_KQUEUE)
-	    EV_SET(&kev[0], job->inPipe, EVFILT_READ, EV_ADD, 0, 0, job);
-	    EV_SET(&kev[1], job->pid, EVFILT_PROC, EV_ADD | EV_ONESHOT,
-		NOTE_EXIT, 0, NULL);
-	    if (kevent(kqfd, kev, 2, NULL, 0, NULL) != 0) {
-		/* kevent() will fail if the job is already finished */
-		if (errno != EBADF && errno != ESRCH)
-		    Punt("kevent: %s", strerror(errno));
-	    }
 #else
 	    FD_SET(job->inPipe, &outputs);
@@ -1298,5 +1327,5 @@
      */
     nJobs += 1;
-    (void) Lst_AtEnd(jobs, (void *)job);
+    (void) Lst_AtEnd(jobs, (ClientData)job);
     if (nJobs == maxJobs) {
 	jobFull = TRUE;
@@ -1317,5 +1346,7 @@
  */
 static void
-JobMakeArgv(Job *job, char **argv)
+JobMakeArgv(job, argv)
+    Job	    	  *job;
+    char	  **argv;
 {
     int	    	  argc;
@@ -1371,5 +1402,6 @@
  */
 static void
-JobRestart(Job *job)
+JobRestart(job)
+    Job 	  *job;    	/* Job to restart */
 {
 #ifdef REMOTE
@@ -1430,7 +1462,10 @@
 		   (void) fflush(stdout);
   		}
-		(void)Lst_AtFront(stoppedJobs, (void *)job);
+		(void)Lst_AtFront(stoppedJobs, (ClientData)job);
 		jobFull = TRUE;
-		DEBUGF(JOB, ("Job queue is full.\n"));
+		if (DEBUG(JOB)) {
+		   (void) fprintf(stdout, "Job queue is full.\n");
+		   (void) fflush(stdout);
+		}
 		return;
 	    }
@@ -1448,9 +1483,12 @@
 #endif
 
-	(void)Lst_AtEnd(jobs, (void *)job);
+	(void)Lst_AtEnd(jobs, (ClientData)job);
 	nJobs += 1;
 	if (nJobs == maxJobs) {
 	    jobFull = TRUE;
-	    DEBUGF(JOB, ("Job queue is full.\n"));
+	    if (DEBUG(JOB)) {
+		(void) fprintf(stdout, "Job queue is full.\n");
+		(void) fflush(stdout);
+	    }
 	}
     } else if (job->flags & JOB_RESTART) {
@@ -1467,5 +1505,8 @@
 	JobMakeArgv(job, argv);
 
-	DEBUGF(JOB, ("Restarting %s...", job->node->name));
+	if (DEBUG(JOB)) {
+	    (void) fprintf(stdout, "Restarting %s...", job->node->name);
+	    (void) fflush(stdout);
+	}
 #ifdef REMOTE
 	if ((job->node->type&OP_NOEXPORT) ||
@@ -1483,8 +1524,14 @@
 		 * back on the hold queue and mark the table full
 		 */
-		DEBUGF(JOB, ("holding\n"));
-		(void)Lst_AtFront(stoppedJobs, (void *)job);
+		if (DEBUG(JOB)) {
+		    (void) fprintf(stdout, "holding\n");
+		    (void) fflush(stdout);
+		}
+		(void)Lst_AtFront(stoppedJobs, (ClientData)job);
 		jobFull = TRUE;
-		DEBUGF(JOB, ("Job queue is full.\n"));
+		if (DEBUG(JOB)) {
+		    (void) fprintf(stdout, "Job queue is full.\n");
+		    (void) fflush(stdout);
+		}
 		return;
 	    } else {
@@ -1492,5 +1539,8 @@
 		 * Job may be run locally.
 		 */
-		DEBUGF(JOB, ("running locally\n"));
+		if (DEBUG(JOB)) {
+		    (void) fprintf(stdout, "running locally\n");
+		    (void) fflush(stdout);
+		}
 		job->flags &= ~JOB_REMOTE;
 	    }
@@ -1501,5 +1551,8 @@
 	     * Can be exported. Hooray!
 	     */
-	    DEBUGF(JOB, ("exporting\n"));
+	    if (DEBUG(JOB)) {
+		(void) fprintf(stdout, "exporting\n");
+		(void) fflush(stdout);
+	    }
 	    job->flags |= JOB_REMOTE;
 	}
@@ -1511,5 +1564,8 @@
 	 * we don't know...
 	 */
-	DEBUGF(JOB, ("Resuming %s...", job->node->name));
+	if (DEBUG(JOB)) {
+	   (void) fprintf(stdout, "Resuming %s...", job->node->name);
+	   (void) fflush(stdout);
+	}
 	if (((job->flags & JOB_REMOTE) ||
 	    (nLocal < maxLocal) ||
@@ -1551,5 +1607,8 @@
 
 		job->flags &= ~(JOB_RESUME|JOB_CONTINUING);
-		DEBUGF(JOB, ("done\n"));
+		if (DEBUG(JOB)) {
+		   (void) fprintf(stdout, "done\n");
+		   (void) fflush(stdout);
+		}
 	    } else {
 		Error("couldn't resume %s: %s",
@@ -1564,8 +1623,14 @@
 	     * place the job back on the list of stopped jobs.
 	     */
-	    DEBUGF(JOB, ("table full\n"));
-	    (void) Lst_AtFront(stoppedJobs, (void *)job);
+	    if (DEBUG(JOB)) {
+		(void) fprintf(stdout, "table full\n");
+		(void) fflush(stdout);
+	    }
+	    (void) Lst_AtFront(stoppedJobs, (ClientData)job);
 	    jobFull = TRUE;
-	    DEBUGF(JOB, ("Job queue is full.\n"));
+	    if (DEBUG(JOB)) {
+		(void) fprintf(stdout, "Job queue is full.\n");
+		(void) fflush(stdout);
+	    }
 	}
     }
@@ -1589,7 +1654,12 @@
  */
 static int
-JobStart(GNode *gn, int flags, Job *previous)
-{
-    Job	  	  *job;       /* new job descriptor */
+JobStart(gn, flags, previous)
+    GNode         *gn;	      /* target to create */
+    int	  	   flags;      /* flags for the job to override normal ones.
+			       * e.g. JOB_SPECIAL or JOB_IGNDOTS */
+    Job 	  *previous;  /* The previous Job structure for this node,
+			       * if any. */
+{
+    register Job  *job;       /* new job descriptor */
     char	  *argv[4];   /* Argument vector to shell */
     Boolean	  cmdsOK;     /* true if the nodes commands were all right */
@@ -1603,9 +1673,12 @@
     } else {
 	job = (Job *) emalloc(sizeof(Job));
+	if (job == NULL) {
+	    Punt("JobStart out of memory");
+	}
 	flags |= JOB_FIRST;
     }
 
     job->node = gn;
-    job->tailCmds = NULL;
+    job->tailCmds = NILLNODE;
 
     /*
@@ -1682,7 +1755,7 @@
 		LstNode	ln = Lst_Next(gn->commands);
 
-		if ((ln == NULL) ||
-		    JobPrintCommand((void *) Lst_Datum(ln),
-				    (void *) job))
+		if ((ln == NILLNODE) ||
+		    JobPrintCommand((ClientData) Lst_Datum(ln),
+				    (ClientData) job))
 		{
 		    noExec = TRUE;
@@ -1709,5 +1782,5 @@
 	     */
 	    numCommands = 0;
-	    Lst_ForEach(gn->commands, JobPrintCommand, (void *)job);
+	    Lst_ForEach(gn->commands, JobPrintCommand, (ClientData)job);
 
 	    /*
@@ -1735,5 +1808,5 @@
 	 */
 	if (cmdsOK) {
-	    Lst_ForEach(gn->commands, JobPrintCommand, (void *)job);
+	    Lst_ForEach(gn->commands, JobPrintCommand, (ClientData)job);
 	}
 	/*
@@ -1773,16 +1846,16 @@
 	if (cmdsOK) {
 	    if (aborting == 0) {
-		if (job->tailCmds != NULL) {
+		if (job->tailCmds != NILLNODE) {
 		    Lst_ForEachFrom(job->node->commands, job->tailCmds,
 				    JobSaveCommand,
-				   (void *)job->node);
+				   (ClientData)job->node);
 		}
 		job->node->made = MADE;
 		Make_Update(job->node);
 	    }
-	    free(job);
+	    free((Address)job);
 	    return(JOB_FINISHED);
 	} else {
-	    free(job);
+	    free((Address)job);
 	    return(JOB_ERROR);
 	}
@@ -1855,7 +1928,10 @@
 	jobFull = TRUE;
 
-	DEBUGF(JOB, ("Can only run job locally.\n"));
+	if (DEBUG(JOB)) {
+	   (void) fprintf(stdout, "Can only run job locally.\n");
+	   (void) fflush(stdout);
+	}
 	job->flags |= JOB_RESTART;
-	(void) Lst_AtEnd(stoppedJobs, (void *)job);
+	(void) Lst_AtEnd(stoppedJobs, (ClientData)job);
     } else {
 	if ((nLocal >= maxLocal) && local) {
@@ -1865,5 +1941,8 @@
 	     */
 	    jobFull = TRUE;
-	    DEBUGF(JOB, ("Local job queue is full.\n"));
+	    if (DEBUG(JOB)) {
+		(void) fprintf(stdout, "Local job queue is full.\n");
+		(void) fflush(stdout);
+	    }
 	}
 	JobExec(job, argv);
@@ -1873,7 +1952,10 @@
 
 static char *
-JobOutput(Job *job, char *cp, char *endp, int msg)
-{
-    char *ecp;
+JobOutput(job, cp, endp, msg)
+    register Job *job;
+    register char *cp, *endp;
+    int msg;
+{
+    register char *ecp;
 
     if (commandShell->noPrint) {
@@ -1943,11 +2025,14 @@
  */
 STATIC void
-JobDoOutput(Job *job, Boolean finish)
+JobDoOutput(job, finish)
+    register Job   *job;	  /* the job whose output needs printing */
+    Boolean	   finish;	  /* TRUE if this is the last time we'll be
+				   * called for this job */
 {
     Boolean       gotNL = FALSE;  /* true if got a newline */
     Boolean       fbuf;  	  /* true if our buffer filled up */
-    int		  nr;	      	  /* number of bytes read */
-    int		  i;	      	  /* auxiliary index into outBuf */
-    int		  max;	      	  /* limit for i (end of current data) */
+    register int  nr;	      	  /* number of bytes read */
+    register int  i;	      	  /* auxiliary index into outBuf */
+    register int  max;	      	  /* limit for i (end of current data) */
     int		  nRead;      	  /* (Temporary) number of bytes read */
 
@@ -1967,5 +2052,7 @@
 			 JOB_BUFSIZE - job->curPos);
 	if (nRead < 0) {
-	    DEBUGF(JOB, ("JobDoOutput(piperead)"));
+	    if (DEBUG(JOB)) {
+		perror("JobDoOutput(piperead)");
+	    }
 	    nr = 0;
 	} else {
@@ -2021,5 +2108,5 @@
 	     * first, overwriting the newline character if there was one.
 	     * So long as the line isn't one we should filter (according
-	     * to the shell description), we print the line, preceded
+	     * to the shell description), we print the line, preceeded
 	     * by a target banner if this target isn't the same as the
 	     * one for which we last printed something.
@@ -2087,5 +2174,5 @@
 	    (void) fflush(stdout);
 	    while (fgets(inLine, sizeof(inLine), oFILE) != NULL) {
-		char	*cp, *endp, *oendp;
+		register char	*cp, *endp, *oendp;
 
 		cp = inLine;
@@ -2134,8 +2221,9 @@
  */
 void
-Job_CatchChildren(Boolean block)
+Job_CatchChildren(block)
+    Boolean	  block;    	/* TRUE if should block on the wait. */
 {
     int    	  pid;	    	/* pid of dead child */
-    Job		  *job;	    	/* job descriptor for dead child */
+    register Job  *job;	    	/* job descriptor for dead child */
     LstNode       jnode;    	/* list element for finding job */
     int	  	  status;   	/* Exit/termination status */
@@ -2151,12 +2239,16 @@
 			  (block?0:WNOHANG)|WUNTRACED)) > 0)
     {
-	DEBUGF(JOB, ("Process %d exited or stopped.\n", pid));
-
-	jnode = Lst_Find(jobs, (void *)&pid, JobCmpPid);
-
-	if (jnode == NULL) {
+	if (DEBUG(JOB)) {
+	    (void) fprintf(stdout, "Process %d exited or stopped.\n", pid);
+	    (void) fflush(stdout);
+	}
+
+
+	jnode = Lst_Find(jobs, (ClientData)&pid, JobCmpPid);
+
+	if (jnode == NILLNODE) {
 	    if (WIFSIGNALED(status) && (WTERMSIG(status) == SIGCONT)) {
-		jnode = Lst_Find(stoppedJobs, (void *) &pid, JobCmpPid);
-		if (jnode == NULL) {
+		jnode = Lst_Find(stoppedJobs, (ClientData) &pid, JobCmpPid);
+		if (jnode == NILLNODE) {
 		    Error("Resumed child (%d) not in table", pid);
 		    continue;
@@ -2172,9 +2264,16 @@
 	    (void) Lst_Remove(jobs, jnode);
 	    nJobs -= 1;
-	    DEBUGF(JOB, ("Job queue is no longer full.\n"));
+	    if (jobFull && DEBUG(JOB)) {
+		(void) fprintf(stdout, "Job queue is no longer full.\n");
+		(void) fflush(stdout);
+	    }
 	    jobFull = FALSE;
 #ifdef REMOTE
 	    if (!(job->flags & JOB_REMOTE)) {
-		DEBUGF(JOB, ("Job queue has one fewer local process.\n"));
+		if (DEBUG(JOB)) {
+		    (void) fprintf(stdout,
+				   "Job queue has one fewer local process.\n");
+		    (void) fflush(stdout);
+		}
 		nLocal -= 1;
 	    }
@@ -2205,17 +2304,11 @@
  */
 void
-Job_CatchOutput(void)
+Job_CatchOutput()
 {
     int           	  nfds;
-#ifdef USE_KQUEUE
-#define KEV_SIZE	4
-    struct kevent	  kev[KEV_SIZE];
-    int			  i;
-#else
     struct timeval	  timeout;
     fd_set           	  readfds;
-    LstNode		  ln;
-    Job		   	  *job;
-#endif
+    register LstNode	  ln;
+    register Job   	  *job;
 #ifdef RMT_WILL_WATCH
     int	    	  	  pnJobs;   	/* Previous nJobs */
@@ -2247,25 +2340,4 @@
 #else
     if (usePipes) {
-#ifdef USE_KQUEUE
-	if ((nfds = kevent(kqfd, NULL, 0, kev, KEV_SIZE, NULL)) == -1) {
-	    Punt("kevent: %s", strerror(errno));
-	} else {
-	    for (i = 0; i < nfds; i++) {
-		if (kev[i].flags & EV_ERROR) {
-		    warnc(kev[i].data, "kevent");
-		    continue;
-		}
-		switch (kev[i].filter) {
-		case EVFILT_READ:
-		    JobDoOutput(kev[i].udata, FALSE);
-		    break;
-		case EVFILT_PROC:
-		    /* Just wake up and let Job_CatchChildren() collect the
-		     * terminated job. */
-		    break;
-		}
-	    }
-	}
-#else
 	readfds = outputs;
 	timeout.tv_sec = SEL_SEC;
@@ -2279,5 +2351,5 @@
 		Punt("Cannot open job table");
 	    }
-	    while (nfds && (ln = Lst_Next(jobs)) != NULL) {
+	    while (nfds && (ln = Lst_Next(jobs)) != NILLNODE) {
 		job = (Job *) Lst_Datum(ln);
 		if (FD_ISSET(job->inPipe, &readfds)) {
@@ -2288,5 +2360,4 @@
 	    Lst_Close(jobs);
 	}
-#endif /* !USE_KQUEUE */
     }
 #endif /* RMT_WILL_WATCH */
@@ -2308,5 +2379,6 @@
  */
 void
-Job_Make(GNode *gn)
+Job_Make(gn)
+    GNode   *gn;
 {
     (void) JobStart(gn, 0, NULL);
@@ -2316,6 +2388,5 @@
  *-----------------------------------------------------------------------
  * Job_Init --
- *	Initialize the process module, given a maximum number of jobs, and
- *	a maximum number of local jobs.
+ *	Initialize the process module
  *
  * Results:
@@ -2327,5 +2398,9 @@
  */
 void
-Job_Init(int maxproc, int maxlocal)
+Job_Init(maxproc, maxlocal)
+    int           maxproc;  /* the greatest number of jobs which may be
+			     * running at one time */
+    int	    	  maxlocal; /* the greatest number of local jobs which may
+			     * be running at once. */
 {
     GNode         *begin;     /* node for commands to do at the very start */
@@ -2342,5 +2417,5 @@
     errors = 	  0;
 
-    lastNode =	  NULL;
+    lastNode =	  NILGNODE;
 
     if (maxJobs == 1 || beVerbose == 0
@@ -2414,13 +2489,7 @@
 #endif
 
-#ifdef USE_KQUEUE
-    if ((kqfd = kqueue()) == -1) {
-	Punt("kqueue: %s", strerror(errno));
-    }
-#endif
-
     begin = Targ_FindNode(".BEGIN", TARG_NOCREATE);
 
-    if (begin != NULL) {
+    if (begin != NILGNODE) {
 	JobStart(begin, JOB_SPECIAL, (Job *)0);
 	while (nJobs) {
@@ -2449,5 +2518,5 @@
  */
 Boolean
-Job_Full(void)
+Job_Full()
 {
     return(aborting || jobFull);
@@ -2471,5 +2540,5 @@
  */
 Boolean
-Job_Empty(void)
+Job_Empty()
 {
     if (nJobs == 0) {
@@ -2504,9 +2573,10 @@
  */
 static Shell *
-JobMatchShell(char *name)
-{
-    Shell	  *sh;	      /* Pointer into shells table */
-    Shell	  *match;     /* Longest-matching shell */
-    char	  *cp1,
+JobMatchShell(name)
+    char	  *name;      /* Final component of shell path */
+{
+    register Shell *sh;	      /* Pointer into shells table */
+    Shell	   *match;    /* Longest-matching shell */
+    register char *cp1,
 		  *cp2;
     char	  *eoname;
@@ -2575,20 +2645,21 @@
  */
 ReturnStatus
-Job_ParseShell(char *line)
+Job_ParseShell(line)
+    char	  *line;  /* The shell spec */
 {
     char    	  **words;
     int	    	  wordCount;
-    char	  **argv;
-    int		  argc;
+    register char **argv;
+    register int  argc;
     char    	  *path;
     Shell   	  newShell;
     Boolean 	  fullSpec = FALSE;
 
-    while (isspace((unsigned char) *line)) {
+    while (isspace(*line)) {
 	line++;
     }
     words = brk_string(line, &wordCount, TRUE);
 
-    memset(&newShell, 0, sizeof(newShell));
+    memset((Address)&newShell, 0, sizeof(newShell));
 
     /*
@@ -2686,4 +2757,9 @@
     }
 
+    /*
+     * Do not free up the words themselves, since they might be in use by the
+     * shell specification...
+     */
+    free(words);
     return SUCCESS;
 }
@@ -2703,5 +2779,8 @@
  */
 static void
-JobInterrupt(int runINTERRUPT, int signo)
+JobInterrupt(runINTERRUPT, signo)
+    int	    runINTERRUPT;   	/* Non-zero if commands for the .INTERRUPT
+				 * target should be executed */
+    int	    signo;		/* signal received */
 {
     LstNode 	  ln;		/* element in job table */
@@ -2711,6 +2790,6 @@
     aborting = ABORT_INTERRUPT;
 
-    (void) Lst_Open(jobs);
-    while ((ln = Lst_Next(jobs)) != NULL) {
+   (void) Lst_Open(jobs);
+    while ((ln = Lst_Next(jobs)) != NILLNODE) {
 	job = (Job *) Lst_Datum(ln);
 
@@ -2744,6 +2823,10 @@
 #else
 	if (job->pid) {
-	    DEBUGF(JOB, ("JobInterrupt passing signal to child %d.\n",
-		   job->pid));
+	    if (DEBUG(JOB)) {
+		(void) fprintf(stdout,
+			       "JobInterrupt passing signal to child %d.\n",
+			       job->pid);
+		(void) fflush(stdout);
+	    }
 	    KILL(job->pid, signo);
 	}
@@ -2752,11 +2835,15 @@
 
 #ifdef REMOTE
-    (void)Lst_Open(stoppedJobs);
-    while ((ln = Lst_Next(stoppedJobs)) != NULL) {
+   (void)Lst_Open(stoppedJobs);
+    while ((ln = Lst_Next(stoppedJobs)) != NILLNODE) {
 	job = (Job *) Lst_Datum(ln);
 
 	if (job->flags & JOB_RESTART) {
-	    DEBUGF(JOB, "JobInterrupt skipping job on stopped queue"
-		   "-- it was waiting to be restarted.\n");
+	    if (DEBUG(JOB)) {
+		(void) fprintf(stdout, "%s%s",
+			       "JobInterrupt skipping job on stopped queue",
+			       "-- it was waiting to be restarted.\n");
+		(void) fflush(stdout);
+	    }
 	    continue;
 	}
@@ -2772,5 +2859,10 @@
 	 * Resume the thing so it will take the signal.
 	 */
-	DEBUGF(JOB, ("JobInterrupt passing CONT to stopped child %d.\n", job->pid));
+	if (DEBUG(JOB)) {
+	    (void) fprintf(stdout,
+			   "JobInterrupt passing CONT to stopped child %d.\n",
+			   job->pid);
+	    (void) fflush(stdout);
+	}
 	KILL(job->pid, SIGCONT);
 #ifdef RMT_WANTS_SIGNALS
@@ -2790,6 +2882,10 @@
 	    }
 	} else if (job->pid) {
-	    DEBUGF(JOB, "JobInterrupt passing interrupt to stopped child %d.\n",
-		   job->pid);
+	    if (DEBUG(JOB)) {
+		(void) fprintf(stdout,
+		       "JobInterrupt passing interrupt to stopped child %d.\n",
+			       job->pid);
+		(void) fflush(stdout);
+	    }
 	    KILL(job->pid, SIGINT);
 	}
@@ -2801,5 +2897,5 @@
     if (runINTERRUPT && !touchFlag) {
 	interrupt = Targ_FindNode(".INTERRUPT", TARG_NOCREATE);
-	if (interrupt != NULL) {
+	if (interrupt != NILGNODE) {
 	    ignoreErrors = FALSE;
 
@@ -2817,5 +2913,5 @@
 /*
  *-----------------------------------------------------------------------
- * Job_Finish --
+ * Job_End --
  *	Do final processing such as the running of the commands
  *	attached to the .END target.
@@ -2826,7 +2922,7 @@
  */
 int
-Job_Finish(void)
-{
-    if (postCommands != NULL && !Lst_IsEmpty(postCommands->commands)) {
+Job_End()
+{
+    if (postCommands != NILGNODE && !Lst_IsEmpty(postCommands->commands)) {
 	if (errors) {
 	    Error("Errors reported so .END ignored");
@@ -2860,5 +2956,5 @@
  */
 void
-Job_Wait(void)
+Job_Wait()
 {
     aborting = ABORT_WAIT;
@@ -2887,5 +2983,5 @@
  */
 void
-Job_AbortAll(void)
+Job_AbortAll()
 {
     LstNode           	ln;	/* element in job table */
@@ -2898,5 +2994,5 @@
 
 	(void) Lst_Open(jobs);
-	while ((ln = Lst_Next(jobs)) != NULL) {
+	while ((ln = Lst_Next(jobs)) != NILLNODE) {
 	    job = (Job *) Lst_Datum(ln);
 
@@ -2932,6 +3028,5 @@
  * JobFlagForMigration --
  *	Handle the eviction of a child. Called from RmtStatusChange.
- *	Flags the child as remigratable and then suspends it.  Takes
- *	the ID of the host we used, for matching children.
+ *	Flags the child as remigratable and then suspends it.
  *
  * Results:
@@ -2944,15 +3039,19 @@
  */
 void
-JobFlagForMigration(int hostID)
-{
-    Job		  *job;	    	/* job descriptor for dead child */
+JobFlagForMigration(hostID)
+    int 	  hostID;    	/* ID of host we used, for matching children. */
+{
+    register Job  *job;	    	/* job descriptor for dead child */
     LstNode       jnode;    	/* list element for finding job */
 
-    DEBUGF(JOB, ("JobFlagForMigration(%d) called.\n", hostID));
-    jnode = Lst_Find(jobs, (void *)hostID, JobCmpRmtID);
-
-    if (jnode == NULL) {
-	jnode = Lst_Find(stoppedJobs, (void *)hostID, JobCmpRmtID);
-		if (jnode == NULL) {
+    if (DEBUG(JOB)) {
+	(void) fprintf(stdout, "JobFlagForMigration(%d) called.\n", hostID);
+	(void) fflush(stdout);
+    }
+    jnode = Lst_Find(jobs, (ClientData)hostID, JobCmpRmtID);
+
+    if (jnode == NILLNODE) {
+	jnode = Lst_Find(stoppedJobs, (ClientData)hostID, JobCmpRmtID);
+		if (jnode == NILLNODE) {
 		    if (DEBUG(JOB)) {
 			Error("Evicting host(%d) not in table", hostID);
@@ -2963,5 +3062,10 @@
     job = (Job *) Lst_Datum(jnode);
 
-    DEBUGF(JOB, ("JobFlagForMigration(%d) found job '%s'.\n", hostID, job->node->name));
+    if (DEBUG(JOB)) {
+	(void) fprintf(stdout,
+		       "JobFlagForMigration(%d) found job '%s'.\n", hostID,
+		       job->node->name);
+	(void) fflush(stdout);
+    }
 
     KILL(job->pid, SIGSTOP);
@@ -2989,8 +3093,12 @@
  */
 static void
-JobRestartJobs(void)
+JobRestartJobs()
 {
     while (!jobFull && !Lst_IsEmpty(stoppedJobs)) {
-	DEBUGF(JOB, ("Job queue is not full. Restarting a stopped job.\n"));
+	if (DEBUG(JOB)) {
+	    (void) fprintf(stdout,
+		       "Job queue is not full. Restarting a stopped job.\n");
+	    (void) fflush(stdout);
+	}
 	JobRestart((Job *)Lst_DeQueue(stoppedJobs));
     }
Index: /trunk/src/kmk/job.h
===================================================================
--- /trunk/src/kmk/job.h	(revision 24)
+++ /trunk/src/kmk/job.h	(revision 25)
@@ -1,5 +1,4 @@
 /*
- * Copyright (c) 1988, 1989, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
  * Copyright (c) 1988, 1989 by Adam de Boor
  * Copyright (c) 1989 by Berkeley Softworks
@@ -37,6 +36,6 @@
  * SUCH DAMAGE.
  *
- *	@(#)job.h	8.1 (Berkeley) 6/6/93
- * $FreeBSD: src/usr.bin/make/job.h,v 1.20 2002/10/09 01:56:02 jmallett Exp $
+ *	from: @(#)job.h	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/job.h,v 1.11 2000/01/17 06:43:41 kris Exp $
  */
 
@@ -47,9 +46,8 @@
  */
 #ifndef _JOB_H_
-#define	_JOB_H_
-
-#define	TMPPAT	"/tmp/makeXXXXXXXXXX"
-
-#ifndef USE_KQUEUE
+#define _JOB_H_
+
+#define TMPPAT	"/tmp/makeXXXXXXXXXX"
+
 /*
  * The SEL_ constants determine the maximum amount of time spent in select
@@ -57,7 +55,6 @@
  * seconds and SEL_USEC is the number of micro-seconds
  */
-#define	SEL_SEC		0
-#define	SEL_USEC	100000
-#endif /* !USE_KQUEUE */
+#define SEL_SEC		0
+#define SEL_USEC	100000
 
 
@@ -70,5 +67,5 @@
  *	2) The graph node describing the target being made by this job
  *	3) A LstNode for the first command to be saved after the job
- *	   completes. This is NULL if there was no "..." in the job's
+ *	   completes. This is NILLNODE if there was no "..." in the job's
  *	   commands.
  *	4) An FILE* for writing out the commands. This is only
@@ -95,5 +92,5 @@
  * traversal of the dependency graph.
  */
-#define	JOB_BUFSIZE	1024
+#define JOB_BUFSIZE	1024
 typedef struct Job {
     int       	pid;	    /* The child's process ID */
@@ -109,15 +106,15 @@
 #define	JOB_IGNERR	0x001	/* Ignore non-zero exits */
 #define	JOB_SILENT	0x002	/* no output */
-#define	JOB_SPECIAL	0x004	/* Target is a special one. i.e. run it locally
+#define JOB_SPECIAL	0x004	/* Target is a special one. i.e. run it locally
 				 * if we can't export it and maxLocal is 0 */
-#define	JOB_IGNDOTS	0x008  	/* Ignore "..." lines when processing
+#define JOB_IGNDOTS	0x008  	/* Ignore "..." lines when processing
 				 * commands */
-#define	JOB_REMOTE	0x010	/* Job is running remotely */
-#define	JOB_FIRST	0x020	/* Job is first job for the node */
-#define	JOB_REMIGRATE	0x040	/* Job needs to be remigrated */
-#define	JOB_RESTART	0x080	/* Job needs to be completely restarted */
-#define	JOB_RESUME	0x100	/* Job needs to be resumed b/c it stopped,
+#define JOB_REMOTE	0x010	/* Job is running remotely */
+#define JOB_FIRST	0x020	/* Job is first job for the node */
+#define JOB_REMIGRATE	0x040	/* Job needs to be remigrated */
+#define JOB_RESTART	0x080	/* Job needs to be completely restarted */
+#define JOB_RESUME	0x100	/* Job needs to be resumed b/c it stopped,
 				 * for some reason */
-#define	JOB_CONTINUING	0x200	/* We are in the process of resuming this job.
+#define JOB_CONTINUING	0x200	/* We are in the process of resuming this job.
 				 * Used to avoid infinite recursion between
 				 * JobFinish and JobRestart */
@@ -148,10 +145,10 @@
 } Job;
 
-#define	outPipe	  	output.o_pipe.op_outPipe
-#define	inPipe	  	output.o_pipe.op_inPipe
-#define	outBuf		output.o_pipe.op_outBuf
-#define	curPos		output.o_pipe.op_curPos
-#define	outFile		output.o_file.of_outFile
-#define	outFd	  	output.o_file.of_outFd
+#define outPipe	  	output.o_pipe.op_outPipe
+#define inPipe	  	output.o_pipe.op_inPipe
+#define outBuf		output.o_pipe.op_outBuf
+#define curPos		output.o_pipe.op_curPos
+#define outFile		output.o_file.of_outFile
+#define outFd	  	output.o_file.of_outFd
 
 
@@ -208,9 +205,5 @@
 }               Shell;
 
-/*
- * If REMOTE is defined then these things need exposed, otherwise they are
- * static to job.c!
- */
-#ifdef REMOTE
+
 extern char 	*targFmt;   	/* Format string for banner that separates
 				 * output from multiple jobs. Contains a
@@ -227,22 +220,19 @@
 				 * quite get started */
 extern Boolean	jobFull;    	/* Non-zero if no more jobs should/will start*/
-#endif
-
-extern int	maxJobs;	/* Number of jobs that may run */
-
-
-void Job_Touch(GNode *, Boolean);
-Boolean Job_CheckCommands(GNode *, void (*abortProc)(const char *, ...));
-void Job_CatchChildren(Boolean);
-void Job_CatchOutput(void);
-void Job_Make(GNode *);
-void Job_Init(int, int);
-Boolean Job_Full(void);
-Boolean Job_Empty(void);
-ReturnStatus Job_ParseShell(char *);
-int Job_Finish(void);
-void Job_Wait(void);
-void Job_AbortAll(void);
-void JobFlagForMigration(int);
+
+
+void Job_Touch __P((GNode *, Boolean));
+Boolean Job_CheckCommands __P((GNode *, void (*abortProc )(char *, ...)));
+void Job_CatchChildren __P((Boolean));
+void Job_CatchOutput __P((void));
+void Job_Make __P((GNode *));
+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));
+void Job_Wait __P((void));
+void Job_AbortAll __P((void));
+void JobFlagForMigration __P((int));
 
 #endif /* _JOB_H_ */
Index: /trunk/src/kmk/list.h
===================================================================
--- /trunk/src/kmk/list.h	(revision 24)
+++ /trunk/src/kmk/list.h	(revision 25)
@@ -1,5 +1,4 @@
 /*
- * Copyright (c) 1988, 1989, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
  * Copyright (c) 1988, 1989 by Adam de Boor
  * Copyright (c) 1989 by Berkeley Softworks
@@ -37,6 +36,6 @@
  * SUCH DAMAGE.
  *
- *	@(#)list.h	8.2 (Berkeley) 4/28/95
- * $FreeBSD: src/usr.bin/make/list.h,v 1.11 2002/09/17 21:29:06 jmallett Exp $
+ *	from: @(#)list.h	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/list.h,v 1.8 1999/08/28 01:03:32 peter Exp $
  */
 
@@ -48,5 +47,5 @@
 
 #ifndef _LIST
-#define	_LIST
+#define _LIST
 
 #ifndef _SPRITE
@@ -131,7 +130,7 @@
  * ----------------------------------------------------------------------------
  */
-#define	List_InitElement(elementPtr) \
-    (elementPtr)->prevPtr = (List_Links *) NULL; \
-    (elementPtr)->nextPtr = (List_Links *) NULL;
+#define List_InitElement(elementPtr) \
+    (elementPtr)->prevPtr = (List_Links *) NIL; \
+    (elementPtr)->nextPtr = (List_Links *) NIL;
 
 /*
@@ -163,5 +162,5 @@
  */
 
-#define	LIST_FORALL(headerPtr, itemPtr) \
+#define LIST_FORALL(headerPtr, itemPtr) \
         for (itemPtr = List_First(headerPtr); \
              !List_IsAtEnd((headerPtr),itemPtr); \
@@ -181,5 +180,5 @@
  */
 
-#define	List_IsEmpty(headerPtr) \
+#define List_IsEmpty(headerPtr) \
         ((headerPtr) == (headerPtr)->nextPtr)
 
@@ -198,5 +197,5 @@
 
 
-#define	List_IsAtEnd(headerPtr, itemPtr) \
+#define List_IsAtEnd(headerPtr, itemPtr) \
         ((itemPtr) == (headerPtr))
 
@@ -216,5 +215,5 @@
  */
 
-#define	List_First(headerPtr) ((headerPtr)->nextPtr)
+#define List_First(headerPtr) ((headerPtr)->nextPtr)
 
 /*
@@ -231,5 +230,5 @@
  */
 
-#define	List_Last(headerPtr) ((headerPtr)->prevPtr)
+#define List_Last(headerPtr) ((headerPtr)->prevPtr)
 
 /*
@@ -247,5 +246,5 @@
  */
 
-#define	List_Prev(itemPtr) ((itemPtr)->prevPtr)
+#define List_Prev(itemPtr) ((itemPtr)->prevPtr)
 
 /*
@@ -263,5 +262,5 @@
  */
 
-#define	List_Next(itemPtr) ((itemPtr)->nextPtr)
+#define List_Next(itemPtr) ((itemPtr)->nextPtr)
 
 
@@ -294,11 +293,11 @@
  */
 
-#define	LIST_AFTER(itemPtr) ((List_Links *) itemPtr)
-
-#define	LIST_BEFORE(itemPtr) (((List_Links *) itemPtr)->prevPtr)
-
-#define	LIST_ATFRONT(headerPtr) ((List_Links *) headerPtr)
-
-#define	LIST_ATREAR(headerPtr) (((List_Links *) headerPtr)->prevPtr)
+#define LIST_AFTER(itemPtr) ((List_Links *) itemPtr)
+
+#define LIST_BEFORE(itemPtr) (((List_Links *) itemPtr)->prevPtr)
+
+#define LIST_ATFRONT(headerPtr) ((List_Links *) headerPtr)
+
+#define LIST_ATREAR(headerPtr) (((List_Links *) headerPtr)->prevPtr)
 
 #endif /* _LIST */
Index: /trunk/src/kmk/lst.h
===================================================================
--- /trunk/src/kmk/lst.h	(revision 24)
+++ /trunk/src/kmk/lst.h	(revision 25)
@@ -1,5 +1,4 @@
 /*
- * Copyright (c) 1988, 1989, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
  * Copyright (c) 1988, 1989 by Adam de Boor
  * Copyright (c) 1989 by Berkeley Softworks
@@ -37,6 +36,6 @@
  * SUCH DAMAGE.
  *
- *	@(#)lst.h	8.2 (Berkeley) 4/28/95
- * $FreeBSD: src/usr.bin/make/lst.h,v 1.15 2002/09/17 21:29:06 jmallett Exp $
+ *	from: @(#)lst.h	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.h,v 1.9 1999/08/28 01:03:32 peter Exp $
  */
 
@@ -46,8 +45,10 @@
  */
 #ifndef _LST_H_
-#define	_LST_H_
+#define _LST_H_
 
 #include	<sys/param.h>
+#ifdef __STDC__
 #include	<stdlib.h>
+#endif
 #include	"sprite.h"
 
@@ -59,4 +60,7 @@
 typedef	struct	LstNode	*LstNode;
 
+#define	NILLST		((Lst) NIL)
+#define	NILLNODE	((LstNode) NIL)
+
 /*
  * NOFREE can be used as the freeProc to Lst_Destroy when the elements are
@@ -64,9 +68,9 @@
  * NOCOPY performs similarly when given as the copyProc to Lst_Duplicate.
  */
-#define	NOFREE		((void (*)(void *)) 0)
-#define	NOCOPY		((void * (*)(void *)) 0)
+#define NOFREE		((void (*) __P((ClientData))) 0)
+#define NOCOPY		((ClientData (*) __P((ClientData))) 0)
 
-#define	LST_CONCNEW	0   /* create new LstNode's when using Lst_Concat */
-#define	LST_CONCLINK	1   /* relink LstNode's when using Lst_Concat */
+#define LST_CONCNEW	0   /* create new LstNode's when using Lst_Concat */
+#define LST_CONCLINK	1   /* relink LstNode's when using Lst_Concat */
 
 /*
@@ -74,11 +78,11 @@
  */
 /* Create a new list */
-Lst		Lst_Init(Boolean);
+Lst		Lst_Init __P((Boolean));
 /* Duplicate an existing list */
-Lst		Lst_Duplicate(Lst, void * (*)(void *));
+Lst		Lst_Duplicate __P((Lst, ClientData (*)(ClientData)));
 /* Destroy an old one */
-void		Lst_Destroy(Lst, void (*)(void *));
+void		Lst_Destroy __P((Lst, void (*)(ClientData)));
 /* True if list is empty */
-Boolean		Lst_IsEmpty(Lst);
+Boolean		Lst_IsEmpty __P((Lst));
 
 /*
@@ -86,17 +90,17 @@
  */
 /* Insert an element before another */
-ReturnStatus	Lst_Insert(Lst, LstNode, void *);
+ReturnStatus	Lst_Insert __P((Lst, LstNode, ClientData));
 /* Insert an element after another */
-ReturnStatus	Lst_Append(Lst, LstNode, void *);
+ReturnStatus	Lst_Append __P((Lst, LstNode, ClientData));
 /* Place an element at the front of a lst. */
-ReturnStatus	Lst_AtFront(Lst, void *);
+ReturnStatus	Lst_AtFront __P((Lst, ClientData));
 /* Place an element at the end of a lst. */
-ReturnStatus	Lst_AtEnd(Lst, void *);
+ReturnStatus	Lst_AtEnd __P((Lst, ClientData));
 /* Remove an element */
-ReturnStatus	Lst_Remove(Lst, LstNode);
+ReturnStatus	Lst_Remove __P((Lst, LstNode));
 /* Replace a node with a new value */
-ReturnStatus	Lst_Replace(LstNode, void *);
+ReturnStatus	Lst_Replace __P((LstNode, ClientData));
 /* Concatenate two lists */
-ReturnStatus	Lst_Concat(Lst, Lst, int);
+ReturnStatus	Lst_Concat __P((Lst, Lst, int));
 
 /*
@@ -104,11 +108,11 @@
  */
 /* Return first element in list */
-LstNode		Lst_First(Lst);
+LstNode		Lst_First __P((Lst));
 /* Return last element in list */
-LstNode		Lst_Last(Lst);
+LstNode		Lst_Last __P((Lst));
 /* Return successor to given element */
-LstNode		Lst_Succ(LstNode);
+LstNode		Lst_Succ __P((LstNode));
 /* Get datum from LstNode */
-void *	Lst_Datum(LstNode);
+ClientData	Lst_Datum __P((LstNode));
 
 /*
@@ -116,14 +120,17 @@
  */
 /* Find an element in a list */
-LstNode		Lst_Find(Lst, void *, int (*)(void *, void *));
+LstNode		Lst_Find __P((Lst, ClientData,
+			      int (*)(ClientData, ClientData)));
 /* Find an element starting from somewhere */
-LstNode		Lst_FindFrom(Lst, LstNode, void *, int (*cProc)(void *, void *));
+LstNode		Lst_FindFrom __P((Lst, LstNode, ClientData,
+				  int (*cProc)(ClientData, ClientData)));
 /*
  * See if the given datum is on the list. Returns the LstNode containing
  * the datum
  */
-LstNode		Lst_Member(Lst, void *);
+LstNode		Lst_Member __P((Lst, ClientData));
 /* Apply a function to all elements of a lst */
-void		Lst_ForEach(Lst, int (*)(void *, void *), void *);
+void		Lst_ForEach __P((Lst, int (*)(ClientData, ClientData),
+				 ClientData));
 /*
  * Apply a function to all elements of a lst starting from a certain point.
@@ -131,5 +138,7 @@
  * beginning of the list again.
  */
-void		Lst_ForEachFrom(Lst, LstNode, int (*)(void *, void *), void *);
+void		Lst_ForEachFrom __P((Lst, LstNode,
+				     int (*)(ClientData, ClientData),
+				     ClientData));
 /*
  * these functions are for dealing with a list as a table, of sorts.
@@ -138,11 +147,11 @@
  */
 /* Open the list */
-ReturnStatus	Lst_Open(Lst);
+ReturnStatus	Lst_Open __P((Lst));
 /* Next element please */
-LstNode		Lst_Next(Lst);
+LstNode		Lst_Next __P((Lst));
 /* Done yet? */
-Boolean		Lst_IsAtEnd(Lst);
+Boolean		Lst_IsAtEnd __P((Lst));
 /* Finish table access */
-void		Lst_Close(Lst);
+void		Lst_Close __P((Lst));
 
 /*
@@ -150,7 +159,7 @@
  */
 /* Place an element at tail of queue */
-ReturnStatus	Lst_EnQueue(Lst, void *);
+ReturnStatus	Lst_EnQueue __P((Lst, ClientData));
 /* Remove an element from head of queue */
-void *	Lst_DeQueue(Lst);
+ClientData	Lst_DeQueue __P((Lst));
 
 #endif /* _LST_H_ */
Index: /trunk/src/kmk/lst.lib/lstAppend.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstAppend.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstAppend.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstAppend.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstAppend.c,v 1.6 1999/08/28 01:03:45 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstAppend.c,v 1.10 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstAppend.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -61,5 +60,5 @@
  *	field of the List will be altered if ln is the last node in the
  *	list. lastPtr and firstPtr will alter if the list was empty and
- *	ln was NULL.
+ *	ln was NILLNODE.
  *
  *-----------------------------------------------------------------------
@@ -69,5 +68,5 @@
     Lst	  	l;	/* affected list */
     LstNode	ln;	/* node after which to append the datum */
-    void *	d;	/* said datum */
+    ClientData	d;	/* said datum */
 {
     register List 	list;
@@ -75,5 +74,5 @@
     register ListNode	nLNode;
 
-    if (LstValid (l) && (ln == NULL && LstIsEmpty (l))) {
+    if (LstValid (l) && (ln == NILLNODE && LstIsEmpty (l))) {
 	goto ok;
     }
@@ -91,9 +90,9 @@
     nLNode->useCount = nLNode->flags = 0;
 
-    if (lNode == NULL) {
+    if (lNode == NilListNode) {
 	if (list->isCirc) {
 	    nLNode->nextPtr = nLNode->prevPtr = nLNode;
 	} else {
-	    nLNode->nextPtr = nLNode->prevPtr = NULL;
+	    nLNode->nextPtr = nLNode->prevPtr = NilListNode;
 	}
 	list->firstPtr = list->lastPtr = nLNode;
@@ -103,5 +102,5 @@
 
 	lNode->nextPtr = nLNode;
-	if (nLNode->nextPtr != NULL) {
+	if (nLNode->nextPtr != NilListNode) {
 	    nLNode->nextPtr->prevPtr = nLNode;
 	}
Index: /trunk/src/kmk/lst.lib/lstAtEnd.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstAtEnd.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstAtEnd.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstAtEnd.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstAtEnd.c,v 1.6 1999/08/28 01:03:46 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstAtEnd.c,v 1.9 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstAtEnd.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -65,5 +64,5 @@
 Lst_AtEnd (l, d)
     Lst		l;	/* List to which to add the datum */
-    void *	d;	/* Datum to add */
+    ClientData	d;	/* Datum to add */
 {
     register LstNode	end;
Index: /trunk/src/kmk/lst.lib/lstAtFront.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstAtFront.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstAtFront.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstAtFront.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstAtFront.c,v 1.6 1999/08/28 01:03:47 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstAtFront.c,v 1.9 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstAtFront.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -66,5 +65,5 @@
 Lst_AtFront (l, d)
     Lst		l;
-    void *	d;
+    ClientData	d;
 {
     register LstNode	front;
Index: /trunk/src/kmk/lst.lib/lstClose.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstClose.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstClose.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstClose.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstClose.c,v 1.6 1999/08/28 01:03:47 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstClose.c,v 1.8 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstClose.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
Index: /trunk/src/kmk/lst.lib/lstConcat.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstConcat.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstConcat.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstConcat.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstConcat.c,v 1.7 1999/08/28 01:03:47 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstConcat.c,v 1.11 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstConcat.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -85,14 +84,14 @@
 
     if (flags == LST_CONCLINK) {
-	if (list2->firstPtr != NULL) {
+	if (list2->firstPtr != NilListNode) {
 	    /*
 	     * We set the nextPtr of the
-	     * last element of list two to be NULL to make the loop easier and
+	     * last element of list two to be NIL to make the loop easier and
 	     * so we don't need an extra case should the first list turn
 	     * out to be non-circular -- the final element will already point
-	     * to NULL space and the first element will be untouched if it
-	     * existed before and will also point to NULL space if it didn't.
+	     * to NIL space and the first element will be untouched if it
+	     * existed before and will also point to NIL space if it didn't.
 	     */
-	    list2->lastPtr->nextPtr = NULL;
+	    list2->lastPtr->nextPtr = NilListNode;
 	    /*
 	     * So long as the second list isn't empty, we just link the
@@ -104,5 +103,5 @@
 	     */
 	    list2->firstPtr->prevPtr = list1->lastPtr;
-	    if (list1->lastPtr != NULL) {
+	    if (list1->lastPtr != NilListNode) {
  		list1->lastPtr->nextPtr = list2->firstPtr;
 	    } else {
@@ -111,5 +110,5 @@
 	    list1->lastPtr = list2->lastPtr;
 	}
-	if (list1->isCirc && list1->firstPtr != NULL) {
+	if (list1->isCirc && list1->firstPtr != NilListNode) {
 	    /*
 	     * If the first list is supposed to be circular and it is (now)
@@ -120,8 +119,8 @@
 	    list1->lastPtr->nextPtr = list1->firstPtr;
 	}
-	free (l2);
-    } else if (list2->firstPtr != NULL) {
+	free ((Address)l2);
+    } else if (list2->firstPtr != NilListNode) {
 	/*
-	 * We set the nextPtr of the last element of list 2 to be NULL to make
+	 * We set the nextPtr of the last element of list 2 to be nil to make
 	 * the loop less difficult. The loop simply goes through the entire
 	 * second list creating new LstNodes and filling in the nextPtr, and
@@ -130,16 +129,16 @@
 	 * follows the last of the new nodes along until the entire l2 has
 	 * been appended. Only then does the bookkeeping catch up with the
-	 * changes. During the first iteration of the loop, if 'last' is NULL,
+	 * changes. During the first iteration of the loop, if 'last' is nil,
 	 * the first list must have been empty so the newly-created node is
 	 * made the first node of the list.
 	 */
-	list2->lastPtr->nextPtr = NULL;
+	list2->lastPtr->nextPtr = NilListNode;
 	for (last = list1->lastPtr, ln = list2->firstPtr;
-	     ln != NULL;
+	     ln != NilListNode;
 	     ln = ln->nextPtr)
 	{
 	    PAlloc (nln, ListNode);
 	    nln->datum = ln->datum;
-	    if (last != NULL) {
+	    if (last != NilListNode) {
 		last->nextPtr = nln;
 	    } else {
@@ -167,5 +166,5 @@
 	    list1->firstPtr->prevPtr = list1->lastPtr;
 	} else {
-	    last->nextPtr = NULL;
+	    last->nextPtr = NilListNode;
 	}
 
Index: /trunk/src/kmk/lst.lib/lstDatum.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstDatum.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstDatum.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstDatum.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstDatum.c,v 1.5 1999/08/28 01:03:48 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstDatum.c,v 1.9 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstDatum.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -55,5 +54,5 @@
  *
  * Results:
- *	The datum or (ick!) NULL if the node is invalid.
+ *	The datum or (ick!) NIL if the node is invalid.
  *
  * Side Effects:
@@ -62,12 +61,12 @@
  *-----------------------------------------------------------------------
  */
-void *
+ClientData
 Lst_Datum (ln)
     LstNode	ln;
 {
-    if (ln != NULL) {
+    if (ln != NILLNODE) {
 	return (((ListNode)ln)->datum);
     } else {
-	return ((void *) NULL);
+	return ((ClientData) NIL);
     }
 }
Index: /trunk/src/kmk/lst.lib/lstDeQueue.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstDeQueue.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstDeQueue.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstDeQueue.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstDeQueue.c,v 1.6 1999/08/28 01:03:48 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstDeQueue.c,v 1.10 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstDeQueue.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -55,5 +54,5 @@
  *
  * Results:
- *	The datum in the node at the head or (ick) NULL if the list
+ *	The datum in the node at the head or (ick) NIL if the list
  *	is empty.
  *
@@ -63,19 +62,19 @@
  *-----------------------------------------------------------------------
  */
-void *
+ClientData
 Lst_DeQueue (l)
     Lst	    	  l;
 {
-    void *	  rd;
+    ClientData	  rd;
     register ListNode	tln;
 
     tln = (ListNode) Lst_First (l);
-    if (tln == NULL) {
-	return ((void *) NULL);
+    if (tln == NilListNode) {
+	return ((ClientData) NIL);
     }
 
     rd = tln->datum;
     if (Lst_Remove (l, (LstNode)tln) == FAILURE) {
-	return ((void *) NULL);
+	return ((ClientData) NIL);
     } else {
 	return (rd);
Index: /trunk/src/kmk/lst.lib/lstDestroy.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstDestroy.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstDestroy.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstDestroy.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstDestroy.c,v 1.7 1999/08/28 01:03:49 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstDestroy.c,v 1.12 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstDestroy.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -67,11 +66,11 @@
 Lst_Destroy (l, freeProc)
     Lst	    	  	l;
-    register void	(*freeProc)(void *);
+    register void	(*freeProc) __P((ClientData));
 {
     register ListNode	ln;
-    register ListNode	tln = NULL;
+    register ListNode	tln = NilListNode;
     register List 	list = (List)l;
 
-    if (l == NULL || ! l) {
+    if (l == NILLST || ! l) {
 	/*
 	 * Note the check for l == (Lst)0 to catch uninitialized static Lst's.
@@ -82,24 +81,24 @@
 
     /* To ease scanning */
-    if (list->lastPtr != NULL)
-	list->lastPtr->nextPtr = NULL;
+    if (list->lastPtr != NilListNode)
+	list->lastPtr->nextPtr = NilListNode;
     else {
-	free (l);
+	free ((Address)l);
 	return;
     }
 
     if (freeProc) {
-	for (ln = list->firstPtr; ln != NULL; ln = tln) {
+	for (ln = list->firstPtr; ln != NilListNode; ln = tln) {
 	     tln = ln->nextPtr;
 	     (*freeProc) (ln->datum);
-	     free (ln);
+	     free ((Address)ln);
 	}
     } else {
-	for (ln = list->firstPtr; ln != NULL; ln = tln) {
+	for (ln = list->firstPtr; ln != NilListNode; ln = tln) {
 	     tln = ln->nextPtr;
-	     free (ln);
+	     free ((Address)ln);
 	}
     }
 
-    free (l);
+    free ((Address)l);
 }
Index: /trunk/src/kmk/lst.lib/lstDupl.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstDupl.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstDupl.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstDupl.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstDupl.c,v 1.7 1999/08/28 01:03:49 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstDupl.c,v 1.12 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstDupl.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -53,9 +52,9 @@
  *-----------------------------------------------------------------------
  * Lst_Duplicate --
- *	Duplicate an entire list. If a function to copy a void * is
+ *	Duplicate an entire list. If a function to copy a ClientData is
  *	given, the individual client elements will be duplicated as well.
  *
  * Results:
- *	The new Lst structure or NULL if failure.
+ *	The new Lst structure or NILLST if failure.
  *
  * Side Effects:
@@ -66,6 +65,6 @@
 Lst_Duplicate (l, copyProc)
     Lst     	  l;	    	 /* the list to duplicate */
-    /* A function to duplicate each void * */
-    void *	  (*copyProc)(void *);
+    /* A function to duplicate each ClientData */
+    ClientData	  (*copyProc) __P((ClientData));
 {
     register Lst 	nl;
@@ -74,24 +73,24 @@
 
     if (!LstValid (l)) {
-	return (NULL);
+	return (NILLST);
     }
 
     nl = Lst_Init (list->isCirc);
-    if (nl == NULL) {
-	return (NULL);
+    if (nl == NILLST) {
+	return (NILLST);
     }
 
     ln = list->firstPtr;
-    while (ln != NULL) {
+    while (ln != NilListNode) {
 	if (copyProc != NOCOPY) {
 	    if (Lst_AtEnd (nl, (*copyProc) (ln->datum)) == FAILURE) {
-		return (NULL);
+		return (NILLST);
 	    }
 	} else if (Lst_AtEnd (nl, ln->datum) == FAILURE) {
-	    return (NULL);
+	    return (NILLST);
 	}
 
 	if (list->isCirc && ln == list->lastPtr) {
-	    ln = NULL;
+	    ln = NilListNode;
 	} else {
 	    ln = ln->nextPtr;
Index: /trunk/src/kmk/lst.lib/lstEnQueue.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstEnQueue.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstEnQueue.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstEnQueue.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstEnQueue.c,v 1.6 1999/08/28 01:03:50 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstEnQueue.c,v 1.9 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstEnQueue.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -66,5 +65,5 @@
 Lst_EnQueue (l, d)
     Lst	    	  l;
-    void *	  d;
+    ClientData	  d;
 {
     if (LstValid (l) == FALSE) {
Index: /trunk/src/kmk/lst.lib/lstFind.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstFind.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstFind.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstFind.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstFind.c,v 1.6 1999/08/28 01:03:50 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstFind.c,v 1.11 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstFind.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -56,5 +55,5 @@
  *
  * Results:
- *	The found node or NULL if none matches.
+ *	The found node or NILLNODE if none matches.
  *
  * Side Effects:
@@ -66,6 +65,6 @@
 Lst_Find (l, d, cProc)
     Lst		l;
-    void *	d;
-    int		(*cProc)(void *, void *);
+    ClientData	d;
+    int		(*cProc) __P((ClientData, ClientData));
 {
     return (Lst_FindFrom (l, Lst_First(l), d, cProc));
Index: /trunk/src/kmk/lst.lib/lstFindFrom.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstFindFrom.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstFindFrom.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstFindFrom.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstFindFrom.c,v 1.7 1999/08/28 01:03:50 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstFindFrom.c,v 1.12 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstFindFrom.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -57,5 +56,5 @@
  *
  * Results:
- *	The found node or NULL
+ *	The found node or NILLNODE
  *
  * Side Effects:
@@ -68,6 +67,6 @@
     Lst		      	l;
     register LstNode    ln;
-    register void * d;
-    register int	(*cProc)(void *, void *);
+    register ClientData d;
+    register int	(*cProc) __P((ClientData, ClientData));
 {
     register ListNode	tln;
@@ -75,5 +74,5 @@
 
     if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) {
-	return (NULL);
+	return (NILLNODE);
     }
 
@@ -87,10 +86,10 @@
 	    tln = tln->nextPtr;
 	}
-    } while (tln != (ListNode)ln && tln != NULL);
+    } while (tln != (ListNode)ln && tln != NilListNode);
 
     if (found) {
 	return ((LstNode)tln);
     } else {
-	return (NULL);
+	return (NILLNODE);
     }
 }
Index: /trunk/src/kmk/lst.lib/lstFirst.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstFirst.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstFirst.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstFirst.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstFirst.c,v 1.5 1999/08/28 01:03:51 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstFirst.c,v 1.8 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstFirst.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -55,5 +54,5 @@
  *
  * Results:
- *	The first node or NULL if the list is empty.
+ *	The first node or NILLNODE if the list is empty.
  *
  * Side Effects:
@@ -67,5 +66,5 @@
 {
     if (!LstValid (l) || LstIsEmpty (l)) {
-	return (NULL);
+	return (NILLNODE);
     } else {
 	return ((LstNode)((List)l)->firstPtr);
Index: /trunk/src/kmk/lst.lib/lstForEach.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstForEach.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstForEach.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstForEach.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstForEach.c,v 1.6 1999/08/28 01:03:51 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstForEach.c,v 1.10 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstForEach.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -68,6 +67,6 @@
 Lst_ForEach (l, proc, d)
     Lst	    	  	l;
-    register int	(*proc)(void *, void *);
-    register void *	d;
+    register int	(*proc) __P((ClientData, ClientData));
+    register ClientData	d;
 {
     Lst_ForEachFrom(l, Lst_First(l), proc, d);
Index: /trunk/src/kmk/lst.lib/lstForEachFrom.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstForEachFrom.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstForEachFrom.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstForEachFrom.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstForEachFrom.c,v 1.7 1999/08/28 01:03:52 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstForEachFrom.c,v 1.12 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstForEachFrom.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -70,6 +69,6 @@
     Lst	    	    	l;
     LstNode    	  	ln;
-    register int	(*proc)(void *, void *);
-    register void *	d;
+    register int	(*proc) __P((ClientData, ClientData));
+    register ClientData	d;
 {
     register ListNode	tln = (ListNode)ln;
@@ -102,5 +101,5 @@
 	 */
 	done = (next == tln->nextPtr &&
-		(next == NULL || next == list->firstPtr));
+		(next == NilListNode || next == list->firstPtr));
 
 	next = tln->nextPtr;
Index: /trunk/src/kmk/lst.lib/lstInit.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstInit.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstInit.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstInit.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstInit.c,v 1.6 1999/08/28 01:03:52 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstInit.c,v 1.9 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstInit.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -70,6 +69,6 @@
     PAlloc (nList, List);
 
-    nList->firstPtr = NULL;
-    nList->lastPtr = NULL;
+    nList->firstPtr = NilListNode;
+    nList->lastPtr = NilListNode;
     nList->isOpen = FALSE;
     nList->isCirc = circ;
Index: /trunk/src/kmk/lst.lib/lstInsert.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstInsert.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstInsert.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstInsert.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstInsert.c,v 1.6 1999/08/28 01:03:52 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstInsert.c,v 1.10 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstInsert.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -68,5 +67,5 @@
     Lst	    	  	l;	/* list to manipulate */
     LstNode	  	ln;	/* node before which to insert d */
-    void *	  	d;	/* datum to be inserted */
+    ClientData	  	d;	/* datum to be inserted */
 {
     register ListNode	nLNode;	/* new lnode for d */
@@ -78,5 +77,5 @@
      * check validity of arguments
      */
-    if (LstValid (l) && (LstIsEmpty (l) && ln == NULL))
+    if (LstValid (l) && (LstIsEmpty (l) && ln == NILLNODE))
 	goto ok;
 
@@ -91,9 +90,9 @@
     nLNode->useCount = nLNode->flags = 0;
 
-    if (ln == NULL) {
+    if (ln == NILLNODE) {
 	if (list->isCirc) {
 	    nLNode->prevPtr = nLNode->nextPtr = nLNode;
 	} else {
-	    nLNode->prevPtr = nLNode->nextPtr = NULL;
+	    nLNode->prevPtr = nLNode->nextPtr = NilListNode;
 	}
 	list->firstPtr = list->lastPtr = nLNode;
@@ -102,5 +101,5 @@
 	nLNode->nextPtr = lNode;
 
-	if (nLNode->prevPtr != NULL) {
+	if (nLNode->prevPtr != NilListNode) {
 	    nLNode->prevPtr->nextPtr = nLNode;
 	}
Index: /trunk/src/kmk/lst.lib/lstInt.h
===================================================================
--- /trunk/src/kmk/lst.lib/lstInt.h	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstInt.h	(revision 25)
@@ -35,5 +35,5 @@
  *
  *	from: @(#)lstInt.h	8.1 (Berkeley) 6/6/93
- * $FreeBSD: src/usr.bin/make/lst.lib/lstInt.h,v 1.10 2002/07/15 06:57:25 jmallett Exp $
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstInt.h,v 1.7 1999/08/28 01:03:53 peter Exp $
  */
 
@@ -51,9 +51,9 @@
 	struct ListNode	*prevPtr;   /* previous element in list */
 	struct ListNode	*nextPtr;   /* next in list */
-	int	    	useCount:8, /* Count of functions using the node.
+	short	    	useCount:8, /* Count of functions using the node.
 				     * node may not be deleted until count
 				     * goes to 0 */
  	    	    	flags:8;    /* Node status flags */
-	void *	datum;	    /* datum associated with this element */
+	ClientData	datum;	    /* datum associated with this element */
 } *ListNode;
 /*
@@ -61,4 +61,6 @@
  */
 #define LN_DELETED  	0x0001      /* List node should be removed when done */
+
+#define NilListNode	((ListNode)-1)
 
 typedef enum {
@@ -76,9 +78,11 @@
 	Where	  	atEnd;	  /* Where in the list the last access was */
 	Boolean	  	isOpen;	  /* true if list has been Lst_Open'ed */
-	ListNode  	curPtr;	  /* current node, if open. NULL if
+	ListNode  	curPtr;	  /* current node, if open. NilListNode if
 				   * *just* opened */
 	ListNode  	prevPtr;  /* Previous node, if open. Used by
 				   * Lst_Remove */
 } *List;
+
+#define NilList	  	((List)-1)
 
 /*
@@ -92,5 +96,5 @@
  *	Return TRUE if the list l is valid
  */
-#define LstValid(l)	(((Lst)l == NULL) ? FALSE : TRUE)
+#define LstValid(l)	(((Lst)l == NILLST) ? FALSE : TRUE)
 
 /*
@@ -98,5 +102,5 @@
  *	Return TRUE if the LstNode ln is valid with respect to l
  */
-#define LstNodeValid(ln, l)	((((LstNode)ln) == NULL) ? FALSE : TRUE)
+#define LstNodeValid(ln, l)	((((LstNode)ln) == NILLNODE) ? FALSE : TRUE)
 
 /*
@@ -104,5 +108,5 @@
  *	TRUE if the list l is empty.
  */
-#define LstIsEmpty(l)	(((List)l)->firstPtr == NULL)
+#define LstIsEmpty(l)	(((List)l)->firstPtr == NilListNode)
 
 #endif /* _LSTINT_H_ */
Index: /trunk/src/kmk/lst.lib/lstIsAtEnd.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstIsAtEnd.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstIsAtEnd.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstIsAtEnd.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstIsAtEnd.c,v 1.5 1999/08/28 01:03:53 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstIsAtEnd.c,v 1.7 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstIsAtEnd.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
Index: /trunk/src/kmk/lst.lib/lstIsEmpty.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstIsEmpty.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstIsEmpty.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstIsEmpty.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstIsEmpty.c,v 1.5 1999/08/28 01:03:54 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstIsEmpty.c,v 1.8 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstIsEmpty.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -60,6 +59,6 @@
  *	None.
  *
- *	A list is considered empty if its firstPtr == NULL (or if
- *	the list itself is NULLLIST).
+ *	A list is considered empty if its firstPtr == NilListNode (or if
+ *	the list itself is NILLIST).
  *-----------------------------------------------------------------------
  */
Index: /trunk/src/kmk/lst.lib/lstLast.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstLast.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstLast.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstLast.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstLast.c,v 1.5 1999/08/28 01:03:55 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstLast.c,v 1.8 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstLast.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -55,5 +54,5 @@
  *
  * Results:
- *	The requested node or NULL if the list is empty.
+ *	The requested node or NILLNODE if the list is empty.
  *
  * Side Effects:
@@ -67,5 +66,5 @@
 {
     if (!LstValid(l) || LstIsEmpty (l)) {
-	return (NULL);
+	return (NILLNODE);
     } else {
 	return ((LstNode)((List)l)->lastPtr);
Index: /trunk/src/kmk/lst.lib/lstMember.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstMember.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstMember.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstMember.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstMember.c,v 1.6 1999/08/28 01:03:55 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstMember.c,v 1.10 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstMember.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -52,5 +51,5 @@
 Lst_Member (l, d)
     Lst	    	  	l;
-    void *	  	d;
+    ClientData	  	d;
 {
     List    	  	list = (List) l;
@@ -58,6 +57,6 @@
 
     lNode = list->firstPtr;
-    if (lNode == NULL) {
-	return NULL;
+    if (lNode == NilListNode) {
+	return NILLNODE;
     }
 
@@ -67,6 +66,6 @@
 	}
 	lNode = lNode->nextPtr;
-    } while (lNode != NULL && lNode != list->firstPtr);
+    } while (lNode != NilListNode && lNode != list->firstPtr);
 
-    return NULL;
+    return NILLNODE;
 }
Index: /trunk/src/kmk/lst.lib/lstNext.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstNext.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstNext.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstNext.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstNext.c,v 1.6 1999/08/28 01:03:55 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstNext.c,v 1.9 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstNext.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -60,6 +59,6 @@
  *
  * Results:
- *	The next node or NULL if the list has yet to be opened. Also
- *	if the list is non-circular and the end has been reached, NULL
+ *	The next node or NILLNODE if the list has yet to be opened. Also
+ *	if the list is non-circular and the end has been reached, NILLNODE
  *	is returned.
  *
@@ -78,10 +77,10 @@
     if ((LstValid (l) == FALSE) ||
 	(list->isOpen == FALSE)) {
-	    return (NULL);
+	    return (NILLNODE);
     }
 
     list->prevPtr = list->curPtr;
 
-    if (list->curPtr == NULL) {
+    if (list->curPtr == NilListNode) {
 	if (list->atEnd == Unknown) {
 	    /*
@@ -93,5 +92,5 @@
 	    list->atEnd = Middle;
 	} else {
-	    tln = NULL;
+	    tln = NilListNode;
 	    list->atEnd = Tail;
 	}
@@ -100,5 +99,5 @@
 	list->curPtr = tln;
 
-	if (tln == list->firstPtr || tln == NULL) {
+	if (tln == list->firstPtr || tln == NilListNode) {
 	    /*
 	     * If back at the front, then we've hit the end...
Index: /trunk/src/kmk/lst.lib/lstOpen.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstOpen.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstOpen.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstOpen.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstOpen.c,v 1.5 1999/08/28 01:03:56 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstOpen.c,v 1.8 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstOpen.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -63,5 +62,5 @@
  *
  * Side Effects:
- *	isOpen is set TRUE and curPtr is set to NULL so the
+ *	isOpen is set TRUE and curPtr is set to NilListNode so the
  *	other sequential functions no it was just opened and can choose
  *	the first element accessed based on this.
@@ -78,5 +77,5 @@
 	((List) l)->isOpen = TRUE;
 	((List) l)->atEnd = LstIsEmpty (l) ? Head : Unknown;
-	((List) l)->curPtr = NULL;
+	((List) l)->curPtr = NilListNode;
 
 	return (SUCCESS);
Index: /trunk/src/kmk/lst.lib/lstRemove.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstRemove.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstRemove.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstRemove.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstRemove.c,v 1.6 1999/08/28 01:03:56 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstRemove.c,v 1.10 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstRemove.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -58,5 +57,5 @@
  *
  * Side Effects:
- *	The list's firstPtr will be set to NULL if ln is the last
+ *	The list's firstPtr will be set to NilListNode if ln is the last
  *	node on the list. firsPtr and lastPtr will be altered if ln is
  *	either the first or last node, respectively, on the list.
@@ -80,8 +79,8 @@
      * unlink it from the list
      */
-    if (lNode->nextPtr != NULL) {
+    if (lNode->nextPtr != NilListNode) {
 	lNode->nextPtr->prevPtr = lNode->prevPtr;
     }
-    if (lNode->prevPtr != NULL) {
+    if (lNode->prevPtr != NilListNode) {
 	lNode->prevPtr->nextPtr = lNode->nextPtr;
     }
@@ -101,10 +100,10 @@
      * Sequential access stuff. If the node we're removing is the current
      * node in the list, reset the current node to the previous one. If the
-     * previous one was non-existent (prevPtr == NULL), we set the
+     * previous one was non-existent (prevPtr == NilListNode), we set the
      * end to be Unknown, since it is.
      */
     if (list->isOpen && (list->curPtr == lNode)) {
 	list->curPtr = list->prevPtr;
-	if (list->curPtr == NULL) {
+	if (list->curPtr == NilListNode) {
 	    list->atEnd = Unknown;
 	}
@@ -117,5 +116,5 @@
      */
     if (list->firstPtr == lNode) {
-	list->firstPtr = NULL;
+	list->firstPtr = NilListNode;
     }
 
@@ -125,5 +124,5 @@
      */
     if (lNode->useCount == 0) {
-	free (ln);
+	free ((Address)ln);
     } else {
 	lNode->flags |= LN_DELETED;
Index: /trunk/src/kmk/lst.lib/lstReplace.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstReplace.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstReplace.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstReplace.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstReplace.c,v 1.5 1999/08/28 01:03:56 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstReplace.c,v 1.9 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstReplace.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -65,7 +64,7 @@
 Lst_Replace (ln, d)
     register LstNode	ln;
-    void *	  	d;
+    ClientData	  	d;
 {
-    if (ln == NULL) {
+    if (ln == NILLNODE) {
 	return (FAILURE);
     } else {
Index: /trunk/src/kmk/lst.lib/lstSucc.c
===================================================================
--- /trunk/src/kmk/lst.lib/lstSucc.c	(revision 24)
+++ /trunk/src/kmk/lst.lib/lstSucc.c	(revision 25)
@@ -34,10 +34,9 @@
  * SUCH DAMAGE.
  *
- * @(#)lstSucc.c	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/lst.lib/lstSucc.c,v 1.5 1999/08/28 01:03:57 peter Exp $
  */
 
 #ifndef lint
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/lst.lib/lstSucc.c,v 1.8 2002/10/09 02:00:22 jmallett Exp $");
+static char sccsid[] = "@(#)lstSucc.c	8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
@@ -68,6 +67,6 @@
     LstNode	ln;
 {
-    if (ln == NULL) {
-	return (NULL);
+    if (ln == NILLNODE) {
+	return (NILLNODE);
     } else {
 	return ((LstNode) ((ListNode) ln)->nextPtr);
Index: /trunk/src/kmk/main.c
===================================================================
--- /trunk/src/kmk/main.c	(revision 24)
+++ /trunk/src/kmk/main.c	(revision 25)
@@ -35,17 +35,20 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * @(#)main.c      8.3 (Berkeley) 3/19/94
- */
+ */
+
+#ifndef lint
+static const char copyright[] =
+"@(#) Copyright (c) 1988, 1989, 1990, 1993\n\
+	The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
 
 #ifndef lint
 #if 0
-static char copyright[] =
-"@(#) Copyright (c) 1988, 1989, 1990, 1993\n\
-	The Regents of the University of California.  All rights reserved.\n";
+static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
+#else
+static const char rcsid[] =
+  "$FreeBSD: src/usr.bin/make/main.c,v 1.35.2.6 2002/07/24 16:50:18 ru Exp $";
 #endif
 #endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/main.c,v 1.79 2002/10/10 19:27:48 jmallett Exp $");
 
 /*-
@@ -59,4 +62,19 @@
  *				invoked. Used by the parse module to implement
  *				the .MFLAGS target.
+ *
+ *	Error			Print a tagged error message. The global
+ *				MAKE variable must have been defined. This
+ *				takes a format string and two optional
+ *				arguments for it.
+ *
+ *	Fatal			Print an error message and exit. Also takes
+ *				a format string and two arguments.
+ *
+ *	Punt			Aborts all jobs and exits with a message. Also
+ *				takes a format string and two arguments.
+ *
+ *	Finish			Finish things up by printing the number of
+ *				errors which occured, as passed to it, and
+ *				exiting.
  */
 
@@ -80,6 +98,9 @@
 #include <stdio.h>
 #include <sysexits.h>
+#ifdef __STDC__
 #include <stdarg.h>
-#include <unistd.h>
+#else
+#include <varargs.h>
+#endif
 #include "make.h"
 #include "hash.h"
@@ -88,6 +109,4 @@
 #include "pathnames.h"
 
-#define WANT_ENV_MKLVL	1
-
 #ifndef	DEFMAXLOCAL
 #define	DEFMAXLOCAL DEFMAXJOBS
@@ -103,4 +122,5 @@
 static Boolean		noBuiltins;	/* -r flag */
 static Lst		makefiles;	/* ordered list of makefiles to read */
+static Boolean		printVars;	/* print value of one or more vars */
 static Boolean		expandVars;	/* fully expand printed variables */
 static Lst		variables;	/* list of variables to print */
@@ -121,10 +141,10 @@
 Boolean			checkEnvFirst;	/* -e flag */
 Lst			envFirstVars;	/* (-E) vars to override from env */
-Boolean			jobsRunning;	/* TRUE if the jobs might be running */
-
-static void		MainParseArgs(int, char **);
-char *			chdir_verify_path(char *, char *);
-static int		ReadMakefile(void *, void *);
-static void		usage(void);
+static Boolean		jobsRunning;	/* TRUE if the jobs might be running */
+
+static void		MainParseArgs __P((int, char **));
+char *			chdir_verify_path __P((char *, char *));
+static int		ReadMakefile __P((ClientData, ClientData));
+static void		usage __P((void));
 
 static char *curdir;			/* startup directory */
@@ -146,6 +166,10 @@
  */
 static void
-MainParseArgs(int argc, char **argv)
-{
+MainParseArgs(argc, argv)
+	int argc;
+	char **argv;
+{
+	extern int optind;
+	extern char *optarg;
 	char *p;
 	int c;
@@ -153,13 +177,10 @@
 	optind = 1;	/* since we're called more than once */
 #ifdef REMOTE
-# define OPTFLAGS "BC:D:E:I:L:PSV:Xd:ef:ij:km:nqrstv"
+# define OPTFLAGS "BD:E:I:L:PSV:Xd:ef:ij:km:nqrstv"
 #else
-# define OPTFLAGS "BC:D:E:I:PSV:Xd:ef:ij:km:nqrstv"
+# define OPTFLAGS "BD:E:I:PSV:Xd:ef:ij:km:nqrstv"
 #endif
 rearg:	while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
 		switch(c) {
-		case 'C':
-			chdir(optarg);
-			break;
 		case 'D':
 			Var_Set(optarg, "1", VAR_GLOBAL);
@@ -173,5 +194,6 @@
 			break;
 		case 'V':
-			(void)Lst_AtEnd(variables, (void *)optarg);
+			printVars = TRUE;
+			(void)Lst_AtEnd(variables, (ClientData)optarg);
 			Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL);
 			Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
@@ -264,7 +286,9 @@
 		}
 		case 'E':
-			p = emalloc(strlen(optarg) + 1);
+			p = malloc(strlen(optarg) + 1);
+			if (!p)
+				Punt("make: cannot allocate memory.");
 			(void)strcpy(p, optarg);
-			(void)Lst_AtEnd(envFirstVars, (void *)p);
+			(void)Lst_AtEnd(envFirstVars, (ClientData)p);
 			Var_Append(MAKEFLAGS, "-E", VAR_GLOBAL);
 			Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
@@ -275,5 +299,5 @@
 			break;
 		case 'f':
-			(void)Lst_AtEnd(makefiles, (void *)optarg);
+			(void)Lst_AtEnd(makefiles, (ClientData)optarg);
 			break;
 		case 'i':
@@ -358,5 +382,5 @@
 				goto rearg;
 			}
-			(void)Lst_AtEnd(create, (void *)estrdup(*argv));
+			(void)Lst_AtEnd(create, (ClientData)estrdup(*argv));
 		}
 }
@@ -378,5 +402,6 @@
  */
 void
-Main_ParseArgLine(char *line)
+Main_ParseArgLine(line)
+	char *line;			/* Line to fracture */
 {
 	char **argv;			/* Manufactured argument vector */
@@ -395,14 +420,24 @@
 
 char *
-chdir_verify_path(char *path, char *obpath)
+chdir_verify_path(path, obpath)
+	char *path;
+	char *obpath;
 {
 	struct stat sb;
 
 	if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) {
-		if (chdir(path) == -1 || getcwd(obpath, MAXPATHLEN) == NULL) {
+		if (chdir(path)) {
 			warn("warning: %s", path);
 			return 0;
 		}
-		return obpath;
+		else {
+			if (path[0] != '/') {
+				(void) snprintf(obpath, MAXPATHLEN, "%s/%s",
+						curdir, path);
+				return obpath;
+			}
+			else
+				return path;
+		}
 	}
 
@@ -429,5 +464,7 @@
  */
 int
-main(int argc, char **argv)
+main(argc, argv)
+	int argc;
+	char **argv;
 {
 	Lst targs;	/* target nodes to create -- passed to Make_Init */
@@ -435,13 +472,11 @@
 	struct stat sa;
 	char *p, *p1, *path, *pathp;
-#ifdef WANT_ENV_MKLVL
-#define	MKLVL_MAXVAL	500
-#define	MKLVL_ENVVAR	"__MKLVL__"
-	int iMkLvl = 0;
-	char *szMkLvl = getenv(MKLVL_ENVVAR);
-#endif	/* WANT_ENV_MKLVL */
-	char mdpath[MAXPATHLEN];
-	char obpath[MAXPATHLEN];
-	char cdpath[MAXPATHLEN];
+#ifdef WANT_ENV_PWD
+	struct stat sb;
+	char *pwd;
+#endif
+	char mdpath[MAXPATHLEN + 1];
+	char obpath[MAXPATHLEN + 1];
+	char cdpath[MAXPATHLEN + 1];
     	char *machine = getenv("MACHINE");
 	char *machine_arch = getenv("MACHINE_ARCH");
@@ -452,24 +487,4 @@
 	static char syspath[] = _PATH_DEFSYSPATH;
 
-#ifdef WANT_ENV_MKLVL
-	if ((iMkLvl = szMkLvl ? atoi(szMkLvl) : 0) < 0) {
-	  iMkLvl = 0;
-	}
-	if (iMkLvl++ > MKLVL_MAXVAL) {
-	  errc(2, EAGAIN, 
-	       "Max recursion level (%d) exceeded.", MKLVL_MAXVAL);
-	}
-	bzero(szMkLvl = emalloc(32), 32);
-	sprintf(szMkLvl, "%d", iMkLvl);
-	setenv(MKLVL_ENVVAR, szMkLvl, 1);
-#endif /* WANT_ENV_MKLVL */
-
-#if DEFSHELL == 2
-	/*
-	 * Turn off ENV to make ksh happier.
-	 */
-	unsetenv("ENV");
-#endif
-
 #ifdef RLIMIT_NOFILE
 	/*
@@ -486,5 +501,5 @@
 #endif
 	/*
-	 * Find where we are...
+	 * Find where we are and take care of PWD for the automounter...
 	 * All this code is so that we know where we are when we start up
 	 * on a different machine with pmake.
@@ -496,4 +511,12 @@
 	if (stat(curdir, &sa) == -1)
 	    err(2, "%s", curdir);
+
+#ifdef WANT_ENV_PWD
+	if ((pwd = getenv("PWD")) != NULL) {
+	    if (stat(pwd, &sb) == 0 && sa.st_ino == sb.st_ino &&
+		sa.st_dev == sb.st_dev)
+		(void) strcpy(curdir, pwd);
+	}
+#endif
 
 #if defined(__i386__) && defined(__FreeBSD_version) && \
@@ -532,6 +555,8 @@
 	    struct utsname utsname;
 
-	    if (uname(&utsname) == -1)
-		    err(2, "uname");
+	    if (uname(&utsname) == -1) {
+		    perror("make: uname");
+		    exit(2);
+	    }
 	    machine = utsname.machine;
 #else
@@ -603,7 +628,12 @@
 	}
 
+#ifdef WANT_ENV_PWD
+	setenv("PWD", objdir, 1);
+#endif
+
 	create = Lst_Init(FALSE);
 	makefiles = Lst_Init(FALSE);
 	envFirstVars = Lst_Init(FALSE);
+	printVars = FALSE;
 	expandVars = TRUE;
 	variables = Lst_Init(FALSE);
@@ -659,7 +689,4 @@
 	Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL);
 	Var_Set("MACHINE_CPU", machine_cpu, VAR_GLOBAL);
-#ifdef MAKE_VERSION
-	Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL);
-#endif
 
 	/*
@@ -691,5 +718,5 @@
 	Suff_Init();
 
-	DEFAULT = NULL;
+	DEFAULT = NILGNODE;
 	(void)time(&now);
 
@@ -702,5 +729,5 @@
 		LstNode ln;
 
-		for (ln = Lst_First(create); ln != NULL;
+		for (ln = Lst_First(create); ln != NILLNODE;
 		    ln = Lst_Succ(ln)) {
 			char *name = (char *)Lst_Datum(ln);
@@ -742,6 +769,6 @@
 		if (Lst_IsEmpty(sysMkPath))
 			Fatal("make: no system rules (%s).", _PATH_DEFSYSMK);
-		ln = Lst_Find(sysMkPath, (void *)NULL, ReadMakefile);
-		if (ln != NULL)
+		ln = Lst_Find(sysMkPath, (ClientData)NULL, ReadMakefile);
+		if (ln != NILLNODE)
 			Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
 	}
@@ -750,9 +777,8 @@
 		LstNode ln;
 
-		ln = Lst_Find(makefiles, (void *)NULL, ReadMakefile);
-		if (ln != NULL)
+		ln = Lst_Find(makefiles, (ClientData)NULL, ReadMakefile);
+		if (ln != NILLNODE)
 			Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
-	} else if (!ReadMakefile("BSDmakefile", NULL))
-	    if (!ReadMakefile("makefile", NULL))
+	} else if (!ReadMakefile("makefile", NULL))
 		(void)ReadMakefile("Makefile", NULL);
 
@@ -778,5 +804,5 @@
 	 */
 	if (Var_Exists("VPATH", VAR_CMD)) {
-		char *vpath, savec;
+		char *vpath, *path, *cp, savec;
 		/*
 		 * GCC stores string constants in read-only memory, but
@@ -800,5 +826,5 @@
 			path = cp + 1;
 		} while (savec == ':');
-		(void)free(vpath);
+		(void)free((Address)vpath);
 	}
 
@@ -814,12 +840,14 @@
 
 	/* print the values of any variables requested by the user */
-	if (!Lst_IsEmpty(variables)) {
+	if (printVars) {
 		LstNode ln;
 
-		for (ln = Lst_First(variables); ln != NULL;
+		for (ln = Lst_First(variables); ln != NILLNODE;
 		    ln = Lst_Succ(ln)) {
 			char *value;
 			if (expandVars) {
-				p1 = emalloc(strlen((char *)Lst_Datum(ln)) + 1 + 3);
+				p1 = malloc(strlen((char *)Lst_Datum(ln)) + 1 + 3);
+				if (!p1)
+					Punt("make: cannot allocate memory.");
 				/* This sprintf is safe, because of the malloc above */
 				(void)sprintf(p1, "${%s}", (char *)Lst_Datum(ln));
@@ -833,45 +861,44 @@
 				free(p1);
 		}
-	} else {
-
+	}
+
+	/*
+	 * Have now read the entire graph and need to make a list of targets
+	 * to create. If none was given on the command line, we consult the
+	 * parsing module to find the main target(s) to create.
+	 */
+	if (Lst_IsEmpty(create))
+		targs = Parse_MainName();
+	else
+		targs = Targ_FindList(create, TARG_CREATE);
+
+	if (!compatMake && !printVars) {
 		/*
-		 * Have now read the entire graph and need to make a list of targets
-		 * to create. If none was given on the command line, we consult the
-		 * parsing module to find the main target(s) to create.
+		 * Initialize job module before traversing the graph, now that
+		 * any .BEGIN and .END targets have been read.  This is done
+		 * only if the -q flag wasn't given (to prevent the .BEGIN from
+		 * being executed should it exist).
 		 */
-		if (Lst_IsEmpty(create))
-			targs = Parse_MainName();
-		else
-			targs = Targ_FindList(create, TARG_CREATE);
-
-		if (!compatMake) {
-			/*
-			 * Initialize job module before traversing the graph, now that
-			 * any .BEGIN and .END targets have been read.  This is done
-			 * only if the -q flag wasn't given (to prevent the .BEGIN from
-			 * being executed should it exist).
-			 */
-			if (!queryFlag) {
-				if (maxLocal == -1)
-					maxLocal = maxJobs;
-				Job_Init(maxJobs, maxLocal);
-				jobsRunning = TRUE;
-			}
-
-			/* Traverse the graph, checking on all the targets */
-			outOfDate = Make_Run(targs);
-		} else {
-			/*
-			 * Compat_Init will take care of creating all the targets as
-			 * well as initializing the module.
-			 */
-			Compat_Run(targs);
-		}
-		Lst_Destroy(targs, NOFREE);
-	}
-
+		if (!queryFlag) {
+			if (maxLocal == -1)
+				maxLocal = maxJobs;
+			Job_Init(maxJobs, maxLocal);
+			jobsRunning = TRUE;
+		}
+
+		/* Traverse the graph, checking on all the targets */
+		outOfDate = Make_Run(targs);
+	} else if (!printVars) {
+		/*
+		 * Compat_Init will take care of creating all the targets as
+		 * well as initializing the module.
+		 */
+		Compat_Run(targs);
+	}
+
+	Lst_Destroy(targs, NOFREE);
 	Lst_Destroy(variables, NOFREE);
 	Lst_Destroy(makefiles, NOFREE);
-	Lst_Destroy(create, (void (*)(void *)) free);
+	Lst_Destroy(create, (void (*) __P((ClientData))) free);
 
 	/* print the graph now it's been processed if the user requested it */
@@ -904,13 +931,13 @@
  */
 static Boolean
-ReadMakefile(void *p, void *q __unused)
-{
-	char *fname;			/* makefile to read */
+ReadMakefile(p, q)
+	ClientData p, q;
+{
+	char *fname = p;		/* makefile to read */
+	extern Lst parseIncPath;
 	FILE *stream;
-	char *name, path[MAXPATHLEN];
+	char *name, path[MAXPATHLEN + 1];
 	char *MAKEFILE;
 	int setMAKEFILE;
-
-	fname = p;
 
 	if (!strcmp(fname, "-")) {
@@ -923,20 +950,4 @@
 		if (curdir != objdir && *fname != '/') {
 			(void)snprintf(path, MAXPATHLEN, "%s/%s", curdir, fname);
-			/*
-			 * XXX The realpath stuff breaks relative includes
-			 * XXX in some cases.   The problem likely is in
-			 * XXX parse.c where it does special things in
-			 * XXX ParseDoInclude if the file is relateive
-			 * XXX or absolute and not a system file.  There
-			 * XXX it assumes that if the current file that's
-			 * XXX being included is absolute, that any files
-			 * XXX that it includes shouldn't do the -I path
-			 * XXX stuff, which is inconsistant with historical
-			 * XXX behavior.  However, I can't pentrate the mists
-			 * XXX further, so I'm putting this workaround in
-			 * XXX here until such time as the underlying bug
-			 * XXX can be fixed.
-			 */
-#if THIS_BREAKS_THINGS
 			if (realpath(path, path) != NULL &&
 			    (stream = fopen(path, "r")) != NULL) {
@@ -951,16 +962,4 @@
 				goto found;
 		}
-#else
-			if ((stream = fopen(path, "r")) != NULL) {
-				MAKEFILE = fname;
-				fname = path;
-				goto found;
-			}
-		} else {
-			MAKEFILE = fname;
-			if ((stream = fopen(fname, "r")) != NULL)
-				goto found;
-		}
-#endif
 		/* look in -I and system include directories. */
 		name = Dir_FindFile(fname, parseIncPath);
@@ -991,5 +990,5 @@
  * Results:
  *	A string containing the output of the command, or the empty string
- *	If error is not NULL, it contains the reason for the command failure
+ *	If err is not NULL, it contains the reason for the command failure
  *
  * Side Effects:
@@ -997,5 +996,7 @@
  */
 char *
-Cmd_Exec(char *cmd, char **error)
+Cmd_Exec(cmd, err)
+    char *cmd;
+    char **err;
 {
     char	*args[4];   	/* Args for invoking the shell */
@@ -1009,5 +1010,6 @@
     int		cc;
 
-    *error = NULL;
+
+    *err = NULL;
 
     /*
@@ -1023,5 +1025,5 @@
      */
     if (pipe(fds) == -1) {
-	*error = "Couldn't create pipe for \"%s\"";
+	*err = "Couldn't create pipe for \"%s\"";
 	goto bad;
     }
@@ -1045,18 +1047,10 @@
 	(void) close(fds[1]);
 
-#if defined(DEFSHELL) && DEFSHELL == 0
-	(void) execv("/bin/csh", args);
-#elif DEFSHELL == 1
 	(void) execv("/bin/sh", args);
-#elif DEFSHELL == 2
-	(void) execv("/bin/ksh", args);
-#else
-#error "DEFSHELL must be 1 or 2."
-#endif
 	_exit(1);
 	/*NOTREACHED*/
 
     case -1:
-	*error = "Couldn't exec \"%s\"";
+	*err = "Couldn't exec \"%s\"";
 	goto bad;
 
@@ -1089,5 +1083,5 @@
 
 	if (cc == -1)
-	    *error = "Error reading shell's output for \"%s\"";
+	    *err = "Error reading shell's output for \"%s\"";
 
 	res = (char *)Buf_GetAll (buf, &cc);
@@ -1095,5 +1089,5 @@
 
 	if (status)
-	    *error = "\"%s\" returned non-zero status";
+	    *err = "\"%s\" returned non-zero status";
 
 	/*
@@ -1125,4 +1119,231 @@
 }
 
+/*-
+ * Error --
+ *	Print an error message given its format.
+ *
+ * Results:
+ *	None.
+ *
+ * Side Effects:
+ *	The message is printed.
+ */
+/* VARARGS */
+void
+#ifdef __STDC__
+Error(char *fmt, ...)
+#else
+Error(va_alist)
+	va_dcl
+#endif
+{
+	va_list ap;
+#ifdef __STDC__
+	va_start(ap, fmt);
+#else
+	char *fmt;
+
+	va_start(ap);
+	fmt = va_arg(ap, char *);
+#endif
+	(void)vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	(void)fprintf(stderr, "\n");
+	(void)fflush(stderr);
+}
+
+/*-
+ * Fatal --
+ *	Produce a Fatal error message. If jobs are running, waits for them
+ *	to finish.
+ *
+ * Results:
+ *	None
+ *
+ * Side Effects:
+ *	The program exits
+ */
+/* VARARGS */
+void
+#ifdef __STDC__
+Fatal(char *fmt, ...)
+#else
+Fatal(va_alist)
+	va_dcl
+#endif
+{
+	va_list ap;
+#ifdef __STDC__
+	va_start(ap, fmt);
+#else
+	char *fmt;
+
+	va_start(ap);
+	fmt = va_arg(ap, char *);
+#endif
+	if (jobsRunning)
+		Job_Wait();
+
+	(void)vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	(void)fprintf(stderr, "\n");
+	(void)fflush(stderr);
+
+	if (DEBUG(GRAPH2))
+		Targ_PrintGraph(2);
+	exit(2);		/* Not 1 so -q can distinguish error */
+}
+
+/*
+ * Punt --
+ *	Major exception once jobs are being created. Kills all jobs, prints
+ *	a message and exits.
+ *
+ * Results:
+ *	None
+ *
+ * Side Effects:
+ *	All children are killed indiscriminately and the program Lib_Exits
+ */
+/* VARARGS */
+void
+#ifdef __STDC__
+Punt(char *fmt, ...)
+#else
+Punt(va_alist)
+	va_dcl
+#endif
+{
+	va_list ap;
+#if __STDC__
+	va_start(ap, fmt);
+#else
+	char *fmt;
+
+	va_start(ap);
+	fmt = va_arg(ap, char *);
+#endif
+
+	(void)fprintf(stderr, "make: ");
+	(void)vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	(void)fprintf(stderr, "\n");
+	(void)fflush(stderr);
+
+	DieHorribly();
+}
+
+/*-
+ * DieHorribly --
+ *	Exit without giving a message.
+ *
+ * Results:
+ *	None
+ *
+ * Side Effects:
+ *	A big one...
+ */
+void
+DieHorribly()
+{
+	if (jobsRunning)
+		Job_AbortAll();
+	if (DEBUG(GRAPH2))
+		Targ_PrintGraph(2);
+	exit(2);		/* Not 1, so -q can distinguish error */
+}
+
+/*
+ * Finish --
+ *	Called when aborting due to errors in child shell to signal
+ *	abnormal exit.
+ *
+ * Results:
+ *	None
+ *
+ * Side Effects:
+ *	The program exits
+ */
+void
+Finish(errors)
+	int errors;	/* number of errors encountered in Make_Make */
+{
+	Fatal("%d error%s", errors, errors == 1 ? "" : "s");
+}
+
+/*
+ * emalloc --
+ *	malloc, but die on error.
+ */
+void *
+emalloc(len)
+	size_t len;
+{
+	void *p;
+
+	if ((p = malloc(len)) == NULL)
+		enomem();
+	return(p);
+}
+
+/*
+ * estrdup --
+ *	strdup, but die on error.
+ */
+char *
+estrdup(str)
+	const char *str;
+{
+	char *p;
+
+	if ((p = strdup(str)) == NULL)
+		enomem();
+	return(p);
+}
+
+/*
+ * erealloc --
+ *	realloc, but die on error.
+ */
+void *
+erealloc(ptr, size)
+	void *ptr;
+	size_t size;
+{
+	if ((ptr = realloc(ptr, size)) == NULL)
+		enomem();
+	return(ptr);
+}
+
+/*
+ * enomem --
+ *	die when out of memory.
+ */
+void
+enomem()
+{
+	err(2, NULL);
+}
+
+/*
+ * enunlink --
+ *	Remove a file carefully, avoiding directories.
+ */
+int
+eunlink(file)
+	const char *file;
+{
+	struct stat st;
+
+	if (lstat(file, &st) == -1)
+		return -1;
+
+	if (S_ISDIR(st.st_mode)) {
+		errno = EISDIR;
+		return -1;
+	}
+	return unlink(file);
+}
+
 /*
  * usage --
@@ -1130,5 +1351,5 @@
  */
 static void
-usage(void)
+usage()
 {
 	(void)fprintf(stderr, "%s\n%s\n%s\n",
@@ -1138,2 +1359,12 @@
 	exit(2);
 }
+
+
+int
+PrintAddr(a, b)
+    ClientData a;
+    ClientData b;
+{
+    printf("%lx ", (unsigned long) a);
+    return b ? 0 : 0;
+}
Index: /trunk/src/kmk/make.1
===================================================================
--- /trunk/src/kmk/make.1	(revision 24)
+++ /trunk/src/kmk/make.1	(revision 25)
@@ -30,8 +30,8 @@
 .\" SUCH DAMAGE.
 .\"
-.\"	@(#)make.1	8.8 (Berkeley) 6/13/95
-.\" $FreeBSD: src/usr.bin/make/make.1,v 1.59 2002/09/27 09:21:07 ru Exp $
+.\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
+.\" $FreeBSD: src/usr.bin/make/make.1,v 1.29.2.14 2002/09/09 19:06:16 archie Exp $
 .\"
-.Dd June 13, 1995
+.Dd March 19, 1994
 .Dt MAKE 1
 .Os
@@ -42,5 +42,4 @@
 .Nm
 .Op Fl BPSXeiknqrstv
-.Op Fl C Ar directory
 .Op Fl D Ar variable
 .Op Fl d Ar flags
@@ -63,5 +62,4 @@
 files and programs.
 The first of
-.Ql Pa BSDmakefile ,
 .Ql Pa makefile
 and
@@ -90,8 +88,4 @@
 .Fl j
 is used.
-.It Fl C Ar directory
-Change to
-.Ar directory
-while running.
 .It Fl D Ar variable
 Define
@@ -178,7 +172,6 @@
 that do not depend on the target whose creation caused the error.
 .It Fl m Ar directory
-Specify a directory in which to search for
-.Pa sys.mk
-and makefiles included via the <...> style.
+Specify a directory in which to search for sys.mk and makefiles included
+via the <...> style.
 Multiple directories can be added to form a search path.
 This path will override the default system include path:
@@ -519,11 +512,4 @@
 is unable to change into any of the remaining three directories,
 then the current directory is used.
-.Pp
-The
-.Nm
-utility sets
-.Va .OBJDIR
-to the canonical path given by
-.Xr getcwd 3 .
 .It Va .MAKEFLAGS
 The environment variable
@@ -551,4 +537,27 @@
 .Va .MAKEFLAGS
 provided for backward compatibility.
+.It Ev PWD
+Alternate path to the current directory.
+Supported if built with WANT_ENV_PWD defined.
+.Nm
+normally sets
+.Ql Va .CURDIR
+to the canonical path given by
+.Xr getcwd 3 .
+However, if the environment variable
+.Ev PWD
+is set and gives a path to the current directory, then
+.Nm
+sets
+.Ql Va .CURDIR
+to the value of
+.Ev PWD
+instead.
+.Ev PWD
+is always set to the value of
+.Ql Va .OBJDIR
+for all programs which
+.Nm
+executes.
 .It Va .TARGETS
 List of targets
@@ -580,5 +589,7 @@
 These directories will be searched for source files by
 .Nm
-after it has finished parsing all input makefiles.
+after
+.Nm
+has finished parsing all input makefiles.
 .El
 .Pp
@@ -700,4 +711,6 @@
 .Pq Ql \&$ ,
 not a preceding dollar sign as is usual.
+.It Cm T
+Replaces each word in the variable with its last component.
 .It Ar old_string=new_string
 This is the
@@ -720,6 +733,4 @@
 to be replaced in
 .Ar new_string
-.It Cm T
-Replaces each word in the variable with its last component.
 .It Cm U
 Converts variable to upper-case letters.
@@ -853,6 +864,5 @@
 .Bl -tag -width "Cm XX"
 .It Cm \&|\&|
-logical
-.Tn OR
+logical OR
 .It Cm \&&&
 Logical
@@ -1107,7 +1117,5 @@
 Disable parallel mode.
 .It Ic .NO_PARALLEL
-Same as above, for compatibility with other
-.Nm pmake
-variants.
+Same as above, for compatibility with other pmake variants.
 .It Ic .ORDER
 The named targets are made in sequence.
@@ -1191,6 +1199,7 @@
 .Ev MAKEFLAGS ,
 .Ev MAKEOBJDIR ,
+.Ev MAKEOBJDIRPREFIX ,
 and
-.Ev MAKEOBJDIRPREFIX .
+.Ev PWD .
 .Sh FILES
 .Bl -tag -width /usr/share/doc/psd/12.make -compact
@@ -1245,5 +1254,5 @@
 .Pp
 For loops are expanded before tests, so a fragment such as:
-.Bd -literal -offset indent
+.Bd -literal
 \&.for TMACHINE in ${SHARED_ARCHS}
 \&.if ${TMACHINE} = ${MACHINE}
@@ -1252,17 +1261,5 @@
 \&.endfor
 .Ed
-.Pp
 won't work, and should be rewritten the other way around.
-.Pp
-The parsing code is broken with respect to handling a semicolon
-after a colon, so a fragment like this will fail:
-.Bd -literal -offset indent
-HDRS=   foo.h bar.h
-
-all:
-\&.for h in ${HDRS:S;^;${.CURDIR}/;}
-     ...
-\&.endfor
-.Ed
 .Sh SEE ALSO
 .Xr mkdep 1 ,
@@ -1276,3 +1273,4 @@
 A
 .Nm
-command appeared in PWB UNIX.
+command appeared in
+.At v7 .
Index: /trunk/src/kmk/make.c
===================================================================
--- /trunk/src/kmk/make.c	(revision 24)
+++ /trunk/src/kmk/make.c	(revision 25)
@@ -35,10 +35,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * @(#)make.c	8.1 (Berkeley) 6/6/93
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/make.c,v 1.23 2002/10/09 03:42:10 jmallett Exp $");
+ */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)make.c	8.1 (Berkeley) 6/6/93";
+#else
+static const char rcsid[] =
+  "$FreeBSD: src/usr.bin/make/make.c,v 1.11 1999/09/11 13:08:01 hoek Exp $";
+#endif
+#endif /* not lint */
 
 /*-
@@ -88,10 +92,10 @@
 				 * TRUE, there's a cycle in the graph */
 
-static int MakeAddChild(void *, void *);
-static int MakeAddAllSrc(void *, void *);
-static int MakeTimeStamp(void *, void *);
-static int MakeHandleUse(void *, void *);
-static Boolean MakeStartJobs(void);
-static int MakePrintStatus(void *, void *);
+static int MakeAddChild __P((ClientData, ClientData));
+static int MakeAddAllSrc __P((ClientData, ClientData));
+static int MakeTimeStamp __P((ClientData, ClientData));
+static int MakeHandleUse __P((ClientData, ClientData));
+static Boolean MakeStartJobs __P((void));
+static int MakePrintStatus __P((ClientData, ClientData));
 /*-
  *-----------------------------------------------------------------------
@@ -109,5 +113,7 @@
  */
 int
-Make_TimeStamp (GNode *pgn, GNode *cgn)
+Make_TimeStamp (pgn, cgn)
+    GNode *pgn;	/* the current parent */
+    GNode *cgn;	/* the child we've just examined */
 {
     if (cgn->mtime > pgn->cmtime) {
@@ -118,5 +124,7 @@
 
 static int
-MakeTimeStamp (void *pgn, void *cgn)
+MakeTimeStamp (pgn, cgn)
+    ClientData pgn;	/* the current parent */
+    ClientData cgn;	/* the child we've just examined */
 {
     return Make_TimeStamp((GNode *) pgn, (GNode *) cgn);
@@ -143,5 +151,6 @@
  */
 Boolean
-Make_OODate (GNode *gn)
+Make_OODate (gn)
+    register GNode *gn;	      /* the node to check */
 {
     Boolean         oodate;
@@ -153,8 +162,10 @@
     if ((gn->type & (OP_JOIN|OP_USE|OP_EXEC)) == 0) {
 	(void) Dir_MTime (gn);
-	if (gn->mtime != 0) {
-	    DEBUGF(MAKE, ("modified %s...", Targ_FmtTime(gn->mtime)));
-	} else {
-	    DEBUGF(MAKE, ("non-existent..."));
+	if (DEBUG(MAKE)) {
+	    if (gn->mtime != 0) {
+		printf ("modified %s...", Targ_FmtTime(gn->mtime));
+	    } else {
+		printf ("non-existent...");
+	    }
 	}
     }
@@ -179,8 +190,12 @@
 	 * no matter *what*.
 	 */
-	DEBUGF(MAKE, (".USE node..."));
+	if (DEBUG(MAKE)) {
+	    printf(".USE node...");
+	}
 	oodate = FALSE;
     } else if (gn->type & OP_LIB) {
-	DEBUGF(MAKE, ("library..."));
+	if (DEBUG(MAKE)) {
+	    printf("library...");
+	}
 
 	/*
@@ -195,5 +210,7 @@
 	 * out-of-date if any of its children was out-of-date.
 	 */
-	DEBUGF(MAKE, (".JOIN node..."));
+	if (DEBUG(MAKE)) {
+	    printf(".JOIN node...");
+	}
 	oodate = gn->childMade;
     } else if (gn->type & (OP_FORCE|OP_EXEC|OP_PHONY)) {
@@ -202,10 +219,12 @@
 	 * the .EXEC attribute is always considered out-of-date.
 	 */
-	if (gn->type & OP_FORCE) {
-	    DEBUGF(MAKE, ("! operator..."));
-	} else if (gn->type & OP_PHONY) {
-	    DEBUGF(MAKE, (".PHONY node..."));
-	} else {
-	    DEBUGF(MAKE, (".EXEC node..."));
+	if (DEBUG(MAKE)) {
+	    if (gn->type & OP_FORCE) {
+		printf("! operator...");
+	    } else if (gn->type & OP_PHONY) {
+		printf(".PHONY node...");
+	    } else {
+		printf(".EXEC node...");
+	    }
 	}
 	oodate = TRUE;
@@ -221,14 +240,25 @@
 	 * it.
 	 */
-	if (gn->mtime < gn->cmtime) {
-	    DEBUGF(MAKE, ("modified before source..."));
-	} else if (gn->mtime == 0) {
-	    DEBUGF(MAKE, ("non-existent and no sources..."));
-	} else {
-	    DEBUGF(MAKE, (":: operator and no sources..."));
+	if (DEBUG(MAKE)) {
+	    if (gn->mtime < gn->cmtime) {
+		printf("modified before source...");
+	    } else if (gn->mtime == 0) {
+		printf("non-existent and no sources...");
+	    } else {
+		printf(":: operator and no sources...");
+	    }
 	}
 	oodate = TRUE;
-    } else
+    } else {
+#if 0
+	/* WHY? */
+	if (DEBUG(MAKE)) {
+	    printf("source %smade...", gn->childMade ? "" : "not ");
+	}
+	oodate = gn->childMade;
+#else
 	oodate = FALSE;
+#endif /* 0 */
+    }
 
     /*
@@ -240,5 +270,5 @@
      */
     if (!oodate) {
-	Lst_ForEach (gn->parents, MakeTimeStamp, (void *)gn);
+	Lst_ForEach (gn->parents, MakeTimeStamp, (ClientData)gn);
     }
 
@@ -261,5 +291,7 @@
  */
 static int
-MakeAddChild (void *gnp, void *lp)
+MakeAddChild (gnp, lp)
+    ClientData     gnp;		/* the node to add */
+    ClientData     lp;		/* the list to which to add it */
 {
     GNode          *gn = (GNode *) gnp;
@@ -267,5 +299,5 @@
 
     if (!gn->make && !(gn->type & OP_USE)) {
-	(void)Lst_EnQueue (l, (void *)gn);
+	(void)Lst_EnQueue (l, (ClientData)gn);
     }
     return (0);
@@ -297,8 +329,10 @@
  */
 int
-Make_HandleUse (GNode *cgn, GNode *pgn)
-{
-    GNode	*gn;	 	/* A child of the .USE node */
-    LstNode	ln;	 	/* An element in the children list */
+Make_HandleUse (cgn, pgn)
+    register GNode	*cgn;	/* The .USE node */
+    register GNode   	*pgn;	/* The target of the .USE node */
+{
+    register GNode	*gn; 	/* A child of the .USE node */
+    register LstNode	ln; 	/* An element in the children list */
 
     if (cgn->type & (OP_USE|OP_TRANSFORM)) {
@@ -312,8 +346,8 @@
 
 	if (Lst_Open (cgn->children) == SUCCESS) {
-	    while ((ln = Lst_Next (cgn->children)) != NULL) {
+	    while ((ln = Lst_Next (cgn->children)) != NILLNODE) {
 		gn = (GNode *)Lst_Datum (ln);
 
-		if (Lst_Member (pgn->children, gn) == NULL) {
+		if (Lst_Member (pgn->children, gn) == NILLNODE) {
 		    (void) Lst_AtEnd (pgn->children, gn);
 		    (void) Lst_AtEnd (gn->parents, pgn);
@@ -340,5 +374,7 @@
 }
 static int
-MakeHandleUse (void *pgn, void *cgn)
+MakeHandleUse (pgn, cgn)
+    ClientData pgn;	/* the current parent */
+    ClientData cgn;	/* the child we've just examined */
 {
     return Make_HandleUse((GNode *) pgn, (GNode *) cgn);
@@ -372,10 +408,11 @@
  */
 void
-Make_Update (GNode *cgn)
-{
-    GNode 	*pgn;		/* the parent node */
-    char  	*cname;		/* the child's name */
-    LstNode	ln;	 	/* Element in parents and iParents lists */
-    char	*p1;
+Make_Update (cgn)
+    register GNode *cgn;	/* the child node */
+{
+    register GNode 	*pgn;	/* the parent node */
+    register char  	*cname;	/* the child's name */
+    register LstNode	ln; 	/* Element in parents and iParents lists */
+    char *p1;
 
     cname = Var_Value (TARGET, cgn, &p1);
@@ -443,10 +480,12 @@
 	    cgn->mtime = now;
 	}
-	DEBUGF(MAKE, ("update time: %s\n", Targ_FmtTime(cgn->mtime)));
+	if (DEBUG(MAKE)) {
+	    printf("update time: %s\n", Targ_FmtTime(cgn->mtime));
+	}
 #endif
     }
 
     if (Lst_Open (cgn->parents) == SUCCESS) {
-	while ((ln = Lst_Next (cgn->parents)) != NULL) {
+	while ((ln = Lst_Next (cgn->parents)) != NILLNODE) {
 	    pgn = (GNode *)Lst_Datum (ln);
 	    if (pgn->make) {
@@ -468,5 +507,5 @@
 		     * be dealt with in MakeStartJobs.
 		     */
-		    (void)Lst_EnQueue (toBeMade, (void *)pgn);
+		    (void)Lst_EnQueue (toBeMade, (ClientData)pgn);
 		} else if (pgn->unmade < 0) {
 		    Error ("Graph cycles through %s", pgn->name);
@@ -482,11 +521,11 @@
      * before.
      */
-    for (ln = Lst_First(cgn->successors); ln != NULL; ln = Lst_Succ(ln)) {
+    for (ln = Lst_First(cgn->successors); ln != NILLNODE; ln = Lst_Succ(ln)) {
 	GNode	*succ = (GNode *)Lst_Datum(ln);
 
 	if (succ->make && succ->unmade == 0 && succ->made == UNMADE &&
-	    Lst_Member(toBeMade, (void *)succ) == NULL)
+	    Lst_Member(toBeMade, (ClientData)succ) == NILLNODE)
 	{
-	    (void)Lst_EnQueue(toBeMade, (void *)succ);
+	    (void)Lst_EnQueue(toBeMade, (ClientData)succ);
 	}
     }
@@ -497,8 +536,8 @@
      */
     if (Lst_Open (cgn->iParents) == SUCCESS) {
-	char    *ptr;
-	char	*cpref = Var_Value(PREFIX, cgn, &ptr);
-
-	while ((ln = Lst_Next (cgn->iParents)) != NULL) {
+	char    *p1;
+	char	*cpref = Var_Value(PREFIX, cgn, &p1);
+
+	while ((ln = Lst_Next (cgn->iParents)) != NILLNODE) {
 	    pgn = (GNode *)Lst_Datum (ln);
 	    if (pgn->make) {
@@ -507,5 +546,5 @@
 	    }
 	}
-	efree(ptr);
+	efree(p1);
 	Lst_Close (cgn->iParents);
     }
@@ -534,5 +573,8 @@
  */
 static int
-MakeAddAllSrc (void *cgnp, void *pgnp)
+MakeAddAllSrc (cgnp, pgnp)
+    ClientData	cgnp;	/* The child to add */
+    ClientData	pgnp;	/* The parent to whose ALLSRC variable it should be */
+			/* added */
 {
     GNode	*cgn = (GNode *) cgnp;
@@ -605,7 +647,8 @@
  */
 void
-Make_DoAllVar (GNode *gn)
-{
-    Lst_ForEach (gn->children, MakeAddAllSrc, (void *) gn);
+Make_DoAllVar (gn)
+    GNode	*gn;
+{
+    Lst_ForEach (gn->children, MakeAddAllSrc, (ClientData) gn);
 
     if (!Var_Exists (OODATE, gn)) {
@@ -641,11 +684,13 @@
  */
 static Boolean
-MakeStartJobs (void)
-{
-    GNode	*gn;
+MakeStartJobs ()
+{
+    register GNode	*gn;
 
     while (!Job_Full() && !Lst_IsEmpty (toBeMade)) {
 	gn = (GNode *) Lst_DeQueue (toBeMade);
-	DEBUGF(MAKE, ("Examining %s...", gn->name));
+	if (DEBUG(MAKE)) {
+	    printf ("Examining %s...", gn->name);
+	}
 	/*
 	 * Make sure any and all predecessors that are going to be made,
@@ -655,19 +700,21 @@
 	    LstNode ln;
 
-	    for (ln = Lst_First(gn->preds); ln != NULL; ln = Lst_Succ(ln)){
+	    for (ln = Lst_First(gn->preds); ln != NILLNODE; ln = Lst_Succ(ln)){
 		GNode	*pgn = (GNode *)Lst_Datum(ln);
 
 		if (pgn->make && pgn->made == UNMADE) {
-		    DEBUGF(MAKE, ("predecessor %s not made yet.\n", pgn->name));
+		    if (DEBUG(MAKE)) {
+			printf("predecessor %s not made yet.\n", pgn->name);
+		    }
 		    break;
 		}
 	    }
 	    /*
-	     * If ln isn't NULL, there's a predecessor as yet unmade, so we
+	     * If ln isn't nil, there's a predecessor as yet unmade, so we
 	     * just drop this node on the floor. When the node in question
 	     * has been made, it will notice this node as being ready to
 	     * make but as yet unmade and will place the node on the queue.
 	     */
-	    if (ln != NULL) {
+	    if (ln != NILLNODE) {
 		continue;
 	    }
@@ -676,5 +723,7 @@
 	numNodes--;
 	if (Make_OODate (gn)) {
-	    DEBUGF(MAKE, ("out-of-date\n"));
+	    if (DEBUG(MAKE)) {
+		printf ("out-of-date\n");
+	    }
 	    if (queryFlag) {
 		return (TRUE);
@@ -683,5 +732,7 @@
 	    Job_Make (gn);
 	} else {
-	    DEBUGF(MAKE, ("up-to-date\n"));
+	    if (DEBUG(MAKE)) {
+		printf ("up-to-date\n");
+	    }
 	    gn->made = UPTODATE;
 	    if (gn->type & OP_JOIN) {
@@ -707,7 +758,5 @@
  *	Print the status of a top-level node, viz. it being up-to-date
  *	already or not created due to an error in a lower level.
- *	Callback function for Make_Run via Lst_ForEach.  If gn->unmade is
- *	nonzero and that is meant to imply a cycle in the graph, then
- *	cycle is TRUE.
+ *	Callback function for Make_Run via Lst_ForEach.
  *
  * Results:
@@ -720,5 +769,9 @@
  */
 static int
-MakePrintStatus(void *gnp, void *cyclep)
+MakePrintStatus(gnp, cyclep)
+    ClientData  gnp;	    /* Node to examine */
+    ClientData 	cyclep;	    /* True if gn->unmade being non-zero implies
+			     * a cycle in the graph, not an error in an
+			     * inferior */
 {
     GNode   	*gn = (GNode *) gnp;
@@ -742,9 +795,9 @@
 		Error("Graph cycles through `%s'", gn->name);
 		gn->made = ENDCYCLE;
-		Lst_ForEach(gn->children, MakePrintStatus, (void *) &t);
+		Lst_ForEach(gn->children, MakePrintStatus, (ClientData) &t);
 		gn->made = UNMADE;
 	    } else if (gn->made != ENDCYCLE) {
 		gn->made = CYCLE;
-		Lst_ForEach(gn->children, MakePrintStatus, (void *) &t);
+		Lst_ForEach(gn->children, MakePrintStatus, (ClientData) &t);
 	    }
 	} else {
@@ -778,8 +831,9 @@
  */
 Boolean
-Make_Run (Lst targs)
-{
-    GNode	    *gn;	/* a temporary pointer */
-    Lst		    examine; 	/* List of targets to examine */
+Make_Run (targs)
+    Lst             targs;	/* the initial list of targets */
+{
+    register GNode  *gn;	/* a temporary pointer */
+    register Lst    examine; 	/* List of targets to examine */
     int	    	    errors; 	/* Number of errors the Job module reports */
 
@@ -808,11 +862,11 @@
 	     * to make sure everything has commands that should...
 	     */
-	    Lst_ForEach (gn->children, MakeHandleUse, (void *)gn);
+	    Lst_ForEach (gn->children, MakeHandleUse, (ClientData)gn);
 	    Suff_FindDeps (gn);
 
 	    if (gn->unmade != 0) {
-		Lst_ForEach (gn->children, MakeAddChild, (void *)examine);
+		Lst_ForEach (gn->children, MakeAddChild, (ClientData)examine);
 	    } else {
-		(void)Lst_EnQueue (toBeMade, (void *)gn);
+		(void)Lst_EnQueue (toBeMade, (ClientData)gn);
 	    }
 	}
@@ -855,5 +909,5 @@
     }
 
-    errors = Job_Finish();
+    errors = Job_End();
 
     /*
@@ -862,5 +916,5 @@
      */
     errors = ((errors == 0) && (numNodes != 0));
-    Lst_ForEach(targs, MakePrintStatus, (void *) &errors);
+    Lst_ForEach(targs, MakePrintStatus, (ClientData) &errors);
 
     return (TRUE);
Index: /trunk/src/kmk/make.h
===================================================================
--- /trunk/src/kmk/make.h	(revision 24)
+++ /trunk/src/kmk/make.h	(revision 25)
@@ -36,6 +36,6 @@
  * SUCH DAMAGE.
  *
- *	@(#)make.h	8.3 (Berkeley) 6/13/95
- * $FreeBSD: src/usr.bin/make/make.h,v 1.23 2002/10/10 19:27:48 jmallett Exp $
+ *	from: @(#)make.h	8.3 (Berkeley) 6/13/95
+ * $FreeBSD: src/usr.bin/make/make.h,v 1.12.2.2 2001/02/13 03:13:58 will Exp $
  */
 
@@ -46,5 +46,5 @@
 
 #ifndef _MAKE_H_
-#define	_MAKE_H_
+#define _MAKE_H_
 
 #include <sys/types.h>
@@ -52,7 +52,30 @@
 #include <string.h>
 #include <ctype.h>
-
+#include <err.h>
+
+#if !defined(MAKE_BOOTSTRAP) && defined(BSD4_4)
+# include <sys/cdefs.h>
+#else
+# ifndef __P
+#  if defined(__STDC__) || defined(__cplusplus)
+#   define	__P(protos)	protos		/* full-blown ANSI C */
+#  else
+#   define	__P(protos)	()		/* traditional C preprocessor */
+#  endif
+# endif
+# ifndef __STDC__
+#  ifndef const
+#   define const
+#  endif
+#  ifndef volatile
+#   define volatile
+#  endif
+# endif
+#endif
+
+#ifdef __STDC__
 #include <stdlib.h>
 #include <unistd.h>
+#endif
 #include "sprite.h"
 #include "lst.h"
@@ -64,5 +87,5 @@
  * pieces of data associated with it.
  *	1) the name of the target it describes
- *	2) the location of the target file in the filesystem.
+ *	2) the location of the target file in the file system.
  *	3) the type of operator used to define its sources (qv. parse.c)
  *	4) whether it is involved in this invocation of make
@@ -143,4 +166,9 @@
 
 /*
+ * Manifest constants
+ */
+#define NILGNODE	((GNode *) NIL)
+
+/*
  * The OP_ constants are used when parsing a dependency line as a way of
  * communicating to other parts of the program the way in which a target
@@ -151,44 +179,44 @@
  * righthand side...
  */
-#define	OP_DEPENDS	0x00000001  /* Execution of commands depends on
+#define OP_DEPENDS	0x00000001  /* Execution of commands depends on
 				     * kids (:) */
-#define	OP_FORCE	0x00000002  /* Always execute commands (!) */
-#define	OP_DOUBLEDEP	0x00000004  /* Execution of commands depends on kids
+#define OP_FORCE	0x00000002  /* Always execute commands (!) */
+#define OP_DOUBLEDEP	0x00000004  /* Execution of commands depends on kids
 				     * per line (::) */
-#define	OP_OPMASK	(OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP)
-
-#define	OP_OPTIONAL	0x00000008  /* Don't care if the target doesn't
+#define OP_OPMASK	(OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP)
+
+#define OP_OPTIONAL	0x00000008  /* Don't care if the target doesn't
 				     * exist and can't be created */
-#define	OP_USE		0x00000010  /* Use associated commands for parents */
-#define	OP_EXEC	  	0x00000020  /* Target is never out of date, but always
+#define OP_USE		0x00000010  /* Use associated commands for parents */
+#define OP_EXEC	  	0x00000020  /* Target is never out of date, but always
 				     * execute commands anyway. Its time
 				     * doesn't matter, so it has none...sort
 				     * of */
-#define	OP_IGNORE	0x00000040  /* Ignore errors when creating the node */
-#define	OP_PRECIOUS	0x00000080  /* Don't remove the target when
+#define OP_IGNORE	0x00000040  /* Ignore errors when creating the node */
+#define OP_PRECIOUS	0x00000080  /* Don't remove the target when
 				     * interrupted */
-#define	OP_SILENT	0x00000100  /* Don't echo commands when executed */
-#define	OP_MAKE		0x00000200  /* Target is a recurrsive make so its
+#define OP_SILENT	0x00000100  /* Don't echo commands when executed */
+#define OP_MAKE		0x00000200  /* Target is a recurrsive make so its
 				     * commands should always be executed when
 				     * it is out of date, regardless of the
 				     * state of the -n or -t flags */
-#define	OP_JOIN 	0x00000400  /* Target is out-of-date only if any of its
+#define OP_JOIN 	0x00000400  /* Target is out-of-date only if any of its
 				     * children was out-of-date */
-#define	OP_INVISIBLE	0x00004000  /* The node is invisible to its parents.
+#define OP_INVISIBLE	0x00004000  /* The node is invisible to its parents.
 				     * I.e. it doesn't show up in the parents's
 				     * local variables. */
-#define	OP_NOTMAIN	0x00008000  /* The node is exempt from normal 'main
+#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_PHONY	0x00010000  /* Not a file target; run always */
 /* 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 */
-#define	OP_LIB	  	0x20000000  /* Target is a library */
-#define	OP_ARCHV  	0x10000000  /* Target is an archive construct */
-#define	OP_HAS_COMMANDS	0x08000000  /* Target has all the commands it should.
+#define OP_TRANSFORM	0x80000000  /* The node is a transformation rule */
+#define OP_MEMBER 	0x40000000  /* Target is a member of an archive */
+#define OP_LIB	  	0x20000000  /* Target is a library */
+#define OP_ARCHV  	0x10000000  /* Target is an archive construct */
+#define OP_HAS_COMMANDS	0x08000000  /* Target has all the commands it should.
 				     * Used when parsing to catch multiple
 				     * commands for a target */
-#define	OP_SAVE_CMDS	0x04000000  /* Saving commands on .END (Compat) */
-#define	OP_DEPS_FOUND	0x02000000  /* Already processed by Suff_FindDeps */
+#define OP_SAVE_CMDS	0x04000000  /* Saving commands on .END (Compat) */
+#define OP_DEPS_FOUND	0x02000000  /* Already processed by Suff_FindDeps */
 
 /*
@@ -196,5 +224,5 @@
  * object of a dependency operator
  */
-#define	OP_NOP(t)	(((t) & OP_OPMASK) == 0x00000000)
+#define OP_NOP(t)	(((t) & OP_OPMASK) == 0x00000000)
 
 /*
@@ -204,8 +232,8 @@
  * is given, a new, empty node will be created for the target, placed in the
  * table of all targets and its address returned. If TARG_NOCREATE is given,
- * a NULL pointer will be returned.
- */
-#define	TARG_CREATE	0x01	  /* create node if not found */
-#define	TARG_NOCREATE	0x00	  /* don't create it */
+ * a NIL pointer will be returned.
+ */
+#define TARG_CREATE	0x01	  /* create node if not found */
+#define TARG_NOCREATE	0x00	  /* don't create it */
 
 /*
@@ -218,5 +246,5 @@
  * schemes allocate in powers of two.
  */
-#define	MAKE_BSIZE		256	/* starting size for expandable buffers */
+#define MAKE_BSIZE		256	/* starting size for expandable buffers */
 
 /*
@@ -229,7 +257,7 @@
  * Str_Concat returns.
  */
-#define	STR_ADDSPACE	0x01	/* add a space when Str_Concat'ing */
-#define	STR_DOFREE	0x02	/* free source strings after concatenation */
-#define	STR_ADDSLASH	0x04	/* add a slash when Str_Concat'ing */
+#define STR_ADDSPACE	0x01	/* add a space when Str_Concat'ing */
+#define STR_DOFREE	0x02	/* free source strings after concatenation */
+#define STR_ADDSLASH	0x04	/* add a slash when Str_Concat'ing */
 
 /*
@@ -238,31 +266,31 @@
  * as the first argument to Parse_Error.
  */
-#define	PARSE_WARNING	2
-#define	PARSE_FATAL	1
+#define PARSE_WARNING	2
+#define PARSE_FATAL	1
 
 /*
  * Values returned by Cond_Eval.
  */
-#define	COND_PARSE	0   	/* Parse the next lines */
-#define	COND_SKIP 	1   	/* Skip the next lines */
-#define	COND_INVALID	2   	/* Not a conditional statement */
+#define COND_PARSE	0   	/* Parse the next lines */
+#define COND_SKIP 	1   	/* Skip the next lines */
+#define COND_INVALID	2   	/* Not a conditional statement */
 
 /*
  * Definitions for the "local" variables. Used only for clarity.
  */
-#define	TARGET	  	  "@" 	/* Target of dependency */
-#define	OODATE	  	  "?" 	/* All out-of-date sources */
-#define	ALLSRC	  	  ">" 	/* All sources */
-#define	IMPSRC	  	  "<" 	/* Source implied by transformation */
-#define	PREFIX	  	  "*" 	/* Common prefix */
-#define	ARCHIVE	  	  "!" 	/* Archive in "archive(member)" syntax */
-#define	MEMBER	  	  "%" 	/* Member in "archive(member)" syntax */
-
-#define	FTARGET           "@F"  /* file part of TARGET */
-#define	DTARGET           "@D"  /* directory part of TARGET */
-#define	FIMPSRC           "<F"  /* file part of IMPSRC */
-#define	DIMPSRC           "<D"  /* directory part of IMPSRC */
-#define	FPREFIX           "*F"  /* file part of PREFIX */
-#define	DPREFIX           "*D"  /* directory part of PREFIX */
+#define TARGET	  	  "@" 	/* Target of dependency */
+#define OODATE	  	  "?" 	/* All out-of-date sources */
+#define ALLSRC	  	  ">" 	/* All sources */
+#define IMPSRC	  	  "<" 	/* Source implied by transformation */
+#define PREFIX	  	  "*" 	/* Common prefix */
+#define ARCHIVE	  	  "!" 	/* Archive in "archive(member)" syntax */
+#define MEMBER	  	  "%" 	/* Member in "archive(member)" syntax */
+
+#define FTARGET           "@F"  /* file part of TARGET */
+#define DTARGET           "@D"  /* directory part of TARGET */
+#define FIMPSRC           "<F"  /* file part of IMPSRC */
+#define DIMPSRC           "<D"  /* directory part of IMPSRC */
+#define FPREFIX           "*F"  /* file part of PREFIX */
+#define DPREFIX           "*D"  /* directory part of PREFIX */
 
 /*
@@ -274,8 +302,5 @@
 extern Lst     	dirSearchPath; 	/* The list of directories to search when
 				 * looking for targets */
-extern Lst	parseIncPath;	/* The list of directories to search when
-				 * looking for includes */
-
-extern Boolean	jobsRunning;	/* True if jobs are running */
+
 extern Boolean	compatMake;	/* True if we are make compatible */
 extern Boolean	ignoreErrors;  	/* True if should ignore all errors */
@@ -336,18 +361,17 @@
 #define	DEBUG_TARG	0x0100
 #define	DEBUG_VAR	0x0200
-#define	DEBUG_FOR	0x0400
-#define	DEBUG_LOUD	0x0800
-
-#define	CONCAT(a,b)	a##b
+#define DEBUG_FOR	0x0400
+#define DEBUG_LOUD	0x0800
+
+#ifdef __STDC__
+#define CONCAT(a,b)	a##b
+#else
+#define I(a)	  	a
+#define CONCAT(a,b)	I(a)b
+#endif /* __STDC__ */
 
 #define	DEBUG(module)	(debug & CONCAT(DEBUG_,module))
-#define	DEBUGF(module,args)		\
-do {						\
-	if (DEBUG(module)) {			\
-		Debug args ;			\
-	}					\
-} while (0)
-#define	ISDOT(c) ((c)[0] == '.' && (((c)[1] == '\0') || ((c)[1] == '/')))
-#define	ISDOTDOT(c) ((c)[0] == '.' && ISDOT(&((c)[1])))
+#define ISDOT(c) ((c)[0] == '.' && (((c)[1] == '\0') || ((c)[1] == '/')))
+#define ISDOTDOT(c) ((c)[0] == '.' && ISDOT(&((c)[1])))
 
 /*
@@ -357,10 +381,10 @@
 #include "nonints.h"
 
-int Make_TimeStamp(GNode *, GNode *);
-Boolean Make_OODate(GNode *);
-int Make_HandleUse(GNode *, GNode *);
-void Make_Update(GNode *);
-void Make_DoAllVar(GNode *);
-Boolean Make_Run(Lst);
+int Make_TimeStamp __P((GNode *, GNode *));
+Boolean Make_OODate __P((GNode *));
+int Make_HandleUse __P((GNode *, GNode *));
+void Make_Update __P((GNode *));
+void Make_DoAllVar __P((GNode *));
+Boolean Make_Run __P((Lst));
 
 #endif /* _MAKE_H_ */
Index: /trunk/src/kmk/nonints.h
===================================================================
--- /trunk/src/kmk/nonints.h	(revision 24)
+++ /trunk/src/kmk/nonints.h	(revision 25)
@@ -36,113 +36,113 @@
  * SUCH DAMAGE.
  *
- *	@(#)nonints.h	8.4 (Berkeley) 4/28/95
- * $FreeBSD: src/usr.bin/make/nonints.h,v 1.17 2002/09/18 16:13:03 jmallett Exp $
+ *	from: @(#)nonints.h	8.3 (Berkeley) 3/19/94
+ * $FreeBSD: src/usr.bin/make/nonints.h,v 1.8 1999/08/28 01:03:35 peter Exp $
  */
 
 /* arch.c */
-ReturnStatus Arch_ParseArchive(char **, Lst, GNode *);
-void Arch_Touch(GNode *);
-void Arch_TouchLib(GNode *);
-int Arch_MTime(GNode *);
-int Arch_MemMTime(GNode *);
-void Arch_FindLib(GNode *, Lst);
-Boolean Arch_LibOODate(GNode *);
-void Arch_Init(void);
-void Arch_End(void);
+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 *));
+void Arch_FindLib __P((GNode *, Lst));
+Boolean Arch_LibOODate __P((GNode *));
+void Arch_Init __P((void));
+void Arch_End __P((void));
 
 /* compat.c */
-void Compat_Run(Lst);
+void Compat_Run __P((Lst));
 
 /* cond.c */
-int Cond_Eval(char *);
-void Cond_End(void);
+int Cond_Eval __P((char *));
+void Cond_End __P((void));
 
 /* for.c */
-int For_Eval(char *);
-void For_Run(void);
+int For_Eval __P((char *));
+void For_Run  __P((void));
 
 /* main.c */
-void Main_ParseArgLine(char *);
-char *Cmd_Exec(char *, char **);
-void Debug(const char *, ...);
-void Error(const char *, ...);
-void Fatal(const char *, ...);
-void Punt(const char *, ...);
-void DieHorribly(void);
-int PrintAddr(void *, void *);
-void Finish(int);
-char *estrdup(const char *);
-void *emalloc(size_t);
+void Main_ParseArgLine __P((char *));
+int main __P((int, char **));
+char *Cmd_Exec __P((char *, char **));
+void Error __P((char *, ...));
+void Fatal __P((char *, ...));
+void Punt __P((char *, ...));
+void DieHorribly __P((void));
+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(void *, size_t);
-void enomem(void);
-int eunlink(const char *);
+#define efree	free
+void *erealloc __P((void *, size_t));
+void enomem __P((void));
+int eunlink __P((const char *));
 
 /* parse.c */
-void Parse_Error(int, const char *, ...);
-Boolean Parse_AnyExport(void);
-Boolean Parse_IsVar(char *);
-void Parse_DoVar(char *, GNode *);
-void Parse_AddIncludeDir(char *);
-void Parse_File(char *, FILE *);
-void Parse_Init(void);
-void Parse_End(void);
-void Parse_FromString(char *);
-Lst Parse_MainName(void);
+void Parse_Error __P((int, char *, ...));
+Boolean Parse_AnyExport __P((void));
+Boolean Parse_IsVar __P((char *));
+void Parse_DoVar __P((char *, GNode *));
+void Parse_AddIncludeDir __P((char *));
+void Parse_File __P((char *, FILE *));
+void Parse_Init __P((void));
+void Parse_End __P((void));
+void Parse_FromString __P((char *));
+Lst Parse_MainName __P((void));
 
 /* str.c */
-void str_init(void);
-void str_end(void);
-char *str_concat(char *, char *, int);
-char **brk_string(char *, int *, Boolean);
-char *Str_FindSubstring(char *, char *);
-int Str_Match(char *, char *);
-char *Str_SYSVMatch(char *, char *, int *len);
-void Str_SYSVSubst(Buffer, char *, char *, int);
+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 *Str_FindSubstring __P((char *, char *));
+int Str_Match __P((char *, char *));
+char *Str_SYSVMatch __P((char *, char *, int *len));
+void Str_SYSVSubst __P((Buffer, char *, char *, int));
 
 /* suff.c */
-void Suff_ClearSuffixes(void);
-Boolean Suff_IsTransform(char *);
-GNode *Suff_AddTransform(char *);
-int Suff_EndTransform(void *, void *);
-void Suff_AddSuffix(char *);
-Lst Suff_GetPath(char *);
-void Suff_DoPaths(void);
-void Suff_AddInclude(char *);
-void Suff_AddLib(char *);
-void Suff_FindDeps(GNode *);
-void Suff_SetNull(char *);
-void Suff_Init(void);
-void Suff_End(void);
-void Suff_PrintAll(void);
+void Suff_ClearSuffixes __P((void));
+Boolean Suff_IsTransform __P((char *));
+GNode *Suff_AddTransform __P((char *));
+int Suff_EndTransform __P((ClientData, ClientData));
+void Suff_AddSuffix __P((char *));
+Lst Suff_GetPath __P((char *));
+void Suff_DoPaths __P((void));
+void Suff_AddInclude __P((char *));
+void Suff_AddLib __P((char *));
+void Suff_FindDeps __P((GNode *));
+void Suff_SetNull __P((char *));
+void Suff_Init __P((void));
+void Suff_End __P((void));
+void Suff_PrintAll __P((void));
 
 /* targ.c */
-void Targ_Init(void);
-void Targ_End(void);
-GNode *Targ_NewGN(char *);
-GNode *Targ_FindNode(char *, int);
-Lst Targ_FindList(Lst, int);
-Boolean Targ_Ignore(GNode *);
-Boolean Targ_Silent(GNode *);
-Boolean Targ_Precious(GNode *);
-void Targ_SetMain(GNode *);
-int Targ_PrintCmd(void *, void *);
-char *Targ_FmtTime(time_t);
-void Targ_PrintType(int);
-void Targ_PrintGraph(int);
+void Targ_Init __P((void));
+void Targ_End __P((void));
+GNode *Targ_NewGN __P((char *));
+GNode *Targ_FindNode __P((char *, int));
+Lst Targ_FindList __P((Lst, int));
+Boolean Targ_Ignore __P((GNode *));
+Boolean Targ_Silent __P((GNode *));
+Boolean Targ_Precious __P((GNode *));
+void Targ_SetMain __P((GNode *));
+int Targ_PrintCmd __P((ClientData, ClientData));
+char *Targ_FmtTime __P((time_t));
+void Targ_PrintType __P((int));
+void Targ_PrintGraph __P((int));
 
 /* var.c */
-void Var_Delete(char *, GNode *);
-void Var_Set(char *, char *, GNode *);
-void Var_Append(char *, char *, GNode *);
-Boolean Var_Exists(char *, GNode *);
-char *Var_Value(char *, GNode *, char **);
-char *Var_Parse(char *, GNode *, Boolean, int *, Boolean *);
-char *Var_Subst(char *, char *, GNode *, Boolean);
-char *Var_GetTail(char *);
-char *Var_GetHead(char *);
-void Var_Init(void);
-void Var_End(void);
-void Var_Dump(GNode *);
+void Var_Delete __P((char *, GNode *));
+void Var_Set __P((char *, char *, GNode *));
+void Var_Append __P((char *, char *, GNode *));
+Boolean Var_Exists __P((char *, GNode *));
+char *Var_Value __P((char *, GNode *, char **));
+char *Var_Parse __P((char *, GNode *, Boolean, int *, Boolean *));
+char *Var_Subst __P((char *, char *, GNode *, Boolean));
+char *Var_GetTail __P((char *));
+char *Var_GetHead __P((char *));
+void Var_Init __P((void));
+void Var_End __P((void));
+void Var_Dump __P((GNode *));
Index: /trunk/src/kmk/parse.c
===================================================================
--- /trunk/src/kmk/parse.c	(revision 24)
+++ /trunk/src/kmk/parse.c	(revision 25)
@@ -35,10 +35,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * @(#)parse.c	8.3 (Berkeley) 3/19/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/parse.c,v 1.48 2002/10/09 03:42:10 jmallett Exp $");
+ */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)parse.c	8.3 (Berkeley) 3/19/94";
+#else
+static const char rcsid[] =
+  "$FreeBSD: src/usr.bin/make/parse.c,v 1.22 1999/08/28 01:03:35 peter Exp $";
+#endif
+#endif /* not lint */
 
 /*-
@@ -84,5 +88,9 @@
  */
 
+#ifdef __STDC__
 #include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
 #include <ctype.h>
 #include <err.h>
@@ -178,5 +186,5 @@
 
 /*
- * Predecessor node for handling .ORDER. Initialized to NULL when .ORDER
+ * Predecessor node for handling .ORDER. Initialized to NILGNODE when .ORDER
  * seen, then set to each successive source on the line.
  */
@@ -231,26 +239,26 @@
 };
 
-static int ParseFindKeyword(char *);
-static int ParseLinkSrc(void *, void *);
-static int ParseDoOp(void *, void *);
-static int ParseAddDep(void *, void *);
-static void ParseDoSrc(int, char *, Lst);
-static int ParseFindMain(void *, void *);
-static int ParseAddDir(void *, void *);
-static int ParseClearPath(void *, void *);
-static void ParseDoDependency(char *);
-static int ParseAddCmd(void *, void *);
-static int ParseReadc(void);
-static void ParseUnreadc(int);
-static void ParseHasCommands(void *);
-static void ParseDoInclude(char *);
-static void ParseDoError(char *);
+static int ParseFindKeyword __P((char *));
+static int ParseLinkSrc __P((ClientData, ClientData));
+static int ParseDoOp __P((ClientData, ClientData));
+static int ParseAddDep __P((ClientData, ClientData));
+static void ParseDoSrc __P((int, char *, Lst));
+static int ParseFindMain __P((ClientData, ClientData));
+static int ParseAddDir __P((ClientData, ClientData));
+static int ParseClearPath __P((ClientData, ClientData));
+static void ParseDoDependency __P((char *));
+static int ParseAddCmd __P((ClientData, ClientData));
+static int ParseReadc __P((void));
+static void ParseUnreadc __P((int));
+static void ParseHasCommands __P((ClientData));
+static void ParseDoInclude __P((char *));
+static void ParseDoError __P((char *));
 #ifdef SYSVINCLUDE
-static void ParseTraditionalInclude(char *);
+static void ParseTraditionalInclude __P((char *));
 #endif
-static int ParseEOF(int);
-static char *ParseReadLine(void);
-static char *ParseSkipLine(int);
-static void ParseFinishLine(void);
+static int ParseEOF __P((int));
+static char *ParseReadLine __P((void));
+static char *ParseSkipLine __P((int));
+static void ParseFinishLine __P((void));
 
 /*-
@@ -267,10 +275,11 @@
  */
 static int
-ParseFindKeyword (char *str)
-{
-    int		    start,
+ParseFindKeyword (str)
+    char	    *str;		/* String to find */
+{
+    register int    start,
 		    end,
 		    cur;
-    int		    diff;
+    register int    diff;
 
     start = 0;
@@ -306,9 +315,23 @@
 /* VARARGS */
 void
-Parse_Error(int type, const char *fmt, ...)
+#ifdef __STDC__
+Parse_Error(int type, char *fmt, ...)
+#else
+Parse_Error(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;
+
+	va_start(ap);
+	type = va_arg(ap, int);
+	fmt = va_arg(ap, char *);
+#endif
+
 	(void)fprintf(stderr, "\"%s\", line %d: ", fname, lineno);
 	if (type == PARSE_WARNING)
@@ -339,12 +362,14 @@
  */
 static int
-ParseLinkSrc (void *pgnp, void *cgnp)
+ParseLinkSrc (pgnp, cgnp)
+    ClientData     pgnp;	/* The parent node */
+    ClientData     cgnp;	/* The child node */
 {
     GNode          *pgn = (GNode *) pgnp;
     GNode          *cgn = (GNode *) cgnp;
-    if (Lst_Member (pgn->children, (void *)cgn) == NULL) {
-	(void)Lst_AtEnd (pgn->children, (void *)cgn);
+    if (Lst_Member (pgn->children, (ClientData)cgn) == NILLNODE) {
+	(void)Lst_AtEnd (pgn->children, (ClientData)cgn);
 	if (specType == Not) {
-	    (void)Lst_AtEnd (cgn->parents, (void *)pgn);
+	    (void)Lst_AtEnd (cgn->parents, (ClientData)pgn);
 	}
 	pgn->unmade += 1;
@@ -370,5 +395,8 @@
  */
 static int
-ParseDoOp (void *gnp, void *opp)
+ParseDoOp (gnp, opp)
+    ClientData     gnp;		/* The node to which the operator is to be
+				 * applied */
+    ClientData     opp;		/* The operator to apply */
 {
     GNode          *gn = (GNode *) gnp;
@@ -395,5 +423,5 @@
 	 * instance.
 	 */
-	GNode		*cohort;
+	register GNode	*cohort;
 	LstNode	    	ln;
 
@@ -408,13 +436,13 @@
 	 * sorry.
 	 */
-	Lst_ForEach(gn->parents, ParseLinkSrc, (void *)cohort);
+	Lst_ForEach(gn->parents, ParseLinkSrc, (ClientData)cohort);
 	cohort->type = OP_DOUBLEDEP|OP_INVISIBLE;
-	(void)Lst_AtEnd(gn->cohorts, (void *)cohort);
+	(void)Lst_AtEnd(gn->cohorts, (ClientData)cohort);
 
 	/*
 	 * Replace the node in the targets list with the new copy
 	 */
-	ln = Lst_Member(targets, (void *)gn);
-	Lst_Replace(ln, (void *)cohort);
+	ln = Lst_Member(targets, (ClientData)gn);
+	Lst_Replace(ln, (ClientData)cohort);
 	gn = cohort;
     }
@@ -445,5 +473,7 @@
  */
 static int
-ParseAddDep(void *pp, void *sp)
+ParseAddDep(pp, sp)
+    ClientData pp;
+    ClientData sp;
 {
     GNode *p = (GNode *) pp;
@@ -456,6 +486,6 @@
 	 * problem
 	 */
-	(void)Lst_AtEnd(p->successors, (void *)s);
-	(void)Lst_AtEnd(s->preds, (void *)p);
+	(void)Lst_AtEnd(p->successors, (ClientData)s);
+	(void)Lst_AtEnd(s->preds, (ClientData)p);
 	return 0;
     }
@@ -483,14 +513,17 @@
  */
 static void
-ParseDoSrc (int tOp, char *src, Lst allsrc)
+ParseDoSrc (tOp, src, allsrc)
+    int		tOp;	/* operator (if any) from special targets */
+    char	*src;	/* name of the source to handle */
+    Lst		allsrc;	/* List of all sources to wait for */
 {
     GNode	*gn = NULL;
 
-    if (*src == '.' && isupper ((unsigned char) src[1])) {
+    if (*src == '.' && isupper (src[1])) {
 	int keywd = ParseFindKeyword(src);
 	if (keywd != -1) {
 	    int op = parseKeywords[keywd].op;
 	    if (op != 0) {
-		Lst_ForEach (targets, ParseDoOp, (void *)&op);
+		Lst_ForEach (targets, ParseDoOp, (ClientData)&op);
 		return;
 	    }
@@ -512,5 +545,5 @@
 	 * line. This is to allow #ifmake's to succeed, or something...
 	 */
-	(void) Lst_AtEnd (create, (void *)estrdup(src));
+	(void) Lst_AtEnd (create, (ClientData)estrdup(src));
 	/*
 	 * Add the name to the .TARGETS variable as well, so the user cna
@@ -526,7 +559,7 @@
 	 */
 	gn = Targ_FindNode(src, TARG_CREATE);
-	if (predecessor != NULL) {
-	    (void)Lst_AtEnd(predecessor->successors, (void *)gn);
-	    (void)Lst_AtEnd(gn->preds, (void *)predecessor);
+	if (predecessor != NILGNODE) {
+	    (void)Lst_AtEnd(predecessor->successors, (ClientData)gn);
+	    (void)Lst_AtEnd(gn->preds, (ClientData)predecessor);
 	}
 	/*
@@ -552,16 +585,16 @@
 	    gn->type |= tOp;
 	} else {
-	    Lst_ForEach (targets, ParseLinkSrc, (void *)gn);
+	    Lst_ForEach (targets, ParseLinkSrc, (ClientData)gn);
 	}
 	if ((gn->type & OP_OPMASK) == OP_DOUBLEDEP) {
-	    GNode  	*cohort;
-	    LstNode	ln;
-
-	    for (ln=Lst_First(gn->cohorts); ln != NULL; ln = Lst_Succ(ln)){
+	    register GNode  	*cohort;
+	    register LstNode	ln;
+
+	    for (ln=Lst_First(gn->cohorts); ln != NILLNODE; ln = Lst_Succ(ln)){
 		cohort = (GNode *)Lst_Datum(ln);
 		if (tOp) {
 		    cohort->type |= tOp;
 		} else {
-		    Lst_ForEach(targets, ParseLinkSrc, (void *)cohort);
+		    Lst_ForEach(targets, ParseLinkSrc, (ClientData)cohort);
 		}
 	    }
@@ -571,7 +604,7 @@
 
     gn->order = waiting;
-    (void)Lst_AtEnd(allsrc, (void *)gn);
+    (void)Lst_AtEnd(allsrc, (ClientData)gn);
     if (waiting) {
-	Lst_ForEach(allsrc, ParseAddDep, (void *)gn);
+	Lst_ForEach(allsrc, ParseAddDep, (ClientData)gn);
     }
 }
@@ -593,5 +626,7 @@
  */
 static int
-ParseFindMain(void *gnp, void *dummy __unused)
+ParseFindMain(gnp, dummy)
+    ClientData	  gnp;	    /* Node to examine */
+    ClientData    dummy;
 {
     GNode   	  *gn = (GNode *) gnp;
@@ -599,7 +634,7 @@
 	mainNode = gn;
 	Targ_SetMain(gn);
-	return (1);
+	return (dummy ? 1 : 1);
     } else {
-	return (0);
+	return (dummy ? 0 : 0);
     }
 }
@@ -619,5 +654,7 @@
  */
 static int
-ParseAddDir(void *path, void *name)
+ParseAddDir(path, name)
+    ClientData	  path;
+    ClientData    name;
 {
     Dir_AddDir((Lst) path, (char *) name);
@@ -639,8 +676,10 @@
  */
 static int
-ParseClearPath(void *path, void *dummy __unused)
+ParseClearPath(path, dummy)
+    ClientData path;
+    ClientData dummy;
 {
     Dir_ClearPath((Lst) path);
-    return (0);
+    return(dummy ? 0 : 0);
 }
 
@@ -680,5 +719,6 @@
  */
 static void
-ParseDoDependency (char *line)
+ParseDoDependency (line)
+    char           *line;	/* the line to parse */
 {
     char  	   *cp;		/* our current position */
@@ -706,5 +746,6 @@
     do {
 	for (cp = line;
-	     *cp && !isspace ((unsigned char) *cp) && *cp != '(';
+	     *cp && !isspace (*cp) &&
+	     (*cp != '!') && (*cp != ':') && (*cp != '(');
 	     cp++)
 	{
@@ -727,34 +768,4 @@
 		}
 		cp += length-1;
-	    } else if (*cp == '!' || *cp == ':') {
-		/*
-		 * We don't want to end a word on ':' or '!' if there is a
-		 * better match later on in the string.  By "better" I mean
-		 * one that is followed by whitespace.	This allows the user
-		 * to have targets like:
-		 *    fie::fi:fo: fum
-		 * where "fie::fi:fo" is the target.  In real life this is used
-		 * for perl5 library man pages where "::" separates an object
-		 * from its class.  Ie: "File::Spec::Unix".  This behaviour
-		 * is also consistent with other versions of make.
-		 */
-		char *p = cp + 1;
-
-		if (*cp == ':' && *p == ':')
-		    p++;
-
-		/* Found the best match already. */
-		if (*p == '\0' || isspace(*p))
-		    break;
-
-		do {
-		    p += strcspn(p, "!:");
-		    if (*p == '\0')
-			break;
-		} while (!isspace(*++p));
-
-		/* No better match later on... */
-		if (*p == '\0')
-		    break;
 	    }
 	    continue;
@@ -784,14 +795,7 @@
 	    /*
 	     * Ending a dependency line without an operator is a Bozo
-	     * no-no.  As a heuristic, this is also often triggered by
-	     * undetected conflicts from cvs/rcs merges.
+	     * no-no
 	     */
-	    if ((strncmp(line, "<<<<<<", 6) == 0) ||
-		(strncmp(line, "======", 6) == 0) ||
-		(strncmp(line, ">>>>>>", 6) == 0))
-		Parse_Error (PARSE_FATAL,
-		    "Makefile appears to contain unresolved cvs/rcs/??? merge conflicts");
-	    else
-	        Parse_Error (PARSE_FATAL, "Need an operator");
+	    Parse_Error (PARSE_FATAL, "Need an operator");
 	    return;
 	}
@@ -801,5 +805,5 @@
 	 * specType to match it.
 	 */
-	if (*line == '.' && isupper ((unsigned char) line[1])) {
+	if (*line == '.' && isupper (line[1])) {
 	    /*
 	     * See if the target is a special target that must have it
@@ -842,5 +846,5 @@
 		 *  	.NOTPARALLEL	Make only one target at a time.
 		 *  	.SINGLESHELL	Create a shell for each command.
-		 *  	.ORDER	    	Must set initial predecessor to NULL
+		 *  	.ORDER	    	Must set initial predecessor to NIL
 		 */
 		switch (specType) {
@@ -849,5 +853,5 @@
 			    paths = Lst_Init(FALSE);
 			}
-			(void)Lst_AtEnd(paths, (void *)dirSearchPath);
+			(void)Lst_AtEnd(paths, (ClientData)dirSearchPath);
 			break;
 		    case Main:
@@ -861,14 +865,16 @@
 			gn = Targ_FindNode(line, TARG_CREATE);
 			gn->type |= OP_NOTMAIN;
-			(void)Lst_AtEnd(targets, (void *)gn);
+			(void)Lst_AtEnd(targets, (ClientData)gn);
 			break;
 		    case Default:
 			gn = Targ_NewGN(".DEFAULT");
 			gn->type |= (OP_NOTMAIN|OP_TRANSFORM);
-			(void)Lst_AtEnd(targets, (void *)gn);
+			(void)Lst_AtEnd(targets, (ClientData)gn);
 			DEFAULT = gn;
 			break;
 		    case NotParallel:
 		    {
+			extern int  maxJobs;
+
 			maxJobs = 1;
 			break;
@@ -878,5 +884,5 @@
 			break;
 		    case Order:
-			predecessor = NULL;
+			predecessor = NILGNODE;
 			break;
 		    default:
@@ -893,5 +899,5 @@
 		specType = ExPath;
 		path = Suff_GetPath (&line[5]);
-		if (path == NULL) {
+		if (path == NILLST) {
 		    Parse_Error (PARSE_FATAL,
 				 "Suffix '%s' not defined (yet)",
@@ -902,5 +908,5 @@
 			paths = Lst_Init(FALSE);
 		    }
-		    (void)Lst_AtEnd(paths, (void *)path);
+		    (void)Lst_AtEnd(paths, (ClientData)path);
 		}
 	    }
@@ -929,5 +935,5 @@
 		 * so create a list with the word on it.
 		 */
-		(void)Lst_AtEnd(curTargs, (void *)line);
+		(void)Lst_AtEnd(curTargs, (ClientData)line);
 	    }
 
@@ -941,5 +947,5 @@
 		}
 
-		(void)Lst_AtEnd (targets, (void *)gn);
+		(void)Lst_AtEnd (targets, (ClientData)gn);
 	    }
 	} else if (specType == ExPath && *line != '.' && *line != '\0') {
@@ -965,5 +971,5 @@
 	    }
 	} else {
-	    while (*cp && isspace ((unsigned char) *cp)) {
+	    while (*cp && isspace (*cp)) {
 		cp++;
 	    }
@@ -1018,10 +1024,10 @@
     cp++;			/* Advance beyond operator */
 
-    Lst_ForEach (targets, ParseDoOp, (void *)&op);
+    Lst_ForEach (targets, ParseDoOp, (ClientData)&op);
 
     /*
      * Get to the first source
      */
-    while (*cp && isspace ((unsigned char) *cp)) {
+    while (*cp && isspace (*cp)) {
 	cp++;
     }
@@ -1052,5 +1058,5 @@
 		break;
 	    case ExPath:
-		Lst_ForEach(paths, ParseClearPath, (void *)NULL);
+		Lst_ForEach(paths, ParseClearPath, (ClientData)NULL);
 		break;
 #ifdef POSIX
@@ -1112,9 +1118,9 @@
 	     * has no valid suffix.
 	     */
-	    char  savech;
-	    while (*cp && !isspace ((unsigned char) *cp)) {
+	    char  savec;
+	    while (*cp && !isspace (*cp)) {
 		cp++;
 	    }
-	    savech = *cp;
+	    savec = *cp;
 	    *cp = '\0';
 	    switch (specType) {
@@ -1123,5 +1129,5 @@
 		    break;
 		case ExPath:
-		    Lst_ForEach(paths, ParseAddDir, (void *)line);
+		    Lst_ForEach(paths, ParseAddDir, (ClientData)line);
 		    break;
 		case Includes:
@@ -1137,9 +1143,9 @@
 		    break;
 	    }
-	    *cp = savech;
-	    if (savech != '\0') {
+	    *cp = savec;
+	    if (savec != '\0') {
 		cp++;
 	    }
-	    while (*cp && isspace ((unsigned char) *cp)) {
+	    while (*cp && isspace (*cp)) {
 		cp++;
 	    }
@@ -1156,5 +1162,5 @@
 	     * and handle them accordingly.
 	     */
-	    while (*cp && !isspace ((unsigned char) *cp)) {
+	    while (*cp && !isspace (*cp)) {
 		if ((*cp == '(') && (cp > line) && (cp[-1] != '$')) {
 		    /*
@@ -1171,5 +1177,5 @@
 
 	    if (*cp == '(') {
-		GNode	  *gnp;
+		GNode	  *gn;
 
 		sources = Lst_Init (FALSE);
@@ -1181,6 +1187,6 @@
 
 		while (!Lst_IsEmpty (sources)) {
-		    gnp = (GNode *) Lst_DeQueue (sources);
-		    ParseDoSrc (tOp, gnp->name, curSrcs);
+		    gn = (GNode *) Lst_DeQueue (sources);
+		    ParseDoSrc (tOp, gn->name, curSrcs);
 		}
 		Lst_Destroy (sources, NOFREE);
@@ -1194,5 +1200,5 @@
 		ParseDoSrc (tOp, line, curSrcs);
 	    }
-	    while (*cp && isspace ((unsigned char) *cp)) {
+	    while (*cp && isspace (*cp)) {
 		cp++;
 	    }
@@ -1201,5 +1207,5 @@
     }
 
-    if (mainNode == NULL) {
+    if (mainNode == NILGNODE) {
 	/*
 	 * If we have yet to decide on a main target to make, in the
@@ -1208,5 +1214,5 @@
 	 * (i.e. isn't a .USE or .EXEC rule) to be made.
 	 */
-	Lst_ForEach (targets, ParseFindMain, (void *)0);
+	Lst_ForEach (targets, ParseFindMain, (ClientData)0);
     }
 
@@ -1234,10 +1240,11 @@
  */
 Boolean
-Parse_IsVar (char *line)
-{
-    Boolean wasSpace = FALSE;	/* set TRUE if found a space */
-    Boolean haveName = FALSE;	/* Set TRUE if have a variable name */
+Parse_IsVar (line)
+    register char  *line;	/* the line to check */
+{
+    register Boolean wasSpace = FALSE;	/* set TRUE if found a space */
+    register Boolean haveName = FALSE;	/* Set TRUE if have a variable name */
     int level = 0;
-#define	ISEQOPERATOR(c) \
+#define ISEQOPERATOR(c) \
 	(((c) == '+') || ((c) == ':') || ((c) == '?') || ((c) == '!'))
 
@@ -1335,5 +1342,8 @@
  */
 void
-Parse_DoVar (char *line, GNode *ctxt)
+Parse_DoVar (line, ctxt)
+    char            *line;	/* a line guaranteed to be a variable
+				 * assignment. This reduces error checks */
+    GNode   	    *ctxt;    	/* Context in which to do the assignment */
 {
     char	   *cp;	/* pointer into line */
@@ -1363,5 +1373,5 @@
      */
     for (cp = line + 1; *cp != '='; cp++) {
-	if (isspace ((unsigned char) *cp)) {
+	if (isspace (*cp)) {
 	    *cp = '\0';
 	}
@@ -1419,5 +1429,5 @@
     }
 
-    while (isspace ((unsigned char) *cp)) {
+    while (isspace (*cp)) {
 	cp++;
     }
@@ -1440,12 +1450,4 @@
 
 	oldVars = FALSE;
-
-	/*
-	 * make sure that we set the variable the first time to nothing
-	 * so that it gets substituted!
-	 */
-	if (!Var_Exists(line, ctxt))
-	    Var_Set(line, "", ctxt);
-
 	cp = Var_Subst(NULL, cp, ctxt, FALSE);
 	oldVars = oldOldVars;
@@ -1456,5 +1458,5 @@
 	Boolean	freeCmd = FALSE; /* TRUE if the command needs to be freed, i.e.
 				  * if any variable expansion was performed */
-	char *res, *error;
+	char *res, *err;
 
 	if (strchr(cp, '$') != NULL) {
@@ -1468,10 +1470,10 @@
 	}
 
-	res = Cmd_Exec(cp, &error);
+	res = Cmd_Exec(cp, &err);
 	Var_Set(line, res, ctxt);
 	free(res);
 
-	if (error)
-	    Parse_Error(PARSE_WARNING, error, cp);
+	if (err)
+	    Parse_Error(PARSE_WARNING, err, cp);
 
 	if (freeCmd)
@@ -1497,5 +1499,7 @@
  */
 static int
-ParseAddCmd(void *gnp, void *cmd)
+ParseAddCmd(gnp, cmd)
+    ClientData gnp;	/* the node to which the command is to be added */
+    ClientData cmd;	/* the command to add */
 {
     GNode *gn = (GNode *) gnp;
@@ -1503,8 +1507,4 @@
     if (!(gn->type & OP_HAS_COMMANDS))
 	(void)Lst_AtEnd(gn->commands, cmd);
-    else
-	Parse_Error(PARSE_WARNING,
-		    "duplicate script for target \"%s\" ignored",
-		    gn->name);
     return(0);
 }
@@ -1527,5 +1527,6 @@
  */
 static void
-ParseHasCommands(void *gnp)
+ParseHasCommands(gnp)
+    ClientData 	  gnp;	    /* Node to examine */
 {
     GNode *gn = (GNode *) gnp;
@@ -1550,5 +1551,6 @@
  */
 void
-Parse_AddIncludeDir (char *dir)
+Parse_AddIncludeDir (dir)
+    char    	  *dir;	    /* The name of the directory to add */
 {
     Dir_AddDir (parseIncPath, dir);
@@ -1566,12 +1568,13 @@
  */
 static void
-ParseDoError(char *errmsg)
-{
-	if (!isspace((unsigned char) *errmsg)) {
+ParseDoError(errmsg)
+    char          *errmsg;	/* error message */
+{
+	if (!isspace(*errmsg)) {
 		Parse_Error(PARSE_WARNING, "invalid syntax: .error%s", errmsg);
 		return;
 	}
 	
-	while (isspace((unsigned char) *errmsg))
+	while (isspace(*errmsg))
 		errmsg++;
 	
@@ -1602,5 +1605,6 @@
  */
 static void
-ParseDoInclude (char *file)
+ParseDoInclude (file)
+    char          *file;	/* file specification */
 {
     char          *fullname;	/* full pathname of file */
@@ -1741,5 +1745,5 @@
     oldFile->lineno = lineno;
 
-    (void) Lst_AtFront (includes, (void *)oldFile);
+    (void) Lst_AtFront (includes, (ClientData)oldFile);
 
     /*
@@ -1779,9 +1783,11 @@
  */
 void
-Parse_FromString(char *str)
+Parse_FromString(str)
+    char *str;
 {
     IFile         *oldFile;	/* state associated with this file */
 
-    DEBUGF(FOR, ("%s\n----\n", str));
+    if (DEBUG(FOR))
+	(void) fprintf(stderr, "%s\n----\n", str);
 
     oldFile = (IFile *) emalloc (sizeof (IFile));
@@ -1791,5 +1797,5 @@
     oldFile->p = curPTR;
 
-    (void) Lst_AtFront (includes, (void *)oldFile);
+    (void) Lst_AtFront (includes, (ClientData)oldFile);
 
     curFILE = NULL;
@@ -1819,5 +1825,6 @@
  */
 static void
-ParseTraditionalInclude (char *file)
+ParseTraditionalInclude (file)
+    char          *file;	/* file specification */
 {
     char          *fullname;	/* full pathname of file */
@@ -1921,5 +1928,5 @@
     oldFile->lineno = lineno;
 
-    (void) Lst_AtFront (includes, (void *)oldFile);
+    (void) Lst_AtFront (includes, (ClientData)oldFile);
 
     /*
@@ -1960,5 +1967,6 @@
  */
 static int
-ParseEOF (int opened)
+ParseEOF (opened)
+    int opened;
 {
     IFile     *ifile;	/* the state on the top of the includes stack */
@@ -1969,5 +1977,5 @@
 
     ifile = (IFile *) Lst_DeQueue (includes);
-    free (fname);
+    free ((Address) fname);
     fname = ifile->fname;
     lineno = ifile->lineno;
@@ -1975,10 +1983,10 @@
 	(void) fclose (curFILE);
     if (curPTR) {
-	free(curPTR->str);
-	free(curPTR);
+	free((Address) curPTR->str);
+	free((Address) curPTR);
     }
     curFILE = ifile->F;
     curPTR = ifile->p;
-    free (ifile);
+    free ((Address)ifile);
     return (CONTINUE);
 }
@@ -1996,5 +2004,5 @@
  */
 static int
-ParseReadc(void)
+ParseReadc()
 {
     if (curFILE)
@@ -2019,5 +2027,6 @@
  */
 static void
-ParseUnreadc(int c)
+ParseUnreadc(c)
+    int c;
 {
     if (curFILE) {
@@ -2033,9 +2042,9 @@
 
 /* ParseSkipLine():
- *	Grab the next line unless it begins with a dot (`.') and we're told to
- *	ignore such lines.
+ *	Grab the next line
  */
 static char *
-ParseSkipLine(int skip)
+ParseSkipLine(skip)
+    int skip; 		/* Skip lines that don't start with . */
 {
     char *line;
@@ -2055,6 +2064,5 @@
                 lineno++;
 
-                while ((c = ParseReadc()) == ' ' || c == '\t')
-		    continue;
+                while ((c = ParseReadc()) == ' ' || c == '\t');
 
                 if (c == EOF)
@@ -2100,9 +2108,9 @@
  */
 static char *
-ParseReadLine (void)
+ParseReadLine ()
 {
     Buffer  	  buf;	    	/* Buffer for current line */
-    int		  c;	      	/* the current character */
-    int		  lastc;    	/* The most-recent character */
+    register int  c;	      	/* the current character */
+    register int  lastc;    	/* The most-recent character */
     Boolean	  semiNL;     	/* treat semi-colons as newlines */
     Boolean	  ignDepOp;   	/* TRUE if should ignore dependency operators
@@ -2221,5 +2229,9 @@
 	    case '#':
 		if (!ignComment) {
-		    if (lastc != '\\') {
+		    if (
+#if 0
+		    compatMake &&
+#endif
+		    (lastc != '\\')) {
 			/*
 			 * If the character is a hash mark and it isn't escaped
@@ -2252,6 +2264,4 @@
 		}
 		break;
-	    default:
-		break;
 	    }
 	    /*
@@ -2274,5 +2284,5 @@
 	/*
 	 * Strip trailing blanks and tabs from the line.
-	 * Do not strip a blank or tab that is preceded by
+	 * Do not strip a blank or tab that is preceeded by
 	 * a '\'
 	 */
@@ -2305,5 +2315,5 @@
 		/*FALLTHRU*/
 	    case COND_PARSE:
-		free (line);
+		free ((Address) line);
 		line = ParseReadLine();
 		break;
@@ -2331,6 +2341,4 @@
 		}
 		break;
-	    default:
-		break;
 	    }
 	}
@@ -2359,8 +2367,8 @@
  */
 static void
-ParseFinishLine(void)
+ParseFinishLine()
 {
     if (inLine) {
-	Lst_ForEach(targets, Suff_EndTransform, (void *)NULL);
+	Lst_ForEach(targets, Suff_EndTransform, (ClientData)NULL);
 	Lst_Destroy (targets, ParseHasCommands);
 	targets = NULL;
@@ -2386,7 +2394,9 @@
  */
 void
-Parse_File(char *name, FILE *stream)
-{
-    char	  *cp,		/* pointer into the line */
+Parse_File(name, stream)
+    char          *name;	/* the name of the file being read */
+    FILE *	  stream;   	/* Stream open to makefile to parse */
+{
+    register char *cp,		/* pointer into the line */
                   *line;	/* the line we're working on */
 
@@ -2404,5 +2414,5 @@
 		 * include or undef directives.
 		 */
-		for (cp = line + 1; isspace ((unsigned char) *cp); cp++) {
+		for (cp = line + 1; isspace (*cp); cp++) {
 		    continue;
 		}
@@ -2443,5 +2453,5 @@
 	    shellCommand:
 #endif
-		for (cp = line + 1; isspace ((unsigned char) *cp); cp++) {
+		for (cp = line + 1; isspace (*cp); cp++) {
 		    continue;
 		}
@@ -2454,5 +2464,5 @@
 			 */
 			Lst_ForEach (targets, ParseAddCmd, cp);
-			Lst_AtEnd(targCmds, (void *) line);
+			Lst_AtEnd(targCmds, (ClientData) line);
 			continue;
 		    } else {
@@ -2569,7 +2579,7 @@
  */
 void
-Parse_Init (void)
-{
-    mainNode = NULL;
+Parse_Init ()
+{
+    mainNode = NILGNODE;
     parseIncPath = Lst_Init (FALSE);
     sysIncPath = Lst_Init (FALSE);
@@ -2579,7 +2589,7 @@
 
 void
-Parse_End (void)
-{
-    Lst_Destroy(targCmds, (void (*)(void *)) free);
+Parse_End()
+{
+    Lst_Destroy(targCmds, (void (*) __P((ClientData))) free);
     if (targets)
 	Lst_Destroy(targets, NOFREE);
@@ -2605,5 +2615,5 @@
  */
 Lst
-Parse_MainName(void)
+Parse_MainName()
 {
     Lst           listmain;	/* result list */
@@ -2611,13 +2621,13 @@
     listmain = Lst_Init (FALSE);
 
-    if (mainNode == NULL) {
+    if (mainNode == NILGNODE) {
 	Punt ("no target to make.");
     	/*NOTREACHED*/
     } else if (mainNode->type & OP_DOUBLEDEP) {
-	(void) Lst_AtEnd (listmain, (void *)mainNode);
+	(void) Lst_AtEnd (listmain, (ClientData)mainNode);
 	Lst_Concat(listmain, mainNode->cohorts, LST_CONCNEW);
     }
     else
-	(void) Lst_AtEnd (listmain, (void *)mainNode);
+	(void) Lst_AtEnd (listmain, (ClientData)mainNode);
     return (listmain);
 }
Index: /trunk/src/kmk/pathnames.h
===================================================================
--- /trunk/src/kmk/pathnames.h	(revision 24)
+++ /trunk/src/kmk/pathnames.h	(revision 25)
@@ -31,6 +31,6 @@
  * SUCH DAMAGE.
  *
- *	@(#)pathnames.h	8.2 (Berkeley) 4/28/95
- * $FreeBSD: src/usr.bin/make/pathnames.h,v 1.12 2002/05/24 15:51:27 ru Exp $
+ *	from: @(#)pathnames.h	5.2 (Berkeley) 6/1/90
+ * $FreeBSD: src/usr.bin/make/pathnames.h,v 1.9 1999/08/28 01:03:36 peter Exp $
  */
 
Index: /trunk/src/kmk/sprite.h
===================================================================
--- /trunk/src/kmk/sprite.h	(revision 24)
+++ /trunk/src/kmk/sprite.h	(revision 25)
@@ -36,6 +36,6 @@
  * SUCH DAMAGE.
  *
- *	@(#)sprite.h	8.2 (Berkeley) 4/28/95
- * $FreeBSD: src/usr.bin/make/sprite.h,v 1.13 2002/09/17 21:29:06 jmallett Exp $
+ *	from: @(#)sprite.h	8.1 (Berkeley) 6/6/93
+ * $FreeBSD: src/usr.bin/make/sprite.h,v 1.9 1999/08/28 01:03:36 peter Exp $
  */
 
@@ -47,5 +47,6 @@
 
 #ifndef _SPRITE
-#define	_SPRITE
+#define _SPRITE
+
 
 /*
@@ -56,14 +57,56 @@
 typedef int Boolean;
 #ifndef TRUE
-#define	TRUE	1
+#define TRUE	1
 #endif /* TRUE */
 #ifndef FALSE
-#define	FALSE	0
+#define FALSE	0
 #endif /* FALSE */
+
+/*
+ * Functions that must return a status can return a ReturnStatus to
+ * indicate success or type of failure.
+ */
 
 typedef int  ReturnStatus;
 
-#define	SUCCESS		0
-#define	FAILURE		1
+/*
+ * The following statuses overlap with the first 2 generic statuses
+ * defined in status.h:
+ *
+ * SUCCESS			There was no error.
+ * FAILURE			There was a general error.
+ */
+
+#define	SUCCESS			0x00000000
+#define	FAILURE			0x00000001
+
+
+/*
+ * A nil pointer must be something that will cause an exception if
+ * referenced.  There are two nils: the kernels nil and the nil used
+ * by user processes.
+ */
+
+#define NIL 		~0
+#define USER_NIL 	0
+#ifndef NULL
+#define NULL	 	0
+#endif /* NULL */
+
+/*
+ * An address is just a pointer in C.  It is defined as a character pointer
+ * so that address arithmetic will work properly, a byte at a time.
+ */
+
+typedef char *Address;
+
+/*
+ * ClientData is an uninterpreted word.  It is defined as an int so that
+ * kdbx will not interpret client data as a string.  Unlike an "Address",
+ * client data will generally not be used in arithmetic.
+ * But we don't have kdbx anymore so we define it as void (christos)
+ */
+
+typedef void *ClientData;
 
 #endif /* _SPRITE */
Index: /trunk/src/kmk/str.c
===================================================================
--- /trunk/src/kmk/str.c	(revision 24)
+++ /trunk/src/kmk/str.c	(revision 25)
@@ -35,10 +35,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * @(#)str.c	5.8 (Berkeley) 6/1/90
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/str.c,v 1.25 2002/10/09 03:42:10 jmallett Exp $");
+ */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)str.c	5.8 (Berkeley) 6/1/90";
+#else
+static const char rcsid[] =
+  "$FreeBSD: src/usr.bin/make/str.c,v 1.12.2.1 2002/06/17 04:30:48 jmallett Exp $";
+#endif
+#endif /* not lint */
 
 #include "make.h"
@@ -53,5 +57,5 @@
  */
 void
-str_init(void)
+str_init()
 {
     char *p1;
@@ -67,10 +71,10 @@
  */
 void
-str_end(void)
+str_end()
 {
     if (argv) {
 	if (argv[0])
 	    free(argv[0]);
-	free(argv);
+	free((Address) argv);
     }
     if (buffer)
@@ -87,8 +91,10 @@
  */
 char *
-str_concat(char *s1, char *s2, int flags)
-{
-	int len1, len2;
-	char *result;
+str_concat(s1, s2, flags)
+	char *s1, *s2;
+	int flags;
+{
+	register int len1, len2;
+	register char *result;
 
 	/* get the length of both strings */
@@ -116,6 +122,6 @@
 	/* free original strings */
 	if (flags & STR_DOFREE) {
-		(void)efree(s1);
-		(void)efree(s2);
+		(void)free(s1);
+		(void)free(s2);
 	}
 	return(result);
@@ -133,8 +139,11 @@
  */
 char **
-brk_string(char *str, int *store_argc, Boolean expand)
-{
-	int argc, ch;
-	char inquote, *p, *start, *t;
+brk_string(str, store_argc, expand)
+	register char *str;
+	int *store_argc;
+	Boolean expand;
+{
+	register int argc, ch;
+	register char inquote, *p, *start, *t;
 	int len;
 
@@ -237,9 +246,5 @@
 				ch = '\t';
 				break;
-			default:
-				break;
-			}
-			break;
-		default:
+			}
 			break;
 		}
@@ -262,11 +267,11 @@
  *
  * Side effects: None.
- *
- * XXX should be strstr(3).
  */
 char *
-Str_FindSubstring(char *string, char *substring)
-{
-	char *a, *b;
+Str_FindSubstring(string, substring)
+	register char *string;		/* String to search. */
+	char *substring;		/* Substring to find in string */
+{
+	register char *a, *b;
 
 	/*
@@ -303,5 +308,7 @@
  */
 int
-Str_Match(char *string, char *pattern)
+Str_Match(string, pattern)
+	register char *string;		/* String */
+	register char *pattern;		/* Pattern */
 {
 	char c2;
@@ -406,5 +413,8 @@
  */
 char *
-Str_SYSVMatch(char *word, char *pattern, int *len)
+Str_SYSVMatch(word, pattern, len)
+    char	*word;		/* Word to examine */
+    char	*pattern;	/* Pattern to examine against */
+    int		*len;		/* Number of characters to substitute */
 {
     char *p = pattern;
@@ -469,5 +479,9 @@
  */
 void
-Str_SYSVSubst(Buffer buf, char *pat, char *src, int len)
+Str_SYSVSubst(buf, pat, src, len)
+    Buffer buf;
+    char *pat;
+    char *src;
+    int   len;
 {
     char *m;
Index: /trunk/src/kmk/suff.c
===================================================================
--- /trunk/src/kmk/suff.c	(revision 24)
+++ /trunk/src/kmk/suff.c	(revision 25)
@@ -35,10 +35,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * @(#)suff.c	8.4 (Berkeley) 3/21/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/suff.c,v 1.26 2002/10/09 03:42:10 jmallett Exp $");
+ */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)suff.c	8.4 (Berkeley) 3/21/94";
+#else
+static const char rcsid[] =
+  "$FreeBSD: src/usr.bin/make/suff.c,v 1.12.2.1 2001/03/09 01:13:24 tmm Exp $";
+#endif
+#endif /* not lint */
 
 /*-
@@ -89,5 +93,5 @@
  *	Suff_FindDeps	    	Find implicit sources for and the location of
  *	    	  	    	a target based on its suffix. Returns the
- *	    	  	    	bottom-most node added to the graph or NULL
+ *	    	  	    	bottom-most node added to the graph or NILGNODE
  *	    	  	    	if the target had no implicit sources.
  */
@@ -112,7 +116,7 @@
     int		 nameLen;	/* Length of the suffix */
     short	 flags;      	/* Type of suffix */
-#define	SUFF_INCLUDE	  0x01	    /* One which is #include'd */
-#define	SUFF_LIBRARY	  0x02	    /* One which contains a library */
-#define	SUFF_NULL 	  0x04	    /* The empty suffix */
+#define SUFF_INCLUDE	  0x01	    /* One which is #include'd */
+#define SUFF_LIBRARY	  0x02	    /* One which contains a library */
+#define SUFF_NULL 	  0x04	    /* The empty suffix */
     Lst    	 searchPath;	/* The path along which files of this suffix
 				 * may be found */
@@ -154,28 +158,28 @@
 
 
-static char *SuffStrIsPrefix(char *, char *);
-static char *SuffSuffIsSuffix(Suff *, char *);
-static int SuffSuffIsSuffixP(void *, void *);
-static int SuffSuffHasNameP(void *, void *);
-static int SuffSuffIsPrefix(void *, void *);
-static int SuffGNHasNameP(void *, void *);
-static void SuffFree(void *);
-static void SuffInsert(Lst, Suff *);
-static void SuffRemove(Lst, Suff *);
-static Boolean SuffParseTransform(char *, Suff **, Suff **);
-static int SuffRebuildGraph(void *, void *);
-static int SuffAddSrc(void *, void *);
-static int SuffRemoveSrc(Lst);
-static void SuffAddLevel(Lst, Src *);
-static Src *SuffFindThem(Lst, Lst);
-static Src *SuffFindCmds(Src *, Lst);
-static int SuffExpandChildren(void *, void *);
-static Boolean SuffApplyTransform(GNode *, GNode *, Suff *, Suff *);
-static void SuffFindDeps(GNode *, Lst);
-static void SuffFindArchiveDeps(GNode *, Lst);
-static void SuffFindNormalDeps(GNode *, Lst);
-static int SuffPrintName(void *, void *);
-static int SuffPrintSuff(void *, void *);
-static int SuffPrintTrans(void *, void *);
+static char *SuffStrIsPrefix __P((char *, char *));
+static char *SuffSuffIsSuffix __P((Suff *, char *));
+static int SuffSuffIsSuffixP __P((ClientData, ClientData));
+static int SuffSuffHasNameP __P((ClientData, ClientData));
+static int SuffSuffIsPrefix __P((ClientData, ClientData));
+static int SuffGNHasNameP __P((ClientData, ClientData));
+static void SuffFree __P((ClientData));
+static void SuffInsert __P((Lst, Suff *));
+static void SuffRemove __P((Lst, Suff *));
+static Boolean SuffParseTransform __P((char *, Suff **, Suff **));
+static int SuffRebuildGraph __P((ClientData, ClientData));
+static int SuffAddSrc __P((ClientData, ClientData));
+static int SuffRemoveSrc __P((Lst));
+static void SuffAddLevel __P((Lst, Src *));
+static Src *SuffFindThem __P((Lst, Lst));
+static Src *SuffFindCmds __P((Src *, Lst));
+static int SuffExpandChildren __P((ClientData, ClientData));
+static Boolean SuffApplyTransform __P((GNode *, GNode *, Suff *, Suff *));
+static void SuffFindDeps __P((GNode *, Lst));
+static void SuffFindArchiveDeps __P((GNode *, Lst));
+static void SuffFindNormalDeps __P((GNode *, Lst));
+static int SuffPrintName __P((ClientData, ClientData));
+static int SuffPrintSuff __P((ClientData, ClientData));
+static int SuffPrintTrans __P((ClientData, ClientData));
 
 	/*************** Lst Predicates ****************/
@@ -193,5 +197,7 @@
  */
 static char    *
-SuffStrIsPrefix (char *pref, char *str)
+SuffStrIsPrefix (pref, str)
+    register char  *pref;	/* possible prefix */
+    register char  *str;	/* string to check */
 {
     while (*str && *pref == *str) {
@@ -218,8 +224,10 @@
  */
 static char *
-SuffSuffIsSuffix (Suff *s, char *str)
-{
-    char	   *p1;	    	/* Pointer into suffix name */
-    char	   *p2;	    	/* Pointer into string being examined */
+SuffSuffIsSuffix (s, str)
+    register Suff  *s;		/* possible suffix */
+    char           *str;	/* string to examine */
+{
+    register char  *p1;	    	/* Pointer into suffix name */
+    register char  *p2;	    	/* Pointer into string being examined */
 
     p1 = s->name + s->nameLen;
@@ -249,5 +257,7 @@
  */
 static int
-SuffSuffIsSuffixP(void *s, void *str)
+SuffSuffIsSuffixP(s, str)
+    ClientData   s;
+    ClientData   str;
 {
     return(!SuffSuffIsSuffix((Suff *) s, (char *) str));
@@ -268,5 +278,7 @@
  */
 static int
-SuffSuffHasNameP (void *s, void *sname)
+SuffSuffHasNameP (s, sname)
+    ClientData    s;	    	    /* Suffix to check */
+    ClientData    sname; 	    /* Desired name */
 {
     return (strcmp ((char *) sname, ((Suff *) s)->name));
@@ -289,5 +301,7 @@
  */
 static int
-SuffSuffIsPrefix (void *s, void *str)
+SuffSuffIsPrefix (s, str)
+    ClientData   s;		/* suffix to compare */
+    ClientData   str;	/* string to examine */
 {
     return (SuffStrIsPrefix (((Suff *) s)->name, (char *) str) == NULL ? 1 : 0);
@@ -307,5 +321,7 @@
  */
 static int
-SuffGNHasNameP (void *gn, void *name)
+SuffGNHasNameP (gn, name)
+    ClientData      gn;		/* current node we're looking at */
+    ClientData      name;	/* name we're looking for */
 {
     return (strcmp ((char *) name, ((GNode *) gn)->name));
@@ -327,5 +343,6 @@
  */
 static void
-SuffFree (void *sp)
+SuffFree (sp)
+    ClientData sp;
 {
     Suff           *s = (Suff *) sp;
@@ -342,6 +359,6 @@
     Lst_Destroy (s->searchPath, Dir_Destroy);
 
-    free (s->name);
-    free (s);
+    free ((Address)s->name);
+    free ((Address)s);
 }
 
@@ -359,8 +376,10 @@
  */
 static void
-SuffRemove(Lst l, Suff *s)
-{
-    LstNode ln = Lst_Member(l, (void *)s);
-    if (ln != NULL) {
+SuffRemove(l, s)
+    Lst l;
+    Suff *s;
+{
+    LstNode ln = Lst_Member(l, (ClientData)s);
+    if (ln != NILLNODE) {
 	Lst_Remove(l, ln);
 	s->refCount--;
@@ -383,5 +402,7 @@
  */
 static void
-SuffInsert (Lst l, Suff *s)
+SuffInsert (l, s)
+    Lst           l;		/* the list where in s should be inserted */
+    Suff          *s;		/* the suffix to insert */
 {
     LstNode 	  ln;		/* current element in l we're examining */
@@ -391,5 +412,5 @@
 	return;
     }
-    while ((ln = Lst_Next (l)) != NULL) {
+    while ((ln = Lst_Next (l)) != NILLNODE) {
 	s2 = (Suff *) Lst_Datum (ln);
 	if (s2->sNum >= s->sNum) {
@@ -397,22 +418,25 @@
 	}
     }
-    if (s2 == NULL) {
-	    DEBUGF(SUFF, ("inserting an empty list?..."));
-    }
 
     Lst_Close (l);
-    DEBUGF(SUFF, ("inserting %s(%d)...", s->name, s->sNum));
-    if (ln == NULL) {
-	DEBUGF(SUFF, ("at end of list\n"));
-	(void)Lst_AtEnd (l, (void *)s);
+    if (DEBUG(SUFF)) {
+	printf("inserting %s(%d)...", s->name, s->sNum);
+    }
+    if (ln == NILLNODE) {
+	if (DEBUG(SUFF)) {
+	    printf("at end of list\n");
+	}
+	(void)Lst_AtEnd (l, (ClientData)s);
 	s->refCount++;
-	(void)Lst_AtEnd(s->ref, (void *) l);
+	(void)Lst_AtEnd(s->ref, (ClientData) l);
     } else if (s2->sNum != s->sNum) {
-	DEBUGF(SUFF, ("before %s(%d)\n", s2->name, s2->sNum));
-	(void)Lst_Insert (l, ln, (void *)s);
+	if (DEBUG(SUFF)) {
+	    printf("before %s(%d)\n", s2->name, s2->sNum);
+	}
+	(void)Lst_Insert (l, ln, (ClientData)s);
 	s->refCount++;
-	(void)Lst_AtEnd(s->ref, (void *) l);
-    } else {
-	DEBUGF(SUFF, ("already there\n"));
+	(void)Lst_AtEnd(s->ref, (ClientData) l);
+    } else if (DEBUG(SUFF)) {
+	printf("already there\n");
     }
 }
@@ -436,5 +460,5 @@
  */
 void
-Suff_ClearSuffixes (void)
+Suff_ClearSuffixes ()
 {
     Lst_Concat (suffClean, sufflist, LST_CONCLINK);
@@ -448,5 +472,5 @@
      * suffNull should not have parents.
      */
-    Lst_Destroy(suffNull->children, NOFREE); 
+    Lst_Destroy(suffNull->children, NOFREE);
     suffNull->children = Lst_Init(FALSE);
 }
@@ -466,10 +490,13 @@
  */
 static Boolean
-SuffParseTransform(char *str, Suff **srcPtr, Suff **targPtr)
-{
-    LstNode		srcLn;	    /* element in suffix list of trans source*/
-    Suff	    	*src;	    /* Source of transformation */
-    LstNode		targLn;	    /* element in suffix list of trans target*/
-    char	    	*str2;	    /* Extra pointer (maybe target suffix) */
+SuffParseTransform(str, srcPtr, targPtr)
+    char    	  	*str;	    	/* String being parsed */
+    Suff    	  	**srcPtr;   	/* Place to store source of trans. */
+    Suff    	  	**targPtr;  	/* Place to store target of trans. */
+{
+    register LstNode	srcLn;	    /* element in suffix list of trans source*/
+    register Suff    	*src;	    /* Source of transformation */
+    register LstNode    targLn;	    /* element in suffix list of trans target*/
+    register char    	*str2;	    /* Extra pointer (maybe target suffix) */
     LstNode 	    	singleLn;   /* element in suffix list of any suffix
 				     * that exactly matches str */
@@ -477,6 +504,6 @@
 				     * null suffix */
 
-    srcLn = NULL;
-    singleLn = NULL;
+    srcLn = NILLNODE;
+    singleLn = NILLNODE;
 
     /*
@@ -487,15 +514,15 @@
      */
     for (;;) {
-	if (srcLn == NULL) {
-	    srcLn = Lst_Find(sufflist, (void *)str, SuffSuffIsPrefix);
+	if (srcLn == NILLNODE) {
+	    srcLn = Lst_Find(sufflist, (ClientData)str, SuffSuffIsPrefix);
 	} else {
-	    srcLn = Lst_FindFrom (sufflist, Lst_Succ(srcLn), (void *)str,
+	    srcLn = Lst_FindFrom (sufflist, Lst_Succ(srcLn), (ClientData)str,
 				  SuffSuffIsPrefix);
 	}
-	if (srcLn == NULL) {
+	if (srcLn == NILLNODE) {
 	    /*
 	     * Ran out of source suffixes -- no such rule
 	     */
-	    if (singleLn != NULL) {
+	    if (singleLn != NILLNODE) {
 		/*
 		 * Not so fast Mr. Smith! There was a suffix that encompassed
@@ -519,6 +546,6 @@
 	    singleLn = srcLn;
 	} else {
-	    targLn = Lst_Find(sufflist, (void *)str2, SuffSuffHasNameP);
-	    if (targLn != NULL) {
+	    targLn = Lst_Find(sufflist, (ClientData)str2, SuffSuffHasNameP);
+	    if (targLn != NILLNODE) {
 		*srcPtr = src;
 		*targPtr = (Suff *)Lst_Datum(targLn);
@@ -544,5 +571,6 @@
  */
 Boolean
-Suff_IsTransform (char *str)
+Suff_IsTransform (str)
+    char          *str;	    	/* string to check */
 {
     Suff    	  *src, *targ;
@@ -566,5 +594,6 @@
  */
 GNode *
-Suff_AddTransform (char *line)
+Suff_AddTransform (line)
+    char          *line;	/* name of transformation to add */
 {
     GNode         *gn;		/* GNode of transformation rule */
@@ -573,6 +602,6 @@
     LstNode 	  ln;	    	/* Node for existing transformation */
 
-    ln = Lst_Find (transforms, (void *)line, SuffGNHasNameP);
-    if (ln == NULL) {
+    ln = Lst_Find (transforms, (ClientData)line, SuffGNHasNameP);
+    if (ln == NILLNODE) {
 	/*
 	 * Make a new graph node for the transformation. It will be filled in
@@ -580,5 +609,5 @@
 	 */
 	gn = Targ_NewGN (line);
-	(void)Lst_AtEnd (transforms, (void *)gn);
+	(void)Lst_AtEnd (transforms, (ClientData)gn);
     } else {
 	/*
@@ -602,6 +631,8 @@
      * link the two together in the proper relationship and order
      */
-    DEBUGF(SUFF, ("defining transformation from `%s' to `%s'\n",
-	   s->name, t->name));
+    if (DEBUG(SUFF)) {
+	printf("defining transformation from `%s' to `%s'\n",
+		s->name, t->name);
+    }
     SuffInsert (t->children, s);
     SuffInsert (s->parents, t);
@@ -628,5 +659,7 @@
  */
 int
-Suff_EndTransform(void *gnp, void *dummy __unused)
+Suff_EndTransform(gnp, dummy)
+    ClientData   gnp;    	/* Node for transformation */
+    ClientData   dummy;    	/* Node for transformation */
 {
     GNode *gn = (GNode *) gnp;
@@ -639,10 +672,12 @@
 	(void)SuffParseTransform(gn->name, &s, &t);
 
-	DEBUGF(SUFF, ("deleting transformation from `%s' to `%s'\n",
-	       s->name, t->name));
+	if (DEBUG(SUFF)) {
+	    printf("deleting transformation from `%s' to `%s'\n",
+		    s->name, t->name);
+	}
 
 	/*
 	 * Remove the source from the target's children list. We check for a
-	 * NULL return to handle a beanhead saying something like
+	 * nil return to handle a beanhead saying something like
 	 *  .c.o .c.o:
 	 *
@@ -656,9 +691,9 @@
 	 */
 	SuffRemove(s->parents, t);
-    } else if (gn->type & OP_TRANSFORM) {
-	DEBUGF(SUFF, ("transformation %s complete\n", gn->name));
-    }
-
-    return (0);
+    } else if ((gn->type & OP_TRANSFORM) && DEBUG(SUFF)) {
+	printf("transformation %s complete\n", gn->name);
+    }
+
+    return(dummy ? 0 : 0);
 }
 
@@ -683,5 +718,7 @@
  */
 static int
-SuffRebuildGraph(void *transformp, void *sp)
+SuffRebuildGraph(transformp, sp)
+    ClientData  transformp; /* Transformation to test */
+    ClientData  sp;	    /* Suffix to rebuild */
 {
     GNode   	*transform = (GNode *) transformp;
@@ -696,10 +733,10 @@
     cp = SuffStrIsPrefix(s->name, transform->name);
     if (cp != (char *)NULL) {
-        if (cp[0] == '\0')  /* null rule */
+	if (cp[0] == '\0')  /* null rule */
 	    s2 = suffNull;
 	else {
-	    ln = Lst_Find(sufflist, (void *)cp, SuffSuffHasNameP);
-	    if (ln != NULL) 
-	        s2 = (Suff *)Lst_Datum(ln);
+	    ln = Lst_Find(sufflist, (ClientData)cp, SuffSuffHasNameP);
+	    if (ln != NILLNODE)
+		s2 = (Suff *)Lst_Datum(ln);
 	}
 	if (s2 != NULL) {
@@ -723,10 +760,10 @@
 	 */
 	cp[1] = '\0';
-	ln = Lst_Find(sufflist, (void *)transform->name, SuffSuffHasNameP);
+	ln = Lst_Find(sufflist, (ClientData)transform->name, SuffSuffHasNameP);
 	/*
 	 * Replace the start of the target suffix
 	 */
 	cp[1] = s->name[0];
-	if (ln != NULL) {
+	if (ln != NILLNODE) {
 	    /*
 	     * Found it -- establish the proper relationship
@@ -755,11 +792,12 @@
  */
 void
-Suff_AddSuffix (char *str)
+Suff_AddSuffix (str)
+    char          *str;	    /* the name of the suffix to add */
 {
     Suff          *s;	    /* new suffix descriptor */
     LstNode 	  ln;
 
-    ln = Lst_Find (sufflist, (void *)str, SuffSuffHasNameP);
-    if (ln == NULL) {
+    ln = Lst_Find (sufflist, (ClientData)str, SuffSuffHasNameP);
+    if (ln == NILLNODE) {
 	s = (Suff *) emalloc (sizeof (Suff));
 
@@ -774,10 +812,10 @@
 	s->refCount =	0;
 
-	(void)Lst_AtEnd (sufflist, (void *)s);
+	(void)Lst_AtEnd (sufflist, (ClientData)s);
 	/*
 	 * Look for any existing transformations from or to this suffix.
 	 * XXX: Only do this after a Suff_ClearSuffixes?
 	 */
-	Lst_ForEach (transforms, SuffRebuildGraph, (void *)s);
+	Lst_ForEach (transforms, SuffRebuildGraph, (ClientData)s);
     }
 }
@@ -789,5 +827,5 @@
  *
  * Results:
- *	The searchPath for the desired suffix or NULL if the suffix isn't
+ *	The searchPath for the desired suffix or NILLST if the suffix isn't
  *	defined.
  *
@@ -797,12 +835,13 @@
  */
 Lst
-Suff_GetPath (char *sname)
+Suff_GetPath (sname)
+    char    	  *sname;
 {
     LstNode   	  ln;
     Suff    	  *s;
 
-    ln = Lst_Find (sufflist, (void *)sname, SuffSuffHasNameP);
-    if (ln == NULL) {
-	return (NULL);
+    ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP);
+    if (ln == NILLNODE) {
+	return (NILLST);
     } else {
 	s = (Suff *) Lst_Datum (ln);
@@ -824,5 +863,5 @@
  *	directories in dirSearchPath. If paths were specified for the
  *	".h" suffix, the directories are stuffed into a global variable
- *	called ".INCLUDES" with each directory preceded by a -I. The same
+ *	called ".INCLUDES" with each directory preceeded by a -I. The same
  *	is done for the ".a" suffix, except the variable is called
  *	".LIBS" and the flag is -L.
@@ -830,8 +869,8 @@
  */
 void
-Suff_DoPaths(void)
-{
-    Suff	   	*s;
-    LstNode	  	ln;
+Suff_DoPaths()
+{
+    register Suff   	*s;
+    register LstNode  	ln;
     char		*ptr;
     Lst	    	    	inIncludes; /* Cumulative .INCLUDES path */
@@ -845,5 +884,5 @@
     inLibs = Lst_Init(FALSE);
 
-    while ((ln = Lst_Next (sufflist)) != NULL) {
+    while ((ln = Lst_Next (sufflist)) != NILLNODE) {
 	s = (Suff *) Lst_Datum (ln);
 	if (!Lst_IsEmpty (s->searchPath)) {
@@ -892,11 +931,12 @@
  */
 void
-Suff_AddInclude (char *sname)
+Suff_AddInclude (sname)
+    char	  *sname;     /* Name of suffix to mark */
 {
     LstNode	  ln;
     Suff	  *s;
 
-    ln = Lst_Find (sufflist, (void *)sname, SuffSuffHasNameP);
-    if (ln != NULL) {
+    ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP);
+    if (ln != NILLNODE) {
 	s = (Suff *) Lst_Datum (ln);
 	s->flags |= SUFF_INCLUDE;
@@ -921,11 +961,12 @@
  */
 void
-Suff_AddLib (char *sname)
+Suff_AddLib (sname)
+    char	  *sname;     /* Name of suffix to mark */
 {
     LstNode	  ln;
     Suff	  *s;
 
-    ln = Lst_Find (sufflist, (void *)sname, SuffSuffHasNameP);
-    if (ln != NULL) {
+    ln = Lst_Find (sufflist, (ClientData)sname, SuffSuffHasNameP);
+    if (ln != NILLNODE) {
 	s = (Suff *) Lst_Datum (ln);
 	s->flags |= SUFF_LIBRARY;
@@ -950,5 +991,7 @@
  */
 static int
-SuffAddSrc (void *sp, void *lsp)
+SuffAddSrc (sp, lsp)
+    ClientData	sp;	    /* suffix for which to create a Src structure */
+    ClientData  lsp;	    /* list and parent for the new Src */
 {
     Suff	*s = (Suff *) sp;
@@ -969,15 +1012,15 @@
 	s2->pref =  	targ->pref;
 	s2->parent = 	targ;
-	s2->node =  	NULL;
+	s2->node =  	NILGNODE;
 	s2->suff =  	s;
 	s->refCount++;
 	s2->children =	0;
 	targ->children += 1;
-	(void)Lst_AtEnd (ls->l, (void *)s2);
+	(void)Lst_AtEnd (ls->l, (ClientData)s2);
 #ifdef DEBUG_SRC
 	s2->cp = Lst_Init(FALSE);
-	Lst_AtEnd(targ->cp, (void *) s2);
+	Lst_AtEnd(targ->cp, (ClientData) s2);
 	printf("1 add %x %x to %x:", targ, s2, ls->l);
-	Lst_ForEach(ls->l, PrintAddr, (void *) 0);
+	Lst_ForEach(ls->l, PrintAddr, (ClientData) 0);
 	printf("\n");
 #endif
@@ -987,15 +1030,15 @@
     s2->pref =	    targ->pref;
     s2->parent =    targ;
-    s2->node = 	    NULL;
+    s2->node = 	    NILGNODE;
     s2->suff = 	    s;
     s->refCount++;
     s2->children =  0;
     targ->children += 1;
-    (void)Lst_AtEnd (ls->l, (void *)s2);
+    (void)Lst_AtEnd (ls->l, (ClientData)s2);
 #ifdef DEBUG_SRC
     s2->cp = Lst_Init(FALSE);
-    Lst_AtEnd(targ->cp, (void *) s2);
+    Lst_AtEnd(targ->cp, (ClientData) s2);
     printf("2 add %x %x to %x:", targ, s2, ls->l);
-    Lst_ForEach(ls->l, PrintAddr, (void *) 0);
+    Lst_ForEach(ls->l, PrintAddr, (ClientData) 0);
     printf("\n");
 #endif
@@ -1017,5 +1060,7 @@
  */
 static void
-SuffAddLevel (Lst l, Src *targ)
+SuffAddLevel (l, targ)
+    Lst            l;		/* list to which to add the new level */
+    Src            *targ;	/* Src structure to use as the parent */
 {
     LstSrc         ls;
@@ -1024,5 +1069,5 @@
     ls.l = l;
 
-    Lst_ForEach (targ->suff->children, SuffAddSrc, (void *)&ls);
+    Lst_ForEach (targ->suff->children, SuffAddSrc, (ClientData)&ls);
 }
 
@@ -1040,5 +1085,6 @@
  */
 static int
-SuffRemoveSrc (Lst l)
+SuffRemoveSrc (l)
+    Lst l;
 {
     LstNode ln;
@@ -1051,19 +1097,19 @@
 #ifdef DEBUG_SRC
     printf("cleaning %lx: ", (unsigned long) l);
-    Lst_ForEach(l, PrintAddr, (void *) 0);
+    Lst_ForEach(l, PrintAddr, (ClientData) 0);
     printf("\n");
 #endif
 
 
-    while ((ln = Lst_Next (l)) != NULL) {
+    while ((ln = Lst_Next (l)) != NILLNODE) {
 	s = (Src *) Lst_Datum (ln);
 	if (s->children == 0) {
-	    free (s->file);
+	    free ((Address)s->file);
 	    if (!s->parent)
-		free(s->pref);
+		free((Address)s->pref);
 	    else {
 #ifdef DEBUG_SRC
-		LstNode ln = Lst_Member(s->parent->cp, (void *)s);
-		if (ln != NULL)
+		LstNode ln = Lst_Member(s->parent->cp, (ClientData)s);
+		if (ln != NILLNODE)
 		    Lst_Remove(s->parent->cp, ln);
 #endif
@@ -1075,5 +1121,5 @@
 #endif
 	    Lst_Remove(l, ln);
-	    free (s);
+	    free ((Address)s);
 	    t |= 1;
 	    Lst_Close(l);
@@ -1083,5 +1129,5 @@
 	else {
 	    printf("keep: [l=%x] p=%x %d: ", l, s, s->children);
-	    Lst_ForEach(s->cp, PrintAddr, (void *) 0);
+	    Lst_ForEach(s->cp, PrintAddr, (ClientData) 0);
 	    printf("\n");
 	}
@@ -1107,5 +1153,7 @@
  */
 static Src *
-SuffFindThem (Lst srcs, Lst slst)
+SuffFindThem (srcs, slst)
+    Lst            srcs;	/* list of Src structures to search through */
+    Lst		   slst;
 {
     Src            *s;		/* current Src */
@@ -1118,5 +1166,7 @@
 	s = (Src *) Lst_DeQueue (srcs);
 
-	DEBUGF(SUFF, ("\ttrying %s...", s->file));
+	if (DEBUG(SUFF)) {
+	    printf ("\ttrying %s...", s->file);
+	}
 
 	/*
@@ -1124,5 +1174,5 @@
 	 * graph for it or the file actually exists.
 	 */
-	if (Targ_FindNode(s->file, TARG_NOCREATE) != NULL) {
+	if (Targ_FindNode(s->file, TARG_NOCREATE) != NILGNODE) {
 #ifdef DEBUG_SRC
 	    printf("remove %x from %x\n", s, srcs);
@@ -1141,12 +1191,14 @@
 	}
 
-	DEBUGF(SUFF, ("not there\n"));
+	if (DEBUG(SUFF)) {
+	    printf ("not there\n");
+	}
 
 	SuffAddLevel (srcs, s);
-	Lst_AtEnd(slst, (void *) s);
-    }
-
-    if (rs) {
-	DEBUGF(SUFF, ("got it\n"));
+	Lst_AtEnd(slst, (ClientData) s);
+    }
+
+    if (DEBUG(SUFF) && rs) {
+	printf ("got it\n");
     }
     return (rs);
@@ -1161,5 +1213,5 @@
  *
  * Results:
- *	The Src structure of the "winning" child, or NULL if no such beast.
+ *	The Src structure of the "winning" child, or NIL if no such beast.
  *
  * Side Effects:
@@ -1169,8 +1221,10 @@
  */
 static Src *
-SuffFindCmds (Src *targ, Lst slst)
+SuffFindCmds (targ, slst)
+    Src	    	*targ;	/* Src structure to play with */
+    Lst		slst;
 {
     LstNode 	  	ln; 	/* General-purpose list node */
-    GNode		*t, 	/* Target GNode */
+    register GNode	*t, 	/* Target GNode */
 	    	  	*s; 	/* Source GNode */
     int	    	  	prefLen;/* The length of the defined prefix */
@@ -1183,5 +1237,5 @@
     prefLen = strlen (targ->pref);
 
-    while ((ln = Lst_Next (t->children)) != NULL) {
+    while ((ln = Lst_Next (t->children)) != NILLNODE) {
 	s = (GNode *)Lst_Datum (ln);
 
@@ -1197,7 +1251,7 @@
 	     * suffix.
 	     */
-	    ln = Lst_Find (sufflist, (void *)&cp[prefLen],
+	    ln = Lst_Find (sufflist, (ClientData)&cp[prefLen],
 			   SuffSuffHasNameP);
-	    if (ln != NULL) {
+	    if (ln != NILLNODE) {
 		/*
 		 * It even has a known suffix, see if there's a transformation
@@ -1209,5 +1263,5 @@
 
 		if (Lst_Member (suff->parents,
-				(void *)targ->suff) != NULL)
+				(ClientData)targ->suff) != NILLNODE)
 		{
 		    /*
@@ -1229,8 +1283,10 @@
 		    ret->cp = Lst_Init(FALSE);
 		    printf("3 add %x %x\n", targ, ret);
-		    Lst_AtEnd(targ->cp, (void *) ret);
+		    Lst_AtEnd(targ->cp, (ClientData) ret);
 #endif
-		    Lst_AtEnd(slst, (void *) ret);
-		    DEBUGF(SUFF, ("\tusing existing source %s\n", s->name));
+		    Lst_AtEnd(slst, (ClientData) ret);
+		    if (DEBUG(SUFF)) {
+			printf ("\tusing existing source %s\n", s->name);
+		    }
 		    return (ret);
 		}
@@ -1259,5 +1315,7 @@
  */
 static int
-SuffExpandChildren(void *cgnp, void *pgnp)
+SuffExpandChildren(cgnp, pgnp)
+    ClientData  cgnp;	    /* Child to examine */
+    ClientData  pgnp;	    /* Parent node being processed */
 {
     GNode   	*cgn = (GNode *) cgnp;
@@ -1272,5 +1330,5 @@
      * after the child
      */
-    prevLN = Lst_Member(pgn->children, (void *)cgn);
+    prevLN = Lst_Member(pgn->children, (ClientData)cgn);
 
     /*
@@ -1281,5 +1339,7 @@
      */
     if (strchr(cgn->name, '$') != (char *)NULL) {
-	DEBUGF(SUFF, ("Expanding \"%s\"...", cgn->name));
+	if (DEBUG(SUFF)) {
+	    printf("Expanding \"%s\"...", cgn->name);
+	}
 	cp = Var_Subst(NULL, cgn->name, pgn, TRUE);
 
@@ -1317,5 +1377,5 @@
 			*cp++ = '\0';
 			gn = Targ_FindNode(start, TARG_CREATE);
-			(void)Lst_AtEnd(members, (void *)gn);
+			(void)Lst_AtEnd(members, (ClientData)gn);
 			while (*cp == ' ' || *cp == '\t') {
 			    cp++;
@@ -1356,5 +1416,5 @@
 		     */
 		    gn = Targ_FindNode(start, TARG_CREATE);
-		    (void)Lst_AtEnd(members, (void *)gn);
+		    (void)Lst_AtEnd(members, (ClientData)gn);
 		}
 		/*
@@ -1370,9 +1430,11 @@
 		gn = (GNode *)Lst_DeQueue(members);
 
-		DEBUGF(SUFF, ("%s...", gn->name));
-		if (Lst_Member(pgn->children, (void *)gn) == NULL) {
-		    (void)Lst_Append(pgn->children, prevLN, (void *)gn);
+		if (DEBUG(SUFF)) {
+		    printf("%s...", gn->name);
+		}
+		if (Lst_Member(pgn->children, (ClientData)gn) == NILLNODE) {
+		    (void)Lst_Append(pgn->children, prevLN, (ClientData)gn);
 		    prevLN = Lst_Succ(prevLN);
-		    (void)Lst_AtEnd(gn->parents, (void *)pgn);
+		    (void)Lst_AtEnd(gn->parents, (ClientData)pgn);
 		    pgn->unmade++;
 		}
@@ -1388,8 +1450,10 @@
 	 * keep it from being processed.
 	 */
-	ln = Lst_Member(pgn->children, (void *)cgn);
+	ln = Lst_Member(pgn->children, (ClientData)cgn);
 	pgn->unmade--;
 	Lst_Remove(pgn->children, ln);
-	DEBUGF(SUFF, ("\n"));
+	if (DEBUG(SUFF)) {
+	    printf("\n");
+	}
     } else if (Dir_HasWildcards(cgn->name)) {
 	Lst 	exp;	    /* List of expansions */
@@ -1405,12 +1469,16 @@
 	 */
 	cp = cgn->name + strlen(cgn->name);
-	ln = Lst_Find(sufflist, (void *)cp, SuffSuffIsSuffixP);
-
-	DEBUGF(SUFF, ("Wildcard expanding \"%s\"...", cgn->name));
-
-	if (ln != NULL) {
+	ln = Lst_Find(sufflist, (ClientData)cp, SuffSuffIsSuffixP);
+
+	if (DEBUG(SUFF)) {
+	    printf("Wildcard expanding \"%s\"...", cgn->name);
+	}
+
+	if (ln != NILLNODE) {
 	    Suff    *s = (Suff *)Lst_Datum(ln);
 
-	    DEBUGF(SUFF, ("suffix is \"%s\"...", s->name));
+	    if (DEBUG(SUFF)) {
+		printf("suffix is \"%s\"...", s->name);
+	    }
 	    path = s->searchPath;
 	} else {
@@ -1433,5 +1501,7 @@
 	    cp = (char *)Lst_DeQueue(exp);
 
-	    DEBUGF(SUFF, ("%s...", cp));
+	    if (DEBUG(SUFF)) {
+		printf("%s...", cp);
+	    }
 	    gn = Targ_FindNode(cp, TARG_CREATE);
 
@@ -1440,8 +1510,8 @@
 	     * up the parent's count of unmade children.
 	     */
-	    if (Lst_Member(pgn->children, (void *)gn) == NULL) {
-		(void)Lst_Append(pgn->children, prevLN, (void *)gn);
+	    if (Lst_Member(pgn->children, (ClientData)gn) == NILLNODE) {
+		(void)Lst_Append(pgn->children, prevLN, (ClientData)gn);
 		prevLN = Lst_Succ(prevLN);
-		(void)Lst_AtEnd(gn->parents, (void *)pgn);
+		(void)Lst_AtEnd(gn->parents, (ClientData)pgn);
 		pgn->unmade++;
 	    }
@@ -1457,8 +1527,10 @@
 	 * keep it from being processed.
 	 */
-	ln = Lst_Member(pgn->children, (void *)cgn);
+	ln = Lst_Member(pgn->children, (ClientData)cgn);
 	pgn->unmade--;
 	Lst_Remove(pgn->children, ln);
-	DEBUGF(SUFF, ("\n"));
+	if (DEBUG(SUFF)) {
+	    printf("\n");
+	}
     }
 
@@ -1485,5 +1557,9 @@
  */
 static Boolean
-SuffApplyTransform(GNode *tGn, GNode *sGn, Suff *t, Suff *s)
+SuffApplyTransform(tGn, sGn, t, s)
+    GNode   	*tGn;	    /* Target node */
+    GNode   	*sGn;	    /* Source node */
+    Suff    	*t; 	    /* Target suffix */
+    Suff    	*s; 	    /* Source suffix */
 {
     LstNode 	ln; 	    /* General node */
@@ -1491,11 +1567,11 @@
     GNode   	*gn;	    /* Node for same */
 
-    if (Lst_Member(tGn->children, (void *)sGn) == NULL) {
+    if (Lst_Member(tGn->children, (ClientData)sGn) == NILLNODE) {
 	/*
 	 * Not already linked, so form the proper links between the
 	 * target and source.
 	 */
-	(void)Lst_AtEnd(tGn->children, (void *)sGn);
-	(void)Lst_AtEnd(sGn->parents, (void *)tGn);
+	(void)Lst_AtEnd(tGn->children, (ClientData)sGn);
+	(void)Lst_AtEnd(sGn->parents, (ClientData)tGn);
 	tGn->unmade += 1;
     }
@@ -1508,14 +1584,14 @@
 	 * will be sufficient to get the .IMPSRC variable set for tGn
 	 */
-	for (ln=Lst_First(sGn->cohorts); ln != NULL; ln=Lst_Succ(ln)) {
+	for (ln=Lst_First(sGn->cohorts); ln != NILLNODE; ln=Lst_Succ(ln)) {
 	    gn = (GNode *)Lst_Datum(ln);
 
-	    if (Lst_Member(tGn->children, (void *)gn) == NULL) {
+	    if (Lst_Member(tGn->children, (ClientData)gn) == NILLNODE) {
 		/*
 		 * Not already linked, so form the proper links between the
 		 * target and source.
 		 */
-		(void)Lst_AtEnd(tGn->children, (void *)gn);
-		(void)Lst_AtEnd(gn->parents, (void *)tGn);
+		(void)Lst_AtEnd(tGn->children, (ClientData)gn);
+		(void)Lst_AtEnd(gn->parents, (ClientData)tGn);
 		tGn->unmade += 1;
 	    }
@@ -1526,8 +1602,8 @@
      */
     tname = str_concat(s->name, t->name, 0);
-    ln = Lst_Find(transforms, (void *)tname, SuffGNHasNameP);
+    ln = Lst_Find(transforms, (ClientData)tname, SuffGNHasNameP);
     free(tname);
 
-    if (ln == NULL) {
+    if (ln == NILLNODE) {
 	/*
 	 * Not really such a transformation rule (can happen when we're
@@ -1540,5 +1616,7 @@
     gn = (GNode *)Lst_Datum(ln);
 
-    DEBUGF(SUFF, ("\tapplying %s -> %s to \"%s\"\n", s->name, t->name, tGn->name));
+    if (DEBUG(SUFF)) {
+	printf("\tapplying %s -> %s to \"%s\"\n", s->name, t->name, tGn->name);
+    }
 
     /*
@@ -1556,7 +1634,7 @@
      */
     ln = Lst_Succ(ln);
-    if (ln != NULL) {
+    if (ln != NILLNODE) {
 	Lst_ForEachFrom(tGn->children, ln,
-			SuffExpandChildren, (void *)tGn);
+			SuffExpandChildren, (ClientData)tGn);
     }
 
@@ -1565,5 +1643,5 @@
      * the .IMPSRC variable can be set correctly for the parent.
      */
-    (void)Lst_AtEnd(sGn->iParents, (void *)tGn);
+    (void)Lst_AtEnd(sGn->iParents, (ClientData)tGn);
 
     return(TRUE);
@@ -1585,5 +1663,7 @@
  */
 static void
-SuffFindArchiveDeps(GNode *gn, Lst slst)
+SuffFindArchiveDeps(gn, slst)
+    GNode   	*gn;	    /* Node for which to locate dependencies */
+    Lst		slst;
 {
     char    	*eoarch;    /* End of archive portion */
@@ -1623,7 +1703,7 @@
      * Create the link between the two nodes right off
      */
-    if (Lst_Member(gn->children, (void *)mem) == NULL) {
-	(void)Lst_AtEnd(gn->children, (void *)mem);
-	(void)Lst_AtEnd(mem->parents, (void *)gn);
+    if (Lst_Member(gn->children, (ClientData)mem) == NILLNODE) {
+	(void)Lst_AtEnd(gn->children, (ClientData)mem);
+	(void)Lst_AtEnd(mem->parents, (ClientData)gn);
 	gn->unmade += 1;
     }
@@ -1644,5 +1724,7 @@
 	 * Didn't know what it was -- use .NULL suffix if not in make mode
 	 */
-	DEBUGF(SUFF, ("using null suffix\n"));
+	if (DEBUG(SUFF)) {
+	    printf("using null suffix\n");
+	}
 	ms = suffNull;
     }
@@ -1669,11 +1751,13 @@
 	ln = Lst_Find(ms->parents, eoarch, SuffSuffIsSuffixP);
 
-	if (ln != NULL) {
+	if (ln != NILLNODE) {
 	    /*
 	     * Got one -- apply it
 	     */
-	    if (!SuffApplyTransform(gn, mem, (Suff *)Lst_Datum(ln), ms)) {
-		DEBUGF(SUFF, ("\tNo transformation from %s -> %s\n",
-		       ms->name, ((Suff *)Lst_Datum(ln))->name));
+	    if (!SuffApplyTransform(gn, mem, (Suff *)Lst_Datum(ln), ms) &&
+		DEBUG(SUFF))
+	    {
+		printf("\tNo transformation from %s -> %s\n",
+		       ms->name, ((Suff *)Lst_Datum(ln))->name);
 	    }
 	}
@@ -1716,5 +1800,7 @@
  */
 static void
-SuffFindNormalDeps(GNode *gn, Lst slst)
+SuffFindNormalDeps(gn, slst)
+    GNode   	*gn;	    /* Node for which to find sources */
+    Lst		slst;
 {
     char    	*eoname;    /* End of name */
@@ -1761,5 +1847,5 @@
      */
 
-    while (ln != NULL) {
+    while (ln != NILLNODE) {
 	/*
 	 * Look for next possible suffix...
@@ -1767,20 +1853,20 @@
 	ln = Lst_FindFrom(sufflist, ln, eoname, SuffSuffIsSuffixP);
 
-	if (ln != NULL) {
+	if (ln != NILLNODE) {
 	    int	    prefLen;	    /* Length of the prefix */
-	    Src	    *target;
+	    Src	    *targ;
 
 	    /*
 	     * Allocate a Src structure to which things can be transformed
 	     */
-	    target = (Src *)emalloc(sizeof (Src));
-	    target->file = estrdup(gn->name);
-	    target->suff = (Suff *)Lst_Datum(ln);
-	    target->suff->refCount++;
-	    target->node = gn;
-	    target->parent = (Src *)NULL;
-	    target->children = 0;
+	    targ = (Src *)emalloc(sizeof (Src));
+	    targ->file = estrdup(gn->name);
+	    targ->suff = (Suff *)Lst_Datum(ln);
+	    targ->suff->refCount++;
+	    targ->node = gn;
+	    targ->parent = (Src *)NULL;
+	    targ->children = 0;
 #ifdef DEBUG_SRC
-	    target->cp = Lst_Init(FALSE);
+	    targ->cp = Lst_Init(FALSE);
 #endif
 
@@ -1789,18 +1875,18 @@
 	     * the length of the suffix from the end of the name.
 	     */
-	    prefLen = (eoname - target->suff->nameLen) - sopref;
-	    target->pref = emalloc(prefLen + 1);
-	    memcpy(target->pref, sopref, prefLen);
-	    target->pref[prefLen] = '\0';
+	    prefLen = (eoname - targ->suff->nameLen) - sopref;
+	    targ->pref = emalloc(prefLen + 1);
+	    memcpy(targ->pref, sopref, prefLen);
+	    targ->pref[prefLen] = '\0';
 
 	    /*
 	     * Add nodes from which the target can be made
 	     */
-	    SuffAddLevel(srcs, target);
+	    SuffAddLevel(srcs, targ);
 
 	    /*
 	     * Record the target so we can nuke it
 	     */
-	    (void)Lst_AtEnd(targs, (void *)target);
+	    (void)Lst_AtEnd(targs, (ClientData)targ);
 
 	    /*
@@ -1815,5 +1901,7 @@
      */
     if (Lst_IsEmpty(targs) && suffNull != NULL) {
-	DEBUGF(SUFF, ("\tNo known suffix on %s. Using .NULL suffix\n", gn->name));
+	if (DEBUG(SUFF)) {
+	    printf("\tNo known suffix on %s. Using .NULL suffix\n", gn->name);
+	}
 
 	targ = (Src *)emalloc(sizeof (Src));
@@ -1836,10 +1924,12 @@
 	    SuffAddLevel(srcs, targ);
 	else {
-	    DEBUGF(SUFF, ("not "));
-	}
-
-	DEBUGF(SUFF, ("adding suffix rules\n"));
-
-	(void)Lst_AtEnd(targs, (void *)targ);
+	    if (DEBUG(SUFF))
+		printf("not ");
+	}
+
+	if (DEBUG(SUFF))
+	    printf("adding suffix rules\n");
+
+	(void)Lst_AtEnd(targs, (ClientData)targ);
     }
 
@@ -1884,8 +1974,10 @@
      * that still contain variables or wildcards in their names.
      */
-    Lst_ForEach(gn->children, SuffExpandChildren, (void *)gn);
+    Lst_ForEach(gn->children, SuffExpandChildren, (ClientData)gn);
 
     if (targ == NULL) {
-	DEBUGF(SUFF, ("\tNo valid suffix on %s\n", gn->name));
+	if (DEBUG(SUFF)) {
+	    printf("\tNo valid suffix on %s\n", gn->name);
+	}
 
 sfnd_abort:
@@ -1984,6 +2076,6 @@
 	     */
 	    while (bottom && bottom->parent != NULL) {
-		if (Lst_Member(slst, (void *) bottom) == NULL) {
-		    Lst_AtEnd(slst, (void *) bottom);
+		if (Lst_Member(slst, (ClientData) bottom) == NILLNODE) {
+		    Lst_AtEnd(slst, (ClientData) bottom);
 		}
 		bottom = bottom->parent;
@@ -2012,5 +2104,5 @@
      * Etc.
      */
-    if (bottom->node == NULL) {
+    if (bottom->node == NILGNODE) {
 	bottom->node = Targ_FindNode(bottom->file, TARG_CREATE);
     }
@@ -2024,5 +2116,5 @@
 	src->node->suffix->refCount++;
 
-	if (targ->node == NULL) {
+	if (targ->node == NILGNODE) {
 	    targ->node = Targ_FindNode(targ->file, TARG_CREATE);
 	}
@@ -2066,6 +2158,6 @@
 sfnd_return:
     if (bottom)
-	if (Lst_Member(slst, (void *) bottom) == NULL)
-	    Lst_AtEnd(slst, (void *) bottom);
+	if (Lst_Member(slst, (ClientData) bottom) == NILLNODE)
+	    Lst_AtEnd(slst, (ClientData) bottom);
 
     while (SuffRemoveSrc(srcs) || SuffRemoveSrc(targs))
@@ -2106,5 +2198,6 @@
 
 void
-Suff_FindDeps(GNode *gn)
+Suff_FindDeps(gn)
+    GNode *gn;
 {
 
@@ -2116,5 +2209,7 @@
 
 static void
-SuffFindDeps (GNode *gn, Lst slst)
+SuffFindDeps (gn, slst)
+    GNode         *gn;	      	/* node we're dealing with */
+    Lst		  slst;
 {
     if (gn->type & OP_DEPS_FOUND) {
@@ -2127,5 +2222,7 @@
     }
 
-    DEBUGF(SUFF, ("SuffFindDeps (%s)\n", gn->name));
+    if (DEBUG(SUFF)) {
+	printf ("SuffFindDeps (%s)\n", gn->name);
+    }
 
     if (gn->type & OP_ARCHV) {
@@ -2143,8 +2240,8 @@
 	Suff	*s;
 
-	ln = Lst_Find (sufflist, (void *)LIBSUFF, SuffSuffHasNameP);
+	ln = Lst_Find (sufflist, (ClientData)LIBSUFF, SuffSuffHasNameP);
 	if (gn->suffix)
 	    gn->suffix->refCount--;
-	if (ln != NULL) {
+	if (ln != NILLNODE) {
 	    gn->suffix = s = (Suff *) Lst_Datum (ln);
 	    gn->suffix->refCount++;
@@ -2183,11 +2280,12 @@
  */
 void
-Suff_SetNull(char *name)
+Suff_SetNull(name)
+    char    *name;	    /* Name of null suffix */
 {
     Suff    *s;
     LstNode ln;
 
-    ln = Lst_Find(sufflist, (void *)name, SuffSuffHasNameP);
-    if (ln != NULL) {
+    ln = Lst_Find(sufflist, (ClientData)name, SuffSuffHasNameP);
+    if (ln != NILLNODE) {
 	s = (Suff *)Lst_Datum(ln);
 	if (suffNull != (Suff *)NULL) {
@@ -2218,5 +2316,5 @@
  */
 void
-Suff_Init (void)
+Suff_Init ()
 {
     sufflist = Lst_Init (FALSE);
@@ -2261,5 +2359,5 @@
 
 void
-Suff_End(void)
+Suff_End()
 {
     Lst_Destroy(sufflist, SuffFree);
@@ -2274,13 +2372,16 @@
 /********************* DEBUGGING FUNCTIONS **********************/
 
+static int SuffPrintName(s, dummy)
+    ClientData s;
+    ClientData dummy;
+{
+    printf ("`%s' ", ((Suff *) s)->name);
+    return (dummy ? 0 : 0);
+}
+
 static int
-SuffPrintName(void *s, void *dummy __unused)
-{
-    printf ("`%s' ", ((Suff *) s)->name);
-    return (0);
-}
-
-static int
-SuffPrintSuff (void *sp, void *dummy __unused)
+SuffPrintSuff (sp, dummy)
+    ClientData sp;
+    ClientData dummy;
 {
     Suff    *s = (Suff *) sp;
@@ -2306,6 +2407,4 @@
 		    printf ("LIBRARY");
 		    break;
-		default:
-		    break;
 	    }
 	    fputc(flags ? '|' : ')', stdout);
@@ -2314,17 +2413,19 @@
     fputc ('\n', stdout);
     printf ("#\tTo: ");
-    Lst_ForEach (s->parents, SuffPrintName, (void *)0);
+    Lst_ForEach (s->parents, SuffPrintName, (ClientData)0);
     fputc ('\n', stdout);
     printf ("#\tFrom: ");
-    Lst_ForEach (s->children, SuffPrintName, (void *)0);
+    Lst_ForEach (s->children, SuffPrintName, (ClientData)0);
     fputc ('\n', stdout);
     printf ("#\tSearch Path: ");
     Dir_PrintPath (s->searchPath);
     fputc ('\n', stdout);
-    return (0);
+    return (dummy ? 0 : 0);
 }
 
 static int
-SuffPrintTrans (void *tp, void *dummy __unused)
+SuffPrintTrans (tp, dummy)
+    ClientData tp;
+    ClientData dummy;
 {
     GNode   *t = (GNode *) tp;
@@ -2333,16 +2434,16 @@
     Targ_PrintType (t->type);
     fputc ('\n', stdout);
-    Lst_ForEach (t->commands, Targ_PrintCmd, (void *)0);
+    Lst_ForEach (t->commands, Targ_PrintCmd, (ClientData)0);
     fputc ('\n', stdout);
-    return (0);
+    return(dummy ? 0 : 0);
 }
 
 void
-Suff_PrintAll(void)
+Suff_PrintAll()
 {
     printf ("#*** Suffixes:\n");
-    Lst_ForEach (sufflist, SuffPrintSuff, (void *)0);
+    Lst_ForEach (sufflist, SuffPrintSuff, (ClientData)0);
 
     printf ("#*** Transformations:\n");
-    Lst_ForEach (transforms, SuffPrintTrans, (void *)0);
-}
+    Lst_ForEach (transforms, SuffPrintTrans, (ClientData)0);
+}
Index: /trunk/src/kmk/targ.c
===================================================================
--- /trunk/src/kmk/targ.c	(revision 24)
+++ /trunk/src/kmk/targ.c	(revision 25)
@@ -35,10 +35,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * @(#)targ.c	8.2 (Berkeley) 3/19/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/targ.c,v 1.25 2002/10/09 03:42:10 jmallett Exp $");
+ */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)targ.c	8.2 (Berkeley) 3/19/94";
+#else
+static const char rcsid[] =
+  "$FreeBSD: src/usr.bin/make/targ.c,v 1.10 1999/09/11 13:08:02 hoek Exp $";
+#endif
+#endif /* not lint */
 
 /*-
@@ -93,10 +97,10 @@
 static Hash_Table targets;	/* a hash table of same */
 
-#define	HTSIZE	191		/* initial size of hash table */
-
-static int TargPrintOnlySrc(void *, void *);
-static int TargPrintName(void *, void *);
-static int TargPrintNode(void *, void *);
-static void TargFreeGN(void *);
+#define HTSIZE	191		/* initial size of hash table */
+
+static int TargPrintOnlySrc __P((ClientData, ClientData));
+static int TargPrintName __P((ClientData, ClientData));
+static int TargPrintNode __P((ClientData, ClientData));
+static void TargFreeGN __P((ClientData));
 
 /*-
@@ -113,5 +117,5 @@
  */
 void
-Targ_Init (void)
+Targ_Init ()
 {
     allTargets = Lst_Init (FALSE);
@@ -132,5 +136,5 @@
  */
 void
-Targ_End (void)
+Targ_End ()
 {
     Lst_Destroy(allTargets, NOFREE);
@@ -154,7 +158,8 @@
  */
 GNode *
-Targ_NewGN (char *name)
-{
-    GNode *gn;
+Targ_NewGN (name)
+    char           *name;	/* the name to stick in the new node */
+{
+    register GNode *gn;
 
     gn = (GNode *) emalloc (sizeof (GNode));
@@ -184,5 +189,5 @@
     if (allGNs == NULL)
 	allGNs = Lst_Init(FALSE);
-    Lst_AtEnd(allGNs, (void *) gn);
+    Lst_AtEnd(allGNs, (ClientData) gn);
 
     return (gn);
@@ -202,5 +207,6 @@
  */
 static void
-TargFreeGN (void *gnp)
+TargFreeGN (gnp)
+    ClientData gnp;
 {
     GNode *gn = (GNode *) gnp;
@@ -218,5 +224,5 @@
     Lst_Destroy(gn->context, NOFREE);
     Lst_Destroy(gn->commands, NOFREE);
-    free(gn);
+    free((Address)gn);
 }
 
@@ -228,5 +234,5 @@
  *
  * Results:
- *	The node in the list if it was. If it wasn't, return NULL of
+ *	The node in the list if it was. If it wasn't, return NILGNODE of
  *	flags was TARG_NOCREATE or the newly created and initialized node
  *	if it was TARG_CREATE
@@ -237,5 +243,8 @@
  */
 GNode *
-Targ_FindNode (char *name, int flags)
+Targ_FindNode (name, flags)
+    char           *name;	/* the name to find */
+    int             flags;	/* flags governing events when target not
+				 * found */
 {
     GNode         *gn;	      /* node in that element */
@@ -250,5 +259,5 @@
 	    gn = Targ_NewGN (name);
 	    Hash_SetValue (he, gn);
-	    (void) Lst_AtEnd (allTargets, (void *)gn);
+	    (void) Lst_AtEnd (allTargets, (ClientData)gn);
 	}
     } else {
@@ -257,5 +266,5 @@
 
     if (he == (Hash_Entry *) NULL) {
-	return (NULL);
+	return (NILGNODE);
     } else {
 	return ((GNode *) Hash_GetValue (he));
@@ -279,10 +288,13 @@
  */
 Lst
-Targ_FindList (Lst names, int flags)
+Targ_FindList (names, flags)
+    Lst        	   names;	/* list of names to find */
+    int            flags;	/* flags used if no node is found for a given
+				 * name */
 {
     Lst            nodes;	/* result list */
-    LstNode	   ln;		/* name list element */
-    GNode	   *gn;		/* node in tLn */
-    char    	   *name;
+    register LstNode  ln;		/* name list element */
+    register GNode *gn;		/* node in tLn */
+    char    	  *name;
 
     nodes = Lst_Init (FALSE);
@@ -291,8 +303,8 @@
 	return (nodes);
     }
-    while ((ln = Lst_Next (names)) != NULL) {
+    while ((ln = Lst_Next (names)) != NILLNODE) {
 	name = (char *)Lst_Datum(ln);
 	gn = Targ_FindNode (name, flags);
-	if (gn != NULL) {
+	if (gn != NILGNODE) {
 	    /*
 	     * Note: Lst_AtEnd must come before the Lst_Concat so the nodes
@@ -300,5 +312,5 @@
 	     * encountered in the makefile.
 	     */
-	    (void) Lst_AtEnd (nodes, (void *)gn);
+	    (void) Lst_AtEnd (nodes, (ClientData)gn);
 	    if (gn->type & OP_DOUBLEDEP) {
 		(void)Lst_Concat (nodes, gn->cohorts, LST_CONCNEW);
@@ -325,5 +337,6 @@
  */
 Boolean
-Targ_Ignore (GNode *gn)
+Targ_Ignore (gn)
+    GNode          *gn;		/* node to check for */
 {
     if (ignoreErrors || gn->type & OP_IGNORE) {
@@ -347,5 +360,6 @@
  */
 Boolean
-Targ_Silent (GNode *gn)
+Targ_Silent (gn)
+    GNode          *gn;		/* node to check for */
 {
     if (beSilent || gn->type & OP_SILENT) {
@@ -369,5 +383,6 @@
  */
 Boolean
-Targ_Precious (GNode *gn)
+Targ_Precious (gn)
+    GNode          *gn;		/* the node to check */
 {
     if (allPrecious || (gn->type & (OP_PRECIOUS|OP_DOUBLEDEP))) {
@@ -395,5 +410,6 @@
  */
 void
-Targ_SetMain (GNode *gn)
+Targ_SetMain (gn)
+    GNode   *gn;  	/* The main target we'll create */
 {
     mainTarg = gn;
@@ -401,5 +417,7 @@
 
 static int
-TargPrintName (void *gnp, void *ppath)
+TargPrintName (gnp, ppath)
+    ClientData     gnp;
+    ClientData	    ppath;
 {
     GNode *gn = (GNode *) gnp;
@@ -420,8 +438,10 @@
 
 int
-Targ_PrintCmd (void *cmd, void *dummy __unused)
+Targ_PrintCmd (cmd, dummy)
+    ClientData cmd;
+    ClientData dummy;
 {
     printf ("\t%s\n", (char *) cmd);
-    return (0);
+    return (dummy ? 0 : 0);
 }
 
@@ -441,12 +461,13 @@
  */
 char *
-Targ_FmtTime (time_t modtime)
+Targ_FmtTime (time)
+    time_t    time;
 {
     struct tm	  	*parts;
     static char	  	buf[128];
 
-    parts = localtime(&modtime);
-
-    strftime(buf, sizeof buf, "%H:%M:%S %b %d, %Y", parts);
+    parts = localtime(&time);
+
+    strftime(buf, sizeof buf, "%k:%M:%S %b %d, %Y", parts);
     buf[sizeof(buf) - 1] = '\0';
     return(buf);
@@ -466,10 +487,16 @@
  */
 void
-Targ_PrintType (int type)
-{
-    int    tbit;
-
-#define	PRINTBIT(attr)	case CONCAT(OP_,attr): printf("." #attr " "); break
-#define	PRINTDBIT(attr) case CONCAT(OP_,attr): DEBUGF(TARG, ("." #attr " ")); break
+Targ_PrintType (type)
+    register int    type;
+{
+    register int    tbit;
+
+#ifdef __STDC__
+#define PRINTBIT(attr)	case CONCAT(OP_,attr): printf("." #attr " "); break
+#define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG)) printf("." #attr " "); break
+#else
+#define PRINTBIT(attr) 	case CONCAT(OP_,attr): printf(".attr "); break
+#define PRINTDBIT(attr)	case CONCAT(OP_,attr): if (DEBUG(TARG)) printf(".attr "); break
+#endif /* __STDC__ */
 
     type &= ~OP_OPMASK;
@@ -492,5 +519,5 @@
 	    PRINTDBIT(LIB);
 	    /*XXX: MEMBER is defined, so CONCAT(OP_,MEMBER) gives OP_"%" */
-	    case OP_MEMBER: DEBUGF(TARG, (".MEMBER ")); break;
+	    case OP_MEMBER: if (DEBUG(TARG)) printf(".MEMBER "); break;
 	    PRINTDBIT(ARCHV);
 	}
@@ -505,5 +532,7 @@
  */
 static int
-TargPrintNode (void *gnp, void *passp)
+TargPrintNode (gnp, passp)
+    ClientData   gnp;
+    ClientData	 passp;
 {
     GNode         *gn = (GNode *) gnp;
@@ -540,5 +569,5 @@
 	    if (!Lst_IsEmpty (gn->iParents)) {
 		printf("# implicit parents: ");
-		Lst_ForEach (gn->iParents, TargPrintName, (void *)0);
+		Lst_ForEach (gn->iParents, TargPrintName, (ClientData)0);
 		fputc ('\n', stdout);
 	    }
@@ -546,5 +575,5 @@
 	if (!Lst_IsEmpty (gn->parents)) {
 	    printf("# parents: ");
-	    Lst_ForEach (gn->parents, TargPrintName, (void *)0);
+	    Lst_ForEach (gn->parents, TargPrintName, (ClientData)0);
 	    fputc ('\n', stdout);
 	}
@@ -558,14 +587,12 @@
 	    case OP_DOUBLEDEP:
 		printf(":: "); break;
-	    default:
-		break;
 	}
 	Targ_PrintType (gn->type);
-	Lst_ForEach (gn->children, TargPrintName, (void *)0);
+	Lst_ForEach (gn->children, TargPrintName, (ClientData)0);
 	fputc ('\n', stdout);
-	Lst_ForEach (gn->commands, Targ_PrintCmd, (void *)0);
+	Lst_ForEach (gn->commands, Targ_PrintCmd, (ClientData)0);
 	printf("\n\n");
 	if (gn->type & OP_DOUBLEDEP) {
-	    Lst_ForEach (gn->cohorts, TargPrintNode, (void *)&pass);
+	    Lst_ForEach (gn->cohorts, TargPrintNode, (ClientData)&pass);
 	}
     }
@@ -582,10 +609,12 @@
  *
  * Side Effects:
- *	The name of each file is printed preceded by #\t
+ *	The name of each file is printed preceeded by #\t
  *
  *-----------------------------------------------------------------------
  */
 static int
-TargPrintOnlySrc(void *gnp, void *dummy __unused)
+TargPrintOnlySrc(gnp, dummy)
+    ClientData 	  gnp;
+    ClientData 	  dummy;
 {
     GNode   	  *gn = (GNode *) gnp;
@@ -593,5 +622,5 @@
 	printf("#\t%s [%s]\n", gn->name, gn->path ? gn->path : gn->name);
 
-    return (0);
+    return (dummy ? 0 : 0);
 }
 
@@ -599,5 +628,5 @@
  *-----------------------------------------------------------------------
  * Targ_PrintGraph --
- *	Print the entire graph.
+ *	print the entire graph. heh heh
  *
  * Results:
@@ -609,11 +638,13 @@
  */
 void
-Targ_PrintGraph (int pass)
+Targ_PrintGraph (pass)
+    int	    pass; 	/* Which pass this is. 1 => no processing
+			 * 2 => processing done */
 {
     printf("#*** Input graph:\n");
-    Lst_ForEach (allTargets, TargPrintNode, (void *)&pass);
+    Lst_ForEach (allTargets, TargPrintNode, (ClientData)&pass);
     printf("\n\n");
     printf("#\n#   Files that are only sources:\n");
-    Lst_ForEach (allTargets, TargPrintOnlySrc, (void *) 0);
+    Lst_ForEach (allTargets, TargPrintOnlySrc, (ClientData) 0);
     printf("#*** Global Variables:\n");
     Var_Dump (VAR_GLOBAL);
Index: /trunk/src/kmk/util.c
===================================================================
--- /trunk/src/kmk/util.c	(revision 24)
+++ /trunk/src/kmk/util.c	(revision 25)
@@ -1,285 +1,343 @@
 /*
- * Copyright (c) 2002 Juli Mallett.  All rights reserved.
- * Copyright (c) 1988, 1989, 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
- * Copyright (c) 1989 by Berkeley Softworks
- * All rights reserved.
+ * Missing stuff from OS's
+ */
+
+#ifndef lint
+static char rcsid[] = "$FreeBSD: src/usr.bin/make/util.c,v 1.5.2.2 2001/02/13 03:13:58 will Exp $";
+#endif
+
+#include <stdio.h>
+#include <errno.h>
+#include "make.h"
+
+#if !__STDC__
+# ifndef const
+#  define const
+# endif
+#endif
+
+#ifdef sun
+extern int errno, sys_nerr;
+extern char *sys_errlist[];
+
+char *
+strerror(e)
+    int e;
+{
+    static char buf[100];
+    if (e < 0 || e >= sys_nerr) {
+	sprintf(buf, "Unknown error %d", e);
+	return buf;
+    }
+    else
+	return sys_errlist[e];
+}
+#endif
+
+#ifdef ultrix
+#include <string.h>
+
+/* strdup
  *
- * This code is derived from software contributed to Berkeley by
- * Adam de Boor.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)main.c      8.3 (Berkeley) 3/19/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/util.c,v 1.12 2002/10/10 19:27:48 jmallett Exp $");
-
-/*-
- * util.c --
- *	General utilitarian routines for make(1).
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <err.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <sysexits.h>
-#include <stdarg.h>
-#include <unistd.h>
-
-#include "make.h"
-#include "hash.h"
-#include "dir.h"
-#include "job.h"
-#include "pathnames.h"
-
-/*-
- * Debug --
- *	Print a debugging message given its format.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *	The message is printed.
- */
-/* VARARGS */
-void
-Debug(const char *fmt, ...)
-{
-	va_list ap;
-
-	va_start(ap, fmt);
-	(void)vfprintf(stderr, fmt, ap);
-	va_end(ap);
-	(void)fflush(stderr);
-}
-
-/*-
- * Error --
- *	Print an error message given its format.
- *
- * Results:
- *	None.
- *
- * Side Effects:
- *	The message is printed.
- */
-/* VARARGS */
-void
-Error(const char *fmt, ...)
-{
-	va_list ap;
-
-	va_start(ap, fmt);
-	(void)vfprintf(stderr, fmt, ap);
-	va_end(ap);
-	(void)fprintf(stderr, "\n");
-	(void)fflush(stderr);
-}
-
-/*-
- * Fatal --
- *	Produce a Fatal error message. If jobs are running, waits for them
- *	to finish.
- *
- * Results:
- *	None
- *
- * Side Effects:
- *	The program exits
- */
-/* VARARGS */
-void
-Fatal(const char *fmt, ...)
-{
-	va_list ap;
-
-	va_start(ap, fmt);
-	if (jobsRunning)
-		Job_Wait();
-
-	(void)vfprintf(stderr, fmt, ap);
-	va_end(ap);
-	(void)fprintf(stderr, "\n");
-	(void)fflush(stderr);
-
-	if (DEBUG(GRAPH2))
-		Targ_PrintGraph(2);
-	exit(2);		/* Not 1 so -q can distinguish error */
-}
-
-/*
- * Punt --
- *	Major exception once jobs are being created. Kills all jobs, prints
- *	a message and exits.
- *
- * Results:
- *	None
- *
- * Side Effects:
- *	All children are killed indiscriminately and the program Lib_Exits
- */
-/* VARARGS */
-void
-Punt(const char *fmt, ...)
-{
-	va_list ap;
-
-	va_start(ap, fmt);
-	(void)fprintf(stderr, "make: ");
-	(void)vfprintf(stderr, fmt, ap);
-	va_end(ap);
-	(void)fprintf(stderr, "\n");
-	(void)fflush(stderr);
-
-	DieHorribly();
-}
-
-/*-
- * DieHorribly --
- *	Exit without giving a message.
- *
- * Results:
- *	None
- *
- * Side Effects:
- *	A big one...
- */
-void
-DieHorribly(void)
-{
-	if (jobsRunning)
-		Job_AbortAll();
-	if (DEBUG(GRAPH2))
-		Targ_PrintGraph(2);
-	exit(2);		/* Not 1, so -q can distinguish error */
-}
-
-/*
- * Finish --
- *	Called when aborting due to errors in child shell to signal
- *	abnormal exit, with the number of errors encountered in Make_Make.
- *
- * Results:
- *	None
- *
- * Side Effects:
- *	The program exits
- */
-void
-Finish(int errors)
-{
-	Fatal("%d error%s", errors, errors == 1 ? "" : "s");
-}
-
-/*
- * emalloc --
- *	malloc, but die on error.
- */
-void *
-emalloc(size_t len)
-{
-	void *p;
-
-	if ((p = malloc(len)) == NULL)
-		enomem();
-	return(p);
-}
-
-/*
- * estrdup --
- *	strdup, but die on error.
+ * Make a duplicate of a string.
+ * For systems which lack this function.
  */
 char *
-estrdup(const char *str)
-{
-	char *p;
-
-	if ((p = strdup(str)) == NULL)
-		enomem();
-	return(p);
-}
-
-/*
- * erealloc --
- *	realloc, but die on error.
+strdup(str)
+    const char *str;
+{
+    size_t len;
+
+    if (str == NULL)
+	return NULL;
+    len = strlen(str) + 1;
+    if ((p = malloc(len)) == NULL)
+	return NULL;
+
+    return memcpy(p, str, len);
+}
+
+#endif
+
+#if defined(sun) || defined(__hpux) || defined(__sgi)
+
+int
+setenv(name, value, dum)
+    const char *name;
+    const char *value;
+    int dum;
+{
+    register char *p;
+    int len = strlen(name) + strlen(value) + 2; /* = \0 */
+    char *ptr = (char*) malloc(len);
+
+    (void) dum;
+
+    if (ptr == NULL)
+	return -1;
+
+    p = ptr;
+
+    while (*name)
+	*p++ = *name++;
+
+    *p++ = '=';
+
+    while (*value)
+	*p++ = *value++;
+
+    *p = '\0';
+
+    len = putenv(ptr);
+/*    free(ptr); */
+    return len;
+}
+#endif
+
+#ifdef __hpux
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/syscall.h>
+#include <sys/signal.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <sys/time.h>
+#include <time.h>
+#include <unistd.h>
+
+
+int
+killpg(pid, sig)
+    int pid, sig;
+{
+    return kill(-pid, sig);
+}
+
+void
+srandom(seed)
+    long seed;
+{
+    srand48(seed);
+}
+
+long
+random()
+{
+    return lrand48();
+}
+
+/* turn into bsd signals */
+void (*
+signal(s, a)) ()
+    int     s;
+    void (*a)();
+{
+    struct sigvec osv, sv;
+
+    (void) sigvector(s, (struct sigvec *) 0, &osv);
+    sv = osv;
+    sv.sv_handler = a;
+#ifdef SV_BSDSIG
+    sv.sv_flags = SV_BSDSIG;
+#endif
+
+    if (sigvector(s, &sv, (struct sigvec *) 0) == -1)
+        return (BADSIG);
+    return (osv.sv_handler);
+}
+
+#if !defined(BSD) && !defined(d_fileno)
+# define d_fileno d_ino
+#endif
+
+#ifndef DEV_DEV_COMPARE
+# define DEV_DEV_COMPARE(a, b) ((a) == (b))
+#endif
+
+/* strrcpy():
+ *	Like strcpy, going backwards and returning the new pointer
  */
-void *
-erealloc(void *ptr, size_t size)
-{
-	if ((ptr = realloc(ptr, size)) == NULL)
-		enomem();
-	return(ptr);
-}
-
-/*
- * enomem --
- *	die when out of memory.
- */
-void
-enomem(void)
-{
-	err(2, NULL);
-}
-
-/*
- * enunlink --
- *	Remove a file carefully, avoiding directories.
- */
+static char *
+strrcpy(ptr, str)
+    register char *ptr, *str;
+{
+    register int len = strlen(str);
+
+    while (len)
+	*--ptr = str[--len];
+
+    return (ptr);
+} /* end strrcpy */
+
+
+char   *
+getwd(pathname)
+    char   *pathname;
+{
+    DIR    *dp;
+    struct dirent *d;
+
+    struct stat st_root, st_cur, st_next, st_dotdot;
+    char    pathbuf[MAXPATHLEN], nextpathbuf[MAXPATHLEN * 2];
+    char   *pathptr, *nextpathptr, *cur_name_add;
+
+    /* find the inode of root */
+    if (stat("/", &st_root) == -1) {
+	(void) sprintf(pathname,
+			"getwd: Cannot stat \"/\" (%s)", strerror(errno));
+	return (NULL);
+    }
+    pathbuf[MAXPATHLEN - 1] = '\0';
+    pathptr = &pathbuf[MAXPATHLEN - 1];
+    nextpathbuf[MAXPATHLEN - 1] = '\0';
+    cur_name_add = nextpathptr = &nextpathbuf[MAXPATHLEN - 1];
+
+    /* find the inode of the current directory */
+    if (lstat(".", &st_cur) == -1) {
+	(void) sprintf(pathname,
+			"getwd: Cannot stat \".\" (%s)", strerror(errno));
+	return (NULL);
+    }
+    nextpathptr = strrcpy(nextpathptr, "../");
+
+    /* Descend to root */
+    for (;;) {
+
+	/* look if we found root yet */
+	if (st_cur.st_ino == st_root.st_ino &&
+	    DEV_DEV_COMPARE(st_cur.st_dev, st_root.st_dev)) {
+	    (void) strcpy(pathname, *pathptr != '/' ? "/" : pathptr);
+	    return (pathname);
+	}
+
+	/* open the parent directory */
+	if (stat(nextpathptr, &st_dotdot) == -1) {
+	    snprintf(pathname, sizeof(pathname),
+			    "getwd: Cannot stat directory \"%s\" (%s)",
+			    nextpathptr, strerror(errno));
+	    return (NULL);
+	}
+	if ((dp = opendir(nextpathptr)) == NULL) {
+	     snprintf(pathname, sizeof(pathname),
+			    "getwd: Cannot open directory \"%s\" (%s)",
+			    nextpathptr, strerror(errno));
+	    return (NULL);
+	}
+
+	/* look in the parent for the entry with the same inode */
+	if (DEV_DEV_COMPARE(st_dotdot.st_dev, st_cur.st_dev)) {
+	    /* Parent has same device. No need to stat every member */
+	    for (d = readdir(dp); d != NULL; d = readdir(dp))
+		if (d->d_fileno == st_cur.st_ino)
+		    break;
+	}
+	else {
+	    /*
+	     * Parent has a different device. This is a mount point so we
+	     * need to stat every member
+	     */
+	    for (d = readdir(dp); d != NULL; d = readdir(dp)) {
+		if (ISDOT(d->d_name) || ISDOTDOT(d->d_name))
+		    continue;
+		(void) strcpy(cur_name_add, d->d_name);
+		if (lstat(nextpathptr, &st_next) == -1) {
+		    snprintf(pathname, sizeof(pathname), "getwd: Cannot stat \"%s\" (%s)",
+				    d->d_name, strerror(errno));
+		    (void) closedir(dp);
+		    return (NULL);
+		}
+		/* check if we found it yet */
+		if (st_next.st_ino == st_cur.st_ino &&
+		    DEV_DEV_COMPARE(st_next.st_dev, st_cur.st_dev))
+		    break;
+	    }
+	}
+	if (d == NULL) {
+	    (void) sprintf(pathname, "getwd: Cannot find \".\" in \"..\"");
+	    (void) closedir(dp);
+	    return (NULL);
+	}
+	st_cur = st_dotdot;
+	pathptr = strrcpy(pathptr, d->d_name);
+	pathptr = strrcpy(pathptr, "/");
+	nextpathptr = strrcpy(nextpathptr, "../");
+	(void) closedir(dp);
+	*cur_name_add = '\0';
+    }
+} /* end getwd */
+
+
+char    *sys_siglist[] = {
+        "Signal 0",
+        "Hangup",                       /* SIGHUP    */
+        "Interrupt",                    /* SIGINT    */
+        "Quit",                         /* SIGQUIT   */
+        "Illegal instruction",          /* SIGILL    */
+        "Trace/BPT trap",               /* SIGTRAP   */
+        "IOT trap",                     /* SIGIOT    */
+        "EMT trap",                     /* SIGEMT    */
+        "Floating point exception",     /* SIGFPE    */
+        "Killed",                       /* SIGKILL   */
+        "Bus error",                    /* SIGBUS    */
+        "Segmentation fault",           /* SIGSEGV   */
+        "Bad system call",              /* SIGSYS    */
+        "Broken pipe",                  /* SIGPIPE   */
+        "Alarm clock",                  /* SIGALRM   */
+        "Terminated",                   /* SIGTERM   */
+        "User defined signal 1",        /* SIGUSR1   */
+        "User defined signal 2",        /* SIGUSR2   */
+        "Child exited",                 /* SIGCLD    */
+        "Power-fail restart",           /* SIGPWR    */
+        "Virtual timer expired",        /* SIGVTALRM */
+        "Profiling timer expired",      /* SIGPROF   */
+        "I/O possible",                 /* SIGIO     */
+        "Window size changes",          /* SIGWINDOW */
+        "Stopped (signal)",             /* SIGSTOP   */
+        "Stopped",                      /* SIGTSTP   */
+        "Continued",                    /* SIGCONT   */
+        "Stopped (tty input)",          /* SIGTTIN   */
+        "Stopped (tty output)",         /* SIGTTOU   */
+        "Urgent I/O condition",         /* SIGURG    */
+        "Remote lock lost (NFS)",       /* SIGLOST   */
+        "Signal 31",                    /* reserved  */
+        "DIL signal"                    /* SIGDIL    */
+};
+
 int
-eunlink(const char *file)
-{
-	struct stat st;
-
-	if (lstat(file, &st) == -1)
-		return -1;
-
-	if (S_ISDIR(st.st_mode)) {
-		errno = EISDIR;
-		return -1;
-	}
-	return unlink(file);
-}
-
-/*
- * Printaddr --
- * 	Print the address of a node, used as an interative function.
- */
-int
-PrintAddr(void *a, void *b __unused)
-{
-    printf("%p ", a);
-    return 0;
-}
+utimes(file, tvp)
+    char *file;
+    struct timeval tvp[2];
+{
+    struct utimbuf t;
+
+    t.actime  = tvp[0].tv_sec;
+    t.modtime = tvp[1].tv_sec;
+    return(utime(file, &t));
+}
+
+
+#endif /* __hpux */
+
+#if defined(sun) && defined(__svr4__)
+#include <signal.h>
+
+/* turn into bsd signals */
+void (*
+signal(s, a)) ()
+    int     s;
+    void (*a)();
+{
+    struct sigaction sa, osa;
+
+    sa.sa_handler = a;
+    sigemptyset(&sa.sa_mask);
+    sa.sa_flags = SA_RESTART;
+
+    if (sigaction(s, &sa, &osa) == -1)
+	return SIG_ERR;
+    else
+	return osa.sa_handler;
+}
+
+#endif
Index: /trunk/src/kmk/var.c
===================================================================
--- /trunk/src/kmk/var.c	(revision 24)
+++ /trunk/src/kmk/var.c	(revision 25)
@@ -35,10 +35,14 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * @(#)var.c	8.3 (Berkeley) 3/19/94
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/make/var.c,v 1.35 2002/10/09 03:42:10 jmallett Exp $");
+ */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
+#else
+static const char rcsid[] =
+  "$FreeBSD: src/usr.bin/make/var.c,v 1.16.2.3 2002/02/27 14:18:57 cjc Exp $";
+#endif
+#endif /* not lint */
 
 /*-
@@ -126,7 +130,7 @@
 static Lst	allVars;      /* List of all variables */
 
-#define	FIND_CMD	0x1   /* look in VAR_CMD when searching */
-#define	FIND_GLOBAL	0x2   /* look in VAR_GLOBAL as well */
-#define	FIND_ENV  	0x4   /* look in the environment also */
+#define FIND_CMD	0x1   /* look in VAR_CMD when searching */
+#define FIND_GLOBAL	0x2   /* look in VAR_GLOBAL as well */
+#define FIND_ENV  	0x4   /* look in the environment also */
 
 typedef struct Var {
@@ -134,8 +138,8 @@
     Buffer	  val;	    	/* its value */
     int	    	  flags;    	/* miscellaneous status flags */
-#define	VAR_IN_USE	1   	    /* Variable's value currently being used.
+#define VAR_IN_USE	1   	    /* Variable's value currently being used.
 				     * Used to avoid recursion */
-#define	VAR_FROM_ENV	2   	    /* Variable comes from the environment */
-#define	VAR_JUNK  	4   	    /* Variable is a junk variable that
+#define VAR_FROM_ENV	2   	    /* Variable comes from the environment */
+#define VAR_JUNK  	4   	    /* Variable is a junk variable that
 				     * should be destroyed when done with
 				     * it. Used by Var_Parse for undefined,
@@ -144,10 +148,10 @@
 
 /* Var*Pattern flags */
-#define	VAR_SUB_GLOBAL	0x01	/* Apply substitution globally */
-#define	VAR_SUB_ONE	0x02	/* Apply substitution to one word */
-#define	VAR_SUB_MATCHED	0x04	/* There was a match */
-#define	VAR_MATCH_START	0x08	/* Match at start of word */
-#define	VAR_MATCH_END	0x10	/* Match at end of word */
-#define	VAR_NOSUBST	0x20	/* don't expand vars in VarGetPattern */
+#define VAR_SUB_GLOBAL	0x01	/* Apply substitution globally */
+#define VAR_SUB_ONE	0x02	/* Apply substitution to one word */
+#define VAR_SUB_MATCHED	0x04	/* There was a match */
+#define VAR_MATCH_START	0x08	/* Match at start of word */
+#define VAR_MATCH_END	0x10	/* Match at end of word */
+#define VAR_NOSUBST	0x20	/* don't expand vars in VarGetPattern */
 
 typedef struct {
@@ -167,27 +171,27 @@
 } VarREPattern;
 
-static int VarCmp(void *, void *);
-static void VarPossiblyExpand(char **, GNode *);
-static Var *VarFind(char *, GNode *, int);
-static void VarAdd(char *, char *, GNode *);
-static void VarDelete(void *);
-static Boolean VarHead(char *, Boolean, Buffer, void *);
-static Boolean VarTail(char *, Boolean, Buffer, void *);
-static Boolean VarSuffix(char *, Boolean, Buffer, void *);
-static Boolean VarRoot(char *, Boolean, Buffer, void *);
-static Boolean VarMatch(char *, Boolean, Buffer, void *);
+static int VarCmp __P((ClientData, ClientData));
+static Var *VarFind __P((char *, GNode *, int));
+static void VarAdd __P((char *, char *, GNode *));
+static void VarDelete __P((ClientData));
+static Boolean VarHead __P((char *, Boolean, Buffer, ClientData));
+static Boolean VarTail __P((char *, Boolean, Buffer, ClientData));
+static Boolean VarSuffix __P((char *, Boolean, Buffer, ClientData));
+static Boolean VarRoot __P((char *, Boolean, Buffer, ClientData));
+static Boolean VarMatch __P((char *, Boolean, Buffer, ClientData));
 #ifdef SYSVVARSUB
-static Boolean VarSYSVMatch(char *, Boolean, Buffer, void *);
+static Boolean VarSYSVMatch __P((char *, Boolean, Buffer, ClientData));
 #endif
-static Boolean VarNoMatch(char *, Boolean, Buffer, void *);
-static void VarREError(int, regex_t *, const char *);
-static Boolean VarRESubstitute(char *, Boolean, Buffer, void *);
-static Boolean VarSubstitute(char *, Boolean, Buffer, void *);
-static char *VarGetPattern(GNode *, int, char **, int, int *, int *, 
-			   VarPattern *);
-static char *VarQuote(char *);
-static char *VarModify(char *, Boolean (*)(char *, Boolean, Buffer, void *),
-		       void *);
-static int VarPrintVar(void *, void *);
+static Boolean VarNoMatch __P((char *, Boolean, Buffer, ClientData));
+static void VarREError __P((int, regex_t *, const char *));
+static Boolean VarRESubstitute __P((char *, Boolean, Buffer, ClientData));
+static Boolean VarSubstitute __P((char *, Boolean, Buffer, ClientData));
+static char *VarGetPattern __P((GNode *, int, char **, int, int *, int *,
+				VarPattern *));
+static char *VarQuote __P((char *));
+static char *VarModify __P((char *, Boolean (*)(char *, Boolean, Buffer,
+						ClientData),
+			    ClientData));
+static int VarPrintVar __P((ClientData, ClientData));
 
 /*-
@@ -205,28 +209,9 @@
  */
 static int
-VarCmp (void *v, void *name)
+VarCmp (v, name)
+    ClientData     v;		/* VAR structure to compare */
+    ClientData     name;	/* name to look for */
 {
     return (strcmp ((char *) name, ((Var *) v)->name));
-}
-
-/*-
- *-----------------------------------------------------------------------
- * VarPossiblyExpand --
- *	Expand a variable name's embedded variables in the given context.
- *
- * Results:
- *	The contents of name, possibly expanded.
- *
- * Side Effects:
- *	The caller must free the new contents or old contents of name.
- *-----------------------------------------------------------------------
- */
-static void
-VarPossiblyExpand(char **name, GNode *ctxt)
-{
-    if (strchr(*name, '$') != NULL)
-        *name = Var_Subst(NULL, *name, ctxt, 0);
-    else
-        *name = estrdup(*name);
 }
 
@@ -237,12 +222,7 @@
  *	indicated.
  *
- *	Flags:
- *		FIND_GLOBAL	set means look in the VAR_GLOBAL context too
- *		FIND_CMD	set means to look in the VAR_CMD context too
- *		FIND_ENV	set means to look in the environment
- *
  * Results:
  *	A pointer to the structure describing the desired variable or
- *	NULL if the variable does not exist.
+ *	NIL if the variable does not exist.
  *
  * Side Effects:
@@ -251,5 +231,13 @@
  */
 static Var *
-VarFind (char *name, GNode *ctxt, int flags)
+VarFind (name, ctxt, flags)
+    char           	*name;	/* name to find */
+    GNode          	*ctxt;	/* context in which to find it */
+    int             	flags;	/* FIND_GLOBAL set means to look in the
+				 * VAR_GLOBAL context as well.
+				 * FIND_CMD set means to look in the VAR_CMD
+				 * context also.
+				 * FIND_ENV set means to look in the
+				 * environment */
 {
     Boolean		localCheckEnvFirst;
@@ -297,6 +285,6 @@
      * the -E flag to use environment-variable-override for.
      */
-    if (Lst_Find (envFirstVars, (void *)name,
-		  (int (*)(void *, void *)) strcmp) != NULL)
+    if (Lst_Find (envFirstVars, (ClientData)name,
+		  (int (*)(ClientData, ClientData)) strcmp) != NILLNODE)
     {
 	localCheckEnvFirst = TRUE;
@@ -310,15 +298,15 @@
      * depending on the FIND_* flags in 'flags'
      */
-    var = Lst_Find (ctxt->context, (void *)name, VarCmp);
-
-    if ((var == NULL) && (flags & FIND_CMD) && (ctxt != VAR_CMD)) {
-	var = Lst_Find (VAR_CMD->context, (void *)name, VarCmp);
-    }
-    if ((var == NULL) && (flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL) &&
+    var = Lst_Find (ctxt->context, (ClientData)name, VarCmp);
+
+    if ((var == NILLNODE) && (flags & FIND_CMD) && (ctxt != VAR_CMD)) {
+	var = Lst_Find (VAR_CMD->context, (ClientData)name, VarCmp);
+    }
+    if ((var == NILLNODE) && (flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL) &&
 	!checkEnvFirst && !localCheckEnvFirst)
     {
-	var = Lst_Find (VAR_GLOBAL->context, (void *)name, VarCmp);
-    }
-    if ((var == NULL) && (flags & FIND_ENV)) {
+	var = Lst_Find (VAR_GLOBAL->context, (ClientData)name, VarCmp);
+    }
+    if ((var == NILLNODE) && (flags & FIND_ENV)) {
 	char *env;
 
@@ -339,15 +327,15 @@
 		   (flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL))
 	{
-	    var = Lst_Find (VAR_GLOBAL->context, (void *)name, VarCmp);
-	    if (var == NULL) {
-		return ((Var *) NULL);
+	    var = Lst_Find (VAR_GLOBAL->context, (ClientData)name, VarCmp);
+	    if (var == NILLNODE) {
+		return ((Var *) NIL);
 	    } else {
 		return ((Var *)Lst_Datum(var));
 	    }
 	} else {
-	    return((Var *)NULL);
+	    return((Var *)NIL);
 	}
-    } else if (var == NULL) {
-	return ((Var *) NULL);
+    } else if (var == NILLNODE) {
+	return ((Var *) NIL);
     } else {
 	return ((Var *) Lst_Datum (var));
@@ -358,5 +346,5 @@
  *-----------------------------------------------------------------------
  * VarAdd  --
- *	Add a new variable of name name and value val to the given context.
+ *	Add a new variable of name name and value val to the given context
  *
  * Results:
@@ -370,7 +358,10 @@
  */
 static void
-VarAdd (char *name, char *val, GNode *ctxt)
-{
-    Var		  *v;
+VarAdd (name, val, ctxt)
+    char           *name;	/* name of variable to add */
+    char           *val;	/* value to set it to */
+    GNode          *ctxt;	/* context in which to set it */
+{
+    register Var   *v;
     int	    	  len;
 
@@ -385,7 +376,9 @@
     v->flags = 0;
 
-    (void) Lst_AtFront (ctxt->context, (void *)v);
-    (void) Lst_AtEnd (allVars, (void *) v);
-    DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, name, val));
+    (void) Lst_AtFront (ctxt->context, (ClientData)v);
+    (void) Lst_AtEnd (allVars, (ClientData) v);
+    if (DEBUG(VAR)) {
+	printf("%s:%s = %s\n", ctxt->name, name, val);
+    }
 }
 
@@ -404,10 +397,11 @@
  */
 static void
-VarDelete(void *vp)
+VarDelete(vp)
+    ClientData vp;
 {
     Var *v = (Var *) vp;
     free(v->name);
     Buf_Destroy(v->val, TRUE);
-    free(v);
+    free((Address) v);
 }
 
@@ -428,12 +422,16 @@
  */
 void
-Var_Delete(char *name, GNode *ctxt)
+Var_Delete(name, ctxt)
+    char    	  *name;
+    GNode	  *ctxt;
 {
     LstNode 	  ln;
 
-    DEBUGF(VAR, ("%s:delete %s\n", ctxt->name, name));
-    ln = Lst_Find(ctxt->context, (void *)name, VarCmp);
-    if (ln != NULL) {
-	Var 	  *v;
+    if (DEBUG(VAR)) {
+	printf("%s:delete %s\n", ctxt->name, name);
+    }
+    ln = Lst_Find(ctxt->context, (ClientData)name, VarCmp);
+    if (ln != NILLNODE) {
+	register Var 	  *v;
 
 	v = (Var *)Lst_Datum(ln);
@@ -441,5 +439,5 @@
 	ln = Lst_Member(allVars, v);
 	Lst_Remove(allVars, ln);
-	VarDelete((void *) v);
+	VarDelete((ClientData) v);
     }
 }
@@ -467,7 +465,10 @@
  */
 void
-Var_Set (char *name, char *val, GNode *ctxt)
-{
-    Var		   *v;
+Var_Set (name, val, ctxt)
+    char           *name;	/* name of variable to set */
+    char           *val;	/* value to give to the variable */
+    GNode          *ctxt;	/* context in which to set it */
+{
+    register Var   *v;
 
     /*
@@ -476,7 +477,6 @@
      * point in searching them all just to save a bit of memory...
      */
-    VarPossiblyExpand(&name, ctxt);
     v = VarFind (name, ctxt, 0);
-    if (v == (Var *) NULL) {
+    if (v == (Var *) NIL) {
 	VarAdd (name, val, ctxt);
     } else {
@@ -484,5 +484,7 @@
 	Buf_AddBytes(v->val, strlen(val), (Byte *)val);
 
-	DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, name, val));
+	if (DEBUG(VAR)) {
+	    printf("%s:%s = %s\n", ctxt->name, name, val);
+	}
     }
     /*
@@ -493,5 +495,4 @@
 	setenv(name, val, 1);
     }
-    free(name);
 }
 
@@ -519,12 +520,14 @@
  */
 void
-Var_Append (char *name, char *val, GNode *ctxt)
-{
-    Var		   *v;
-
-    VarPossiblyExpand(&name, ctxt);
+Var_Append (name, val, ctxt)
+    char           *name;	/* Name of variable to modify */
+    char           *val;	/* String to append to it */
+    GNode          *ctxt;	/* Context in which this should occur */
+{
+    register Var   *v;
+
     v = VarFind (name, ctxt, (ctxt == VAR_GLOBAL) ? FIND_ENV : 0);
 
-    if (v == (Var *) NULL) {
+    if (v == (Var *) NIL) {
 	VarAdd (name, val, ctxt);
     } else {
@@ -532,6 +535,8 @@
 	Buf_AddBytes(v->val, strlen(val), (Byte *)val);
 
-	DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, name, 
-	       (char *) Buf_GetAll(v->val, (int *)NULL)));
+	if (DEBUG(VAR)) {
+	    printf("%s:%s = %s\n", ctxt->name, name,
+		   (char *) Buf_GetAll(v->val, (int *)NULL));
+	}
 
 	if (v->flags & VAR_FROM_ENV) {
@@ -543,8 +548,7 @@
 	     */
 	    v->flags &= ~VAR_FROM_ENV;
-	    Lst_AtFront(ctxt->context, (void *)v);
+	    Lst_AtFront(ctxt->context, (ClientData)v);
 	}
     }
-    free(name);
 }
 
@@ -563,13 +567,13 @@
  */
 Boolean
-Var_Exists(char *name, GNode *ctxt)
+Var_Exists(name, ctxt)
+    char	  *name;    	/* Variable to find */
+    GNode	  *ctxt;    	/* Context in which to start search */
 {
     Var	    	  *v;
 
-    VarPossiblyExpand(&name, ctxt);
     v = VarFind(name, ctxt, FIND_CMD|FIND_GLOBAL|FIND_ENV);
-    free(name);
-
-    if (v == (Var *)NULL) {
+
+    if (v == (Var *)NIL) {
 	return(FALSE);
     } else if (v->flags & VAR_FROM_ENV) {
@@ -594,17 +598,18 @@
  */
 char *
-Var_Value (char *name, GNode *ctxt, char **frp)
+Var_Value (name, ctxt, frp)
+    char           *name;	/* name to find */
+    GNode          *ctxt;	/* context in which to search for it */
+    char	   **frp;
 {
     Var            *v;
 
-    VarPossiblyExpand(&name, ctxt);
     v = VarFind (name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
-    free(name);
     *frp = NULL;
-    if (v != (Var *) NULL) {
+    if (v != (Var *) NIL) {
 	char *p = ((char *)Buf_GetAll(v->val, (int *)NULL));
 	if (v->flags & VAR_FROM_ENV) {
 	    Buf_Destroy(v->val, FALSE);
-	    free(v);
+	    free((Address) v);
 	    *frp = p;
 	}
@@ -631,7 +636,12 @@
  */
 static Boolean
-VarHead (char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
-{
-    char *slash;
+VarHead (word, addSpace, buf, dummy)
+    char    	  *word;    	/* Word to trim */
+    Boolean 	  addSpace; 	/* True if need to add a space to the buffer
+				 * before sticking in the head */
+    Buffer  	  buf;	    	/* Buffer in which to store it */
+    ClientData	  dummy;
+{
+    register char *slash;
 
     slash = strrchr (word, '/');
@@ -654,5 +664,5 @@
 	}
     }
-    return (TRUE);
+    return(dummy ? TRUE : TRUE);
 }
 
@@ -673,7 +683,12 @@
  */
 static Boolean
-VarTail (char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
-{
-    char *slash;
+VarTail (word, addSpace, buf, dummy)
+    char    	  *word;    	/* Word to trim */
+    Boolean 	  addSpace; 	/* TRUE if need to stick a space in the
+				 * buffer before adding the tail */
+    Buffer  	  buf;	    	/* Buffer in which to store it */
+    ClientData	  dummy;
+{
+    register char *slash;
 
     if (addSpace) {
@@ -689,5 +704,5 @@
 	Buf_AddBytes (buf, strlen(word), (Byte *)word);
     }
-    return (TRUE);
+    return (dummy ? TRUE : TRUE);
 }
 
@@ -707,7 +722,12 @@
  */
 static Boolean
-VarSuffix (char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
-{
-    char *dot;
+VarSuffix (word, addSpace, buf, dummy)
+    char    	  *word;    	/* Word to trim */
+    Boolean 	  addSpace; 	/* TRUE if need to add a space before placing
+				 * the suffix in the buffer */
+    Buffer  	  buf;	    	/* Buffer in which to store it */
+    ClientData	  dummy;
+{
+    register char *dot;
 
     dot = strrchr (word, '.');
@@ -721,5 +741,5 @@
 	addSpace = TRUE;
     }
-    return (addSpace);
+    return (dummy ? addSpace : addSpace);
 }
 
@@ -740,7 +760,12 @@
  */
 static Boolean
-VarRoot (char *word, Boolean addSpace, Buffer buf, void *dummy __unused)
-{
-    char *dot;
+VarRoot (word, addSpace, buf, dummy)
+    char    	  *word;    	/* Word to trim */
+    Boolean 	  addSpace; 	/* TRUE if need to add a space to the buffer
+				 * before placing the root in it */
+    Buffer  	  buf;	    	/* Buffer in which to store it */
+    ClientData	  dummy;
+{
+    register char *dot;
 
     if (addSpace) {
@@ -756,5 +781,5 @@
 	Buf_AddBytes (buf, strlen(word), (Byte *)word);
     }
-    return (TRUE);
+    return (dummy ? TRUE : TRUE);
 }
 
@@ -764,6 +789,4 @@
  *	Place the word in the buffer if it matches the given pattern.
  *	Callback function for VarModify to implement the :M modifier.
- *	A space will be added if requested.  A pattern is supplied
- *	which the word must match.
  *
  * Results:
@@ -777,5 +800,11 @@
  */
 static Boolean
-VarMatch (char *word, Boolean addSpace, Buffer buf, void *pattern)
+VarMatch (word, addSpace, buf, pattern)
+    char    	  *word;    	/* Word to examine */
+    Boolean 	  addSpace; 	/* TRUE if need to add a space to the
+				 * buffer before adding the word, if it
+				 * matches */
+    Buffer  	  buf;	    	/* Buffer in which to store it */
+    ClientData    pattern; 	/* Pattern the word must match */
 {
     if (Str_Match(word, (char *) pattern)) {
@@ -795,5 +824,5 @@
  *	Place the word in the buffer if it matches the given pattern.
  *	Callback function for VarModify to implement the System V %
- *	modifiers.  A space is added if requested.
+ *	modifiers.
  *
  * Results:
@@ -807,5 +836,11 @@
  */
 static Boolean
-VarSYSVMatch (char *word, Boolean addSpace, Buffer buf, void *patp)
+VarSYSVMatch (word, addSpace, buf, patp)
+    char    	  *word;    	/* Word to examine */
+    Boolean 	  addSpace; 	/* TRUE if need to add a space to the
+				 * buffer before adding the word, if it
+				 * matches */
+    Buffer  	  buf;	    	/* Buffer in which to store it */
+    ClientData 	  patp; 	/* Pattern the word must match */
 {
     int len;
@@ -832,6 +867,5 @@
  * VarNoMatch --
  *	Place the word in the buffer if it doesn't match the given pattern.
- *	Callback function for VarModify to implement the :N modifier.  A
- *	space is added if requested.
+ *	Callback function for VarModify to implement the :N modifier.
  *
  * Results:
@@ -845,5 +879,11 @@
  */
 static Boolean
-VarNoMatch (char *word, Boolean addSpace, Buffer buf, void *pattern)
+VarNoMatch (word, addSpace, buf, pattern)
+    char    	  *word;    	/* Word to examine */
+    Boolean 	  addSpace; 	/* TRUE if need to add a space to the
+				 * buffer before adding the word, if it
+				 * matches */
+    Buffer  	  buf;	    	/* Buffer in which to store it */
+    ClientData    pattern; 	/* Pattern the word must match */
 {
     if (!Str_Match(word, (char *) pattern)) {
@@ -862,5 +902,5 @@
  * VarSubstitute --
  *	Perform a string-substitution on the given word, placing the
- *	result in the passed buffer.  A space is added if requested.
+ *	result in the passed buffer.
  *
  * Results:
@@ -873,8 +913,13 @@
  */
 static Boolean
-VarSubstitute (char *word, Boolean addSpace, Buffer buf, void *patternp)
-{
-    int		  	wordLen;    /* Length of word */
-    char	 	*cp;	    /* General pointer */
+VarSubstitute (word, addSpace, buf, patternp)
+    char    	  	*word;	    /* Word to modify */
+    Boolean 	  	addSpace;   /* True if space should be added before
+				     * other characters */
+    Buffer  	  	buf;	    /* Buffer for result */
+    ClientData	        patternp;   /* Pattern for substitution */
+{
+    register int  	wordLen;    /* Length of word */
+    register char 	*cp;	    /* General pointer */
     VarPattern	*pattern = (VarPattern *) patternp;
 
@@ -971,5 +1016,5 @@
 	     * buffer.
 	     */
-	    Boolean done;
+	    register Boolean done;
 	    int origSize;
 
@@ -1035,5 +1080,8 @@
  */
 static void
-VarREError(int err, regex_t *pat, const char *str)
+VarREError(err, pat, str)
+    int err;
+    regex_t *pat;
+    const char *str;
 {
     char *errbuf;
@@ -1052,5 +1100,5 @@
  * VarRESubstitute --
  *	Perform a regex substitution on the given word, placing the
- *	result in the passed buffer.  A space is added if requested.
+ *	result in the passed buffer.
  *
  * Results:
@@ -1063,5 +1111,9 @@
  */
 static Boolean
-VarRESubstitute(char *word, Boolean addSpace, Buffer buf, void *patternp)
+VarRESubstitute(word, addSpace, buf, patternp)
+    char *word;
+    Boolean addSpace;
+    Buffer buf;
+    ClientData patternp;
 {
     VarREPattern *pat;
@@ -1072,5 +1124,5 @@
     int flags = 0;
 
-#define	MAYBE_ADD_SPACE()		\
+#define MAYBE_ADD_SPACE()		\
 	if (addSpace && !added)		\
 	    Buf_AddByte(buf, ' ');	\
@@ -1191,6 +1243,9 @@
  */
 static char *
-VarModify (char *str, Boolean (*modProc)(char *, Boolean, Buffer, void *),
-    void *datum)
+VarModify (str, modProc, datum)
+    char    	  *str;	    	    /* String whose words should be trimmed */
+				    /* Function to use to modify them */
+    Boolean    	  (*modProc) __P((char *, Boolean, Buffer, ClientData));
+    ClientData	  datum;    	    /* Datum to pass it */
 {
     Buffer  	  buf;	    	    /* Buffer for the new string */
@@ -1238,6 +1293,12 @@
  */
 static char *
-VarGetPattern(GNode *ctxt, int err, char **tstr, int delim, int *flags,
-    int *length, VarPattern *pattern)
+VarGetPattern(ctxt, err, tstr, delim, flags, length, pattern)
+    GNode *ctxt;
+    int err;
+    char **tstr;
+    int delim;
+    int *flags;
+    int *length;
+    VarPattern *pattern;
 {
     char *cp;
@@ -1247,5 +1308,5 @@
 	length = &junk;
 
-#define	IS_A_MATCH(cp, delim) \
+#define IS_A_MATCH(cp, delim) \
     ((cp[0] == '\\') && ((cp[1] == delim) ||  \
      (cp[1] == '\\') || (cp[1] == '$') || (pattern && (cp[1] == '&'))))
@@ -1352,5 +1413,6 @@
  */
 static char *
-VarQuote(char *str)
+VarQuote(str)
+	char *str;
 {
 
@@ -1392,14 +1454,19 @@
  */
 char *
-Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
-{
-    char	    *tstr;    	/* Pointer into str */
+Var_Parse (str, ctxt, err, lengthPtr, freePtr)
+    char    	  *str;	    	/* The string to parse */
+    GNode   	  *ctxt;    	/* The context for the variable */
+    Boolean 	    err;    	/* TRUE if undefined variables are an error */
+    int	    	    *lengthPtr;	/* OUT: The length of the specification */
+    Boolean 	    *freePtr; 	/* OUT: TRUE if caller should free result */
+{
+    register char   *tstr;    	/* Pointer into str */
     Var	    	    *v;	    	/* Variable in invocation */
     char	    *cp;    	/* Secondary pointer into str (place marker
 				 * for tstr) */
     Boolean 	    haveModifier;/* TRUE if have modifiers for the variable */
-    char	    endc;    	/* Ending character when variable in parens
+    register char   endc;    	/* Ending character when variable in parens
 				 * or braces */
-    char	    startc=0;	/* Starting character when variable in parens
+    register char   startc=0;	/* Starting character when variable in parens
 				 * or braces */
     int             cnt;	/* Used to count brace pairs when variable in
@@ -1430,5 +1497,5 @@
 
 	v = VarFind (name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
-	if (v == (Var *)NULL) {
+	if (v == (Var *)NIL) {
 	    *lengthPtr = 2;
 
@@ -1453,6 +1520,4 @@
 		    case '!':
 			return("$(.MEMBER)");
-		    default:
-			break;
 		}
 	    }
@@ -1512,5 +1577,5 @@
 
 	v = VarFind (str, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
-	if ((v == (Var *)NULL) && (ctxt != VAR_CMD) && (ctxt != VAR_GLOBAL) &&
+	if ((v == (Var *)NIL) && (ctxt != VAR_CMD) && (ctxt != VAR_GLOBAL) &&
 	    (vlen == 2) && (str[1] == 'F' || str[1] == 'D'))
 	{
@@ -1537,5 +1602,5 @@
 		    v = VarFind(vname, ctxt, 0);
 
-		    if (v != (Var *)NULL && !haveModifier) {
+		    if (v != (Var *)NIL && !haveModifier) {
 			/*
 			 * No need for nested expansion or anything, as we're
@@ -1546,7 +1611,7 @@
 
 			if (str[1] == 'D') {
-			    val = VarModify(val, VarHead, (void *)0);
+			    val = VarModify(val, VarHead, (ClientData)0);
 			} else {
-			    val = VarModify(val, VarTail, (void *)0);
+			    val = VarModify(val, VarTail, (ClientData)0);
 			}
 			/*
@@ -1561,11 +1626,9 @@
 		    }
 		    break;
-		default:
-		    break;
 		}
 	    }
 	}
 
-	if (v == (Var *)NULL) {
+	if (v == (Var *)NIL) {
 	    if (((vlen == 1) ||
 		 (((vlen == 2) && (str[1] == 'F' ||
@@ -1588,6 +1651,4 @@
 		    case '!':
 			dynamic = TRUE;
-			break;
-		    default:
 			break;
 		}
@@ -1693,5 +1754,7 @@
 	    char	termc;	    /* Character which terminated scan */
 
-	    DEBUGF(VAR, ("Applying :%c to \"%s\"\n", *tstr, str));
+	    if (DEBUG(VAR)) {
+		printf("Applying :%c to \"%s\"\n", *tstr, str);
+	    }
 	    switch (*tstr) {
 	        case 'U':
@@ -1770,8 +1833,8 @@
 		    }
 		    if (*tstr == 'M' || *tstr == 'm') {
-			newStr = VarModify(str, VarMatch, (void *)pattern);
+			newStr = VarModify(str, VarMatch, (ClientData)pattern);
 		    } else {
 			newStr = VarModify(str, VarNoMatch,
-					   (void *)pattern);
+					   (ClientData)pattern);
 		    }
 		    if (copy) {
@@ -1783,9 +1846,9 @@
 		{
 		    VarPattern 	    pattern;
-		    char	    del;
+		    register char   delim;
 		    Buffer  	    buf;    	/* Buffer for patterns */
 
 		    pattern.flags = 0;
-		    del = tstr[1];
+		    delim = tstr[1];
 		    tstr += 2;
 
@@ -1808,7 +1871,7 @@
 		     * The result is left in the Buffer buf.
 		     */
-		    for (cp = tstr; *cp != '\0' && *cp != del; cp++) {
+		    for (cp = tstr; *cp != '\0' && *cp != delim; cp++) {
 			if ((*cp == '\\') &&
-			    ((cp[1] == del) ||
+			    ((cp[1] == delim) ||
 			     (cp[1] == '$') ||
 			     (cp[1] == '\\')))
@@ -1817,5 +1880,5 @@
 			    cp++;
 			} else if (*cp == '$') {
-			    if (cp[1] != del) {
+			    if (cp[1] != delim) {
 				/*
 				 * If unescaped dollar sign not before the
@@ -1851,5 +1914,5 @@
 		     * return NULL
 		     */
-		    if (*cp != del) {
+		    if (*cp != delim) {
 			*lengthPtr = cp - start + 1;
 			if (*freePtr) {
@@ -1858,5 +1921,5 @@
 			Buf_Destroy(buf, TRUE);
 			Error("Unclosed substitution for %s (%c missing)",
-			      v->name, del);
+			      v->name, delim);
 			return (var_Error);
 		    }
@@ -1883,7 +1946,7 @@
 
 		    tstr = cp + 1;
-		    for (cp = tstr; *cp != '\0' && *cp != del; cp++) {
+		    for (cp = tstr; *cp != '\0' && *cp != delim; cp++) {
 			if ((*cp == '\\') &&
-			    ((cp[1] == del) ||
+			    ((cp[1] == delim) ||
 			     (cp[1] == '&') ||
 			     (cp[1] == '\\') ||
@@ -1892,5 +1955,5 @@
 			    Buf_AddByte(buf, (Byte)cp[1]);
 			    cp++;
-			} else if ((*cp == '$') && (cp[1] != del)) {
+			} else if ((*cp == '$') && (cp[1] != delim)) {
 			    char    *cp2;
 			    int	    len;
@@ -1916,5 +1979,5 @@
 		     * If didn't end in delimiter character, complain
 		     */
-		    if (*cp != del) {
+		    if (*cp != delim) {
 			*lengthPtr = cp - start + 1;
 			if (*freePtr) {
@@ -1923,5 +1986,5 @@
 			Buf_Destroy(buf, TRUE);
 			Error("Unclosed substitution for %s (%c missing)",
-			      v->name, del);
+			      v->name, delim);
 			return (var_Error);
 		    }
@@ -1944,5 +2007,5 @@
 		    termc = *cp;
 		    newStr = VarModify(str, VarSubstitute,
-				       (void *)&pattern);
+				       (ClientData)&pattern);
 		    /*
 		     * Free the two strings.
@@ -1998,6 +2061,4 @@
 			    pattern.flags |= VAR_SUB_ONE;
 			    continue;
-			default:
-			    break;
 			}
 			break;
@@ -2023,5 +2084,5 @@
 					      sizeof(regmatch_t));
 		    newStr = VarModify(str, VarRESubstitute,
-				       (void *) &pattern);
+				       (ClientData) &pattern);
 		    regfree(&pattern.re);
 		    free(pattern.replace);
@@ -2039,5 +2100,5 @@
 		case 'T':
 		    if (tstr[1] == endc || tstr[1] == ':') {
-			newStr = VarModify (str, VarTail, (void *)0);
+			newStr = VarModify (str, VarTail, (ClientData)0);
 			cp = tstr + 1;
 			termc = *cp;
@@ -2047,5 +2108,5 @@
 		case 'H':
 		    if (tstr[1] == endc || tstr[1] == ':') {
-			newStr = VarModify (str, VarHead, (void *)0);
+			newStr = VarModify (str, VarHead, (ClientData)0);
 			cp = tstr + 1;
 			termc = *cp;
@@ -2055,5 +2116,5 @@
 		case 'E':
 		    if (tstr[1] == endc || tstr[1] == ':') {
-			newStr = VarModify (str, VarSuffix, (void *)0);
+			newStr = VarModify (str, VarSuffix, (ClientData)0);
 			cp = tstr + 1;
 			termc = *cp;
@@ -2063,5 +2124,5 @@
 		case 'R':
 		    if (tstr[1] == endc || tstr[1] == ':') {
-			newStr = VarModify (str, VarRoot, (void *)0);
+			newStr = VarModify (str, VarRoot, (ClientData)0);
 			cp = tstr + 1;
 			termc = *cp;
@@ -2072,8 +2133,8 @@
 		case 's':
 		    if (tstr[1] == 'h' && (tstr[2] == endc || tstr[2] == ':')) {
-			char *error;
-			newStr = Cmd_Exec (str, &error);
-			if (error)
-			    Error (error, str);
+			char *err;
+			newStr = Cmd_Exec (str, &err);
+			if (err)
+			    Error (err, str);
 			cp = tstr + 2;
 			termc = *cp;
@@ -2143,5 +2204,5 @@
 			 */
 			newStr = VarModify(str, VarSYSVMatch,
-					   (void *)&pattern);
+					   (ClientData)&pattern);
 
 			/*
@@ -2164,5 +2225,7 @@
 		}
 	    }
-	    DEBUGF(VAR, ("Result is \"%s\"\n", newStr));
+	    if (DEBUG(VAR)) {
+		printf("Result is \"%s\"\n", newStr);
+	    }
 
 	    if (*freePtr) {
@@ -2203,5 +2266,5 @@
 	}
 	Buf_Destroy(v->val, destroy);
-	free(v);
+	free((Address)v);
     } else if (v->flags & VAR_JUNK) {
 	/*
@@ -2214,5 +2277,5 @@
 	*freePtr = FALSE;
 	Buf_Destroy(v->val, TRUE);
-	free(v);
+	free((Address)v);
 	if (dynamic) {
 	    str = emalloc(*lengthPtr + 1);
@@ -2242,5 +2305,9 @@
  */
 char *
-Var_Subst (char *var, char *str, GNode *ctxt, Boolean undefErr)
+Var_Subst (var, str, ctxt, undefErr)
+    char	  *var;		    /* Named variable || NULL for all */
+    char 	  *str;	    	    /* the string in which to substitute */
+    GNode         *ctxt;	    /* the context wherein to find variables */
+    Boolean 	  undefErr; 	    /* TRUE if undefineds are an error */
 {
     Buffer  	  buf;	    	    /* Buffer for forming things */
@@ -2377,5 +2444,5 @@
 		Buf_AddBytes (buf, strlen (val), (Byte *)val);
 		if (doFree) {
-		    free (val);
+		    free ((Address)val);
 		}
 	    }
@@ -2404,7 +2471,8 @@
  */
 char *
-Var_GetTail(char *file)
-{
-    return(VarModify(file, VarTail, (void *)0));
+Var_GetTail(file)
+    char    	*file;	    /* Filename to modify */
+{
+    return(VarModify(file, VarTail, (ClientData)0));
 }
 
@@ -2425,7 +2493,8 @@
  */
 char *
-Var_GetHead(char *file)
-{
-    return(VarModify(file, VarHead, (void *)0));
+Var_GetHead(file)
+    char    	*file;	    /* Filename to manipulate */
+{
+    return(VarModify(file, VarHead, (ClientData)0));
 }
 
@@ -2443,5 +2512,5 @@
  */
 void
-Var_Init (void)
+Var_Init ()
 {
     VAR_GLOBAL = Targ_NewGN ("Global");
@@ -2453,5 +2522,5 @@
 
 void
-Var_End (void)
+Var_End ()
 {
     Lst_Destroy(allVars, VarDelete);
@@ -2461,9 +2530,11 @@
 /****************** PRINT DEBUGGING INFO *****************/
 static int
-VarPrintVar (void *vp, void *dummy __unused)
+VarPrintVar (vp, dummy)
+    ClientData vp;
+    ClientData dummy;
 {
     Var    *v = (Var *) vp;
     printf ("%-16s = %s\n", v->name, (char *) Buf_GetAll(v->val, (int *)NULL));
-    return (0);
+    return (dummy ? 0 : 0);
 }
 
@@ -2475,6 +2546,7 @@
  */
 void
-Var_Dump (GNode *ctxt)
-{
-    Lst_ForEach (ctxt->context, VarPrintVar, (void *) 0);
-}
+Var_Dump (ctxt)
+    GNode          *ctxt;
+{
+    Lst_ForEach (ctxt->context, VarPrintVar, (ClientData) 0);
+}
