xref: /petsc/config/configure.py (revision 95108ba7f1b20518596460ef72c4c94ae22cc7f4)
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
31*95108ba7SSatish Balaydef getBuildSystem(configDir,bsDir):
32*95108ba7SSatish Balay  print '==============================================================================='
33*95108ba7SSatish Balay  print '''++ Could not locate BuildSystem in %s.''' % configDir
34*95108ba7SSatish Balay  (status,output) = commands.getstatusoutput('hg showconfig paths.default')
35*95108ba7SSatish Balay  if status or not output:
36*95108ba7SSatish Balay    print '++ Mercurial clone not found. Downloading it from http://petsc.cs.iit.edu/petsc/BuildSystem/archive/tip.tar.gz'
37*95108ba7SSatish Balay    downloadPackage('http://petsc.cs.iit.edu/petsc/BuildSystem/archive/tip.tar.gz', 'BuildSystem.tar.gz', configDir)
38*95108ba7SSatish Balay  else:
39*95108ba7SSatish Balay    print '++ Mercurial clone found. URL : ' + output
40*95108ba7SSatish Balay    if output.find("petsc.cs.iit.edu") >=0:
41*95108ba7SSatish Balay      bsurl = output.replace('petsc-dev','BuildSystem').replace('releases/petsc-','releases/BuildSystem-')
42*95108ba7SSatish Balay      print '++ Using: hg clone '+ bsurl +' '+ bsDir
43*95108ba7SSatish Balay      (status,output) = commands.getstatusoutput('hg clone '+ bsurl +' '+ bsDir)
44*95108ba7SSatish Balay      if status:
45*95108ba7SSatish Balay        print '++ Unable to clone BuildSystem. Please clone manually'
46*95108ba7SSatish Balay        print '==============================================================================='
47*95108ba7SSatish Balay        sys.exit(3)
48*95108ba7SSatish Balay    else:
49*95108ba7SSatish Balay      print '++ Nonstandard parent URL. Cannot determine appropriate BuildSystem URL. Please clone appropriate BuildSystem'
50*95108ba7SSatish Balay      print '==============================================================================='
51*95108ba7SSatish Balay      sys.exit(3)
52*95108ba7SSatish Balay  print '==============================================================================='
53*95108ba7SSatish Balay  return
54*95108ba7SSatish Balay
55*95108ba7SSatish Balay
5644b0d7f9SSatish Balay# Use en_US as language so that BuildSystem parses compiler messages in english
579b436e4bSSatish 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'
589b436e4bSSatish 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'
5944b0d7f9SSatish Balay
606b66766aSSatish Balayif not hasattr(sys, 'version_info') or not sys.version_info[0] == 2 or not sys.version_info[1] >= 3:
616b66766aSSatish Balay  print '*** You must have Python2 version 2.3 or higher to run ./configure        *****'
62495ffa62SBarry Smith  print '*          Python is easy to install for end users or sys-admin.              *'
6332077d6dSBarry Smith  print '*                  http://www.python.org/download/                            *'
6432077d6dSBarry Smith  print '*                                                                             *'
65495ffa62SBarry Smith  print '*           You CANNOT configure PETSc without Python                         *'
66495ffa62SBarry Smith  print '*   http://www.mcs.anl.gov/petsc/petsc-as/documentation/installation.html     *'
67a0022257SSatish Balay  print '*******************************************************************************'
68b26a8723SBarry Smith  sys.exit(4)
692fb34ac0SMatthew Knepley
704d18482cSSatish Balayif sys.platform == 'win32':
714d18482cSSatish Balay  print '**** Windows python detected. ****'
724d18482cSSatish Balay  print sys.version,'on',sys.platform
734d18482cSSatish Balay  print ''
744d18482cSSatish Balay  print '** You must use cygwin python, but not windows python with PETSc configure. ***'
754d18482cSSatish Balay  sys.exit(4)
764d18482cSSatish Balay
77ccb279e1SMatthew Knepleydef check_for_option_mistakes(opts):
7845faeebdSBarry Smith  for opt in opts[1:]:
79cda0060aSMatthew Knepley    name = opt.split('=')[0]
80ccb279e1SMatthew Knepley    if name.find('_') >= 0:
81ccb279e1SMatthew Knepley      exception = False
82f3fbd535SBarry 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']:
83ccb279e1SMatthew Knepley        if name.find(exc) >= 0:
84ccb279e1SMatthew Knepley          exception = True
85ccb279e1SMatthew Knepley      if not exception:
86ccb279e1SMatthew Knepley        raise ValueError('The option '+name+' should probably be '+name.replace('_', '-'));
87ab610953SSatish Balay    if opt.find('=') >=0:
88ab610953SSatish Balay      optval = opt.split('=')[1]
89ab610953SSatish Balay      if optval == 'ifneeded':
90ab610953SSatish Balay        raise ValueError('The option '+opt+' should probably be '+opt.replace('ifneeded', '1'));
91ccb279e1SMatthew Knepley  return
92ccb279e1SMatthew Knepley
9359e9bfd6SSatish Balaydef check_petsc_arch(opts):
94c43ea0feSSatish Balay  # If PETSC_ARCH not specified - use script name (if not configure.py)
95b0b472b0SSatish Balay  global petsc_arch
96c43ea0feSSatish Balay  found = 0
9759e9bfd6SSatish Balay  for name in opts:
98c43ea0feSSatish Balay    if name.find('PETSC_ARCH=') >= 0:
99b0b472b0SSatish Balay      petsc_arch=name.split('=')[1]
100c43ea0feSSatish Balay      found = 1
10159e9bfd6SSatish Balay      break
10259e9bfd6SSatish Balay  # If not yet specified - use the filename of script
103c43ea0feSSatish Balay  if not found:
10459e9bfd6SSatish Balay      filename = os.path.basename(sys.argv[0])
105e68ebbecSBarry Smith      if not filename.startswith('configure') and not filename.startswith('reconfigure') and not filename.startswith('setup'):
106b0b472b0SSatish Balay        petsc_arch=os.path.splitext(os.path.basename(sys.argv[0]))[0]
107b0b472b0SSatish Balay        useName = 'PETSC_ARCH='+petsc_arch
10859e9bfd6SSatish Balay        opts.append(useName)
1091937db7aSSatish Balay  return 0
1104b8aa89bSBarry Smith
1111921852fSSatish Balaydef chkwinf90():
1126a8f6897SSatish Balay  for arg in sys.argv:
1131921852fSSatish Balay    if (arg.find('win32fe') >= 0 and (arg.find('f90') >=0 or arg.find('ifort') >=0)):
1146a8f6897SSatish Balay      return 1
1156a8f6897SSatish Balay  return 0
1166a8f6897SSatish Balay
1176a8f6897SSatish Balaydef chkcygwinlink():
1181921852fSSatish Balay  if os.path.exists('/usr/bin/cygcheck.exe') and os.path.exists('/usr/bin/link.exe') and chkwinf90():
1196a8f6897SSatish Balay      if '--ignore-cygwin-link' in sys.argv: return 0
1206a8f6897SSatish Balay      print '==============================================================================='
1211921852fSSatish Balay      print ' *** Cygwin /usr/bin/link detected! Compiles with CVF/Intel f90 can break!  **'
1226a8f6897SSatish Balay      print ' *** To workarround do: "mv /usr/bin/link.exe /usr/bin/link-cygwin.exe"     **'
1236a8f6897SSatish Balay      print ' *** Or to ignore this check, use configure option: --ignore-cygwin-link    **'
1246a8f6897SSatish Balay      print '==============================================================================='
1256a8f6897SSatish Balay      sys.exit(3)
1266a8f6897SSatish Balay  return 0
1276a8f6897SSatish Balay
12885ef4d1eSSatish Balaydef chkbrokencygwin():
1299dabcff0SSatish Balay  if os.path.exists('/usr/bin/cygcheck.exe'):
1309dabcff0SSatish Balay    buf = os.popen('/usr/bin/cygcheck.exe -c cygwin').read()
1319dabcff0SSatish Balay    if buf.find('1.5.11-1') > -1:
132a0022257SSatish Balay      print '==============================================================================='
133e2e64c6bSBarry Smith      print ' *** cygwin-1.5.11-1 detected. ./configure fails with this version ***'
1341937db7aSSatish Balay      print ' *** Please upgrade to cygwin-1.5.12-1 or newer version. This can  ***'
1351937db7aSSatish Balay      print ' *** be done by running cygwin-setup, selecting "next" all the way.***'
136a0022257SSatish Balay      print '==============================================================================='
1371937db7aSSatish Balay      sys.exit(3)
1389dabcff0SSatish Balay  return 0
1399dabcff0SSatish Balay
14014f5c25cSSatish Balaydef chkcygwinpython():
14114f5c25cSSatish Balay  if os.path.exists('/usr/bin/cygcheck.exe') and sys.platform == 'cygwin' :
1421937db7aSSatish Balay    sys.argv.append('--useThreads=0')
1431937db7aSSatish Balay    extraLogs.append('''\
144a0022257SSatish Balay===============================================================================
14514f5c25cSSatish Balay** Cygwin-python detected. Threads do not work correctly. ***
14614f5c25cSSatish Balay** Disabling thread usage for this run of ./configure *******
147a0022257SSatish Balay===============================================================================''')
14871384062SSatish Balay  return 0
14971384062SSatish Balay
1501937db7aSSatish Balaydef chkrhl9():
1511937db7aSSatish Balay  if os.path.exists('/etc/redhat-release'):
152836c2c52SSatish Balay    try:
153594eb360SSatish Balay      file = open('/etc/redhat-release','r')
154836c2c52SSatish Balay      buf = file.read()
155836c2c52SSatish Balay      file.close()
156836c2c52SSatish Balay    except:
157836c2c52SSatish Balay      # can't read file - assume dangerous RHL9
1581937db7aSSatish Balay      buf = 'Shrike'
159836c2c52SSatish Balay    if buf.find('Shrike') > -1:
1601937db7aSSatish Balay      sys.argv.append('--useThreads=0')
1611937db7aSSatish Balay      extraLogs.append('''\
162a0022257SSatish Balay==============================================================================
1631937db7aSSatish Balay   *** RHL9 detected. Threads do not work correctly with this distribution ***
164e2e64c6bSBarry Smith   ****** Disabling thread usage for this run of ./configure *********
165a0022257SSatish Balay===============================================================================''')
166836c2c52SSatish Balay  return 0
167836c2c52SSatish Balay
168da58527dSSatish Balaydef check_broken_configure_log_links():
169da58527dSSatish Balay  '''Sometime symlinks can get broken if the original files are deleted. Delete such broken links'''
170da58527dSSatish Balay  import os
171da58527dSSatish Balay  for logfile in ['configure.log','configure.log.bkp']:
172da58527dSSatish Balay    if os.path.islink(logfile) and not os.path.isfile(logfile): os.remove(logfile)
173da58527dSSatish Balay  return
174da58527dSSatish Balay
175da1d79b4SSatish Balaydef move_configure_log(framework):
176da1d79b4SSatish Balay  '''Move configure.log to PETSC_ARCH/conf - and update configure.log.bkp in both locations appropriately'''
177b0b472b0SSatish Balay  global petsc_arch
178b0b472b0SSatish Balay
179b0b472b0SSatish Balay  if hasattr(framework,'arch'): petsc_arch = framework.arch
180b0b472b0SSatish Balay  if hasattr(framework,'logName'): curr_file = framework.logName
181b0b472b0SSatish Balay  else: curr_file = 'configure.log'
182b0b472b0SSatish Balay
183b0b472b0SSatish Balay  if petsc_arch:
184da1d79b4SSatish Balay    import shutil
185da1d79b4SSatish Balay    import os
186b0b472b0SSatish Balay
187b0b472b0SSatish Balay    # Just in case - confdir is not created
188b0b472b0SSatish Balay    conf_dir = os.path.join(petsc_arch,'conf')
189b0b472b0SSatish Balay    if not os.path.isdir(petsc_arch): os.mkdir(petsc_arch)
190b0b472b0SSatish Balay    if not os.path.isdir(conf_dir): os.mkdir(conf_dir)
191b0b472b0SSatish Balay
192da1d79b4SSatish Balay    curr_bkp  = curr_file + '.bkp'
193b0b472b0SSatish Balay    new_file  = os.path.join(conf_dir,curr_file)
194da1d79b4SSatish Balay    new_bkp   = new_file + '.bkp'
195da1d79b4SSatish Balay
196da1d79b4SSatish Balay    # Keep backup in $PETSC_ARCH/conf location
197da1d79b4SSatish Balay    if os.path.isfile(new_bkp): os.remove(new_bkp)
198da1d79b4SSatish Balay    if os.path.isfile(new_file): os.rename(new_file,new_bkp)
1999e50940cSSatish Balay    if os.path.isfile(curr_file):
2009e50940cSSatish Balay      shutil.copyfile(curr_file,new_file)
2019e50940cSSatish Balay      os.remove(curr_file)
202da58527dSSatish Balay    if os.path.isfile(new_file): os.symlink(new_file,curr_file)
203da1d79b4SSatish Balay    # If the old bkp is using the same PETSC_ARCH/conf - then update bkp link
204da1d79b4SSatish Balay    if os.path.realpath(curr_bkp) == os.path.realpath(new_file):
205da58527dSSatish Balay      if os.path.isfile(curr_bkp): os.remove(curr_bkp)
206da58527dSSatish Balay      if os.path.isfile(new_bkp): os.symlink(new_bkp,curr_bkp)
207da1d79b4SSatish Balay  return
208da1d79b4SSatish Balay
2095d5a5a7bSMatthew Knepleydef petsc_configure(configure_options):
210a0022257SSatish Balay  print '==============================================================================='
21159e9bfd6SSatish Balay  print '             Configuring PETSc to compile on your system                       '
212a0022257SSatish Balay  print '==============================================================================='
21359e9bfd6SSatish Balay
214a258c2c4SMatthew G Knepley  try:
215c43ea0feSSatish Balay    # Command line arguments take precedence (but don't destroy argv[0])
216c43ea0feSSatish Balay    sys.argv = sys.argv[:1] + configure_options + sys.argv[1:]
217ccb279e1SMatthew Knepley    check_for_option_mistakes(sys.argv)
218a258c2c4SMatthew G Knepley  except (TypeError, ValueError), e:
219a258c2c4SMatthew G Knepley    emsg = str(e)
220a258c2c4SMatthew G Knepley    if not emsg.endswith('\n'): emsg = emsg+'\n'
221a258c2c4SMatthew G Knepley    msg ='*******************************************************************************\n'\
222a258c2c4SMatthew G Knepley    +'                ERROR in COMMAND LINE ARGUMENT to ./configure \n' \
223a258c2c4SMatthew G Knepley    +'-------------------------------------------------------------------------------\n'  \
224a258c2c4SMatthew G Knepley    +emsg+'*******************************************************************************\n'
225a258c2c4SMatthew G Knepley    sys.exit(msg)
22659e9bfd6SSatish Balay  # check PETSC_ARCH
22759e9bfd6SSatish Balay  check_petsc_arch(sys.argv)
228da58527dSSatish Balay  check_broken_configure_log_links()
2295fb2c094SBarry Smith
230c22cdea9SBarry Smith  # support a few standard configure option types
231ed6a7445SBarry Smith  for l in range(0,len(sys.argv)):
232c22cdea9SBarry Smith    name = sys.argv[l]
233637cc2ebSSatish Balay    if name.find('enable-') >= 0:
234193cd51eSMatthew Knepley      if name.find('=') == -1:
235193cd51eSMatthew Knepley        sys.argv[l] = name.replace('enable-','with-')+'=1'
236193cd51eSMatthew Knepley      else:
237193cd51eSMatthew Knepley        head, tail = name.split('=', 1)
238193cd51eSMatthew Knepley        sys.argv[l] = head.replace('enable-','with-')+'='+tail
239637cc2ebSSatish Balay    if name.find('disable-') >= 0:
240193cd51eSMatthew Knepley      if name.find('=') == -1:
241193cd51eSMatthew Knepley        sys.argv[l] = name.replace('disable-','with-')+'=0'
242193cd51eSMatthew Knepley      else:
243193cd51eSMatthew Knepley        head, tail = name.split('=', 1)
244193cd51eSMatthew Knepley        if tail == '1': tail = '0'
245193cd51eSMatthew Knepley        sys.argv[l] = head.replace('disable-','with-')+'='+tail
246637cc2ebSSatish Balay    if name.find('without-') >= 0:
247193cd51eSMatthew Knepley      if name.find('=') == -1:
248193cd51eSMatthew Knepley        sys.argv[l] = name.replace('without-','with-')+'=0'
249193cd51eSMatthew Knepley      else:
250193cd51eSMatthew Knepley        head, tail = name.split('=', 1)
251193cd51eSMatthew Knepley        if tail == '1': tail = '0'
252193cd51eSMatthew Knepley        sys.argv[l] = head.replace('without-','with-')+'='+tail
253adc3e427SMatthew Knepley
2549dabcff0SSatish Balay  # Check for broken cygwin
2551937db7aSSatish Balay  chkbrokencygwin()
256d65f3bddSMatthew Knepley  # Disable threads on RHL9
2571937db7aSSatish Balay  chkrhl9()
25814f5c25cSSatish Balay  # Threads don't work for cygwin & python...
25914f5c25cSSatish Balay  chkcygwinpython()
2606a8f6897SSatish Balay  chkcygwinlink()
2619dabcff0SSatish Balay
26287282423SMatthew Knepley  # Should be run from the toplevel
263dbca6d9dSSatish Balay  configDir = os.path.abspath('config')
264f8833479SBarry Smith  bsDir     = os.path.join(configDir, 'BuildSystem')
265f8833479SBarry Smith  if not os.path.isdir(configDir):
2665d5a5a7bSMatthew Knepley    raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.'))
267*95108ba7SSatish Balay  if not os.path.isdir(bsDir): getBuildSystem(configDir,bsDir)
26887282423SMatthew Knepley  sys.path.insert(0, bsDir)
269f8833479SBarry Smith  sys.path.insert(0, configDir)
270e69ef9dfSMatthew Knepley  import config.base
2715d5a5a7bSMatthew Knepley  import config.framework
272f56be888SMatthew Knepley  import cPickle
2734f8a5b45SBarry Smith
2749dd2fdb1SMatthew Knepley  framework = None
2759dd2fdb1SMatthew Knepley  try:
2761a784507SMatthew Knepley    framework = config.framework.Framework(['--configModules=PETSc.Configure','--optionsModule=PETSc.compilerOptions']+sys.argv[1:], loadArgDB = 0)
277d65f3bddSMatthew Knepley    framework.setup()
278d65f3bddSMatthew Knepley    framework.logPrint('\n'.join(extraLogs))
279f24f64feSBarry Smith    framework.configure(out = sys.stdout)
280358ebc22SMatthew Knepley    framework.storeSubstitutions(framework.argDB)
281f56be888SMatthew Knepley    framework.argDB['configureCache'] = cPickle.dumps(framework)
2827cfd0b05SBarry Smith    import PETSc.packages
2837cfd0b05SBarry Smith    for i in framework.packages:
2847cfd0b05SBarry Smith      if hasattr(i,'postProcess'):
2857cfd0b05SBarry Smith        i.postProcess()
2867c939e48SSatish Balay    framework.printSummary()
28712c1d45bSMatthew G Knepley    framework.argDB.save(force = True)
2887cfd0b05SBarry Smith    framework.logClear()
289eefa2c0fSBarry Smith    framework.closeLog()
2909e50940cSSatish Balay    try:
291da1d79b4SSatish Balay      move_configure_log(framework)
2929e50940cSSatish Balay    except:
2939e50940cSSatish Balay      # perhaps print an error about unable to shuffle logs?
2949e50940cSSatish Balay      pass
295dd50d019SBarry Smith    return 0
296e69ef9dfSMatthew Knepley  except (RuntimeError, config.base.ConfigureSetupError), e:
2977d670a3cSBarry Smith    emsg = str(e)
29842351d26SSatish Balay    if not emsg.endswith('\n'): emsg = emsg+'\n'
299a0022257SSatish Balay    msg ='*******************************************************************************\n'\
300fe09c992SBarry Smith    +'         UNABLE to CONFIGURE with GIVEN OPTIONS    (see configure.log for details):\n' \
301a0022257SSatish Balay    +'-------------------------------------------------------------------------------\n'  \
302a0022257SSatish Balay    +emsg+'*******************************************************************************\n'
303e9f3bb17SBarry Smith    se = ''
3049dd2fdb1SMatthew Knepley  except (TypeError, ValueError), e:
3057d670a3cSBarry Smith    emsg = str(e)
30642351d26SSatish Balay    if not emsg.endswith('\n'): emsg = emsg+'\n'
307a0022257SSatish Balay    msg ='*******************************************************************************\n'\
308e2e64c6bSBarry Smith    +'                ERROR in COMMAND LINE ARGUMENT to ./configure \n' \
309a0022257SSatish Balay    +'-------------------------------------------------------------------------------\n'  \
310a0022257SSatish Balay    +emsg+'*******************************************************************************\n'
3111a02243aSBarry Smith    se = ''
31296dc2fe8SMatthew Knepley  except ImportError, e :
3137d670a3cSBarry Smith    emsg = str(e)
31442351d26SSatish Balay    if not emsg.endswith('\n'): emsg = emsg+'\n'
315a0022257SSatish Balay    msg ='*******************************************************************************\n'\
316e2e64c6bSBarry Smith    +'                     UNABLE to FIND MODULE for ./configure \n' \
317a0022257SSatish Balay    +'-------------------------------------------------------------------------------\n'  \
318a0022257SSatish Balay    +emsg+'*******************************************************************************\n'
31996dc2fe8SMatthew Knepley    se = ''
32001def6f0SMatthew Knepley  except OSError, e :
32101def6f0SMatthew Knepley    emsg = str(e)
32201def6f0SMatthew Knepley    if not emsg.endswith('\n'): emsg = emsg+'\n'
323a0022257SSatish Balay    msg ='*******************************************************************************\n'\
324e2e64c6bSBarry Smith    +'                    UNABLE to EXECUTE BINARIES for ./configure \n' \
325a0022257SSatish Balay    +'-------------------------------------------------------------------------------\n'  \
326a0022257SSatish Balay    +emsg+'*******************************************************************************\n'
32701def6f0SMatthew Knepley    se = ''
328d7d3c4beSMatthew Knepley  except SystemExit, e:
329d7d3c4beSMatthew Knepley    if e.code is None or e.code == 0:
330d7d3c4beSMatthew Knepley      return
331a0022257SSatish Balay    msg ='*******************************************************************************\n'\
332b1dada7fSMatthew Knepley    +'         CONFIGURATION FAILURE  (Please send configure.log to petsc-maint@mcs.anl.gov)\n' \
333a0022257SSatish Balay    +'*******************************************************************************\n'
334d7d3c4beSMatthew Knepley    se  = str(e)
335e9f3bb17SBarry Smith  except Exception, e:
336a0022257SSatish Balay    msg ='*******************************************************************************\n'\
337fe09c992SBarry Smith    +'        CONFIGURATION CRASH  (Please send configure.log to petsc-maint@mcs.anl.gov)\n' \
338a0022257SSatish Balay    +'*******************************************************************************\n'
339e9f3bb17SBarry Smith    se  = str(e)
340e9f3bb17SBarry Smith
341e9f3bb17SBarry Smith  print msg
3429dd2fdb1SMatthew Knepley  if not framework is None:
3439dd2fdb1SMatthew Knepley    framework.logClear()
344e9f3bb17SBarry Smith    if hasattr(framework, 'log'):
345f6614063SBarry Smith      import traceback
346b1dada7fSMatthew Knepley      try:
347f24f64feSBarry Smith        framework.log.write(msg+se)
348f24f64feSBarry Smith        traceback.print_tb(sys.exc_info()[2], file = framework.log)
349f73e6a6cSSatish Balay        if hasattr(framework,'log'): framework.log.close()
350da1d79b4SSatish Balay        move_configure_log(framework)
351b1dada7fSMatthew Knepley      except:
352b1dada7fSMatthew Knepley        pass
353e9f3bb17SBarry Smith      sys.exit(1)
3545a74f024SMatthew Knepley  else:
3555a74f024SMatthew Knepley    print se
3565a74f024SMatthew Knepley    import traceback
3575a74f024SMatthew Knepley    traceback.print_tb(sys.exc_info()[2])
358f73e6a6cSSatish Balay  if hasattr(framework,'log'): framework.log.close()
3595d5a5a7bSMatthew Knepley
3605d5a5a7bSMatthew Knepleyif __name__ == '__main__':
361a030c540SBarry Smith  petsc_configure([])
362759acf64SBarry Smith
363