Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Jan 2026 21:33:59 +0000
From:      Simon J. Gerraty <sjg@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 1166b90143da - stable/14 - Merge bmake-20240430
Message-ID:  <6962c5c7.24f4f.6de1ddb2@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/14 has been updated by sjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=1166b90143dafc2e7f19140cd2492be74ed94348

commit 1166b90143dafc2e7f19140cd2492be74ed94348
Author:     Simon J. Gerraty <sjg@FreeBSD.org>
AuthorDate: 2024-05-03 22:45:05 +0000
Commit:     Simon J. Gerraty <sjg@FreeBSD.org>
CommitDate: 2026-01-10 21:33:11 +0000

    Merge bmake-20240430
    
    Merge commit '507951f55039f9d1ceae507d510f8cb68225fbc5'
    
    (cherry picked from commit 548bfc56eb0b2cefa0fb8dc2478240bfef610309)
---
 contrib/bmake/ChangeLog                            |   75 +-
 contrib/bmake/Makefile                             |    6 +-
 contrib/bmake/Makefile.config.in                   |    1 +
 contrib/bmake/VERSION                              |    2 +-
 contrib/bmake/arch.c                               |  250 +-
 contrib/bmake/bmake.cat1                           | 2585 +++++++++++++-------
 contrib/bmake/buf.c                                |   31 +-
 contrib/bmake/buf.h                                |    3 +-
 contrib/bmake/compat.c                             |    6 +-
 contrib/bmake/cond.c                               |   19 +-
 contrib/bmake/configure                            |   40 +-
 contrib/bmake/configure.in                         |   25 +-
 contrib/bmake/for.c                                |   15 +-
 contrib/bmake/job.c                                |   11 +-
 contrib/bmake/lst.c                                |    8 +-
 contrib/bmake/lst.h                                |   11 +-
 contrib/bmake/main.c                               |   18 +-
 contrib/bmake/make-bootstrap.sh.in                 |    1 +
 contrib/bmake/make.h                               |   22 +-
 contrib/bmake/meta.c                               |    4 +-
 contrib/bmake/mk/ChangeLog                         |   36 +
 contrib/bmake/mk/FILES                             |    1 +
 contrib/bmake/mk/init.mk                           |    4 +-
 contrib/bmake/mk/install-mk                        |    6 +-
 contrib/bmake/mk/meta.autodep.mk                   |    4 +-
 contrib/bmake/mk/meta.subdir.mk                    |    3 +-
 contrib/bmake/mk/own.mk                            |    5 +-
 contrib/bmake/mk/progs.mk                          |   22 +-
 contrib/bmake/mk/subdir.mk                         |    6 +-
 contrib/bmake/mk/sys.dirdeps.mk                    |   15 +-
 contrib/bmake/mk/sys/Cygwin.mk                     |   21 +
 contrib/bmake/os.sh                                |    6 +-
 contrib/bmake/parse.c                              |   26 +-
 contrib/bmake/str.c                                |   30 +-
 contrib/bmake/targ.c                               |   17 +-
 contrib/bmake/unit-tests/Makefile                  |   27 +-
 contrib/bmake/unit-tests/archive.exp               |    8 +
 contrib/bmake/unit-tests/archive.mk                |   33 +-
 contrib/bmake/unit-tests/cmd-errors-jobs.exp       |    6 +-
 contrib/bmake/unit-tests/cmd-errors-jobs.mk        |   31 +-
 contrib/bmake/unit-tests/cmd-errors-lint.exp       |    6 +-
 contrib/bmake/unit-tests/cmd-errors-lint.mk        |   11 +-
 contrib/bmake/unit-tests/cmd-errors.exp            |    6 +-
 contrib/bmake/unit-tests/cmd-errors.mk             |   11 +-
 contrib/bmake/unit-tests/cmdline-undefined.mk      |    4 +-
 contrib/bmake/unit-tests/cmdline.mk                |    4 +-
 contrib/bmake/unit-tests/comment.mk                |    8 +-
 contrib/bmake/unit-tests/cond-cmp-string.mk        |   20 +-
 contrib/bmake/unit-tests/cond-func-defined.exp     |    3 -
 contrib/bmake/unit-tests/cond-func-defined.mk      |   11 +-
 contrib/bmake/unit-tests/cond-token-string.exp     |    2 +-
 contrib/bmake/unit-tests/cond-token-string.mk      |    4 +-
 contrib/bmake/unit-tests/depsrc-end.mk             |    4 +-
 contrib/bmake/unit-tests/depsrc-nopath.exp         |    2 +
 contrib/bmake/unit-tests/depsrc-nopath.mk          |   25 +-
 contrib/bmake/unit-tests/depsrc-phony.mk           |    3 +-
 contrib/bmake/unit-tests/deptgt-phony.exp          |    2 +-
 contrib/bmake/unit-tests/deptgt.exp                |    2 +-
 contrib/bmake/unit-tests/deptgt.mk                 |    4 +-
 contrib/bmake/unit-tests/directive-export-impl.exp |    2 +
 contrib/bmake/unit-tests/directive-for-errors.exp  |    2 +-
 contrib/bmake/unit-tests/directive-for-errors.mk   |    4 +-
 contrib/bmake/unit-tests/directive-for-escape.exp  |    1 +
 contrib/bmake/unit-tests/directive-for-null.exp    |    6 +-
 contrib/bmake/unit-tests/directive-for-null.mk     |   14 +-
 contrib/bmake/unit-tests/directive-for.exp         |    2 +-
 contrib/bmake/unit-tests/directive-for.mk          |    4 +-
 contrib/bmake/unit-tests/directive-include.exp     |    2 +-
 contrib/bmake/unit-tests/directive-include.mk      |    4 +-
 contrib/bmake/unit-tests/directive-undef.exp       |    2 +-
 contrib/bmake/unit-tests/directive-undef.mk        |    4 +-
 contrib/bmake/unit-tests/lint.exp                  |    2 +-
 contrib/bmake/unit-tests/moderrs.exp               |   12 +-
 contrib/bmake/unit-tests/opt-chdir.exp             |    2 -
 contrib/bmake/unit-tests/opt-chdir.mk              |    8 +-
 contrib/bmake/unit-tests/opt-debug-errors-jobs.exp |    6 +
 contrib/bmake/unit-tests/opt-debug-lint.exp        |    6 +-
 contrib/bmake/unit-tests/opt-debug-lint.mk         |    8 +-
 contrib/bmake/unit-tests/opt-debug-parse.exp       |    2 +
 contrib/bmake/unit-tests/opt-file.exp              |    4 +-
 contrib/bmake/unit-tests/opt-file.mk               |   12 +-
 .../bmake/unit-tests/opt-keep-going-indirect.mk    |   10 +-
 contrib/bmake/unit-tests/opt-m-include-dir.mk      |    8 +-
 contrib/bmake/unit-tests/var-eval-short.exp        |    4 +-
 contrib/bmake/unit-tests/var-eval-short.mk         |    4 +-
 contrib/bmake/unit-tests/var-op-expand.exp         |    4 +-
 contrib/bmake/unit-tests/var-op-expand.mk          |    6 +-
 contrib/bmake/unit-tests/vardebug.exp              |    2 +-
 contrib/bmake/unit-tests/vardebug.mk               |    4 +-
 contrib/bmake/unit-tests/varmisc.exp               |   20 +-
 contrib/bmake/unit-tests/varmod-assign.exp         |    2 +-
 contrib/bmake/unit-tests/varmod-assign.mk          |    4 +-
 contrib/bmake/unit-tests/varmod-edge.exp           |    6 +-
 contrib/bmake/unit-tests/varmod-edge.mk            |    8 +-
 contrib/bmake/unit-tests/varmod-gmtime.exp         |   10 +-
 contrib/bmake/unit-tests/varmod-gmtime.mk          |   12 +-
 contrib/bmake/unit-tests/varmod-hash.exp           |    6 +-
 contrib/bmake/unit-tests/varmod-ifelse.exp         |    2 +-
 contrib/bmake/unit-tests/varmod-ifelse.mk          |    6 +-
 contrib/bmake/unit-tests/varmod-indirect.exp       |    8 +-
 contrib/bmake/unit-tests/varmod-indirect.mk        |   10 +-
 contrib/bmake/unit-tests/varmod-localtime.exp      |   10 +-
 contrib/bmake/unit-tests/varmod-localtime.mk       |   12 +-
 contrib/bmake/unit-tests/varmod-loop-delete.exp    |    2 +-
 contrib/bmake/unit-tests/varmod-loop-delete.mk     |    4 +-
 contrib/bmake/unit-tests/varmod-loop-varname.exp   |    8 +-
 contrib/bmake/unit-tests/varmod-loop-varname.mk    |   10 +-
 contrib/bmake/unit-tests/varmod-loop.exp           |    2 +
 contrib/bmake/unit-tests/varmod-match-escape.exp   |    6 +-
 contrib/bmake/unit-tests/varmod-match-escape.mk    |    8 +-
 contrib/bmake/unit-tests/varmod-match.exp          |   22 +-
 contrib/bmake/unit-tests/varmod-match.mk           |   54 +-
 contrib/bmake/unit-tests/varmod-mtime.exp          |   12 +-
 contrib/bmake/unit-tests/varmod-mtime.mk           |   14 +-
 contrib/bmake/unit-tests/varmod-range.exp          |   10 +-
 contrib/bmake/unit-tests/varmod-range.mk           |   12 +-
 contrib/bmake/unit-tests/varmod-subst-regex.exp    |    2 +-
 contrib/bmake/unit-tests/varmod-subst.exp          |    2 +-
 contrib/bmake/unit-tests/varmod-to-separator.exp   |    6 +-
 contrib/bmake/unit-tests/varmod-to-separator.mk    |    8 +-
 contrib/bmake/unit-tests/varmod.exp                |    4 +-
 contrib/bmake/unit-tests/varmod.mk                 |    6 +-
 contrib/bmake/unit-tests/varname-dot-shell.exp     |    3 +
 contrib/bmake/unit-tests/varparse-errors.exp       |    4 +-
 contrib/bmake/unit-tests/varparse-errors.mk        |    6 +-
 contrib/bmake/var.c                                |  159 +-
 usr.bin/bmake/Makefile                             |    4 +-
 usr.bin/bmake/Makefile.config                      |    3 +-
 usr.bin/bmake/config.h                             |    4 +-
 usr.bin/bmake/unit-tests/Makefile                  |   27 +-
 130 files changed, 2625 insertions(+), 1616 deletions(-)

