| Line 2... |
Line 2... |
import sys
|
import sys
|
import commands
|
import commands
|
|
|
import petscconf
|
import petscconf
|
import log
|
import log
|
|
|
def Link(functions,callbacks,flags):
|
def LinkWithOutput(functions,callbacks,flags):
|
os.chdir('config')
|
os.chdir('config')
|
cfile = open('checklink.c','w')
|
cfile = open('checklink.c','w')
|
cfile.write('#include "petsc.h"\n')
|
cfile.write('#include "petsc.h"\n')
|
|
|
cfile.write('EXTERN_C_BEGIN\n')
|
cfile.write('EXTERN_C_BEGIN\n')
|
| Line 29... |
Line 29... |
cfile.write('return 0;\n}\n')
|
cfile.write('return 0;\n}\n')
|
cfile.close()
|
cfile.close()
|
(result, output) = commands.getstatusoutput(petscconf.MAKE + ' checklink TESTFLAGS="'+str.join(' ',flags)+'"')
|
(result, output) = commands.getstatusoutput(petscconf.MAKE + ' checklink TESTFLAGS="'+str.join(' ',flags)+'"')
|
os.chdir(os.pardir)
|
os.chdir(os.pardir)
|
if result:
|
if result:
|
log.Write(output)
|
return (0, output)
|
return 0
|
|
else:
|
else:
|
return 1
|
return (1, output)
|
|
|
|
def Link(functions,callbacks,flags):
|
|
(result, output) = LinkWithOutput(functions,callbacks,flags)
|
|
if result == 0:
|
|
log.Write(output)
|
|
return result
|
|
|
def FortranLink(functions,callbacks,flags):
|
def FortranLink(functions,callbacks,flags):
|
log.Write('=== With linker flags: '+str.join(' ',flags))
|
|
f = []
|
f = []
|
for i in functions:
|
for i in functions:
|
f.append(i+'_')
|
f.append(i+'_')
|
c = []
|
c = []
|
for i in callbacks:
|
for i in callbacks:
|
c.append(i+'_')
|
c.append(i+'_')
|
if Link(f,c,flags): return 'UNDERSCORE'
|
(result, output1) = LinkWithOutput(f,c,flags)
|
|
if result: return ('UNDERSCORE','')
|
|
|
f = []
|
f = []
|
for i in functions:
|
for i in functions:
|
f.append(i.upper())
|
f.append(i.upper())
|
c = []
|
c = []
|
for i in callbacks:
|
for i in callbacks:
|
c.append(i.upper())
|
c.append(i.upper())
|
if Link(f,c,flags): return 'CAPS'
|
(result, output2) = LinkWithOutput(f,c,flags)
|
if Link(functions,callbacks,flags): return 'STDCALL'
|
if result: return ('CAPS','')
|
return ''
|
|
|
(result, output3) = LinkWithOutput(functions,callbacks,flags)
|
|
if result: return ('STDCALL','')
|
|
|
|
output = '=== With linker flags: '+str.join(' ',flags)
|
|
output += '\n====== With underscore Fortran names\n'
|
|
output += output1
|
|
output += '\n====== With capital Fortran names\n'
|
|
output += output2
|
|
output += '\n====== With unmodified Fortran names\n'
|
|
output += output3+'\n'
|
|
return ('',output)
|
|
|
def GenerateGuesses(name):
|
def GenerateGuesses(name):
|
installdirs = ['/usr/local','/opt']
|
installdirs = ['/usr/local','/opt']
|
if 'HOME' in os.environ:
|
if 'HOME' in os.environ:
|
installdirs.insert(0,os.environ['HOME'])
|
installdirs.insert(0,os.environ['HOME'])
|
| Line 75... |
Line 93... |
return dirs
|
return dirs
|
|
|
def FortranLib(conf,name,dirs,libs,functions,callbacks = []):
|
def FortranLib(conf,name,dirs,libs,functions,callbacks = []):
|
log.Println('Checking '+name+' library...')
|
log.Println('Checking '+name+' library...')
|
|
|
mangling = 0
|
error = ''
|
|
mangling = ''
|
for d in dirs:
|
for d in dirs:
|
for l in libs:
|
for l in libs:
|
if d:
|
if d:
|
flags = ['-L' + d] + l
|
flags = ['-L' + d] + l
|
else:
|
else:
|
flags = l
|
flags = l
|
mangling = FortranLink(functions,callbacks,flags)
|
(mangling, output) = FortranLink(functions,callbacks,flags)
|
|
error += output
|
if mangling: break
|
if mangling: break
|
if mangling: break
|
if mangling: break
|
|
|
if not mangling:
|
if not mangling:
|
|
log.Write(error);
|
print 'ERROR: Unable to link with library',name
|
print 'ERROR: Unable to link with library',name
|
print 'ERROR: In directories',dirs
|
print 'ERROR: In directories',dirs
|
print 'ERROR: With flags',libs
|
print 'ERROR: With flags',libs
|
|
print 'ERROR: See "configure_log_' + petscconf.ARCH + '" file for details'
|
sys.exit(1)
|
sys.exit(1)
|
|
|
|
|
conf.write('SLEPC_HAVE_' + name + ' = -DSLEPC_HAVE_' + name + ' -DSLEPC_' + name + '_HAVE_'+mangling+'\n')
|
conf.write('SLEPC_HAVE_' + name + ' = -DSLEPC_HAVE_' + name + ' -DSLEPC_' + name + '_HAVE_'+mangling+'\n')
|
conf.write(name + '_LIB = '+str.join(' ',flags)+'\n')
|
conf.write(name + '_LIB = '+str.join(' ',flags)+'\n')
|
return flags
|
return flags
|
|
|
|
|