So I hit <send> too soon...

> I would to be able to expand Gnu make variables and macros appearing in a
> text file using values of .VARIABLES in the current execution environment.
> 
> This in effect is using Gnu make as a kind of [Template
> processor](https://en.wikipedia.org/wiki/Template_processor).
> 
> I find that this rule only copies the contents without expansion/interpolation
> 
> %.expanded: %
>       $(file >$@,$(file < $<))
> 
> However the following seems to do exactly what I desire:
> 
> define \n :=
> 
> 
> endef
> 
> %.expanded: %
>         $(file >$@,$(eval define .x:=${\n}$(file < $<)${\n}endef ${\n})${.x})

The problem with this approach is that, though it expands "correctly", it 
builds the target during the first phase of reading the makefile (c.f. [How 
make Reads a 
Makefile](https://www.gnu.org/software/make/manual/make.html#Reading-Makefiles))
 and thus standard dependency processing is precluded, which is decidedly 
unfavorable.

> 
> My question is whether this is the best/fastest way to do what I desire.

My question is changed and is now how to accomplish this in the second phase.

> 
> Thoughts?  Recommendations? Gothcas?


Reply via email to