Use cabal configurations rather than Setup hacks
authorIan Lynagh <igloo@earth.li>
Sun, 29 Jul 2007 13:21:57 +0000 (13:21 +0000)
committerIan Lynagh <igloo@earth.li>
Sun, 29 Jul 2007 13:21:57 +0000 (13:21 +0000)
Setup.hs
base.cabal

index a983953..33d56cc 100644 (file)
--- a/Setup.hs
+++ b/Setup.hs
@@ -14,28 +14,20 @@ import Distribution.Simple.LocalBuildInfo
 import Distribution.Simple.Utils
 import System.Cmd
 import System.FilePath
-import System.Info
 
 main :: IO ()
 main = do let hooks = defaultUserHooks {
-                  confHook = add_extra_deps
-                           $ confHook defaultUserHooks,
                   buildHook = build_primitive_sources
                             $ filter_modules_hook
                             $ buildHook defaultUserHooks,
                   makefileHook = build_primitive_sources
                                $ filter_modules_hook
                                $ makefileHook defaultUserHooks,
-                  regHook = add_extra_libs
-                          $ regHook defaultUserHooks,
                   instHook = filter_modules_hook
                            $ instHook defaultUserHooks }
           defaultMainWithHooks hooks
 
 type Hook a = PackageDescription -> LocalBuildInfo -> UserHooks -> a -> IO ()
-type ConfHook = PackageDescription -> ConfigFlags -> IO LocalBuildInfo
-
--- type PDHook = PackageDescription -> ConfigFlags -> IO ()
 
 build_primitive_sources :: Hook a -> Hook a
 build_primitive_sources f pd lbi uhs x
@@ -54,53 +46,11 @@ build_primitive_sources f pd lbi uhs x
 
 filter_modules_hook :: Hook a -> Hook a
 filter_modules_hook f pd lbi uhs x
- = let build_filter = case compilerFlavor $ compiler lbi of
-                          GHC -> forGHCBuild
-                          _ -> isPortableBuild
-       lib' = case library pd of
+ = let lib' = case library pd of
                   Just lib ->
-                      let ems = filter build_filter (exposedModules lib)
+                      let ems = filter ("GHC.Prim" /=) (exposedModules lib)
                       in lib { exposedModules = ems }
                   Nothing -> error "Expected a library"
        pd' = pd { library = Just lib' }
    in f pd' lbi uhs x
 
