Building Multiple Targets Simultaneously

The #pragma multi directive lets you use one rule that creates multiple outputs simultaneously. You can use this directive when a pattern rule might not be suitable. This directive lets you create non-pattern rules that have multiple outputs. You can use this directive only with gmake and NMAKE emulation.

#pragma multi causes the targets of the immediately-following rule or dependency specification to be treated as updated together if they are updated. For example, the following produces one rule and one rule job, rather than three of each:

#pragma multi
a b c: ; @echo building a b and c

The #pragma multi directive has the following restrictions:

  • If you apply #pragma multi to a target list, then you must apply it to all overlapping target lists. Those lists must specify the same set of targets (although they might do so in a different order).

  • Target- and pattern-specific variable assignments for the targets of a #pragma multi rule must agree. Otherwise, eMake might choose the assignments for just one target or combine them all.

  • You cannot apply #pragma multi to static patterns, double-colon rules, or pattern targets that follow non-pattern targets on the same line.

  • If you apply #pragma multi to a non-static pattern, a warning appears.

  • A #pragma multi rule with commands might not override (or be overridden by) other commands for the same targets.

  • A #pragma multi dependency specification must correspond to a #pragma multi rule with commands having the same set of targets. Otherwise, eMake will fail with errors. Implicit rules are not searched for these missing commands.

  • $@ has the same meaning as it does in multiple-target patterns: the target that first caused the rule to be needed.

  • Setting the --emake-disable-pragma=multi or --emake-disable-pragma=all options disables #pragma multi.