On Sun, 12 May 2019 22:23:12 +0200
Bruno Haible <br...@clisp.org> wrote:
> Now, when my use-case is:
>   - one rule that produces N files (N > 1),
>   - I want "make" to execute the rule only once, not N times,
>     even with parallel make.
> What is the solution?

I think that the only good solution is to make sure than only 1 of the N
created files is a known target for the Makefile. If you write single
rules that on one call creates multiple targets your Makefile will not be
compatible with parallel make.

Example with one rule creating 4 files:

all : copy1 

copy1: Makefile
        install -c -m 644 Makefile copy1
        install -c -m 644 Makefile copy2
        install -c -m 644 Makefile copy3
        install -c -m 644 Makefile copy4

A better way would be to have one rule to create multiple targets, but
only on target for each call, example:

all: copy1 copy2 copy3 copy4

copy%: Makefile
        install -c -m 644 Makefile $@

The above simple Makefile would be fully compatible with parallel make.

regards Henrik

Bug-make mailing list

Reply via email to