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

import os
import Options

def set_options(opt):
    opt.add_option('--enable-metacity',
                   help=('Enable metacity bindings.'
                         ' WARNING: these bindings are not very well maintained '
                         'and may not work or even compile.'),
                   action="store_true", default=False,
                   dest='enable_metacity')
    
def configure(conf):
    conf.env.append_value('MODULES_AVAILABLE', 'metacity')
    if 'metacity' in conf.env['ENABLE_MODULES'] or Options.options.enable_metacity:
        if conf.pkg_check_modules('METACITY', 'libmetacity-private >= 2.19.8 pygobject-2.0 ',
                                  mandatory=False):
            conf.env.append_value('MODULES_TO_BUILD', 'metacity')

def build(bld):
    env = bld.env
    if 'metacity' in env['MODULES_TO_BUILD']:
        bld.codegen('metacity')
        pyext = bld.create_pyext()
        pyext.source = 'metacitymodule.c metacity.c'
        pyext.target = 'metacity'
        pyext.uselib = 'METACITY'
        pyext.install_path = '${PYTHONDIR}/gtk-2.0'

        bld.install_files('${DATADIR}/pygtk/2.0/defs', ['metacity.defs'])

