[Top][All Lists]

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

make doesn't rebuild file when I expect it to

From: Dmitri Gribenko
Subject: make doesn't rebuild file when I expect it to
Date: Tue, 4 Aug 2009 07:16:43 +0300


Here is a very simplified version of my makefile for latex.  All actual
commands have been replaced by 'touch'.  There is a text.tex and a directory
for images.  Images are in svg format and have to be converted to eps before
running latex.

$ mkdir test-dir
$ cd test-dir
$ cat > Makefile
text.dvi: text.tex images/image.eps
        touch $@
        echo === no bug ===

images/image.eps: images

.PHONY: images
        $(MAKE) -C images

$ mkdir images
$ cat > images/Makefile
image.eps: image.svg
        touch $@

$ touch text.tex images/image.svg

With these makefiles I expect that if images/image.svg is newer than text.dvi
then text.dvi will be rebuilt if make is called in the toplevel directory.

However, consider such situation: images/image.eps is older than text.dvi, but
images/image.svg is newer than any of them.  (Like image.svg was edited.)
'images' target is invoked regardless the timestamp because it is phony.  In
the sub-make images/image.eps is updated.  But when sub-make finishes, toplevel
make doesn't see that images/image.eps is newer than text.dvi.  text.dvi is not

Here's a test command.  It just simulates the whole process (setting proper
timestamps) in one line.  The 'sleep' time is arbitrary, I have put it to make
sure that timestamps really differ.

$ touch text.dvi && sleep 2 && touch images/image.svg && sleep 2 && \
  ls -l --full-time images/image.svg images/image.eps text.tex text.dvi && \
-rw-r--r-- 1 grib grib 0 2009-08-04 04:13:08.000000000 +0300 images/image.eps
-rw-r--r-- 1 grib grib 0 2009-08-04 04:16:34.000000000 +0300 images/image.svg
-rw-r--r-- 1 grib grib 0 2009-08-04 04:16:32.000000000 +0300 text.dvi
-rw-r--r-- 1 grib grib 0 2009-08-04 03:38:57.000000000 +0300 text.tex
make -C images
make[1]: Entering directory `/tmp/test-dir/images'
touch image.eps
make[1]: Leaving directory `/tmp/test-dir/images'

I can send make -d output if it is needed.

Is this a make bug or I'm missing something?

Best regards,
Dmitri Gribenko

(j){printf("%d\n",i);}}} /*Dmitri Gribenko <address@hidden>*/

reply via email to

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