import os
import sys


Import('env dirs name')

libraries = [
    'freelan',
    'asiotap',
    'fscp',
    'mongooseplus',
    'cryptoplus',
    'executeplus',
    'kfather',
    'iconvplus',
    'boost_system',
    'boost_thread',
    'boost_filesystem',
    'boost_date_time',
    'boost_program_options',
    'boost_iostreams',
    'curl',
    'ssl',
    'crypto',
]

if sys.platform.startswith('linux'):
    libraries.extend([
        'pthread',
        'netlinkplus',
    ])
elif sys.platform.startswith('darwin'):
    libraries.extend([
        'ldap',
        'z',
        'iconv',
    ])

env = env.Clone()
env.Prepend(LIBS=libraries)

sources = list(sorted(set(env.RGlob('src', '*.cpp')) - set(env.RGlob(os.path.join('src', 'windows'), '*.cpp'))))
app = env.Program(target=os.path.join(str(dirs['bin']), name), source=sources)
configuration = env.File(env.RGlob('config', '*.cfg'))

Return('app configuration')
