@@ -22,7 +22,10 @@ import Distribution.PackageDescription (PackageDescription(..), Executable(..))
2222import System.Process ( rawSystem )
2323import System.FilePath ( (</>) )
2424import System.Directory ( findExecutable )
25−import Distribution.Simple.Utils (info)
25+import Distribution.Simple.Utils (info, rawSystemExit)
26+import Distribution.Simple.Setup
27+import Distribution.Simple.LocalBuildInfo
28+import Distribution.Verbosity
2629
2730main :: IO ()
2831main = defaultMainWithHooks $ simpleUserHooks {
@@ -30,12 +33,15 @@ main = defaultMainWithHooks $ simpleUserHooks {
3033 hookedPreProcessors = [ppBlobSuffixHandler]
3134 -- ensure that make-pandoc-man-pages doesn't get installed to bindir
3235 , copyHook = \pkgdescr ->
33− (copyHook simpleUserHooks) pkgdescr{ executables =
34− [x | x <- executables pkgdescr, exeName x /= "make-pandoc-man-pages"] }
36+ copyHook simpleUserHooks pkgdescr{ executables =
37+ [x | x <- executables pkgdescr, exeName x `notElem` noInstall] }
3538 , instHook = \pkgdescr ->
36− (instHook simpleUserHooks) pkgdescr{ executables =
37− [x | x <- executables pkgdescr, exeName x /= "make-pandoc-man-pages"] }
39+ instHook simpleUserHooks pkgdescr{ executables =
40+ [x | x <- executables pkgdescr, exeName x `notElem` noInstall] }
41+ , postBuild = makeReferenceFiles
3842 }
43+ where
44+ noInstall = ["make-pandoc-man-pages","make-reference-files"]
3945
4046ppBlobSuffixHandler :: PPSuffixHandler
4147ppBlobSuffixHandler = ("hsb", \_ _ ->
@@ -49,3 +55,13 @@ ppBlobSuffixHandler = ("hsb", \_ _ ->
4955 Nothing -> error "hsb2hs is needed to build this program: cabal install hsb2hs"
5056 return ()
5157 })
58+
59+makeReferenceFiles :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
60+makeReferenceFiles _ bf _ LocalBuildInfo{buildDir=buildDir}
61+ = mapM_
62+ (rawSystemExit verbosity progPath . return)
63+ referenceFormats
64+ where
65+ verbosity = fromFlagOrDefault normal $ buildVerbosity bf
66+ progPath = buildDir </> "make-reference-files" </> "make-reference-files"
67+ referenceFormats = ["docx", "odt"]