Bug#4073: make pattern rules delete intermediate files
Package: make
Version: 3.74-11
Given the Makefile below in an empty directory:
chiark:d> make clean
rm -f t.* u.*
chiark:d> make
echo bar >t.bar
echo foo >t.foo
echo wombat >u.wombat
echo spong >u.spong
rm t.bar
chiark:d>
We see that the intermediate file used for the pattern rules (%.bar)
is removed by make, and that this doesn't happen if we use suffix
rules.
This is silly. Consider the dependency graph (a --> b means a is
required to generate b, and b depends on a):
a --> b --+--> d
c --------'
where b and d are automatically generated.
Now if you start with a clean directory and say `make d' make
generates b from a, and then d from b and c. However, it then deletes
b again. If you edit c and want to rebuild it has to regenerate b,
and it ends up doing this every time. This defeats the purpose of
using make, which is supposed to avoid rebuilding files unnecessarily.
This doesn't appear to happen if the rules involved are ordinary
targets, only if they're pattern targets.
I can't find any documentation about this `feature', and there doesn't
appear to be a way to turn it off.
Ian.
PS: You may need to put this Makefile through `unexpand' to put the
tabs back. It has them now when I send the message, but tabs are
notorious for being mangled.
.SUFFIXES:
.SUFFIXES: .spong .wibble .wombat
all: t.foo u.spong
%.foo: %.bar
echo foo >$@
%.bar:
echo bar >$@
.spong.wibble:
echo wibble >$@
.wombat.spong:
echo spong >$@
u.wombat:
echo wombat >$@
clean:
rm -f t.* u.*
Reply to: