85341c299de60894cc03b6c92808d14cd4fbb162
[ghc.git] / libraries / cabal-bin.hs
1
2 module Cabal (main) where
3
4 import Data.Maybe
5 import Distribution.PackageDescription
6 import Distribution.PackageDescription.Parse
7 import Distribution.Simple
8 import Distribution.Simple.Utils
9 import Distribution.Verbosity
10 import System.Directory
11 import System.Environment
12 import System.FilePath
13
14 import qualified Distribution.Make as Make
15 import qualified Distribution.Simple as Simple
16
17 setupProg :: FilePath
18 setupProg = "./Setup"
19
20 main :: IO ()
21 main = do
22 let verbosity = verbose
23 exists <- doesFileExist setupProg
24 args <- getArgs
25 if exists then rawSystemExit verbosity setupProg args
26 else do
27 gpdFile <- defaultPackageDesc verbosity
28 gpd <- readPackageDescription verbosity gpdFile
29 let pd = packageDescription gpd
30 case buildType pd of
31 Just Simple -> Simple.defaultMainArgs args
32 Just Make -> Make.defaultMainArgs args
33 Just Configure -> defaultMainWithHooksArgs autoconfUserHooks args
34 _ | packageName pd == PackageName "Cabal" ->
35 -- Cabal is special...*sigh*
36 Simple.defaultMainArgs args
37 | otherwise -> die "cabal: Don't know what to do!"
38