1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
# coding=utf-8
import os.path as osp
from functools import partial
from waflib import Options, Configure, Logs, Utils, Errors
def options(self):
group = self.add_option_group("Petsc library options")
group.add_option('--disable-petsc', dest='enable_petsc',
action='store_false', default=None,
help='Disable PETSC support')
group.add_option('--enable-petsc', dest='enable_petsc',
action='store_true', default=None,
help='Force PETSC support')
group.add_option('--petsc-libs', type='string',
dest='petsc_libs', default=None,
help='petsc librairies used when linking')
group.add_option('--embed-petsc', dest='embed_petsc',
default=False, action='store_true',
help='Embed PETSC libraries as static library')
def configure(self):
from Options import options as opts
try:
self.env.stash()
self.check_petsc()
except Errors.ConfigurationError:
self.env.revert()
if opts.enable_petsc == True:
raise
else:
self.define('_HAVE_PETSC', 1)
self.define('HAVE_PETSC', 1)
###############################################################################
@Configure.conf
def check_petsc(self):
from Options import options as opts
if opts.enable_petsc == False:
raise Errors.ConfigurationError('PETSC disabled')
optlibs = None
if opts.petsc_libs is None:
opts.petsc_libs = 'petsc'
# add optional libs
optlibs ='ml HYPRE stdc++'
if opts.petsc_libs:
self.check_petsc_libs(optlibs)
self.check_petsc_headers()
@Configure.conf
def check_petsc_libs(self, optlibs):
from Options import options as opts
keylib = ('st' if opts.embed_all or opts.embed_scotch else '') + 'lib'
for lib in Utils.to_list(opts.petsc_libs):
self.check_cc(uselib_store='PETSC', use='MPI', mandatory=True, **{ keylib: lib})
for lib in Utils.to_list(optlibs or ''):
self.check_cc(uselib_store='PETSC', use='MPI', mandatory=False, **{ keylib: lib})
@Configure.conf
def check_petsc_headers(self):
from Options import options as opts
check = partial(self.check, header_name='petsc.h', uselib='PETSC',
uselib_store='PETSC')
self.start_msg('Checking for header petsc.h')
try:
if not check(mandatory=False):
if not check(includes=[osp.join(self.env.INCLUDEDIR, 'petsc')], mandatory=False):
check(includes=[osp.join(self.env.OLDINCLUDEDIR, 'petsc')], mandatory=True)
except:
self.end_msg('no', 'YELLOW')
raise
else:
self.end_msg('yes')
|