module Platform (
Platform(..),
Arch(..),
OS(..),
defaultTargetPlatform,
osElfTarget
)
where
#include "HsVersions.h"
data Platform
= Platform
{ platformArch :: Arch
, platformOS :: OS }
data Arch
= ArchAlpha
| ArchX86
| ArchX86_64
| ArchPPC
| ArchPPC_64
| ArchSPARC
deriving (Show, Eq)
data OS
= OSUnknown
| OSLinux
| OSDarwin
| OSSolaris
| OSMinGW32
| OSFreeBSD
| OSOpenBSD
deriving (Show, Eq)
osElfTarget :: OS -> Bool
osElfTarget OSLinux = True
osElfTarget OSFreeBSD = True
osElfTarget OSOpenBSD = True
osElfTarget _ = False
defaultTargetPlatform :: Platform
defaultTargetPlatform
= Platform defaultTargetArch defaultTargetOS
defaultTargetArch :: Arch
#if alpha_TARGET_ARCH
defaultTargetArch = ArchAlpha
#elif 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
#else
#error "Platform.buildArch: undefined"
#endif
defaultTargetOS :: OS
#if linux_TARGET_OS
defaultTargetOS = OSLinux
#elif darwin_TARGET_OS
defaultTargetOS = OSDarwin
#elif solaris_TARGET_OS
defaultTargetOS = OSSolaris
#elif mingw32_TARGET_OS
defaultTargetOS = OSMinGW32
#elif freebsd_TARGET_OS
defaultTargetOS = OSFreeBSD
#elif openbsd_TARGET_OS
defaultTargetOS = OSOpenBSD
#else
defaultTargetOS = OSUnknown
#endif