HGL with GHC in Win32
Alastair Reid
reid@cs.utah.edu
14 Jun 2002 21:03:12 +0100
S J Thompson <S.J.Thompson@ukc.ac.uk> writes:
> Can anyone help? I would like to run a program using the Haskell
> Graphics Library under GHC on Windows. HGL is listed as a package
> (when ghc is asked about its packages) but not actually distributed
> as a package with ghc-5.02.3. On trying to remedy this,
> - I am able to compile HGL by hand on windows, but on
> executing the HelloWorld.hs the program hangs: nothing happens.
> - HGL doesn't appear to compile on unix (solaris).
> I'd be grateful for any feedback.
I feel bound to say that feedback would come faster if you started
with the author of the package or at least copied your request to the
author. I only became aware of this when I did because Simon Peyton
Jones was good enough to forward your mail to me.
I haven't built HGL for GHC anytime recently so I didn't have a ready
to run solution handy. Attached is a hastily cobbled together
Makefile for Unix. To use it:
1) Install GreenCard (the makefile assumes it is in $HOME/local but
you can change that easily).
2) Download graphics-2.0.4 from the web site.
3) Copy this Makefile into graphics-2.0.4/lib/x11/Makefile.ghc
4) make -f Makefile.ghc clean
5) make -f Makefile.ghc demo
6) ./demo
A similar Makefile should work for Windows but I don't have a Windows
installation of GHC at the moment so I can't test it.
There are the makings of a GHC package description file in the Xlib
source code (hslibs/xlib/xlib.conf.in) but the code rotted quickly
after Xlib was removed from the standard GHC hslib build (about a day
after it was added).
--
Alastair Reid Reid Consulting (UK) Ltd
default: demo
DEMO=../../demos/HelloWorld.hs
GREENCARD=green-card
GCDIR = $(HOME)/local/green-card
X_LIBS=-L/usr/X11R6/lib
HC = ghc
GCLIBDIR = $(GCDIR)/lib/ghc
GC_SRCS = $(wildcard *.gc)
HSGC_SRCS = $(addsuffix .hs, $(basename $(GC_SRCS)))
HS_SRCS = $(wildcard *.hs) $(HSGC_SRCS)
C_SRCS = $(wildcard cbits/*.c)
OBJS = $(addsuffix .o, $(basename $(HS_SRCS) $(C_SRCS)))
SRC_HC_OPTS += -fglasgow-exts -fvia-C
SRC_HC_OPTS += -syslib data
SRC_HC_OPTS += -syslib text
SRC_HC_OPTS += -monly-3-regs
# SRC_HC_OPTS += -package greencard
SRC_HC_OPTS += $(X_CFLAGS)
# compiling via the ghc target has historically been the most reliable
# approach
SRC_GC_OPTS += --target ghc
#SRC_GC_OPTS += --target ffi
SRC_GC_OPTS += --include-dir $(GCLIBDIR)
EXTRA_LD_OPTS += $(X_LIBS) -lX11
.SUFFIXES : .gc .hs .o .hi .lhs
%.hs : %.gc
$(GREENCARD) $(SRC_GC_OPTS) $< -o $@
%.o : %.hs
$(HC) $(SRC_HC_OPTS) $(EXTRA_HC_OPTS) -c $< -o $@
%.o : %.lhs
$(HC) $(SRC_HC_OPTS) $(EXTRA_HC_OPTS) -c $< -o $@
%.hi : %.o
@:
clean:
rm -f $(HSGC_SRCS)
objs: $(HSGC_SRCS) $(OBJS)
.PRECIOUS: $(HSGC_SRCS)
demo : $(DEMO) $(OBJS)
$(HC) $(SRC_HC_OPTS) $(EXTRA_HC_OPTS) $^ $(EXTRA_LD_OPTS) -o $@
depends.mk : $(HS_SRCS)
$(HC) -M -optdep-f -optdepdepends.mk $(SRC_HC_OPTS) $^
-include depends.mk