summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Kolmodin <kolmodin@gentoo.org>2009-05-06 20:55:17 +0000
committerLennart Kolmodin <kolmodin@gentoo.org>2009-05-06 20:55:17 +0000
commitf22e68c8c066ff792ab86fba407343e938a50ee9 (patch)
treed0f3ce40198ca62ebfb36f9871eeb8a5614c4ce8 /dev-haskell/haddock/files
parentamd64 stable, bug #264594 (diff)
downloadhistorical-f22e68c8c066ff792ab86fba407343e938a50ee9.tar.gz
historical-f22e68c8c066ff792ab86fba407343e938a50ee9.tar.bz2
historical-f22e68c8c066ff792ab86fba407343e938a50ee9.zip
Fixes for dev-haskell/haddock
Package-Manager: portage-2.1.6.12/cvs/Linux x86_64
Diffstat (limited to 'dev-haskell/haddock/files')
-rw-r--r--dev-haskell/haddock/files/haddock-2.4.2-Setup.hs72
1 files changed, 72 insertions, 0 deletions
diff --git a/dev-haskell/haddock/files/haddock-2.4.2-Setup.hs b/dev-haskell/haddock/files/haddock-2.4.2-Setup.hs
new file mode 100644
index 000000000000..31ee04eb8168
--- /dev/null
+++ b/dev-haskell/haddock/files/haddock-2.4.2-Setup.hs
@@ -0,0 +1,72 @@
+{-
+Setup.hs: based on code from ghc-paths of Simon Marlow
+Fixed to not use the .buildinfo, and use -Dfoo flags for both libraries and executables
+-}
+import Distribution.Simple
+import Distribution.Simple.Setup
+import Distribution.PackageDescription
+import Distribution.Simple.LocalBuildInfo
+import Distribution.InstalledPackageInfo
+import Distribution.Simple.Program
+import Distribution.Simple.PackageIndex as Pkg
+
+import System.Exit
+import System.IO
+import Data.IORef
+import Data.Char
+import Data.Maybe
+
+main = defaultMainWithHooks simpleUserHooks {
+ confHook = myCustomConfHook
+ }
+ where
+ myCustomConfHook :: (Either GenericPackageDescription PackageDescription, HookedBuildInfo)
+ -> ConfigFlags
+ -> IO LocalBuildInfo
+ myCustomConfHook egpdpdhbi flags = do
+ -- get the default LBI
+ lbi <- confHook simpleUserHooks egpdpdhbi flags
+ let programs = withPrograms lbi
+
+ libdir_ <- rawSystemProgramStdoutConf (fromFlag (configVerbosity flags))
+ ghcProgram programs ["--print-libdir"]
+ let libdir = reverse $ dropWhile isSpace $ reverse libdir_
+
+ ghc_pkg = case lookupProgram ghcPkgProgram programs of
+ Just p -> programPath p
+ Nothing -> error "ghc-pkg was not found"
+ ghc = case lookupProgram ghcProgram programs of
+ Just p -> programPath p
+ Nothing -> error "ghc was not found"
+
+ -- figure out docdir from base's haddock-html field
+ base_pkg = case searchByName (installedPkgs lbi) "base" of
+ None -> error "no base package"
+ Unambiguous (x:_) -> x
+ _ -> error "base ambiguous"
+ base_html = case haddockHTMLs base_pkg of
+ [] -> ""
+ (x:_) -> x
+ docdir = fromMaybe base_html $
+ fmap reverse (stripPrefix (reverse "/libraries/base")
+ (reverse base_html))
+
+ let programs' = userSpecifyArgs "ghc" ["-DGHC_PATHS_GHC_PKG=" ++ show ghc_pkg,
+ "-DGHC_PATHS_GHC=" ++ show ghc,
+ "-DGHC_PATHS_LIBDIR=" ++ show libdir,
+ "-DGHC_PATHS_DOCDIR=" ++ show docdir
+ ] programs
+ -- returning our modified LBI that includes the -D definitions
+ return lbi { withPrograms = programs' }
+
+die :: String -> IO a
+die msg = do
+ hFlush stdout
+ hPutStr stderr msg
+ exitWith (ExitFailure 1)
+
+stripPrefix :: Eq a => [a] -> [a] -> Maybe [a]
+stripPrefix [] ys = Just ys
+stripPrefix (x:xs) (y:ys)
+ | x == y = stripPrefix xs ys
+stripPrefix _ _ = Nothing