How do I write a rule to generate set of files using a single action.
Example:
Files x
, y
, z
are generated as a result of single execution of script t.sh
which takes file a
as input.
x y z: a
t.sh $@
GNU make tries to execute t.sh
3 times.
There can only be one recipe to be executed for a file. If more than one rule gives a recipe for the same file, make uses the last one given and prints an error message.
The file name of the target of the rule. If the target is an archive member, then ' $@ ' is the name of the archive file. In a pattern rule that has multiple targets (see Introduction to Pattern Rules), ' $@ ' is the name of whichever target caused the rule's recipe to be run.
Makefile Syntax The targets are file names, separated by spaces. Typically, there is only one per rule.
By default, the goal is the first target in the makefile (not counting targets that start with a period). Therefore, makefiles are usually written so that the first target is for compiling the entire program or programs they describe.
You could implement one of the solutions specified in the automake manual.
Because you've tagged this gnumake
, I should also point out that using a GNU make pattern rule (the ones with %
) with multiple targets WILL consider both generated from one execution of the rule: see the GNU make manual.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With