2013-11-06 01:54:13 +01:00
|
|
|
#
|
|
|
|
# This file is part of Mapnik (c++ mapping toolkit)
|
|
|
|
#
|
2015-06-16 12:49:16 +02:00
|
|
|
# Copyright (C) 2015 Artem Pavlenko
|
2013-11-06 01:54:13 +01:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
#
|
2010-07-18 23:34:08 +02:00
|
|
|
|
|
|
|
import re
|
|
|
|
import os
|
2011-08-13 19:07:05 +02:00
|
|
|
import sys
|
2011-08-29 23:12:22 +02:00
|
|
|
from copy import copy
|
2012-08-22 23:44:58 +02:00
|
|
|
from subprocess import Popen, PIPE
|
2010-07-18 23:34:08 +02:00
|
|
|
|
2011-06-29 16:44:40 +02:00
|
|
|
Import('env')
|
2011-08-13 19:07:05 +02:00
|
|
|
|
2011-06-29 16:44:40 +02:00
|
|
|
config_env = env.Clone()
|
|
|
|
|
2015-10-12 22:42:08 +02:00
|
|
|
|
|
|
|
def GetMapnikLibVersion():
|
|
|
|
ver = []
|
|
|
|
for line in open('../../include/mapnik/version.hpp').readlines():
|
|
|
|
if line.startswith('#define MAPNIK_MAJOR_VERSION'):
|
|
|
|
ver.append(line.split(' ')[2].strip())
|
|
|
|
if line.startswith('#define MAPNIK_MINOR_VERSION'):
|
|
|
|
ver.append(line.split(' ')[2].strip())
|
|
|
|
if line.startswith('#define MAPNIK_PATCH_VERSION'):
|
|
|
|
ver.append(line.split(' ')[2].strip())
|
|
|
|
version_string = ".".join(ver)
|
|
|
|
return version_string
|
|
|
|
|
|
|
|
if (GetMapnikLibVersion() != config_env['MAPNIK_VERSION_STRING']):
|
|
|
|
print 'Error: version.hpp mismatch (%s) to cached value (%s): please reconfigure mapnik' % (GetMapnikLibVersion(),config_env['MAPNIK_VERSION_STRING'])
|
|
|
|
Exit(1)
|
|
|
|
|
2015-05-24 22:16:31 +02:00
|
|
|
config_variables = '''#!/usr/bin/env bash
|
2011-08-13 19:07:05 +02:00
|
|
|
|
|
|
|
## variables
|
|
|
|
|
2013-03-15 21:31:10 +01:00
|
|
|
CONFIG_PREFIX="$( cd "$( dirname $( dirname "$0" ))" && pwd )"
|
|
|
|
|
2013-05-10 22:45:18 +02:00
|
|
|
CONFIG_MAPNIK_VERSION_STRING='%(version_string)s'
|
2011-08-13 19:07:05 +02:00
|
|
|
CONFIG_MAPNIK_VERSION='%(version)s'
|
2013-03-14 03:49:59 +01:00
|
|
|
CONFIG_GIT_REVISION='%(git_revision)s'
|
|
|
|
CONFIG_GIT_DESCRIBE='%(git_describe)s'
|
2013-03-15 21:31:10 +01:00
|
|
|
CONFIG_FONTS="%(fonts)s"
|
|
|
|
CONFIG_INPUT_PLUGINS="%(input_plugins)s"
|
2013-03-14 03:49:59 +01:00
|
|
|
CONFIG_MAPNIK_DEFINES='%(defines)s'
|
|
|
|
CONFIG_MAPNIK_LIBNAME='%(mapnik_libname)s'
|
2013-03-15 21:31:10 +01:00
|
|
|
CONFIG_MAPNIK_LIBPATH="%(mapnik_libpath)s"
|
2013-03-14 03:49:59 +01:00
|
|
|
CONFIG_DEP_LIBS='%(dep_libs)s'
|
2014-01-20 01:31:17 +01:00
|
|
|
CONFIG_MAPNIK_LDFLAGS="%(ldflags)s"
|
2013-03-14 03:49:59 +01:00
|
|
|
CONFIG_MAPNIK_INCLUDE="${CONFIG_PREFIX}/include -I${CONFIG_PREFIX}/include/mapnik/agg"
|
2014-01-20 01:31:17 +01:00
|
|
|
CONFIG_DEP_INCLUDES="%(dep_includes)s"
|
|
|
|
CONFIG_CXXFLAGS="%(cxxflags)s"
|
2013-05-10 22:24:41 +02:00
|
|
|
CONFIG_CXX='%(cxx)s'
|
2015-04-28 01:02:41 +02:00
|
|
|
CONFIG_MAPNIK_GDAL_DATA='%(mapnik_bundled_gdal_data)s'
|
|
|
|
CONFIG_MAPNIK_PROJ_LIB='%(mapnik_bundled_proj_data)s'
|
|
|
|
CONFIG_MAPNIK_ICU_DATA='%(mapnik_bundled_icu_data)s'
|
2011-08-13 19:07:05 +02:00
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
def write_config(configuration,template,config_file):
|
|
|
|
template = open(template,'r').read()
|
|
|
|
open(config_file,'w').write(config_variables % configuration + template)
|
|
|
|
try:
|
|
|
|
os.chmod(config_file,0755)
|
|
|
|
except: pass
|
|
|
|
|
2013-03-14 03:49:59 +01:00
|
|
|
cxxflags = ' '.join(config_env['LIBMAPNIK_CXXFLAGS'])
|
2011-06-29 16:44:40 +02:00
|
|
|
|
2013-03-14 03:49:59 +01:00
|
|
|
defines = ' '.join(config_env['LIBMAPNIK_DEFINES'])
|
2011-09-01 17:06:11 +02:00
|
|
|
|
2015-06-15 21:53:42 +02:00
|
|
|
dep_includes = ''.join([' -I${NODE_CONFIG_PREFIX:-""}%s' % i for i in config_env['CPPPATH'] if not i.startswith('#')])
|
2010-07-18 23:34:08 +02:00
|
|
|
|
2013-03-14 03:49:59 +01:00
|
|
|
dep_includes += ' '
|
2011-09-01 17:06:11 +02:00
|
|
|
|
2011-08-30 07:17:50 +02:00
|
|
|
if config_env['HAS_CAIRO']:
|
2015-06-15 23:25:59 +02:00
|
|
|
dep_includes += ''.join([' -I${NODE_CONFIG_PREFIX:-""}%s' % i for i in env['CAIRO_CPPPATHS'] if not i.startswith('#')])
|
2011-09-01 17:06:11 +02:00
|
|
|
|
2013-10-22 22:35:46 +02:00
|
|
|
ldflags = ''.join([' -L%s' % i for i in config_env['LIBPATH'] if not i.startswith('#')])
|
2013-05-16 20:33:23 +02:00
|
|
|
ldflags += config_env['LIBMAPNIK_LINKFLAGS']
|
2010-07-18 23:34:08 +02:00
|
|
|
|
2011-08-13 19:07:05 +02:00
|
|
|
dep_libs = ''.join([' -l%s' % i for i in env['LIBMAPNIK_LIBS']])
|
2010-07-18 23:34:08 +02:00
|
|
|
|
2012-05-25 02:05:51 +02:00
|
|
|
# remove local agg from public linking
|
|
|
|
dep_libs = dep_libs.replace('-lagg','')
|
2011-08-22 18:58:40 +02:00
|
|
|
|
2014-10-23 10:00:35 +02:00
|
|
|
git_revision = 'N/A'
|
|
|
|
git_describe = config_env['MAPNIK_VERSION_STRING']
|
2014-10-23 09:42:10 +02:00
|
|
|
|
|
|
|
try:
|
2012-08-22 23:44:58 +02:00
|
|
|
git_cmd = "git rev-list --max-count=1 HEAD"
|
|
|
|
stdin, stderr = Popen(git_cmd, shell=True, stdout=PIPE, stderr=PIPE).communicate()
|
|
|
|
if not stderr:
|
|
|
|
git_revision = stdin.strip()
|
2011-10-19 00:22:47 +02:00
|
|
|
|
2013-03-14 03:49:59 +01:00
|
|
|
git_cmd = "git describe"
|
|
|
|
stdin, stderr = Popen(git_cmd, shell=True, stdout=PIPE, stderr=PIPE).communicate()
|
|
|
|
if not stderr:
|
|
|
|
git_describe = stdin.strip()
|
2014-10-23 09:42:10 +02:00
|
|
|
except:
|
|
|
|
pass
|
2013-03-14 03:49:59 +01:00
|
|
|
|
2013-03-15 21:31:10 +01:00
|
|
|
# for fonts and input plugins we should try
|
|
|
|
# to store the relative path, if feasible
|
|
|
|
fontspath = config_env['MAPNIK_FONTS']
|
2014-01-20 01:31:17 +01:00
|
|
|
lib_root = os.path.join(config_env['PREFIX'], config_env['LIBDIR_SCHEMA'])
|
2013-03-15 21:31:10 +01:00
|
|
|
if lib_root in fontspath:
|
2014-01-20 01:31:17 +01:00
|
|
|
fontspath = "${CONFIG_PREFIX}/" + os.path.relpath(fontspath,config_env['PREFIX'])
|
2013-03-15 21:31:10 +01:00
|
|
|
inputpluginspath = config_env['MAPNIK_INPUT_PLUGINS']
|
|
|
|
if lib_root in inputpluginspath:
|
2014-01-20 01:31:17 +01:00
|
|
|
inputpluginspath = "${CONFIG_PREFIX}/" + os.path.relpath(inputpluginspath,config_env['PREFIX'])
|
2013-03-15 21:31:10 +01:00
|
|
|
|
|
|
|
lib_path = "${CONFIG_PREFIX}/" + config_env['LIBDIR_SCHEMA']
|
|
|
|
|
2015-04-28 01:02:41 +02:00
|
|
|
mapnik_bundled_gdal_data = ''
|
|
|
|
mapnik_bundled_proj_data = ''
|
|
|
|
mapnik_bundled_icu_data = ''
|
|
|
|
|
|
|
|
if config_env.get('MAPNIK_BUNDLED_SHARE_DIRECTORY'):
|
|
|
|
mapnik_bundled_gdal_data = 'lib/mapnik/share/gdal'
|
|
|
|
mapnik_bundled_proj_data = 'lib/mapnik/share/proj'
|
|
|
|
mapnik_bundled_icu_data = 'lib/mapnik/share/icu'
|
|
|
|
|
2011-08-13 19:07:05 +02:00
|
|
|
configuration = {
|
2013-03-14 03:49:59 +01:00
|
|
|
"git_revision": git_revision,
|
|
|
|
"git_describe": git_describe,
|
2013-05-10 22:45:18 +02:00
|
|
|
"version_string": config_env['MAPNIK_VERSION_STRING'],
|
|
|
|
"version": config_env['MAPNIK_VERSION'],
|
2014-06-09 22:55:56 +02:00
|
|
|
"mapnik_libname": env['MAPNIK_NAME'],
|
2013-03-15 21:31:10 +01:00
|
|
|
"mapnik_libpath": lib_path,
|
2011-08-13 19:07:05 +02:00
|
|
|
"ldflags": ldflags,
|
|
|
|
"dep_libs": dep_libs,
|
2013-03-14 03:49:59 +01:00
|
|
|
"dep_includes": dep_includes,
|
2013-03-15 21:31:10 +01:00
|
|
|
"fonts": fontspath,
|
|
|
|
"input_plugins": inputpluginspath,
|
2013-03-14 03:49:59 +01:00
|
|
|
"defines":defines,
|
2013-05-10 22:24:41 +02:00
|
|
|
"cxxflags":cxxflags,
|
2015-04-28 01:02:41 +02:00
|
|
|
"cxx":env['CXX'],
|
|
|
|
"mapnik_bundled_gdal_data":mapnik_bundled_gdal_data,
|
|
|
|
"mapnik_bundled_proj_data":mapnik_bundled_proj_data,
|
|
|
|
"mapnik_bundled_icu_data":mapnik_bundled_icu_data,
|
2011-08-13 19:07:05 +02:00
|
|
|
}
|
2010-07-18 23:34:08 +02:00
|
|
|
|
2013-01-24 07:00:25 +01:00
|
|
|
## if we are statically linking depedencies
|
|
|
|
## then they do not need to be reported in ldflags
|
2013-04-11 02:05:33 +02:00
|
|
|
#if env['RUNTIME_LINK'] == 'static':
|
|
|
|
# configuration['ldflags'] = ''
|
|
|
|
# configuration['dep_libs'] = ''
|
2010-07-18 23:34:08 +02:00
|
|
|
|
2011-08-13 19:07:05 +02:00
|
|
|
template = 'mapnik-config.template.sh'
|
|
|
|
config_file = 'mapnik-config'
|
|
|
|
source = config_file
|
|
|
|
write_config(configuration,template,config_file)
|
|
|
|
target_path = os.path.normpath(os.path.join(config_env['INSTALL_PREFIX'],'bin'))
|
|
|
|
full_target = os.path.join(target_path,config_file)
|
2010-07-18 23:40:24 +02:00
|
|
|
|
2014-10-23 08:46:33 +02:00
|
|
|
Depends(full_target, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
|
2015-10-12 22:42:08 +02:00
|
|
|
Depends(full_target, '../../include/mapnik/version.hpp')
|
2011-08-29 23:12:22 +02:00
|
|
|
|
2010-07-18 23:34:08 +02:00
|
|
|
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)
|
2011-10-19 00:22:47 +02:00
|
|
|
|
2011-08-13 19:07:05 +02:00
|
|
|
env.Command(full_target, config_file,
|
2010-07-18 23:34:08 +02:00
|
|
|
[
|
|
|
|
Copy("$TARGET","$SOURCE"),
|
|
|
|
Chmod("$TARGET", 0755),
|
|
|
|
])
|
|
|
|
|
2011-08-13 19:07:05 +02:00
|
|
|
config_env['create_uninstall_target'](env,os.path.join(target_path,config_file))
|