'Adjust OpenFOAM build for spack.
Where needed, apply filter as an alternative to normal patching.'

def patch(self):

    add_extra_files(self, self.common, self.assets)
    files = ['src/dbns/Make/options', 'src/fvAgglomerationMethods/MGridGenGamgAgglomeration/Make/options']
    for f in files:
        filter_file('-lMGridGen', '-lmgrid', f, backup=False)
    files = ['src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L', 'src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L', 'src/meshTools/triSurface/triSurface/interfaces/STL/readSTLASCII.L', 'applications/utilities/preProcessing/fluentDataToFoam/fluentDataToFoam.L', 'applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L', 'applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L', 'applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L', 'applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L', 'applications/utilities/mesh/conversion/fluent3DMeshToElmer/fluent3DMeshToElmer.L']
    for f in files:
        filter_file('#if    YY_FLEX_SUBMINOR_VERSION    <    34', '#if    YY_FLEX_MAJOR_VERSION    <=    2    &&    YY_FLEX_MINOR_VERSION    <=    5    &&    YY_FLEX_SUBMINOR_VERSION    <    34', f, backup=False)
