Simon L Peyton Jones <[EMAIL PROTECTED]> writes:
> > Why can't GHC (and all the others for that matter) be that simple?
> > Hugs seems to do the right thing.
>
> Good idea. I'll put it on our wish-list. The more people that
> say "yes please" the more likely it is to get done!
Ok, here's a half-hour hack that should serve as a starting point.
You need an installed ghc-2.10 (or modify the script). Install the
script as 'ghcmake', then go into a directory containing your Haskell
program (at least Main.{lhs,hs} must exist), and type 'ghcmake'. With
any luck, you'll get an executable called 'Main'.
Cheers,
Simon
--
Simon Marlow [EMAIL PROTECTED]
University of Glasgow http://www.dcs.gla.ac.uk/~simonm/
finger for PGP public key
#!/usr/local/bin/perl
#-----------------------------------------------------------------------------
# GHC make script. Invoke in a directory containing Main.lhs (and possibly
# other Haskell modules), and the script will build all out-of-date modules
# in the correct order and generate the program 'Main'.
# Extra options for ghc may be given on the command line. eg.
# ghcmake -H16m -fglasgow-exts
#-----------------------------------------------------------------------------
$makefile = '.Makefile';
$template = <<EOF;
.SUFFIXES: .o .lhs .hi .hs .ly .y
RM = rm -f
HAPPY = happy
HC = ghc-2.10
Main : Main.o
\$(HC) -o Main *.o
.ly.hs:
\$(RM) \$@
\$(HAPPY) \$(HAPPYFLAGS) \$<
.y.hs:
\$(RM) \$@
\$(HAPPY) \$(HAPPYFLAGS) \$<
.lhs.o:
\$(HC) -c \$(HC_OPTS) \$< -o \$*.o
.hs.o :
\$(HC) -c \$(HC_OPTS) \$< -o \$*.o
.o.hi:
\@:
depend:
mkdependHS -f $makefile *.hs *.lhs
\@chmod u+w $makefile
EOF
if (! -f 'Main.lhs' && ! -f 'Main.hs')
{ print "ghcmake: Main.{lhs,hs} doesn't exist\n"; exit(1); }
open(MAKEFILE, "> $makefile") || die("ghcmake: can't open $makefile");
print MAKEFILE "HC_OPTS = @ARGV \n";
print MAKEFILE $template;
close(MAKEFILE);
system("gmake -f $makefile depend");
if ($? != 0) { print "ghcmake: make depend failed"; exit(1); }
system("gmake -f $makefile");
if ($? != 0) { exit(1); }
exit(0);