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
commit27f6c96629fd140ada6ad2625617dbc943472227 (patch)
tree6f75baa32120079fbe0915316440aa4fc63ae807
parent42e9af8981e3c82407d08754cdf89260b90ee4fb (diff)
downloadtxr-27f6c96629fd140ada6ad2625617dbc943472227.tar.gz
txr-27f6c96629fd140ada6ad2625617dbc943472227.tar.bz2
txr-27f6c96629fd140ada6ad2625617dbc943472227.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
#