diff --git a/contrib/bmake/ChangeLog b/contrib/bmake/ChangeLog
index fc1da62fbe54..a2dd8dd5ed14 100644
--- a/contrib/bmake/ChangeLog
+++ b/contrib/bmake/ChangeLog
@@ -1,3 +1,74 @@
+2024-04-30  Simon J Gerraty  <sjg@beast.crufty.net>
+
+	* VERSION (_MAKE_VERSION): 20240430
+	Merge with NetBSD make, pick up
+	o main.c: ensure '.include <makefile>' respects MAKESYSPATH.
+	Dir_FindFile will search .CURDIR first unless ".DOTLAST" is seen.
+
+2024-04-28  Simon J Gerraty  <sjg@beast.crufty.net>
+
+	* VERSION (_MAKE_VERSION): 20240428
+	Merge with NetBSD make, pick up
+	o simplify freeing of lists
+	o arch.c: trim pointless comments
+	o var.c: delay variable assignments until actually needed
+	don't reallocate memory after evaluating an expression, result is
+	almost always short-lived.
+
+2024-04-26  Simon J Gerraty  <sjg@beast.crufty.net>
+
+	* VERSION (_MAKE_VERSION): 20240426
+	Merge with NetBSD make, pick up
+	o job.c: in debug output, print the directory in which a job
+	failed at same time as failed target so it is more easily found in
+	build log.
+
+2024-04-24  Simon J Gerraty  <sjg@beast.crufty.net>
+
+	* VERSION (_MAKE_VERSION): 20240424
+	Merge with NetBSD make, pick up
+	o clean up comments, code and tests
+
+2024-04-23  Simon J Gerraty  <sjg@beast.crufty.net>
+
+	* VERSION (_MAKE_VERSION): 20240422
+	Merge with NetBSD make, pick up
+	o var.c: avoid LazyBuf for :*time modifiers.
+	LazyBuf's are not nul terminated so not suitable for passing to
+	functions that expect that. These modifiers are used sparingly so
+	an extra allocation is not a problem.
+
+2024-04-20  Simon J Gerraty  <sjg@beast.crufty.net>
+
+	* VERSION (_MAKE_VERSION): 20240420
+	Merge with NetBSD make, pick up
+	o provide more context information for parse/evaluate errors
+
+2024-04-14  Simon J Gerraty  <sjg@beast.crufty.net>
+
+	* VERSION (_MAKE_VERSION): 20240414
+	Merge with NetBSD make, pick up
+	o parse.c: print -dp debug info earlier so we see which
+	.if or .for line is being parsed.
+
+2024-04-04  Simon J Gerraty  <sjg@beast.crufty.net>
+
+	* VERSION (_MAKE_VERSION): 20240404
+	Merge with NetBSD make, pick up
+	o fix some unit tests for Cygwin
+	o parse.c: exit immediately after reading a null byte from a makefile
+
+	* fix generation of bmake.cat1
+
+2024-03-19  Simon J Gerraty  <sjg@beast.crufty.net>
+
+	* VERSION (_MAKE_VERSION): 20240314
+	Add/Improve support for Cygwin
+	o uname -s output isn't useful so allow configure to
+	set FORCE_MAKE_OS - to force the value of .MAKE.OS
+	and use Cygwin which matches uname -o
+	o fix some unit-tests for Cygwin
+
 2024-03-10  Simon J Gerraty  <sjg@beast.crufty.net>
 
 	* boot-strap: tests can take a long time; use a cookie to
