#!python

Import('env', 'PREREQS', 'srv')

env.AppendUnique(LIBPATH=[Dir('.')])

if PREREQS is None:
    # This isn't ideal as this is already checked for in / and /common
    # so should probably be a variable.
    config = Configure(env)
    if config.CheckHeader('libpmemobj.h'):
        env.Append(LIBS='libpmemobj')
    config.Finish()
else:
    PREREQS.require(env, 'nvml')

denv = env.Clone()

# Compiler options
denv.Append(CPPPATH = ['#/src/vos/'])

if srv == False:
	# generate standalone library
	denv.Append(CPPDEFINES = {'VOS_STANDALONE' : '1'})
	lib = 'vos'
	install = 'lib'
else:
	# generate DAOS server module
	lib = 'vos_srv'
	install = 'lib/daos_srv'

vos = denv.SharedLibrary(lib, Glob('*.c'))

denv.Install('$PREFIX/' + install, vos)

# Tests
if srv == False:
	SConscript('tests/SConscript', exports='denv')
