I have two questions on ghc-5.00 -make.
The User's Guide says in Section 4.5 that it is simpler to use -make than the Makefile technique.
1. I try ghc -make Main.hs
with Main.hs containing main = putStr "hello\n"
(in ghc-5.00, binary, i386-unknown, Linux), and it reports ghc-5.00: unrecognised flag: -make - ?
The flag is actually '--make' (note the double dash). Apparently the documentation system has some problems rendering the double dash in printed mode.
2. How to simplify (eliminate?) Makefile. -----------------------------------------
My project has many .hs files in the directories ./source/ ./source/auxil/ ./source/pol/factor/ ... `make ...' compiles them putting .hi, .o files into ./export/, then, applies `ar' to make .a library. To do all this, Makefile includes the rules like
.hs.o: $(HC) -c $< $(HCFlags)
and applies the compiler $(HC) with the flags
... -syslib data -recomp ... -i$(E) -odir $(E) -ohi $(E)/$(notdir $*).hi $($*_flags) ... Now, this Makefile does not work under ghc-5.00, because second compilation cannot find .hi file of the first compilation:
..ghc -c source/auxil/Prelude_.hs -fglasgow-exts ... -recomp -iexport -odir export -ohi export/Prelude_.hi +RTS -G3 -F1.5 -M29m -RTS -Onot ... ..ghc -c source/parse/Iparse_.hs -fglasgow-exts ... -recomp -iexport -odir export -ohi export/Iparse_.hi +RTS -G3 -F1.5 -M29m -RTS -Onot
source/parse/Iparse_.hs:20: failed to load interface for `Prelude_': Bad interface file: export/Iparse_.hi does not exist
This is indeed a bug: -ohi doesn't work properly in 5.00. I'm fixing it right now.
Also what -make can do to replace some large part of Makefile. For (a) Makefile has rather odd language, it is not good to force the functional programmer to look into it, (b) one has to think of Makefile versions for different operation systems.
The simplest way to work is to put the objects and .hi files in the same directory as the source. Then you can use --make like this: $ ghc --make -i<dir1>:<dir2>:... Main to put the objects in a single directory, you can use -odir <dir>. Unfortunately the .hi files can't be saved elsewhere when using --make. Cheers, Simon