import os,glob,shutil

# import root environment
Import( "env")
myenv = env.Copy()

# gather cpp files
cpps = env.SGlob("*.cpp")
pycpps = env.SGlob("python_*.cpp")
for pf in pycpps: cpps.remove(pf)

casalibd = os.path.join(myenv['CASAROOT'],myenv['CASAARCH'],'lib')

# location of libcasav.a
myenv.Prepend( LIBPATH = ['#/build'] )
myenv.Install('#build', os.path.join(casalibd, 'libwcs.a'))
myenv['SHLIBPREFIX']=""   #gets rid of lib prefix

# need to create library here to fool  scons linker
casav = myenv.StaticLibrary(target = "casav", source = os.path.join(casalibd, 'version.o'))
libasap =  myenv.StaticLibrary(target = "asap", source = cpps)
myenv.Prepend( LIBS =  ['asap'] )

# Finally create the library for the module
so = myenv.SharedLibrary( target = "_asap", source = pycpps )
#test = myenv.Program("test", cpps)
Return("so")

