From: Andreas Raab [mailto:andreas.raab@gmx.de]
ifeq (source/foo/test, $(wildcard source/foo/test))
works fine, but neither do
ifeq (source/$*/test, $(wildcard source/foo/test)) ifeq (source/foo/test, $(wildcard source/$*/test))
Something special about $* in ifeq?
The automatic variables ($@, $< $*, etc.) are only valid within the rule(s) of an implicit template. Conditionals are not rules, so automatic variables are meaningless to (and are not defined within) them.
If you have to use automatic variables to construct the path to an optional file then I think I would suggest Dave's approach that puts the test into a shell command run from within the rule proper, where the $* makes sense and wil be correctly substituted.
(If you have a finite set of possible locations that you can enumerate, you might be able to make things easier by writing a script to do the job: 'copy_if_source_present_and_dest_missing sourceFile destFile' or somethine along those lines and then just run it for every possible candidate.)
Cheers, Ian
piumarta@speakeasy.net wrote:
Something special about $* in ifeq?
The automatic variables ($@, $< $*, etc.) are only valid within the rule(s) of an implicit template. Conditionals are not rules, so automatic variables are meaningless to (and are not defined within) them.
Ouch. That stinks. But it sure as hell explains it.
If you have to use automatic variables to construct the path to an optional file then I think I would suggest Dave's approach that puts the test into a shell command run from within the rule proper, where the $* makes sense and wil be correctly substituted.
This is windows so shell commands are tricky (I'm not going to require Cygwin etc) but I think I can solve this via recursive Makefile invokation.
Thanks for the help.
Cheers, - Andreas
Andreas Raab schrieb:
piumarta@speakeasy.net wrote:
Something special about $* in ifeq?
The automatic variables ($@, $< $*, etc.) are only valid within the rule(s) of an implicit template. Conditionals are not rules, so automatic variables are meaningless to (and are not defined within) them.
Ouch. That stinks. But it sure as hell explains it.
Ah, it does indeed.
If you have to use automatic variables to construct the path to an optional file then I think I would suggest Dave's approach that puts the test into a shell command run from within the rule proper, where the $* makes sense and wil be correctly substituted.
This is windows so shell commands are tricky (I'm not going to require Cygwin etc) but I think I can solve this via recursive Makefile invokation.
Given your original problem ... how about this?
foo: dest/foo/test
dest/%/test: source/%/test @echo making $@ from $<
dest/%/test: default/%/test @echo making $@ from $<
This looks first for source/foo/test and then for default/foo/test.
- Bert -
Bert Freudenberg wrote:
Given your original problem ... how about this?
Ah, this is nice. I like it and it works like a charm.
Thanks! - Andreas
foo: dest/foo/test
dest/%/test: source/%/test @echo making $@ from $<
dest/%/test: default/%/test @echo making $@ from $<
This looks first for source/foo/test and then for default/foo/test.
- Bert -
vm-dev@lists.squeakfoundation.org