add --enable-shared to configure, and $(BuildSharedLibs) to the build system
[ghc.git] / libraries / cabal-bin.hs
1
2 module Main (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 unprocessedArgs <- getArgs
23 let verbosity = verbose
24 case unprocessedArgs of
25 ghc : packageConf : args ->
26 doit verbosity ghc packageConf args
27 _ -> die "Bad args"
28
29 doit :: Verbosity -> FilePath -> FilePath -> [String] -> IO ()
30 doit verbosity ghc packageConf args = do
31 exists <- doesFileExist setupProg
32 if exists then rawSystemExit verbosity setupProg args
33 else do
34 gpdFile <- defaultPackageDesc verbosity
35 gpd <- readPackageDescription verbosity gpdFile
36 let pd = packageDescription gpd
37 case buildType pd of
38 Just Simple -> Simple.defaultMainArgs args
39 Just Make -> Make.defaultMainArgs args
40 Just Configure -> defaultMainWithHooksArgs autoconfUserHooks args
41 _ | packageName pd == PackageName "Cabal" ->
42 -- Cabal is special...*sigh*
43 Simple.defaultMainArgs args
44 | otherwise -> runSetup verbosity ghc packageConf args
45
46 runSetup :: Verbosity -> FilePath -> FilePath -> [String] -> IO ()
47 runSetup verbosity ghc packageConf args = do
48 rawSystemExit verbosity ghc ["-package-conf", packageConf,
49 "--make", "Setup", "-o", "Setup"]
50 rawSystemExit verbosity "./Setup" args
51