#  Copyright (C) 2008 Gilles Hennenfent and Sean Ross-Ross
#  
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

from slabcore import *
from os.path import join
 
env = Environment()
env.Tool('slabroot')
env.Tool('python')
env.Tool('slabc')
env.Tool('slab_cc')

env.Tool('eslabc')
env.Tool('scew')
env.Tool('expat')


srcdir = Dir('.').srcnode( ).abspath
srcincdir = join( srcdir, "../includes" )
srcincdir_esl = join( srcdir, "../../python_eslab_api/includes" )


env.Append( CPPPATH=[srcincdir,srcincdir_esl],
#            LIBPATH=['../../c_api/src'],
#            LIBS='slab_c' 
            )

#CCFLAGS = env['CCFLAGS']
#for i in range( CCFLAGS.count('-O3') ):
#    CCFLAGS.remove('-O3')

#senv = env.Clone()

if env['PLATFORM'] == 'darwin':
    env.Append(SHLINKFLAGS=['-undefined','dynamic_lookup'])
    

#libpyslab = env.SharedLibrary( 'pyslab', 
SOURCES=                   [  'py_environment.c',
                              'PySLFileObject/py_sl_file.c',
                              'PySLFileObject/Py_slfile_getseters.c',
                              'PySLFileObject/Py_slfile_methods.c',
                              'py_error.c',
                              'PySLDictObject/pysl_dict.c',
                              'PySLDictObject/py_sl_dict_helpers.c',
                              "PYSLIterator/pysl_iterator.c" ,
                              
#                "../../python_eslab_api/src/slabxml.c", 
                "../../python_eslab_api/src/eslfile.c",

                              ]
#                                )

#libpyslab = env.SharedLibrary( 'pyslab', SOURCES )
#env.InstallLibrary(libpyslab)

env = env.Clone()
#env.Append( LIBS=["pyslab"] )

env.AppendENVPath( 'LD_RUN_PATH', env['lib_prefix'] )
#slab_so = env.LoadableModule("slab", ["slab.c" ] )
slab_so = env.LoadableModule("slab", ["slab.c" ,SOURCES] )

mains = env.InstallPythonModule( [slab_so] )

env.InstallPythonModule( ['slabutils.py'] )
env.InstallPythonModule( ['slabxml.py'] )

