import os
import os.path
import sys
sys.path += ["../../scons-config"]
import global_config
from   global_config import LIBUTIL
from   global_config import LIBECL
from   global_config import LIBCONFIG
from   global_config import LIBRMS
from   global_config import LIBPLOT
from   global_config import LIBSCHED
from   global_config import LIBPLOT
from   global_config import LIBJOB_QUEUE
from   global_config import LIBANALYSIS
from   global_config import LIBGEOMETRY

from   global_config import add_static_library
from   global_config import add_shared_library
from   global_config import add_header
from   global_config import get_target

package      = "enkf"
lib_path     = "../lib"
slib_path    = "../slib"
include_path = "../include"
bin_path     = "../bin"  

def make_build_info(conf , target_file):
    fileH = open(target_file,"w")
    fileH.write("#define SVN_VERSION        \"%s\"\n" % conf.SVN_VERSION)
    fileH.write("#define COMPILE_TIME_STAMP \"%s\"\n" % conf.TIME_STAMP)
    fileH.close()


conf = global_config.get_conf(os.getcwd() , 2)
make_build_info( conf , "ert_build_info.h")
env  = Environment()
conf.update_env( env , [ LIBANALYSIS , LIBJOB_QUEUE , LIBCONFIG , LIBRMS , LIBSCHED , LIBECL , LIBGEOMETRY , LIBPLOT , LIBUTIL ] , link = False)
env.Append(CPPPATH = "plot")

src_list = Split("ert_report_list.c ert_report.c time_map.c rng_config.c trans_func.c enkf_types.c enkf_obs.c obs_data.c block_obs.c enkf_config_node.c container_config.c container.c field_config.c field.c ecl_static_kw.c enkf_state.c enkf_util.c enkf_node.c gen_kw_config.c gen_kw.c enkf_fs.c fs_driver.c meas_data.c summary_obs.c summary.c summary_config.c gen_data_config.c gen_data.c gen_common.c gen_obs.c enkf_sched.c enkf_serialize.c ecl_config.c enkf_defaults.c ensemble_config.c model_config.c site_config.c active_list.c obs_vector.c field_trans.c plain_driver.c config_parser.c enkf_analysis.c local_ministep.c local_updatestep.c local_context.c local_config.c analysis_config.c data_ranking.c ranking_table.c misfit_ts.c misfit_ranking.c misfit_member.c misfit_ensemble.c fs_types.c block_fs_driver.c  plot_config.c ert_template.c member_config.c enkf_main.c local_dataset.c local_obsset.c surface.c surface_config.c plot/enkf_plot_data.c plot/enkf_plot_member.c plot/enkf_plot_arg.c qc_config.c")

header_list = Split("ert_report_list.h ert_report.h time_map.h rng_config.h enkf_fs_type.h trans_func.h enkf_obs.h obs_data.h enkf_config_node.h container_config.h container.h block_obs.h field_config.h field.h enkf_macros.h ecl_static_kw.h enkf_state.h enkf_util.h enkf_main.h enkf_node.h enkf_fs.h gen_kw_config.h gen_kw.h enkf_types.h fs_driver.h  meas_data.h summary_obs.h summary_config.h summary_config.h gen_data_config.h gen_data.h gen_common.h gen_obs.h enkf_sched.h fs_types.h enkf_serialize.h ecl_config.h ensemble_config.h model_config.h site_config.h active_list.h obs_vector.h field_trans.h plain_driver.h config_parser.h enkf_analysis.h local_ministep.h local_updatestep.h ranking_common.h data_ranking.h ranking_table.h local_config.h analysis_config.h misfit_ranking.c misfit_ensemble_typedef.h misfit_ensemble.h misfit_member.h block_fs_driver.h misfit_ts.h field_common.h gen_kw_common.h gen_data_common.h plot_config.h ert_template.h member_config.h enkf_defaults.h ert_build_info.h local_dataset.h local_obsset.h surface.h surface_config.h local_context.h config_keys.h plot/enkf_plot_data.h plot/enkf_plot_member.h plot/enkf_plot_arg.h qc_config.h")

add_static_library( env , conf , lib_path  , package , src_list )
add_shared_library( env , conf , slib_path , package , src_list )

add_header( env , conf , include_path , header_list )

target = get_target( env , conf )
Default( lib_path , slib_path , include_path )