#!/usr/bin/env python
from waflib.extras import autowaf as autowaf

def build(bld):
    sources = [
        'AtomReader.cpp',
        'AtomWriter.cpp',
        'ClashAvoider.cpp',
        'Configuration.cpp',
        'Forge.cpp',
        'LV2Features.cpp',
        'Log.cpp',
        'Parser.cpp',
        'Resource.cpp',
        'Serialiser.cpp',
        'Store.cpp',
        'URIMap.cpp',
        'URIs.cpp',
        'World.cpp',
        'runtime_paths.cpp'
    ]
    if bld.is_defined('HAVE_SOCKET'):
        sources += [ 'SocketReader.cpp', 'SocketWriter.cpp' ]

    obj = bld(features        = 'cxx cxxshlib',
              source          = sources,
              export_includes = ['..'],
              includes        = ['..'],
              name            = 'libingen',
              target          = 'ingen',
              vnum            = '0.0.0',
              install_path    = '${LIBDIR}',
              lib             = ['dl'],
              cxxflags        = bld.env.PTHREAD_CFLAGS,
              linkflags       = bld.env.PTHREAD_LINKFLAGS)
    autowaf.use_lib(bld, obj, 'GLIBMM LV2 LILV RAUL SERD SORD SRATOM')

    if bld.env.BUILD_TESTS:
        obj = bld(features        = 'cxx cxxshlib',
                  source          = sources,
                  export_includes = ['..'],
                  includes        = ['..'],
                  name            = 'libingen_profiled',
                  target          = 'ingen_profiled',
                  install_path    = '',
                  lib             = ['dl'] + bld.env.INGEN_TEST_LIBS,
                  cxxflags        = bld.env.PTHREAD_CFLAGS + bld.env.INGEN_TEST_CXXFLAGS,
                  linkflags       = bld.env.PTHREAD_LINKFLAGS)
        autowaf.use_lib(bld, obj, 'GLIBMM LV2 LILV RAUL SERD SORD SRATOM')