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