Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## how do I propagate variables from GNU Make to files?..
- ## 1st version
- ## this is totally WRONG solution and given here just for your knowledge
- FILES_TEMPLATED :=$(patsubst %.in,%,$(wildcard debian/*.in))
- $(FILES_TEMPLATED): %: %.in
- @cp -f $(<) $(@)
- .PHONY: process_templates
- process_templates: $(FILES_TEMPLATED)
- $(foreach var,$(.VARIABLES),echo -n '$(var)' | grep -Eqe '^[a-zA-Z_][a-zA-Z0-9_]*$$' && grep -Fqe '%$(var)%' $(FILES_TEMPLATED) && sed -re 's/%$(var)%/$($(var))/g' -i $(FILES_TEMPLATED);)
- ## 2nd version
- X :=$(shell printf '\027')
- FILES_TEMPLATED :=$(patsubst %.in,%,$(wildcard debian/*.in))
- .PHONY: push_templates
- push_templates:
- @$(foreach f,$(FILES_TEMPLATED),cp -f '$(f).in' '$(f)';)
- .PHONY: process_templates
- process_templates: push_templates
- @$(foreach var,$(.VARIABLES),$(if $(shell echo -n '$(var)' | grep -Eqe '^[a-zA-Z_][a-zA-Z0-9_]*$$' && echo ok || true),$(if $(shell grep -Fqe '%$(var)%' $(FILES_TEMPLATED) && echo ok || true),sed -re 's$(X)%$(var)%$(X)$($(var))$(X)g' -i $(FILES_TEMPLATED);)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement