module Platform (
Platform(..),
Arch(..),
OS(..),
defaultTargetPlatform,
target32Bit,
osElfTarget
)
where
import Panic
#include "HsVersions.h"
data Platform
= Platform
{ platformArch :: Arch
, platformOS :: OS }
data Arch
= ArchUnknown
| ArchX86
| ArchX86_64
| ArchPPC
| ArchPPC_64
| ArchSPARC
| ArchARM
deriving (Show, Eq)
data OS
= OSUnknown
| OSLinux
| OSDarwin
| OSSolaris2
| OSMinGW32
| OSFreeBSD
| OSOpenBSD
deriving (Show, Eq)
target32Bit :: Platform -> Bool
target32Bit p = case platformArch p of
ArchUnknown -> panic "Don't know if ArchUnknown is 32bit"
ArchX86 -> True
ArchX86_64 -> False
ArchPPC -> True
ArchPPC_64 -> False
ArchSPARC -> True
ArchARM -> True
osElfTarget :: OS -> Bool
osElfTarget OSLinux = True
osElfTarget OSFreeBSD = True
osElfTarget OSOpenBSD = True
osElfTarget OSSolaris2 = True
osElfTarget OSDarwin = False
osElfTarget OSMinGW32 = False
osElfTarget OSUnknown = panic "Don't know if OSUnknown is elf"
defaultTargetPlatform :: Platform
defaultTargetPlatform
= Platform defaultTargetArch defaultTargetOS
defaultTargetArch :: Arch
#if i386_TARGET_ARCH
defaultTargetArch = ArchX86
#elif x86_64_TARGET_ARCH
defaultTargetArch = ArchX86_64
#elif powerpc_TARGET_ARCH
defaultTargetArch = ArchPPC
#elif powerpc64_TARGET_ARCH
defaultTargetArch = ArchPPC_64
#elif sparc_TARGET_ARCH
defaultTargetArch = ArchSPARC
#elif arm_TARGET_ARCH
defaultTargetArch = ArchARM
#else
defaultTargetArch = ArchUnknown
#endif
defaultTargetOS :: OS
#if linux_TARGET_OS
defaultTargetOS = OSLinux
#elif darwin_TARGET_OS
defaultTargetOS = OSDarwin
#elif solaris2_TARGET_OS
defaultTargetOS = OSSolaris2
#elif mingw32_TARGET_OS
defaultTargetOS = OSMinGW32
#elif freebsd_TARGET_OS
defaultTargetOS = OSFreeBSD
#elif kfreebsdgnu_TARGET_OS
defaultTargetOS = OSFreeBSD
#elif openbsd_TARGET_OS
defaultTargetOS = OSOpenBSD
#else
defaultTargetOS = OSUnknown
#endif