The Haskell wiki states that you should use Cabal as your build system. However, it seems to me much more directed at producing packages then just building binaries. Basically, all I want to do is build every *.hs file in my src/ directory into a seperate binary in bin/. This makefile accomplishes this nicely, but I want to learn about Cabal and this seems like a good example to get me started:
GHC = ghc
GHCFLAGS = -outputdir bin
SRC = $(wildcard src/*.hs)
BIN = $(patsubst src/%.hs,%,$(SRC))
all: $(addprefix bin/, $(BIN))
bin/%: src/%.hs
$(GHC) $(GHCFLAGS) $< -o $@
clean:
rm bin/*
The easiest way to get started is to have Cabal generate a
.cabalfile for you that you can use as a starting point. To do this, go into your project directory and typeIt will then ask you a bunch of questions about your package. Some questions like author name and email only really matter if you plan on uploading your package to Hackage, so you can leave those blank if you want. After doing that, you can then edit the
.cabalfile to customize it. The generated file will contain a bunch of comments which should help you get started. After that, simply typeThe binary will by default be placed in
./dist/build/<name>/.