import os

Import('argenv', 'STARS_CCFLAGS')




libdirs='''
	src/base
	src/interfaces
	src/interfaces/abstract
	src/interfaces/irdb
	src/drivers/library
     '''
libdirs=Split(libdirs)

cpppath='''
        $SMPSA_HOME/include   \
        $SMPSA_HOME/include/base  \
        $SMPSA_HOME/include/interfaces \
        $SMPSA_HOME/include/interfaces/abstract \
	$SECURITY_TRANSFORMS_HOME/include  \
	$SECURITY_TRANSFORMS_HOME/beaengine/include  \
	$SECURITY_TRANSFORMS_HOME/libIRDB/include/  \
	$SECURITY_TRANSFORMS_HOME/libMEDSannotation/include/ \
	'''

IRDB_CCFLAGS=''' -std=c++0x  \
        -w \
        -DSTARS_IRDB_INTERFACE  \
        '''+STARS_CCFLAGS+" "

IRDB_LIBPATH="$SECURITY_TRANSFORMS_HOME/lib $SECURITY_TRANSFORMS_HOME/beaengine/lib/Linux.gnu.Debug "
LIBS="IRDB-core IRDB-cfg pqxx BeaEngine_s_d MEDSannotation pq IRDB-util"
IRDB_LDFLAGS=" "


# set 32/64 bit build properly
if int(argenv['do_64bit_build']) == 2:
	print "Defaulting to mach-dep 32/64 bit build parameter"
elif int(argenv['do_64bit_build']) == 1:
	IRDB_CCFLAGS+=" -m64 "
	IRDB_LDFLAGS+=" -m64 "
else:
	IRDB_CCFLAGS+=" -m32 "
	IRDB_LDFLAGS+=" -m32 "



# find files
#print 'dirs: ',dirs
libfiles=[]
for dir in libdirs:
	libfiles=libfiles+ Glob( os.path.join( Dir('.').srcnode().abspath, dir,"*.cpp"))


#setup the environment
irdbenv=argenv.Clone(CCFLAGS=IRDB_CCFLAGS, LINKFLAGS=IRDB_LDFLAGS, CPPPATH=Split(cpppath));


# build the program
starslib=irdbenv.Library('stars', libfiles)
install=argenv.Install("$SECURITY_TRANSFORMS_HOME/lib/", starslib)
Default(install)


Return('starslib')