On 5 January 2015 at 18:13, SF Markus Elfring <elfr...@users.sourceforge.net
> wrote:

> > I assume that you want something different from this
> > but you need to explain better, sorry :-)
>
> I hope that an other wording will be clearer.
>
> Can make rules be extended on demand while a build script
> is evaluated?
>
> How much can a command like "getconf _NPROCESSORS_ONLN"
> influence rule evaluation directly during a make run?
>


Ok, well I'll make a guess at what you want:

    You have some sort of work which you can control the "granularity" i.e.
you can either have 1 rule that generates 10 targets or you can have 10
rules that generate 1 target.

Normally I'd just say "have 10 rules that generate 10 targets" because this
is the simplest thing to do and works properly within make and is what
people expect. But I can imagine ways in which this would not be efficient
- particularly if the startup time for the rule was high.

So you have in your toolbox $(shell) and $(eval).

$(eval) lets you generate rules dynamically.
$(shell) lets you run an external tool in a shell

e.g. you could use $(shell) to find out how many processors there were like
this (linux):

NPROC:=$(shell grep "processor" /proc/cpuinfo  | cut -b12- )
# this returns "0 1 2 3" etc

# Then you might use eval to generate rules dynamically:

$(foreach N,$(NPROC),$(eval
   # YOUR DYNAMIC RULE
  MYTARGET_$(N):
<TAB>mytool --dosomething -o$@
  )
)


I am probably guessing wrong but perhaps this gives you some ideas.

Regards,

Tim


-- 
You could help some brave and decent people to have access to uncensored
news by making a donation at:

http://www.thezimbabwean.co.uk/friends/
_______________________________________________
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make

Reply via email to