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
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
67 = Platform defaultTargetArch defaultTargetOS
70 -- | Move the evil TARGET_ARCH #ifdefs into Haskell land.
71 defaultTargetArch :: Arch
73 defaultTargetArch = ArchAlpha
74 #elif i386_TARGET_ARCH
75 defaultTargetArch = ArchX86
76 #elif x86_64_TARGET_ARCH
77 defaultTargetArch = ArchX86_64
78 #elif powerpc_TARGET_ARCH
79 defaultTargetArch = ArchPPC
80 #elif powerpc64_TARGET_ARCH
81 defaultTargetArch = ArchPPC_64
82 #elif sparc_TARGET_ARCH
83 defaultTargetArch = ArchSPARC
85 #error "Platform.buildArch: undefined"
89 -- | Move the evil TARGET_OS #ifdefs into Haskell land.
92 defaultTargetOS = OSLinux
93 #elif darwin_TARGET_OS
94 defaultTargetOS = OSDarwin
95 #elif solaris_TARGET_OS
96 defaultTargetOS = OSSolaris
97 #elif mingw32_TARGET_OS
98 defaultTargetOS = OSMinGW32
99 #elif freebsd_TARGET_OS
100 defaultTargetOS = OSFreeBSD
101 #elif openbsd_TARGET_OS
102 defaultTargetOS = OSOpenBSD
104 defaultTargetOS = OSUnknown