wildcard - GNU Makefile: multiple outputs from single rule + preventing intermediate files from being deleted -


This is the continuity of the question in a way The problem is that there is a rule to generate many outputs from the same input, And this is less time consuming, so we would love to avoid duplication. Now there is an additional turn, that we want to prevent files from being deleted as intermediate files, and wildcards are included to allow the rules for the parameters.


The solution was to suggest that we set the following rule:

  file-a.out: program file.in./program file.in file-a .out file-b.out file-c.out file-b.out: file-aout@file-c.out: file-b.out @  

Then, < Code> call-file-c.out and we avoid problems with -j in the parallel with the switch create is running OK till now.


The problem is as the above solution sets a series in DAG, because create understands it differently; The file file-a.out and file-b.out are treated as intermediate files, and they are by default as soon as file-c Out is ready.

One way to avoid that place was mentioned somewhere here, and it has been included in the file-a.out and file-b. Out as a dependency of a target .secondary , which prevents them from being removed Unfortunately, this does not solve my case because my rules use wildcard patter; Specifically, my rules look like this:

  file-A -% out: program file.in./program $ * file.in File-A-$ *. Out File-B - $ *. Out file-c - $ *. Out File-B -% Out: File-A -% Out @ file-c -% out: file-b -% Outside @  

so that any file can be included in the parameter, for example

  file-c-12.out  

The solution that builds documentation suggests is to add these codes as the rules contained in the list of dependencies of .privacy , thus deleting these files Used to be.


Work solution with. works, but whenever a rule fails and files are incomplete, it prevents these files from being deleted is there any other way to do this work?

To fix this, a hack is to define a target .SECONDARY with anything, that is,

  .SECondary:  

which indicates that all files should be treated as secondary and not thus removed, as long as created < / Code> does not interrupt or fails the rule. Unfortunately, it does not allow a subset of rules with wildcards to work in this way, so I consider it a hack only (even if it is useful).

the simplest thing

  file-a-% Out file -b-% Out file-c -% out: in the program file ./program $ * file.in file-a-$ *. Out File-B - $ *. Out file-c - $ *. Exactly  

will do exactly what you want.

(Pattern rules with many goals are different from the general rule, which you were asking about.) See Bison Example in the example.)


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -