from waftools.plugin import plugin

def plugin_configure(conf):
    cfg = conf.create(configurator='cfgtool')
    cfg.binary = 'ffmpeg-config'
    cfg.uselib = 'avformat'
    cfg.tests = {'--cflags': 'CCFLAGS',
                 '--plugin-libs avformat': 'LINKFLAGS'}
    return (cfg.run() or conf.check_pkg('libavformat', destvar='avformat'))

configure, build = plugin('avformat', configure=plugin_configure,
                          source="avformat.c",
                          needs_lib=True)
