ghc --make and make

Simon Marlow simonmar at microsoft.com
Wed Dec 7 06:34:55 EST 2005


On 04 December 2005 00:51, John Meacham wrote:

> I was thinking it would be nice if ghc --make could touch the output
> file with the timestamp of the most recently modified source file.
> 
> As it is, if you edit a file in between when ghc --make starts and it
> finishes (a substantial amount of time in some cases) then 'make' will
> not realize the dependencies have changed.

Hmm, I'm not sure about this.  I see the problem: you have a Makefile
rule that looks like this:

myprog : Main.hs Foo.hs Bar.hs ...
  $(GHC) -o $@ --make Main.hs

and while building myprog, you edit Foo.hs after it has been compiled,
with the result that myprog has a later modification date than Foo.hs so
won't be recompiled.

However, touching myprog to match the date of Foo.hs when it was
compiled doesn't seem right - the date on the executable would be
earlier than the object files, which might not cause problems with the
Makefile rule above, but would likely lead to problems with different
Makefile setups.  Perhaps the date on an object file should be set to
the same as the source file?  And the date on the .hi file?

The easiest thing to do is not to try to use make dependencies with
--make, just run ghc --make every time.  It doesn't link if linking
isn't required any more.

Cheers,
	Simon



More information about the Glasgow-haskell-users mailing list