multiple targets from one recipe and parallel execution

后端 未结 5 1283
醉梦人生
醉梦人生 2020-12-03 15:19

I have a project which includes a code generator which generates several .c and .h files from one input file with just one invocation of the code generator. I have a rule w

5条回答
  •  无人及你
    2020-12-03 15:37

    This is how make is defined to work. A rule like this:

    foo bar baz : boz ; $(BUILDIT)
    

    is exactly equivalent, to make, to writing these three rules:

    foo : boz ; $(BUILDIT)
    bar : boz ; $(BUILDIT)
    baz : boz ; $(BUILDIT)
    

    There is no way (in GNU make) to define an explicit rule with the characteristics you want; that is that one invocation of the recipe will build all three targets.

    However, if your output files and your input file share a common base, you CAN write a pattern rule like this:

    %.foo %.bar %.baz : %.boz ; $(BUILDIT)
    

    Strangely, for implicit rules with multiple targets GNU make assumes that a single invocation of the recipe WILL build all the targets, and it will behave exactly as you want.

提交回复
热议问题