    cpu detection
    * don't setup a cpu before scanning for --cpu=
    * if cpu="" then
        if ARCH != "" then cpu=$ARCH else cpu=`uname -m`
    * if cpu="x86-64" and sizeof(long) = 4 then cpu="x86"

diff -urN tinycc.git.old/configure tinycc.git/configure
--- tinycc.git.old/configure	2015-01-05 18:55:02.000000000 +0300
+++ tinycc.git/configure	2015-01-05 19:33:59.000000000 +0300
@@ -37,6 +37,7 @@
 cygwin="no"
 gprof="no"
 bigendian="no"
+sizeoflong=""
 mingw32="no"
 LIBSUF=".a"
 EXESUF=""
@@ -46,8 +47,7 @@
 tcc_elfinterp=""
 tcc_lddir=
 confvars=
-
-cpu=`uname -m`
+cpu=
 
 # OS specific
 targetos=`uname -s`
@@ -192,6 +192,13 @@
   esac
 done
 
+if test -z "$cpu" ; then
+    if test -n "$ARCH" ; then
+	cpu="$ARCH"
+    else
+	cpu=`uname -m`
+    fi
+fi
 classify_cpu "$cpu"
 
 # Checking for CFLAGS
@@ -309,6 +316,7 @@
     echo "configure: error: '$cc' failed to compile conftest.c."
   else
     bigendian="$($CONFTEST bigendian)"
+    sizeoflong="$($CONFTEST sizeoflong)"
     gcc_major="$($CONFTEST version)"
     gcc_minor="$($CONFTEST minor)"
     if test "$mingw32" = "no" ; then
@@ -354,6 +362,10 @@
   esac
 fi
 
+if test "$cpu" = "x86-64" -a "$sizeoflong" = "4" ; then
+    cpu="x86"
+fi
+
 cat <<EOF
 Binary  directory   $bindir
 TinyCC directory    $tccdir
diff -urN tinycc.git.old/conftest.c tinycc.git/conftest.c
--- tinycc.git.old/conftest.c	2015-01-05 18:55:02.000000000 +0300
+++ tinycc.git/conftest.c	2015-01-05 19:26:22.000000000 +0300
@@ -66,6 +66,10 @@
         case 't':
             puts(TRIPLET);
             break;
+        case 's':
+    	    /* userland: 32bit or 64bit */
+            printf("%d\n", sizeof(long));
+            break;
         case -1:
             /* to test -Wno-unused-result */
             fread(NULL, 1, 1, NULL);
