#!/usr/bin/env python
# encoding: utf-8

import os

def configure(conf):
    pass

def build(bld):
    bsources = [
        '../gx_head/gx_json.cpp',
        '../gx_head/gx_faust_plugins.cpp',
        '../gx_head/gx_internal_plugins.cpp',
        '../gx_head/gx_engine_audio.cpp',
        '../gx_head/gx_paramtable.cpp',
        '../gx_head/gx_ui.cpp',
        '../gx_head/gx_convolver.cpp',
        '../gx_head/gx_resampler.cpp',
        '../gx_head/gx_system.cpp',
        '../gx_head/gx_pluginloader.cpp',
        '../plugins/zita_rev1.cc',  ## lib can't be used (-fPIC)
        ]
    
    src = ['ladspa_guitarix.cpp'] + bsources
    incl = ['../headers', '..', '../gx_head','../../libgxwmm','../../libgxw']
    lib = ['dl']
    uselib = ['JACK', 'SNDFILE', 'GTHREAD', 'GMODULE_EXPORT',
              'GLIBMM', 'GIOMM', 'FFTW3', 'BOOST_THREAD']
    if bld.env['ZITA_CONVOLVER']:
        uselib.append('ZITA_CONVOLVER')
    else:
        src.append('../zita-convolver/zita-convolver.cc')
        incl.append('../zita-convolver');
    if bld.env['ZITA_RESAMPLER']:
        uselib.append('ZITA_RESAMPLER')
    else:
        src.append('../zita-resampler/zita-resampler.cc')
        incl.append('../zita-resampler')
    ladspa_plugin = bld(
        #features='cxx cprogram',  ## for debugging
        features='cxx cshlib',
        includes = incl,
        lib = lib,
        uselib = uselib,
        #uselib_local = ["plugins"], ## needs -fPIC
        cxxflags = ["-fvisibility=hidden"],
        defines = ["LADSPA_SO"],
        target   = 'ladspa_guitarix',
        source   = src,
        install_path = '${LADSPADIR}',
        chmod = 0755,
        )
    ladspa_plugin.env['shlib_PATTERN'] = '%s.so'
    bld.install_files('${SHAREDIR}/ladspa/rdf', 'guitarix_amp.rdf')
