@@ -6,6 +6,7 @@ import Distribution.PackageDescription
66import Distribution.Simple.LocalBuildInfo
77 (LocalBuildInfo(..), absoluteInstallDirs)
88import Distribution.Verbosity ( Verbosity, silent )
9+import Distribution.Simple.GHC (ghcPackageDbOptions)
910import Distribution.Simple.InstallDirs (mandir, bindir, CopyDest (NoCopyDest))
1011import Distribution.Simple.Utils (copyFiles)
1112import Control.Exception ( bracket_ )
@@ -49,21 +50,36 @@ runTestSuite args _ pkg lbi = do
4950
5051-- | Build man pages from markdown sources in man/
5152makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
52−makeManPages _ flags _ _ = do
53− let verbosity = fromFlag $ buildVerbosity flags
53+makeManPages _ flags _ lbi = do
5454 ds1 <- modifiedDependencies (manDir </> "man1" </> "pandoc.1")
5555 ["README", manDir </> "man1" </> "pandoc.1.template"]
5656 ds2 <- modifiedDependencies (manDir </> "man1" </> "markdown2pdf.1")
5757 [manDir </> "man1" </> "markdown2pdf.1.md"]
5858 ds3 <- modifiedDependencies (manDir </> "man5" </> "pandoc_markdown.5")
5959 ["README", manDir </> "man5" </> "pandoc_markdown.5.template"]
60− let cmd = "runghc -package-conf=dist/package.conf.inplace MakeManPage.hs"
61− let cmd' = if verbosity == silent
62− then cmd
63− else cmd ++ " --verbose"
60+
61+ let distPref = fromFlag (buildDistPref flags)
62+ packageDB =
63+ withPackageDB lbi
64+ ++ [SpecificPackageDB $ distPref </> "package.conf.inplace"]
65+
66+ verbosity = fromFlag $ buildVerbosity flags
67+
68+ args = makeGhcArgs (ghcPackageDbOptions packageDB)
69+ ++ ["MakeManPage.hs"]
70+ args' = if verbosity == silent
71+ then args
72+ else args ++ ["--verbose"]
6473 -- Don't run MakeManPage.hs unless we have to
65− unless (null ds1 && null ds2 && null ds3) $
66− runCommand cmd' >>= waitForProcess >>= exitWith
74+ unless (null ds1 && null ds2 && null ds3) $ do
75+ rawSystem "runghc" args' >>= exitWith
76+
77+-- format arguments to runghc that we wish to pass to ghc
78+-- normally runghc gets it right, unless the argument does
79+-- not begin with a '-' charecter, so we need to give clear
80+-- directions.
81+makeGhcArgs :: [String] -> [String]
82+makeGhcArgs = map ("--ghc-arg="++)
6783
6884manpages :: [FilePath]
6985manpages = ["man1" </> "pandoc.1"