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

import sys, os, TaskGen, ctypes

def configure(conf):
    pass

def build(bld):
    bundle = 'gxautowah.lv2'
    
    src = ['gxautowah.cpp'
           ]
    incl = ['./']
    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(
        features='cxx cshlib ',
        includes = incl,
        lib = lib,
        uselib = uselib,
        obj_ext  = '_5.o',
        cxxflags = cxxflag,
        defines  = ["LV2_SO"],
        target   = 'gxautowah',
        source   = src,
        install_path = '${LV2DIR}/%s' % bundle,
        chmod = 0o755,
        )
    lv2_effects.env['shlib_PATTERN'] = '%s.so'
    
    uselib_local6 = []
    libpath6 = []
    lib6 = []
    incl6 = ['../../../libgxwmm','../../../libgxw','../']
    if sys.platform.startswith("linux"):
        lib6.append('dl')
    if bld.env["GX_LIB_SHARED"]:
        lib6 += ['gxwmm','gxw']
        libpath6 += [bld.path.find_dir("../../../libgxw/gxw").bldpath(bld.env),
                    bld.path.find_dir("../../../libgxwmm/gxwmm").bldpath(bld.env)]
    else:
        uselib_local6 += ['gxwmm','gxw']
    
    lv2_effetcs_gui = bld(
        features='cxx cshlib ',
        includes = incl6,
        lib = lib6,
        uselib = 'LV2CORE GTKMM',
        libpath = libpath6,
        uselib_local = uselib_local6,
        linkflags = '-Wl,-z,nodelete',
        defines  = ["LV2_GUI"],
        target   = 'gxautowah_gui',
        source   = 'widget.cpp gxautowah_gui.cpp',
        install_path = '${LV2DIR}/%s' % bundle,
        chmod = 0o755,
        )
    lv2_effetcs_gui.env['shlib_PATTERN'] = '%s.so'

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

