NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/59018: make: missing support for POSIX $^
>Number: 59018
>Category: bin
>Synopsis: make: missing support for POSIX $^
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Tue Jan 21 14:45:00 +0000 2025
>Originator: Diogo Santos
>Release: 10.1
>Organization:
>Environment:
Linux debian 6.1.0-30-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.124-1 (2025-01-12) x86_64 GNU/Linux
>Description:
POSIX 2024 [1] introduced the internal macro $^.
NetBSD's make currently doesn't support it.
[1]: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/make.html#tag_20_76_13_08
>How-To-Repeat:
1. Create a Makefile with the following contents
```
all: file.c; @echo $^
file.c:
```
2. Run make
Current output:
```
```
Expected output:
```
file.c
```
Tested with the latest bmake (bmake-20241124).
>Fix:
I am not sure if this is the place to submit patches.
I have created one from the GitHub mirror:
make: add POSIX $^ support
POSIX 2024 [1] introduced the $^ internal macro. Implement it as an
alias for $> (.ALLSRC), following the suggestion from defect 1520 [2].
[1]: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/make.html
[2]: https://www.austingroupbugs.net/view.php?id=1520
---
distrib/sets/lists/tests/mi | 2 ++
usr.bin/make/make.1 | 5 +++-
usr.bin/make/unit-tests/Makefile | 1 +
.../unit-tests/varname-dollar-circumflex.exp | 7 ++++++
.../unit-tests/varname-dollar-circumflex.mk | 24 +++++++++++++++++++
usr.bin/make/var.c | 9 +++----
6 files changed, 43 insertions(+), 5 deletions(-)
create mode 100644 usr.bin/make/unit-tests/varname-dollar-circumflex.exp
create mode 100644 usr.bin/make/unit-tests/varname-dollar-circumflex.mk
diff --git a/distrib/sets/lists/tests/mi b/distrib/sets/lists/tests/mi
index b51ecfd053bc..7aff825b0d07 100644
--- a/distrib/sets/lists/tests/mi
+++ b/distrib/sets/lists/tests/mi
@@ -6353,6 +6353,8 @@
./usr/tests/usr.bin/make/unit-tests/varmod-unique.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varmod.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varmod.mk tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varname-dollar-circumflex.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varname-dollar-circumflex.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varname-dollar.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varname-dollar.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varname-dot-alltargets.exp tests-usr.bin-tests compattestfile,atf
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
index 88b436ba7c38..eb98600d001b 100644
--- a/usr.bin/make/make.1
+++ b/usr.bin/make/make.1
@@ -789,7 +789,9 @@ The seven built-in local variables are:
.Bl -tag -width ".Va .ARCHIVE" -offset indent
.It Va .ALLSRC
The list of all sources for this target; also known as
-.Sq Va \&> .
+.Sq Va \&>
+or
+.Sq Va \&^ .
.It Va .ARCHIVE
The name of the archive file; also known as
.Sq Va \&! .
@@ -823,6 +825,7 @@ in archive member rules.
The shorter forms
.Po
.Sq Va \&> ,
+.Sq Va \&^ ,
.Sq Va \&! ,
.Sq Va \&< ,
.Sq Va \&% ,
diff --git a/usr.bin/make/unit-tests/Makefile b/usr.bin/make/unit-tests/Makefile
index de296624961a..806d5ce18bc6 100644
--- a/usr.bin/make/unit-tests/Makefile
+++ b/usr.bin/make/unit-tests/Makefile
@@ -404,6 +404,7 @@ TESTS+= varmod-undefined
TESTS+= varmod-unique
TESTS+= varname
TESTS+= varname-dollar
+TESTS+= varname-dollar-circumflex
TESTS+= varname-dot-alltargets
TESTS+= varname-dot-curdir
TESTS+= varname-dot-includes
diff --git a/usr.bin/make/unit-tests/varname-dollar-circumflex.exp b/usr.bin/make/unit-tests/varname-dollar-circumflex.exp
new file mode 100644
index 000000000000..68381c230b1e
--- /dev/null
+++ b/usr.bin/make/unit-tests/varname-dollar-circumflex.exp
@@ -0,0 +1,7 @@
+
+file1.o
+file1.o file2.o file3.o
+file1.o file2.o file3.o
+/usr/include /usr/include .
+stdio.h unistd.h foo.h
+exit status 0
diff --git a/usr.bin/make/unit-tests/varname-dollar-circumflex.mk b/usr.bin/make/unit-tests/varname-dollar-circumflex.mk
new file mode 100644
index 000000000000..d98dec662f03
--- /dev/null
+++ b/usr.bin/make/unit-tests/varname-dollar-circumflex.mk
@@ -0,0 +1,24 @@
+# Tests for the POSIX $^ internal macro.
+
+all: no_prerequisites prerequisite unique duplicate dir_part file_part
+
+no_prerequisites:
+ @echo $^
+
+prerequisite: file1.o
+ @echo $^
+
+unique: file1.o file2.o file3.o
+ @echo $^
+
+duplicate: file1.o file2.o file3.o file3.o
+ @echo $^
+
+dir_part: /usr/include/stdio.h /usr/include/unistd.h foo.h
+ @echo $(^D)
+
+file_part: /usr/include/stdio.h /usr/include/unistd.h foo.h
+ @echo ${^F}
+
+file1.o file2.o file3.o:
+/usr/include/stdio.h /usr/include/unistd.h foo.h:
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index 43f93882674b..9aafbb24dd7b 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -418,9 +418,12 @@ VarNew(FStr name, const char *value,
static Substring
CanonicalVarname(Substring name)
{
+ if (!(Substring_Length(name) > 0 && name.start[0] == '.')) {
+ if (Substring_Equals(name, "^"))
+ return Substring_InitStr(ALLSRC);
- if (!(Substring_Length(name) > 0 && name.start[0] == '.'))
return name;
+ }
if (Substring_Equals(name, ".ALLSRC"))
return Substring_InitStr(ALLSRC);
@@ -437,8 +440,6 @@ CanonicalVarname(Substring name)
if (Substring_Equals(name, ".TARGET"))
return Substring_InitStr(TARGET);
- /* GNU make has an additional alias $^ == ${.ALLSRC}. */
-
if (Substring_Equals(name, ".SHELL") && shellPath == NULL)
Shell_Init();
@@ -4305,7 +4306,7 @@ FindLocalLegacyVar(Substring varname, GNode *scope,
return NULL;
if (varname.start[1] != 'F' && varname.start[1] != 'D')
return NULL;
- if (strchr("@%?*!<>", varname.start[0]) == NULL)
+ if (strchr("@%?*!<>^", varname.start[0]) == NULL)
return NULL;
v = VarFindSubstring(Substring_Init(varname.start, varname.start + 1),
--
2.39.5
Home |
Main Index |
Thread Index |
Old Index