using ghc with make

Frederik Eaton frederik at a5.repetae.net
Mon Apr 17 17:57:32 EDT 2006


Hi all,

I have a project which currently uses Cabal, and I would like to
switch to using a plain Makefile. 

I have two examples of projects that use Makefiles, darcs and jhc, but
they both appear to hand-code the list of dependencies for
executables. The "-M" option to ghc should let us do this
automatically, but either because of a deficiency in GHC or in GNU
Make, that looks to be impossible or difficult. Does anyone have
experience with this?

Since I'm not using the multi-compiler features of Cabal, I think it
shouldn't be too hard to get the project-specific part of my Makefile
down to the size of the .cabal file.

Many thanks,

Frederik



P.S. I want to use 'make' rather than Cabal because:

- I want to be able to rebuild specific targets, rather than building
everything every time

- I want better dependency inference, for instance I don't want to
relink every executable every time I do a build (I think this is fixed
in newer versions of ghc, but not the one I use)

- I ultimately want to be able to use a more sophisticated build
system than Cabal's. GNU Make is a good first start, because it allows
me to run several jobs simultaneously, for instance potentially
utilizing multiple processors. In the future, I want to write a build
system that does result caching as well. There are a lot of tricks
that can be done in build systems, so in general I think it would be
good to have a build system which is separable from the
domain-specific configuration and compiler logic, rather than coupling
them as Cabal and "ghc --make" do.

The compile / fix compiler errors cycle is an important part of the
development process for me, and so I want recompilation to go as
quickly as possible. By the way, the GHC user manual claims that using
--make is much faster than using a Makefile, but in a test on a small
program, the difference was not significant (16 seconds vs. 18
seconds). Furthermore, some build systems are able to combine targets,
e.g. running "ghc -c Bar.hs -c Foo.hs" instead of "ghc -c Bar.hs; ghc
-c Foo.hs", which should eliminate the already small difference.

-- 
http://ofb.net/~frederik/


More information about the Glasgow-haskell-users mailing list