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?
Commands and executionIf you want a string to have a dollar sign, you can use $$ . This is how to use a shell variable in bash or sh . Note the differences between Makefile variables and Shell variables in this next example.
A rule appears in the makefile and says when and how to remake certain files, called the rule's targets (most often only one per rule). It lists the other files that are the prerequisites of the target, and the recipe to use to create or update the target.
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.
This means that when you do a "make all", make always thinks that it needs to build it, and so executes all the commands for that target. Those commands will typically be ones that build all the end-products that the makefile knows about, but it could do anything.
You can use .SECONDARY with no prerequisites, this will set all intermediate targets behave as SECONDARY.
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