15d5a5a7bSMatthew Knepley#!/usr/bin/env python 22787667cSMatthew G Knepleyimport os, sys 34f8a5b45SBarry Smithimport commands 4a1eda5bfSSatish Balay# to load ~/.pythonrc.py before inserting correct BuildSystem to path 5a1eda5bfSSatish Balayimport user 67c9abfe7SSatish BalayextraLogs = [] 7b0b472b0SSatish Balaypetsc_arch = '' 84b8aa89bSBarry Smith 92787667cSMatthew G Knepleyimport urllib 102787667cSMatthew G Knepleyimport tarfile 112787667cSMatthew G Knepley 122787667cSMatthew G Knepleydef untar(tar, path = '.', leading = ''): 132787667cSMatthew G Knepley if leading: 142787667cSMatthew G Knepley entries = [t.name for t in tar.getmembers()] 152787667cSMatthew G Knepley prefix = os.path.commonprefix(entries) 162787667cSMatthew G Knepley if prefix: 172787667cSMatthew G Knepley for tarinfo in tar.getmembers(): 182787667cSMatthew G Knepley tail = tarinfo.name.split(prefix, 1)[1] 192787667cSMatthew G Knepley tarinfo.name = os.path.join(leading, tail) 202787667cSMatthew G Knepley for tarinfo in tar.getmembers(): 212787667cSMatthew G Knepley tar.extract(tarinfo, path) 222787667cSMatthew G Knepley return 232787667cSMatthew G Knepley 242787667cSMatthew G Knepleydef downloadPackage(url, filename, targetDirname): 252787667cSMatthew G Knepley '''Download the tarball for a package at url, save it as filename, and untar it into targetDirname''' 262787667cSMatthew G Knepley filename, headers = urllib.urlretrieve(url, filename) 272787667cSMatthew G Knepley tar = tarfile.open(filename, 'r:gz') 282787667cSMatthew G Knepley untar(tar, targetDirname, leading = filename.split('.')[0]) 292787667cSMatthew G Knepley return 302787667cSMatthew G Knepley 3144b0d7f9SSatish Balay# Use en_US as language so that BuildSystem parses compiler messages in english 329b436e4bSSatish Balayif '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' 339b436e4bSSatish Balayif 'LANG' in os.environ and os.environ['LANG'] != '' and os.environ['LANG'] != 'en_US' and os.environ['LANG'] != 'en_US.UTF-8': os.environ['LANG'] = 'en_US.UTF-8' 3444b0d7f9SSatish Balay 35200fbeb4SSatish Balayif not hasattr(sys, 'version_info') or not sys.version_info[0] == 2 or not sys.version_info[1] >= 4: 36200fbeb4SSatish Balay print '*** You must have Python2 version 2.4 or higher to run ./configure *****' 37495ffa62SBarry Smith print '* Python is easy to install for end users or sys-admin. *' 3832077d6dSBarry Smith print '* http://www.python.org/download/ *' 3932077d6dSBarry Smith print '* *' 40495ffa62SBarry Smith print '* You CANNOT configure PETSc without Python *' 41f08646a8SSatish Balay print '* http://www.mcs.anl.gov/petsc/documentation/installation.html *' 42a0022257SSatish Balay print '*******************************************************************************' 43b26a8723SBarry Smith sys.exit(4) 442fb34ac0SMatthew Knepley 45ccb279e1SMatthew Knepleydef check_for_option_mistakes(opts): 4645faeebdSBarry Smith for opt in opts[1:]: 47cda0060aSMatthew Knepley name = opt.split('=')[0] 48ccb279e1SMatthew Knepley if name.find('_') >= 0: 49ccb279e1SMatthew Knepley exception = False 50f3fbd535SBarry Smith for exc in ['superlu_dist', 'PETSC_ARCH', 'PETSC_DIR', 'CXX_CXXFLAGS', 'LD_SHARED', 'CC_LINKER_FLAGS', 'CXX_LINKER_FLAGS', 'FC_LINKER_FLAGS', 'AR_FLAGS', 'C_VERSION', 'CXX_VERSION', 'FC_VERSION', 'size_t', 'MPI_Comm','MPI_Fint']: 51ccb279e1SMatthew Knepley if name.find(exc) >= 0: 52ccb279e1SMatthew Knepley exception = True 53ccb279e1SMatthew Knepley if not exception: 54ccb279e1SMatthew Knepley raise ValueError('The option '+name+' should probably be '+name.replace('_', '-')); 55ab610953SSatish Balay if opt.find('=') >=0: 56ab610953SSatish Balay optval = opt.split('=')[1] 57ab610953SSatish Balay if optval == 'ifneeded': 58ab610953SSatish Balay raise ValueError('The option '+opt+' should probably be '+opt.replace('ifneeded', '1')); 59ccb279e1SMatthew Knepley return 60ccb279e1SMatthew Knepley 612af240f0SSatish Balaydef check_for_option_changed(opts): 622af240f0SSatish Balay# Document changes in command line options here. 632af240f0SSatish Balay optMap = [('c-blas-lapack','f2cblaslapack')] 642af240f0SSatish Balay for opt in opts[1:]: 652af240f0SSatish Balay optname = opt.split('=')[0].strip('-') 662af240f0SSatish Balay for oldname,newname in optMap: 672af240f0SSatish Balay if optname.find(oldname) >=0: 682af240f0SSatish Balay raise ValueError('The option '+opt+' should probably be '+opt.replace(oldname,newname)) 692af240f0SSatish Balay return 702af240f0SSatish Balay 7159e9bfd6SSatish Balaydef check_petsc_arch(opts): 72c43ea0feSSatish Balay # If PETSC_ARCH not specified - use script name (if not configure.py) 73b0b472b0SSatish Balay global petsc_arch 74c43ea0feSSatish Balay found = 0 7559e9bfd6SSatish Balay for name in opts: 76c43ea0feSSatish Balay if name.find('PETSC_ARCH=') >= 0: 77b0b472b0SSatish Balay petsc_arch=name.split('=')[1] 78c43ea0feSSatish Balay found = 1 7959e9bfd6SSatish Balay break 8059e9bfd6SSatish Balay # If not yet specified - use the filename of script 81c43ea0feSSatish Balay if not found: 8259e9bfd6SSatish Balay filename = os.path.basename(sys.argv[0]) 83e68ebbecSBarry Smith if not filename.startswith('configure') and not filename.startswith('reconfigure') and not filename.startswith('setup'): 84b0b472b0SSatish Balay petsc_arch=os.path.splitext(os.path.basename(sys.argv[0]))[0] 85b0b472b0SSatish Balay useName = 'PETSC_ARCH='+petsc_arch 8659e9bfd6SSatish Balay opts.append(useName) 871937db7aSSatish Balay return 0 884b8aa89bSBarry Smith 891921852fSSatish Balaydef chkwinf90(): 906a8f6897SSatish Balay for arg in sys.argv: 911921852fSSatish Balay if (arg.find('win32fe') >= 0 and (arg.find('f90') >=0 or arg.find('ifort') >=0)): 926a8f6897SSatish Balay return 1 936a8f6897SSatish Balay return 0 946a8f6897SSatish Balay 958a4600f2SSatish Balaydef chkdosfiles(): 968a4600f2SSatish Balay if not os.path.exists('/usr/bin/cygcheck.exe'): return 97f4f48842SSatish Balay if os.path.exists('.hg'): 988a4600f2SSatish Balay (status,output) = commands.getstatusoutput('hg showconfig paths.default') 998a4600f2SSatish Balay if not status and output: return 100f4f48842SSatish Balay if os.path.exists('.git'): 101f4f48842SSatish Balay (status,output) = commands.getstatusoutput('git rev-parse') 102f4f48842SSatish Balay if not status: return 1038a4600f2SSatish Balay # cygwin - but not a hg clone - so check files in bin dir 1048a4600f2SSatish Balay (status,output) = commands.getstatusoutput('file bin/*') 1058a4600f2SSatish Balay if status: 1068a4600f2SSatish Balay print '===============================================================================' 1078a4600f2SSatish Balay print ' *** Incomplete cygwin install? command "file" not found! **' 1088a4600f2SSatish Balay print '===============================================================================' 1098a4600f2SSatish Balay return 1108a4600f2SSatish Balay if output.find('with CRLF line terminators') >= 0: 1118a4600f2SSatish Balay print '===============================================================================' 1128a4600f2SSatish Balay print ' *** Scripts are in DOS mode. Was winzip used instead of tar? Converting.......' 1138a4600f2SSatish Balay print '===============================================================================' 1148a4600f2SSatish Balay (status,output) = commands.getstatusoutput('dos2unix bin/*') 1158a4600f2SSatish Balay if status: 1168a4600f2SSatish Balay print '===============================================================================' 1178a4600f2SSatish Balay print ' *** Incomplete cygwin install? command "dos2unix" not found! **' 1188a4600f2SSatish Balay print '===============================================================================' 1198a4600f2SSatish Balay return 1208a4600f2SSatish Balay 1216a8f6897SSatish Balaydef chkcygwinlink(): 1221921852fSSatish Balay if os.path.exists('/usr/bin/cygcheck.exe') and os.path.exists('/usr/bin/link.exe') and chkwinf90(): 1236a8f6897SSatish Balay if '--ignore-cygwin-link' in sys.argv: return 0 1246a8f6897SSatish Balay print '===============================================================================' 1251921852fSSatish Balay print ' *** Cygwin /usr/bin/link detected! Compiles with CVF/Intel f90 can break! **' 1266a8f6897SSatish Balay print ' *** To workarround do: "mv /usr/bin/link.exe /usr/bin/link-cygwin.exe" **' 1276a8f6897SSatish Balay print ' *** Or to ignore this check, use configure option: --ignore-cygwin-link **' 1286a8f6897SSatish Balay print '===============================================================================' 1296a8f6897SSatish Balay sys.exit(3) 1306a8f6897SSatish Balay return 0 1316a8f6897SSatish Balay 13285ef4d1eSSatish Balaydef chkbrokencygwin(): 1339dabcff0SSatish Balay if os.path.exists('/usr/bin/cygcheck.exe'): 1349dabcff0SSatish Balay buf = os.popen('/usr/bin/cygcheck.exe -c cygwin').read() 1359dabcff0SSatish Balay if buf.find('1.5.11-1') > -1: 136a0022257SSatish Balay print '===============================================================================' 137e2e64c6bSBarry Smith print ' *** cygwin-1.5.11-1 detected. ./configure fails with this version ***' 1381937db7aSSatish Balay print ' *** Please upgrade to cygwin-1.5.12-1 or newer version. This can ***' 1391937db7aSSatish Balay print ' *** be done by running cygwin-setup, selecting "next" all the way.***' 140a0022257SSatish Balay print '===============================================================================' 1411937db7aSSatish Balay sys.exit(3) 1429dabcff0SSatish Balay return 0 1439dabcff0SSatish Balay 144ee76e990SSatish Balaydef chkusingwindowspython(): 145ee76e990SSatish Balay if sys.platform == 'win32': 146ee76e990SSatish Balay print '===============================================================================' 147ee76e990SSatish Balay print ' *** Windows python detected. Please rerun ./configure with cygwin-python. ***' 148ee76e990SSatish Balay print '===============================================================================' 149ee76e990SSatish Balay sys.exit(3) 150ee76e990SSatish Balay return 0 151ee76e990SSatish Balay 15214f5c25cSSatish Balaydef chkcygwinpython(): 15314f5c25cSSatish Balay if os.path.exists('/usr/bin/cygcheck.exe') and sys.platform == 'cygwin' : 1541937db7aSSatish Balay sys.argv.append('--useThreads=0') 1551937db7aSSatish Balay extraLogs.append('''\ 156a0022257SSatish Balay=============================================================================== 15714f5c25cSSatish Balay** Cygwin-python detected. Threads do not work correctly. *** 15814f5c25cSSatish Balay** Disabling thread usage for this run of ./configure ******* 159a0022257SSatish Balay===============================================================================''') 16071384062SSatish Balay return 0 16171384062SSatish Balay 1621937db7aSSatish Balaydef chkrhl9(): 1631937db7aSSatish Balay if os.path.exists('/etc/redhat-release'): 164836c2c52SSatish Balay try: 165594eb360SSatish Balay file = open('/etc/redhat-release','r') 166836c2c52SSatish Balay buf = file.read() 167836c2c52SSatish Balay file.close() 168836c2c52SSatish Balay except: 169836c2c52SSatish Balay # can't read file - assume dangerous RHL9 1701937db7aSSatish Balay buf = 'Shrike' 171836c2c52SSatish Balay if buf.find('Shrike') > -1: 1721937db7aSSatish Balay sys.argv.append('--useThreads=0') 1731937db7aSSatish Balay extraLogs.append('''\ 174a0022257SSatish Balay============================================================================== 1751937db7aSSatish Balay *** RHL9 detected. Threads do not work correctly with this distribution *** 176e2e64c6bSBarry Smith ****** Disabling thread usage for this run of ./configure ********* 177a0022257SSatish Balay===============================================================================''') 178836c2c52SSatish Balay return 0 179836c2c52SSatish Balay 180da58527dSSatish Balaydef check_broken_configure_log_links(): 181da58527dSSatish Balay '''Sometime symlinks can get broken if the original files are deleted. Delete such broken links''' 182da58527dSSatish Balay import os 183da58527dSSatish Balay for logfile in ['configure.log','configure.log.bkp']: 184da58527dSSatish Balay if os.path.islink(logfile) and not os.path.isfile(logfile): os.remove(logfile) 185da58527dSSatish Balay return 186da58527dSSatish Balay 187da1d79b4SSatish Balaydef move_configure_log(framework): 188da1d79b4SSatish Balay '''Move configure.log to PETSC_ARCH/conf - and update configure.log.bkp in both locations appropriately''' 189b0b472b0SSatish Balay global petsc_arch 190b0b472b0SSatish Balay 191b0b472b0SSatish Balay if hasattr(framework,'arch'): petsc_arch = framework.arch 192b0b472b0SSatish Balay if hasattr(framework,'logName'): curr_file = framework.logName 193b0b472b0SSatish Balay else: curr_file = 'configure.log' 194b0b472b0SSatish Balay 195b0b472b0SSatish Balay if petsc_arch: 196da1d79b4SSatish Balay import shutil 197da1d79b4SSatish Balay import os 198b0b472b0SSatish Balay 199b0b472b0SSatish Balay # Just in case - confdir is not created 200b0b472b0SSatish Balay conf_dir = os.path.join(petsc_arch,'conf') 201b0b472b0SSatish Balay if not os.path.isdir(petsc_arch): os.mkdir(petsc_arch) 202b0b472b0SSatish Balay if not os.path.isdir(conf_dir): os.mkdir(conf_dir) 203b0b472b0SSatish Balay 204da1d79b4SSatish Balay curr_bkp = curr_file + '.bkp' 205b0b472b0SSatish Balay new_file = os.path.join(conf_dir,curr_file) 206da1d79b4SSatish Balay new_bkp = new_file + '.bkp' 207da1d79b4SSatish Balay 208da1d79b4SSatish Balay # Keep backup in $PETSC_ARCH/conf location 209da1d79b4SSatish Balay if os.path.isfile(new_bkp): os.remove(new_bkp) 210da1d79b4SSatish Balay if os.path.isfile(new_file): os.rename(new_file,new_bkp) 2119e50940cSSatish Balay if os.path.isfile(curr_file): 2129e50940cSSatish Balay shutil.copyfile(curr_file,new_file) 2139e50940cSSatish Balay os.remove(curr_file) 214da58527dSSatish Balay if os.path.isfile(new_file): os.symlink(new_file,curr_file) 215da1d79b4SSatish Balay # If the old bkp is using the same PETSC_ARCH/conf - then update bkp link 216da1d79b4SSatish Balay if os.path.realpath(curr_bkp) == os.path.realpath(new_file): 217da58527dSSatish Balay if os.path.isfile(curr_bkp): os.remove(curr_bkp) 218da58527dSSatish Balay if os.path.isfile(new_bkp): os.symlink(new_bkp,curr_bkp) 219da1d79b4SSatish Balay return 220da1d79b4SSatish Balay 2215d5a5a7bSMatthew Knepleydef petsc_configure(configure_options): 2224a532159SBarry Smith try: 2234a532159SBarry Smith petscdir = os.environ['PETSC_DIR'] 2244a532159SBarry Smith sys.path.append(os.path.join(petscdir,'bin')) 2254a532159SBarry Smith import petscnagupgrade 2264a532159SBarry Smith file = os.path.join(petscdir,'.nagged') 2274a532159SBarry Smith if not petscnagupgrade.naggedtoday(file): 2284a532159SBarry Smith petscnagupgrade.currentversion(petscdir) 2294a532159SBarry Smith except: 2304a532159SBarry Smith pass 231a0022257SSatish Balay print '===============================================================================' 23259e9bfd6SSatish Balay print ' Configuring PETSc to compile on your system ' 233a0022257SSatish Balay print '===============================================================================' 23459e9bfd6SSatish Balay 235a258c2c4SMatthew G Knepley try: 236c43ea0feSSatish Balay # Command line arguments take precedence (but don't destroy argv[0]) 237c43ea0feSSatish Balay sys.argv = sys.argv[:1] + configure_options + sys.argv[1:] 238ccb279e1SMatthew Knepley check_for_option_mistakes(sys.argv) 2392af240f0SSatish Balay check_for_option_changed(sys.argv) 240a258c2c4SMatthew G Knepley except (TypeError, ValueError), e: 241a258c2c4SMatthew G Knepley emsg = str(e) 242a258c2c4SMatthew G Knepley if not emsg.endswith('\n'): emsg = emsg+'\n' 243a258c2c4SMatthew G Knepley msg ='*******************************************************************************\n'\ 244a258c2c4SMatthew G Knepley +' ERROR in COMMAND LINE ARGUMENT to ./configure \n' \ 245a258c2c4SMatthew G Knepley +'-------------------------------------------------------------------------------\n' \ 246a258c2c4SMatthew G Knepley +emsg+'*******************************************************************************\n' 247a258c2c4SMatthew G Knepley sys.exit(msg) 24859e9bfd6SSatish Balay # check PETSC_ARCH 24959e9bfd6SSatish Balay check_petsc_arch(sys.argv) 250da58527dSSatish Balay check_broken_configure_log_links() 2515fb2c094SBarry Smith 252c22cdea9SBarry Smith # support a few standard configure option types 253ed6a7445SBarry Smith for l in range(0,len(sys.argv)): 254c22cdea9SBarry Smith name = sys.argv[l] 255637cc2ebSSatish Balay if name.find('enable-') >= 0: 256193cd51eSMatthew Knepley if name.find('=') == -1: 257193cd51eSMatthew Knepley sys.argv[l] = name.replace('enable-','with-')+'=1' 258193cd51eSMatthew Knepley else: 259193cd51eSMatthew Knepley head, tail = name.split('=', 1) 260193cd51eSMatthew Knepley sys.argv[l] = head.replace('enable-','with-')+'='+tail 261637cc2ebSSatish Balay if name.find('disable-') >= 0: 262193cd51eSMatthew Knepley if name.find('=') == -1: 263193cd51eSMatthew Knepley sys.argv[l] = name.replace('disable-','with-')+'=0' 264193cd51eSMatthew Knepley else: 265193cd51eSMatthew Knepley head, tail = name.split('=', 1) 266193cd51eSMatthew Knepley if tail == '1': tail = '0' 267193cd51eSMatthew Knepley sys.argv[l] = head.replace('disable-','with-')+'='+tail 268637cc2ebSSatish Balay if name.find('without-') >= 0: 269193cd51eSMatthew Knepley if name.find('=') == -1: 270193cd51eSMatthew Knepley sys.argv[l] = name.replace('without-','with-')+'=0' 271193cd51eSMatthew Knepley else: 272193cd51eSMatthew Knepley head, tail = name.split('=', 1) 273193cd51eSMatthew Knepley if tail == '1': tail = '0' 274193cd51eSMatthew Knepley sys.argv[l] = head.replace('without-','with-')+'='+tail 275adc3e427SMatthew Knepley 2769dabcff0SSatish Balay # Check for broken cygwin 2771937db7aSSatish Balay chkbrokencygwin() 278d65f3bddSMatthew Knepley # Disable threads on RHL9 2791937db7aSSatish Balay chkrhl9() 280ee76e990SSatish Balay # Make sure cygwin-python is used on windows 281ee76e990SSatish Balay chkusingwindowspython() 28214f5c25cSSatish Balay # Threads don't work for cygwin & python... 28314f5c25cSSatish Balay chkcygwinpython() 2846a8f6897SSatish Balay chkcygwinlink() 2858a4600f2SSatish Balay chkdosfiles() 2869dabcff0SSatish Balay 28787282423SMatthew Knepley # Should be run from the toplevel 288dbca6d9dSSatish Balay configDir = os.path.abspath('config') 289f8833479SBarry Smith bsDir = os.path.join(configDir, 'BuildSystem') 290f8833479SBarry Smith if not os.path.isdir(configDir): 2915d5a5a7bSMatthew Knepley raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.')) 29287282423SMatthew Knepley sys.path.insert(0, bsDir) 293f8833479SBarry Smith sys.path.insert(0, configDir) 294e69ef9dfSMatthew Knepley import config.base 2955d5a5a7bSMatthew Knepley import config.framework 296f56be888SMatthew Knepley import cPickle 2974f8a5b45SBarry Smith 2989dd2fdb1SMatthew Knepley framework = None 2999dd2fdb1SMatthew Knepley try: 3001a784507SMatthew Knepley framework = config.framework.Framework(['--configModules=PETSc.Configure','--optionsModule=PETSc.compilerOptions']+sys.argv[1:], loadArgDB = 0) 301d65f3bddSMatthew Knepley framework.setup() 302d65f3bddSMatthew Knepley framework.logPrint('\n'.join(extraLogs)) 303f24f64feSBarry Smith framework.configure(out = sys.stdout) 304358ebc22SMatthew Knepley framework.storeSubstitutions(framework.argDB) 305f56be888SMatthew Knepley framework.argDB['configureCache'] = cPickle.dumps(framework) 3067c939e48SSatish Balay framework.printSummary() 30712c1d45bSMatthew G Knepley framework.argDB.save(force = True) 3087cfd0b05SBarry Smith framework.logClear() 309eefa2c0fSBarry Smith framework.closeLog() 3109e50940cSSatish Balay try: 311da1d79b4SSatish Balay move_configure_log(framework) 3129e50940cSSatish Balay except: 3139e50940cSSatish Balay # perhaps print an error about unable to shuffle logs? 3149e50940cSSatish Balay pass 315dd50d019SBarry Smith return 0 316e69ef9dfSMatthew Knepley except (RuntimeError, config.base.ConfigureSetupError), e: 3177d670a3cSBarry Smith emsg = str(e) 31842351d26SSatish Balay if not emsg.endswith('\n'): emsg = emsg+'\n' 319a0022257SSatish Balay msg ='*******************************************************************************\n'\ 320fe09c992SBarry Smith +' UNABLE to CONFIGURE with GIVEN OPTIONS (see configure.log for details):\n' \ 321a0022257SSatish Balay +'-------------------------------------------------------------------------------\n' \ 322a0022257SSatish Balay +emsg+'*******************************************************************************\n' 323e9f3bb17SBarry Smith se = '' 3249dd2fdb1SMatthew Knepley except (TypeError, ValueError), e: 3257d670a3cSBarry Smith emsg = str(e) 32642351d26SSatish Balay if not emsg.endswith('\n'): emsg = emsg+'\n' 327a0022257SSatish Balay msg ='*******************************************************************************\n'\ 328e2e64c6bSBarry Smith +' ERROR in COMMAND LINE ARGUMENT to ./configure \n' \ 329a0022257SSatish Balay +'-------------------------------------------------------------------------------\n' \ 330a0022257SSatish Balay +emsg+'*******************************************************************************\n' 3311a02243aSBarry Smith se = '' 33296dc2fe8SMatthew Knepley except ImportError, e : 3337d670a3cSBarry Smith emsg = str(e) 33442351d26SSatish Balay if not emsg.endswith('\n'): emsg = emsg+'\n' 335a0022257SSatish Balay msg ='*******************************************************************************\n'\ 336e2e64c6bSBarry Smith +' UNABLE to FIND MODULE for ./configure \n' \ 337a0022257SSatish Balay +'-------------------------------------------------------------------------------\n' \ 338a0022257SSatish Balay +emsg+'*******************************************************************************\n' 33996dc2fe8SMatthew Knepley se = '' 34001def6f0SMatthew Knepley except OSError, e : 34101def6f0SMatthew Knepley emsg = str(e) 34201def6f0SMatthew Knepley if not emsg.endswith('\n'): emsg = emsg+'\n' 343a0022257SSatish Balay msg ='*******************************************************************************\n'\ 344e2e64c6bSBarry Smith +' UNABLE to EXECUTE BINARIES for ./configure \n' \ 345a0022257SSatish Balay +'-------------------------------------------------------------------------------\n' \ 346a0022257SSatish Balay +emsg+'*******************************************************************************\n' 34701def6f0SMatthew Knepley se = '' 348d7d3c4beSMatthew Knepley except SystemExit, e: 349d7d3c4beSMatthew Knepley if e.code is None or e.code == 0: 350d7d3c4beSMatthew Knepley return 351a0022257SSatish Balay msg ='*******************************************************************************\n'\ 352b1dada7fSMatthew Knepley +' CONFIGURATION FAILURE (Please send configure.log to petsc-maint@mcs.anl.gov)\n' \ 353a0022257SSatish Balay +'*******************************************************************************\n' 354d7d3c4beSMatthew Knepley se = str(e) 355e9f3bb17SBarry Smith except Exception, e: 356a0022257SSatish Balay msg ='*******************************************************************************\n'\ 357fe09c992SBarry Smith +' CONFIGURATION CRASH (Please send configure.log to petsc-maint@mcs.anl.gov)\n' \ 358a0022257SSatish Balay +'*******************************************************************************\n' 359e9f3bb17SBarry Smith se = str(e) 360e9f3bb17SBarry Smith 361e9f3bb17SBarry Smith print msg 3629dd2fdb1SMatthew Knepley if not framework is None: 3639dd2fdb1SMatthew Knepley framework.logClear() 364e9f3bb17SBarry Smith if hasattr(framework, 'log'): 36522c95ba3SMatthew G Knepley try: 366*d71f8ab3SSatish Balay if hasattr(framework,'compilerDefines'): 367bd5137a2SBarry Smith framework.log.write('**** Configure header '+framework.compilerDefines+' ****\n') 368febd46b0SSatish Balay framework.outputHeader(framework.log) 369*d71f8ab3SSatish Balay if hasattr(framework,'compilerFixes'): 370bd5137a2SBarry Smith framework.log.write('**** C specific Configure header '+framework.compilerFixes+' ****\n') 371febd46b0SSatish Balay framework.outputCHeader(framework.log) 37222c95ba3SMatthew G Knepley except Exception, e: 37322c95ba3SMatthew G Knepley framework.log.write('Problem writing headers to log: '+str(e)) 374f6614063SBarry Smith import traceback 375b1dada7fSMatthew Knepley try: 376f24f64feSBarry Smith framework.log.write(msg+se) 377f24f64feSBarry Smith traceback.print_tb(sys.exc_info()[2], file = framework.log) 378f73e6a6cSSatish Balay if hasattr(framework,'log'): framework.log.close() 379da1d79b4SSatish Balay move_configure_log(framework) 380b1dada7fSMatthew Knepley except: 381b1dada7fSMatthew Knepley pass 382e9f3bb17SBarry Smith sys.exit(1) 3835a74f024SMatthew Knepley else: 3845a74f024SMatthew Knepley print se 3855a74f024SMatthew Knepley import traceback 3865a74f024SMatthew Knepley traceback.print_tb(sys.exc_info()[2]) 387f73e6a6cSSatish Balay if hasattr(framework,'log'): framework.log.close() 3885d5a5a7bSMatthew Knepley 3895d5a5a7bSMatthew Knepleyif __name__ == '__main__': 390a030c540SBarry Smith petsc_configure([]) 391759acf64SBarry Smith 392