@@ -2175,10 +2246,10 @@
 
 	* VERSION (_MAKE_VERSION): 20200418
 
-	* configure.in: use_makefile=no for cygwin et al.
+	* configure.in: use_makefile=no for Cygwin et al.
 	case insensitive filesystems just don't work if both
 	makefile and Makefile exist.
-	NOTE: bmake does not support cygwin and likely never will,
+	NOTE: bmake does not support Cygwin and likely never will,
 	but if brave souls want to try it - help them out.
 
 2020-04-02  Simon J Gerraty  <sjg@beast.crufty.net>
diff --git a/contrib/bmake/Makefile b/contrib/bmake/Makefile
index 3332dcdeaf2d..65730df7e3df 100644
--- a/contrib/bmake/Makefile
+++ b/contrib/bmake/Makefile
@@ -1,4 +1,4 @@
-#	$Id: Makefile,v 1.126 2024/03/10 17:46:44 sjg Exp $
+#	$Id: Makefile,v 1.127 2024/03/19 16:03:23 sjg Exp $
 
 PROG=	bmake
 
@@ -48,7 +48,7 @@ CFLAGS+= -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE
 CFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}}
 COPTS.main.c+= "-DMAKE_VERSION=\"${_MAKE_VERSION}\""
 
-.for x in FORCE_MACHINE FORCE_MACHINE_ARCH
+.for x in FORCE_MAKE_OS FORCE_MACHINE FORCE_MACHINE_ARCH
 .ifdef $x
 COPTS.main.c+= "-D$x=\"${$x}\""
 .endif
@@ -90,7 +90,7 @@ OS := ${.MAKE.OS:U${uname -s:L:sh}}
 # are we 4.4BSD ?
 isBSD44:=${BSD44_LIST:M${OS}}
 
-.if ${isBSD44} == "" && ${OS:NCYGWIN*:NDarwin:NLinux} != ""
+.if ${isBSD44} == "" && ${OS:NCygwin:NDarwin:NLinux} != ""
 MANTARGET?= cat
 .if ${MACHINE} == "sun386"
 # even I don't have one of these anymore :-)
diff --git a/contrib/bmake/Makefile.config.in b/contrib/bmake/Makefile.config.in
index dfc26d90a02a..43ad1b9a397a 100644
--- a/contrib/bmake/Makefile.config.in
+++ b/contrib/bmake/Makefile.config.in
@@ -5,6 +5,7 @@ _MAKE_VERSION?=@_MAKE_VERSION@
 prefix?= @prefix@
 srcdir= @srcdir@
 CC= @CC@
+@force_make_os@MAKE_OS?= @make_os@
 @force_machine@MACHINE?= @machine@
 @force_machine_arch@MACHINE_ARCH?= @machine_arch@
 DEFAULT_SYS_PATH?= @default_sys_path@
diff --git a/contrib/bmake/VERSION b/contrib/bmake/VERSION
index 5d6ca326700a..49a67b80073a 100644
--- a/contrib/bmake/VERSION
+++ b/contrib/bmake/VERSION
@@ -1,2 +1,2 @@
 # keep this compatible with sh and make
