mapnik/python/SConscript
Artem Pavlenko a6191fade0 1. corrected LIBS in SConsctipt files
2. use boost::shared_ptr instead of ref_ptr
2005-12-12 13:15:33 +00:00

122 lines
4 KiB
Python

# This file is part of Mapnik (c++ mapping toolkit)
# Copyright (C) 2005 Artem Pavlenko
#
# Mapnik 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 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.
#
# $Id$
import os
import SCons.Errors
import SCons.Defaults
import glob
Import('env')
#env.Append(CCFLAGS = ' -DBOOST_PYTHON_DYNAMIC_LIB')
#boost python
prefix = env['PREFIX']
boost_root = env['BOOST_ROOT']
python_root = env['PYTHON_ROOT']
python_version = env['PYTHON_VERSION']
python_headers = python_root+'/include/python'+python_version
boost_python_src_dir = boost_root + '/libs/python/src/'
boost_python_src = glob.glob(boost_python_src_dir + '*.cpp')
boost_python_src.append(glob.glob(boost_python_src_dir + 'object/*.cpp'))
boost_python_src.append(glob.glob(boost_python_src_dir + 'converter/*.cpp'))
python_cpppath = python_root+'/include/python'+python_version
lib_boost_python = env.SharedLibrary('libboost-python',boost_python_src,LIBS=[],CPPPATH=[boost_root,python_cpppath])
env.Install(prefix + '/lib',lib_boost_python)
agg_root = env['AGG_ROOT']
agg_headers = agg_root +'/include'
freetype2_root = env['FREETYPE2_ROOT']
def createPythonExtBuilder(env):
"""This is a utility function that creates boost-python
extension Builder in an Environment if it is not there already.
If it is already there, we return the existing one.
"""
try:
python_ext = env['BUILDERS']['PythonExtension']
except KeyError:
action_list = [ SCons.Defaults.SharedCheck,
SCons.Defaults.ShLinkAction ]
python_ext = SCons.Builder.Builder(action = action_list,
emitter = "$SHLIBEMITTER",
prefix = '',
suffix = '$SHLIBSUFFIX',
target_scanner = SCons.Defaults.ProgScan,
src_suffix = '$SHOBJSUFFIX',
src_builder = 'SharedObject')
env['BUILDERS']['PythonExtension'] = python_ext
return python_ext
createPythonExtBuilder(env)
mapnik_python_src=Split(
"""
mapnik_color.cpp
mapnik_envelope.cpp
mapnik_image.cpp
mapnik_layer.cpp
mapnik_map.cpp
mapnik_parameters.cpp
mapnik_filter.cpp
mapnik_rule.cpp
mapnik_style.cpp
mapnik_stroke.cpp
mapnik_datasource_cache.cpp
mapnik_python.cpp
"""
)
headers =[ '#include',boost_root,freetype2_root,agg_headers,python_headers]
libraries=['mapnik','boost-python']
libpaths = [prefix+"/lib"]
_mapnik_python = env.PythonExtension(target='_mapnik',\
source=mapnik_python_src,\
CPPPATH=headers,\
LIBS=libraries,\
LIBPATH=libpaths)
def substitute_prefix(target,source,env):
from string import Template
s = Template(source[0].get_contents())
str = s.substitute(PREFIX=prefix)
_out = file(target[0].abspath,'w')
_out.write(str)
_out.close()
return None
env.Command('mapnik/__init__.py','mapnik/__init__.py.in', substitute_prefix)
__init1__ = env.Install(prefix+'/lib','__init__.py')
__init2__ = env.Install(prefix+'/lib/mapnik','mapnik/__init__.py')
_source=env.Install(prefix+'/lib/mapnik',_mapnik_python)
_source.append(__init1__)
_source.append(__init2__)
env.Alias(target="install",source=_source)