>From 55c200a1e8b47bcd867adf263d1bd1e6aba97096 Mon Sep 17 00:00:00 2001
From: Philip Lorenz <lorenzph@gmail.com>
Date: Wed, 4 May 2011 11:43:28 +0200
Subject: [PATCH 3/6] Fix architecture detection. The old code did not
 determine the architecture correctly (uname -m returns
 iX86 for 32 bit platforms and x86_64 for 64 bit
 platforms - both containing the string 86).

---
 Makefile |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index 1f6f01d..7de3255 100644
--- a/Makefile
+++ b/Makefile
@@ -16,13 +16,11 @@ UCS ?= $(shell $(PYTHON) -c "import sys; \
 SITEPACKAGES = $(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib; \
     print get_python_lib(plat_specific=1, standard_lib=0)")
 INSTALL=/usr/bin/install -m644
-# Contributed by VIKAS DHIMAN -  - Thanks, Vikas!
-ARCH_FULL = $(shell uname -m)
-ifneq (, $(findstring 86, $(ARCH_FULL)))
-	ARCH = x86
-else
-	ARCH = x64
-endif 
+
+# Determine host architecture if it was not specified by the user.
+ARCH ?= $(shell getconf LONG_BIT)
+CFLAGS_CLR_64 = -Ix64
+CFLAGS_CLR_32 = -Ix86
 
 ifeq ($(origin WINDIR), undefined)
     RUNNER = mono
@@ -81,7 +79,7 @@ Python.Runtime.dll: $(RUNTIME_CS)
 src/runtime/clrmodule.il: src/runtime/clrmodule.pp.il
 ifeq ($(origin WINDIR), undefined)
 	cd "$(BASEDIR)/src/runtime";\
-	$(CPP) -C -P -x c++ -I $(ARCH) clrmodule.pp.il -o clrmodule.il
+	$(CPP) -C -P -x c++ $(CFLAGS_CLR_$(ARCH)) clrmodule.pp.il -o clrmodule.il
 else
 	cd "$(BASEDIR)/src/runtime";\
 	cp oldmodule.il clrmodule.il
-- 
1.7.5

