#! /usr/bin/python
# Copyright 2004-2008 Roman Yakovenko.
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

import os
import sys
import random_settings

Import( 'env' )

def get_ccflags():
    if sys.platform == 'win32':
        return random_settings.scons.ccflags \
               + map( lambda ds: '/D%s' % ds, random_settings.defined_symbols )
    else:
        return map( lambda ds: '-D' + ds, random_settings.defined_symbols )

def get_source_files():
    source_files = filter( lambda s: s.endswith( '.cpp' ), os.listdir(random_settings.generated_files_dir) )
    return map( lambda fname: os.path.join( random_settings.generated_files_dir, fname ), source_files )

def get_target():
    return os.path.join( random_settings.generated_files_dir
                         , random_settings.module_name + random_settings.scons.suffix )

local_env = env.Copy()
local_env.Append( CPPPATH=[ random_settings.working_dir, random_settings.generated_files_dir ] )
local_env.Append( CCFLAGS=get_ccflags() )

_random_ = local_env.SharedLibrary( target=random_settings.module_name 
                                 , source=get_source_files() )

local_env.Install( '#pyboost/boost_random', _random_ )
