The branch stable/14 has been updated by sjg:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=5d3c3f73b69c61cd2630be56642292a676363dd0

commit 5d3c3f73b69c61cd2630be56642292a676363dd0
Author:     Simon J. Gerraty <[email protected]>
AuthorDate: 2024-05-23 20:11:02 +0000
Commit:     Simon J. Gerraty <[email protected]>
CommitDate: 2026-01-10 21:33:11 +0000

    Merge bmake-20240520
    
    Merge commit '29efb3dcaedd9cbabc6f96f35545baf2c8b28501'
    
    (cherry picked from commit 9d3df31ec06fe91c5c67da464f11408474d57174)
---
 contrib/bmake/ChangeLog                   | 15 +++++++++
 contrib/bmake/VERSION                     |  2 +-
 contrib/bmake/dir.c                       | 51 ++++++++++++++++++++++++++-----
 contrib/bmake/dir.h                       |  3 +-
 contrib/bmake/getopt.c                    |  6 ++--
 contrib/bmake/main.c                      |  6 ++--
 contrib/bmake/parse.c                     |  6 ++--
 contrib/bmake/unit-tests/deptgt-phony.exp |  2 +-
 usr.bin/bmake/Makefile.config             |  2 +-
 9 files changed, 71 insertions(+), 22 deletions(-)

diff --git a/contrib/bmake/ChangeLog b/contrib/bmake/ChangeLog
index 1ce033887c8f..6d8a8228969d 100644
--- a/contrib/bmake/ChangeLog
+++ b/contrib/bmake/ChangeLog
@@ -1,3 +1,18 @@
+2024-05-20  Simon J Gerraty  <[email protected]>
+
+       * VERSION (_MAKE_VERSION):
+       Merge with NetBSD make, pick up
+       o dir.c: in FindFile restore last search of .CURDIR even for
+       includes, as a number of existing makefiles are broken otherwise.
+
+2024-05-19  Simon J Gerraty  <[email protected]>
+
+       * VERSION (_MAKE_VERSION): 20240519
+       Merge with NetBSD make, pick up
+       o dir.c: Add Dir_FindInclude, FindFile without looking in .CURDIR.
+       Also fix Dir_SetSYSPATH to use defSysIncPath if sysIncPath is empty.
+       o main.c: no need to set .DOTLAST in sysIncPath
+
 2024-05-07  Simon J Gerraty  <[email protected]>
 
        * VERSION (_MAKE_VERSION): 20240508
diff --git a/contrib/bmake/VERSION b/contrib/bmake/VERSION
index 60aa9ae5069b..4af36cf84624 100644
--- a/contrib/bmake/VERSION
+++ b/contrib/bmake/VERSION
@@ -1,2 +1,2 @@
 # keep this compatible with sh and make
-_MAKE_VERSION=20240508
+_MAKE_VERSION=20240520
diff --git a/contrib/bmake/dir.c b/contrib/bmake/dir.c
index 5c11d6c794d7..de50b2faf511 100644
--- a/contrib/bmake/dir.c
+++ b/contrib/bmake/dir.c
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.c,v 1.286 2023/12/29 18:53:24 rillig Exp $ */
+/*     $NetBSD: dir.c,v 1.290 2024/05/20 19:14:12 sjg Exp $    */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -132,7 +132,7 @@
 #include "job.h"
 
 /*     "@(#)dir.c      8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: dir.c,v 1.286 2023/12/29 18:53:24 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.290 2024/05/20 19:14:12 sjg Exp $");
 
 /*
  * A search path is a list of CachedDir structures. A CachedDir has in it the
@@ -566,10 +566,12 @@ void
 Dir_SetSYSPATH(void)
 {
        CachedDirListNode *ln;
-
+       SearchPath *path = Lst_IsEmpty(&sysIncPath->dirs)
+               ? defSysIncPath : sysIncPath;
+       
        Var_ReadOnly(".SYSPATH", false);
        Global_Delete(".SYSPATH");
-       for (ln = sysIncPath->dirs.first; ln != NULL; ln = ln->next) {
+       for (ln = path->dirs.first; ln != NULL; ln = ln->next) {
                CachedDir *dir = ln->datum;
                Global_Append(".SYSPATH", dir->name);
        }
@@ -1142,15 +1144,16 @@ found:
  * Input:
  *     name            the file to find
  *     path            the directories to search, or NULL
+ *     isinclude       if true, do not search .CURDIR at all
  *
  * Results:
  *     The freshly allocated path to the file, or NULL.
  */
-char *
-Dir_FindFile(const char *name, SearchPath *path)
+static char *
+FindFile(const char *name, SearchPath *path, bool isinclude)
 {
        char *file;             /* the current filename to check */
-       bool seenDotLast = false; /* true if we should search dot last */
+       bool seenDotLast = isinclude; /* true if we should search dot last */
        struct cached_stat cst;
        const char *trailing_dot = ".";
        const char *base = str_basename(name);
@@ -1163,7 +1166,7 @@ Dir_FindFile(const char *name, SearchPath *path)
                return NULL;
        }
 
