paul, thanks for the note. I do understand the difference between Makefile and say, a procedural script. I had forgotten to mention that I did try the for loop in shell but did not like it much - for the same reasons that you mention. So I was thinking of taking advantage of ability in Make that it "automatically re-makes target if the pre-requisite is newer than target". The only stumbling block as I said is ability on "How to keep newing the target". This I am not able to do. May be manipulating an environment variable from within Make would help. Thanks again.
aditya On Wed, Sep 30, 2009 at 11:20 PM, Paul Smith <[email protected]> wrote: > On Wed, 2009-09-30 at 18:05 +0900, Aditya Kher wrote: > > folks, > > I would like to re-evaluate or rather re-calculate variable value > > during making of target > > > > something like below: > > > > %gmake all RUN_COUNT=4 > > > > > > Makefile: > > all: > > ${MAKE} run${RUN_COUNT} > > > > #add code for > > # 1. RUN_COUNT = RUN_COUNT -1 > > # 2. re-evaluate "all" target after updating RUN_COUNT > > pre-requisite > > This kind of thing is not possible in GNU make. Makefiles are not > procedural languages; they don't start at the top of the makefile and > run rules until they're done, at the bottom. > > You can do it with the shell: > > all: > for i in `seq 1 $(RUN_COUNT)`; do \ > $(MAKE) run$$i || exit $$?; \ > done > > Not perfect (doesn't obey make's -k option for example) but it will > work. Another option is something like this: > > TARGETS := $(addprefix run,$(shell seq 1 $(RUN_COUNT))) > > all: $(TARGETS) > > run%: %.txt > .... > > this does all the work in a single instance of make, instead of invoking > sub-makes. > > -- ---- Aditya Kher email: [email protected] Web: http://www.kher.org ----
_______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
