aboutsummaryrefslogtreecommitdiff
path: root/conftest.c
diff options
context:
space:
mode:
authorThomas Preud'homme <robotux@celest.fr>2013-02-14 15:39:35 +0100
committerThomas Preud'homme <robotux@celest.fr>2013-02-14 15:39:35 +0100
commitb1a82335626fa504b83a4eb2d1373a5e4ee5cf4f (patch)
treed10a76f01559c43e830744f1b1d35017880453d1 /conftest.c
parent062efe6ab851c1a926dae5c9202558e885e89f31 (diff)
downloadtinycc-b1a82335626fa504b83a4eb2d1373a5e4ee5cf4f.tar.gz
tinycc-b1a82335626fa504b83a4eb2d1373a5e4ee5cf4f.tar.bz2
Another attempt to "detect" multiarch
Diffstat (limited to 'conftest.c')
-rw-r--r--conftest.c50
1 files changed, 41 insertions, 9 deletions
diff --git a/conftest.c b/conftest.c
index a803bff..9eae11a 100644
--- a/conftest.c
+++ b/conftest.c
@@ -1,27 +1,59 @@
#include <stdio.h>
+/* Define architecture */
+#if defined(__i386__)
+# define TRIPLET_ARCH "i386"
+#elif defined(__x86_64__)
+# define TRIPLET_ARCH "x86_64"
+#elif defined(__arm__)
+# define TRIPLET_ARCH "arm"
+#else
+# define TRIPLET_ARCH "unknown"
+#endif
+
+/* Define OS */
+#if defined (__linux__)
+# define TRIPLET_OS "linux"
+#elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
+# define TRIPLET_OS "kfreebsd"
+#elif !defined (__GNU__)
+# define TRIPLET_OS "unknown"
+#endif
+
+/* Define calling convention and ABI */
+#define TRIPLET_ABI "gnu"
+
+#ifdef __GNU__
+# define TRIPLET TRIPLET_ARCH "-" TRIPLET_ABI
+#else
+# define TRIPLET TRIPLET_ARCH "-" TRIPLET_OS "-" TRIPLET_ABI
+#endif
+
int main(int argc, char *argv[])
{
switch(argc == 2 ? argv[1][0] : 0) {
-#ifdef __GNUC__
- case 'v':
- printf("%d\n", __GNUC__);
+ case 'b':
+ {
+ volatile unsigned foo = 0x01234567;
+ puts(*(unsigned char*)&foo == 0x67 ? "no" : "yes");
break;
+ }
+#ifdef __GNUC__
case 'm':
printf("%d\n", __GNUC_MINOR__);
break;
-#else
case 'v':
+ printf("%d\n", __GNUC__);
+ break;
+#else
case 'm':
+ case 'v':
puts("0");
break;
#endif
- case 'b':
- {
- volatile unsigned foo = 0x01234567;
- puts(*(unsigned char*)&foo == 0x67 ? "no" : "yes");
+ case 't':
+ puts(TRIPLET);
break;
- }
case -1:
/* to test -Wno-unused-result */
fread(NULL, 1, 1, NULL);