using ghc with make
Niklas Sorensson
nik at cs.chalmers.se
Tue Apr 18 05:07:39 EDT 2006
Frederik Eaton wrote:
> Hi all,
>
> I have a project which currently uses Cabal, and I would like to
> switch to using a plain Makefile.
I use something like the attached Makefile. I don't have any experience with big projects though, so
it could be that regenerating dependencies all the time is expensive.
/Niklas
-------------- next part --------------
## This Makefile compiles all haskell sources files in current
## directory to an executable with the same name as the last level of
## the current directory path. Change the following variables to alter
## this behaviour
EXEC = $(notdir $(shell pwd))
HSRCS = $(wildcard *.hs)
HOBJS = $(addsuffix .o, $(basename $(HSRCS)))
HCFLAGS = -O3 -fglasgow-exts
HLFLAGS =
## Link rule
$(EXEC): $(HOBJS)
ghc $(HLFLAGS) -o $@ $^
## Build rule
%.o %.hi: %.hs
ghc $(HCFLAGS) -c -o $(addsuffix .o, $(basename $@)) $<
## Make dependencies
depend.mk: $(HSRCS)
@echo Making dependencies ...
ghc $(HCFLAGS) -M -optdep-f -optdepdepend.mk $^
-include depend.mk
More information about the Glasgow-haskell-users
mailing list