'Ghostscript comes with all of its dependencies vendored.
In order to build with Spack versions of these dependencies,
we have to remove these vendored dependencies.
Note that this approach is also recommended by Linux from Scratch:
http://www.linuxfromscratch.org/blfs/view/svn/pst/gs.html'

def patch(self):

    directories = ['freetype', 'jpeg', 'lcms2', 'libpng', 'zlib']
    for directory in directories:
        shutil.rmtree(directory)
    filter_file('ZLIBDIR=src', 'ZLIBDIR={0}'.format(self.spec['zlib'].prefix.include), 'configure.ac', 'configure', string=True)
