[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make doesn't rebuild file when I expect it to
From: |
Paul Smith |
Subject: |
Re: make doesn't rebuild file when I expect it to |
Date: |
Tue, 04 Aug 2009 00:41:39 -0400 |
On Tue, 2009-08-04 at 07:16 +0300, Dmitri Gribenko wrote:
> 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
> 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
> rebuilt.
This is expected. Here, you are not telling make the truth. The
top-level makefile has no commands to build the target images/image.eps.
It's built as a side-effect of the "directory" prerequisite "images".
But make doesn't know that; make sees that you have no commands in your
rule for images/image.eps, so make doesn't know that this file was
updated.
If you change your rule to contain a command line, then I believe it
will work:
images/image.eps: images
@:
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.mad-scientist.us
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist