diff --git a/Makefile b/Makefile
deleted file mode 100644
index deb350cce15bba5a9f637ac30ce1c2b6170bde21..0000000000000000000000000000000000000000
--- a/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-TOP = .
-include $(TOP)/mk/boilerplate.mk
-
-SUBDIRS = src html doc
-
-include $(TOP)/mk/target.mk
diff --git a/Setup.lhs b/Setup.lhs
new file mode 100644
index 0000000000000000000000000000000000000000..f0ae773bf02f9aeff54527ac5c8194b29d957c9a
--- /dev/null
+++ b/Setup.lhs
@@ -0,0 +1,6 @@
+#!/usr/bin/runhaskell
+
+\begin{code}
+import Distribution.Simple
+main = defaultMain
+\end{code}
diff --git a/haddock.cabal b/haddock.cabal
new file mode 100644
index 0000000000000000000000000000000000000000..6779799ea5eecb38e6b2f195abe9411e3f883428
--- /dev/null
+++ b/haddock.cabal
@@ -0,0 +1,49 @@
+name: Haddock
+version: 0.8
+license: BSD3
+license-file: LICENSE
+copyright: (c) Simon Marlow
+author: Simon Marlow
+maintainer: Simon Marlow <simonmar@microsoft.com>
+stability: stable
+homepage: http://www.haskell.org/haddock/
+synopsis: Haddock is a documentation-generation tool for Haskell libraries
+build-depends: base>=1.0, haskell98>=1.0, mtl>=1.0, network>=1.0
+data-files:
+	html/haddock.css
+	html/haddock.js
+	html/haskell_icon.gif
+	html/minus.gif
+	html/plus.gif
+
+executable: haddock
+hs-source-dirs: src
+main-is: Main.hs
+extensions: CPP
+other-modules:
+	Binary
+	BlockTable
+	Digraph
+	FastMutInt
+	HaddockDB
+	HaddockDevHelp
+	HaddockHH
+	HaddockHH2
+	HaddockHtml
+	HaddockLex
+	HaddockModuleTree
+	HaddockParse
+	HaddockRename
+	HaddockTypes
+	HaddockUtil
+	HaddockVersion
+	HsLexer
+	HsParseMonad
+	HsParseUtils
+	HsParser
+	HsSyn
+	Html
+	Main
+	Map
+	Set
+
diff --git a/html/Makefile b/html/Makefile
deleted file mode 100644
index b10189f00740cecfa244666009740a792185a976..0000000000000000000000000000000000000000
--- a/html/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-TOP = ..
-include $(TOP)/mk/boilerplate.mk
-
-INSTALL_DATAS = haddock.css haddock.js haskell_icon.gif minus.gif plus.gif
-
-include $(TOP)/mk/target.mk
diff --git a/mk/boilerplate.mk b/mk/boilerplate.mk
deleted file mode 100644
index 0f29d4ab3795db4b2b5a0ab18b726078fb125e43..0000000000000000000000000000000000000000
--- a/mk/boilerplate.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-#-----------------------------------------------------------------------------
-# $Id: boilerplate.mk,v 1.1 2002/04/04 16:23:42 simonmar Exp $
-
-# Begin by slurping in the boilerplate from one level up.
-# Remember, TOP is the top level of the innermost level
-# (FPTOOLS_TOP is the fptools top)
-
--include $(TOP)/mk/version.mk
-
-# We need to set TOP to be the TOP that the next level up expects!
-# The TOP variable is reset after the inclusion of the fptools
-# boilerplate, so we stash TOP away first:
-HADDOCK_TOP := $(TOP)
-TOP:=$(TOP)/..
-
-include $(TOP)/mk/boilerplate.mk
-
-# Reset TOP
-TOP:=$(HADDOCK_TOP)
-
-# -----------------------------------------------------------------
-# Everything after this point
-# augments or overrides previously set variables.
-# -----------------------------------------------------------------
-
--include $(TOP)/mk/paths.mk
--include $(TOP)/mk/opts.mk
--include $(TOP)/mk/suffix.mk
diff --git a/mk/config.mk b/mk/config.mk
deleted file mode 100644
index 5675a1e611a840a9dc59409272ff8d1f817396ec..0000000000000000000000000000000000000000
--- a/mk/config.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# Haddock project information
-#
-
-# what to include in a binary distribution
-HaddockMainDir 		= haddock
-HaddockBinDistDirs 	= haddock
-HaddockBinDistDocs 	= haddock/doc
-HaddockBinDistShScripts	= haddock-$(ProjectVersion)
-HaddockBinDistLinks 	= haddock
-
-include $(HaddockMainDir)/mk/version.mk
diff --git a/mk/target.mk b/mk/target.mk
deleted file mode 100644
index dcba624e4b1d659322f2da67bd10d14b307eb84d..0000000000000000000000000000000000000000
--- a/mk/target.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-#-----------------------------------------------------------------------------
-# $Id: target.mk,v 1.1 2002/04/04 16:23:42 simonmar Exp $
-# target.mk project stub
-#
-
-# We need to set TOP to be the TOP that the next level up expects!
-# The TOP variable is reset after the inclusion of the fptools
-# boilerplate, so we stash TOP away first:
-HADDOCK_TOP := $(TOP)
-TOP:=$(TOP)/..
-
-include $(TOP)/mk/target.mk
-
-HADDOCK_INPLACE = $(HADDOCK_TOP)/src/haddock-inplace
-
-# Reset TOP
-TOP:=$(HADDOCK_TOP)
diff --git a/mk/version.mk b/mk/version.mk
deleted file mode 100644
index e454d1f1eb7f0b505a1e89142f9153e90cd97df1..0000000000000000000000000000000000000000
--- a/mk/version.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Project-specific version information.
-#
-# Note:
-#   this config file is intended to centralise all
-#   project version information. To bump up the version
-#   info on your package, edit this file and recompile
-#   all the dependents. This file lives in the source tree.
-#
-
-#
-# haddock project variable settings:
-#
-ProjectName       = Haddock
-ProjectNameShort  = haddock
-ProjectVersion    = 0.7
-ProjectVersionInt = 7
-ProjectPatchLevel = 0
diff --git a/src/Binary.hs b/src/Binary.hs
index f3bc647781239ba25c345b18285c17de29e719c0..f1c9862012161b877998b6cc5eeb84147f5b5b39 100644
--- a/src/Binary.hs
+++ b/src/Binary.hs
@@ -1,4 +1,4 @@
-{-# OPTIONS -cpp #-}
+{-# OPTIONS_GHC -cpp -fglasgow-exts #-}
 --
 -- (c) The University of Glasgow 2002
 --
diff --git a/src/FastMutInt.hs b/src/FastMutInt.hs
index 39f4f99b315e5cb35f35004c23b9d1de6bf9dffc..23001c1fc2e1f6a72f336873e5b742328896a6aa 100644
--- a/src/FastMutInt.hs
+++ b/src/FastMutInt.hs
@@ -1,4 +1,4 @@
-{-# OPTIONS -cpp #-}
+{-# OPTIONS_GHC -cpp -fglasgow-exts #-}
 --
 -- (c) The University of Glasgow 2002
 --
diff --git a/src/HaddockVersion.hs b/src/HaddockVersion.hs
index f3090b4e24365cc08e2263d7eb987f51ef80e090..4cb9427154f68405fb923243dbd5282bfd516549 100644
--- a/src/HaddockVersion.hs
+++ b/src/HaddockVersion.hs
@@ -8,10 +8,11 @@ module HaddockVersion (
 	projectName, projectVersion, projectUrl
    ) where
 
-import Version ( version )
+import Paths_Haddock ( version )
+import Data.Version ( showVersion )
 
 projectName, projectUrl :: String
 projectName = "Haddock"
 projectUrl = "http://www.haskell.org/haddock/"
 
-projectVersion = version
+projectVersion = showVersion version
diff --git a/src/Main.hs b/src/Main.hs
index 0c9cdb0a18c37eaaf16e404069d59af7ccce60ff..bed74040ad6100a8b8a3b8df8b89fbbf681c5a2e 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -1,3 +1,4 @@
+{-# OPTIONS_GHC -fglasgow-exts #-}
 --
 -- Haddock - A Haskell Documentation Tool
 --
@@ -22,6 +23,7 @@ import HsSyn
 import Map ( Map )
 import qualified Map hiding ( Map )
 import Set
+import Paths_Haddock	( getDataDir )
 
 import Control.Exception ( bracket )
 import Control.Monad ( when )
@@ -166,11 +168,7 @@ run flags files = do
       verbose = Flag_Verbose `elem` flags
 
   libdir <- case [str | Flag_Lib str <- flags] of
-		[] -> do maybe_exec_dir <- getBaseDir
-				-- Get directory of executable
-			 case maybe_exec_dir of
-                                       Nothing  -> return "."
-                                       Just dir -> return dir
+		[] -> getDataDir -- provided by Cabal
 		fs -> return (last fs)
 
   let css_file = case [str | Flag_CSS str <- flags] of
@@ -1404,34 +1402,3 @@ toModuleInfo descriptionOpt =
 
 type ErrMsg = String
 type ErrMsgM a = Writer [ErrMsg] a
-
-getBaseDir :: IO (Maybe String)
-#if defined(mingw32_HOST_OS)
-getBaseDir = do let len = (2048::Int) -- plenty, PATH_MAX is 512 under Win32.
-		buf <- mallocArray len
-                ret <- getModuleFileName nullPtr buf len
-                if ret == 0 then free buf >> return Nothing
-                            else do s <- peekCString buf
-                                    free buf
-                                    return (Just (rootDir s))
-  where
-    rootDir s = reverse (dropList "/haddock.exe" (reverse (normalisePath s)))
-
-foreign import stdcall unsafe "GetModuleFileNameA" 
-  getModuleFileName :: Ptr () -> CString -> Int -> IO Int32
-#else
-getBaseDir :: IO (Maybe String) = do return Nothing
-#endif
-normalisePath :: String -> String
--- Just changes '\' to '/'
-
-#if defined(mingw32_HOST_OS)
-normalisePath xs = subst '\\' '/' xs
-subst a b ls = map (\ x -> if x == a then b else x) ls
-#else
-normalisePath xs   = xs
-#endif
-dropList :: [b] -> [a] -> [a]
-dropList [] xs    = xs
-dropList _  xs@[] = xs
-dropList (_:xs) (_:ys) = dropList xs ys
diff --git a/src/Makefile b/src/Makefile
deleted file mode 100644
index d97a1276dfe58b4112bd3a35ab3f1588199c8bef..0000000000000000000000000000000000000000
--- a/src/Makefile
+++ /dev/null
@@ -1,115 +0,0 @@
-TOP = ..
-include $(TOP)/mk/boilerplate.mk
-
-INSTALLING=1
-
-ghc_ge_504 := $(shell if (test $(GhcCanonVersion) -ge 504); then echo YES; else echo NO; fi)
-ghc_ge_603 := $(shell if (test $(GhcCanonVersion) -ge 603); then echo YES; else echo NO; fi)
-
-SRC_HC_OPTS += -fglasgow-exts -cpp
-
-# Use hierarchical libraries for GHC >= 5.04
-ifeq "$(ghc_ge_504)" "YES"
-SRC_HC_OPTS += -package network
-# Monad transformers live in their own package for GHC >= 6.3
-ifeq "$(ghc_ge_603)" "YES"
-SRC_HC_OPTS += -package mtl
-endif
-else
-SRC_HC_OPTS += -package data -package text -package util -package net
-endif
-
-ifeq "$(Windows)" "YES"
-HS_PROG_EXT = .exe
-else
-HS_PROG_EXT = .bin
-endif
-
-HS_PROG = haddock$(HS_PROG_EXT)
-
-# Why HOST platform, not TARGET platform??? Confusing...
-ifeq "$(Windows)" "YES"
-Main_HC_OPTS += -Dmingw32_HOST_OS=1
-endif
-
-HsParser_HC_OPTS      += -Onot
-HaddockParse_HC_OPTS  += -Onot
-
-# -----------------------------------------------------------------------------
-# Create the Version.hs file
-
-VERSION_HS = Version.hs
-EXTRA_SRCS += $(VERSION_HS)
-
-boot :: $(VERSION_HS)
-
-Version.hs : $(TOP)/mk/version.mk
-	@$(RM) -f $(VERSION_HS)
-	@echo "Creating $(VERSION_HS) ... "
-	@echo "module Version where" >>$(VERSION_HS)
-	@echo "version = \"$(ProjectVersion)\"" >> $(VERSION_HS)
-
-# -----------------------------------------------------------------------------
-
-ifeq "$(INSTALLING)" "1"
-ifeq "$(BIN_DIST)"   "1"
-HADDOCKLIB=$$\"\"datadir/haddock
-HADDOCKBIN=$$\"\"libexecdir/$(HS_PROG)
-else
-ifeq "$(TARGETPLATFORM)" "i386-unknown-cygwin32"
-# --mixed is only provided by newer versions of cygpath (1.2 doesn't have it, for instance.)
-#HADDOCKLIB=$(shell cygpath --mixed $(datadir))
-HADDOCKLIB=$(shell cygpath -w $(datadir) | sed -e 's%\\%/%g')
-else
-HADDOCKLIB=$(datadir)
-endif
-HADDOCKBIN=$(libexecdir)/$(HS_PROG)
-endif # BIN_DIST
-else
-ifeq "$(TARGETPLATFORM)" "i386-unknown-cygwin32"
-# See above comment re: --mixed
-#HADDOCKLIB=$(shell cygpath --mixed $(FPTOOLS_TOP_ABS)/haddock/html)
-HADDOCKLIB=$(shell cygpath -w $(FPTOOLS_TOP_ABS)/haddock/html | sed -e 's%\\%/%g')
-else
-HADDOCKLIB=$(FPTOOLS_TOP_ABS)/haddock/html
-endif
-HADDOCKBIN=$(FPTOOLS_TOP_ABS)/haddock/src/$(HS_PROG)
-endif # INSTALLING
-
-HAPPY_OPTS += $(GHC_HAPPY_OPTS)
-
-INSTALLED_SCRIPT_PROG  = haddock-$(ProjectVersion)
-INPLACE_SCRIPT_PROG    = haddock-inplace
-
-ifeq "$(INSTALLING)" "1"
-TOP_PWD 	:= $(prefix)
-SCRIPT_PROG 	=  $(INSTALLED_SCRIPT_PROG)
-ifeq "$(Windows)" "NO"
-LINK	 	=  haddock
-endif
-else
-TOP_PWD 	:= $(FPTOOLS_TOP_ABS)
-SCRIPT_PROG 	=  $(INPLACE_SCRIPT_PROG)
-endif
-
-SCRIPT_OBJS=haddock.sh
-
-INTERP=$(SHELL)
-
-SCRIPT_SUBST_VARS = HADDOCKLIB HADDOCKBIN
-
-# The script isn't installed on MinGW; we run the binary directly
-ifeq "$(Windows)" "NO"
-INSTALL_SCRIPTS += $(SCRIPT_PROG)
-endif
-
-INSTALL_LIBEXECS = $(HS_PROG)
-
-# don't recurse on 'make install'
-#
-ifeq "$(INSTALLING)" "1"
-all clean distclean maintainer-clean ::
-	$(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
-endif
-
-include $(TOP)/mk/target.mk