help-make
[Top][All Lists]
Advanced

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

Re: Re-calculate variable values


From: Paul Smith
Subject: Re: Re-calculate variable values
Date: Wed, 30 Sep 2009 10:20:37 -0400

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.





reply via email to

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