Use explicit language extensions & remove extension fields from base.cabal
[packages/base.git] / System / Info.hs
1 {-# LANGUAGE CPP #-}
2
3 -----------------------------------------------------------------------------
4 -- |
5 -- Module : System.Info
6 -- Copyright : (c) The University of Glasgow 2001
7 -- License : BSD-style (see the file libraries/base/LICENSE)
8 --
9 -- Maintainer : libraries@haskell.org
10 -- Stability : experimental
11 -- Portability : portable
12 --
13 -- Information about the characteristics of the host
14 -- system lucky enough to run your program.
15 --
16 -----------------------------------------------------------------------------
17
18 module System.Info
19 (
20 os, -- :: String
21 arch, -- :: String
22 compilerName, -- :: String
23 compilerVersion -- :: Version
24 ) where
25
26 import Prelude
27 import Data.Version
28
29 -- | The version of 'compilerName' with which the program was compiled
30 -- or is being interpreted.
31 compilerVersion :: Version
32 compilerVersion = Version {versionBranch=[major, minor], versionTags=[]}
33 where (major, minor) = compilerVersionRaw `divMod` 100
34
35 -- | The operating system on which the program is running.
36 os :: String
37
38 -- | The machine architecture on which the program is running.
39 arch :: String
40
41 -- | The Haskell implementation with which the program was compiled
42 -- or is being interpreted.
43 compilerName :: String
44
45 compilerVersionRaw :: Int
46
47 #if defined(__NHC__)
48 #include "OSInfo.hs"
49 compilerName = "nhc98"
50 compilerVersionRaw = __NHC__
51
52 #elif defined(__GLASGOW_HASKELL__)
53 #include "ghcplatform.h"
54 os = HOST_OS
55 arch = HOST_ARCH
56 compilerName = "ghc"
57 compilerVersionRaw = __GLASGOW_HASKELL__
58
59 #elif defined(__HUGS__)
60 #include "platform.h"
61 os = HOST_OS
62 arch = HOST_ARCH
63 compilerName = "hugs"
64 compilerVersionRaw = 0 -- ToDo
65
66 #else
67 #error Unknown compiler name
68 #endif