15

I want to use the special target .SECONDARY of GNU Make to specify that the results of a particular pattern rule should not be deleted when created as a intermediate files. .PRECIOUS works with patterns, but oddly enough, not .SECONDARY. I don't want to use .PRECIOUS, because I do want the file to be deleted in the case that Make is interrupted by a signal, or the command returns a non-zero exit status when used in combination with .DELETE_ON_ERROR. Any suggestions?

Shaun Jackman
  • 956
  • 10
  • 15
  • 1
    Waow **.PRECIOUS works with patterns, but oddly enough, not .SECONDARY.** i think i get a starting point answer to http://stackoverflow.com/questions/27090032/why-make-remove-intermediate-file-even-with-secondary-and-require-to-use-preci – philippe lhardy Nov 23 '14 at 17:01

1 Answers1

14

You can use .SECONDARY with no prerequisites, this will set all intermediate targets behave as SECONDARY.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • Cool this might be another hint for my http://stackoverflow.com/questions/27090032/why-make-remove-intermediate-file-even-with-secondary-and-require-to-use-preci question... – philippe lhardy Nov 23 '14 at 17:02
  • It appears to have other implications too – it turns all targets X as intermediate in the sense that they will not be created when "not necessary" (that is, if the prerequisites of X are older than a target depending on X). So once you declare .SECONDARY as suggested with no prerequisites, you will *not* get the entire build as you did before. Unless this is what you want – i am not aware of a solution to @Shaun Jackman 's question. – amka66 Mar 23 '21 at 13:59