On Wed, Aug 11, 1999 at 16:39:18 +0400, S.D.Mechveliani wrote:
> Could the people, please, explain me the behaviour of  ghc-4.04 -M
> (mkdependHS) ?
> For a long time my large project compiles (`makes') and works without 
> any special file dependency forming. No  -M,  no  mkdependHS  used. 
> Probably, this is since i had eliminated the interface cycles (?).

You always have to "half-order" your modules before compilation. For example:

\begin{code}
module A where
foo = id
\end{code}

\begin{code}
module B where
import A
bar = foo
\end{code}

B depends on A, therefore A < B, i.e. A has to be compiled before B,
otherwise the compiler complains about a missing .hi file for A.

Sure, you can order the modules by hand, but with 'ghc -M'/mkdependHS you
get it for free ;-)

    $ touch Makefile   # just a bogus Makefile
    $ ghc -M B.hs A.hs
    $ cat Makefile
# DO NOT DELETE: Beginning of Haskell dependencies
B.o : B.hs
B.o : ./A.hi
A.o : A.hs
# DO NOT DELETE: End of Haskell dependencies

Note, that with 'ghc -M' the module order in not relevant, it nevertheless
generates rules, that take care of the right ordering.

As you can see, A.o does not depend on B.hs or B.o, but on B.hi, so it has
to be recompiled *only*, iff the interface file of A changes (if no relevant
information to the outside world changes, only A.o gets updated, if you
recompile A; A.hi then remains the same).

If you want to delegate the dependency information to a file other than
'Makefile' or 'makefile', you can use: 
    $ ghc -M -optdep-f -optdep.depend ...

and in Makefile, use 'include .depend'.


Cheers,
Michael
-- 
Everything is controlled by a small evil group to which, unfortunately,
no one we know belongs.
                                                -- fortune cookie

Reply via email to