aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsimonmar <simonmar@microsoft.com>2005-10-14 23:11:19 +0000
committersimonmar <simonmar@microsoft.com>2005-10-14 23:11:19 +0000
commit21c7ac8d714be74903755ed2d6ee3716ab77a727 (patch)
tree98fe80aceff6746cfbf8eb631a42ef1101198150
parentb2edbedbcf19f9ec187128574f0dba29d3373d41 (diff)
First cut of Cabal build system
-rw-r--r--Makefile6
-rw-r--r--Setup.lhs6
-rw-r--r--haddock.cabal49
-rw-r--r--html/Makefile6
-rw-r--r--mk/boilerplate.mk28
-rw-r--r--mk/config.mk12
-rw-r--r--mk/target.mk17
-rw-r--r--mk/version.mk18
-rw-r--r--src/Binary.hs2
-rw-r--r--src/FastMutInt.hs2
-rw-r--r--src/HaddockVersion.hs5
-rw-r--r--src/Main.hs39
-rw-r--r--src/Makefile115
13 files changed, 63 insertions, 242 deletions
diff --git a/Makefile b/Makefile
deleted file mode 100644
index deb350cc..00000000
--- 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 00000000..f0ae773b
--- /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 00000000..6779799e
--- /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 b10189f0..00000000
--- 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 0f29d4ab..00000000
--- 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 5675a1e6..00000000
--- 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 dcba624e..00000000
--- 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 e454d1f1..00000000
--- 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 f3bc6477..f1c98620 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 39f4f99b..23001c1f 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 f3090b4e..4cb94271 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 0c9cdb0a..bed74040 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 d97a1276..00000000
--- 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