[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dynamically building (temp) include file - how to delete on exit?
From: |
gnu_make0 |
Subject: |
Re: dynamically building (temp) include file - how to delete on exit? |
Date: |
Sun, 17 Jun 2012 13:50:22 -0500 |
On Sat 6/16/12 14:23 EDT ogronom wrote:
> From info make
>
> The only processing `make' does on the result
> is to convert each newline (or carriage-return / newline pair) to a
> single space. If there is a trailing (carriage-return and) newline it
> will simply be removed.
>
> So it looks like, that you can not change this behaviour. Workaround
> depends on what your script actually does. For example suggested below
> you can do something like this
>
> vars_to_define=foo bam
> foo_script=echo 123
> bam_script=echo hi
>
> $(foreach v,$(vars_to_define),$(eval $(v)=$(shell $($(v)_script))))
>
> .PHONEY: bar
> bar:
> @echo foo: $(foo)
> @echo
> @echo bam: $(bam)
Inspired by your hints, this approach ( no include file, but should allow
dynamic macro definition ) is looking promising:
$ cat makefile
$(shell echo -e 'frob=x\ngrok=y\njam=z' > /tmp/zat)
$(foreach v,$(shell set -- $$(wc -l /tmp/zat); seq $$1),$(eval $(shell sed
-ne $(v)p /tmp/zat)))
$(shell rm /tmp/zat)
.PHONEY: bar
bar:
@echo frob: $(frob)
@echo grok: $(grok)
@echo jam: $(jam)
$ rm -f /tmp/zat; make bar
frob: x
grok: y
jam: z
$ ls /tmp/zat
ls: /tmp/zat: No such file or directory
$
I need to see if I can adjust above to use mktemp instead of a constant
'/tmp/zat'
temp filename.
--
Tom
Re: dynamically building (temp) include file - how to delete on exit?, Basile Starynkevitch, 2012/06/16