[project @ 2005-03-19 02:03:26 by sof]
[ghc-hetmet.git] / ghc / compiler / main / Packages.lhs
index 8a4009d..06180a1 100644 (file)
@@ -37,10 +37,10 @@ where
 #include "HsVersions.h"
 
 import PackageConfig   
-import DriverState     ( v_Build_tag, v_RTS_Build_tag, v_Static )
 import SysTools                ( getTopDir, getPackageConfigPath )
 import ParsePkgConf    ( loadPackageConfig )
-import CmdLineOpts     ( DynFlags(..), PackageFlag(..), opt_Static )
+import DynFlags                ( dopt, DynFlag(..), DynFlags(..), PackageFlag(..) )
+import StaticFlags     ( opt_Static )
 import Config          ( cProjectVersion )
 import Name            ( Name, nameModule_maybe )
 import Module          ( Module, mkModule )
@@ -201,13 +201,16 @@ readPackageConfigs dflags = do
        -- unless the -no-user-package-conf flag was given.
        -- We only do this when getAppUserDataDirectory is available 
        -- (GHC >= 6.3).
-   appdir <- getAppUserDataDirectory "ghc"
-   let 
+   (exists, pkgconf) <- catch (do
+      appdir <- getAppUserDataDirectory "ghc"
+      let 
         pkgconf = appdir ++ '/':TARGET_ARCH ++ '-':TARGET_OS
                        ++ '-':cProjectVersion ++ "/package.conf"
-   --
-   exists <- doesFileExist pkgconf
-   pkg_map2 <- if (readUserPkgConf dflags && exists)
+      flg <- doesFileExist pkgconf
+      return (flg, pkgconf))
+       -- gobble them all up and turn into False.
+      (\ _ -> return (False, ""))
+   pkg_map2 <- if (dopt Opt_ReadUserPackageConf dflags && exists)
                  then readPackageConfig dflags pkg_map1 pkgconf
                  else return pkg_map1
 
@@ -222,7 +225,7 @@ readPackageConfig
    :: DynFlags -> PackageConfigMap -> FilePath -> IO PackageConfigMap
 readPackageConfig dflags pkg_map conf_file = do
   when (verbosity dflags >= 2) $
-       hPutStrLn stderr ("Reading package config file: "
+       hPutStrLn stderr ("Using package config file: "
                         ++ conf_file)
   proto_pkg_configs <- loadPackageConfig conf_file
   top_dir          <- getTopDir
@@ -433,13 +436,12 @@ getPackageLibraryPath dflags pkgs = do
 getPackageLinkOpts :: DynFlags -> [PackageId] -> IO [String]
 getPackageLinkOpts dflags pkgs = do
   ps <- getExplicitPackagesAnd dflags pkgs
-  tag <- readIORef v_Build_tag
-  rts_tag <- readIORef v_RTS_Build_tag
-  static <- readIORef v_Static
+  let tag = buildTag dflags
+      rts_tag = rtsBuildTag dflags
   let 
-       imp        = if static then "" else "_dyn"
+       imp        = if opt_Static then "" else "_dyn"
        libs p     = map ((++imp) . addSuffix) (hACK (hsLibraries p)) ++ extraLibraries p
-       all_opts p = map ("-l" ++) (libs p) ++ extraLdOpts p
+       all_opts p = map ("-l" ++) (libs p) ++ ldOptions p
 
        suffix     = if null tag then "" else  '_':tag
        rts_suffix = if null rts_tag then "" else  '_':rts_tag
@@ -483,7 +485,7 @@ getPackageLinkOpts dflags pkgs = do
 getPackageExtraCcOpts :: DynFlags -> [PackageId] -> IO [String]
 getPackageExtraCcOpts dflags pkgs = do
   ps <- getExplicitPackagesAnd dflags pkgs
-  return (concatMap extraCcOpts ps)
+  return (concatMap ccOptions ps)
 
 getPackageFrameworkPath  :: DynFlags -> [PackageId] -> IO [String]
 getPackageFrameworkPath dflags pkgs = do
@@ -493,7 +495,7 @@ getPackageFrameworkPath dflags pkgs = do
 getPackageFrameworks  :: DynFlags -> [PackageId] -> IO [String]
 getPackageFrameworks dflags pkgs = do
   ps <- getExplicitPackagesAnd dflags pkgs
-  return (concatMap extraFrameworks ps)
+  return (concatMap frameworks ps)
 
 -- -----------------------------------------------------------------------------
 -- Package Utils