From ed061b91c8e3247e1d3b1538eca24687adf0e575 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 6 Oct 2013 18:04:18 -0700 Subject: Setup.hs: Better way of handling man page building. Previously we tried to remove make-pandoc-man-pages from the list of packages to be haddocked, installed, copied, etc. It works better to set 'Buildable: False' on make-pandoc-man-pages, then have the buildHook temporarily set Buildable to True. This allows make-pandoc-man-pages to be built (and used in generating the man pages), but not installed. --- Setup.hs | 17 +++++++++-------- pandoc.cabal | 4 +++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Setup.hs b/Setup.hs index 4245df203..e2779e65b 100644 --- a/Setup.hs +++ b/Setup.hs @@ -4,7 +4,7 @@ import Distribution.Simple import Distribution.Simple.PreProcess import Distribution.Simple.Setup (copyDest, copyVerbosity, fromFlag, installVerbosity, BuildFlags(..)) -import Distribution.PackageDescription (PackageDescription(..), Executable(..)) +import Distribution.PackageDescription (PackageDescription(..), Executable(..), BuildInfo(..)) import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..), absoluteInstallDirs) import Distribution.Verbosity ( Verbosity, silent ) @@ -19,18 +19,19 @@ import System.Exit main :: IO () main = do defaultMainWithHooks $ simpleUserHooks { - postBuild = makeManPages + buildHook = \pkgdescr -> + (buildHook simpleUserHooks) pkgdescr{ executables = + [x | x <- executables pkgdescr, + exeName x /= "make-pandoc-man-pages"] ++ + [x{ buildInfo = (buildInfo x){ buildable = True } } + | x <- executables pkgdescr, + exeName x == "make-pandoc-man-pages"] } + , postBuild = makeManPages , postCopy = \ _ flags pkg lbi -> installManpages pkg lbi (fromFlag $ copyVerbosity flags) (fromFlag $ copyDest flags) , postInst = \ _ flags pkg lbi -> installManpages pkg lbi (fromFlag $ installVerbosity flags) NoCopyDest - , copyHook = \pkgdescr -> - (copyHook simpleUserHooks) pkgdescr{ executables = - [x | x <- executables pkgdescr, exeName x /= "make-pandoc-man-pages"] } - , instHook = \pkgdescr -> - (instHook simpleUserHooks) pkgdescr{ executables = - [x | x <- executables pkgdescr, exeName x /= "make-pandoc-man-pages"] } , hookedPreProcessors = [ppBlobSuffixHandler] } exitWith ExitSuccess diff --git a/pandoc.cabal b/pandoc.cabal index a18e1cff4..71f1b1f62 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -361,10 +361,12 @@ Executable pandoc Main-Is: pandoc.hs Buildable: True --- NOTE: A trick in Setup.hs makes sure this won't be installed: Executable make-pandoc-man-pages Main-Is: make-pandoc-man-pages.hs Hs-Source-Dirs: man + Buildable: False + -- Setup.hs will make this look buildable in build phase, + -- but it won't be copied/installed Build-Depends: pandoc, base >= 4.2 && < 5, directory >= 1 && < 1.3, -- cgit v1.2.3