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 944b0d7f9SSatish Balay# Use en_US as language so that BuildSystem parses compiler messages in english 109b436e4bSSatish 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' 119b436e4bSSatish 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' 1244b0d7f9SSatish Balay 13200fbeb4SSatish Balayif not hasattr(sys, 'version_info') or not sys.version_info[0] == 2 or not sys.version_info[1] >= 4: 14200fbeb4SSatish Balay print '*** You must have Python2 version 2.4 or higher to run ./configure *****' 15495ffa62SBarry Smith print '* Python is easy to install for end users or sys-admin. *' 1632077d6dSBarry Smith print '* http://www.python.org/download/ *' 1732077d6dSBarry Smith print '* *' 18495ffa62SBarry Smith print '* You CANNOT configure PETSc without Python *' 19f08646a8SSatish Balay print '* http://www.mcs.anl.gov/petsc/documentation/installation.html *' 20a0022257SSatish Balay print '*******************************************************************************' 21b26a8723SBarry Smith sys.exit(4) 222fb34ac0SMatthew Knepley 23ccb279e1SMatthew Knepleydef check_for_option_mistakes(opts): 2445faeebdSBarry Smith for opt in opts[1:]: 25cda0060aSMatthew Knepley name = opt.split('=')[0] 26ccb279e1SMatthew Knepley if name.find('_') >= 0: 27ccb279e1SMatthew Knepley exception = False 28d305a81bSVasiliy Kozyrev for exc in ['mkl_cpardiso', 'mkl_pardiso', 'superlu_dist', 'superlu_mt', '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','int64_t']: 29ccb279e1SMatthew Knepley if name.find(exc) >= 0: 30ccb279e1SMatthew Knepley exception = True 31ccb279e1SMatthew Knepley if not exception: 32ccb279e1SMatthew Knepley raise ValueError('The option '+name+' should probably be '+name.replace('_', '-')); 33ab610953SSatish Balay if opt.find('=') >=0: 34ab610953SSatish Balay optval = opt.split('=')[1] 35ab610953SSatish Balay if optval == 'ifneeded': 36ab610953SSatish Balay raise ValueError('The option '+opt+' should probably be '+opt.replace('ifneeded', '1')); 37ccb279e1SMatthew Knepley return 38ccb279e1SMatthew Knepley 39*2f393ef5SBarry Smithdef check_for_unsupported_combinations(opts): 40*2f393ef5SBarry Smith if '--with-precision=single' in opts and '--with-clanguage=cxx' in opts and '--with-scalar-type=complex' in opts: 41*2f393ef5SBarry Smith sys.exit(ValueError('PETSc does not support single precision complex with C++ clanguage, run with --with-clanguage=c')) 42*2f393ef5SBarry Smith 432af240f0SSatish Balaydef check_for_option_changed(opts): 442af240f0SSatish Balay# Document changes in command line options here. 4569c3d79aSBarry Smith optMap = [('with-64bit-indices','with-64-bit-indices'),('c-blas-lapack','f2cblaslapack'),('cholmod','suitesparse'),('umfpack','suitesparse'),('f-blas-lapack','fblaslapack')] 462af240f0SSatish Balay for opt in opts[1:]: 472af240f0SSatish Balay optname = opt.split('=')[0].strip('-') 482af240f0SSatish Balay for oldname,newname in optMap: 492af240f0SSatish Balay if optname.find(oldname) >=0: 502af240f0SSatish Balay raise ValueError('The option '+opt+' should probably be '+opt.replace(oldname,newname)) 512af240f0SSatish Balay return 522af240f0SSatish Balay 5359e9bfd6SSatish Balaydef check_petsc_arch(opts): 54c43ea0feSSatish Balay # If PETSC_ARCH not specified - use script name (if not configure.py) 55b0b472b0SSatish Balay global petsc_arch 56c43ea0feSSatish Balay found = 0 5759e9bfd6SSatish Balay for name in opts: 58c43ea0feSSatish Balay if name.find('PETSC_ARCH=') >= 0: 59b0b472b0SSatish Balay petsc_arch=name.split('=')[1] 60c43ea0feSSatish Balay found = 1 6159e9bfd6SSatish Balay break 6259e9bfd6SSatish Balay # If not yet specified - use the filename of script 63c43ea0feSSatish Balay if not found: 6459e9bfd6SSatish Balay filename = os.path.basename(sys.argv[0]) 65e68ebbecSBarry Smith if not filename.startswith('configure') and not filename.startswith('reconfigure') and not filename.startswith('setup'): 66b0b472b0SSatish Balay petsc_arch=os.path.splitext(os.path.basename(sys.argv[0]))[0] 67b0b472b0SSatish Balay useName = 'PETSC_ARCH='+petsc_arch 6859e9bfd6SSatish Balay opts.append(useName) 691937db7aSSatish Balay return 0 704b8aa89bSBarry Smith 71f08ee00aSJason Sarichdef chkenable(): 72f08ee00aSJason Sarich #Replace all 'enable-'/'disable-' with 'with-'=0/1/tail 73f08ee00aSJason Sarich #enable-fortran is a special case, the resulting --with-fortran is ambiguous. 74f08ee00aSJason Sarich #Would it mean --with-fc= or --with-fortran-interfaces=? 75f08ee00aSJason Sarich for l in range(0,len(sys.argv)): 76f08ee00aSJason Sarich name = sys.argv[l] 77f08ee00aSJason Sarich if name.find('enable-fortran') >= 0: 78f08ee00aSJason Sarich if name.find('=') == -1: 79f08ee00aSJason Sarich sys.argv[l] = name.replace('enable-fortran','with-fortran-interfaces')+'=1' 80f08ee00aSJason Sarich else: 81f08ee00aSJason Sarich head, tail = name.split('=', 1) 82f08ee00aSJason Sarich sys.argv[l] = head.replace('enable-fortran','with-fortran-interfaces')+'='+tail 83f08ee00aSJason Sarich continue 84f08ee00aSJason Sarich if name.find('disable-fortran') >= 0: 85f08ee00aSJason Sarich if name.find('=') == -1: 86f08ee00aSJason Sarich sys.argv[l] = name.replace('disable-fortran','with-fortran-interfaces')+'=0' 87f08ee00aSJason Sarich else: 88f08ee00aSJason Sarich head, tail = name.split('=', 1) 89f08ee00aSJason Sarich if tail == '1': tail = '0' 90f08ee00aSJason Sarich sys.argv[l] = head.replace('disable-fortran','with-fortran-interfaces')+'='+tail 91f08ee00aSJason Sarich continue 92f08ee00aSJason Sarich 932b700d61SJason Sarich if name.find('enable-cxx') >= 0: 942b700d61SJason Sarich if name.find('=') == -1: 952b700d61SJason Sarich sys.argv[l] = name.replace('enable-cxx','with-clanguage=C++') 962b700d61SJason Sarich else: 972b700d61SJason Sarich head, tail = name.split('=', 1) 982b700d61SJason Sarich if tail=='0': 992b700d61SJason Sarich sys.argv[l] = head.replace('enable-cxx','with-clanguage=C') 1002b700d61SJason Sarich else: 1012b700d61SJason Sarich sys.argv[l] = head.replace('enable-cxx','with-clanguage=C++') 1022b700d61SJason Sarich continue 1032b700d61SJason Sarich if name.find('disable-cxx') >= 0: 1042b700d61SJason Sarich if name.find('=') == -1: 1052b700d61SJason Sarich sys.argv[l] = name.replace('disable-cxx','with-clanguage=C') 1062b700d61SJason Sarich else: 1072b700d61SJason Sarich head, tail = name.split('=', 1) 1082b700d61SJason Sarich if tail == '0': 1092b700d61SJason Sarich sys.argv[l] = head.replace('disable-cxx','with-clanguage=C++') 1102b700d61SJason Sarich else: 1112b700d61SJason Sarich sys.argv[l] = head.replace('disable-cxx','with-clanguage=C') 1122b700d61SJason Sarich continue 1132b700d61SJason Sarich 114f08ee00aSJason Sarich 115f08ee00aSJason Sarich if name.find('enable-') >= 0: 116f08ee00aSJason Sarich if name.find('=') == -1: 117f08ee00aSJason Sarich sys.argv[l] = name.replace('enable-','with-')+'=1' 118f08ee00aSJason Sarich else: 119f08ee00aSJason Sarich head, tail = name.split('=', 1) 120f08ee00aSJason Sarich sys.argv[l] = head.replace('enable-','with-')+'='+tail 121f08ee00aSJason Sarich if name.find('disable-') >= 0: 122f08ee00aSJason Sarich if name.find('=') == -1: 123f08ee00aSJason Sarich sys.argv[l] = name.replace('disable-','with-')+'=0' 124f08ee00aSJason Sarich else: 125f08ee00aSJason Sarich head, tail = name.split('=', 1) 126f08ee00aSJason Sarich if tail == '1': tail = '0' 127f08ee00aSJason Sarich sys.argv[l] = head.replace('disable-','with-')+'='+tail 128f08ee00aSJason Sarich if name.find('without-') >= 0: 129f08ee00aSJason Sarich if name.find('=') == -1: 130f08ee00aSJason Sarich sys.argv[l] = name.replace('without-','with-')+'=0' 131f08ee00aSJason Sarich else: 132f08ee00aSJason Sarich head, tail = name.split('=', 1) 133f08ee00aSJason Sarich if tail == '1': tail = '0' 134f08ee00aSJason Sarich sys.argv[l] = head.replace('without-','with-')+'='+tail 135f08ee00aSJason Sarich 1368fd71741SJason Sarich 137f08ee00aSJason Sarichdef chksynonyms(): 138f08ee00aSJason Sarich #replace common configure options with ones that PETSc BuildSystem recognizes 139f08ee00aSJason Sarich for l in range(0,len(sys.argv)): 140f08ee00aSJason Sarich name = sys.argv[l] 141f08ee00aSJason Sarich 142f08ee00aSJason Sarich 143ce54fb35SBarry Smith if name.find('with-debug=') >= 0 or name.endswith('with-debug'): 144f08ee00aSJason Sarich if name.find('=') == -1: 145f08ee00aSJason Sarich sys.argv[l] = name.replace('with-debug','with-debugging')+'=1' 146f08ee00aSJason Sarich else: 147f08ee00aSJason Sarich head, tail = name.split('=', 1) 148f08ee00aSJason Sarich sys.argv[l] = head.replace('with-debug','with-debugging')+'='+tail 149f08ee00aSJason Sarich 150ce54fb35SBarry Smith if name.find('with-shared=') >= 0 or name.endswith('with-shared'): 151f08ee00aSJason Sarich if name.find('=') == -1: 152ce54fb35SBarry Smith sys.argv[l] = name.replace('with-shared','with-shared-libraries')+'=1' 153f08ee00aSJason Sarich else: 154f08ee00aSJason Sarich head, tail = name.split('=', 1) 155ce54fb35SBarry Smith sys.argv[l] = head.replace('with-shared','with-shared-libraries')+'='+tail 156f08ee00aSJason Sarich 1578fd71741SJason Sarich if name.find('with-index-size=') >=0: 1588fd71741SJason Sarich head,tail = name.split('=',1) 1598fd71741SJason Sarich if int(tail)==32: 1608fd71741SJason Sarich sys.argv[l] = '--with-64-bit-indices=0' 1618fd71741SJason Sarich elif int(tail)==64: 1628fd71741SJason Sarich sys.argv[l] = '--with-64-bit-indices=1' 1638fd71741SJason Sarich else: 1648fd71741SJason Sarich raise RuntimeError('--with-index-size= must be 32 or 64') 165f08ee00aSJason Sarich 1668fd71741SJason Sarich if name.find('with-precision=') >=0: 1678fd71741SJason Sarich head,tail = name.split('=',1) 1688fd71741SJason Sarich if tail.find('quad')>=0: 1698fd71741SJason Sarich sys.argv[l]='--with-precision=__float128' 170f08ee00aSJason Sarich 171f08ee00aSJason Sarich 1721921852fSSatish Balaydef chkwinf90(): 1736a8f6897SSatish Balay for arg in sys.argv: 1741921852fSSatish Balay if (arg.find('win32fe') >= 0 and (arg.find('f90') >=0 or arg.find('ifort') >=0)): 1756a8f6897SSatish Balay return 1 1766a8f6897SSatish Balay return 0 1776a8f6897SSatish Balay 1788a4600f2SSatish Balaydef chkdosfiles(): 179360dfd13SSatish Balay # cygwin - but not a hg clone - so check one of files in bin dir 180db1f124cSVasiliy Kozyrev if "\r\n" in open(os.path.join('bin','petscmpiexec'),"rb").read(): 181db1f124cSVasiliy Kozyrev print '===============================================================================' 182db1f124cSVasiliy Kozyrev print ' *** Scripts are in DOS mode. Was winzip used to extract petsc sources? ****' 183db1f124cSVasiliy Kozyrev print ' *** Please restart with a fresh tarball and use "tar -xzf petsc.tar.gz" ****' 184db1f124cSVasiliy Kozyrev print '===============================================================================' 185db1f124cSVasiliy Kozyrev sys.exit(3) 1868a4600f2SSatish Balay return 1878a4600f2SSatish Balay 1886a8f6897SSatish Balaydef chkcygwinlink(): 1891921852fSSatish Balay if os.path.exists('/usr/bin/cygcheck.exe') and os.path.exists('/usr/bin/link.exe') and chkwinf90(): 1906a8f6897SSatish Balay if '--ignore-cygwin-link' in sys.argv: return 0 1916a8f6897SSatish Balay print '===============================================================================' 1921921852fSSatish Balay print ' *** Cygwin /usr/bin/link detected! Compiles with CVF/Intel f90 can break! **' 1936a8f6897SSatish Balay print ' *** To workarround do: "mv /usr/bin/link.exe /usr/bin/link-cygwin.exe" **' 1946a8f6897SSatish Balay print ' *** Or to ignore this check, use configure option: --ignore-cygwin-link **' 1956a8f6897SSatish Balay print '===============================================================================' 1966a8f6897SSatish Balay sys.exit(3) 1976a8f6897SSatish Balay return 0 1986a8f6897SSatish Balay 19985ef4d1eSSatish Balaydef chkbrokencygwin(): 2009dabcff0SSatish Balay if os.path.exists('/usr/bin/cygcheck.exe'): 2019dabcff0SSatish Balay buf = os.popen('/usr/bin/cygcheck.exe -c cygwin').read() 2029dabcff0SSatish Balay if buf.find('1.5.11-1') > -1: 203a0022257SSatish Balay print '===============================================================================' 204e2e64c6bSBarry Smith print ' *** cygwin-1.5.11-1 detected. ./configure fails with this version ***' 2051937db7aSSatish Balay print ' *** Please upgrade to cygwin-1.5.12-1 or newer version. This can ***' 2061937db7aSSatish Balay print ' *** be done by running cygwin-setup, selecting "next" all the way.***' 207a0022257SSatish Balay print '===============================================================================' 2081937db7aSSatish Balay sys.exit(3) 2099dabcff0SSatish Balay return 0 2109dabcff0SSatish Balay 211ee76e990SSatish Balaydef chkusingwindowspython(): 212ee76e990SSatish Balay if sys.platform == 'win32': 213ee76e990SSatish Balay print '===============================================================================' 214ee76e990SSatish Balay print ' *** Windows python detected. Please rerun ./configure with cygwin-python. ***' 215ee76e990SSatish Balay print '===============================================================================' 216ee76e990SSatish Balay sys.exit(3) 217ee76e990SSatish Balay return 0 218ee76e990SSatish Balay 21914f5c25cSSatish Balaydef chkcygwinpython(): 2201150532aSSatish Balay if sys.platform == 'cygwin' : 2211150532aSSatish Balay import platform 2221150532aSSatish Balay import re 2231150532aSSatish Balay r=re.compile("([0-9]+).([0-9]+).([0-9]+)") 2241150532aSSatish Balay m=r.match(platform.release()) 2251150532aSSatish Balay major=int(m.group(1)) 2261150532aSSatish Balay minor=int(m.group(2)) 2271150532aSSatish Balay subminor=int(m.group(3)) 2281150532aSSatish Balay if ((major < 1) or (major == 1 and minor < 7) or (major == 1 and minor == 7 and subminor < 34)): 2291937db7aSSatish Balay sys.argv.append('--useThreads=0') 2301937db7aSSatish Balay extraLogs.append('''\ 231a0022257SSatish Balay=============================================================================== 2321150532aSSatish Balay** Cygwin version is older than 1.7.34. Python threads do not work correctly. *** 23314f5c25cSSatish Balay** Disabling thread usage for this run of ./configure ******* 234a0022257SSatish Balay===============================================================================''') 23571384062SSatish Balay return 0 23671384062SSatish Balay 2371937db7aSSatish Balaydef chkrhl9(): 2381937db7aSSatish Balay if os.path.exists('/etc/redhat-release'): 239836c2c52SSatish Balay try: 240594eb360SSatish Balay file = open('/etc/redhat-release','r') 241836c2c52SSatish Balay buf = file.read() 242836c2c52SSatish Balay file.close() 243836c2c52SSatish Balay except: 244836c2c52SSatish Balay # can't read file - assume dangerous RHL9 2451937db7aSSatish Balay buf = 'Shrike' 246836c2c52SSatish Balay if buf.find('Shrike') > -1: 2471937db7aSSatish Balay sys.argv.append('--useThreads=0') 2481937db7aSSatish Balay extraLogs.append('''\ 249a0022257SSatish Balay============================================================================== 2501937db7aSSatish Balay *** RHL9 detected. Threads do not work correctly with this distribution *** 251e2e64c6bSBarry Smith ****** Disabling thread usage for this run of ./configure ********* 252a0022257SSatish Balay===============================================================================''') 253836c2c52SSatish Balay return 0 254836c2c52SSatish Balay 255da58527dSSatish Balaydef check_broken_configure_log_links(): 256da58527dSSatish Balay '''Sometime symlinks can get broken if the original files are deleted. Delete such broken links''' 257da58527dSSatish Balay import os 258da58527dSSatish Balay for logfile in ['configure.log','configure.log.bkp']: 259da58527dSSatish Balay if os.path.islink(logfile) and not os.path.isfile(logfile): os.remove(logfile) 260da58527dSSatish Balay return 261da58527dSSatish Balay 262da1d79b4SSatish Balaydef move_configure_log(framework): 263af0996ceSBarry Smith '''Move configure.log to PETSC_ARCH/lib/petsc/conf - and update configure.log.bkp in both locations appropriately''' 264b0b472b0SSatish Balay global petsc_arch 265b0b472b0SSatish Balay 266b0b472b0SSatish Balay if hasattr(framework,'arch'): petsc_arch = framework.arch 267b0b472b0SSatish Balay if hasattr(framework,'logName'): curr_file = framework.logName 268b0b472b0SSatish Balay else: curr_file = 'configure.log' 269b0b472b0SSatish Balay 270b0b472b0SSatish Balay if petsc_arch: 271da1d79b4SSatish Balay import shutil 272da1d79b4SSatish Balay import os 273b0b472b0SSatish Balay 274b0b472b0SSatish Balay # Just in case - confdir is not created 275fe998a80SBarry Smith lib_dir = os.path.join(petsc_arch,'lib') 276af0996ceSBarry Smith conf_dir = os.path.join(petsc_arch,'lib','petsc','conf') 277b0b472b0SSatish Balay if not os.path.isdir(petsc_arch): os.mkdir(petsc_arch) 278fe998a80SBarry Smith if not os.path.isdir(lib_dir): os.mkdir(lib_dir) 279b0b472b0SSatish Balay if not os.path.isdir(conf_dir): os.mkdir(conf_dir) 280b0b472b0SSatish Balay 281da1d79b4SSatish Balay curr_bkp = curr_file + '.bkp' 282b0b472b0SSatish Balay new_file = os.path.join(conf_dir,curr_file) 283da1d79b4SSatish Balay new_bkp = new_file + '.bkp' 284da1d79b4SSatish Balay 285af0996ceSBarry Smith # Keep backup in $PETSC_ARCH/lib/petsc/conf location 286da1d79b4SSatish Balay if os.path.isfile(new_bkp): os.remove(new_bkp) 287da1d79b4SSatish Balay if os.path.isfile(new_file): os.rename(new_file,new_bkp) 2889e50940cSSatish Balay if os.path.isfile(curr_file): 2899e50940cSSatish Balay shutil.copyfile(curr_file,new_file) 2909e50940cSSatish Balay os.remove(curr_file) 291da58527dSSatish Balay if os.path.isfile(new_file): os.symlink(new_file,curr_file) 292af0996ceSBarry Smith # If the old bkp is using the same PETSC_ARCH/lib/petsc/conf - then update bkp link 293da1d79b4SSatish Balay if os.path.realpath(curr_bkp) == os.path.realpath(new_file): 294da58527dSSatish Balay if os.path.isfile(curr_bkp): os.remove(curr_bkp) 295da58527dSSatish Balay if os.path.isfile(new_bkp): os.symlink(new_bkp,curr_bkp) 296da1d79b4SSatish Balay return 297da1d79b4SSatish Balay 298d93c4beeSSatish Balaydef print_final_timestamp(framework): 299d93c4beeSSatish Balay import time 300d93c4beeSSatish Balay framework.log.write(('='*80)+'\n') 301d93c4beeSSatish Balay framework.log.write('Finishing Configure Run at '+time.ctime(time.time())+'\n') 302d93c4beeSSatish Balay framework.log.write(('='*80)+'\n') 303d93c4beeSSatish Balay return 304d93c4beeSSatish Balay 3055d5a5a7bSMatthew Knepleydef petsc_configure(configure_options): 3064a532159SBarry Smith try: 3074a532159SBarry Smith petscdir = os.environ['PETSC_DIR'] 308af0996ceSBarry Smith sys.path.append(os.path.join(petscdir,'bin')) 3094a532159SBarry Smith import petscnagupgrade 3104a532159SBarry Smith file = os.path.join(petscdir,'.nagged') 3114a532159SBarry Smith if not petscnagupgrade.naggedtoday(file): 3124a532159SBarry Smith petscnagupgrade.currentversion(petscdir) 3134a532159SBarry Smith except: 3144a532159SBarry Smith pass 315a0022257SSatish Balay print '===============================================================================' 31659e9bfd6SSatish Balay print ' Configuring PETSc to compile on your system ' 317a0022257SSatish Balay print '===============================================================================' 31859e9bfd6SSatish Balay 319a258c2c4SMatthew G Knepley try: 320c43ea0feSSatish Balay # Command line arguments take precedence (but don't destroy argv[0]) 321c43ea0feSSatish Balay sys.argv = sys.argv[:1] + configure_options + sys.argv[1:] 322ccb279e1SMatthew Knepley check_for_option_mistakes(sys.argv) 3232af240f0SSatish Balay check_for_option_changed(sys.argv) 324a258c2c4SMatthew G Knepley except (TypeError, ValueError), e: 325a258c2c4SMatthew G Knepley emsg = str(e) 326a258c2c4SMatthew G Knepley if not emsg.endswith('\n'): emsg = emsg+'\n' 327a258c2c4SMatthew G Knepley msg ='*******************************************************************************\n'\ 328a258c2c4SMatthew G Knepley +' ERROR in COMMAND LINE ARGUMENT to ./configure \n' \ 329a258c2c4SMatthew G Knepley +'-------------------------------------------------------------------------------\n' \ 330a258c2c4SMatthew G Knepley +emsg+'*******************************************************************************\n' 331a258c2c4SMatthew G Knepley sys.exit(msg) 33259e9bfd6SSatish Balay # check PETSC_ARCH 333*2f393ef5SBarry Smith check_for_unsupported_combinations(sys.argv) 33459e9bfd6SSatish Balay check_petsc_arch(sys.argv) 335da58527dSSatish Balay check_broken_configure_log_links() 3365fb2c094SBarry Smith 337f08ee00aSJason Sarich #rename '--enable-' to '--with-' 338f08ee00aSJason Sarich chkenable() 339c22cdea9SBarry Smith # support a few standard configure option types 340f08ee00aSJason Sarich chksynonyms() 3419dabcff0SSatish Balay # Check for broken cygwin 3421937db7aSSatish Balay chkbrokencygwin() 343d65f3bddSMatthew Knepley # Disable threads on RHL9 3441937db7aSSatish Balay chkrhl9() 345ee76e990SSatish Balay # Make sure cygwin-python is used on windows 346ee76e990SSatish Balay chkusingwindowspython() 34714f5c25cSSatish Balay # Threads don't work for cygwin & python... 34814f5c25cSSatish Balay chkcygwinpython() 3496a8f6897SSatish Balay chkcygwinlink() 3508a4600f2SSatish Balay chkdosfiles() 3519dabcff0SSatish Balay 35287282423SMatthew Knepley # Should be run from the toplevel 353dbca6d9dSSatish Balay configDir = os.path.abspath('config') 354f8833479SBarry Smith bsDir = os.path.join(configDir, 'BuildSystem') 355f8833479SBarry Smith if not os.path.isdir(configDir): 3565d5a5a7bSMatthew Knepley raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.')) 35787282423SMatthew Knepley sys.path.insert(0, bsDir) 358f8833479SBarry Smith sys.path.insert(0, configDir) 359e69ef9dfSMatthew Knepley import config.base 3605d5a5a7bSMatthew Knepley import config.framework 361f56be888SMatthew Knepley import cPickle 3624f8a5b45SBarry Smith 3639dd2fdb1SMatthew Knepley framework = None 3649dd2fdb1SMatthew Knepley try: 36523a19ef1SSatish Balay framework = config.framework.Framework(['--configModules=PETSc.Configure','--optionsModule=config.compilerOptions']+sys.argv[1:], loadArgDB = 0) 366d65f3bddSMatthew Knepley framework.setup() 367d65f3bddSMatthew Knepley framework.logPrint('\n'.join(extraLogs)) 368f24f64feSBarry Smith framework.configure(out = sys.stdout) 369358ebc22SMatthew Knepley framework.storeSubstitutions(framework.argDB) 370f56be888SMatthew Knepley framework.argDB['configureCache'] = cPickle.dumps(framework) 3717c939e48SSatish Balay framework.printSummary() 37212c1d45bSMatthew G Knepley framework.argDB.save(force = True) 3737cfd0b05SBarry Smith framework.logClear() 374d93c4beeSSatish Balay print_final_timestamp(framework) 375eefa2c0fSBarry Smith framework.closeLog() 3769e50940cSSatish Balay try: 377da1d79b4SSatish Balay move_configure_log(framework) 3789e50940cSSatish Balay except: 3799e50940cSSatish Balay # perhaps print an error about unable to shuffle logs? 3809e50940cSSatish Balay pass 381dd50d019SBarry Smith return 0 382e69ef9dfSMatthew Knepley except (RuntimeError, config.base.ConfigureSetupError), e: 3837d670a3cSBarry Smith emsg = str(e) 38442351d26SSatish Balay if not emsg.endswith('\n'): emsg = emsg+'\n' 385a0022257SSatish Balay msg ='*******************************************************************************\n'\ 386fe09c992SBarry Smith +' UNABLE to CONFIGURE with GIVEN OPTIONS (see configure.log for details):\n' \ 387a0022257SSatish Balay +'-------------------------------------------------------------------------------\n' \ 388a0022257SSatish Balay +emsg+'*******************************************************************************\n' 389e9f3bb17SBarry Smith se = '' 3909dd2fdb1SMatthew Knepley except (TypeError, ValueError), e: 3917d670a3cSBarry Smith emsg = str(e) 39242351d26SSatish Balay if not emsg.endswith('\n'): emsg = emsg+'\n' 393a0022257SSatish Balay msg ='*******************************************************************************\n'\ 394e2e64c6bSBarry Smith +' ERROR in COMMAND LINE ARGUMENT to ./configure \n' \ 395a0022257SSatish Balay +'-------------------------------------------------------------------------------\n' \ 396a0022257SSatish Balay +emsg+'*******************************************************************************\n' 3971a02243aSBarry Smith se = '' 39896dc2fe8SMatthew Knepley except ImportError, e : 3997d670a3cSBarry Smith emsg = str(e) 40042351d26SSatish Balay if not emsg.endswith('\n'): emsg = emsg+'\n' 401a0022257SSatish Balay msg ='*******************************************************************************\n'\ 402e2e64c6bSBarry Smith +' UNABLE to FIND MODULE for ./configure \n' \ 403a0022257SSatish Balay +'-------------------------------------------------------------------------------\n' \ 404a0022257SSatish Balay +emsg+'*******************************************************************************\n' 40596dc2fe8SMatthew Knepley se = '' 40601def6f0SMatthew Knepley except OSError, e : 40701def6f0SMatthew Knepley emsg = str(e) 40801def6f0SMatthew Knepley if not emsg.endswith('\n'): emsg = emsg+'\n' 409a0022257SSatish Balay msg ='*******************************************************************************\n'\ 410e2e64c6bSBarry Smith +' UNABLE to EXECUTE BINARIES for ./configure \n' \ 411a0022257SSatish Balay +'-------------------------------------------------------------------------------\n' \ 412a0022257SSatish Balay +emsg+'*******************************************************************************\n' 41301def6f0SMatthew Knepley se = '' 414d7d3c4beSMatthew Knepley except SystemExit, e: 415d7d3c4beSMatthew Knepley if e.code is None or e.code == 0: 416d7d3c4beSMatthew Knepley return 417a0022257SSatish Balay msg ='*******************************************************************************\n'\ 418b1dada7fSMatthew Knepley +' CONFIGURATION FAILURE (Please send configure.log to petsc-maint@mcs.anl.gov)\n' \ 419a0022257SSatish Balay +'*******************************************************************************\n' 420d7d3c4beSMatthew Knepley se = str(e) 421e9f3bb17SBarry Smith except Exception, e: 422a0022257SSatish Balay msg ='*******************************************************************************\n'\ 423fe09c992SBarry Smith +' CONFIGURATION CRASH (Please send configure.log to petsc-maint@mcs.anl.gov)\n' \ 424a0022257SSatish Balay +'*******************************************************************************\n' 425e9f3bb17SBarry Smith se = str(e) 426e9f3bb17SBarry Smith 427e9f3bb17SBarry Smith print msg 4289dd2fdb1SMatthew Knepley if not framework is None: 4299dd2fdb1SMatthew Knepley framework.logClear() 430e9f3bb17SBarry Smith if hasattr(framework, 'log'): 43122c95ba3SMatthew G Knepley try: 432d71f8ab3SSatish Balay if hasattr(framework,'compilerDefines'): 433bd5137a2SBarry Smith framework.log.write('**** Configure header '+framework.compilerDefines+' ****\n') 434febd46b0SSatish Balay framework.outputHeader(framework.log) 435d71f8ab3SSatish Balay if hasattr(framework,'compilerFixes'): 436bd5137a2SBarry Smith framework.log.write('**** C specific Configure header '+framework.compilerFixes+' ****\n') 437febd46b0SSatish Balay framework.outputCHeader(framework.log) 43822c95ba3SMatthew G Knepley except Exception, e: 43922c95ba3SMatthew G Knepley framework.log.write('Problem writing headers to log: '+str(e)) 440f6614063SBarry Smith import traceback 441b1dada7fSMatthew Knepley try: 442f24f64feSBarry Smith framework.log.write(msg+se) 443f24f64feSBarry Smith traceback.print_tb(sys.exc_info()[2], file = framework.log) 444d93c4beeSSatish Balay print_final_timestamp(framework) 445f73e6a6cSSatish Balay if hasattr(framework,'log'): framework.log.close() 446da1d79b4SSatish Balay move_configure_log(framework) 447b1dada7fSMatthew Knepley except: 448b1dada7fSMatthew Knepley pass 449e9f3bb17SBarry Smith sys.exit(1) 4505a74f024SMatthew Knepley else: 4515a74f024SMatthew Knepley print se 4525a74f024SMatthew Knepley import traceback 4535a74f024SMatthew Knepley traceback.print_tb(sys.exc_info()[2]) 454f73e6a6cSSatish Balay if hasattr(framework,'log'): framework.log.close() 4555d5a5a7bSMatthew Knepley 4565d5a5a7bSMatthew Knepleyif __name__ == '__main__': 457a030c540SBarry Smith petsc_configure([]) 458759acf64SBarry Smith 459