help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible to get prerequisite path with secondary expansion when VPAT


From: Glen Huang
Subject: Re: Possible to get prerequisite path with secondary expansion when VPATH is employed?
Date: Thu, 7 Apr 2022 14:36:49 +0800

> 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 $< $@
> ```

Sorry, the source files are actually structured like this:

Source files
```
foo/1.tpl
foo/data
bar/2.tpl
bar/data
baz/3
```
And I wish the Makefile could be like this:

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

Previously, the pattern rule could simply be "build/%: %.tpl %.data”, but it 
won’t work for my actual case.

Regards.
Glen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]