Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
286 lines (244 sloc) 8.47 KB
#
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# $Id$
import os
import glob
from subprocess import Popen, PIPE
Import('env')
lib_env = env.Clone()
def call(cmd, silent=True):
stdin, stderr = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE).communicate()
if not stderr:
return stdin.strip()
elif not silent:
print stderr
def ldconfig(*args,**kwargs):
call('ldconfig')
mapnik_lib_link_flag = ''
ABI_VERSION = env['ABI_VERSION']
prefix = env['PREFIX']
lib_dir = os.path.normpath(prefix + '/' + env['LIBDIR_SCHEMA'])
install_prefix = env['DESTDIR'] + '/' + prefix
filesystem = 'boost_filesystem%s' % env['BOOST_APPEND']
regex = 'boost_regex%s' % env['BOOST_APPEND']
libraries = ['freetype','ltdl','png','tiff','z','jpeg','proj',env['ICU_LIB_NAME'],filesystem,regex]
if env['HAS_CAIRO']:
# add cairo and cairomm-1.0 to libs
libraries.append('cairomm-1.0')
libraries.append('cairo')
if env['XMLPARSER'] == 'libxml2':
libraries.append('xml2')
if env['THREADING'] == 'multi':
libraries.append('boost_thread%s' % env['BOOST_APPEND'])
if env['PLATFORM'] == 'Darwin':
if env['HAS_BOOST_SYSTEM']:
libraries.append('boost_system%s' % env['BOOST_APPEND'])
if env['INTERNAL_LIBAGG']:
libraries.insert(0, 'agg')
else:
libraries.append([lib for lib in env['LIBS'] if lib.startswith('agg')])
if env['PLATFORM'] == 'Darwin':
mapnik_libname = 'libmapnik2.dylib'
elif env['PLATFORM'] == 'SunOS' and env['CXX'].startswith('CC'):
mapnik_libname = 'libmapnik2.so'
else:
mapnik_libname = 'libmapnik2.so.' + ("%d.%d" % (ABI_VERSION[0],ABI_VERSION[1]))
if env['PLATFORM'] == 'Darwin':
if env['FULL_LIB_PATH']:
lib_path = '%s/%s' % (lib_dir,mapnik_libname)
else:
lib_path = mapnik_libname
mapnik_lib_link_flag += ' -Wl,-install_name,%s' % lib_path
_d = {'version':env['MAPNIK_VERSION_STRING']}
mapnik_lib_link_flag += ' -current_version %(version)s -compatibility_version %(version)s' % _d
elif env['PLATFORM'] == 'SunOS':
if env['CXX'].startswith('CC'):
mapnik_lib_link_flag += ' -R. -h %s' % mapnik_libname
else:
mapnik_lib_link_flag += ' -Wl,-h,%s' % mapnik_libname
else: # Linux and others
mapnik_lib_link_flag += ' -Wl,-rpath-link,. -Wl,-soname,%s' % mapnik_libname
source = Split(
"""
color.cpp
datasource_cache.cpp
box2d.cpp
expression_node.cpp
expression_string.cpp
filter_factory.cpp
font_engine_freetype.cpp
font_set.cpp
graphics.cpp
image_cache.cpp
image_reader.cpp
image_util.cpp
layer.cpp
line_pattern_symbolizer.cpp
map.cpp
load_map.cpp
memory.cpp
params.cpp
parse_path.cpp
placement_finder.cpp
plugin.cpp
png_reader.cpp
point_symbolizer.cpp
polygon_pattern_symbolizer.cpp
save_map.cpp
shield_symbolizer.cpp
text_symbolizer.cpp
tiff_reader.cpp
wkb.cpp
projection.cpp
proj_transform.cpp
distance.cpp
scale_denominator.cpp
memory_datasource.cpp
stroke.cpp
symbolizer.cpp
arrow.cpp
unicode.cpp
glyph_symbolizer.cpp
markers_symbolizer.cpp
metawriter.cpp
"""
)
if env['JPEG']:
source += Split(
"""
jpeg_reader.cpp
""")
if True : # agg backend
source += Split(
"""
agg/agg_renderer.cpp
agg/process_building_symbolizer.cpp
agg/process_glyph_symbolizer.cpp
agg/process_line_symbolizer.cpp
agg/process_line_pattern_symbolizer.cpp
agg/process_text_symbolizer.cpp
agg/process_point_symbolizer.cpp
agg/process_polygon_symbolizer.cpp
agg/process_polygon_pattern_symbolizer.cpp
agg/process_raster_symbolizer.cpp
agg/process_shield_symbolizer.cpp
agg/process_markers_symbolizer.cpp
svg_parser.cpp
svg_path_parser.cpp
svg_points_parser.cpp
svg_transform_parser.cpp
marker_cache.cpp
"""
)
if env['HAS_CAIRO']:
env2 = lib_env.Clone()
env2.Append(CXXFLAGS = '-DHAVE_CAIRO')
env2.ParseConfig('pkg-config --libs --cflags cairomm-1.0')
fixup = ['cairo_renderer.cpp','graphics.cpp','image_util.cpp']
for cpp in fixup:
if cpp in source:
source.remove(cpp)
source.insert(0,env2.SharedObject(cpp))
if env['XMLPARSER'] == 'tinyxml':
source += Split(
"""
../tinyxml/tinystr.cpp
../tinyxml/tinyxml.cpp
../tinyxml/tinyxmlerror.cpp
../tinyxml/tinyxmlparser.cpp
""")
elif env['XMLPARSER'] == 'libxml2' and env['HAS_LIBXML2']:
source += Split(
"""
libxml2_loader.cpp
""")
env2 = lib_env.Clone()
env2.Append(CXXFLAGS = '-DHAVE_LIBXML2')
fixup = ['load_map.cpp','libxml2_loader.cpp']
for cpp in fixup:
if cpp in source:
source.remove(cpp)
source.insert(0,env2.SharedObject(cpp))
if env['SVG_RENDERER']: # svg backend
source += Split(
"""
svg/svg_renderer.cpp
svg/svg_generator.cpp
svg/svg_output_attributes.cpp
svg/process_symbolizers.cpp
svg/process_building_symbolizer.cpp
svg/process_glyph_symbolizer.cpp
svg/process_line_pattern_symbolizer.cpp
svg/process_line_symbolizer.cpp
svg/process_markers_symbolizer.cpp
svg/process_point_symbolizer.cpp
svg/process_polygon_pattern_symbolizer.cpp
svg/process_polygon_symbolizer.cpp
svg/process_raster_symbolizer.cpp
svg/process_shield_symbolizer.cpp
svg/process_text_symbolizer.cpp
""")
lib_env.Append(CXXFLAGS = '-DSVG_RENDERER')
if env['CUSTOM_LDFLAGS']:
linkflags = '%s %s' % (env['CUSTOM_LDFLAGS'], mapnik_lib_link_flag)
else:
linkflags = mapnik_lib_link_flag
mapnik = lib_env.SharedLibrary('mapnik2', source, LIBS=libraries, LINKFLAGS=linkflags)
if env['PLATFORM'] != 'Darwin':
# Symlink command, only works if both files are in same directory
def symlink(env, target, source):
trgt = str(target[0])
src = str(source[0])
if os.path.islink(trgt) or os.path.exists(trgt):
os.remove(trgt)
os.symlink(os.path.basename(src), trgt)
major, minor, micro = ABI_VERSION
soFile = "%s.%d.%d.%d" % (os.path.basename(str(mapnik[0])), major, minor, micro)
libDir = install_prefix + '/' + env['LIBDIR_SCHEMA']
target = os.path.join(libDir, soFile)
if 'uninstall' not in COMMAND_LINE_TARGETS:
result = env.InstallAs(target=target, source=mapnik)
env.Alias(target='install', source=result)
if result:
env.AddPostAction(result, ldconfig)
# Install symlinks
target1 = os.path.join(libDir, "%s.%d.%d" % (os.path.basename(str(mapnik[0])),major, minor))
target2 = os.path.join(libDir, os.path.basename(str(mapnik[0])))
if 'uninstall' not in COMMAND_LINE_TARGETS:
if 'install' in COMMAND_LINE_TARGETS:
link1 = env.Command(target1, target, symlink)
env.Alias(target='install', source=link1)
link2 = env.Command(target2, target1, symlink)
env.Alias(target='install', source=link2)
# delete in reverse order..
env['create_uninstall_target'](env, target2)
env['create_uninstall_target'](env, target1)
env['create_uninstall_target'](env, target)
else:
target_path = os.path.normpath(install_prefix + '/' + env['LIBDIR_SCHEMA'])
if 'uninstall' not in COMMAND_LINE_TARGETS:
result = env.Install(target_path, mapnik)
env.Alias(target='install', source=result)
env['create_uninstall_target'](env, os.path.join(target_path,mapnik_libname))
includes = glob.glob('../include/mapnik/*.hpp')
inc_target = os.path.normpath(install_prefix+'/include/mapnik')
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Alias(target='install', source=env.Install(inc_target, includes))
env['create_uninstall_target'](env, inc_target)