Refactor case-merging and identical-alternative optimisations
[ghc-hetmet.git] / utils / ghc-cabal / ghc-cabal.hs
index 9a99ad4..ca26ca4 100644 (file)
@@ -34,10 +34,10 @@ main = do args <- getArgs
                   runHaddock distDir dir args'
               "check" : dir : [] ->
                   doCheck dir
-              "install" : ghc : ghcpkg : topdir : directory : distDir
+              "install" : ghc : ghcpkg : strip : topdir : directory : distDir
                         : myDestDir : myPrefix : myLibdir : myDocdir
                         : relocatableBuild : args' ->
-                  doInstall ghc ghcpkg topdir directory distDir
+                  doInstall ghc ghcpkg strip topdir directory distDir
                             myDestDir myPrefix myLibdir myDocdir
                             relocatableBuild args'
               "configure" : args' -> case break (== "--") args' of
@@ -139,10 +139,10 @@ runHaddock distdir directory args
           = f pd lbi us flags
 
 doInstall :: FilePath -> FilePath -> FilePath -> FilePath -> FilePath
-          -> FilePath -> FilePath -> FilePath -> FilePath -> String
-          -> [String]
+          -> FilePath -> FilePath -> FilePath -> FilePath -> FilePath
+          -> String -> [String]
           -> IO ()
-doInstall ghc ghcpkg topdir directory distDir
+doInstall ghc ghcpkg strip topdir directory distDir
           myDestDir myPrefix myLibdir myDocdir
           relocatableBuildStr args
  = withCurrentDirectory directory $ do
@@ -198,8 +198,8 @@ doInstall ghc ghcpkg topdir directory distDir
                             libsubdir = toPathTemplate "$pkgid",
                             docdir    = toPathTemplate $
                                             if relocatableBuild
-                                            then "$topdir/$pkg"
-                                            else (myDocdir </> "$pkg"),
+                                            then "$topdir/$pkgid"
+                                            else (myDocdir </> "$pkgid"),
                             htmldir   = toPathTemplate "$docdir"
                         }
                 progs = withPrograms lbi
@@ -220,8 +220,16 @@ doInstall ghc ghcpkg topdir directory distDir
                                                   else [],
                                  programLocation = UserSpecified ghcpkg
                              }
+                stripProg = ConfiguredProgram {
+                              programId = programName stripProgram,
+                              programVersion = Nothing,
+                              programArgs = [],
+                              programLocation = UserSpecified strip
+                          }
                 progs' = updateProgram ghcProg
-                       $ updateProgram ghcPkgProg progs
+                       $ updateProgram ghcPkgProg
+                       $ updateProgram stripProg
+                         progs
             instInfos <- dump verbosity ghcPkgProg GlobalPackageDB
             let installedPkgs' = PackageIndex.fromList instInfos
             let mlc = libraryConfig lbi
@@ -302,7 +310,10 @@ generate config_args distdir directory
               let ipid = InstalledPackageId (display (packageId pd) ++ "-inplace")
               let installedPkgInfo = inplaceInstalledPackageInfo cwd distdir
                                          pd lib lbi clbi
-                  final_ipi = installedPkgInfo{ Installed.installedPackageId = ipid }
+                  final_ipi = installedPkgInfo {
+                                  Installed.installedPackageId = ipid,
+                                  Installed.haddockHTMLs = ["../" ++ display (packageId pd)]
+                              }
                   content = Installed.showInstalledPackageInfo final_ipi ++ "\n"
               writeFileAtomic (distdir </> "inplace-pkg-config") content
           _ -> error "Inconsistent lib components; can't happen?"