rmyorston / pdpmake

Public domain POSIX make
https://frippery.org/make
Other
103 stars 10 forks source link

Implementing $(*F) and $(*D) #32

Closed absolutelynothinghere closed 1 month ago

absolutelynothinghere commented 8 months ago

Hello again,

pdpmake currently implements the alternative forms of $? which are $(?F) and $(?D), however it does not implement the alternative forms of the internal macros $< and $* (maybe $% too I haven't tested)

As per the specification (emphasis mine):

Each of the internal macros has an alternative form. When an uppercase 'D' or 'F' is appended to any of the macros, the meaning shall be changed to the directory part for 'D' and filename part for 'F'.

Currently both GNU Make and BSD Make implement this.

rmyorston commented 8 months ago

Can you provide an example of what doesn't work? I tried this:

$ cat M32
.POSIX:
.PRAGMA: target_name
.SUFFIXES: .x .z

.x.z:
    @echo $< $* $@
    @echo $(<D) $(*D) $(@D)
    @echo $(<F) $(*F) $(@F)

/tmp/1.z: /tmp/1.x
$ touch /tmp/1.x
$ ./make -f M32
/tmp/1.x /tmp/1 /tmp/1.z
/tmp /tmp /tmp
1.x 1 1.z
$

and it seems to do stuff that looks correct.

absolutelynothinghere commented 8 months ago

Makefile:

COMMAND1 = echo "$(?F)"
COMMAND2 = echo "$(@F)"
COMMAND3 = echo "$(*F)"
COMMAND4 = echo "$(<F)"

build/test.o: src/test.c src/test.h src/foo.c
    @$(COMMAND1)
    @$(COMMAND2)
    @$(COMMAND3)
    @$(COMMAND4)

pdpmake output:

test.c test.h foo.c
test.o

gmake output:

test.c test.h foo.c
test.o
test
test.c
rmyorston commented 8 months ago

This isn't about the F and D modifiers. Even with:

COMMAND3 = echo "$*"
COMMAND4 = echo "$<"

your Makefile will output blank lines.

According to POSIX $* and $< are only required to work in inference rules, which is why I used them in that context in my example above.

Evidently GNU make allows $* and $< in target rules but pdpmake doesn't. It could, but it would be a non-POSIX extension.

absolutelynothinghere commented 8 months ago

I see, thank you for the explanation.

Having this feature would definitely be nice but it's completely up to you, feel free to close the issue if it's not on the roadmap.

rmyorston commented 8 months ago

I'll keep this issue open as a reminder.

rmyorston commented 1 month ago

pdpmake now supports $< and $* in target rules as a non-POSIX extension.