diff options
author | Lennart Kolmodin <kolmodin@gentoo.org> | 2009-05-06 20:55:17 +0000 |
---|---|---|
committer | Lennart Kolmodin <kolmodin@gentoo.org> | 2009-05-06 20:55:17 +0000 |
commit | e7f14c3c5bb09c60716ebcef91300fb8cd21377a (patch) | |
tree | 379622f80b95db13f779f1c3c19bea87c44d8305 /dev-haskell/haddock/files | |
parent | amd64 stable, bug #264594 (diff) | |
download | gentoo-2-e7f14c3c5bb09c60716ebcef91300fb8cd21377a.tar.gz gentoo-2-e7f14c3c5bb09c60716ebcef91300fb8cd21377a.tar.bz2 gentoo-2-e7f14c3c5bb09c60716ebcef91300fb8cd21377a.zip |
Fixes for dev-haskell/haddock
(Portage version: 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.hs | 72 |
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 |