To debug a complex XSLT transformation I broke it into several parts: first I build %.1.xml
, then I use it to build %.2.xml
, and finally I build %.3.xml
. It all works fine, but if I ask Make to build the last one, then Make invariably deletes the intermediate %.1.xml
and %.2.xml
, and I'd rather keep them. I've tried to mark all .xml
files as .PRECIOUS
so:
.PRECIOUS: %.xml
but this didn't seem to work. (I also tried to use %.1.xml
and %.2.xml
, but this didn't work either. I then tried to mark them as .SECONDARY
in the same manner and with the same negative result. The only way it doesn't delete the intermediate files is when the files already exist; in this case it only rebuilds them. But if the files do not exist, it always deletes them.
What am I missing?
GNU Make 4.1.
Update: the Makefile, >>
stands for TAB
:
sample-%.1.xml: sample-%.0.xml job.1.xslt job.xslt
>> xsltproc $(filter %.1.xslt,$^) $(filter %.xml,$^) > $@
sample-%.2.xml: sample-%.1.xml job.2.xslt job.xslt
>> xsltproc $(filter %.2.xslt,$^) $(filter %.xml,$^) > $@
sample-%.3.xml: sample-%.2.xml job.3.xslt job.xslt
>> xsltproc $(filter %.3.xslt,$^) $(filter %.xml,$^) > $@
.SECONDARY: %.xml # or .PRECIOUS: %.xml
It works fine, rebuilds everything or builds intermediate files as required, but when asked to build .3.xml
and .1.xml
and .2.xml
do not exist, it builds them and then deletes at the end. If .1.xml
exists, but .2.xml
doesn't, it will rebuild all and delete .2.xml
. It's not a show-stopper, of course, but I want to understand :)