-       if (path->dirs.first != NULL) {
+       if (!seenDotLast && path->dirs.first != NULL) {
                CachedDir *dir = path->dirs.first->datum;
                if (dir == dotLast) {
                        seenDotLast = true;
@@ -1244,6 +1247,38 @@ Dir_FindFile(const char *name, SearchPath *path)
        return NULL;
 }
 
+/*
+ * Find the file with the given name along the given search path.
+ *
+ * Input:
+ *     name            the file to find
+ *     path            the directories to search, or NULL
+ *
+ * Results:
+ *     The freshly allocated path to the file, or NULL.
+ */
+char *
+Dir_FindFile(const char *name, SearchPath *path)
+{
+       return FindFile(name, path, false);
+}
+
+/*
+ * Find the include file with the given name along the given search path.
+ *
+ * Input:
+ *     name            the file to find
+ *     path            the directories to search, or NULL
+ *
+ * Results:
+ *     The freshly allocated path to the file, or NULL.
+ */
+char *
+Dir_FindInclude(const char *name, SearchPath *path)
+{
+       return FindFile(name, path, true);
+}
+
 
 /*
  * Search for 'needle' starting at the directory 'here' and then working our
diff --git a/contrib/bmake/dir.h b/contrib/bmake/dir.h
index 09cbca8ec4c1..58bfd8c996ef 100644
--- a/contrib/bmake/dir.h
+++ b/contrib/bmake/dir.h
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.h,v 1.47 2023/01/24 00:24:02 sjg Exp $     */
+/*     $NetBSD: dir.h,v 1.48 2024/05/19 20:09:40 sjg Exp $     */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -86,6 +86,7 @@ void Dir_SetSYSPATH(void);
 bool Dir_HasWildcards(const char *) MAKE_ATTR_USE;
 void SearchPath_Expand(SearchPath *, const char *, StringList *);
 char *Dir_FindFile(const char *, SearchPath *) MAKE_ATTR_USE;
+char *Dir_FindInclude(const char *, SearchPath *) MAKE_ATTR_USE;
 char *Dir_FindHereOrAbove(const char *, const char *) MAKE_ATTR_USE;
 void Dir_UpdateMTime(GNode *, bool);
 CachedDir *SearchPath_Add(SearchPath *, const char *);
diff --git a/contrib/bmake/getopt.c b/contrib/bmake/getopt.c
index da29daed2ca8..2afe663acb00 100644
--- a/contrib/bmake/getopt.c
+++ b/contrib/bmake/getopt.c
@@ -1,4 +1,4 @@
-/*     $NetBSD: getopt.c,v 1.29 2014/06/05 22:00:22 christos Exp $     */
+/*     $NetBSD: getopt.c,v 1.30 2024/01/19 18:41:38 christos Exp $     */
 
 /*
  * Copyright (c) 1987, 1993, 1994
@@ -58,8 +58,8 @@ int
 getopt(int nargc, char * const nargv[], const char *ostr)
 {
        extern char *__progname;
-       static const char *place = EMSG;        /* option letter processing */
-       char *oli;                              /* option letter list index */
+       static const char *place = EMSG;        /* option letter processing */
+       const char *oli;                        /* option letter list index */
 
 #ifndef BSD4_4
        if (!__progname) {
diff --git a/contrib/bmake/main.c b/contrib/bmake/main.c
index fff294291ccf..6c97d648e5a2 100644
--- a/contrib/bmake/main.c
+++ b/contrib/bmake/main.c
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.615 2024/05/07 18:26:22 sjg Exp $   */
+/*     $NetBSD: main.c,v 1.616 2024/05/19 17:55:54 sjg Exp $   */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include "trace.h"
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.615 2024/05/07 18:26:22 sjg Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.616 2024/05/19 17:55:54 sjg Exp $");
 #if defined(MAKE_NATIVE)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -1174,8 +1174,6 @@ InitDefSysIncPath(char *syspath)
        else
                syspath = bmake_strdup(syspath);
 
-       /* do NOT search .CURDIR first for .include <makefile> */
-       SearchPath_Add(defSysIncPath, ".DOTLAST");
        for (start = syspath; *start != '\0'; start = p) {
                for (p = start; *p != '\0' && *p != ':'; p++)
                        continue;
diff --git a/contrib/bmake/parse.c b/contrib/bmake/parse.c
index 54f29ba5ff13..70c6d6fe5157 100644
--- a/contrib/bmake/parse.c
+++ b/contrib/bmake/parse.c
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.722 2024/04/27 17:33:46 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.723 2024/05/19 20:09:40 sjg Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.722 2024/04/27 17:33:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.723 2024/05/19 20:09:40 sjg Exp $");
 
 /* Detects a multiple-inclusion guard in a makefile. */
 typedef enum {
@@ -1269,7 +1269,7 @@ IncludeFile(const char *file, bool isSystem, bool depinc, 
bool silent)
        if (fullname == NULL) {
                SearchPath *path = Lst_IsEmpty(&sysIncPath->dirs)
                    ? defSysIncPath : sysIncPath;
-               fullname = Dir_FindFile(file, path);
+               fullname = Dir_FindInclude(file, path);
        }
 
        if (fullname == NULL) {
diff --git a/contrib/bmake/unit-tests/deptgt-phony.exp 
b/contrib/bmake/unit-tests/deptgt-phony.exp
index e943091e4cef..1c379b32a33b 100644
--- a/contrib/bmake/unit-tests/deptgt-phony.exp
+++ b/contrib/bmake/unit-tests/deptgt-phony.exp
@@ -2,7 +2,7 @@ Expanding "depsrc-phony-pr-15164-*-wildcard"...
 Expanding "deptgt-phony-pr-15164-*-wildcard"... 
 Searching for .depend ...
    failed.
-Searching for .depend ...[dot last]...
+Searching for .depend ...
    . ...
    failed.
 Wildcard expanding "all"...
diff --git a/usr.bin/bmake/Makefile.config b/usr.bin/bmake/Makefile.config
index 55bc4a4370ca..e62d207b70ac 100644
--- a/usr.bin/bmake/Makefile.config
+++ b/usr.bin/bmake/Makefile.config
@@ -6,7 +6,7 @@ SRCTOP?= ${.CURDIR:H:H}
 
 # things set by configure
 
-_MAKE_VERSION?=20240508
+_MAKE_VERSION?=20240520
 
 prefix?= /usr
 srcdir= ${SRCTOP}/contrib/bmake

Reply via email to