build: better host_arch() definition in configure
On one of my OS X Lion machines, it always reports i386, even though 64-bit is supported. This lookup better matches how WAF determines the host arch, which was correctly getting 64-bit even on this screwy machine.
This commit is contained in:
parent
da908364a8
commit
19133cac02
48
configure
vendored
48
configure
vendored
@ -139,28 +139,42 @@ def pkg_config(pkg):
|
|||||||
return (libs, cflags)
|
return (libs, cflags)
|
||||||
|
|
||||||
|
|
||||||
def uname(switch):
|
|
||||||
f = os.popen('uname %s' % switch)
|
|
||||||
s = f.read().strip()
|
|
||||||
f.close()
|
|
||||||
return s
|
|
||||||
|
|
||||||
|
|
||||||
def host_arch():
|
def host_arch():
|
||||||
"""Host architecture. One of arm, ia32 or x64."""
|
"""Host architecture. One of arm, ia32 or x64."""
|
||||||
arch = uname('-m')
|
|
||||||
arches = {
|
# TODO better/configurable way of getting the proper 'cc' command?
|
||||||
'arm': 'arm',
|
cc = [ 'cc' ]
|
||||||
'x86': 'ia32',
|
|
||||||
'i386': 'ia32',
|
cmd = cc + [ '-dM', '-E', '-' ]
|
||||||
'i686': 'ia32',
|
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
'x86_64': 'x64',
|
p.stdin.write('\n')
|
||||||
|
out = p.communicate()[0]
|
||||||
|
|
||||||
|
out = str(out).split('\n')
|
||||||
|
|
||||||
|
k = {}
|
||||||
|
for line in out:
|
||||||
|
import shlex
|
||||||
|
lst = shlex.split(line)
|
||||||
|
if len(lst) > 2:
|
||||||
|
key = lst[1]
|
||||||
|
val = lst[2]
|
||||||
|
k[key] = val
|
||||||
|
|
||||||
|
matchup = {
|
||||||
|
'__x86_64__' : 'x64',
|
||||||
|
'__i386__' : 'ia32',
|
||||||
|
'__arm__' : 'arm',
|
||||||
}
|
}
|
||||||
|
|
||||||
if arches.get(arch) == None:
|
rtn = 'ia32' # default
|
||||||
arch = uname('-p')
|
|
||||||
|
|
||||||
return arches.get(arch, 'ia32')
|
for i in matchup:
|
||||||
|
if i in k and k[i] != '0':
|
||||||
|
rtn = matchup[i]
|
||||||
|
break
|
||||||
|
|
||||||
|
return rtn
|
||||||
|
|
||||||
|
|
||||||
def target_arch():
|
def target_arch():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user