[project @ 2004-11-09 16:59:31 by simonmar]
[ghc-hetmet.git] / ghc / utils / ghc-pkg / Main.hs
index 05c92e3..1c18d5a 100644 (file)
@@ -7,6 +7,7 @@
 module Main where
 
 import Package
+import Version  ( version )
 
 #if __GLASGOW_HASKELL__ >= 504
 import System.Console.GetOpt
@@ -29,7 +30,7 @@ import List ( isPrefixOf, isSuffixOf )
 
 import ParsePkgConfLite
 
-#include "../../includes/config.h"
+#include "../../includes/ghcconfig.h"
 
 #ifdef mingw32_HOST_OS
 import Foreign
@@ -82,11 +83,6 @@ isAction _              = True
 copyright :: String
 copyright = "GHC package manager version " ++ version ++ "\n"
 
--- hackery to convice cpp to splice GHC_PKG_VERSION into a string
-version :: String
-version = tail "\ 
-   \ GHC_PKG_VERSION"
-
 usageHeader :: String -> String
 usageHeader prog = "Usage: " ++ prog ++ " [OPTION...]\n"
 
@@ -256,9 +252,9 @@ checkConfigAccess filename = do
 maybeRestoreOldConfig :: FilePath -> IO () -> IO ()
 maybeRestoreOldConfig filename io
   = my_catch io (\e -> do
-        hPutStr stdout "\nWARNING: an error was encountered while the new \n\ 
-                      \configuration was being written.  Attempting to \n\ 
-                      \restore the old configuration... "
+        hPutStr stdout ("\nWARNING: an error was encountered while the new \n"++
+                         "configuration was being written.  Attempting to \n"++
+                         "restore the old configuration... ")
        renameFile (filename ++ ".old")  filename
         hPutStrLn stdout "done."
        my_throw e
@@ -349,16 +345,15 @@ doesLibExistIn lib d
  | otherwise                = doesFileExist (d ++ '/':lib)
 
 checkGHCiLib :: [String] -> String -> String -> String -> Bool -> IO ()
-checkGHCiLib dirs batch_lib_dir batch_lib_file lib auto_build = do
-  let ghci_lib_file = lib ++ ".o"
-  bs <- mapM (doesLibExistIn ghci_lib_file) dirs
-  case [ dir | (exists,dir) <- zip bs dirs, exists ] of
-        [] | auto_build -> 
-               autoBuildGHCiLib batch_lib_dir batch_lib_file ghci_lib_file
-          | otherwise  -> 
-               hPutStrLn stderr ("warning: can't find GHCi lib `"
-                                        ++ ghci_lib_file ++ "'")
+checkGHCiLib dirs batch_lib_dir batch_lib_file lib auto_build
+  | auto_build = autoBuildGHCiLib batch_lib_dir batch_lib_file ghci_lib_file
+  | otherwise  = do
+      bs <- mapM (doesLibExistIn ghci_lib_file) dirs
+      case [dir | (exists,dir) <- zip bs dirs, exists] of
+        []    -> hPutStrLn stderr ("warning: can't find GHCi lib `" ++ ghci_lib_file ++ "'")
        (_:_) -> return ()
+  where
+    ghci_lib_file = lib ++ ".o"
 
 -- automatically build the GHCi version of a batch lib, 
 -- using ld --whole-archive.
@@ -530,7 +525,7 @@ getExecDir cmd
   where
     len = 2048::Int -- Plenty, PATH_MAX is 512 under Win32.
 
-foreign import stdcall "GetModuleFileNameA" unsafe 
+foreign import stdcall unsafe  "GetModuleFileNameA"
   getModuleFileName :: Ptr () -> CString -> Int -> IO Int32
 #else
 getExecDir :: String -> IO (Maybe String)