2 import Distribution.PackageDescription
3 import Distribution.Setup
4 import Distribution.Simple
5 import Distribution.Simple.Configure
6 import Distribution.Simple.LocalBuildInfo
7 import Distribution.Simple.Utils
8 import Distribution.Verbosity
10 import System.Environment
14 main = do args <- getArgs
16 pref : ghcpkg : args' ->
17 let verbosity = case args' of
24 _ -> error ("Bad arguments: " ++ show args)
25 in doit pref ghcpkg verbosity
27 error "Missing arguments"
29 doit :: FilePath -> FilePath -> Verbosity -> IO ()
30 doit pref ghcpkg verbosity =
31 do let userHooks = simpleUserHooks
32 copyFlags = CopyFlags {
33 copyDest = NoCopyDest,
34 copyVerbose = verbosity
36 registerFlags = RegisterFlags {
37 regUser = MaybeUserGlobal,
40 regWithHcPkg = Just ghcpkg,
41 regVerbose = verbosity
43 pdFile <- defaultPackageDesc verbosity
44 pd <- readPackageDescription verbosity pdFile
45 lbi <- getPersistBuildConfig
46 let -- XXX These are almighty hacks, shadowing the base
48 extraExtraLibs = if (os == "mingw32") &&
49 (pkgName (package pd) == "base")
50 then ["wsock32", "msvcrt", "kernel32",
53 lib' = case library pd of
55 let ems = filter (("GHC.Prim" /=))
57 lib_bi = libBuildInfo lib
59 extraLibs = extraExtraLibs
64 libBuildInfo = lib_bi'
67 error "Expected a library, but none found"
68 pd' = pd { library = Just lib' }
69 -- When coying, we need to actually give a concrete
70 -- directory to copy to rather than "$topdir"
71 lbi_copy = lbi { prefix = pref }
72 -- When we run GHC we give it a $topdir that includes the
73 -- $compiler/lib/ part of libsubdir, so we only want the
74 -- $pkgid part in the package.conf file. This is a bit of
76 lbi_register = lbi { libsubdir = "$pkgid" }
77 (copyHook simpleUserHooks) pd' lbi_copy userHooks copyFlags
78 (regHook simpleUserHooks) pd' lbi_register userHooks registerFlags