我有一个make文件,尽管前提条件是最新的,但它总是重新运行规则:
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 regardless 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
任何想法表示赞赏。
在文件上设置时间戳的标准POSIX系统调用不支持亚秒精度。为了使这些工具在文件上设置特定的时间(他们试图这样做,以使压缩文件具有与原始文件相同的时间戳)并保留使用不同系统调用所需的原始精度;显然他们没有这样做。
要解决此问题,您可以做的就是更改您的规则,如下所示:
data.tar.bz2: data.tar
bzip2 --keep data.tar && touch $@
以便将目标的时间戳设置为“现在”。
ETA用于在文件上设置修改时间的传统系统调用是utime(),它仅以一秒为增量接受时间戳。较新版本的POSIX规范引入了utimensat(),它允许设置纳秒级的时间戳。还有一种utimes()
允许微秒级的精确度,但长期以来一直被认为是“传统”。
如果当前最新版本的中存在此行为bzip2
,我认为这是一个值得向他们报告错误的错误。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句