xref: /petsc/config/PETSc/Configure.py (revision 4eb428fdc6f36238aef3665003db33fd4cbae8e2)
1import config.base
2
3import os
4import re
5
6# The sorted() builtin is not available with python-2.3
7try: sorted
8except NameError:
9  def sorted(lst):
10    lst.sort()
11    return lst
12
13class Configure(config.base.Configure):
14  def __init__(self, framework):
15    config.base.Configure.__init__(self, framework)
16    self.headerPrefix = 'PETSC'
17    self.substPrefix  = 'PETSC'
18    return
19
20  def __str2__(self):
21    desc = []
22    desc.append('xxx=========================================================================xxx')
23    if self.getMakeMacro('PETSC_BUILD_USING_CMAKE'):
24      build_type = 'cmake build'
25    else:
26      build_type = 'legacy build'
27    desc.append(' Configure stage complete. Now build PETSc libraries with (%s):' % build_type)
28    desc.append('   make PETSC_DIR='+self.petscdir.dir+' PETSC_ARCH='+self.arch.arch+' all')
29    desc.append(' or (experimental with python):')
30    desc.append('   PETSC_DIR='+self.petscdir.dir+' PETSC_ARCH='+self.arch.arch+' ./config/builder.py')
31    desc.append('xxx=========================================================================xxx')
32    return '\n'.join(desc)+'\n'
33
34  def setupHelp(self, help):
35    import nargs
36    help.addArgument('PETSc',  '-prefix=<dir>',                  nargs.Arg(None, '', 'Specifiy location to install PETSc (eg. /usr/local)'))
37    help.addArgument('Windows','-with-windows-graphics=<bool>',   nargs.ArgBool(None, 1,'Enable check for Windows Graphics'))
38    help.addArgument('PETSc', '-with-default-arch=<bool>',        nargs.ArgBool(None, 1, 'Allow using the last configured arch without setting PETSC_ARCH'))
39    help.addArgument('PETSc','-with-single-library=<bool>',       nargs.ArgBool(None, 1,'Put all PETSc code into the single -lpetsc library'))
40    help.addArgument('PETSc', '-with-ios=<bool>',              nargs.ArgBool(None, 0, 'Build an iPhone/iPad version of PETSc library'))
41    return
42
43  def setupDependencies(self, framework):
44    config.base.Configure.setupDependencies(self, framework)
45    self.setCompilers  = framework.require('config.setCompilers',      self)
46    self.arch          = framework.require('PETSc.utilities.arch',     self.setCompilers)
47    self.petscdir      = framework.require('PETSc.utilities.petscdir', self.setCompilers)
48    self.languages     = framework.require('PETSc.utilities.languages',self.setCompilers)
49    self.debugging     = framework.require('PETSc.utilities.debugging',self.setCompilers)
50    self.CHUD          = framework.require('PETSc.utilities.CHUD',     self)
51    self.compilers     = framework.require('config.compilers',         self)
52    self.types         = framework.require('config.types',             self)
53    self.headers       = framework.require('config.headers',           self)
54    self.functions     = framework.require('config.functions',         self)
55    self.libraries     = framework.require('config.libraries',         self)
56    self.atomics       = framework.require('config.atomics',           self)
57    if os.path.isdir(os.path.join('config', 'PETSc')):
58      for d in ['utilities', 'packages']:
59        for utility in os.listdir(os.path.join('config', 'PETSc', d)):
60          (utilityName, ext) = os.path.splitext(utility)
61          if not utilityName.startswith('.') and not utilityName.startswith('#') and ext == '.py' and not utilityName == '__init__':
62            utilityObj                    = self.framework.require('PETSc.'+d+'.'+utilityName, self)
63            utilityObj.headerPrefix       = self.headerPrefix
64            utilityObj.archProvider       = self.arch
65            utilityObj.languageProvider   = self.languages
66            utilityObj.installDirProvider = self.petscdir
67            setattr(self, utilityName.lower(), utilityObj)
68
69    for package in config.packages.all:
70      if not package == 'PETSc':
71        packageObj                    = framework.require('config.packages.'+package, self)
72        packageObj.archProvider       = self.arch
73        packageObj.languageProvider   = self.languages
74        packageObj.installDirProvider = self.petscdir
75        setattr(self, package.lower(), packageObj)
76    # Force blaslapack to depend on scalarType so precision is set before BlasLapack is built
77    framework.require('PETSc.utilities.scalarTypes', self.f2cblaslapack)
78    self.f2cblaslapack.precisionProvider = self.scalartypes
79    framework.require('PETSc.utilities.scalarTypes', self.blaslapack)
80    self.blaslapack.precisionProvider = self.scalartypes
81
82    self.compilers.headerPrefix  = self.headerPrefix
83    self.types.headerPrefix      = self.headerPrefix
84    self.headers.headerPrefix    = self.headerPrefix
85    self.functions.headerPrefix  = self.headerPrefix
86    self.libraries.headerPrefix  = self.headerPrefix
87    self.blaslapack.headerPrefix = self.headerPrefix
88    self.mpi.headerPrefix        = self.headerPrefix
89    headersC = map(lambda name: name+'.h', ['setjmp','dos', 'endian', 'fcntl', 'float', 'io', 'limits', 'malloc', 'pwd', 'search', 'strings',
90                                            'unistd', 'sys/sysinfo', 'machine/endian', 'sys/param', 'sys/procfs', 'sys/resource',
91                                            'sys/systeminfo', 'sys/times', 'sys/utsname','string', 'stdlib','memory',
92                                            'sys/socket','sys/wait','netinet/in','netdb','Direct','time','Ws2tcpip','sys/types',
93                                            'WindowsX', 'cxxabi','float','ieeefp','stdint','fenv','sched','pthread'])
94    functions = ['access', '_access', 'clock', 'drand48', 'getcwd', '_getcwd', 'getdomainname', 'gethostname', 'getpwuid',
95                 'gettimeofday', 'getwd', 'memalign', 'memmove', 'mkstemp', 'popen', 'PXFGETARG', 'rand', 'getpagesize',
96                 'readlink', 'realpath',  'sigaction', 'signal', 'sigset', 'usleep', 'sleep', '_sleep', 'socket',
97                 'times', 'gethostbyname', 'uname','snprintf','_snprintf','_fullpath','lseek','_lseek','time','fork','stricmp',
98                 'strcasecmp', 'bzero', 'dlopen', 'dlsym', 'dlclose', 'dlerror',
99                 '_intel_fast_memcpy','_intel_fast_memset']
100    libraries1 = [(['socket', 'nsl'], 'socket'), (['fpe'], 'handle_sigfpes')]
101    self.headers.headers.extend(headersC)
102    self.functions.functions.extend(functions)
103    self.libraries.libraries.extend(libraries1)
104
105    return
106
107  def Dump(self):
108    ''' Actually put the values into the configuration files '''
109    # eventually everything between -- should be gone
110#-----------------------------------------------------------------------------------------------------
111
112    # Sometimes we need C compiler, even if built with C++
113    self.setCompilers.pushLanguage('C')
114    self.addMakeMacro('CC_FLAGS',self.setCompilers.getCompilerFlags())
115    self.setCompilers.popLanguage()
116
117    # C preprocessor values
118    self.addMakeMacro('CPP_FLAGS',self.setCompilers.CPPFLAGS+self.CHUD.CPPFLAGS)
119
120    # compiler values
121    self.setCompilers.pushLanguage(self.languages.clanguage)
122    self.addMakeMacro('PCC',self.setCompilers.getCompiler())
123    self.addMakeMacro('PCC_FLAGS',self.setCompilers.getCompilerFlags())
124    self.setCompilers.popLanguage()
125    # .o or .obj
126    self.addMakeMacro('CC_SUFFIX','o')
127
128    # executable linker values
129    self.setCompilers.pushLanguage(self.languages.clanguage)
130    pcc_linker = self.setCompilers.getLinker()
131    self.addMakeMacro('PCC_LINKER',pcc_linker)
132    self.addMakeMacro('PCC_LINKER_FLAGS',self.setCompilers.getLinkerFlags())
133    self.setCompilers.popLanguage()
134    # '' for Unix, .exe for Windows
135    self.addMakeMacro('CC_LINKER_SUFFIX','')
136
137    if hasattr(self.compilers, 'FC'):
138      self.setCompilers.pushLanguage('FC')
139      # need FPPFLAGS in config/setCompilers
140      self.addDefine('HAVE_FORTRAN','1')
141      self.addMakeMacro('FPP_FLAGS',self.setCompilers.CPPFLAGS)
142
143      # compiler values
144      self.addMakeMacro('FC_FLAGS',self.setCompilers.getCompilerFlags())
145      self.setCompilers.popLanguage()
146      # .o or .obj
147      self.addMakeMacro('FC_SUFFIX','o')
148
149      # executable linker values
150      self.setCompilers.pushLanguage('FC')
151      # Cannot have NAG f90 as the linker - so use pcc_linker as fc_linker
152      fc_linker = self.setCompilers.getLinker()
153      if config.setCompilers.Configure.isNAG(fc_linker):
154        self.addMakeMacro('FC_LINKER',pcc_linker)
155      else:
156        self.addMakeMacro('FC_LINKER',fc_linker)
157      self.addMakeMacro('FC_LINKER_FLAGS',self.setCompilers.getLinkerFlags())
158      # apple requires this shared library linker flag on SOME versions of the os
159      if self.setCompilers.getLinkerFlags().find('-Wl,-commons,use_dylibs') > -1:
160        self.addMakeMacro('DARWIN_COMMONS_USE_DYLIBS',' -Wl,-commons,use_dylibs ')
161      self.setCompilers.popLanguage()
162
163      # F90 Modules
164      if self.setCompilers.fortranModuleIncludeFlag:
165        self.addMakeMacro('FC_MODULE_FLAG', self.setCompilers.fortranModuleIncludeFlag)
166      else: # for non-f90 compilers like g77
167        self.addMakeMacro('FC_MODULE_FLAG', '-I')
168      if self.setCompilers.fortranModuleIncludeFlag:
169        self.addMakeMacro('FC_MODULE_OUTPUT_FLAG', self.setCompilers.fortranModuleOutputFlag)
170    else:
171      self.addMakeMacro('FC','')
172
173    if hasattr(self.compilers, 'CUDAC'):
174      self.setCompilers.pushLanguage('CUDA')
175      self.addMakeMacro('CUDAC_FLAGS',self.setCompilers.getCompilerFlags())
176      self.setCompilers.popLanguage()
177
178    # shared library linker values
179    self.setCompilers.pushLanguage(self.languages.clanguage)
180    # need to fix BuildSystem to collect these separately
181    self.addMakeMacro('SL_LINKER',self.setCompilers.getLinker())
182    self.addMakeMacro('SL_LINKER_FLAGS','${PCC_LINKER_FLAGS}')
183    self.setCompilers.popLanguage()
184    # One of 'a', 'so', 'lib', 'dll', 'dylib' (perhaps others also?) depending on the library generator and architecture
185    # Note: . is not included in this macro, consistent with AR_LIB_SUFFIX
186    if self.setCompilers.sharedLibraryExt == self.setCompilers.AR_LIB_SUFFIX:
187      self.addMakeMacro('SL_LINKER_SUFFIX', '')
188      self.addDefine('SLSUFFIX','""')
189    else:
190      self.addMakeMacro('SL_LINKER_SUFFIX', self.setCompilers.sharedLibraryExt)
191      self.addDefine('SLSUFFIX','"'+self.setCompilers.sharedLibraryExt+'"')
192
193    self.addMakeMacro('SL_LINKER_LIBS','${PETSC_EXTERNAL_LIB_BASIC}')
194
195#-----------------------------------------------------------------------------------------------------
196
197    # CONLY or CPP. We should change the PETSc makefiles to do this better
198    if self.languages.clanguage == 'C': lang = 'CONLY'
199    else: lang = 'CXXONLY'
200    self.addMakeMacro('PETSC_LANGUAGE',lang)
201
202    # real or complex
203    self.addMakeMacro('PETSC_SCALAR',self.scalartypes.scalartype)
204    # double or float
205    self.addMakeMacro('PETSC_PRECISION',self.scalartypes.precision)
206
207    if self.framework.argDB['with-batch']:
208      self.addMakeMacro('PETSC_WITH_BATCH','1')
209
210    # Test for compiler-specific macros that need to be defined.
211    if self.setCompilers.isCrayVector('CC'):
212      self.addDefine('HAVE_CRAY_VECTOR','1')
213
214#-----------------------------------------------------------------------------------------------------
215    if self.functions.haveFunction('gethostbyname') and self.functions.haveFunction('socket') and self.headers.haveHeader('netinet/in.h'):
216      self.addDefine('USE_SOCKET_VIEWER','1')
217      if self.checkCompile('#include <sys/socket.h>','setsockopt(0,SOL_SOCKET,SO_REUSEADDR,0,0)'):
218        self.addDefine('HAVE_SO_REUSEADDR','1')
219
220#-----------------------------------------------------------------------------------------------------
221    # print include and lib for makefiles
222    self.framework.packages.reverse()
223    includes = [os.path.join(self.petscdir.dir,'include'),os.path.join(self.petscdir.dir,self.arch.arch,'include')]
224    libs = []
225    for i in self.framework.packages:
226      if i.useddirectly:
227        self.addDefine('HAVE_'+i.PACKAGE, 1)  # ONLY list package if it is used directly by PETSc (and not only by another package)
228      if not isinstance(i.lib, list):
229        i.lib = [i.lib]
230      libs.extend(i.lib)
231      print i.lib, self.libraries.toStringNoDupes(i.lib)
232      self.addMakeMacro(i.PACKAGE+'_LIB', self.libraries.toStringNoDupes(i.lib))
233      if hasattr(i,'include'):
234        if not isinstance(i.include,list):
235          i.include = [i.include]
236        includes.extend(i.include)
237        self.addMakeMacro(i.PACKAGE+'_INCLUDE',self.headers.toStringNoDupes(i.include))
238    if self.framework.argDB['with-single-library']:
239      self.addMakeMacro('PETSC_WITH_EXTERNAL_LIB',self.libraries.toStringNoDupes(['-L'+os.path.join(self.petscdir.dir,self.arch.arch,'lib'),' -lpetsc']+libs+self.libraries.math+self.compilers.flibs+self.compilers.cxxlibs+self.compilers.LIBS.split(' '))+self.CHUD.LIBS)
240    self.addMakeMacro('PETSC_EXTERNAL_LIB_BASIC',self.libraries.toStringNoDupes(libs+self.libraries.math+self.compilers.flibs+self.compilers.cxxlibs+self.compilers.LIBS.split(' '))+self.CHUD.LIBS)
241    self.PETSC_EXTERNAL_LIB_BASIC = self.libraries.toStringNoDupes(libs+self.libraries.math+self.compilers.flibs+self.compilers.cxxlibs+self.compilers.LIBS.split(' '))+self.CHUD.LIBS
242    self.addMakeMacro('PETSC_CC_INCLUDES',self.headers.toStringNoDupes(includes))
243    self.PETSC_CC_INCLUDES = self.headers.toStringNoDupes(includes)
244    if hasattr(self.compilers, 'FC'):
245      if self.compilers.fortranIsF90:
246        self.addMakeMacro('PETSC_FC_INCLUDES',self.headers.toStringNoDupes(includes,includes))
247      else:
248        self.addMakeMacro('PETSC_FC_INCLUDES',self.headers.toStringNoDupes(includes))
249
250    self.addMakeMacro('DESTDIR',self.installdir)
251    self.addDefine('LIB_DIR','"'+os.path.join(self.installdir,'lib')+'"')
252
253    if self.framework.argDB['with-single-library']:
254      # overrides the values set in conf/variables
255      self.addMakeMacro('LIBNAME','${INSTALL_LIB_DIR}/libpetsc.${AR_LIB_SUFFIX}')
256      self.addMakeMacro('SHLIBS','libpetsc')
257      self.addMakeMacro('PETSC_LIB_BASIC','-lpetsc')
258      self.addMakeMacro('PETSC_KSP_LIB_BASIC','-lpetsc')
259      self.addMakeMacro('PETSC_TS_LIB_BASIC','-lpetsc')
260      self.addDefine('USE_SINGLE_LIBRARY', '1')
261      if self.sharedlibraries.useShared:
262        self.addMakeMacro('PETSC_SYS_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
263        self.addMakeMacro('PETSC_VEC_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
264        self.addMakeMacro('PETSC_MAT_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
265        self.addMakeMacro('PETSC_DM_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
266        self.addMakeMacro('PETSC_KSP_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
267        self.addMakeMacro('PETSC_SNES_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
268        self.addMakeMacro('PETSC_TS_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
269        self.addMakeMacro('PETSC_CHARACTERISTIC_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
270        self.addMakeMacro('PETSC_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
271        self.addMakeMacro('PETSC_CONTRIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
272      else:
273        self.addMakeMacro('PETSC_SYS_LIB','${PETSC_WITH_EXTERNAL_LIB}')
274        self.addMakeMacro('PETSC_VEC_LIB','${PETSC_WITH_EXTERNAL_LIB}')
275        self.addMakeMacro('PETSC_MAT_LIB','${PETSC_WITH_EXTERNAL_LIB}')
276        self.addMakeMacro('PETSC_DM_LIB','${PETSC_WITH_EXTERNAL_LIB}')
277        self.addMakeMacro('PETSC_KSP_LIB','${PETSC_WITH_EXTERNAL_LIB}')
278        self.addMakeMacro('PETSC_SNES_LIB','${PETSC_WITH_EXTERNAL_LIB}')
279        self.addMakeMacro('PETSC_TS_LIB','${PETSC_WITH_EXTERNAL_LIB}')
280        self.addMakeMacro('PETSC_CHARACTERISTIC_LIB','${PETSC_WITH_EXTERNAL_LIB}')
281        self.addMakeMacro('PETSC_LIB','${PETSC_WITH_EXTERNAL_LIB}')
282        self.addMakeMacro('PETSC_CONTRIB','${PETSC_WITH_EXTERNAL_LIB}')
283
284    if not os.path.exists(os.path.join(self.petscdir.dir,self.arch.arch,'lib')):
285      os.makedirs(os.path.join(self.petscdir.dir,self.arch.arch,'lib'))
286
287    # add a makefile entry for configure options
288    self.addMakeMacro('CONFIGURE_OPTIONS', self.framework.getOptionsString(['configModules', 'optionsModule']).replace('\"','\\"'))
289    return
290
291  def dumpConfigInfo(self):
292    import time
293    fd = file(os.path.join(self.arch.arch,'include','petscconfiginfo.h'),'w')
294    fd.write('static const char *petscconfigureruntime = "'+time.ctime(time.time())+'";\n')
295    fd.write('static const char *petscconfigureoptions = "'+self.framework.getOptionsString(['configModules', 'optionsModule']).replace('\"','\\"')+'";\n')
296    fd.close()
297    return
298
299  def dumpMachineInfo(self):
300    import platform
301    import time
302    import script
303    fd = file(os.path.join(self.arch.arch,'include','petscmachineinfo.h'),'w')
304    fd.write('static const char *petscmachineinfo = \"\\n\"\n')
305    fd.write('\"-----------------------------------------\\n\"\n')
306    fd.write('\"Libraries compiled on %s on %s \\n\"\n' % (time.ctime(time.time()), platform.node()))
307    fd.write('\"Machine characteristics: %s\\n\"\n' % (platform.platform()))
308    fd.write('\"Using PETSc directory: %s\\n\"\n' % (self.petscdir.dir))
309    fd.write('\"Using PETSc arch: %s\\n\"\n' % (self.arch.arch))
310    fd.write('\"-----------------------------------------\\n\";\n')
311    fd.write('static const char *petsccompilerinfo = \"\\n\"\n')
312    self.setCompilers.pushLanguage(self.languages.clanguage)
313    fd.write('\"Using C compiler: %s %s ${COPTFLAGS} ${CFLAGS}\\n\"\n' % (self.setCompilers.getCompiler(), self.setCompilers.getCompilerFlags()))
314    self.setCompilers.popLanguage()
315    if hasattr(self.compilers, 'FC'):
316      self.setCompilers.pushLanguage('FC')
317      fd.write('\"Using Fortran compiler: %s %s ${FOPTFLAGS} ${FFLAGS} %s\\n\"\n' % (self.setCompilers.getCompiler(), self.setCompilers.getCompilerFlags(), self.setCompilers.CPPFLAGS))
318      self.setCompilers.popLanguage()
319    fd.write('\"-----------------------------------------\\n\";\n')
320    fd.write('static const char *petsccompilerflagsinfo = \"\\n\"\n')
321    fd.write('\"Using include paths: %s %s %s\\n\"\n' % ('-I'+os.path.join(self.petscdir.dir, self.arch.arch, 'include'), '-I'+os.path.join(self.petscdir.dir, 'include'), self.PETSC_CC_INCLUDES.replace('\\ ','\\\\ ')))
322    fd.write('\"-----------------------------------------\\n\";\n')
323    fd.write('static const char *petsclinkerinfo = \"\\n\"\n')
324    self.setCompilers.pushLanguage(self.languages.clanguage)
325    fd.write('\"Using C linker: %s\\n\"\n' % (self.setCompilers.getLinker()))
326    self.setCompilers.popLanguage()
327    if hasattr(self.compilers, 'FC'):
328      self.setCompilers.pushLanguage('FC')
329      fd.write('\"Using Fortran linker: %s\\n\"\n' % (self.setCompilers.getLinker()))
330      self.setCompilers.popLanguage()
331    if self.framework.argDB['with-single-library']:
332      petsclib = '-lpetsc'
333    else:
334      petsclib = '-lpetscts -lpetscsnes -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetscsys'
335    fd.write('\"Using libraries: %s%s -L%s %s %s\\n\"\n' % (self.setCompilers.CSharedLinkerFlag, os.path.join(self.petscdir.dir, self.arch.arch, 'lib'), os.path.join(self.petscdir.dir, self.arch.arch, 'lib'), petsclib, self.PETSC_EXTERNAL_LIB_BASIC.replace('\\ ','\\\\ ')))
336    fd.write('\"-----------------------------------------\\n\";\n')
337    fd.close()
338    return
339
340  def dumpCMakeConfig(self):
341    '''
342    Writes configuration-specific values to ${PETSC_ARCH}/conf/PETScConfig.cmake.
343    This file is private to PETSc and should not be included by third parties
344    (a suitable file can be produced later by CMake, but this is not it).
345    '''
346    def cmakeset(fd,key,val=True):
347      if val == True: val = 'YES'
348      if val == False: val = 'NO'
349      fd.write('set (' + key + ' ' + val + ')\n')
350    def ensurelist(a):
351      if isinstance(a,list):
352        return a
353      else:
354        return [a]
355    def libpath(lib):
356      'Returns a search path if that is what this item provides, else "" which will be cleaned out later'
357      if not isinstance(lib,str): return ''
358      if lib.startswith('-L'): return lib[2:]
359      if lib.startswith('-R'): return lib[2:]
360      if lib.startswith('-Wl,-rpath,'):
361        # This case occurs when an external package needs a specific system library that is normally provided by the compiler.
362        # In other words, the -L path is builtin to the wrapper or compiler, here we provide it so that CMake can locate the
363        # corresponding library.
364        return lib[len('-Wl,-rpath,'):]
365      if lib.startswith('-'): return ''
366      return os.path.dirname(lib)
367    def cleanlib(lib):
368      'Returns a library name if that is what this item provides, else "" which will be cleaned out later'
369      if not isinstance(lib,str): return ''
370      if lib.startswith('-l'):  return lib[2:]
371      if lib.startswith('-Wl') or lib.startswith('-L'): return ''
372      lib = os.path.splitext(os.path.basename(lib))[0]
373      if lib.startswith('lib'): return lib[3:]
374      return lib
375    def nub(lst):
376      'Return a list containing the first occurrence of each unique element'
377      unique = []
378      for elem in lst:
379        if elem not in unique and elem != '':
380          unique.append(elem)
381      return unique
382    try: reversed # reversed was added in Python-2.4
383    except NameError:
384      def reversed(lst): return lst[::-1]
385    def nublast(lst):
386      'Return a list containing the last occurrence of each unique entry in a list'
387      return reversed(nub(reversed(lst)))
388    def cmakeexpand(varname):
389      return r'"${' + varname + r'}"'
390    def uniqextend(lst,new):
391      for x in ensurelist(new):
392        if x not in lst:
393          lst.append(x)
394    def notstandardinclude(path):
395      return path not in '/usr/include'.split() # /usr/local/include is not automatically included on FreeBSD
396    def writeMacroDefinitions(fd):
397      if self.mpi.usingMPIUni:
398        cmakeset(fd,'PETSC_HAVE_MPIUNI')
399      for pkg in self.framework.packages:
400        if pkg.useddirectly:
401          cmakeset(fd,'PETSC_HAVE_' + pkg.PACKAGE)
402        for pair in pkg.defines.items():
403          if pair[0].startswith('HAVE_') and pair[1]:
404            cmakeset(fd, self.framework.getFullDefineName(pkg, pair[0]), pair[1])
405      for name,val in self.functions.defines.items():
406        cmakeset(fd,'PETSC_'+name,val)
407      for dct in [self.defines, self.libraryoptions.defines]:
408        for k,v in dct.items():
409          if k.startswith('USE_'):
410            cmakeset(fd,'PETSC_' + k, v)
411      cmakeset(fd,'PETSC_USE_COMPLEX', self.scalartypes.scalartype == 'complex')
412      cmakeset(fd,'PETSC_USE_REAL_' + self.scalartypes.precision.upper())
413      cmakeset(fd,'PETSC_CLANGUAGE_'+self.languages.clanguage)
414      if hasattr(self.compilers, 'FC'):
415        cmakeset(fd,'PETSC_HAVE_FORTRAN')
416        if self.compilers.fortranIsF90:
417          cmakeset(fd,'PETSC_USING_F90')
418        if self.compilers.fortranIsF2003:
419          cmakeset(fd,'PETSC_USING_F2003')
420      if hasattr(self.compilers, 'CXX'):
421        cmakeset(fd,'PETSC_HAVE_CXX')
422      if self.sharedlibraries.useShared:
423        cmakeset(fd,'BUILD_SHARED_LIBS')
424    def writeBuildFlags(fd):
425      def extendby(lib):
426        libs = ensurelist(lib)
427        lib_paths.extend(map(libpath,libs))
428        lib_libs.extend(map(cleanlib,libs))
429      lib_paths = []
430      lib_libs  = []
431      includes  = []
432      libvars   = []
433      for pkg in self.framework.packages:
434        extendby(pkg.lib)
435        uniqextend(includes,pkg.include)
436      extendby(self.libraries.math)
437      extendby(self.libraries.rt)
438      extendby(self.compilers.flibs)
439      extendby(self.compilers.cxxlibs)
440      extendby(self.compilers.LIBS.split())
441      for libname in nublast(lib_libs):
442        libvar = 'PETSC_' + libname.upper() + '_LIB'
443        addpath = ''
444        for lpath in nublast(lib_paths):
445          addpath += '"' + str(lpath) + '" '
446        fd.write('find_library (' + libvar + ' ' + libname + ' HINTS ' + addpath + ')\n')
447        libvars.append(libvar)
448      fd.write('mark_as_advanced (' + ' '.join(libvars) + ')\n')
449      fd.write('set (PETSC_PACKAGE_LIBS ' + ' '.join(map(cmakeexpand,libvars)) + ')\n')
450      includes = filter(notstandardinclude,includes)
451      fd.write('set (PETSC_PACKAGE_INCLUDES ' + ' '.join(map(lambda i: '"'+i+'"',includes)) + ')\n')
452    fd = open(os.path.join(self.arch.arch,'conf','PETScConfig.cmake'), 'w')
453    writeMacroDefinitions(fd)
454    writeBuildFlags(fd)
455    fd.close()
456    return
457
458  def dumpCMakeLists(self):
459    import sys
460    if sys.version_info >= (2,5):
461      import cmakegen
462      try:
463        cmakegen.main(self.petscdir.dir, log=self.framework.log)
464      except (OSError), e:
465        self.framework.logPrint('Generating CMakeLists.txt failed:\n' + str(e))
466    else:
467      self.framework.logPrint('Skipping cmakegen due to old python version: ' +str(sys.version_info) )
468
469  def cmakeBoot(self):
470    import sys
471    self.cmakeboot_success = False
472    if sys.version_info >= (2,5) and hasattr(self.cmake,'cmake'):
473      try:
474        import cmakeboot
475        self.cmakeboot_success = cmakeboot.main(petscdir=self.petscdir.dir,petscarch=self.arch.arch,argDB=self.argDB,framework=self.framework,log=self.framework.log)
476      except (OSError), e:
477        self.framework.logPrint('Booting CMake in PETSC_ARCH failed:\n' + str(e))
478      except (ImportError, KeyError), e:
479        self.framework.logPrint('Importing cmakeboot failed:\n' + str(e))
480      if self.cmakeboot_success:
481        if self.framework.argDB['with-cuda']: # Our CMake build does not support CUDA at this time
482          self.framework.logPrint('CMake configured successfully, but could not be used by default because --with-cuda was used\n')
483        elif hasattr(self.compilers, 'FC') and self.compilers.fortranIsF90 and not self.setCompilers.fortranModuleOutputFlag:
484          self.framework.logPrint('CMake configured successfully, but could not be used by default because of missing fortranModuleOutputFlag\n')
485        else:
486          self.framework.logPrint('CMake configured successfully, using as default build\n')
487          self.addMakeMacro('PETSC_BUILD_USING_CMAKE',1)
488      else:
489        self.framework.logPrint('CMake configuration was unsuccessful\n')
490    else:
491      self.framework.logPrint('Skipping cmakeboot due to old python version: ' +str(sys.version_info) )
492    return
493
494  def configurePrefetch(self):
495    '''Sees if there are any prefetch functions supported'''
496    if config.setCompilers.Configure.isSolaris() or self.framework.argDB['with-ios']:
497      self.addDefine('Prefetch(a,b,c)', ' ')
498      return
499    self.pushLanguage(self.languages.clanguage)
500    if self.checkLink('#include <xmmintrin.h>', 'void *v = 0;_mm_prefetch((const char*)v,_MM_HINT_NTA);\n'):
501      # The Intel Intrinsics manual [1] specifies the prototype
502      #
503      #   void _mm_prefetch(char const *a, int sel);
504      #
505      # but other vendors seem to insist on using subtly different
506      # prototypes, including void* for the pointer, and an enum for
507      # sel.  These are both reasonable changes, but negatively impact
508      # portability.
509      #
510      # [1] http://software.intel.com/file/6373
511      self.addDefine('HAVE_XMMINTRIN_H', 1)
512      self.addDefine('Prefetch(a,b,c)', '_mm_prefetch((const char*)(a),(c))')
513      self.addDefine('PREFETCH_HINT_NTA', '_MM_HINT_NTA')
514      self.addDefine('PREFETCH_HINT_T0',  '_MM_HINT_T0')
515      self.addDefine('PREFETCH_HINT_T1',  '_MM_HINT_T1')
516      self.addDefine('PREFETCH_HINT_T2',  '_MM_HINT_T2')
517    elif self.checkLink('#include <xmmintrin.h>', 'void *v = 0;_mm_prefetch(v,_MM_HINT_NTA);\n'):
518      self.addDefine('HAVE_XMMINTRIN_H', 1)
519      self.addDefine('Prefetch(a,b,c)', '_mm_prefetch((const void*)(a),(c))')
520      self.addDefine('PREFETCH_HINT_NTA', '_MM_HINT_NTA')
521      self.addDefine('PREFETCH_HINT_T0',  '_MM_HINT_T0')
522      self.addDefine('PREFETCH_HINT_T1',  '_MM_HINT_T1')
523      self.addDefine('PREFETCH_HINT_T2',  '_MM_HINT_T2')
524    elif self.checkLink('', 'void *v = 0;__builtin_prefetch(v,0,0);\n'):
525      # From GCC docs: void __builtin_prefetch(const void *addr,int rw,int locality)
526      #
527      #   The value of rw is a compile-time constant one or zero; one
528      #   means that the prefetch is preparing for a write to the memory
529      #   address and zero, the default, means that the prefetch is
530      #   preparing for a read. The value locality must be a compile-time
531      #   constant integer between zero and three. A value of zero means
532      #   that the data has no temporal locality, so it need not be left
533      #   in the cache after the access. A value of three means that the
534      #   data has a high degree of temporal locality and should be left
535      #   in all levels of cache possible. Values of one and two mean,
536      #   respectively, a low or moderate degree of temporal locality.
537      #
538      # Here we adopt Intel's x86/x86-64 naming scheme for the locality
539      # hints.  Using macros for these values in necessary since some
540      # compilers require an enum.
541      self.addDefine('Prefetch(a,b,c)', '__builtin_prefetch((a),(b),(c))')
542      self.addDefine('PREFETCH_HINT_NTA', '0')
543      self.addDefine('PREFETCH_HINT_T0',  '3')
544      self.addDefine('PREFETCH_HINT_T1',  '2')
545      self.addDefine('PREFETCH_HINT_T2',  '1')
546    else:
547      self.addDefine('Prefetch(a,b,c)', ' ')
548    self.popLanguage()
549
550  def configureFeatureTestMacros(self):
551    '''Checks if certain feature test macros are support'''
552    if self.checkCompile('#define _POSIX_C_SOURCE 200112L\n#include <sysctl.h>',''):
553       self.addDefine('_POSIX_C_SOURCE_200112L', '1')
554    if self.checkCompile('#define _BSD_SOURCE\n#include<stdlib.h>',''):
555       self.addDefine('_BSD_SOURCE', '1')
556    if self.checkCompile('#define _GNU_SOURCE\n#include <sched.h>','cpu_set_t mset;\nCPU_ZERO(&mset);'):
557       self.addDefine('_GNU_SOURCE', '1')
558
559  def configureAtoll(self):
560    '''Checks if atoll exists'''
561    if self.checkCompile('#define _POSIX_C_SOURCE 200112L\n#include <stdlib.h>','long v = atoll("25")') or self.checkCompile ('#include <stdlib.h>','long v = atoll("25")'):
562       self.addDefine('HAVE_ATOLL', '1')
563
564  def configureUnused(self):
565    '''Sees if __attribute((unused)) is supported'''
566    if self.framework.argDB['with-ios'] or self.framework.argDB['with-cuda']:
567      self.addDefine('UNUSED', ' ')
568      return
569    self.pushLanguage(self.languages.clanguage)
570    if self.checkLink('__attribute((unused)) static int myfunc(void){ return 1;}', 'int i = myfunc();\ntypedef void* atype;\n__attribute((unused))  atype a;\n'):
571      self.addDefine('UNUSED', '__attribute((unused))')
572    else:
573      self.addDefine('UNUSED', ' ')
574    self.popLanguage()
575
576  def configureExpect(self):
577    '''Sees if the __builtin_expect directive is supported'''
578    self.pushLanguage(self.languages.clanguage)
579    if self.checkLink('', 'if (__builtin_expect(0,1)) return 1;'):
580      self.addDefine('HAVE_BUILTIN_EXPECT', 1)
581    self.popLanguage()
582
583  def configureFunctionName(self):
584    '''Sees if the compiler supports __func__ or a variant.  Falls back
585    on __FUNCT__ which PETSc source defines, but most users do not, thus
586    stack traces through user code are better when the compiler's
587    variant is used.'''
588    def getFunctionName(lang):
589      name = '__FUNCT__'
590      self.pushLanguage(lang)
591      if self.checkLink('', "if (__func__[0] != 'm') return 1;"):
592        name = '__func__'
593      elif self.checkLink('', "if (__FUNCTION__[0] != 'm') return 1;"):
594        name = '__FUNCTION__'
595      self.popLanguage()
596      return name
597    langs = []
598
599    self.addDefine('FUNCTION_NAME_C', getFunctionName('C'))
600    if hasattr(self.compilers, 'CXX'):
601      self.addDefine('FUNCTION_NAME_CXX', getFunctionName('Cxx'))
602    else:
603      self.addDefine('FUNCTION_NAME_CXX', '__FUNCT__')
604
605  def configureIntptrt(self):
606    '''Determine what to use for uintptr_t'''
607    def staticAssertSizeMatchesVoidStar(inc,typename):
608      # The declaration is an error if either array size is negative.
609      # It should be okay to use an int that is too large, but it would be very unlikely for this to be the case
610      return self.checkCompile(inc, ('#define STATIC_ASSERT(cond) char negative_length_if_false[2*(!!(cond))-1]\n'
611                                     + 'STATIC_ASSERT(sizeof(void*) == sizeof(%s));'%typename))
612    self.pushLanguage(self.languages.clanguage)
613    if self.checkCompile('#include <stdint.h>', 'int x; uintptr_t i = (uintptr_t)&x;'):
614      self.addDefine('UINTPTR_T', 'uintptr_t')
615    elif staticAssertSizeMatchesVoidStar('','unsigned long long'):
616      self.addDefine('UINTPTR_T', 'unsigned long long')
617    elif staticAssertSizeMatchesVoidStar('#include <stdlib.h>','size_t') or staticAssertSizeMatchesVoidStar('#include <string.h>', 'size_t'):
618      self.addDefine('UINTPTR_T', 'size_t')
619    elif staticAssertSizeMatchesVoidStar('','unsigned long'):
620      self.addDefine('UINTPTR_T', 'unsigned long')
621    elif staticAssertSizeMatchesVoidStar('','unsigned'):
622      self.addDefine('UINTPTR_T', 'unsigned')
623    else:
624      raise RuntimeError('Could not find any unsigned integer type matching void*')
625    self.popLanguage()
626
627  def configureInline(self):
628    '''Get a generic inline keyword, depending on the language'''
629    if self.languages.clanguage == 'C':
630      self.addDefine('STATIC_INLINE', self.compilers.cStaticInlineKeyword)
631      self.addDefine('RESTRICT', self.compilers.cRestrict)
632    elif self.languages.clanguage == 'Cxx':
633      self.addDefine('STATIC_INLINE', self.compilers.cxxStaticInlineKeyword)
634      self.addDefine('RESTRICT', self.compilers.cxxRestrict)
635
636    if self.checkCompile('#include <dlfcn.h>\n void *ptr =  RTLD_DEFAULT;'):
637      self.addDefine('RTLD_DEFAULT','1')
638    return
639
640  def configureSolaris(self):
641    '''Solaris specific stuff'''
642    if os.path.isdir(os.path.join('/usr','ucblib')):
643      try:
644        flag = getattr(self.setCompilers, self.language[-1]+'SharedLinkerFlag')
645      except AttributeError:
646        flag = None
647      if flag is None:
648        self.compilers.LIBS += ' -L/usr/ucblib'
649      else:
650        self.compilers.LIBS += ' '+flag+'/usr/ucblib'
651    return
652
653  def configureLinux(self):
654    '''Linux specific stuff'''
655    # TODO: Test for this by mallocing an odd number of floats and checking the address
656    self.addDefine('HAVE_DOUBLE_ALIGN_MALLOC', 1)
657    return
658
659  def configureWin32(self):
660    '''Win32 non-cygwin specific stuff'''
661    kernel32=0
662    if self.libraries.add('Kernel32.lib','GetComputerName',prototype='#include <Windows.h>', call='GetComputerName(NULL,NULL);'):
663      self.addDefine('HAVE_WINDOWS_H',1)
664      self.addDefine('HAVE_GETCOMPUTERNAME',1)
665      kernel32=1
666    elif self.libraries.add('kernel32','GetComputerName',prototype='#include <Windows.h>', call='GetComputerName(NULL,NULL);'):
667      self.addDefine('HAVE_WINDOWS_H',1)
668      self.addDefine('HAVE_GETCOMPUTERNAME',1)
669      kernel32=1
670    if kernel32:
671      if self.framework.argDB['with-windows-graphics']:
672        self.addDefine('USE_WINDOWS_GRAPHICS',1)
673      if self.checkLink('#include <Windows.h>','LoadLibrary(0)'):
674        self.addDefine('HAVE_LOADLIBRARY',1)
675      if self.checkLink('#include <Windows.h>','GetProcAddress(0,0)'):
676        self.addDefine('HAVE_GETPROCADDRESS',1)
677      if self.checkLink('#include <Windows.h>','FreeLibrary(0)'):
678        self.addDefine('HAVE_FREELIBRARY',1)
679      if self.checkLink('#include <Windows.h>','GetLastError()'):
680        self.addDefine('HAVE_GETLASTERROR',1)
681      if self.checkLink('#include <Windows.h>','SetLastError(0)'):
682        self.addDefine('HAVE_SETLASTERROR',1)
683      if self.checkLink('#include <Windows.h>\n','QueryPerformanceCounter(0);\n'):
684        self.addDefine('USE_NT_TIME',1)
685    if self.libraries.add('Advapi32.lib','GetUserName',prototype='#include <Windows.h>', call='GetUserName(NULL,NULL);'):
686      self.addDefine('HAVE_GET_USER_NAME',1)
687    elif self.libraries.add('advapi32','GetUserName',prototype='#include <Windows.h>', call='GetUserName(NULL,NULL);'):
688      self.addDefine('HAVE_GET_USER_NAME',1)
689
690    if not self.libraries.add('User32.lib','GetDC',prototype='#include <Windows.h>',call='GetDC(0);'):
691      self.libraries.add('user32','GetDC',prototype='#include <Windows.h>',call='GetDC(0);')
692    if not self.libraries.add('Gdi32.lib','CreateCompatibleDC',prototype='#include <Windows.h>',call='CreateCompatibleDC(0);'):
693      self.libraries.add('gdi32','CreateCompatibleDC',prototype='#include <Windows.h>',call='CreateCompatibleDC(0);')
694
695    self.types.check('int32_t', 'int')
696    if not self.checkCompile('#include <sys/types.h>\n','uid_t u;\n'):
697      self.addTypedef('int', 'uid_t')
698      self.addTypedef('int', 'gid_t')
699    if not self.checkLink('#if defined(PETSC_HAVE_UNISTD_H)\n#include <unistd.h>\n#endif\n','int a=R_OK;\n'):
700      self.framework.addDefine('R_OK', '04')
701      self.framework.addDefine('W_OK', '02')
702      self.framework.addDefine('X_OK', '01')
703    if not self.checkLink('#include <sys/stat.h>\n','int a=0;\nif (S_ISDIR(a)){}\n'):
704      self.framework.addDefine('S_ISREG(a)', '(((a)&_S_IFMT) == _S_IFREG)')
705      self.framework.addDefine('S_ISDIR(a)', '(((a)&_S_IFMT) == _S_IFDIR)')
706    if self.checkCompile('#include <Windows.h>\n','LARGE_INTEGER a;\nDWORD b=a.u.HighPart;\n'):
707      self.addDefine('HAVE_LARGE_INTEGER_U',1)
708
709    # Windows requires a Binary file creation flag when creating/opening binary files.  Is a better test in order?
710    if self.checkCompile('#include <Windows.h>\n#include <fcntl.h>\n', 'int flags = O_BINARY;'):
711      self.addDefine('HAVE_O_BINARY',1)
712
713    if self.compilers.CC.find('win32fe') >= 0:
714      self.addDefine('PATH_SEPARATOR','\';\'')
715      self.addDefine('DIR_SEPARATOR','\'\\\\\'')
716      self.addDefine('REPLACE_DIR_SEPARATOR','\'/\'')
717      self.addDefine('CANNOT_START_DEBUGGER',1)
718    else:
719      self.addDefine('PATH_SEPARATOR','\':\'')
720      self.addDefine('REPLACE_DIR_SEPARATOR','\'\\\\\'')
721      self.addDefine('DIR_SEPARATOR','\'/\'')
722
723    return
724
725#-----------------------------------------------------------------------------------------------------
726  def configureDefaultArch(self):
727    conffile = os.path.join('conf', 'petscvariables')
728    if self.framework.argDB['with-default-arch']:
729      fd = file(conffile, 'w')
730      fd.write('PETSC_ARCH='+self.arch.arch+'\n')
731      fd.write('PETSC_DIR='+self.petscdir.dir+'\n')
732      fd.write('include '+os.path.join(self.petscdir.dir,self.arch.arch,'conf','petscvariables')+'\n')
733      fd.close()
734      self.framework.actions.addArgument('PETSc', 'Build', 'Set default architecture to '+self.arch.arch+' in '+conffile)
735    elif os.path.isfile(conffile):
736      try:
737        os.unlink(conffile)
738      except:
739        raise RuntimeError('Unable to remove file '+conffile+'. Did a different user create it?')
740    return
741
742#-----------------------------------------------------------------------------------------------------
743  def configureScript(self):
744    '''Output a script in the conf directory which will reproduce the configuration'''
745    import nargs
746    import sys
747    scriptName = os.path.join(self.arch.arch,'conf', 'reconfigure-'+self.arch.arch+'.py')
748    args = dict([(nargs.Arg.parseArgument(arg)[0], arg) for arg in self.framework.clArgs])
749    if 'configModules' in args:
750      if nargs.Arg.parseArgument(args['configModules'])[1] == 'PETSc.Configure':
751        del args['configModules']
752    if 'optionsModule' in args:
753      if nargs.Arg.parseArgument(args['optionsModule'])[1] == 'PETSc.compilerOptions':
754        del args['optionsModule']
755    if not 'PETSC_ARCH' in args:
756      args['PETSC_ARCH'] = 'PETSC_ARCH='+str(self.arch.arch)
757    f = file(scriptName, 'w')
758    f.write('#!'+sys.executable+'\n')
759    f.write('if __name__ == \'__main__\':\n')
760    f.write('  import sys\n')
761    f.write('  import os\n')
762    f.write('  sys.path.insert(0, os.path.abspath(\'config\'))\n')
763    f.write('  import configure\n')
764    # pretty print repr(args.values())
765    f.write('  configure_options = [\n')
766    for itm in sorted(args.values()):
767      f.write('    \''+str(itm)+'\',\n')
768    f.write('  ]\n')
769    f.write('  configure.petsc_configure(configure_options)\n')
770    f.close()
771    try:
772      os.chmod(scriptName, 0775)
773    except OSError, e:
774      self.framework.logPrint('Unable to make reconfigure script executable:\n'+str(e))
775    self.framework.actions.addArgument('PETSc', 'File creation', 'Created '+scriptName+' for automatic reconfiguration')
776    return
777
778  def configureInstall(self):
779    '''Setup the directories for installation'''
780    if self.framework.argDB['prefix']:
781      self.installdir = self.framework.argDB['prefix']
782      self.addMakeRule('shared_install','',['-@echo "Now to install the libraries do:"',\
783                                              '-@echo "make PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} install"',\
784                                              '-@echo "========================================="'])
785    else:
786      self.installdir = os.path.join(self.petscdir.dir,self.arch.arch)
787      self.addMakeRule('shared_install','',['-@echo "Now to check if the libraries are working do:"',\
788                                              '-@echo "make PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} test"',\
789                                              '-@echo "========================================="'])
790      return
791
792  def configureGCOV(self):
793    if self.framework.argDB['with-gcov']:
794      self.addDefine('USE_GCOV','1')
795    return
796
797  def configureFortranFlush(self):
798    if hasattr(self.compilers, 'FC'):
799      for baseName in ['flush','flush_']:
800        if self.libraries.check('', baseName, otherLibs = self.compilers.flibs, fortranMangle = 1):
801          self.addDefine('HAVE_'+baseName.upper(), 1)
802          return
803
804  def postProcessPackages(self):
805    postPackages=[]
806    for i in self.framework.packages:
807      if hasattr(i,'postProcess'): postPackages.append(i)
808    if postPackages:
809      # prometheus needs petsc conf files. so attempt to create them early
810      self.framework.dumpConfFiles()
811      for i in postPackages: i.postProcess()
812    return
813
814  def configure(self):
815    if not os.path.samefile(self.petscdir.dir, os.getcwd()):
816      raise RuntimeError('Wrong PETSC_DIR option specified: '+str(self.petscdir.dir) + '\n  Configure invoked in: '+os.path.realpath(os.getcwd()))
817    if self.framework.argDB['prefix'] and os.path.isdir(self.framework.argDB['prefix']) and os.path.samefile(self.framework.argDB['prefix'],self.petscdir.dir):
818      raise RuntimeError('Incorrect option --prefix='+self.framework.argDB['prefix']+' specified. It cannot be same as PETSC_DIR!')
819    if self.framework.argDB['prefix'] and os.path.isdir(self.framework.argDB['prefix']) and os.path.samefile(self.framework.argDB['prefix'],os.path.join(self.petscdir.dir,self.arch.arch)):
820      raise RuntimeError('Incorrect option --prefix='+self.framework.argDB['prefix']+' specified. It cannot be same as PETSC_DIR/PETSC_ARCH!')
821    self.framework.header          = os.path.join(self.arch.arch,'include','petscconf.h')
822    self.framework.cHeader         = os.path.join(self.arch.arch,'include','petscfix.h')
823    self.framework.makeMacroHeader = os.path.join(self.arch.arch,'conf','petscvariables')
824    self.framework.makeRuleHeader  = os.path.join(self.arch.arch,'conf','petscrules')
825    if self.libraries.math is None:
826      raise RuntimeError('PETSc requires a functional math library. Please send configure.log to petsc-maint@mcs.anl.gov.')
827    if self.languages.clanguage == 'Cxx' and not hasattr(self.compilers, 'CXX'):
828      raise RuntimeError('Cannot set C language to C++ without a functional C++ compiler.')
829    self.executeTest(self.configureInline)
830    self.executeTest(self.configurePrefetch)
831    self.executeTest(self.configureUnused)
832    self.executeTest(self.configureExpect);
833    self.executeTest(self.configureFunctionName);
834    self.executeTest(self.configureIntptrt);
835    self.executeTest(self.configureSolaris)
836    self.executeTest(self.configureLinux)
837    self.executeTest(self.configureWin32)
838    self.executeTest(self.configureDefaultArch)
839    self.executeTest(self.configureScript)
840    self.executeTest(self.configureInstall)
841    self.executeTest(self.configureGCOV)
842    self.executeTest(self.configureFortranFlush)
843    self.executeTest(self.configureFeatureTestMacros)
844    self.executeTest(self.configureAtoll)
845    # dummy rules, always needed except for remote builds
846    self.addMakeRule('remote','')
847    self.addMakeRule('remoteclean','')
848
849    self.Dump()
850    self.dumpConfigInfo()
851    self.dumpMachineInfo()
852    self.postProcessPackages()
853    self.dumpCMakeConfig()
854    self.dumpCMakeLists()
855    self.cmakeBoot()
856    self.framework.log.write('================================================================================\n')
857    self.logClear()
858    return
859