diff --git a/configure b/configure
index 12fd3c563e5a226e1afcf448882214e53c78e16f..9fa405884483e88f9173c762ce9970b4b156e43e 100755
--- a/configure
+++ b/configure
@@ -1110,6 +1110,19 @@ if test $tune != "generic"; then
     esac
 fi
 
+# make sure we can execute files in $TMPDIR
+cat >$TMPE 2>>$logfile <<EOF
+#! /bin/sh
+EOF
+chmod +x $TMPE >>$logfile 2>&1
+if ! $TMPE >>$logfile 2>&1; then
+    cat <<EOF
+Unable to create and execute files in $TMPDIR1.  Set the TMPDIR environment
+variable to another directory.
+EOF
+    die "Sanity test failed."
+fi
+
 # compiler sanity check
 check_exec <<EOF
 int main(){