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

import sys

def configure(conf):
    pass

def build(bld):
    bundle = 'gxtape_st.lv2'
    
    src = ['gxtape_st.cpp'
           ]
    incl = ['../faust','./', '../DSP']
    lib = []
    if sys.platform.startswith("linux"):
        lib.append('dl')
    uselib = ['LV2CORE']
    cxxflag =[]
    if not bld.env['OPT'] and bld.env['SSE2']:
        cxxflag = [ "-msse2", "-mfpmath=sse"]
    lv2_effects = bld.shlib(
        includes = incl,
        lib = lib,
        uselib = uselib,
        obj_ext  = '_5.o',
        cxxflags = cxxflag,
        defines  = ["LV2_SO"],
        target   = 'gxtape_st',
        source   = src,
        install_path = '${LV2DIR}/%s' % bundle,
        chmod = 0o755,
        )
    lv2_effects.env['cxxshlib_PATTERN'] = '%s.so'
    
    if bld.env['LV2GUI']:
        libpath5 = []
        lib5 = []
        incl5 = ['../']
        if sys.platform.startswith("linux"):
            lib5.append('dl')
    
        lv2_effetcs_gui = bld.shlib(
            includes = incl5,
            lib = lib5,
            libpath = libpath5,
            use = ['gxwmm','LV2CORE','GTKMM'],
            linkflags = '-Wl,-z,nodelete',
            defines  = ["LV2_GUI"],
            target   = 'gxtape_st_gui',
            source   = 'widget.cpp gxtape_st_gui.cpp',
            install_path = '${LV2DIR}/%s' % bundle,
            chmod = 0o755,
            )
        lv2_effetcs_gui.env['cxxshlib_PATTERN'] = '%s.so'

    
    install_path = '${LV2DIR}/%s' % bundle,
    bld.install_files('${LV2DIR}/gxtape_st.lv2', 'manifest.ttl')
    bld.install_files('${LV2DIR}/gxtape_st.lv2', 'gxtape_st.ttl')

