Haskell Platform from Source on Unix-Like

Albert Y. C. Lai, trebla [at] vex [dot] net

Why you may like to build Haskell Platform from source: there is no binary package for your OS; there are binary packages for your OS but you don't like them (versions, directories, privileges). (If you have none of those problems, good for you!)

This article is for Unix-like OSes, generalizing from what works on Ubuntu Linux.

Required C Libraries and Headers

Haskell Platform and GHC rely on some C libraries. You need them and their headers present to build Haskell Platform, not to mention use. As a partial test of presense, look for the following header files in /usr/include, /usr/local/include, etc.

namea.k.a.a header fileremarks
editlinelibedit-devhistedit.honly for Haskell Platform 2009.2.0.2
libbsdlibbsd-devlibutil.h
gmplibgmp3-devgmp.h
zlibzlib1g-devzlib.h
GLUTfreeglut3-devGL/glut.halso OpenGL, X... too many to list but your package manager likely gets them all from GLUT

Planning Ahead: Choose Where to Install

By default, Haskell Platform files will be scattered over various places in /usr/local. Same story for GHC if you install it yourself.

You may dislike this for one of two reasons. When you want to delete files, they are harder to hunt down. If you want several versions of Haskell Platform or GHC to co-exist, they step over each other in /usr/local/bin (Haskell Platform contains executables too).

How I do it: I create one directory (say /usr/local/haskell-platform-2011.2.0.0) and put one GHC and one Haskell Platform inside. I adjust my PATH environment variable accordingly (add /usr/local/haskell-platform-2011.2.0.0/bin). Switching versions means just editing PATH. You could further separate GHC and Haskell Platform into two directories if you want.

GHC

You must install GHC yourself to build Haskell Platform from source. While binary packages of Haskell Platform include GHC, the source does not. Any means of installing GHC is fine:

There is a matching version of GHC for each version of Haskell Platform, and it is seldom the “current released” version. Normally you should stick to the matching version of GHC; the benefits are that the matched pair has been well-tested together and is well-supported. Using a slightly older or newer GHC is possible but slightly more risky.

Haskell Platform versionGHC version
2011.4.0.07.0.4
2011.2.0.17.0.3
2011.2.0.07.0.2
2010.2.0.06.12.3
2010.1.0.06.12.1
2009.2.0.26.10.4

Build Haskell Platform

Look for “Build from source” and get the .tar.gz file on “Haskell Platform for Linux”.

Unpack and change directory into the unpacked.

Configure with:

./configure --prefix=chosen-directory

If you lack some C libs, it tells you now.

If you use a mismatched GHC, it also finds out now, and you can insist with

./configure --prefix=chosen-directory --enable-unsupported-ghc-version

If there is no problem so far, you can build now, and it will take 5-10 minutes:

make

If it builds successfully, you can install now, and this needs enough privilege:

make install

When it finishes, it instructs you to initialize “the package list” with the following. What it does: downloads and caches the list of libs available on Hackage.

cabal update

I have more Haskell Notes and Examples