-_MAKE_VERSION=20240309
+_MAKE_VERSION=20240430
diff --git a/contrib/bmake/arch.c b/contrib/bmake/arch.c
index caec2e148690..4e52532c780a 100644
--- a/contrib/bmake/arch.c
+++ b/contrib/bmake/arch.c
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.215 2024/02/07 06:43:02 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.217 2024/04/27 20:41:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -147,7 +147,7 @@ struct ar_hdr {
 #include "dir.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.215 2024/02/07 06:43:02 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.217 2024/04/27 20:41:32 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -155,7 +155,7 @@ typedef struct ListNode ArchListNode;
 static ArchList archives;	/* The archives we've already examined */
 
 typedef struct Arch {
-	char *name;		/* Name of archive */
+	char *name;
 	HashTable members;	/* All the members of the archive described
 				 * by <name, struct ar_hdr *> key/value pairs */
 	char *fnametab;		/* Extended name table strings */
@@ -199,12 +199,10 @@ static int ArchSVR4Entry(Arch *, char *, size_t, FILE *);
 
 #ifdef CLEANUP
 static void
-ArchFree(void *ap)
+ArchFree(Arch *a)
 {
-	Arch *a = ap;
 	HashIter hi;
 
-	/* Free memory from hash entries */
 	HashIter_Init(&hi, &a->members);
 	while (HashIter_Next(&hi) != NULL)
 		free(hi.entry->value);
@@ -217,32 +215,22 @@ ArchFree(void *ap)
 #endif
 
 /* Return "archive(member)". */
-static char *
+MAKE_ATTR_NOINLINE static char *
 FullName(const char *archive, const char *member)
 {
-	size_t len1 = strlen(archive);
-	size_t len3 = strlen(member);
-	char *result = bmake_malloc(len1 + 1 + len3 + 1 + 1);
-	memcpy(result, archive, len1);
-	memcpy(result + len1, "(", 1);
-	memcpy(result + len1 + 1, member, len3);
-	memcpy(result + len1 + 1 + len3, ")", 1 + 1);
-	return result;
+	Buffer buf;
+	Buf_Init(&buf);
+	Buf_AddStr(&buf, archive);
+	Buf_AddStr(&buf, "(");
+	Buf_AddStr(&buf, member);
+	Buf_AddStr(&buf, ")");
+	return Buf_DoneData(&buf);
 }
 
 /*
  * Parse an archive specification such as "archive.a(member1 member2.${EXT})",
- * adding nodes for the expanded members to gns.  Nodes are created as
- * necessary.
- *
- * Input:
- *	pp		The start of the specification.
- *	gns		The list on which to place the nodes.
- *	scope		The scope in which to expand variables.
- *
- * Output:
- *	return		True if it was a valid specification.
- *	*pp		Points to the first non-space after the archive spec.
+ * adding nodes for the expanded members to gns.  If successful, advance pp
+ * beyond the archive specification and any trailing whitespace.
  */
 bool
 Arch_ParseArchive(char **pp, GNodeList *gns, GNode *scope)
@@ -323,12 +311,6 @@ Arch_ParseArchive(char **pp, GNodeList *gns, GNode *scope)
 			}
 		}
 
-		/*
-		 * If the specification ends without a closing parenthesis,
-		 * chances are there's something wrong (like a missing
-		 * backslash), so it's better to return failure than allow
-		 * such things to happen
-		 */
 		if (*cp == '\0') {
 			Parse_Error(PARSE_FATAL,
 			    "No closing parenthesis "
@@ -336,9 +318,6 @@ Arch_ParseArchive(char **pp, GNodeList *gns, GNode *scope)
 			return false;
 		}
 
-		/*
-		 * If we didn't move anywhere, we must be done
-		 */
 		if (cp == mem.str)
 			break;
 
@@ -375,8 +354,7 @@ Arch_ParseArchive(char **pp, GNodeList *gns, GNode *scope)
 				/*
 				 * Must contain dynamic sources, so we can't
 				 * deal with it now. Just create an ARCHV node
-				 * for the thing and let SuffExpandChildren
-				 * handle it.
+				 * and let SuffExpandChildren handle it.
 				 */
 				gn = Targ_GetNode(fullName);
 				gn->type |= OP_ARCHV;
@@ -413,13 +391,6 @@ Arch_ParseArchive(char **pp, GNodeList *gns, GNode *scope)
 			gn = Targ_GetNode(fullname);
 			free(fullname);
 
-			/*
-			 * We've found the node, but have to make sure the
-			 * rest of the world knows it's an archive member,
-			 * without having to constantly check for parentheses,
-			 * so we type the thing with the OP_ARCHV bit before
-			 * we place it on the end of the provided list.
-			 */
 			gn->type |= OP_ARCHV;
 			Lst_Append(gns, gn);
 		}
@@ -431,23 +402,13 @@ Arch_ParseArchive(char **pp, GNodeList *gns, GNode *scope)
 	FStr_Done(&lib);
 
 	cp++;			/* skip the ')' */
-	/* We promised that pp would be set up at the next non-space. */
 	cpp_skip_whitespace(&cp);
 	*pp += cp - *pp;
 	return true;
 }
 
 /*
- * Locate a member of an archive, given the path of the archive and the path
- * of the desired member.
- *
- * Input:
- *	archive		Path to the archive
- *	member		Name of member; only its basename is used.
- *	addToCache	True if archive should be cached if not already so.
- *
- * Results:
- *	The ar_hdr for the member, or NULL.
+ * Locate a member in an archive.
  *
  * See ArchFindMember for an almost identical copy of this code.
  */
@@ -459,15 +420,11 @@ ArchStatMember(const char *archive, const char *member, bool addToCache)
 	size_t size;		/* Size of archive member */
 	char magic[SARMAG];
 	ArchListNode *ln;
-	Arch *ar;		/* Archive descriptor */
-	struct ar_hdr arh;	/* archive-member header for reading archive */
+	Arch *ar;
+	struct ar_hdr arh;
 	char memName[MAXPATHLEN + 1];
 	/* Current member name while hashing. */
 
