Import('env')
Import('projects')
Import('RTT_ROOT')
Import('rtconfig')
Import('TARGET')

RTMLINKER = RTT_ROOT + '/tools/rtmlinker.exe '

# group definitions
group = {}
group['name'] = 'examples'
group['src'] = Glob('*.c')
group['CCFLAGS'] = ''
group['CPPPATH'] = ['']
group['CPPDEFINES'] = ''

target = 'basicapp.so'
POST_ACTION = RTMLINKER + '-l ' + TARGET + ' -o basicapp.mo ' + '$TARGET'

# add group to project list
projects.append(group)

src_local = Glob('basicapp.c')

env.Append(CCFLAGS = group['CCFLAGS'])
env.Append(CPPPATH = group['CPPPATH'])
env.Append(CPPDEFINES = group['CPPDEFINES'])
module_env = env.Clone(CPPDEFINE = 'RT_MODULE')
module_env = env.Clone(CCFLAGS = ' -mcpu=arm920t -O0 -fPIC')
module_env.Replace(LINK =  'arm-none-eabi-ld')
module_env.Replace(LINKFLAGS = '-z max-page-size=0x4 -shared -fPIC -e rt_application_entry -nostdlib -s')
module_env.Program(target, src_local) 
module_env.AddPostAction(target, POST_ACTION) 

