about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2015-03-23 14:27:09 -0700
committerBrian Anderson <banderson@mozilla.com>2015-03-23 14:27:09 -0700
commit1aa75cea1de6b318d015b205f584ec5760f866e3 (patch)
tree3668cfc91ce062c1d50417da204c7586ab593a25
parentb0aad7dd4fad8d7e2e2f877a511a637258949597 (diff)
downloadrust-1aa75cea1de6b318d015b205f584ec5760f866e3.tar.gz
rust-1aa75cea1de6b318d015b205f584ec5760f866e3.zip
configure: Fix detection of 32-bit Linux userspace
The variable '$SHELL' is not actually defined by 'sh'.
-rwxr-xr-xconfigure15
1 files changed, 12 insertions, 3 deletions
diff --git a/configure b/configure
index fdc28eee8c8..683c7fd0563 100755
--- a/configure
+++ b/configure
@@ -479,10 +479,19 @@ esac
 # Detect 64 bit linux systems with 32 bit userland and force 32 bit compilation
 if [ $CFG_OSTYPE = unknown-linux-gnu -a $CFG_CPUTYPE = x86_64 ]
 then
-    file -L "$SHELL" | grep -q "x86[_-]64"
-    if [ $? != 0 ]; then
-        CFG_CPUTYPE=i686
+    # $SHELL does not exist in standard 'sh', so probably only exists
+    # if configure is running in an interactive bash shell. /usr/bin/env
+    # exists *everywhere*.
+    BIN_TO_PROBE="$SHELL"
+    if [ -z "$BIN_TO_PROBE" -a -e "/usr/bin/env" ]; then
+       BIN_TO_PROBE="/usr/bin/env"
     fi
+    if [ -n "$BIN_TO_PROBE" ]; then
+       file -L "$BIN_TO_PROBE" | grep -q "x86[_-]64"
+       if [ $? != 0 ]; then
+            CFG_CPUTYPE=i686
+       fi
+     fi
 fi