# -*- python -*-
# encoding: utf-8

def configure(conf):
    conf.env.append_value('MODULES_AVAILABLE', 'totem.plparser')
    if 'totem.plparser' in conf.env['ENABLE_MODULES'] or 'all' in conf.env['ENABLE_MODULES']:
        if conf.pkg_check_modules('PLPARSER',
                                  'totem-plparser >= 1.4 pygobject-2.0 ',
                                  mandatory=False):
            conf.env.append_value('MODULES_TO_BUILD', 'totem.plparser')


def build(bld):

    if 'totem.plparser' in bld.env['MODULES_TO_BUILD']:
        bld.codegen('plparser')
        pyext = bld.create_pyext()
        pyext.source = 'plparsermodule.c plparser.c'
        pyext.target = 'plparser'
        pyext.uselib = 'PLPARSER'
        pyext.install_path = '${PYTHONDIR}/gtk-2.0/totem'

        py = bld.new_task_gen('py')
        py.install_path = '${PYTHONDIR}/gtk-2.0/totem'
        py.source = "__init__.py"

        bld.install_files('${DATADIR}/pygtk/2.0/defs', 'plparser.defs')

