2 -- | A description of the platform we're compiling for.
3 -- In the future, this module should be the only one that references
4 -- the evil #defines for each TARGET_ARCH and TARGET_OS
11 defaultTargetPlatform,
20 #include "HsVersions.h"
23 -- | Contains enough information for the native code generator to emit
24 -- code for this platform.
27 { platformArch :: Arch
31 -- | Architectures that the native code generator knows about.
32 -- TODO: It might be nice to extend these constructors with information
33 -- about what instruction set extensions an architecture might support.
45 -- | Operating systems that the native code generator knows about.
46 -- Having OSUnknown should produce a sensible default, but no promises.
58 target32Bit :: Platform -> Bool
59 target32Bit p = case platformArch p of
60 ArchUnknown -> panic "Don't know if ArchUnknown is 32bit"
68 -- | This predicates tells us whether the OS supports ELF-like shared libraries.
69 osElfTarget :: OS -> Bool
70 osElfTarget OSLinux = True
71 osElfTarget OSFreeBSD = True
72 osElfTarget OSOpenBSD = True
73 osElfTarget OSSolaris2 = True
76 -- | This is the target platform as far as the #ifdefs are concerned.
77 -- These are set in includes/ghcplatform.h by the autoconf scripts
78 defaultTargetPlatform :: Platform
80 = Platform defaultTargetArch defaultTargetOS
83 -- | Move the evil TARGET_ARCH #ifdefs into Haskell land.
84 defaultTargetArch :: Arch
86 defaultTargetArch = ArchX86
87 #elif x86_64_TARGET_ARCH
88 defaultTargetArch = ArchX86_64
89 #elif powerpc_TARGET_ARCH
90 defaultTargetArch = ArchPPC
91 #elif powerpc64_TARGET_ARCH
92 defaultTargetArch = ArchPPC_64
93 #elif sparc_TARGET_ARCH
94 defaultTargetArch = ArchSPARC
96 defaultTargetArch = ArchUnknown
100 -- | Move the evil TARGET_OS #ifdefs into Haskell land.
101 defaultTargetOS :: OS
103 defaultTargetOS = OSLinux
104 #elif darwin_TARGET_OS
105 defaultTargetOS = OSDarwin
106 #elif solaris2_TARGET_OS
107 defaultTargetOS = OSSolaris2
108 #elif mingw32_TARGET_OS
109 defaultTargetOS = OSMinGW32
110 #elif freebsd_TARGET_OS
111 defaultTargetOS = OSFreeBSD
112 #elif openbsd_TARGET_OS
113 defaultTargetOS = OSOpenBSD
115 defaultTargetOS = OSUnknown