Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
absolutelynothinghere opened this issue Nov 12, 2023 · 6 comments
Closed

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

absolutelynothinghere opened this issue Nov 12, 2023 · 6 comments

Comments

@absolutelynothinghere
Copy link
Contributor

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
Copy link
Owner

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
Copy link
Contributor Author

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
Copy link
Owner

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
Copy link
Contributor Author

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
Copy link
Owner

I'll keep this issue open as a reminder.

rmyorston added a commit that referenced this issue May 22, 2024
POSIX only requires $< and $* to be set for inference rules, not
target rules.

As an extension allow them to be set for target rules, as in
GNU make.  This may or may not be useful.

(GitHub issue #32)
@rmyorston
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants