# # 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 re import os # clone the environment so changes # here to no affect the main build env Import('env') config_env = env.Clone() mapnik_libname = 'mapnik2' # recreate a few dynamic path additions if config_env['HAS_CAIRO']: # attach libs to library linking environment try: config_env.ParseConfig('pkg-config --libs cairomm-1.0') config_env.Append(CXXFLAGS = '-DHAVE_CAIRO') config_env.ParseConfig('pkg-config --cflags cairomm-1.0') except OSError, e: print '\nFailed to detect cairo/cairomm configuration, please re-run "python scons/scons.py configure"' sys.exit(1) prefix = config_env['PREFIX'] install_prefix = config_env['DESTDIR'] + '/' + prefix LIBDIR_SCHEMA = config_env['LIBDIR_SCHEMA'] version = config_env['MAPNIK_VERSION_STRING'] input_plugins = os.path.normpath(config_env['PREFIX'] + '/' + config_env['LIBDIR_SCHEMA'] + config_env['LIB_DIR_NAME'] + "/input" ) if config_env['SYSTEM_FONTS']: fonts = os.path.normpath(config_env['SYSTEM_FONTS']) else: fonts = os.path.normpath(prefix + '/' + config_env['LIBDIR_SCHEMA'] + config_env['LIB_DIR_NAME'] + '/fonts') svn_revision = config_env['SVN_REVISION'] filesystem = 'boost_filesystem%s' % config_env['BOOST_APPEND'] regex = 'boost_regex%s' % config_env['BOOST_APPEND'] # todo - refine this list other_includes = config_env['CUSTOM_CXXFLAGS'] + config_env['CXXFLAGS'] + ''.join([' -I%s' % i for i in config_env['CPPPATH'] if not i.startswith('#')]) private_libs = ' -lfreetype -l%s -l%s -l%s' % (config_env['ICU_LIB_NAME'],filesystem,regex) #if config_env['HAS_CAIRO']: # private_libs += ' -lcairomm-1.0 -lcairo' # other_includes.append('-DHAVE_CAIRO') if config_env['XMLPARSER'] == 'libxml2' and config_env['HAS_LIBXML2']: config_env.Append(CXXFLAGS = '-DHAVE_LIBXML2') if config_env['THREADING'] == 'multi': private_libs += ' -lboost_thread%s' % config_env['BOOST_APPEND'] if config_env['HAS_BOOST_SYSTEM']: private_libs += ' -lboost_system%s' % config_env['BOOST_APPEND'] if not config_env['INTERNAL_LIBAGG']: for lib in config_env['LIBS']: if lib.startswith('agg'): private_libs += ' -l%s' % lib if config_env['SVG_RENDERER']: other_includes.append('-DSVG_RENDERER') if config_env['LIBTOOL_SUPPORTS_ADVISE']: other_includes.append('-DLIBTOOL_SUPPORTS_ADVISE') other_libs = config_env['CUSTOM_LDFLAGS'] + ''.join([' -L%s' % i for i in config_env['LIBPATH'] if not i.startswith('#')]) other_libs += private_libs top = '''#!/bin/sh prefix=%(prefix)s exec_prefix=${prefix} includedir=${prefix}/include libdir=${exec_prefix}/%(LIBDIR_SCHEMA)s version='%(version)s' mapnik_libname=%(mapnik_libname)s private_libs='%(private_libs)s' other_libs='%(other_libs)s' other_includes='%(other_includes)s' fonts='%(fonts)s' input_plugins='%(input_plugins)s' svn_revision='%(svn_revision)s' ''' % locals() # TODO - add fonts and input_plugins to pkg-config? pkg_config = ''' Name: libmapnik Version: ${version} Description: libmapnik library. Requires: Libs: -L${libdir} -l${mapnik_libname} Libs.private: ${private_libs} Cflags: -I${includedir} ''' template = open('mapnik-config.template','r').read() source = 'mapnik-config' open(source,'w').write(top+template) try: os.chmod(source,0666) except: pass target_path = os.path.normpath(install_prefix+'/bin') full_target = os.path.join(target_path,source) if 'install' in COMMAND_LINE_TARGETS: # we must add 'install' catch here because otherwise # custom command will be run when not installing env.Alias('install',full_target) env.Command(full_target, source, [ Copy("$TARGET","$SOURCE"), Chmod("$TARGET", 0755), ]) config_env['create_uninstall_target'](env,os.path.join(target_path,source)) source = 'mapnik2.pc' open(source,'w').write(top+pkg_config) try: os.chmod(source,0666) except: pass target_path = os.path.normpath(install_prefix+'/'+LIBDIR_SCHEMA+'/pkgconfig') full_target = os.path.join(target_path,source) if 'install' in COMMAND_LINE_TARGETS: env.Install(target_path,source) env.Alias('install',target_path) config_env['create_uninstall_target'](env,full_target)