I have a make file that is always re-running a rule despite the prerequisite being up-to-date:
data.tar.bz2: data.tar
bzip2 --keep data.tar
# The following rule always runs the rule for its prerequisite
# even if it is up-to-date. Note that it doesn't matter whether
# the bunzip2 directory exists or not. I suppose is has something
# to do with the dir/file naming of the rule but I haven't been
# able to decipher why.
bunzip2/data2.tar: data.tar.bz2
mkdir bunzip2 && cd bunzip2 && bzip2 -ckd ../data.tar.bz2 > data2.tar && cd ..
.PHONY: clean
clean:
rm -f data.tar.bz2
rm -Rf bunzip2
Any ideas appreciated.
The standard POSIX system calls that set timestamps on files do not support sub-second accuracy. In order for these tools to set a specific time on a file (which they try to do so that the compressed file has the same timestamp as the original file) and preserve the original accuracy they need to use different system calls; apparently they don't do so.
What you can do to work around this is change your rule like this:
data.tar.bz2: data.tar
bzip2 --keep data.tar && touch $@
so that the timestamp of the target is set to "now".
ETA The traditional system call for setting modification times on files is utime() which accepts timestamps only in increments of one second. Newer versions of the POSIX spec introduced utimensat() which allows nanosecond timestamp settings. There is also utimes()
which allows microsecond accuracy but which has been considered "legacy" for a long time now.
If this behavior exists in the current latest release of bzip2
, I would consider it a bug worthy of a bug report to them.