Search code examples
makefilegnu-makejobs

Makefile $(eval ...) : what's the behavior when plutiple jobs run simultaneously?


I've defined the following rule:

$(OUTDIR)/%_sorted.bam:
    $(eval SAMPLE:=$(subst _sorted,,$(notdir $(basename $@))))
    (...) do something with $(SAMPLE)

can I use it safely (= is it a "local variable" to the rule ?) with

make -j (number of jobs) 

or does the variable $(SAMPLE) will be replaced for each (simultaneous) invocation of the rule ?


Solution

  • Yes, you can. GNU make expands the whole recipe prior to executing it. Job server mode only affects the execution of sub-processes spawned by make, everything else is single threaded.