defs = '-D_REENTRANT -D_THREAD_SAFE'
build_flags = defs + ' -Wall -Werror -O2 -fPIC -DPIC'
test_flags = defs + ' -Wall -Werror'

destdir = ARGUMENTS.get('destdir', '')

env = Environment(DESTDIR = destdir)

base_libs = ['pthread', 'rt']
test_libs = ['sharedmem'] + base_libs

lib_srcs = ['sharedmem.c', 'shmalloc.c']

shm_header = ['sharedmem.h', 'shm_config.h', 'shmalloc.h']
shm_static = env.StaticLibrary('sharedmem', lib_srcs, CCFLAGS=build_flags)
shm_shared = env.SharedLibrary('sharedmem', lib_srcs, CCFLAGS=build_flags)

'''Program('test', 'test.c', LIBS=test_libs, LIBPATH='.', CCFLAGS=test_flags)'''
Program('test2', 'test2.c', LIBS=test_libs, LIBPATH='.', CCFLAGS=test_flags)
Program('test3', 'test3.c', LIBS=test_libs, LIBPATH='.', CCFLAGS=test_flags)
Program('test4', 'test4.c', LIBS=test_libs, LIBPATH='.', CCFLAGS=test_flags)

SourceSignatures('timestamp')

env.Install(env['DESTDIR'] + '/usr/include', shm_header)
env.Install(env['DESTDIR'] + '/usr/lib', [shm_static, shm_shared])
env.Alias('install', [env['DESTDIR'] + '/usr/include', env['DESTDIR'] + '/usr/lib'])

