From 31c60dc0663c493dfacf9df79ddc8aa1e96fbaec Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 18 Jul 2010 21:34:08 +0000 Subject: [PATCH] add mapnik-config script and pkg-config file - #175 --- SConstruct | 3 + utils/mapnik-config/SConscript | 103 +++++++++++++++++++++ utils/mapnik-config/mapnik-config.template | 99 ++++++++++++++++++++ 3 files changed, 205 insertions(+) create mode 100644 utils/mapnik-config/SConscript create mode 100755 utils/mapnik-config/mapnik-config.template diff --git a/SConstruct b/SConstruct index 96377b6b4..950810e4b 100644 --- a/SConstruct +++ b/SConstruct @@ -1266,3 +1266,6 @@ if not HELP_REQUESTED: # build C++ tests SConscript('tests/cpp_tests/SConscript') + + # install pkg-config script and mapnik-config script + SConscript('utils/mapnik-config/SConscript') diff --git a/utils/mapnik-config/SConscript b/utils/mapnik-config/SConscript new file mode 100644 index 000000000..741fbe749 --- /dev/null +++ b/utils/mapnik-config/SConscript @@ -0,0 +1,103 @@ +# +# 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 ('env') +import re +import os + +prefix = env['PREFIX'] +install_prefix = env['DESTDIR'] + '/' + prefix +LIBDIR_SCHEMA = env['LIBDIR_SCHEMA'] +version = env['MAPNIK_VERSION_STRING'] +mapnik_libname = 'mapnik2' + +filesystem = 'boost_filesystem%s' % env['BOOST_APPEND'] +regex = 'boost_regex%s' % env['BOOST_APPEND'] + +private_libs = '-lfreetype -l%s -l%s -l%s' % (env['ICU_LIB_NAME'],filesystem,regex) + +if env['THREADING'] == 'multi': + private_libs += ' -lboost_thread%s' % env['BOOST_APPEND'] + +if env['HAS_BOOST_SYSTEM']: + private_libs += ' -lboost_system%s' % env['BOOST_APPEND'] + +if env['HAS_CAIRO']: + private_libs += '-lcairomm-1.0 -lcairo' + +other_libs = private_libs + ' '.join(['-L%s' % i for i in env['LIBPATH'] if not i.startswith('#')]) + +# todo - refine this list +other_includes = ' '.join(['-I%s' % i for i in env['CPPPATH'] if not i.startswith('#')]) + +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' +''' % locals() + + +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 + +if 'install' in COMMAND_LINE_TARGETS: + # we must add 'install' catch here because otherwise + # custom command will be run when not installing + target_path = os.path.normpath(install_prefix+'/bin') + full_target = os.path.join(target_path,source) + env.Alias('install',full_target) + env.Command(full_target, source, + [ + Copy("$TARGET","$SOURCE"), + Chmod("$TARGET", 0755), + ]) + +source = 'mapnik.pc' +open(source,'w').write(top+pkg_config) +try: + os.chmod(source,0666) +except: pass +target_path = os.path.normpath(install_prefix+'/lib/pkgconfig') +env.Install(target_path,source) +env.Alias('install',target_path) diff --git a/utils/mapnik-config/mapnik-config.template b/utils/mapnik-config/mapnik-config.template new file mode 100755 index 000000000..1fe80dc21 --- /dev/null +++ b/utils/mapnik-config/mapnik-config.template @@ -0,0 +1,99 @@ +usage() +{ + cat <