- modHook f pd lbi us flags
- = let idts = installDirTemplates lbi
- idts' = idts { prefix = toPathTemplate myPrefix,
- libdir = toPathTemplate myLibdir,
- libsubdir = toPathTemplate "$pkgid",
- docdir = toPathTemplate (myDocdir </> "$pkgid"),
- htmldir = toPathTemplate "$docdir" }
- progs = withPrograms lbi
- prog = ConfiguredProgram {
- programId = programName ghcPkgProgram,
- programVersion = Nothing,
- programArgs = ["--global-conf", ghcpkgconf]
- ++ if not (null myDestDir)
- then ["--force"]
- else [],
- programLocation = UserSpecified ghcpkg
+ modHook relocatableBuild f pd lbi us flags
+ = do let verbosity = normal
+ idts = installDirTemplates lbi
+ idts' = idts {
+ prefix = toPathTemplate $
+ if relocatableBuild
+ then "$topdir"
+ else myPrefix,
+ libdir = toPathTemplate $
+ if relocatableBuild
+ then "$topdir"
+ else myLibdir,
+ libsubdir = toPathTemplate "$pkgid",
+ docdir = toPathTemplate $
+ if relocatableBuild
+ then "$topdir/../doc/html/libraries/$pkgid"
+ else (myDocdir </> "$pkgid"),
+ htmldir = toPathTemplate "$docdir"
+ }
+ progs = withPrograms lbi
+ ghcProg = ConfiguredProgram {
+ programId = programName ghcProgram,
+ programVersion = Nothing,
+ programDefaultArgs = ["-B" ++ topdir],
+ programOverrideArgs = [],
+ programLocation = UserSpecified ghc
+ }
+ ghcpkgconf = topdir </> "package.conf.d"
+ ghcPkgProg = ConfiguredProgram {
+ programId = programName ghcPkgProgram,
+ programVersion = Nothing,
+ programDefaultArgs = ["--global-conf",
+ ghcpkgconf]
+ ++ if not (null myDestDir)
+ then ["--force"]
+ else [],
+ programOverrideArgs = [],
+ programLocation = UserSpecified ghcpkg
+ }
+ stripProg = ConfiguredProgram {
+ programId = programName stripProgram,
+ programVersion = Nothing,
+ programDefaultArgs = [],
+ programOverrideArgs = [],
+ programLocation = UserSpecified strip
+ }
+ progs' = updateProgram ghcProg
+ $ updateProgram ghcPkgProg
+ $ updateProgram stripProg
+ progs
+ instInfos <- dump verbosity ghcPkgProg GlobalPackageDB
+ let installedPkgs' = PackageIndex.fromList instInfos
+ let mlc = libraryConfig lbi
+ mlc' = case mlc of
+ Just lc ->
+ let cipds = componentPackageDeps lc
+ cipds' = [ (fixupPackageId instInfos ipid, pid)
+ | (ipid,pid) <- cipds ]
+ in Just $ lc {
+ componentPackageDeps = cipds'
+ }
+ Nothing -> Nothing
+ lbi' = lbi {
+ libraryConfig = mlc',
+ installedPkgs = installedPkgs',
+ installDirTemplates = idts',
+ withPrograms = progs'