1#!/usr/bin/env runhaskell
2-- Cf. <http://www.mail-archive.com/haskell-cafe@haskell.org/msg59984.html>
3-- <http://www.haskell.org/pipermail/haskell-cafe/2008-December/051785.html>
4
5{-# OPTIONS_GHC -Wall -fwarn-tabs -fno-warn-missing-signatures #-}
6module Main (main) where
7import Distribution.Simple
8import Distribution.Simple.LocalBuildInfo (withPrograms)
9import Distribution.Simple.Program        (userSpecifyArgs)
10----------------------------------------------------------------
11
12-- | Define __HADDOCK__ when building documentation.
13main :: IO ()
14main = defaultMainWithHooks
15    $ simpleUserHooks `modify_haddockHook` \oldHH pkg lbi hooks flags -> do
16
17        -- Call the old haddockHook with a modified LocalBuildInfo
18        (\lbi' -> oldHH pkg lbi' hooks flags)
19            $ lbi `modify_withPrograms` \oldWP ->
20                userSpecifyArgs "haddock" ["--optghc=-D__HADDOCK__"] oldWP
21
22
23modify_haddockHook  hooks f = hooks { haddockHook  = f (haddockHook  hooks) }
24modify_withPrograms lbi   f = lbi   { withPrograms = f (withPrograms lbi)   }
25
26----------------------------------------------------------------
27----------------------------------------------------------- fin.
28