module Development.Shake.Language.C.Host (
OS(..)
, os
, executableExtension
, sharedLibraryExtension
, loadableLibraryExtension
, defaultToolChain
) where
import Development.Shake (Action)
import Development.Shake.Language.C.Target (Target)
import qualified Development.Shake.Language.C.Host.Linux as Linux
import qualified Development.Shake.Language.C.Host.OSX as OSX
import qualified Development.Shake.Language.C.Host.Windows as Windows
import Development.Shake.Language.C.ToolChain (ToolChain)
import qualified System.Info as System
import System.IO.Unsafe (unsafePerformIO)
data OS =
Linux
| OSX
| Windows
deriving (Eq, Ord, Show)
os :: OS
os =
case System.os of
"darwin" -> OSX
"mingw32" -> Windows
"linux" -> Linux
_ -> error $ "Unknown host operating system: " ++ System.os
executableExtension :: String
executableExtension =
case os of
Windows -> "exe"
_ -> ""
sharedLibraryExtension :: String
sharedLibraryExtension =
case os of
Linux -> "so"
OSX -> "dylib"
Windows -> "dll"
loadableLibraryExtension :: String
loadableLibraryExtension =
case os of
Linux -> "so"
OSX -> "bundle"
Windows -> "dll"
defaultToolChain :: (Target, Action ToolChain)
defaultToolChain = unsafePerformIO $ do
case os of
Linux -> Linux.getHostToolChain
OSX -> OSX.getHostToolChain
Windows -> Windows.getHostToolChain