xref: /petsc/config/configure.py (revision fe998a80077c9ee0917a39496df43fc256e1b478)
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
392af240f0SSatish Balaydef check_for_option_changed(opts):
402af240f0SSatish Balay# Document changes in command line options here.
41c22361cbSBarry Smith  optMap = [('c-blas-lapack','f2cblaslapack'),('cholmod','suitesparse'),('umfpack','suitesparse'),('f-blas-lapack','fblaslapack')]
422af240f0SSatish Balay  for opt in opts[1:]:
432af240f0SSatish Balay    optname = opt.split('=')[0].strip('-')
442af240f0SSatish Balay    for oldname,newname in optMap:
452af240f0SSatish Balay      if optname.find(oldname) >=0:
462af240f0SSatish Balay        raise ValueError('The option '+opt+' should probably be '+opt.replace(oldname,newname))
472af240f0SSatish Balay  return
482af240f0SSatish Balay
4959e9bfd6SSatish Balaydef check_petsc_arch(opts):
50c43ea0feSSatish Balay  # If PETSC_ARCH not specified - use script name (if not configure.py)
51b0b472b0SSatish Balay  global petsc_arch
52c43ea0feSSatish Balay  found = 0
5359e9bfd6SSatish Balay  for name in opts:
54c43ea0feSSatish Balay    if name.find('PETSC_ARCH=') >= 0:
55b0b472b0SSatish Balay      petsc_arch=name.split('=')[1]
56c43ea0feSSatish Balay      found = 1
5759e9bfd6SSatish Balay      break
5859e9bfd6SSatish Balay  # If not yet specified - use the filename of script
59c43ea0feSSatish Balay  if not found:
6059e9bfd6SSatish Balay      filename = os.path.basename(sys.argv[0])
61e68ebbecSBarry Smith      if not filename.startswith('configure') and not filename.startswith('reconfigure') and not filename.startswith('setup'):
62b0b472b0SSatish Balay        petsc_arch=os.path.splitext(os.path.basename(sys.argv[0]))[0]
63b0b472b0SSatish Balay        useName = 'PETSC_ARCH='+petsc_arch
6459e9bfd6SSatish Balay        opts.append(useName)
651937db7aSSatish Balay  return 0
664b8aa89bSBarry Smith
671921852fSSatish Balaydef chkwinf90():
686a8f6897SSatish Balay  for arg in sys.argv:
691921852fSSatish Balay    if (arg.find('win32fe') >= 0 and (arg.find('f90') >=0 or arg.find('ifort') >=0)):
706a8f6897SSatish Balay      return 1
716a8f6897SSatish Balay  return 0
726a8f6897SSatish Balay
738a4600f2SSatish Balaydef chkdosfiles():
74360dfd13SSatish Balay  # cygwin - but not a hg clone - so check one of files in bin dir
75db1f124cSVasiliy Kozyrev  if "\r\n" in open(os.path.join('bin','petscmpiexec'),"rb").read():
76db1f124cSVasiliy Kozyrev    print '==============================================================================='
77db1f124cSVasiliy Kozyrev    print ' *** Scripts are in DOS mode. Was winzip used to extract petsc sources?    ****'
78db1f124cSVasiliy Kozyrev    print ' *** Please restart with a fresh tarball and use "tar -xzf petsc.tar.gz"   ****'
79db1f124cSVasiliy Kozyrev    print '==============================================================================='
80db1f124cSVasiliy Kozyrev    sys.exit(3)
818a4600f2SSatish Balay  return
828a4600f2SSatish Balay
836a8f6897SSatish Balaydef chkcygwinlink():
841921852fSSatish Balay  if os.path.exists('/usr/bin/cygcheck.exe') and os.path.exists('/usr/bin/link.exe') and chkwinf90():
856a8f6897SSatish Balay      if '--ignore-cygwin-link' in sys.argv: return 0
866a8f6897SSatish Balay      print '==============================================================================='
871921852fSSatish Balay      print ' *** Cygwin /usr/bin/link detected! Compiles with CVF/Intel f90 can break!  **'
886a8f6897SSatish Balay      print ' *** To workarround do: "mv /usr/bin/link.exe /usr/bin/link-cygwin.exe"     **'
896a8f6897SSatish Balay      print ' *** Or to ignore this check, use configure option: --ignore-cygwin-link    **'
906a8f6897SSatish Balay      print '==============================================================================='
916a8f6897SSatish Balay      sys.exit(3)
926a8f6897SSatish Balay  return 0
936a8f6897SSatish Balay
9485ef4d1eSSatish Balaydef chkbrokencygwin():
959dabcff0SSatish Balay  if os.path.exists('/usr/bin/cygcheck.exe'):
969dabcff0SSatish Balay    buf = os.popen('/usr/bin/cygcheck.exe -c cygwin').read()
979dabcff0SSatish Balay    if buf.find('1.5.11-1') > -1:
98a0022257SSatish Balay      print '==============================================================================='
99e2e64c6bSBarry Smith      print ' *** cygwin-1.5.11-1 detected. ./configure fails with this version ***'
1001937db7aSSatish Balay      print ' *** Please upgrade to cygwin-1.5.12-1 or newer version. This can  ***'
1011937db7aSSatish Balay      print ' *** be done by running cygwin-setup, selecting "next" all the way.***'
102a0022257SSatish Balay      print '==============================================================================='
1031937db7aSSatish Balay      sys.exit(3)
1049dabcff0SSatish Balay  return 0
1059dabcff0SSatish Balay
106ee76e990SSatish Balaydef chkusingwindowspython():
107ee76e990SSatish Balay  if sys.platform == 'win32':
108ee76e990SSatish Balay    print '==============================================================================='
109ee76e990SSatish Balay    print ' *** Windows python detected. Please rerun ./configure with cygwin-python. ***'
110ee76e990SSatish Balay    print '==============================================================================='
111ee76e990SSatish Balay    sys.exit(3)
112ee76e990SSatish Balay  return 0
113ee76e990SSatish Balay
11414f5c25cSSatish Balaydef chkcygwinpython():
11514f5c25cSSatish Balay  if os.path.exists('/usr/bin/cygcheck.exe') and sys.platform == 'cygwin' :
1161937db7aSSatish Balay    sys.argv.append('--useThreads=0')
1171937db7aSSatish Balay    extraLogs.append('''\
118a0022257SSatish Balay===============================================================================
11914f5c25cSSatish Balay** Cygwin-python detected. Threads do not work correctly. ***
12014f5c25cSSatish Balay** Disabling thread usage for this run of ./configure *******
121a0022257SSatish Balay===============================================================================''')
12271384062SSatish Balay  return 0
12371384062SSatish Balay
1241937db7aSSatish Balaydef chkrhl9():
1251937db7aSSatish Balay  if os.path.exists('/etc/redhat-release'):
126836c2c52SSatish Balay    try:
127594eb360SSatish Balay      file = open('/etc/redhat-release','r')
128836c2c52SSatish Balay      buf = file.read()
129836c2c52SSatish Balay      file.close()
130836c2c52SSatish Balay    except:
131836c2c52SSatish Balay      # can't read file - assume dangerous RHL9
1321937db7aSSatish Balay      buf = 'Shrike'
133836c2c52SSatish Balay    if buf.find('Shrike') > -1:
1341937db7aSSatish Balay      sys.argv.append('--useThreads=0')
1351937db7aSSatish Balay      extraLogs.append('''\
136a0022257SSatish Balay==============================================================================
1371937db7aSSatish Balay   *** RHL9 detected. Threads do not work correctly with this distribution ***
138e2e64c6bSBarry Smith   ****** Disabling thread usage for this run of ./configure *********
139a0022257SSatish Balay===============================================================================''')
140836c2c52SSatish Balay  return 0
141836c2c52SSatish Balay
142da58527dSSatish Balaydef check_broken_configure_log_links():
143da58527dSSatish Balay  '''Sometime symlinks can get broken if the original files are deleted. Delete such broken links'''
144da58527dSSatish Balay  import os
145da58527dSSatish Balay  for logfile in ['configure.log','configure.log.bkp']:
146da58527dSSatish Balay    if os.path.islink(logfile) and not os.path.isfile(logfile): os.remove(logfile)
147da58527dSSatish Balay  return
148da58527dSSatish Balay
149da1d79b4SSatish Balaydef move_configure_log(framework):
150*fe998a80SBarry Smith  '''Move configure.log to PETSC_ARCH/lib/petsc-conf - and update configure.log.bkp in both locations appropriately'''
151b0b472b0SSatish Balay  global petsc_arch
152b0b472b0SSatish Balay
153b0b472b0SSatish Balay  if hasattr(framework,'arch'): petsc_arch = framework.arch
154b0b472b0SSatish Balay  if hasattr(framework,'logName'): curr_file = framework.logName
155b0b472b0SSatish Balay  else: curr_file = 'configure.log'
156b0b472b0SSatish Balay
157b0b472b0SSatish Balay  if petsc_arch:
158da1d79b4SSatish Balay    import shutil
159da1d79b4SSatish Balay    import os
160b0b472b0SSatish Balay
161b0b472b0SSatish Balay    # Just in case - confdir is not created
162*fe998a80SBarry Smith    lib_dir = os.path.join(petsc_arch,'lib')
163*fe998a80SBarry Smith    conf_dir = os.path.join(petsc_arch,'lib','petsc-conf')
164b0b472b0SSatish Balay    if not os.path.isdir(petsc_arch): os.mkdir(petsc_arch)
165*fe998a80SBarry Smith    if not os.path.isdir(lib_dir): os.mkdir(lib_dir)
166b0b472b0SSatish Balay    if not os.path.isdir(conf_dir): os.mkdir(conf_dir)
167b0b472b0SSatish Balay
168da1d79b4SSatish Balay    curr_bkp  = curr_file + '.bkp'
169b0b472b0SSatish Balay    new_file  = os.path.join(conf_dir,curr_file)
170da1d79b4SSatish Balay    new_bkp   = new_file + '.bkp'
171da1d79b4SSatish Balay
172*fe998a80SBarry Smith    # Keep backup in $PETSC_ARCH/lib/petsc-conf location
173da1d79b4SSatish Balay    if os.path.isfile(new_bkp): os.remove(new_bkp)
174da1d79b4SSatish Balay    if os.path.isfile(new_file): os.rename(new_file,new_bkp)
1759e50940cSSatish Balay    if os.path.isfile(curr_file):
1769e50940cSSatish Balay      shutil.copyfile(curr_file,new_file)
1779e50940cSSatish Balay      os.remove(curr_file)
178da58527dSSatish Balay    if os.path.isfile(new_file): os.symlink(new_file,curr_file)
179*fe998a80SBarry Smith    # If the old bkp is using the same PETSC_ARCH/lib/petsc-conf - then update bkp link
180da1d79b4SSatish Balay    if os.path.realpath(curr_bkp) == os.path.realpath(new_file):
181da58527dSSatish Balay      if os.path.isfile(curr_bkp): os.remove(curr_bkp)
182da58527dSSatish Balay      if os.path.isfile(new_bkp): os.symlink(new_bkp,curr_bkp)
183da1d79b4SSatish Balay  return
184da1d79b4SSatish Balay
185d93c4beeSSatish Balaydef print_final_timestamp(framework):
186d93c4beeSSatish Balay  import time
187d93c4beeSSatish Balay  framework.log.write(('='*80)+'\n')
188d93c4beeSSatish Balay  framework.log.write('Finishing Configure Run at '+time.ctime(time.time())+'\n')
189d93c4beeSSatish Balay  framework.log.write(('='*80)+'\n')
190d93c4beeSSatish Balay  return
191d93c4beeSSatish Balay
1925d5a5a7bSMatthew Knepleydef petsc_configure(configure_options):
1934a532159SBarry Smith  try:
1944a532159SBarry Smith    petscdir = os.environ['PETSC_DIR']
195bf39c399SBarry Smith    sys.path.append(os.path.join(petscdir,'bin','petsc-pythonscripts'))
1964a532159SBarry Smith    import petscnagupgrade
1974a532159SBarry Smith    file     = os.path.join(petscdir,'.nagged')
1984a532159SBarry Smith    if not petscnagupgrade.naggedtoday(file):
1994a532159SBarry Smith      petscnagupgrade.currentversion(petscdir)
2004a532159SBarry Smith  except:
2014a532159SBarry Smith    pass
202a0022257SSatish Balay  print '==============================================================================='
20359e9bfd6SSatish Balay  print '             Configuring PETSc to compile on your system                       '
204a0022257SSatish Balay  print '==============================================================================='
20559e9bfd6SSatish Balay
206a258c2c4SMatthew G Knepley  try:
207c43ea0feSSatish Balay    # Command line arguments take precedence (but don't destroy argv[0])
208c43ea0feSSatish Balay    sys.argv = sys.argv[:1] + configure_options + sys.argv[1:]
209ccb279e1SMatthew Knepley    check_for_option_mistakes(sys.argv)
2102af240f0SSatish Balay    check_for_option_changed(sys.argv)
211a258c2c4SMatthew G Knepley  except (TypeError, ValueError), e:
212a258c2c4SMatthew G Knepley    emsg = str(e)
213a258c2c4SMatthew G Knepley    if not emsg.endswith('\n'): emsg = emsg+'\n'
214a258c2c4SMatthew G Knepley    msg ='*******************************************************************************\n'\
215a258c2c4SMatthew G Knepley    +'                ERROR in COMMAND LINE ARGUMENT to ./configure \n' \
216a258c2c4SMatthew G Knepley    +'-------------------------------------------------------------------------------\n'  \
217a258c2c4SMatthew G Knepley    +emsg+'*******************************************************************************\n'
218a258c2c4SMatthew G Knepley    sys.exit(msg)
21959e9bfd6SSatish Balay  # check PETSC_ARCH
22059e9bfd6SSatish Balay  check_petsc_arch(sys.argv)
221da58527dSSatish Balay  check_broken_configure_log_links()
2225fb2c094SBarry Smith
223c22cdea9SBarry Smith  # support a few standard configure option types
224ed6a7445SBarry Smith  for l in range(0,len(sys.argv)):
225c22cdea9SBarry Smith    name = sys.argv[l]
226637cc2ebSSatish Balay    if name.find('enable-') >= 0:
227193cd51eSMatthew Knepley      if name.find('=') == -1:
228193cd51eSMatthew Knepley        sys.argv[l] = name.replace('enable-','with-')+'=1'
229193cd51eSMatthew Knepley      else:
230193cd51eSMatthew Knepley        head, tail = name.split('=', 1)
231193cd51eSMatthew Knepley        sys.argv[l] = head.replace('enable-','with-')+'='+tail
232637cc2ebSSatish Balay    if name.find('disable-') >= 0:
233193cd51eSMatthew Knepley      if name.find('=') == -1:
234193cd51eSMatthew Knepley        sys.argv[l] = name.replace('disable-','with-')+'=0'
235193cd51eSMatthew Knepley      else:
236193cd51eSMatthew Knepley        head, tail = name.split('=', 1)
237193cd51eSMatthew Knepley        if tail == '1': tail = '0'
238193cd51eSMatthew Knepley        sys.argv[l] = head.replace('disable-','with-')+'='+tail
239637cc2ebSSatish Balay    if name.find('without-') >= 0:
240193cd51eSMatthew Knepley      if name.find('=') == -1:
241193cd51eSMatthew Knepley        sys.argv[l] = name.replace('without-','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('without-','with-')+'='+tail
246adc3e427SMatthew Knepley
2479dabcff0SSatish Balay  # Check for broken cygwin
2481937db7aSSatish Balay  chkbrokencygwin()
249d65f3bddSMatthew Knepley  # Disable threads on RHL9
2501937db7aSSatish Balay  chkrhl9()
251ee76e990SSatish Balay  # Make sure cygwin-python is used on windows
252ee76e990SSatish Balay  chkusingwindowspython()
25314f5c25cSSatish Balay  # Threads don't work for cygwin & python...
25414f5c25cSSatish Balay  chkcygwinpython()
2556a8f6897SSatish Balay  chkcygwinlink()
2568a4600f2SSatish Balay  chkdosfiles()
2579dabcff0SSatish Balay
25887282423SMatthew Knepley  # Should be run from the toplevel
259dbca6d9dSSatish Balay  configDir = os.path.abspath('config')
260f8833479SBarry Smith  bsDir     = os.path.join(configDir, 'BuildSystem')
261f8833479SBarry Smith  if not os.path.isdir(configDir):
2625d5a5a7bSMatthew Knepley    raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.'))
26387282423SMatthew Knepley  sys.path.insert(0, bsDir)
264f8833479SBarry Smith  sys.path.insert(0, configDir)
265e69ef9dfSMatthew Knepley  import config.base
2665d5a5a7bSMatthew Knepley  import config.framework
267f56be888SMatthew Knepley  import cPickle
2684f8a5b45SBarry Smith
2699dd2fdb1SMatthew Knepley  framework = None
2709dd2fdb1SMatthew Knepley  try:
27123a19ef1SSatish Balay    framework = config.framework.Framework(['--configModules=PETSc.Configure','--optionsModule=config.compilerOptions']+sys.argv[1:], loadArgDB = 0)
272d65f3bddSMatthew Knepley    framework.setup()
273d65f3bddSMatthew Knepley    framework.logPrint('\n'.join(extraLogs))
274f24f64feSBarry Smith    framework.configure(out = sys.stdout)
275358ebc22SMatthew Knepley    framework.storeSubstitutions(framework.argDB)
276f56be888SMatthew Knepley    framework.argDB['configureCache'] = cPickle.dumps(framework)
2777c939e48SSatish Balay    framework.printSummary()
27812c1d45bSMatthew G Knepley    framework.argDB.save(force = True)
2797cfd0b05SBarry Smith    framework.logClear()
280d93c4beeSSatish Balay    print_final_timestamp(framework)
281eefa2c0fSBarry Smith    framework.closeLog()
2829e50940cSSatish Balay    try:
283da1d79b4SSatish Balay      move_configure_log(framework)
2849e50940cSSatish Balay    except:
2859e50940cSSatish Balay      # perhaps print an error about unable to shuffle logs?
2869e50940cSSatish Balay      pass
287dd50d019SBarry Smith    return 0
288e69ef9dfSMatthew Knepley  except (RuntimeError, config.base.ConfigureSetupError), e:
2897d670a3cSBarry Smith    emsg = str(e)
29042351d26SSatish Balay    if not emsg.endswith('\n'): emsg = emsg+'\n'
291a0022257SSatish Balay    msg ='*******************************************************************************\n'\
292fe09c992SBarry Smith    +'         UNABLE to CONFIGURE with GIVEN OPTIONS    (see configure.log for details):\n' \
293a0022257SSatish Balay    +'-------------------------------------------------------------------------------\n'  \
294a0022257SSatish Balay    +emsg+'*******************************************************************************\n'
295e9f3bb17SBarry Smith    se = ''
2969dd2fdb1SMatthew Knepley  except (TypeError, ValueError), e:
2977d670a3cSBarry Smith    emsg = str(e)
29842351d26SSatish Balay    if not emsg.endswith('\n'): emsg = emsg+'\n'
299a0022257SSatish Balay    msg ='*******************************************************************************\n'\
300e2e64c6bSBarry Smith    +'                ERROR in COMMAND LINE ARGUMENT to ./configure \n' \
301a0022257SSatish Balay    +'-------------------------------------------------------------------------------\n'  \
302a0022257SSatish Balay    +emsg+'*******************************************************************************\n'
3031a02243aSBarry Smith    se = ''
30496dc2fe8SMatthew Knepley  except ImportError, e :
3057d670a3cSBarry Smith    emsg = str(e)
30642351d26SSatish Balay    if not emsg.endswith('\n'): emsg = emsg+'\n'
307a0022257SSatish Balay    msg ='*******************************************************************************\n'\
308e2e64c6bSBarry Smith    +'                     UNABLE to FIND MODULE for ./configure \n' \
309a0022257SSatish Balay    +'-------------------------------------------------------------------------------\n'  \
310a0022257SSatish Balay    +emsg+'*******************************************************************************\n'
31196dc2fe8SMatthew Knepley    se = ''
31201def6f0SMatthew Knepley  except OSError, e :
31301def6f0SMatthew Knepley    emsg = str(e)
31401def6f0SMatthew Knepley    if not emsg.endswith('\n'): emsg = emsg+'\n'
315a0022257SSatish Balay    msg ='*******************************************************************************\n'\
316e2e64c6bSBarry Smith    +'                    UNABLE to EXECUTE BINARIES for ./configure \n' \
317a0022257SSatish Balay    +'-------------------------------------------------------------------------------\n'  \
318a0022257SSatish Balay    +emsg+'*******************************************************************************\n'
31901def6f0SMatthew Knepley    se = ''
320d7d3c4beSMatthew Knepley  except SystemExit, e:
321d7d3c4beSMatthew Knepley    if e.code is None or e.code == 0:
322d7d3c4beSMatthew Knepley      return
323a0022257SSatish Balay    msg ='*******************************************************************************\n'\
324b1dada7fSMatthew Knepley    +'         CONFIGURATION FAILURE  (Please send configure.log to petsc-maint@mcs.anl.gov)\n' \
325a0022257SSatish Balay    +'*******************************************************************************\n'
326d7d3c4beSMatthew Knepley    se  = str(e)
327e9f3bb17SBarry Smith  except Exception, e:
328a0022257SSatish Balay    msg ='*******************************************************************************\n'\
329fe09c992SBarry Smith    +'        CONFIGURATION CRASH  (Please send configure.log to petsc-maint@mcs.anl.gov)\n' \
330a0022257SSatish Balay    +'*******************************************************************************\n'
331e9f3bb17SBarry Smith    se  = str(e)
332e9f3bb17SBarry Smith
333e9f3bb17SBarry Smith  print msg
3349dd2fdb1SMatthew Knepley  if not framework is None:
3359dd2fdb1SMatthew Knepley    framework.logClear()
336e9f3bb17SBarry Smith    if hasattr(framework, 'log'):
33722c95ba3SMatthew G Knepley      try:
338d71f8ab3SSatish Balay        if hasattr(framework,'compilerDefines'):
339bd5137a2SBarry Smith          framework.log.write('**** Configure header '+framework.compilerDefines+' ****\n')
340febd46b0SSatish Balay          framework.outputHeader(framework.log)
341d71f8ab3SSatish Balay        if hasattr(framework,'compilerFixes'):
342bd5137a2SBarry Smith          framework.log.write('**** C specific Configure header '+framework.compilerFixes+' ****\n')
343febd46b0SSatish Balay          framework.outputCHeader(framework.log)
34422c95ba3SMatthew G Knepley      except Exception, e:
34522c95ba3SMatthew G Knepley        framework.log.write('Problem writing headers to log: '+str(e))
346f6614063SBarry Smith      import traceback
347b1dada7fSMatthew Knepley      try:
348f24f64feSBarry Smith        framework.log.write(msg+se)
349f24f64feSBarry Smith        traceback.print_tb(sys.exc_info()[2], file = framework.log)
350d93c4beeSSatish Balay        print_final_timestamp(framework)
351f73e6a6cSSatish Balay        if hasattr(framework,'log'): framework.log.close()
352da1d79b4SSatish Balay        move_configure_log(framework)
353b1dada7fSMatthew Knepley      except:
354b1dada7fSMatthew Knepley        pass
355e9f3bb17SBarry Smith      sys.exit(1)
3565a74f024SMatthew Knepley  else:
3575a74f024SMatthew Knepley    print se
3585a74f024SMatthew Knepley    import traceback
3595a74f024SMatthew Knepley    traceback.print_tb(sys.exc_info()[2])
360f73e6a6cSSatish Balay  if hasattr(framework,'log'): framework.log.close()
3615d5a5a7bSMatthew Knepley
3625d5a5a7bSMatthew Knepleyif __name__ == '__main__':
363a030c540SBarry Smith  petsc_configure([])
364759acf64SBarry Smith
365