[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Possible bug: Intermediate file deletion using pattern rules with multi

From: Johan Bezem
Subject: Possible bug: Intermediate file deletion using pattern rules with multiple targets
Date: Tue, 23 Apr 2002 09:12:30 +0200


using make 3.79.1 on multiple platforms, I've discovered a bahavior of make 
that I cannot explain:
When intermediates are created using a pattern rule with multiple targets, only 
the first (intermediate) target to be created is deleted after the processing 
has ended.
As an example, I have a 'file.input' with arbitrary contents, and I'm using the 
following makefile:

# The next line can be a workaround in some cases
# but no wildcard like %.int is allowed
#.INTERMEDIATE: file.int file-nodelete.int

all: file.out file-nodelete.out

%.out: %.int
        cat $< > $@

%-nodelete.int %.int: %.input
        echo "intfile, target $(subst -nodelete,,$*).int" > $(subst 
        echo "intfile nodelete, target $(subst -nodelete,,$*)-nodelete.int" > 
$(subst -nodelete,,$*)-nodelete.int

        rm -f *.int *.out

The two 'echo' lines will possibly get mangled by my/your mail client, but I 
hope the intention is clear.
Since 'file.out' is the first prerequisite of target 'all', the intermediate 
'file.int' is created first, but the commands for it also create 
'file-nodelete.int' in the process. The commands are - correctly - executed 
only once.
Now, if 'file-nodelete.out' would not be a prerequisite of all, 
'file-nodelete.int' would arguably not be deleted afterwards, possibly since 
make doesn't retain any knowledge about files it doesn't need.
However, since 'file-nodelete.int' is a required intermediate file, I would 
expect it to be deleted after the process, just like 'file.int' is. The output 
of running make, however, reads like this:

[jbezem] darkstar:TmpTest/$ make -f Makefile-indirect
echo "intfile, target file.int" > file.int
echo "intfile nodelete, target file-nodelete.int" > file-nodelete.int
cat file.int > file.out
rm file.int

I've tested this both on Windows NT4, using CygWin 1.3.10, make 3.79.1-5, and 
on Solaris 2.7, make 3.79.1.
The inclusion of the special target name '.INTERMEDIATE' for all *.int files 
induces make to delete both files, however, wildcards are not supported... I 
couldn't find anything in the archives or the manual, either.

Is this a true bug, or can someone teach me how to RTFM?


Johan Bezem
CSK Software AG

reply via email to

[Prev in Thread] Current Thread [Next in Thread]