-	/*
-	 * Because of space constraints and similar things, files are archived
-	 * using their basename, not the entire path.
-	 */
 	member = str_basename(member);
 
 	for (ln = archives.first; ln != NULL; ln = ln->next) {
@@ -499,11 +456,8 @@ ArchStatMember(const char *archive, const char *member, bool addToCache)
 
 	if (!addToCache) {
 		/*
-		 * Caller doesn't want the thing cached, just use
-		 * ArchFindMember to read the header for the member out and
-		 * close down the stream again. Since the archive is not to be
-		 * cached, we assume there's no need to allocate extra room
-		 * for the header we're returning, so just declare it static.
+		 * Since the archive is not to be cached, assume there's no
+		 * need to allocate the header, so just declare it static.
 		 */
 		static struct ar_hdr sarh;
 
@@ -515,18 +469,10 @@ ArchStatMember(const char *archive, const char *member, bool addToCache)
 		return &sarh;
 	}
 
-	/*
-	 * We don't have this archive on the list yet, so we want to find out
-	 * everything that's in it and cache it so we can get at it quickly.
-	 */
 	arch = fopen(archive, "r");
 	if (arch == NULL)
 		return NULL;
 
-	/*
-	 * We use the ARMAG string to make sure this is an archive we
-	 * can handle...
-	 */
 	if (fread(magic, SARMAG, 1, arch) != 1 ||
 	    strncmp(magic, ARMAG, SARMAG) != 0) {
 		(void)fclose(arch);
@@ -543,17 +489,9 @@ ArchStatMember(const char *archive, const char *member, bool addToCache)
 	while (fread(&arh, sizeof arh, 1, arch) == 1) {
 		char *nameend;
 
-		/* If the header is bogus, there's no way we can recover. */
 		if (strncmp(arh.AR_FMAG, ARFMAG, sizeof arh.AR_FMAG) != 0)
-			goto badarch;
+			goto bad_archive;
 
-		/*
-		 * We need to advance the stream's pointer to the start of the
-		 * next header. Files are padded with newlines to an even-byte
-		 * boundary, so we need to extract the size of the file from
-		 * the 'size' field of the header and round it up during the
-		 * seek.
-		 */
 		arh.AR_SIZE[sizeof arh.AR_SIZE - 1] = '\0';
 		size = (size_t)strtol(arh.AR_SIZE, NULL, 10);
 
@@ -572,7 +510,7 @@ ArchStatMember(const char *archive, const char *member, bool addToCache)
 			/* svr4 magic mode; handle it */
 			switch (ArchSVR4Entry(ar, memName, size, arch)) {
 			case -1:	/* Invalid data */
-				goto badarch;
+				goto bad_archive;
 			case 0:		/* List of files entry */
 				continue;
 			default:	/* Got the entry */
@@ -596,12 +534,12 @@ ArchStatMember(const char *archive, const char *member, bool addToCache)
 			    memName + sizeof AR_EFMT1 - 1);
 
 			if (elen > MAXPATHLEN)
-				goto badarch;
+				goto bad_archive;
 			if (fread(memName, elen, 1, arch) != 1)
-				goto badarch;
+				goto bad_archive;
 			memName[elen] = '\0';
 			if (fseek(arch, -(long)elen, SEEK_CUR) != 0)
-				goto badarch;
+				goto bad_archive;
 			if (DEBUG(ARCH) || DEBUG(MAKE))
 				debug_printf(
 				    "ArchStatMember: "
@@ -617,21 +555,18 @@ ArchStatMember(const char *archive, const char *member, bool addToCache)
 			HashTable_Set(&ar->members, memName, cached_hdr);
 		}
 
+		/* Files are padded with newlines to an even-byte boundary. */
 		if (fseek(arch, ((long)size + 1) & ~1, SEEK_CUR) != 0)
-			goto badarch;
+			goto bad_archive;
 	}
 
 	fclose(arch);
 
 	Lst_Append(&archives, ar);
 
-	/*
-	 * Now that the archive has been read and cached, we can look into
-	 * the addToCache table to find the desired member's header.
-	 */
 	return HashTable_FindValue(&ar->members, member);
 
-badarch:
+bad_archive:
 	fclose(arch);
 	HashTable_Done(&ar->members);
 	free(ar->fnametab);
@@ -736,37 +671,27 @@ ArchiveMember_HasName(const struct ar_hdr *hdr,
 	 * In archives created by GNU binutils 2.27, the member names end
 	 * with a slash.
 	 */
-	if (ar_name[namelen] == '/' &&
-	    (namelen == ar_name_len || ar_name[namelen + 1] == ' '))
+	if (ar_name[namelen] == '/' && ar_name[namelen + 1] == ' ')
 		return true;
 
 	return false;
 }
 
 /*
- * Locate a member of an archive, given the path of the archive and the path
- * of the desired member.
- *
- * Input:
- *	archive		Path to the archive
- *	member		Name of member. If it is a path, only the last
- *			component is used.
- *	out_arh		Archive header to be filled in
- *	mode		"r" for read-only access, "r+" for read-write access
+ * Load the header of an archive member.  The mode is "r" for read-only
+ * access, "r+" for read-write access.
  *
- * Output:
- *	return		The archive file, positioned at the start of the
- *			member's struct ar_hdr, or NULL if the member doesn't
- *			exist.
- *	*out_arh	The current struct ar_hdr for member.
+ * Upon successful return, the archive file is positioned at the start of the
+ * member's struct ar_hdr.  In case of a failure or if the member doesn't
+ * exist, return NULL.
  *
  * See ArchStatMember for an almost identical copy of this code.
  */
 static FILE *
-ArchFindMember(const char *archive, const char *member, struct ar_hdr *out_arh,
-	       const char *mode)
+ArchFindMember(const char *archive, const char *member,
+	       struct ar_hdr *out_arh, const char *mode)
 {
-	FILE *arch;		/* Stream to archive */
+	FILE *arch;
 	int size;		/* Size of archive member */
 	char magic[SARMAG];
 	size_t len;
@@ -775,32 +700,20 @@ ArchFindMember(const char *archive, const char *member, struct ar_hdr *out_arh,
 	if (arch == NULL)
 		return NULL;
 
-	/*
-	 * We use the ARMAG string to make sure this is an archive we
-	 * can handle...
-	 */
 	if (fread(magic, SARMAG, 1, arch) != 1 ||
 	    strncmp(magic, ARMAG, SARMAG) != 0) {
 		fclose(arch);
 		return NULL;
 	}
 
-	/*
-	 * Because of space constraints and similar things, files are archived
-	 * using their basename, not the entire path.
-	 */
+	/* Files are archived using their basename, not the entire path. */
 	member = str_basename(member);
-
 	len = strlen(member);
 
 	while (fread(out_arh, sizeof *out_arh, 1, arch) == 1) {
 
 		if (strncmp(out_arh->AR_FMAG, ARFMAG,
 			    sizeof out_arh->AR_FMAG) != 0) {
-			/*
-			 * The header is bogus, so the archive is bad
-			 * and there's no way we can recover...
-			 */
 			fclose(arch);
 			return NULL;
 		}
@@ -811,14 +724,6 @@ ArchFindMember(const char *archive, const char *member, struct ar_hdr *out_arh,
 		    (int)sizeof out_arh->ar_date, out_arh->ar_date);
 
 		if (ArchiveMember_HasName(out_arh, member, len)) {
-			/*
-			 * To make life easier for callers that want to update
-			 * the archive, we reposition the file at the start of
-			 * the header we just read before we return the
-			 * stream. In a more general situation, it might be
-			 * better to leave the file at the actual member,
-			 * rather than its header, but not here.
-			 */
 			if (fseek(arch, -(long)sizeof *out_arh, SEEK_CUR) !=
 			    0) {
 				fclose(arch);
@@ -870,15 +775,10 @@ ArchFindMember(const char *archive, const char *member, struct ar_hdr *out_arh,
 		}
 #endif
 
-		/*
-		 * This isn't the member we're after, so we need to advance the
-		 * stream's pointer to the start of the next header. Files are
-		 * padded with newlines to an even-byte boundary, so we need to
-		 * extract the size of the file from the 'size' field of the
-		 * header and round it up during the seek.
-		 */
+		/* Advance to the next member. */
 		out_arh->AR_SIZE[sizeof out_arh->AR_SIZE - 1] = '\0';
 		size = (int)strtol(out_arh->AR_SIZE, NULL, 10);
+		/* Files are padded with newlines to an even-byte boundary. */
 		if (fseek(arch, (size + 1) & ~1L, SEEK_CUR) != 0) {
 			fclose(arch);
 			return NULL;
@@ -890,17 +790,9 @@ ArchFindMember(const char *archive, const char *member, struct ar_hdr *out_arh,
 }
 
 /*
- * Touch a member of an archive, on disk.
- * The GNode's modification time is left as-is.
- *
- * The st_mtime of the entire archive is also changed.
- * For a library, it may be required to run ranlib after this.
- *
- * Input:
- *	gn		Node of member to touch
- *
- * Results:
- *	The 'time' field of the member's header is updated.
+ * Update the ar_date of the member of an archive, on disk but not in the
+ * GNode.  Update the st_mtime of the entire archive as well.  For a library,
+ * it may be required to run ranlib after this.
  */
 void
 Arch_Touch(GNode *gn)
@@ -1015,9 +907,6 @@ Arch_UpdateMemberMTime(GNode *gn)
  * TARGET variable for this node to be the node's name. Otherwise,
  * we set the TARGET variable to be the full path of the library,
  * as returned by Dir_FindFile.
- *
- * Input:
- *	gn		Node of library to find
  */
 void
 Arch_FindLib(GNode *gn, SearchPath *path)
@@ -1059,20 +948,18 @@ RanlibOODate(const GNode *gn MAKE_ATTR_UNUSED)
 }
 
 /*
- * Decide if a node with the OP_LIB attribute is out-of-date. Called from
- * GNode_IsOODate to make its life easier.
+ * Decide if a node with the OP_LIB attribute is out-of-date.
  * The library is cached if it hasn't been already.
  *
- * There are several ways for a library to be out-of-date that are
- * not available to ordinary files. In addition, there are ways
- * that are open to regular files that are not available to
- * libraries.
+ * There are several ways for a library to be out-of-date that are not
+ * available to ordinary files.  In addition, there are ways that are open to
+ * regular files that are not available to libraries.
  *
- * A library that is only used as a source is never
- * considered out-of-date by itself. This does not preclude the
- * library's modification time from making its parent be out-of-date.
- * A library will be considered out-of-date for any of these reasons,
- * given that it is a target on a dependency line somewhere:
+ * A library that is only used as a source is never considered out-of-date by
+ * itself.  This does not preclude the library's modification time from making
+ * its parent be out-of-date.  A library will be considered out-of-date for
+ * any of these reasons, given that it is a target on a dependency line
+ * somewhere:
  *
  *	Its modification time is less than that of one of its sources
  *	(gn->mtime < gn->youngestChild->mtime).
@@ -1092,18 +979,16 @@ bool
 Arch_LibOODate(GNode *gn)
 {
 
-	if (gn->type & OP_PHONY) {
+	if (gn->type & OP_PHONY)
 		return true;
-	} else if (!GNode_IsTarget(gn) && Lst_IsEmpty(&gn->children)) {
+	if (!GNode_IsTarget(gn) && Lst_IsEmpty(&gn->children))
 		return false;
-	} else if ((!Lst_IsEmpty(&gn->children) && gn->youngestChild == NULL) ||
+	if ((!Lst_IsEmpty(&gn->children) && gn->youngestChild == NULL) ||
 		   (gn->mtime > now) ||
 		   (gn->youngestChild != NULL &&
-		    gn->mtime < gn->youngestChild->mtime)) {
+		    gn->mtime < gn->youngestChild->mtime))
 		return true;
-	} else {
-		return RanlibOODate(gn);
-	}
+	return RanlibOODate(gn);
 }
 
 /* Initialize the archives module. */
@@ -1118,26 +1003,25 @@ void
 Arch_End(void)
 {
 #ifdef CLEANUP
-	Lst_DoneCall(&archives, ArchFree);
+	ArchListNode *ln;
+
+	for (ln = archives.first; ln != NULL; ln = ln->next)
+		ArchFree(ln->datum);
+	Lst_Done(&archives);
 #endif
 }
 
 bool
 Arch_IsLib(GNode *gn)
 {
-	static const char armag[] = "!<arch>\n";
-	char buf[sizeof armag - 1];
+	char buf[8];
 	int fd;
+	bool isLib;
 
 	if ((fd = open(gn->path, O_RDONLY)) == -1)
 		return false;
-
-	if (read(fd, buf, sizeof buf) != sizeof buf) {
-		(void)close(fd);
-		return false;
-	}
-
+	isLib = read(fd, buf, sizeof buf) == sizeof buf
+	    && memcmp(buf, "!<arch>\n", sizeof buf) == 0;
 	(void)close(fd);
-
-	return memcmp(buf, armag, sizeof buf) == 0;
+	return isLib;
 }
diff --git a/contrib/bmake/bmake.cat1 b/contrib/bmake/bmake.cat1
index 7c50930807f4..f2b05878e7e2 100644
--- a/contrib/bmake/bmake.cat1
+++ b/contrib/bmake/bmake.cat1
@@ -1,924 +1,1783 @@
-is  a  program designed to simplify the maintenance of other pro-
-grams.  Its input is a list of specifications  as  to  the  files
-upon  which  programs  and  other  files depend.  If no option is
-given, tries to open then in order to  find  the  specifications.
-If  the file exists, it is read, see This manual page is intended
-as a reference document only.  For a more thorough description of
-and makefiles, please refer to (from 1993).   prepends  the  con-
-tents  of  the environment variable to the command line arguments
-before parsing them.  The options are as follows: Try to be back-
-wards compatible by executing a single shell per command  and  by
-making  the  sources of a dependency line in sequence.  Change to
-before reading the makefiles or doing anything else.  If multiple
-options are specified, each is interpreted relative to the previ-
-ous one: is equivalent to Define to be 1, in  the  global  scope.
-Turn on debugging, and specify which portions of are to print de-
-bugging  information.   Unless the flags are preceded by they are
-added to the environment variable and are passed on to any  child
-make  processes.  By default, debugging information is printed to
-standard error, but this can be changed using the debugging flag.
-The debugging output is always unbuffered; in addition, if debug-
-ging is enabled but debugging output is not directed to  standard
-output, the standard output is line buffered.  The available are:
-Print  all possible debugging information; equivalent to specify-
-ing all of the  debugging  flags.   Print  debugging  information
-about archive searching and caching.  Print debugging information
-about the current working directory.  Print debugging information
-about  conditional evaluation.  Print debugging information about
-directory searching and  caching.   Print  debugging  information
-about  failed commands and targets.  Specify where debugging out-
-put is written.  This must be the last flag, because it  consumes
-the  remainder of the argument.  If the character immediately af-
-ter the flag is the file is opened in append mode; otherwise  the
-file  is overwritten.  If the file name is or debugging output is
-written to the standard output or standard error  output  respec-
-tively  (and the option has no effect).  Otherwise, the output is
-written to the named file.  If the file name ends with the is re-
-placed by the pid.  Print debugging information about loop evalu-
-ation.  Print the input graph before making anything.  Print  the
-input  graph after making everything, or before exiting on error.
-Print the input graph before exiting on error.   Print  debugging
-information  about hash table operations.  Print debugging infor-
-mation about running multiple shells.  Turn on lint checks.  This
-throws errors for variable assignments that  do  not  parse  cor-
-rectly,  at  the  time of assignment, so the file and line number
-are available.  Print commands in Makefiles regardless of whether
-or not they are prefixed by or other flags.  Also known as behav-
-ior.  Print debugging information about mode decisions about tar-
-gets.  Print debugging information about making targets,  includ-
-ing  modification  dates.   Don't  delete  the  temporary command
-scripts created when running commands.  These  temporary  scripts
-are created in the directory referred to by the environment vari-
-able,  or  in if is unset or set to the empty string.  The tempo-
-rary scripts are created by and have names of the form  This  can
-create many files in or so use with care.  Print debugging infor-
-mation about makefile parsing.  Print debugging information about
-suffix-transformation  rules.   Print debugging information about
-target list maintenance.  Force the option to print raw values of
-variables, overriding the default behavior set via  Print  debug-
-ging  information  about  variable assignment and expansion.  Run
-shell commands with so the actual commands are  printed  as  they
-are  executed.   Let  environment variables override global vari-
-ables within makefiles.  Specify a makefile to  read  instead  of
-the  default or If is standard input is read.  Multiple makefiles
-may be specified, and are read in the order specified.  Specify a
-directory in which to search for  makefiles  and  included  make-
-files.   The  system  makefile directory (or directories, see the
-option) is automatically included as part of this  list.   Ignore
-non-zero  exit  of shell commands in the makefile.  Equivalent to
-specifying before each command line in the makefile.  This option
-should be specified by the user.  When the option is in use in  a
-recursive  build,  this option is passed by a make to child makes
-to allow all the make processes in  the  build  to  cooperate  to
-avoid overloading the system.  Specify the maximum number of jobs
-that  may  have  running at any one time.  If is a floating point
-number, or ends with then the value is multiplied by  the  number
-of CPUs reported online by The value of is saved in Turns compat-
-ibility mode off, unless the option is also specified.  When com-
-patibility mode is off, all commands associated with a target are
-executed  in  a  single shell invocation as opposed to the tradi-
-tional one shell invocation per line.  This can break traditional
-scripts which change directories on each command  invocation  and
-then  expect  to start with a fresh environment on the next line.
-It is more efficient to correct  the  scripts  rather  than  turn
-backwards compatibility on.  A job token pool with tokens is used
-to  control  the  total number of jobs running.  Each instance of
-will wait for a token from the pool before  running  a  new  job.
-Continue  processing  after  errors  are encountered, but only on
-those targets that do not depend on  the  target  whose  creation
-caused the error.  Specify a directory in which to search for and
-makefiles  included via the include statement.  The option can be
-used multiple times to form a search path.  This  path  overrides
-the  default  system include path Furthermore, the system include
-path is appended to the search path used for  include  statements
-(see  the option).  The system include path can be referenced via
-the read-only variable If a directory name in  the  argument  (or
-the environment variable) starts with the string searches for the
-specified  file  or  directory named in the remaining part of the
-argument string.  The search starts with  the  current  directory
-and  then  works  upward towards the root of the file system.  If
-the search is successful, the resulting  directory  replaces  the
-specification  in  the  argument.   This feature allows to easily
-search in the current source tree for customized files (e.g.,  by
-using as an argument).  Display the commands that would have been
-executed,  but do not actually execute them unless the target de-
-pends on the special source (see below) or the  command  is  pre-
-fixed  with  Display  the commands that would have been executed,
-but do not actually execute any of  them;  useful  for  debugging
-top-level  makefiles  without descending into subdirectories.  Do
-not execute any commands, instead exit 0 if the specified targets
-are up to date, and 1 otherwise.  Do not use the  built-in  rules
-specified in the system makefile.  Stop processing if an error is
-encountered.  This is the default behavior and the opposite of Do
-not echo any commands as they are executed.  Equivalent to speci-
-fying  before  each command line in the makefile.  When used with
-the flag, append a trace record to for each job started and  com-
-pleted.   Rather  than  re-building  a target as specified in the
-makefile, create it or update its modification time  to  make  it
-appear  up-to-date.  Print the value of Do not build any targets.
-Multiple instances of this option may be specified; the variables
-are printed one per line, with a blank line for each null or  un-
-defined variable.  The value printed is extracted from the global
-scope  after  all  makefiles have been read.  By default, the raw
-variable contents (which may include additional unexpanded  vari-
-able  references) are shown.  If contains a it is not interpreted
-as a variable name but rather as an expression.  Its value is ex-
-panded before printing.  The value is also expanded before print-
-ing if is set to true and the option has not been used  to  over-
-ride  it.   Note  that  loop-local and target-local variables, as
-well as values taken temporarily by global variables during make-
-file processing, are not accessible via this option.   The  debug
-mode  can be used to see these at the cost of generating substan-
-tial extraneous output.  Like but all printed variables  are  al-
-ways expanded to their complete value.  The last occurrence of or
-decides  whether  all  variables  are expanded or not.  Treat any
-warnings during makefile parsing as errors.  Print  entering  and
-leaving  directory  messages, pre and post processing.  Don't ex-
-port variables passed on the command line to the environment  in-
-dividually.   Variables  passed on the command line are still ex-
-ported via the environment variable.  This option may  be  useful
-on  systems which have a small limit on the size of command argu-
-ments.  Set the value of the variable  to  Normally,  all  values
-passed  on the command line are also exported to sub-makes in the
-environment.  The flag disables this behavior.  Variable  assign-
-ments should follow options for POSIX compatibility but no order-
-ing is enforced.  There are several different types of lines in a
-makefile: dependency specifications, shell commands, variable as-
-signments, include statements, conditional directives, for loops,
-other  directives, and comments.  Lines may be continued from one
-line to the next by ending them with  a  backslash  The  trailing
-newline  character  and  initial whitespace on the following line
-are compressed into a single space.  Dependency lines consist  of
-one or more targets, an operator, and zero or more sources.  This
-creates  a  relationship where the targets on the sources and are
-customarily created from them.  A target  is  considered  out  of
-date  if  it  does not exist, or if its modification time is less
-than that of any of its sources.  An out-of-date  target  is  re-
-created,  but  not until all sources have been examined and them-
-selves re-created as needed.  Three operators may be  used:  Many
-dependency  lines  may name this target but only one may have at-
-tached shell commands.  All sources named in all dependency lines
-are considered together, and if needed the  attached  shell  com-
-mands  are  run  to create or re-create the target.  If is inter-
-rupted, the target is removed.  The same, but the target  is  al-
-ways re-created whether or not it is out of date.  Any dependency
-line  may  have  attached shell commands, but each one is handled
-independently: its sources are considered and the attached  shell
-commands  are  run  if  the target is out of date with respect to
-(only) those sources.  Thus, different  groups  of  the  attached
-shell  commands  may be run depending on the circumstances.  Fur-
-thermore, unlike for dependency lines with no  sources,  the  at-
-tached  shell commands are always run.  Also unlike the target is
-not removed if is interrupted.  All dependency lines mentioning a
-particular target  must  use  the  same  operator.   Targets  and
-sources  may contain the shell wildcard values and The values and
-may only be used as part of the final component of the target  or
-source, and only match existing files.  The value need not neces-
-sarily  be  used to describe existing files.  Expansion is in di-
-rectory order, not alphabetically as done  in  the  shell.   Each
-target  may  have  associated  with it one or more lines of shell
-commands, normally used to create the target.  Each of the  lines
-in  this  script  be preceded by a tab.  (For historical reasons,
*** 6521 LINES SKIPPED ***


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6962c5c7.24f4f.6de1ddb2>