-isPortableBuild :: String -> Bool
-isPortableBuild s
- | "GHC" `isPrefixOf` s = False
- | "Data.Generics" `isPrefixOf` s = False
- | otherwise = s `notElem` ["Foreign.Concurrent", "System.Timeout"]
-
-forGHCBuild :: String -> Bool
-forGHCBuild = ("GHC.Prim" /=)
-
-add_extra_deps :: ConfHook -> ConfHook
-add_extra_deps f pd cf
- = do lbi <- f pd cf
-      case compilerFlavor (compiler lbi) of
-          GHC ->
-              do -- Euch. We should just add the right thing to the lbi
-                 -- ourselves rather than rerunning configure.
-                 let pd' = pd { buildDepends = Dependency "rts" AnyVersion
-                                             : buildDepends pd }
-                 f pd' cf
-          _ ->
-              return lbi
-
-add_extra_libs :: Hook a -> Hook a
-add_extra_libs f pd lbi uhs x
- = let pd' = if (os == "mingw32") && (compilerFlavor (compiler lbi) == GHC)
-             then case library pd of
-                  Just lib ->
-                      let lib_bi = libBuildInfo lib
-                          lib_bi' = lib_bi { extraLibs = "wsock32"
-                                                       : "msvcrt"
-                                                       : "kernel32"
-                                                       : "user32"
-                                                       : "shell32"
-                                                       : extraLibs lib_bi }
-                          lib' = lib { libBuildInfo = lib_bi' }
-                      in pd { library = Just lib' }
-                  Nothing -> error "Expected a library"
-             else pd
-   in f pd' lbi uhs x
index 0d79130..14aa264 100644 (file)
-name:          base
-version:       2.1
-license:       BSD3
-license-file:  LICENSE
-maintainer:    libraries@haskell.org
-synopsis:      Basic libraries
+name:        base
+version:    2.1
+license:    BSD3
+license-file:    LICENSE
+maintainer:    libraries@haskell.org
+synopsis:    Basic libraries
 description:
-       This package contains the Prelude and its support libraries,
-       and a large collection of useful libraries ranging from data
-       structures to parsing combinators and debugging utilities.
-exposed-modules:
-       Control.Applicative,
-       Control.Arrow,
-       Control.Concurrent,
-       Control.Concurrent.Chan,
-       Control.Concurrent.MVar,
-       Control.Concurrent.QSem,
-       Control.Concurrent.QSemN,
-       Control.Concurrent.SampleVar,
-       Control.Exception,
-       Control.Monad,
-       Control.Monad.Fix,
-       Control.Monad.Instances,
-       Control.Monad.ST,
-       Control.Monad.ST.Lazy,
-       Control.Monad.ST.Strict,
-       Data.Array,
-       Data.Array.Base,
-       Data.Array.Diff,
-       Data.Array.IArray,
-       Data.Array.IO,
-       Data.Array.MArray,
-       Data.Array.ST,
-       Data.Array.Storable,
-       Data.Array.Unboxed,
-       Data.Bits,
-       Data.Bool,
-       Data.ByteString,
-       Data.ByteString.Char8,
-       Data.ByteString.Lazy
-       Data.ByteString.Lazy.Char8
-       Data.ByteString.Base
-       Data.ByteString.Fusion
-       Data.Char,
-       Data.Complex,
-       Data.Dynamic,
-       Data.Either,
-       Data.Eq,
-       Data.Foldable,
-       Data.Fixed,
-       Data.Function,
-       Data.Generics,
-       Data.Generics.Aliases,
-       Data.Generics.Basics,
-       Data.Generics.Instances,
-       Data.Generics.Schemes,
-       Data.Generics.Text,
-       Data.Generics.Twins,
-       Data.Graph,
-       Data.HashTable,
-       Data.IORef,
-       Data.Int,
-       Data.IntMap,
-       Data.IntSet,
-       Data.Ix,
-       Data.List,
-       Data.Maybe,
-       Data.Map,
-       Data.Monoid,
-       Data.Ord,
-       Data.PackedString,
-       Data.Ratio,
-       Data.STRef,
-       Data.STRef.Lazy,
-       Data.STRef.Strict,
-       Data.Sequence,
-       Data.Set,
-       Data.String,
-       Data.Tree,
-       Data.Traversable,
-       Data.Tuple,
-       Data.Typeable,
-       Data.Unique,
-       Data.Version,
-       Data.Word,
-       Debug.Trace,
-       Foreign,
-       Foreign.C,
-       Foreign.C.Error,
-       Foreign.C.String,
-       Foreign.C.Types,
-       Foreign.Concurrent,
-       Foreign.ForeignPtr,
-       Foreign.Marshal,
-       Foreign.Marshal.Alloc,
-       Foreign.Marshal.Array,
-       Foreign.Marshal.Error,
-       Foreign.Marshal.Pool,
-       Foreign.Marshal.Utils,
-       Foreign.Ptr,
-       Foreign.StablePtr,
-       Foreign.Storable,
-       GHC.Arr,
-       GHC.Base,
-       GHC.Conc,
-       GHC.ConsoleHandler,
-       GHC.Dotnet,
-       GHC.Enum,
-       GHC.Environment,
-       GHC.Err,
-       GHC.Exception,
-       GHC.Exts,
-       GHC.Float,
-       GHC.ForeignPtr,
-       GHC.Handle,
-       GHC.IO,
-       GHC.IOBase,
-       GHC.Int,
-       GHC.List,
-       GHC.Num,
-       GHC.PArr,
-       GHC.Pack,
-       GHC.Prim,
-       GHC.PrimopWrappers,
-       GHC.Ptr,
-       GHC.Read,
-       GHC.Real,
-       GHC.ST,
-       GHC.STRef,
-       GHC.Show,
-       GHC.Stable,
-       GHC.Storable,
-       GHC.TopHandler,
-       GHC.Unicode,
-       GHC.Weak,
-       GHC.Word,
-       Numeric,
-       Prelude,
-       System.Console.GetOpt,
-       System.CPUTime,
-       System.Environment,
-       System.Exit,
-       System.IO,
-       System.IO.Error,
-       System.IO.Unsafe,
-       System.Info,
-       System.Mem,
-       System.Mem.StableName,
-       System.Mem.Weak,
-       System.Posix.Internals,
-       System.Posix.Signals,
-       System.Posix.Types,
-       System.Timeout,
-       Text.ParserCombinators.ReadP,
-       Text.ParserCombinators.ReadPrec,
-       Text.Printf,
-       Text.Read,
-       Text.Read.Lex,
-       Text.Show,
-       Text.Show.Functions
-       Unsafe.Coerce
-other-modules:
-       Data.Array.IO.Internals
-c-sources:
-       cbits/PrelIOUtils.c
-       cbits/WCsubst.c
-       cbits/Win32Utils.c
-       cbits/consUtils.c
-       cbits/dirUtils.c
-       cbits/fpstring.c
-       cbits/inputReady.c
-       cbits/lockFile.c
-       cbits/longlong.c
-       cbits/selectUtils.c
-include-dirs: include
-includes:      HsBase.h
-install-includes:      HsBase.h HsBaseConfig.h WCsubst.h dirUtils.h lockFile.h consUtils.h Typeable.h
-extensions:    CPP
--- XXX is there an extension for using # in varids?
--- We need to set the package name to base (without a version number)
--- as it's magic.
-ghc-options: -fglasgow-exts -package-name base
-nhc98-options: -H4M -K3M
+    This package contains the Prelude and its support libraries,
+    and a large collection of useful libraries ranging from data
+    structures to parsing combinators and debugging utilities.
+
+Flag IsGHC {
+    Description: Are we compiling with GHC?
+    Default: True
+}
+
+Library {
+    -- This is actually something of a hack, as if we are using
+    -- GHC and we don't have an rts package for some reason, we
+    -- actually ought to fail.
+    if flag(IsGHC) {
+        build-depends: rts
+        if os(windows) {
+            extra-libraries: wsock32, msvcrt, kernel32, user32, shell32
+        }
+        exposed-modules:
+            Data.Generics,
+            Data.Generics.Aliases,
+            Data.Generics.Basics,
+            Data.Generics.Instances,
+            Data.Generics.Schemes,
+            Data.Generics.Text,
+            Data.Generics.Twins,
+            Foreign.Concurrent,
+            GHC.Arr,
+            GHC.Base,
+            GHC.Conc,
+            GHC.ConsoleHandler,
+            GHC.Dotnet,
+            GHC.Enum,
+            GHC.Environment,
+            GHC.Err,
+            GHC.Exception,
+            GHC.Exts,
+            GHC.Float,
+            GHC.ForeignPtr,
+            GHC.Handle,
+            GHC.IO,
+            GHC.IOBase,
+            GHC.Int,
+            GHC.List,
+            GHC.Num,
+            GHC.PArr,
+            GHC.Pack,
+            GHC.Prim,
+            GHC.PrimopWrappers,
+            GHC.Ptr,
+            GHC.Read,
+            GHC.Real,
+            GHC.ST,
+            GHC.STRef,
+            GHC.Show,
+            GHC.Stable,
+            GHC.Storable,
+            GHC.TopHandler,
+            GHC.Unicode,
+            GHC.Weak,
+            GHC.Word,
+            System.Timeout
+    }
+    exposed-modules:
+        Control.Applicative,
+        Control.Arrow,
+        Control.Concurrent,
+        Control.Concurrent.Chan,
+        Control.Concurrent.MVar,
+        Control.Concurrent.QSem,
+        Control.Concurrent.QSemN,
+        Control.Concurrent.SampleVar,
+        Control.Exception,
+        Control.Monad,
+        Control.Monad.Fix,
+        Control.Monad.Instances,
+        Control.Monad.ST,
+        Control.Monad.ST.Lazy,
+        Control.Monad.ST.Strict,
+        Data.Array,
+        Data.Array.Base,
+        Data.Array.Diff,
+        Data.Array.IArray,
+        Data.Array.IO,
+        Data.Array.MArray,
+        Data.Array.ST,
+        Data.Array.Storable,
+        Data.Array.Unboxed,
+        Data.Bits,
+        Data.Bool,
+        Data.ByteString,
+        Data.ByteString.Char8,
+        Data.ByteString.Lazy
+        Data.ByteString.Lazy.Char8
+        Data.ByteString.Base
+        Data.ByteString.Fusion
+        Data.Char,
+        Data.Complex,
+        Data.Dynamic,
+        Data.Either,
+        Data.Eq,
+        Data.Foldable,
+        Data.Fixed,
+        Data.Function,
+        Data.Graph,
+        Data.HashTable,
+        Data.IORef,
+        Data.Int,
+        Data.IntMap,
+        Data.IntSet,
+        Data.Ix,
+        Data.List,
+        Data.Maybe,
+        Data.Map,
+        Data.Monoid,
+        Data.Ord,
+        Data.PackedString,
+        Data.Ratio,
+        Data.STRef,
+        Data.STRef.Lazy,
+        Data.STRef.Strict,
+        Data.Sequence,
+        Data.Set,
+        Data.String,
+        Data.Tree,
+        Data.Traversable,
+        Data.Tuple,
+        Data.Typeable,
+        Data.Unique,
+        Data.Version,
+        Data.Word,
+        Debug.Trace,
+        Foreign,
+        Foreign.C,
+        Foreign.C.Error,
+        Foreign.C.String,
+        Foreign.C.Types,
+        Foreign.ForeignPtr,
+        Foreign.Marshal,
+        Foreign.Marshal.Alloc,
+        Foreign.Marshal.Array,
+        Foreign.Marshal.Error,
+        Foreign.Marshal.Pool,
+        Foreign.Marshal.Utils,
+        Foreign.Ptr,
+        Foreign.StablePtr,
+        Foreign.Storable,
+        Numeric,
+        Prelude,
+        System.Console.GetOpt,
+        System.CPUTime,
+        System.Environment,
+        System.Exit,
+        System.IO,
+        System.IO.Error,
+        System.IO.Unsafe,
+        System.Info,
+        System.Mem,
+        System.Mem.StableName,
+        System.Mem.Weak,
+        System.Posix.Internals,
+        System.Posix.Signals,
+        System.Posix.Types,
+        Text.ParserCombinators.ReadP,
+        Text.ParserCombinators.ReadPrec,
+        Text.Printf,
+        Text.Read,
+        Text.Read.Lex,
+        Text.Show,
+        Text.Show.Functions
+        Unsafe.Coerce
+    other-modules:
+        Data.Array.IO.Internals
+    c-sources:
+        cbits/PrelIOUtils.c
+        cbits/WCsubst.c
+        cbits/Win32Utils.c
+        cbits/consUtils.c
+        cbits/dirUtils.c
+        cbits/fpstring.c
+        cbits/inputReady.c
+        cbits/lockFile.c
+        cbits/longlong.c
+        cbits/selectUtils.c
+    include-dirs: include
+    includes:    HsBase.h
+    install-includes:    HsBase.h HsBaseConfig.h WCsubst.h dirUtils.h lockFile.h consUtils.h Typeable.h
+    extensions:    CPP
+    -- XXX is there an extension for using # in varids?
+    -- We need to set the package name to base (without a version number)
+    -- as it's magic.
+    ghc-options: -fglasgow-exts -package-name base
+    nhc98-options: -H4M -K3M
+}