help-make
[Top][All Lists]
Advanced

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

how to: write a rule which expands the contents of an arbitrary text fil


From: Cook, Malcolm
Subject: how to: write a rule which expands the contents of an arbitrary text file?
Date: Fri, 14 May 2021 17:54:32 +0000

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})

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

Thoughts?  Recommendations? Gothcas?




reply via email to

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