xref: /petsc/config/BuildSystem/config/packages/PFLARE.py (revision 3220ff8572602716d60bdda8b51773ebceb3c8ea)
1import config.package
2
3class Configure(config.package.Package):
4    def __init__(self, framework):
5        config.package.Package.__init__(self, framework)
6        self.version                = '1.25.1'
7        self.gitcommit              = '0fc79e1a12bc3811e1f2834fb7b318f2114b6d91' # https://github.com/PFLAREProject/PFLARE/pull/179
8        self.download               = ['git://https://github.com/PFLAREProject/PFLARE','https://github.com/PFLAREProject/PFLARE/archive/'+self.gitcommit+'.tar.gz']
9        self.functions              = ['PCRegister_PFLARE']
10        self.includes               = ['pflare.h']
11        self.liblist                = [['libpflare.a']]
12        self.complex                = 0
13        self.precisions             = ['double']
14        self.linkedbypetsc          = 0
15        self.builtafterpetsc        = 1
16        return
17
18    def setupDependencies(self, framework):
19        config.package.Package.setupDependencies(self, framework)
20        self.sharedLibraries = framework.require('PETSc.options.sharedLibraries',self)
21        self.mpi             = framework.require('config.packages.MPI',self)
22        self.blasLapack      = framework.require('config.packages.BlasLapack',self)
23        self.parmetis        = framework.require('config.packages.ParMETIS',self)
24        self.kokkos          = framework.require('config.packages.kokkos',self)
25        self.kokkoskernels   = framework.require('config.packages.kokkos-kernels',self)
26        self.scalartypes     = framework.require('PETSc.options.scalarTypes',self)
27        self.petsc4py        = framework.require('config.packages.petsc4py',self)
28        self.cython          = framework.require('config.packages.Cython',self)
29        self.deps            = [self.mpi,self.blasLapack,self.parmetis]
30        self.odeps           = [self.kokkos,self.kokkoskernels,self.petsc4py,self.cython]
31        return
32
33    def Install(self):
34        import os
35        # Have to be built with shared libraries if using the PETSc configure
36        # For static builds you have to build PFLARE yourself from source
37        if not self.checkSharedLibrariesEnabled():
38            raise RuntimeError('PFLARE built through the PETSc configure requires shared libraries')
39
40        # if installing prefix location then need to set new value for PETSC_DIR/PETSC_ARCH
41        if self.argDB['prefix'] and not 'package-prefix-hash' in self.argDB:
42            barg = ' PETSC_DIR='+os.path.abspath(os.path.expanduser(self.argDB['prefix']))+' PETSC_ARCH=""'
43            prefix = os.path.abspath(os.path.expanduser(self.argDB['prefix']))
44            # We also have to add the original PETSc source dirs to C includes before the build
45            # No PETSC_ARCH in the source directory as we are in a prefix build
46            barg = barg + ' CFLAGS="-I${PETSC_DIR}/include ${CFLAGS}"'
47            barg = barg + ' CPPFLAGS="-I${PETSC_DIR}/include ${CPPFLAGS}"'
48            barg = barg + ' CXXFLAGS="-I${PETSC_DIR}/include ${CXXFLAGS}"'
49        else:
50            barg = 'PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH}'
51            checkarg = barg
52            prefix = os.path.join(self.petscdir.dir,self.arch)
53        barg = barg + ' PREFIX=' + prefix
54        checkarg = barg
55
56        self.include = [os.path.join(self.installDir,'include')]
57        self.lib     = [os.path.join(self.installDir,'lib','libpflare.a')]
58        libdir = os.path.join(self.installDir, 'lib')
59        # Call make, make python (if petsc4py is enabled), then
60        # make install. After that create a symlink called libpetscpflare
61        # to ensure the PFLARE registration routine is called when PETSc loads
62        # the dynamic PFLARE library
63        post_cmds = [barg + ' ${OMAKE} ' + barg,]
64        if self.petsc4py.found:
65            if not self.cython.found:
66                raise RuntimeError('PFLARE with petsc4py requires cython! Suggest --download-cython!')
67            post_cmds.append(barg + ' ${OMAKE} ' + barg + ' python')
68        post_cmds.append(barg + ' ${OMAKE} ' + barg + ' install')
69        post_cmds.append('cd "{0}" && ln -sf libpflare.{1} libpetscpflare.{1}'.format(libdir, self.setCompilers.sharedLibraryExt))
70        self.addPost(self.packageDir, post_cmds)
71        self.addMakeCheck(self.packageDir, '${OMAKE} ' + checkarg + ' check')
72
73        return self.installDir
74