#------------------------------------------------------------------
# the top-level SConstruct file for building counter tests
#------------------------------------------------------------------

import os

#------------------------------------------------------------------
# function that searches for source files in a subdirectory
#------------------------------------------------------------------

def findsrc(srcdir, subdir, pattern):
   srch_dir = srcdir + os.sep + subdir
   srch_pattern = srch_dir + os.sep + pattern
   srclist = Glob(srch_pattern, True, True, True)
   return srclist

#------------------------------------------------------------------
# read options for environment
#------------------------------------------------------------------

home_dir = os.environ['HOME']

options_file = home_dir + os.sep + '.scons_opts.py'

if os.path.exists(options_file):
   vars = Variables(options_file)
else:
   vars = Variables()

vars.Add(BoolVariable('debug', 'Debug option, False => no debug', True))

vars.Add('gcc_version', 'GCC compiler version')

vars.Add('boost_version', 'Boost version', 1.40)

vars.Add('boost_incl_dir', 'Boost include directory', '-')

vars.Add('boost_lib_dir', 'Boost library directory', '/usr/local/lib')

vars.Add('boost_lib_suffix', 'Suffix for Boost library name', '-')

env = Environment(options = vars)

Help(vars.GenerateHelpText(env))

debug = env['debug']

# set debug options for compiler if debug flag is set
if debug:
   print 'Making debug build...'
   env['CCFLAGS'] = ['-g']
   debug_suffix = '-d'
else:
   print 'Making non-debug build...'
   env['CCFLAGS'] = []
   debug_suffix = ''

compiler_version = env['gcc_version']

boost_version = env['boost_version']

boost_incl_dir = env['boost_incl_dir']

boost_lib_dir = env['boost_lib_dir']

boost_lib_suffix = env['boost_lib_suffix']

if boost_version < 1.40:
   boost_lib_suffix += debug_suffix

boost_libs = ['boost_serialization' + boost_lib_suffix]

#------------------------------------------------------------------

env['CPPDEFINES'] = ['_REENTRANT', '__STRICT_ANSI__']

env['CCFLAGS'] += ['-mwin32', '-mthreads', '-Wall']

env['CPPPATH'] = [boost_incl_dir]

env['LIBPATH'] = [boost_lib_dir]

env['LIBS'] = boost_libs

target1_name = 'test_weak_ptr_serialization'
target1_sources = [ target1_name + '.cpp' ]
target1 = env.Program(target = target1_name, source = target1_sources)

Alias(target1_name, target1)
