Tell ghc-cabal what strip program to use
[ghc-hetmet.git] / utils / ghc-cabal / ghc-cabal.hs
index 29e0f5c..ef4e989 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
@@ -220,18 +220,26 @@ 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.listToInstalledPackageIndex
-                                     instInfos
+            let installedPkgs' = PackageIndex.fromList instInfos
             let mlc = libraryConfig lbi
                 mlc' = case mlc of
                        Just lc ->
-                           let cipds = componentInstalledPackageDeps lc
-                               cipds' = map (fixupPackageId instInfos) cipds
+                           let cipds = componentPackageDeps lc
+                               cipds' = [ (fixupPackageId instInfos ipid, pid)
+                                        | (ipid,pid) <- cipds ]
                            in Just $ lc {
-                                         componentInstalledPackageDeps = cipds'
+                                         componentPackageDeps = cipds'
                                      }
                        Nothing -> Nothing
                 lbi' = lbi {
@@ -335,12 +343,11 @@ generate config_args distdir directory
           -- stricter than gnu ld). Thus we remove the ldOptions for
           -- GHC's rts package:
           hackRtsPackage index =
-            case PackageIndex.lookupInstalledPackageByName index (PackageName "rts") of
-              [rts] -> PackageIndex.addToInstalledPackageIndex rts { Installed.ldOptions = [] } index
+            case PackageIndex.lookupPackageName index (PackageName "rts") of
+              [(_,[rts])] -> PackageIndex.insert rts{ Installed.ldOptions = [] } index
               _ -> error "No (or multiple) ghc rts package is registered!!"
 
-          dep_ids = map (packageId.getLocalPackageInfo lbi) $
-                       externalPackageDeps lbi
+          dep_ids = map snd (externalPackageDeps lbi)
 
       let variablePrefix = directory ++ '_':distdir
       let xs = [variablePrefix ++ "_VERSION = " ++ display (pkgVersion (package pd)),
@@ -364,12 +371,12 @@ generate config_args distdir directory
                 variablePrefix ++ "_CC_OPTS = " ++ unwords (ccOptions bi),
                 variablePrefix ++ "_CPP_OPTS = " ++ unwords (cppOptions bi),
                 variablePrefix ++ "_LD_OPTS = " ++ unwords (ldOptions bi),
-                variablePrefix ++ "_DEP_INCLUDE_DIRS = " ++ unwords (forDeps Installed.includeDirs),
+                variablePrefix ++ "_DEP_INCLUDE_DIRS = " ++ unwords (wrap $ forDeps Installed.includeDirs),
                 variablePrefix ++ "_DEP_CC_OPTS = "    ++ unwords (forDeps Installed.ccOptions),
-                variablePrefix ++ "_DEP_LIB_DIRS = "   ++ unwords (forDeps Installed.libraryDirs),
+                variablePrefix ++ "_DEP_LIB_DIRS = "   ++ unwords (wrap $ forDeps Installed.libraryDirs),
                 variablePrefix ++ "_DEP_EXTRA_LIBS = " ++ unwords (forDeps Installed.extraLibraries),
                 variablePrefix ++ "_DEP_LD_OPTS = "    ++ unwords (forDeps Installed.ldOptions)]
       writeFile (distdir ++ "/package-data.mk") $ unlines xs
   where
      escape = foldr (\c xs -> if c == '#' then '\\':'#':xs else c:xs) []
-
+     wrap = map (\s -> "\'" ++ s ++ "\'")