xref: /petsc/config/PETSc/Configure.py (revision 5b0d26cfbf6ed9982f633be5fbebf5c618cfd10c)
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-iphone=<bool>',              nargs.ArgBool(None, 0, 'Build an iPhone version of PETSc'))
41    help.addArgument('CTetgen', '-with-ctetgen=<bool>',           nargs.ArgBool(None, 0, 'Enable CTetgen support'))
42    return
43
44  def setupDependencies(self, framework):
45    config.base.Configure.setupDependencies(self, framework)
46    self.setCompilers  = framework.require('config.setCompilers',      self)
47    self.arch          = framework.require('PETSc.utilities.arch',     self.setCompilers)
48    self.petscdir      = framework.require('PETSc.utilities.petscdir', self.setCompilers)
49    self.languages     = framework.require('PETSc.utilities.languages',self.setCompilers)
50    self.debugging     = framework.require('PETSc.utilities.debugging',self.setCompilers)
51    self.CHUD          = framework.require('PETSc.utilities.CHUD',     self)
52    self.compilers     = framework.require('config.compilers',         self)
53    self.types         = framework.require('config.types',             self)
54    self.headers       = framework.require('config.headers',           self)
55    self.functions     = framework.require('config.functions',         self)
56    self.libraries     = framework.require('config.libraries',         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', ['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    if self.framework.argDB['with-ctetgen']:
223      self.addDefine('HAVE_CTETGEN', 1)
224    self.framework.packages.reverse()
225    includes = [os.path.join(self.petscdir.dir,'include'),os.path.join(self.petscdir.dir,self.arch.arch,'include')]
226    libs = []
227    for i in self.framework.packages:
228      if i.useddirectly:
229        self.addDefine('HAVE_'+i.PACKAGE, 1)  # ONLY list package if it is used directly by PETSc (and not only by another package)
230      if not isinstance(i.lib, list):
231        i.lib = [i.lib]
232      libs.extend(i.lib)
233      self.addMakeMacro(i.PACKAGE+'_LIB', self.libraries.toStringNoDupes(i.lib))
234      if hasattr(i,'include'):
235        if not isinstance(i.include,list):
236          i.include = [i.include]
237        if not i.PACKAGE.lower() == 'valgrind':
238          includes.extend(i.include)
239        self.addMakeMacro(i.PACKAGE+'_INCLUDE',self.headers.toStringNoDupes(i.include))
240    if self.framework.argDB['with-single-library']:
241      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)
242    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)
243    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
244    self.addMakeMacro('PETSC_CC_INCLUDES',self.headers.toStringNoDupes(includes))
245    self.PETSC_CC_INCLUDES = self.headers.toStringNoDupes(includes)
246    if hasattr(self.compilers, 'FC'):
247      if self.compilers.fortranIsF90:
248        self.addMakeMacro('PETSC_FC_INCLUDES',self.headers.toStringNoDupes(includes,includes))
249      else:
250        self.addMakeMacro('PETSC_FC_INCLUDES',self.headers.toStringNoDupes(includes))
251
252    self.addMakeMacro('DESTDIR',self.installdir)
253    self.addDefine('LIB_DIR','"'+os.path.join(self.installdir,'lib')+'"')
254
255    if self.framework.argDB['with-single-library']:
256      # overrides the values set in conf/variables
257      self.addMakeMacro('LIBNAME','${INSTALL_LIB_DIR}/libpetsc.${AR_LIB_SUFFIX}')
258      self.addMakeMacro('SHLIBS','libpetsc')
259      self.addMakeMacro('PETSC_LIB_BASIC','-lpetsc')
260      self.addMakeMacro('PETSC_KSP_LIB_BASIC','-lpetsc')
261      self.addMakeMacro('PETSC_TS_LIB_BASIC','-lpetsc')
262      self.addDefine('USE_SINGLE_LIBRARY', '1')
263      if self.sharedlibraries.useShared:
264        self.addMakeMacro('PETSC_SYS_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
265        self.addMakeMacro('PETSC_VEC_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
266        self.addMakeMacro('PETSC_MAT_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
267        self.addMakeMacro('PETSC_DM_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
268        self.addMakeMacro('PETSC_KSP_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
269        self.addMakeMacro('PETSC_SNES_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
270        self.addMakeMacro('PETSC_TS_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
271        self.addMakeMacro('PETSC_CHARACTERISTIC_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
272        self.addMakeMacro('PETSC_LIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
273        self.addMakeMacro('PETSC_CONTRIB','${C_SH_LIB_PATH} ${PETSC_WITH_EXTERNAL_LIB}')
274      else:
275        self.addMakeMacro('PETSC_SYS_LIB','${PETSC_WITH_EXTERNAL_LIB}')
276        self.addMakeMacro('PETSC_VEC_LIB','${PETSC_WITH_EXTERNAL_LIB}')
277        self.addMakeMacro('PETSC_MAT_LIB','${PETSC_WITH_EXTERNAL_LIB}')
278        self.addMakeMacro('PETSC_DM_LIB','${PETSC_WITH_EXTERNAL_LIB}')
279        self.addMakeMacro('PETSC_KSP_LIB','${PETSC_WITH_EXTERNAL_LIB}')
280        self.addMakeMacro('PETSC_SNES_LIB','${PETSC_WITH_EXTERNAL_LIB}')
281        self.addMakeMacro('PETSC_TS_LIB','${PETSC_WITH_EXTERNAL_LIB}')
282        self.addMakeMacro('PETSC_CHARACTERISTIC_LIB','${PETSC_WITH_EXTERNAL_LIB}')
283        self.addMakeMacro('PETSC_LIB','${PETSC_WITH_EXTERNAL_LIB}')
284        self.addMakeMacro('PETSC_CONTRIB','${PETSC_WITH_EXTERNAL_LIB}')
285
286    if not os.path.exists(os.path.join(self.petscdir.dir,self.arch.arch,'lib')):
287      os.makedirs(os.path.join(self.petscdir.dir,self.arch.arch,'lib'))
288
289    # add a makefile entry for configure options
290    self.addMakeMacro('CONFIGURE_OPTIONS', self.framework.getOptionsString(['configModules', 'optionsModule']).replace('\"','\\"'))
291    return
292
293  def dumpConfigInfo(self):
294    import time
295    fd = file(os.path.join(self.arch.arch,'include','petscconfiginfo.h'),'w')
296    fd.write('static const char *petscconfigureruntime = "'+time.ctime(time.time())+'";\n')
297    fd.write('static const char *petscconfigureoptions = "'+self.framework.getOptionsString(['configModules', 'optionsModule']).replace('\"','\\"')+'";\n')
298    fd.close()
299    return
300
301  def dumpMachineInfo(self):
302    import platform
303    import time
304    import script
305    fd = file(os.path.join(self.arch.arch,'include','petscmachineinfo.h'),'w')
306    fd.write('static const char *petscmachineinfo = \"\\n\"\n')
307    fd.write('\"-----------------------------------------\\n\"\n')
308    fd.write('\"Libraries compiled on %s on %s \\n\"\n' % (time.ctime(time.time()), platform.node()))
309    fd.write('\"Machine characteristics: %s\\n\"\n' % (platform.platform()))
310    fd.write('\"Using PETSc directory: %s\\n\"\n' % (self.petscdir.dir))
311    fd.write('\"Using PETSc arch: %s\\n\"\n' % (self.arch.arch))
312    fd.write('\"-----------------------------------------\\n\";\n')
313    fd.write('static const char *petsccompilerinfo = \"\\n\"\n')
314    self.setCompilers.pushLanguage(self.languages.clanguage)
315    fd.write('\"Using C compiler: %s %s ${COPTFLAGS} ${CFLAGS}\\n\"\n' % (self.setCompilers.getCompiler(), self.setCompilers.getCompilerFlags()))
316    self.setCompilers.popLanguage()
317    if hasattr(self.compilers, 'FC'):
318      self.setCompilers.pushLanguage('FC')
319      fd.write('\"Using Fortran compiler: %s %s ${FOPTFLAGS} ${FFLAGS} %s\\n\"\n' % (self.setCompilers.getCompiler(), self.setCompilers.getCompilerFlags(), self.setCompilers.CPPFLAGS))
320      self.setCompilers.popLanguage()
321    fd.write('\"-----------------------------------------\\n\";\n')
322    fd.write('static const char *petsccompilerflagsinfo = \"\\n\"\n')
323    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('\\ ','\\\\ ')))
324    fd.write('\"-----------------------------------------\\n\";\n')
325    fd.write('static const char *petsclinkerinfo = \"\\n\"\n')
326    self.setCompilers.pushLanguage(self.languages.clanguage)
327    fd.write('\"Using C linker: %s\\n\"\n' % (self.setCompilers.getLinker()))
328    self.setCompilers.popLanguage()
329    if hasattr(self.compilers, 'FC'):
330      self.setCompilers.pushLanguage('FC')
331      fd.write('\"Using Fortran linker: %s\\n\"\n' % (self.setCompilers.getLinker()))
332      self.setCompilers.popLanguage()
333    if self.framework.argDB['with-single-library']:
334      petsclib = '-lpetsc'
335    else:
336      petsclib = '-lpetscts -lpetscsnes -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetscsys'
337    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('\\ ','\\\\ ')))
338    fd.write('\"-----------------------------------------\\n\";\n')
339    fd.close()
340    return
341
342  def dumpCMakeConfig(self):
343    '''
344    Writes configuration-specific values to ${PETSC_ARCH}/conf/PETScConfig.cmake.
345    This file is private to PETSc and should not be included by third parties
346    (a suitable file can be produced later by CMake, but this is not it).
347    '''
348    def cmakeset(fd,key,val=True):
349      if val == True: val = 'YES'
350      if val == False: val = 'NO'
351      fd.write('set (' + key + ' ' + val + ')\n')
352    def ensurelist(a):
353      if isinstance(a,list):
354        return a
355      else:
356        return [a]
357    def libpath(lib):
358      'Returns a search path if that is what this item provides, else "" which will be cleaned out later'
359      if not isinstance(lib,str): return ''
360      if lib.startswith('-L'): return lib[2:]
361      if lib.startswith('-R'): return lib[2:]
362      if lib.startswith('-Wl,-rpath,'):
363        # This case occurs when an external package needs a specific system library that is normally provided by the compiler.
364        # In other words, the -L path is builtin to the wrapper or compiler, here we provide it so that CMake can locate the
365        # corresponding library.
366        return lib[len('-Wl,-rpath,'):]
367      if lib.startswith('-'): return ''
368      return os.path.dirname(lib)
369    def cleanlib(lib):
370      'Returns a library name if that is what this item provides, else "" which will be cleaned out later'
371      if not isinstance(lib,str): return ''
372      if lib.startswith('-l'):  return lib[2:]
373      if lib.startswith('-Wl') or lib.startswith('-L'): return ''
374      lib = os.path.splitext(os.path.basename(lib))[0]
375      if lib.startswith('lib'): return lib[3:]
376      return lib
377    def nub(lst):
378      'Return a list containing the first occurrence of each unique element'
379      unique = []
380      for elem in lst:
381        if elem not in unique and elem != '':
382          unique.append(elem)
383      return unique
384    try: reversed # reversed was added in Python-2.4
385    except NameError:
386      def reversed(lst): return lst[::-1]
387    def nublast(lst):
388      'Return a list containing the last occurrence of each unique entry in a list'
389      return reversed(nub(reversed(lst)))
390    def cmakeexpand(varname):
391      return r'"${' + varname + r'}"'
392    def uniqextend(lst,new):
393      for x in ensurelist(new):
394        if x not in lst:
395          lst.append(x)
396    def notstandardinclude(path):
397      return path not in '/usr/include'.split() # /usr/local/include is not automatically included on FreeBSD
398    def writeMacroDefinitions(fd):
399      if self.mpi.usingMPIUni:
400        cmakeset(fd,'PETSC_HAVE_MPIUNI')
401      for pkg in self.framework.packages:
402        if pkg.useddirectly:
403          cmakeset(fd,'PETSC_HAVE_' + pkg.PACKAGE)
404        for pair in pkg.defines.items():
405          if pair[0].startswith('HAVE_') and pair[1]:
406            cmakeset(fd, self.framework.getFullDefineName(pkg, pair[0]), pair[1])
407      for name,val in self.functions.defines.items():
408        cmakeset(fd,'PETSC_'+name,val)
409      for dct in [self.defines, self.libraryoptions.defines]:
410        for k,v in dct.items():
411          if k.startswith('USE_'):
412            cmakeset(fd,'PETSC_' + k, v)
413      cmakeset(fd,'PETSC_USE_COMPLEX', self.scalartypes.scalartype == 'complex')
414      cmakeset(fd,'PETSC_USE_REAL_' + self.scalartypes.precision.upper())
415      cmakeset(fd,'PETSC_CLANGUAGE_'+self.languages.clanguage)
416      if hasattr(self.compilers, 'FC'):
417        cmakeset(fd,'PETSC_HAVE_FORTRAN')
418        if self.compilers.fortranIsF90:
419          cmakeset(fd,'PETSC_USING_F90')
420      if self.sharedlibraries.useShared:
421        cmakeset(fd,'BUILD_SHARED_LIBS')
422    def writeBuildFlags(fd):
423      def extendby(lib):
424        libs = ensurelist(lib)
425        lib_paths.extend(map(libpath,libs))
426        lib_libs.extend(map(cleanlib,libs))
427      lib_paths = []
428      lib_libs  = []
429      includes  = []
430      libvars   = []
431      for pkg in self.framework.packages:
432        extendby(pkg.lib)
433        uniqextend(includes,pkg.include)
434      extendby(self.libraries.math)
435      extendby(self.libraries.rt)
436      extendby(self.compilers.flibs)
437      extendby(self.compilers.cxxlibs)
438      extendby(self.compilers.LIBS.split())
439      for libname in nublast(lib_libs):
440        libvar = 'PETSC_' + libname.upper() + '_LIB'
441        addpath = ''
442        for lpath in nublast(lib_paths):
443          addpath += '"' + str(lpath) + '" '
444        fd.write('find_library (' + libvar + ' ' + libname + ' HINTS ' + addpath + ')\n')
445        libvars.append(libvar)
446      fd.write('mark_as_advanced (' + ' '.join(libvars) + ')\n')
447      fd.write('set (PETSC_PACKAGE_LIBS ' + ' '.join(map(cmakeexpand,libvars)) + ')\n')
448      includes = filter(notstandardinclude,includes)
449      fd.write('set (PETSC_PACKAGE_INCLUDES ' + ' '.join(map(lambda i: '"'+i+'"',includes)) + ')\n')
450    fd = open(os.path.join(self.arch.arch,'conf','PETScConfig.cmake'), 'w')
451    writeMacroDefinitions(fd)
452    writeBuildFlags(fd)
453    fd.close()
454    return
455
456  def dumpCMakeLists(self):
457    import sys
458    if sys.version_info >= (2,5):
459      import cmakegen
460      try:
461        cmakegen.main(self.petscdir.dir, log=self.framework.log)
462      except (OSError), e:
463        self.framework.logPrint('Generating CMakeLists.txt failed:\n' + str(e))
464    else:
465      self.framework.logPrint('Skipping cmakegen due to old python version: ' +str(sys.version_info) )
466
467  def cmakeBoot(self):
468    import sys
469    self.cmakeboot_success = False
470    if sys.version_info >= (2,5) and hasattr(self.cmake,'cmake'):
471      try:
472        import cmakeboot
473        self.cmakeboot_success = cmakeboot.main(petscdir=self.petscdir.dir,petscarch=self.arch.arch,argDB=self.argDB,framework=self.framework,log=self.framework.log)
474      except (OSError), e:
475        self.framework.logPrint('Booting CMake in PETSC_ARCH failed:\n' + str(e))
476      except (ImportError, KeyError), e:
477        self.framework.logPrint('Importing cmakeboot failed:\n' + str(e))
478      if self.cmakeboot_success:
479        if self.framework.argDB['with-cuda']: # Our CMake build does not support CUDA at this time
480          self.framework.logPrint('CMake configured successfully, but could not be used by default because --with-cuda was used\n')
481        elif hasattr(self.compilers, 'FC') and not self.setCompilers.fortranModuleOutputFlag:
482          self.framework.logPrint('CMake configured successfully, but could not be used by default because of missing fortranModuleOutputFlag\n')
483        else:
484          self.framework.logPrint('CMake configured successfully, using as default build\n')
485          self.addMakeMacro('PETSC_BUILD_USING_CMAKE',1)
486      else:
487        self.framework.logPrint('CMake configuration was unsuccessful\n')
488    else:
489      self.framework.logPrint('Skipping cmakeboot due to old python version: ' +str(sys.version_info) )
490    return
491
492  def configurePrefetch(self):
493    '''Sees if there are any prefetch functions supported'''
494    if config.setCompilers.Configure.isSolaris() or self.framework.argDB['with-iphone']:
495      self.addDefine('Prefetch(a,b,c)', ' ')
496      return
497    self.pushLanguage(self.languages.clanguage)
498    if self.checkLink('#include <xmmintrin.h>', 'void *v = 0;_mm_prefetch((const char*)v,_MM_HINT_NTA);\n'):
499      # The Intel Intrinsics manual [1] specifies the prototype
500      #
501      #   void _mm_prefetch(char const *a, int sel);
502      #
503      # but other vendors seem to insist on using subtly different
504      # prototypes, including void* for the pointer, and an enum for
505      # sel.  These are both reasonable changes, but negatively impact
506      # portability.
507      #
508      # [1] http://software.intel.com/file/6373
509      self.addDefine('HAVE_XMMINTRIN_H', 1)
510      self.addDefine('Prefetch(a,b,c)', '_mm_prefetch((const char*)(a),(c))')
511      self.addDefine('PREFETCH_HINT_NTA', '_MM_HINT_NTA')
512      self.addDefine('PREFETCH_HINT_T0',  '_MM_HINT_T0')
513      self.addDefine('PREFETCH_HINT_T1',  '_MM_HINT_T1')
514      self.addDefine('PREFETCH_HINT_T2',  '_MM_HINT_T2')
515    elif self.checkLink('#include <xmmintrin.h>', 'void *v = 0;_mm_prefetch(v,_MM_HINT_NTA);\n'):
516      self.addDefine('HAVE_XMMINTRIN_H', 1)
517      self.addDefine('Prefetch(a,b,c)', '_mm_prefetch((const void*)(a),(c))')
518      self.addDefine('PREFETCH_HINT_NTA', '_MM_HINT_NTA')
519      self.addDefine('PREFETCH_HINT_T0',  '_MM_HINT_T0')
520      self.addDefine('PREFETCH_HINT_T1',  '_MM_HINT_T1')
521      self.addDefine('PREFETCH_HINT_T2',  '_MM_HINT_T2')
522    elif self.checkLink('', 'void *v = 0;__builtin_prefetch(v,0,0);\n'):
523      # From GCC docs: void __builtin_prefetch(const void *addr,int rw,int locality)
524      #
525      #   The value of rw is a compile-time constant one or zero; one
526      #   means that the prefetch is preparing for a write to the memory
527      #   address and zero, the default, means that the prefetch is
528      #   preparing for a read. The value locality must be a compile-time
529      #   constant integer between zero and three. A value of zero means
530      #   that the data has no temporal locality, so it need not be left
531      #   in the cache after the access. A value of three means that the
532      #   data has a high degree of temporal locality and should be left
533      #   in all levels of cache possible. Values of one and two mean,
534      #   respectively, a low or moderate degree of temporal locality.
535      #
536      # Here we adopt Intel's x86/x86-64 naming scheme for the locality
537      # hints.  Using macros for these values in necessary since some
538      # compilers require an enum.
539      self.addDefine('Prefetch(a,b,c)', '__builtin_prefetch((a),(b),(c))')
540      self.addDefine('PREFETCH_HINT_NTA', '0')
541      self.addDefine('PREFETCH_HINT_T0',  '3')
542      self.addDefine('PREFETCH_HINT_T1',  '2')
543      self.addDefine('PREFETCH_HINT_T2',  '1')
544    else:
545      self.addDefine('Prefetch(a,b,c)', ' ')
546    self.popLanguage()
547
548  def configureFeatureTestMacros(self):
549    '''Checks if certain feature test macros are support'''
550    if self.checkCompile('#define _POSIX_C_SOURCE 200112L\n#include <stdlib.h>',''):
551       self.addDefine('_POSIX_C_SOURCE_200112L', '1')
552    if self.checkCompile('#define _BSD_SOURCE\n#include<stdlib.h>',''):
553       self.addDefine('_BSD_SOURCE', '1')
554    if self.checkCompile('#define _GNU_SOURCE\n#include <sched.h>','cpu_set_t mset;\nCPU_ZERO(&mset);'):
555       self.addDefine('_GNU_SOURCE', '1')
556
557  def configureAtoll(self):
558    '''Checks if atoll exists'''
559    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")'):
560       self.addDefine('HAVE_ATOLL', '1')
561
562  def configureUnused(self):
563    '''Sees if __attribute((unused)) is supported'''
564    if self.framework.argDB['with-iphone'] or self.framework.argDB['with-cuda']:
565      self.addDefine('UNUSED', ' ')
566      return
567    self.pushLanguage(self.languages.clanguage)
568    if self.checkLink('__attribute((unused)) static int myfunc(void){ return 1;}', 'int i = myfunc();\ntypedef void* atype;\n__attribute((unused))  atype a;\n'):
569      self.addDefine('UNUSED', '__attribute((unused))')
570    else:
571      self.addDefine('UNUSED', ' ')
572    self.popLanguage()
573
574  def configureExpect(self):
575    '''Sees if the __builtin_expect directive is supported'''
576    self.pushLanguage(self.languages.clanguage)
577    if self.checkLink('', 'if (__builtin_expect(0,1)) return 1;'):
578      self.addDefine('HAVE_BUILTIN_EXPECT', 1)
579    self.popLanguage()
580
581  def configureFunctionName(self):
582    '''Sees if the compiler supports __func__ or a variant.  Falls back
583    on __FUNCT__ which PETSc source defines, but most users do not, thus
584    stack traces through user code are better when the compiler's
585    variant is used.'''
586    def getFunctionName(lang):
587      name = '__FUNCT__'
588      self.pushLanguage(lang)
589      if self.checkLink('', "if (__func__[0] != 'm') return 1;"):
590        name = '__func__'
591      elif self.checkLink('', "if (__FUNCTION__[0] != 'm') return 1;"):
592        name = '__FUNCTION__'
593      self.popLanguage()
594      return name
595    langs = []
596
597    self.addDefine('FUNCTION_NAME_C', getFunctionName('C'))
598    if hasattr(self.compilers, 'CXX'):
599      self.addDefine('FUNCTION_NAME_CXX', getFunctionName('Cxx'))
600    else:
601      self.addDefine('FUNCTION_NAME_CXX', '__FUNCT__')
602
603  def configureIntptrt(self):
604    '''Determine what to use for uintptr_t'''
605    def staticAssertSizeMatchesVoidStar(inc,typename):
606      # The declaration is an error if either array size is negative.
607      # It should be okay to use an int that is too large, but it would be very unlikely for this to be the case
608      return self.checkCompile(inc, ('#define STATIC_ASSERT(cond) char negative_length_if_false[2*(!!(cond))-1]\n'
609                                     + 'STATIC_ASSERT(sizeof(void*) == sizeof(%s));'%typename))
610    self.pushLanguage(self.languages.clanguage)
611    if self.checkCompile('#include <stdint.h>', 'int x; uintptr_t i = (uintptr_t)&x;'):
612      self.addDefine('UINTPTR_T', 'uintptr_t')
613    elif staticAssertSizeMatchesVoidStar('','unsigned long long'):
614      self.addDefine('UINTPTR_T', 'unsigned long long')
615    elif staticAssertSizeMatchesVoidStar('#include <stdlib.h>','size_t') or staticAssertSizeMatchesVoidStar('#include <string.h>', 'size_t'):
616      self.addDefine('UINTPTR_T', 'size_t')
617    elif staticAssertSizeMatchesVoidStar('','unsigned long'):
618      self.addDefine('UINTPTR_T', 'unsigned long')
619    elif staticAssertSizeMatchesVoidStar('','unsigned'):
620      self.addDefine('UINTPTR_T', 'unsigned')
621    else:
622      raise RuntimeError('Could not find any unsigned integer type matching void*')
623    self.popLanguage()
624
625  def configureInline(self):
626    '''Get a generic inline keyword, depending on the language'''
627    if self.languages.clanguage == 'C':
628      self.addDefine('STATIC_INLINE', self.compilers.cStaticInlineKeyword)
629      self.addDefine('RESTRICT', self.compilers.cRestrict)
630    elif self.languages.clanguage == 'Cxx':
631      self.addDefine('STATIC_INLINE', self.compilers.cxxStaticInlineKeyword)
632      self.addDefine('RESTRICT', self.compilers.cxxRestrict)
633
634    if self.checkCompile('#include <dlfcn.h>\n void *ptr =  RTLD_DEFAULT;'):
635      self.addDefine('RTLD_DEFAULT','1')
636    return
637
638  def configureSolaris(self):
639    '''Solaris specific stuff'''
640    if os.path.isdir(os.path.join('/usr','ucblib')):
641      try:
642        flag = getattr(self.setCompilers, self.language[-1]+'SharedLinkerFlag')
643      except AttributeError:
644        flag = None
645      if flag is None:
646        self.compilers.LIBS += ' -L/usr/ucblib'
647      else:
648        self.compilers.LIBS += ' '+flag+'/usr/ucblib'
649    return
650
651  def configureLinux(self):
652    '''Linux specific stuff'''
653    # TODO: Test for this by mallocing an odd number of floats and checking the address
654    self.addDefine('HAVE_DOUBLE_ALIGN_MALLOC', 1)
655    return
656
657  def configureWin32(self):
658    '''Win32 non-cygwin specific stuff'''
659    kernel32=0
660    if self.libraries.add('Kernel32.lib','GetComputerName',prototype='#include <Windows.h>', call='GetComputerName(NULL,NULL);'):
661      self.addDefine('HAVE_WINDOWS_H',1)
662      self.addDefine('HAVE_GETCOMPUTERNAME',1)
663      kernel32=1
664    elif self.libraries.add('kernel32','GetComputerName',prototype='#include <Windows.h>', call='GetComputerName(NULL,NULL);'):
665      self.addDefine('HAVE_WINDOWS_H',1)
666      self.addDefine('HAVE_GETCOMPUTERNAME',1)
667      kernel32=1
668    if kernel32:
669      if self.framework.argDB['with-windows-graphics']:
670        self.addDefine('USE_WINDOWS_GRAPHICS',1)
671      if self.checkLink('#include <Windows.h>','LoadLibrary(0)'):
672        self.addDefine('HAVE_LOADLIBRARY',1)
673      if self.checkLink('#include <Windows.h>','GetProcAddress(0,0)'):
674        self.addDefine('HAVE_GETPROCADDRESS',1)
675      if self.checkLink('#include <Windows.h>','FreeLibrary(0)'):
676        self.addDefine('HAVE_FREELIBRARY',1)
677      if self.checkLink('#include <Windows.h>','GetLastError()'):
678        self.addDefine('HAVE_GETLASTERROR',1)
679      if self.checkLink('#include <Windows.h>','SetLastError(0)'):
680        self.addDefine('HAVE_SETLASTERROR',1)
681      if self.checkLink('#include <Windows.h>\n','QueryPerformanceCounter(0);\n'):
682        self.addDefine('USE_NT_TIME',1)
683    if self.libraries.add('Advapi32.lib','GetUserName',prototype='#include <Windows.h>', call='GetUserName(NULL,NULL);'):
684      self.addDefine('HAVE_GET_USER_NAME',1)
685    elif self.libraries.add('advapi32','GetUserName',prototype='#include <Windows.h>', call='GetUserName(NULL,NULL);'):
686      self.addDefine('HAVE_GET_USER_NAME',1)
687
688    if not self.libraries.add('User32.lib','GetDC',prototype='#include <Windows.h>',call='GetDC(0);'):
689      self.libraries.add('user32','GetDC',prototype='#include <Windows.h>',call='GetDC(0);')
690    if not self.libraries.add('Gdi32.lib','CreateCompatibleDC',prototype='#include <Windows.h>',call='CreateCompatibleDC(0);'):
691      self.libraries.add('gdi32','CreateCompatibleDC',prototype='#include <Windows.h>',call='CreateCompatibleDC(0);')
692
693    self.types.check('int32_t', 'int')
694    if not self.checkCompile('#include <sys/types.h>\n','uid_t u;\n'):
695      self.addTypedef('int', 'uid_t')
696      self.addTypedef('int', 'gid_t')
697    if not self.checkLink('#if defined(PETSC_HAVE_UNISTD_H)\n#include <unistd.h>\n#endif\n','int a=R_OK;\n'):
698      self.framework.addDefine('R_OK', '04')
699      self.framework.addDefine('W_OK', '02')
700      self.framework.addDefine('X_OK', '01')
701    if not self.checkLink('#include <sys/stat.h>\n','int a=0;\nif (S_ISDIR(a)){}\n'):
702      self.framework.addDefine('S_ISREG(a)', '(((a)&_S_IFMT) == _S_IFREG)')
703      self.framework.addDefine('S_ISDIR(a)', '(((a)&_S_IFMT) == _S_IFDIR)')
704    if self.checkCompile('#include <Windows.h>\n','LARGE_INTEGER a;\nDWORD b=a.u.HighPart;\n'):
705      self.addDefine('HAVE_LARGE_INTEGER_U',1)
706
707    # Windows requires a Binary file creation flag when creating/opening binary files.  Is a better test in order?
708    if self.checkCompile('#include <Windows.h>\n#include <fcntl.h>\n', 'int flags = O_BINARY;'):
709      self.addDefine('HAVE_O_BINARY',1)
710
711    if self.compilers.CC.find('win32fe') >= 0:
712      self.addDefine('PATH_SEPARATOR','\';\'')
713      self.addDefine('DIR_SEPARATOR','\'\\\\\'')
714      self.addDefine('REPLACE_DIR_SEPARATOR','\'/\'')
715      self.addDefine('CANNOT_START_DEBUGGER',1)
716    else:
717      self.addDefine('PATH_SEPARATOR','\':\'')
718      self.addDefine('REPLACE_DIR_SEPARATOR','\'\\\\\'')
719      self.addDefine('DIR_SEPARATOR','\'/\'')
720
721    return
722
723#-----------------------------------------------------------------------------------------------------
724  def configureDefaultArch(self):
725    conffile = os.path.join('conf', 'petscvariables')
726    if self.framework.argDB['with-default-arch']:
727      fd = file(conffile, 'w')
728      fd.write('PETSC_ARCH='+self.arch.arch+'\n')
729      fd.write('PETSC_DIR='+self.petscdir.dir+'\n')
730      fd.write('include '+os.path.join(self.petscdir.dir,self.arch.arch,'conf','petscvariables')+'\n')
731      fd.close()
732      self.framework.actions.addArgument('PETSc', 'Build', 'Set default architecture to '+self.arch.arch+' in '+conffile)
733    elif os.path.isfile(conffile):
734      try:
735        os.unlink(conffile)
736      except:
737        raise RuntimeError('Unable to remove file '+conffile+'. Did a different user create it?')
738    return
739
740#-----------------------------------------------------------------------------------------------------
741  def configureScript(self):
742    '''Output a script in the conf directory which will reproduce the configuration'''
743    import nargs
744    import sys
745    scriptName = os.path.join(self.arch.arch,'conf', 'reconfigure-'+self.arch.arch+'.py')
746    args = dict([(nargs.Arg.parseArgument(arg)[0], arg) for arg in self.framework.clArgs])
747    if 'configModules' in args:
748      if nargs.Arg.parseArgument(args['configModules'])[1] == 'PETSc.Configure':
749        del args['configModules']
750    if 'optionsModule' in args:
751      if nargs.Arg.parseArgument(args['optionsModule'])[1] == 'PETSc.compilerOptions':
752        del args['optionsModule']
753    if not 'PETSC_ARCH' in args:
754      args['PETSC_ARCH'] = 'PETSC_ARCH='+str(self.arch.arch)
755    f = file(scriptName, 'w')
756    f.write('#!'+sys.executable+'\n')
757    f.write('if __name__ == \'__main__\':\n')
758    f.write('  import sys\n')
759    f.write('  import os\n')
760    f.write('  sys.path.insert(0, os.path.abspath(\'config\'))\n')
761    f.write('  import configure\n')
762    # pretty print repr(args.values())
763    f.write('  configure_options = [\n')
764    for itm in sorted(args.values()):
765      f.write('    \''+str(itm)+'\',\n')
766    f.write('  ]\n')
767    f.write('  configure.petsc_configure(configure_options)\n')
768    f.close()
769    try:
770      os.chmod(scriptName, 0775)
771    except OSError, e:
772      self.framework.logPrint('Unable to make reconfigure script executable:\n'+str(e))
773    self.framework.actions.addArgument('PETSc', 'File creation', 'Created '+scriptName+' for automatic reconfiguration')
774    return
775
776  def configureInstall(self):
777    '''Setup the directories for installation'''
778    if self.framework.argDB['prefix']:
779      self.installdir = self.framework.argDB['prefix']
780      self.addMakeRule('shared_install','',['-@echo "Now to install the libraries do:"',\
781                                              '-@echo "make PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} install"',\
782                                              '-@echo "========================================="'])
783    else:
784      self.installdir = os.path.join(self.petscdir.dir,self.arch.arch)
785      self.addMakeRule('shared_install','',['-@echo "Now to check if the libraries are working do:"',\
786                                              '-@echo "make PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} test"',\
787                                              '-@echo "========================================="'])
788      return
789
790  def configureGCOV(self):
791    if self.framework.argDB['with-gcov']:
792      self.addDefine('USE_GCOV','1')
793    return
794
795  def configureFortranFlush(self):
796    if hasattr(self.compilers, 'FC'):
797      for baseName in ['flush','flush_']:
798        if self.libraries.check('', baseName, otherLibs = self.compilers.flibs, fortranMangle = 1):
799          self.addDefine('HAVE_'+baseName.upper(), 1)
800          return
801
802  def postProcessPackages(self):
803    postPackages=[]
804    for i in self.framework.packages:
805      if hasattr(i,'postProcess'): postPackages.append(i)
806    if postPackages:
807      # prometheus needs petsc conf files. so attempt to create them early
808      self.framework.dumpConfFiles()
809      for i in postPackages: i.postProcess()
810    return
811
812  def configure(self):
813    if not os.path.samefile(self.petscdir.dir, os.getcwd()):
814      raise RuntimeError('Wrong PETSC_DIR option specified: '+str(self.petscdir.dir) + '\n  Configure invoked in: '+os.path.realpath(os.getcwd()))
815    if self.framework.argDB['prefix'] and os.path.isdir(self.framework.argDB['prefix']) and os.path.samefile(self.framework.argDB['prefix'],self.petscdir.dir):
816      raise RuntimeError('Incorrect option --prefix='+self.framework.argDB['prefix']+' specified. It cannot be same as PETSC_DIR!')
817    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)):
818      raise RuntimeError('Incorrect option --prefix='+self.framework.argDB['prefix']+' specified. It cannot be same as PETSC_DIR/PETSC_ARCH!')
819    self.framework.header          = os.path.join(self.arch.arch,'include','petscconf.h')
820    self.framework.cHeader         = os.path.join(self.arch.arch,'include','petscfix.h')
821    self.framework.makeMacroHeader = os.path.join(self.arch.arch,'conf','petscvariables')
822    self.framework.makeRuleHeader  = os.path.join(self.arch.arch,'conf','petscrules')
823    if self.libraries.math is None:
824      raise RuntimeError('PETSc requires a functional math library. Please send configure.log to petsc-maint@mcs.anl.gov.')
825    if self.languages.clanguage == 'Cxx' and not hasattr(self.compilers, 'CXX'):
826      raise RuntimeError('Cannot set C language to C++ without a functional C++ compiler.')
827    self.executeTest(self.configureInline)
828    self.executeTest(self.configurePrefetch)
829    self.executeTest(self.configureUnused)
830    self.executeTest(self.configureExpect);
831    self.executeTest(self.configureFunctionName);
832    self.executeTest(self.configureIntptrt);
833    self.executeTest(self.configureSolaris)
834    self.executeTest(self.configureLinux)
835    self.executeTest(self.configureWin32)
836    self.executeTest(self.configureDefaultArch)
837    self.executeTest(self.configureScript)
838    self.executeTest(self.configureInstall)
839    self.executeTest(self.configureGCOV)
840    self.executeTest(self.configureFortranFlush)
841    self.executeTest(self.configureFeatureTestMacros)
842    self.executeTest(self.configureAtoll)
843    # dummy rules, always needed except for remote builds
844    self.addMakeRule('remote','')
845    self.addMakeRule('remoteclean','')
846
847    self.Dump()
848    self.dumpConfigInfo()
849    self.dumpMachineInfo()
850    self.postProcessPackages()
851    self.dumpCMakeConfig()
852    self.dumpCMakeLists()
853    self.cmakeBoot()
854    self.framework.log.write('================================================================================\n')
855    self.logClear()
856    return
857