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
12 defaultTargetPlatform,
18 #include "HsVersions.h"
21 -- | Contains enough information for the native code generator to emit
22 -- code for this platform.
25 { platformArch :: Arch
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.
43 -- | Operating systems that the native code generator knows about.
44 -- Having OSUnknown should produce a sensible default, but no promises.
56 -- | This predicates tells us whether the OS supports ELF-like shared libraries.
57 osElfTarget :: OS -> Bool
58 osElfTarget OSLinux = True
59 osElfTarget OSFreeBSD = True
60 osElfTarget OSOpenBSD = True
61 osElfTarget OSSolaris2 = True
64 -- | This is the target platform as far as the #ifdefs are concerned.
65 -- These are set in includes/ghcplatform.h by the autoconf scripts
66 defaultTargetPlatform :: Platform
68 = Platform defaultTargetArch defaultTargetOS
71 -- | Move the evil TARGET_ARCH #ifdefs into Haskell land.
72 defaultTargetArch :: Arch
74 defaultTargetArch = ArchAlpha
75 #elif i386_TARGET_ARCH
76 defaultTargetArch = ArchX86
77 #elif x86_64_TARGET_ARCH
78 defaultTargetArch = ArchX86_64
79 #elif powerpc_TARGET_ARCH
80 defaultTargetArch = ArchPPC
81 #elif powerpc64_TARGET_ARCH
82 defaultTargetArch = ArchPPC_64
83 #elif sparc_TARGET_ARCH
84 defaultTargetArch = ArchSPARC
86 #error "Platform.buildArch: undefined"
90 -- | Move the evil TARGET_OS #ifdefs into Haskell land.
93 defaultTargetOS = OSLinux
94 #elif darwin_TARGET_OS
95 defaultTargetOS = OSDarwin
96 #elif solaris2_TARGET_OS
97 defaultTargetOS = OSSolaris2
98 #elif mingw32_TARGET_OS
99 defaultTargetOS = OSMinGW32
100 #elif freebsd_TARGET_OS
101 defaultTargetOS = OSFreeBSD
102 #elif openbsd_TARGET_OS
103 defaultTargetOS = OSOpenBSD
105 defaultTargetOS = OSUnknown