Improve the warning about -fllvm and -fPIC/-dynamic conflicting
[ghc-hetmet.git] / compiler / nativeGen / Platform.hs
1
2 -- | A description of the platform we're compiling for.
3 --      Used by the native code generator.
4 --      In the future, this module should be the only one that references
5 --      the evil #defines for each TARGET_ARCH and TARGET_OS
6 --
7 module Platform (
8         Platform(..),
9         Arch(..),
10         OS(..),
11
12         defaultTargetPlatform,
13         osElfTarget
14 )
15
16 where
17
18 #include "HsVersions.h"
19
20
21 -- | Contains enough information for the native code generator to emit
22 --      code for this platform.
23 data Platform
24         = Platform 
25         { platformArch  :: Arch
26         , platformOS    :: OS }
27
28
29 -- | Architectures that the native code generator knows about.
30 --      TODO: It might be nice to extend these constructors with information
31 --      about what instruction set extensions an architecture might support.
32 --
33 data Arch
34         = ArchX86
35         | ArchX86_64
36         | ArchPPC
37         | ArchPPC_64
38         | ArchSPARC
39         deriving (Show, Eq)
40         
41
42 -- | Operating systems that the native code generator knows about.
43 --      Having OSUnknown should produce a sensible default, but no promises.
44 data OS
45         = OSUnknown
46         | OSLinux
47         | OSDarwin
48         | OSSolaris2
49         | OSMinGW32
50         | OSFreeBSD
51         | OSOpenBSD
52         deriving (Show, Eq)
53
54
55 -- | This predicates tells us whether the OS supports ELF-like shared libraries.
56 osElfTarget :: OS -> Bool
57 osElfTarget OSLinux   = True
58 osElfTarget OSFreeBSD = True
59 osElfTarget OSOpenBSD = True
60 osElfTarget OSSolaris2 = True
61 osElfTarget _         = False
62
63 -- | This is the target platform as far as the #ifdefs are concerned.
64 --      These are set in includes/ghcplatform.h by the autoconf scripts
65 defaultTargetPlatform :: Platform
66 defaultTargetPlatform
67         = Platform defaultTargetArch defaultTargetOS
68
69
70 -- | Move the evil TARGET_ARCH #ifdefs into Haskell land.
71 defaultTargetArch :: Arch
72 #if i386_TARGET_ARCH
73 defaultTargetArch       = ArchX86
74 #elif x86_64_TARGET_ARCH
75 defaultTargetArch       = ArchX86_64
76 #elif powerpc_TARGET_ARCH
77 defaultTargetArch       = ArchPPC
78 #elif powerpc64_TARGET_ARCH
79 defaultTargetArch       = ArchPPC_64
80 #elif sparc_TARGET_ARCH
81 defaultTargetArch       = ArchSPARC
82 #else
83 #error  "Platform.buildArch: undefined"
84 #endif
85
86
87 -- | Move the evil TARGET_OS #ifdefs into Haskell land.
88 defaultTargetOS :: OS
89 #if   linux_TARGET_OS
90 defaultTargetOS = OSLinux
91 #elif darwin_TARGET_OS
92 defaultTargetOS = OSDarwin
93 #elif solaris2_TARGET_OS
94 defaultTargetOS = OSSolaris2
95 #elif mingw32_TARGET_OS
96 defaultTargetOS = OSMinGW32
97 #elif freebsd_TARGET_OS
98 defaultTargetOS = OSFreeBSD
99 #elif openbsd_TARGET_OS
100 defaultTargetOS = OSOpenBSD
101 #else
102 defaultTargetOS = OSUnknown
103 #endif
104