summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-05-25 19:11:51 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-05-25 19:11:51 -0700
commit5c676f789d9e896f4b8d88a977d4e0fcae3a9fc1 (patch)
tree6f75baa32120079fbe0915316440aa4fc63ae807
parent761476fcb466b0dc8bfe35c71b873ebb7d2629a6 (diff)
downloadtxr-5c676f789d9e896f4b8d88a977d4e0fcae3a9fc1.tar.gz
txr-5c676f789d9e896f4b8d88a977d4e0fcae3a9fc1.tar.bz2
txr-5c676f789d9e896f4b8d88a977d4e0fcae3a9fc1.zip
configure: detect endianness.
* configure: New test for endianness of the compile target. Produces HAVE_LITTLE_ENDIAN in config.h with a value of either 1 or 0.
-rwxr-xr-xconfigure37
1 files changed, 37 insertions, 0 deletions
diff --git a/configure b/configure
index c80c8820..a441a7c4 100755
--- a/configure
+++ b/configure
@@ -1246,6 +1246,43 @@ printf "%d\n" "$lit_align"
printf "#define LIT_ALIGN %d\n" "$lit_align" >> config.h
#
+# Endianness.
+#
+
+printf "Checking target machine endianness ... "
+cat > conftest.c <<!
+#define USPELL(C0, C1, C2, C3) \
+ ((unsigned) C0 << 24 | \
+ (unsigned) C1 << 16 | \
+ (unsigned) C2 << 8 | (unsigned) C3)
+
+unsigned x[6] = {
+ 0,
+ USPELL('L', 'I', 'S', 'P'),
+ USPELL('U', 'N', 'I', 'X'),
+ USPELL('C', 'O', 'R', 'E'),
+ USPELL('D', 'W', 'I', 'M'),
+ 0
+};
+!
+
+if ! conftest_o ; then
+ printf "failed\n";
+ exit 1;
+else
+ if grep -q 'PSILXINUEROCMIWD' conftest.o ; then
+ printf "little\n";
+ printf "#define HAVE_LITTLE_ENDIAN 1\n" >> config.h
+ elif grep -q 'LISPUNIXCOREDWIM' conftest.o ; then
+ printf "big\n";
+ printf "#define HAVE_LITTLE_ENDIAN 0\n" >> config.h
+ else
+ printf "failed\n"
+ exit 1
+ fi
+fi
+
+#
# Inline functions
#