History

Another attempt to "detect" multiarch

Thomas Preud'homme committed 13 years ago

Commit b1a82331 parent 062efe62 files · +55 −17Browse files

Unified · Split

2 files
  1. configure +14 −8
  2. conftest.c +41 −9
configure+14−8
@@ -296,7 +296,13 @@ if test -z "$cross_prefix" ; then · 295 unmodified lines
296296 gcc_major="$($CONFTEST version)"
297297 gcc_minor="$($CONFTEST minor)"
298298 if test "$mingw32" = "no" ; then
299− libc_dir="$(ldd $CONFTEST | grep libc.so | sed 's|[^/]*/\(.*/\)[^/]*|\1|')"
299+ triplet="$($CONFTEST triplet)"
300+ if test -f "/usr/lib/$triplet/crti.o" ; then
301+ tcc_lddir="lib/$triplet"
302+ multiarch_triplet="$triplet"
303+ elif test -f "usr/lib64/crti.o" ; then
304+ tcc_lddir="lib64"
305+ fi
300306
301307 # gr: FIXME
302308 # ldd $CONFTEST gives (ubuntu 8)
@@ -306,13 +312,13 @@ if test -z "$cross_prefix" ; then · 3 unmodified lines
306312 # result is crap:
307313 # CONFIG_LDDIR="lib/tls/i686/cmov"
308314 # CONFIG_MUADIR="tls/i686/cmov"
309−
310− multiarch_triplet=${libc_dir#*/}
311− multiarch_triplet=${multiarch_triplet%/}
312− tcc_lddir="${libc_dir%%/*}"
313− if test -n "$multiarch_triplet" ; then
314− tcc_lddir="$tcc_lddir/$multiarch_triplet"
315− fi
315+#
316+# multiarch_triplet=${libc_dir#*/}
317+# multiarch_triplet=${multiarch_triplet%/}
318+# tcc_lddir="${libc_dir%%/*}"
319+# if test -n "$multiarch_triplet" ; then
320+# tcc_lddir="$tcc_lddir/$multiarch_triplet"
321+# fi
316322
317323 # gr: maybe for after the release:
318324 # tcc_elfinterp="$(ldd $CONFTEST | grep 'ld.*.so' | sed 's,\s*\(\S\+\).*,\1,')"
conftest.c+41−9
@@ -1,27 +1,59 @@
11 #include <stdio.h>
22
3+/* Define architecture */
4+#if defined(__i386__)
5+# define TRIPLET_ARCH "i386"
6+#elif defined(__x86_64__)
7+# define TRIPLET_ARCH "x86_64"
8+#elif defined(__arm__)
9+# define TRIPLET_ARCH "arm"
10+#else
11+# define TRIPLET_ARCH "unknown"
12+#endif
13+
14+/* Define OS */
15+#if defined (__linux__)
16+# define TRIPLET_OS "linux"
17+#elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
18+# define TRIPLET_OS "kfreebsd"
19+#elif !defined (__GNU__)
20+# define TRIPLET_OS "unknown"
21+#endif
22+
23+/* Define calling convention and ABI */
24+#define TRIPLET_ABI "gnu"
25+
26+#ifdef __GNU__
27+# define TRIPLET TRIPLET_ARCH "-" TRIPLET_ABI
28+#else
29+# define TRIPLET TRIPLET_ARCH "-" TRIPLET_OS "-" TRIPLET_ABI
30+#endif
31+
332 int main(int argc, char *argv[])
433 {
534 switch(argc == 2 ? argv[1][0] : 0) {
6−#ifdef __GNUC__
7− case 'v':
8− printf("%d\n", __GNUC__);
35+ case 'b':
36+ {
37+ volatile unsigned foo = 0x01234567;
38+ puts(*(unsigned char*)&foo == 0x67 ? "no" : "yes");
939 break;
40+ }
41+#ifdef __GNUC__
1042 case 'm':
1143 printf("%d\n", __GNUC_MINOR__);
1244 break;
13−#else
1445 case 'v':
46+ printf("%d\n", __GNUC__);
47+ break;
48+#else
1549 case 'm':
50+ case 'v':
1651 puts("0");
1752 break;
1853 #endif
19− case 'b':
20− {
21− volatile unsigned foo = 0x01234567;
22− puts(*(unsigned char*)&foo == 0x67 ? "no" : "yes");
54+ case 't':
55+ puts(TRIPLET);
2356 break;
24− }
2557 case -1:
2658 /* to test -Wno-unused-result */
2759 fread(NULL, 1, 1, NULL);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t