make option suggestion
Duncan Coutts
duncan.coutts at worc.ox.ac.uk
Mon Nov 6 16:31:48 EST 2006
I think this kind of build system feature ought to go into Cabal so it
can be used more widely and without people needing Makefiles.
I admit that we're not there yet with how easy it is to generate source
files.
Duncan
On Mon, 2006-11-06 at 21:12 +0000, Frederik Eaton wrote:
> Hello,
>
> I have a proposal for ghc. I think that it should take a new option,
> say "--make-command". This will specify a command to be run whenever a
> source file is read in by ghc. The command will be passed an argument,
> which is the name of the source file. The idea is that the command can
> be used to create auto-generated "source" files when ghc needs them.
>
> The purpose of this would be the following. Suppose I have a source
> file, say Source.hs, which is generated from some template, say
> Source.hs.in. If I edit Source.hs.in, and compile my program with 'ghc
> --make', then the copy of Source.hs which ghc uses will be out of
> date. That's because ghc doesn't know about the fact that Source.hs is
> generated from Source.hs.in. If I use ghc, then I'll have to remember
> to manually generate a new version of Source.hs every time I modify
> Source.hs.in.
>
> But under the present proposal, I would simply write a Makefile with
> the rules for generating Source.hs, and then pass --make-command=make
> to ghc. For instance, my Makefile might say:
>
> Source.hs: Source.hs.in
> $(TAC) < $< > $@
>
> Then every time I run ghc, and Source.hs is out of date, an up-to-date
> version of Source.hs will be generated automatically - because ghc
> will call 'make Source.hs' before reading it in.
>
> Does this sound like a good idea?
>
> Frederik
>
More information about the Glasgow-haskell-users
mailing list