| import urlparse |
| import commands |
| def Install(conf,vars,cmake,url,archdir): |
| def Install(conf,vars,cmake,tmpdir,url,archdir): |
| ''' |
| Download and uncompress the BLOPEX tarball |
| ''' |
| import log |
| import check |
| def Check(conf,vars,cmake,directory,libs): |
| def Check(conf,vars,cmake,tmpdir,directory,libs): |
| log.write('='*80) |
| log.Println('Checking PRIMME library...') |
| else: |
| l = libs |
| f = [] |
| if check.Link(functions,[],l+f): |
| if check.Link(tmpdir,functions,[],l+f): |
| conf.write('#ifndef SLEPC_HAVE_PRIMME\n#define SLEPC_HAVE_PRIMME 1\n#endif\n\n') |
| vars.write('PRIMME_LIB = ' + str.join(' ', l) + '\n') |
| vars.write('PRIMME_FLAGS = ' + str.join(' ', f) + '\n') |
| import log |
| import check |
| def Check(conf,vars,cmake): |
| def Check(conf,vars,cmake,tmpdir): |
| log.write('='*80) |
| log.Println('Checking LAPACK library...') |
| all.append(f) |
| log.write('=== Checking all LAPACK functions...') |
| if check.Link(all,[],[]): |
| if check.Link(tmpdir,all,[],[]): |
| return [] |
| # check functions one by one |
| f += '#endif\n' |
| log.write('=== Checking LAPACK '+i+' function...') |
| if not check.Link([f],[],[]): |
| if not check.Link(tmpdir,[f],[],[]): |
| missing.append(i) |
| conf.write('#ifndef SLEPC_MISSING_LAPACK_' + i[1:].upper() + '\n#define SLEPC_MISSING_LAPACK_' + i[1:].upper() + ' 1\n#endif\n\n') |
| cmake.write('set (SLEPC_MISSING_LAPACK_' + i[1:].upper() + ' YES)\n') |
| import petscconf |
| import check |
| def Check(conf,vars,cmake,directory,libs): |
| def Check(conf,vars,cmake,tmpdir,directory,libs): |
| if petscconf.SCALAR == 'real': |
| if petscconf.PRECISION == 'single': |
| else: |
| dirs = check.GenerateGuesses('Arpack') |
| return check.FortranLib(conf,vars,cmake,'ARPACK',dirs,libs,functions) |
| return check.FortranLib(tmpdir,conf,vars,cmake,'ARPACK',dirs,libs,functions) |
| import petscconf |
| import log |
| def LinkWithOutput(functions,callbacks,flags): |
| def LinkWithOutput(tmpdir,functions,callbacks,flags): |
| code = '#include "petscksp.h"\n' |
| code += 'EXTERN_C_BEGIN\n' |
| for f in functions: |
| code += f + '();\n' |
| code += 'return 0;\n}\n' |
| os.chdir('config') |
| cfile = open('checklink.c','w') |
| cfile = open(os.sep.join([tmpdir,'checklink.c']),'w') |
| cfile.write(code) |
| cfile.close() |
| (result, output) = commands.getstatusoutput(petscconf.MAKE + ' checklink TESTFLAGS="'+str.join(' ',flags)+'"') |
| if os.path.exists('checklink.o'): |
| os.unlink('checklink.o') |
| os.chdir(os.pardir) |
| (result, output) = commands.getstatusoutput(petscconf.MAKE + ' -C ' + tmpdir + ' checklink TESTFLAGS="'+str.join(' ',flags)+'"') |
| if result: |
| return (0,code + output) |
| else: |
| return (1,code + output) |
| def Link(functions,callbacks,flags): |
| (result, output) = LinkWithOutput(functions,callbacks,flags) |
| def Link(tmpdir,functions,callbacks,flags): |
| (result, output) = LinkWithOutput(tmpdir,functions,callbacks,flags) |
| log.write(output) |
| return result |
| def FortranLink(functions,callbacks,flags): |
| def FortranLink(tmpdir,functions,callbacks,flags): |
| output = '\n=== With linker flags: '+str.join(' ',flags) |
| f = [] |
| c = [] |
| for i in callbacks: |
| c.append(i+'_') |
| (result, output1) = LinkWithOutput(f,c,flags) |
| (result, output1) = LinkWithOutput(tmpdir,f,c,flags) |
| output1 = '\n====== With underscore Fortran names\n' + output1 |
| if result: return ('UNDERSCORE',output1) |
| c = [] |
| for i in callbacks: |
| c.append(i.upper()) |
| (result, output2) = LinkWithOutput(f,c,flags) |
| (result, output2) = LinkWithOutput(tmpdir,f,c,flags) |
| output2 = '\n====== With capital Fortran names\n' + output2 |
| if result: return ('CAPS',output2) |
| (result, output3) = LinkWithOutput(functions,callbacks,flags) |
| (result, output3) = LinkWithOutput(tmpdir,functions,callbacks,flags) |
| output3 = '\n====== With unmodified Fortran names\n' + output3 |
| if result: return ('STDCALL',output3) |
| flags = ['-L' + d] + l |
| else: |
| flags = l |
| (mangling, output) = FortranLink(functions,callbacks,flags) |
| (mangling, output) = FortranLink(tmpdir,functions,callbacks,flags) |
| error += output |
| if mangling: break |
| if mangling: break |
| import petscconf |
| import check |
| def Check(conf,vars,cmake,directory,libs): |
| def Check(conf,vars,cmake,tmpdir,directory,libs): |
| if petscconf.SCALAR == 'complex': |
| sys.exit('ERROR: TRLAN does not support complex numbers.') |
| else: |
| dirs = check.GenerateGuesses('TRLan') |
| return check.FortranLib(conf,vars,cmake,'TRLAN',dirs,libs,functions) |
| return check.FortranLib(tmpdir,conf,vars,cmake,'TRLAN',dirs,libs,functions) |
| import sys |
| import time |
| import commands |
| import tempfile |
| import shutil |
| # Use en_US as language so that compiler messages are in English |
| if 'LC_LOCAL' in os.environ and os.environ['LC_LOCAL'] != '' and os.environ['LC_LOCAL'] != 'en_US' and os.environ['LC_LOCAL']!= 'en_US.UTF-8': os.environ['LC_LOCAL'] = 'en_US.UTF-8' |
| elif i.startswith('--h') or i.startswith('-h') or i.startswith('-?'): |
| print 'SLEPc Configure Help' |
| print '-'*80 |
| print ' --prefix=<dir> : Specifiy location to install SLEPc (e.g., /usr/local)' |
| print ' --prefix=<dir> : Specify location to install SLEPc (e.g., /usr/local)' |
| print 'ARPACK:' |
| print ' --with-arpack : Indicate if you wish to test for ARPACK (PARPACK)' |
| print ' --with-arpack-dir=<dir> : Indicate the directory for ARPACK libraries' |
| if prefixinstall and os.path.isfile(os.sep.join([prefixdir,'include','slepc.h'])): |
| sys.exit('ERROR: prefix directory ' + prefixdir + ' contains files from a previous installation') |
| # Create temporary directory and makefile for running tests |
| try: |
| tmpdir = tempfile.mkdtemp(prefix='slepc-') |
| if not os.path.isdir(tmpdir): os.mkdir(tmpdir) |
| except: |
| sys.exit('ERROR: cannot create temporary directory') |
| try: |
| makefile = open(os.sep.join([tmpdir,'makefile']),'w') |
| makefile.write('include ${PETSC_DIR}/conf/variables\n') |
| makefile.write('include ${PETSC_DIR}/conf/rules\n') |
| makefile.write('checklink: checklink.o chkopts\n') |
| makefile.write('\t${CLINKER} -o checklink checklink.o ${TESTFLAGS} ${PETSC_KSP_LIB}\n') |
| makefile.write('\t@${RM} -f checklink checklink.o\n') |
| makefile.write('LOCDIR = ./\n') |
| makefile.close() |
| except: |
| sys.exit('ERROR: cannot create makefile in temporary directory') |
| # Open log file |
| log.Open(os.sep.join([confdir,'configure.log'])) |
| log.write('='*80) |
| if petscconf.ISINSTALL: |
| if os.path.realpath(petscconf.DESTDIR) != os.path.realpath(petscdir): |
| log.Println('WARNING: PETSC_DIR does not point to PETSc installation path') |
| if not check.Link([],[],[]): |
| if not check.Link(tmpdir,[],[],[]): |
| log.Exit('ERROR: Unable to link with PETSc') |
| # Check for external packages |
| if havearpack: |
| arpacklibs = arpack.Check(slepcconf,slepcvars,cmake,arpackdir,arpacklibs) |
| arpacklibs = arpack.Check(slepcconf,slepcvars,cmake,tmpdir,arpackdir,arpacklibs) |
| if haveblzpack: |
| blzpacklibs = blzpack.Check(slepcconf,slepcvars,cmake,blzpackdir,blzpacklibs) |
| blzpacklibs = blzpack.Check(slepcconf,slepcvars,cmake,tmpdir,blzpackdir,blzpacklibs) |
| if havetrlan: |
| trlanlibs = trlan.Check(slepcconf,slepcvars,cmake,trlandir,trlanlibs) |
| trlanlibs = trlan.Check(slepcconf,slepcvars,cmake,tmpdir,trlandir,trlanlibs) |
| if haveprimme: |
| primmelibs = primme.Check(slepcconf,slepcvars,cmake,primmedir,primmelibs) |
| primmelibs = primme.Check(slepcconf,slepcvars,cmake,tmpdir,primmedir,primmelibs) |
| if getblopex: |
| blopexlibs = blopex.Install(slepcconf,slepcvars,cmake,blopexurl,archdir) |
| blopexlibs = blopex.Install(slepcconf,slepcvars,cmake,tmpdir,blopexurl,archdir) |
| haveblopex = 1 |
| # Check for missing LAPACK functions |
| missing = lapack.Check(slepcconf,slepcvars,cmake) |
| missing = lapack.Check(slepcconf,slepcvars,cmake,tmpdir) |
| # Download and install slepc4py |
| if getslepc4py: |
| slepcrules.close() |
| slepcconf.write('#endif\n') |
| slepcconf.close() |
| shutil.rmtree(tmpdir) |
| # Print summary |
| log.Println('') |
| import petscconf |
| import check |
| def Check(conf,vars,cmake,directory,libs): |
| def Check(conf,vars,cmake,tmpdir,directory,libs): |
| if petscconf.SCALAR == 'complex': |
| sys.exit('ERROR: BLZPACK does not support complex numbers.') |
| else: |
| dirs = check.GenerateGuesses('Blzpack') |
| return check.FortranLib(conf,vars,cmake,'BLZPACK',dirs,libs,functions) |
| return check.FortranLib(tmpdir,conf,vars,cmake,'BLZPACK',dirs,libs,functions) |