"""Build pool library"""


def scons():
    """Execute build"""
    Import('env', 'prereqs', 'libdaos_tgts')

    env.AppendUnique(LIBPATH=[Dir('.')])
    env.AppendUnique(CPPPATH=[Dir('../mgmt').srcnode()])
    denv = env.Clone()

    denv.require('argobots', 'protobufc')

    common = denv.SharedObject(['rpc.c'])

    # dc_pool: Pool Client
    libdaos_tgts.extend(denv.SharedObject(['cli.c']) + common)

    if not prereqs.server_requested():
        return

    # ds_pool: Pool Server
    ds_pool = denv.d_library('pool',
                             ['srv.c', 'srv_pool.c', 'srv_layout.c',
                              'srv_target.c', 'srv_util.c', 'srv_iv.c',
                              'srv_cli.c',
                              'srv_pool_scrub_ult.c', 'srv_pool_map.c',
                              'srv_metrics.c', 'srv_pool_chkpt.c', common],
                             install_off="../..")
    denv.Install('$PREFIX/lib64/daos_srv', ds_pool)


if __name__ == "SCons.Script":
    scons()
