diff options
author | John Hodge <tpg@ucc.asn.au> | 2018-06-03 14:57:05 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2018-06-03 14:57:05 +0800 |
commit | bf8f8b4b4a9fe273451be59f68acafbe61968b83 (patch) | |
tree | 82993550cb3c88de0edbd55d79e4ea8e8cefffac /tools/common/target_detect.h | |
parent | 39b3cf53798683e496804f8322da2254b10850f4 (diff) | |
parent | a7fb27789a2b34543851d207120e2c0001ee9c27 (diff) | |
download | mrust-bf8f8b4b4a9fe273451be59f68acafbe61968b83.tar.gz |
Merge branch 'master' of https://github.com/thepowersgang/mrustc
Diffstat (limited to 'tools/common/target_detect.h')
-rw-r--r-- | tools/common/target_detect.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tools/common/target_detect.h b/tools/common/target_detect.h new file mode 100644 index 00000000..995ab6a4 --- /dev/null +++ b/tools/common/target_detect.h @@ -0,0 +1,66 @@ +/* + * MRustC - Rust Compiler + * - By John Hodge (Mutabah/thePowersGang) + * + * common/target_detect.h + * - Auto-magical host target detection + */ +#pragma once + +// - Windows (MSVC) +#ifdef _MSC_VER +# if defined(_WIN64) +# define DEFAULT_TARGET_NAME "x86_64-windows-msvc" +# else +# define DEFAULT_TARGET_NAME "x86-windows-msvc" +# endif +// - Linux +#elif defined(__linux__) +# if defined(__amd64__) +# define DEFAULT_TARGET_NAME "x86_64-linux-gnu" +# elif defined(__aarch64__) +# define DEFAULT_TARGET_NAME "aarch64-linux-gnu" +# elif defined(__arm__) +# define DEFAULT_TARGET_NAME "arm-linux-gnu" +# elif defined(__i386__) +# define DEFAULT_TARGET_NAME "i586-linux-gnu" +# else +# warning "Unable to detect a suitable default target (linux-gnu)" +# endif +// - MinGW +#elif defined(__MINGW32__) +# if defined(_WIN64) +# define DEFAULT_TARGET_NAME "x86_64-windows-gnu" +# else +# define DEFAULT_TARGET_NAME "i586-windows-gnu" +# endif +// - NetBSD +#elif defined(__NetBSD__) +# if defined(__amd64__) +# define DEFAULT_TARGET_NAME "x86_64-unknown-netbsd" +# else +# warning "Unable to detect a suitable default target (NetBSD)" +# endif +// - OpenBSD +#elif defined(__OpenBSD__) +# if defined(__amd64__) +# define DEFAULT_TARGET_NAME "x86_64-unknown-openbsd" +# elif defined(__aarch64__) +# define DEFAULT_TARGET_NAME "aarch64-unknown-openbsd" +# elif defined(__arm__) +# define DEFAULT_TARGET_NAME "arm-unknown-openbsd" +# elif defined(__i386__) +# define DEFAULT_TARGET_NAME "i686-unknown-openbsd" +# else +# warning "Unable to detect a suitable default target (OpenBSD)" +# endif +// - Apple devices +#elif defined(__APPLE__) +# define DEFAULT_TARGET_NAME "x86_64-apple-macosx" +// - Unknown +#else +# warning "Unable to detect a suitable default target" +#endif +#ifndef DEFAULT_TARGET_NAME +# define DEFAULT_TARGET_NAME "" +#endif |