From 0e4f91fab96e3142cd81ffb05a4129e3da4ff7d5 Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Fri, 11 Sep 2009 16:43:07 +0000 Subject: [PATCH] Detect arch from gcc, not from uname, to cope with 32-bit userspace on 64-bit kernel This was SVN commit r7141. --- build/premake/premake.lua | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/build/premake/premake.lua b/build/premake/premake.lua index 41ae2e9883..f3c8783f5b 100755 --- a/build/premake/premake.lua +++ b/build/premake/premake.lua @@ -20,15 +20,22 @@ if OS == "windows" then end else arch = os.getenv("HOSTTYPE") - if not arch then - os.execute("uname -m > .hosttype.tmp") - local f = io.open(".hosttype.tmp","r") - arch = f:read("*line") - f:close() - end if arch == "x86_64" then arch = "amd64" end + if not arch then + os.execute("gcc -dumpmachine > .gccmachine.tmp") + local f = io.open(".gccmachine.tmp", "r") + local machine = f:read("*line") + f:close() + if string.find(machine, "x86_64") == 1 then + arch = "amd64" + elseif string.find(machine, "i.86") == 1 then + arch = "x86" + else + print("WARNING: Cannot determine architecture from GCC, assuming x86") + end + end end -- Set up the Project @@ -61,8 +68,9 @@ else -- you have a better idea) if not options["icc"] then os.execute("gcc -dumpversion > .gccver.tmp") - f = io.open(".gccver.tmp") + local f = io.open(".gccver.tmp", "r") major, dot, minor = f:read(1, 1, 1) + f:close() major = 0+major -- coerce to number minor = 0+minor has_broken_pch = (major < 4 or (major == 4 and minor < 2))