Possible to get prerequisite path with secondary expansion when VPATH is employed?

Glen Huang <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Message-ID <[email protected]>
Hi,

I’m trying to use make to render some files with VPATH employed:

Source files
```
foo/1.tpl
foo/1.data
bar/2.tpl
bar/2.data
baz/3
```

Makefile
```
.SECONDEXPANSION:
VPATH := foo bar baz
build/%: %.tpl $$(patsubst %.tpl,%.data,$$<)
        render --data $(word 2,$^) $< $@
build/%: %
        cp $< $@
```

I’d like for make to automatically list the corresponding data file as a prerequisite for the pattern rule, but apparently this doesn’t work, because $$< expands to an empty string.

I also tried this:

Makefile
```
.SECONDEXPANSION:
VPATH := foo bar
build/%: %.tpl
build/%: $$(patsubst %.tpl,%.data,$$<)
        render --data $(word 2,$^) $< $@
build/%: %
        cp $< $@
```

But since an implicit rule only applies when both the target and requisites are found, this also doesn’t work.

I read the official doc on topics about secondary expansion, VPATH and search algorithm, but couldn’t come up with a way to get the prerequisite path and turn it into another prerequisite. I’d be really grateful if anyone could shed some light.

Regards,
Glen
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.