2010-07-18 21:34:08 +00:00
|
|
|
|
|
|
|
import re
|
|
|
|
import os
|
2011-08-13 17:07:05 +00:00
|
|
|
import sys
|
2011-08-29 21:12:22 +00:00
|
|
|
from copy import copy
|
2012-08-22 21:44:58 +00:00
|
|
|
from subprocess import Popen, PIPE
|
2010-07-18 21:34:08 +00:00
|
|
|
|
2011-06-29 14:44:40 +00:00
|
|
|
Import('env')
|
2011-08-13 17:07:05 +00:00
|
|
|
|
2011-06-29 14:44:40 +00:00
|
|
|
config_env = env.Clone()
|
|
|
|
|
2011-08-13 17:07:05 +00:00
|
|
|
config_variables = '''#!/bin/sh
|
|
|
|
|
|
|
|
## variables
|
|
|
|
|
2013-03-15 20:31:10 +00:00
|
|
|
CONFIG_PREFIX="$( cd "$( dirname $( dirname "$0" ))" && pwd )"
|
|
|
|
|
2013-05-10 20:45:18 +00:00
|
|
|
CONFIG_MAPNIK_VERSION_STRING='%(version_string)s'
|
2011-08-13 17:07:05 +00:00
|
|
|
CONFIG_MAPNIK_VERSION='%(version)s'
|
2013-03-14 02:49:59 +00:00
|
|
|
CONFIG_GIT_REVISION='%(git_revision)s'
|
|
|
|
CONFIG_GIT_DESCRIBE='%(git_describe)s'
|
2013-03-15 20:31:10 +00:00
|
|
|
CONFIG_FONTS="%(fonts)s"
|
|
|
|
CONFIG_INPUT_PLUGINS="%(input_plugins)s"
|
2013-03-14 02:49:59 +00:00
|
|
|
CONFIG_MAPNIK_DEFINES='%(defines)s'
|
|
|
|
CONFIG_MAPNIK_LIBNAME='%(mapnik_libname)s'
|
2013-03-15 20:31:10 +00:00
|
|
|
CONFIG_MAPNIK_LIBPATH="%(mapnik_libpath)s"
|
2013-03-14 02:49:59 +00:00
|
|
|
CONFIG_DEP_LIBS='%(dep_libs)s'
|
|
|
|
CONFIG_MAPNIK_LDFLAGS='%(ldflags)s'
|
|
|
|
CONFIG_MAPNIK_INCLUDE="${CONFIG_PREFIX}/include -I${CONFIG_PREFIX}/include/mapnik/agg"
|
|
|
|
CONFIG_DEP_INCLUDES='%(dep_includes)s'
|
|
|
|
CONFIG_CXXFLAGS='%(cxxflags)s'
|
2013-05-10 20:24:41 +00:00
|
|
|
CONFIG_CXX='%(cxx)s'
|
2011-08-13 17:07:05 +00: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 02:49:59 +00:00
|
|
|
cxxflags = ' '.join(config_env['LIBMAPNIK_CXXFLAGS'])
|
2011-06-29 14:44:40 +00:00
|
|
|
|
2013-03-14 02:49:59 +00:00
|
|
|
defines = ' '.join(config_env['LIBMAPNIK_DEFINES'])
|
2011-09-01 15:06:11 +00:00
|
|
|
|
2013-03-14 02:49:59 +00:00
|
|
|
dep_includes = ''.join([' -I%s' % i for i in config_env['CPPPATH'] if not i.startswith('#')])
|
2010-07-18 21:34:08 +00:00
|
|
|
|
2013-03-14 02:49:59 +00:00
|
|
|
dep_includes += ' '
|
2011-09-01 15:06:11 +00:00
|
|
|
|
2011-08-30 05:17:50 +00:00
|
|
|
if config_env['HAS_CAIRO']:
|
2013-03-14 02:49:59 +00:00
|
|
|
dep_includes += ''.join([' -I%s' % i for i in env['CAIRO_CPPPATHS'] if not i.startswith('#')])
|
2011-09-01 15:06:11 +00:00
|
|
|
|
2011-08-13 17:07:05 +00:00
|
|
|
ldflags = config_env['CUSTOM_LDFLAGS'] + ''.join([' -L%s' % i for i in config_env['LIBPATH'] if not i.startswith('#')])
|
2013-05-16 18:33:23 +00:00
|
|
|
ldflags += config_env['LIBMAPNIK_LINKFLAGS']
|
2010-07-18 21:34:08 +00:00
|
|
|
|
2011-08-13 17:07:05 +00:00
|
|
|
dep_libs = ''.join([' -l%s' % i for i in env['LIBMAPNIK_LIBS']])
|
2010-07-18 21:34:08 +00:00
|
|
|
|
2012-05-25 00:05:51 +00:00
|
|
|
# remove local agg from public linking
|
|
|
|
dep_libs = dep_libs.replace('-lagg','')
|
2011-08-22 16:58:40 +00:00
|
|
|
|
2012-08-22 21:44:58 +00:00
|
|
|
git_revision = 'unknown'
|
2013-03-14 02:49:59 +00:00
|
|
|
git_describe = 'unknown'
|
|
|
|
# special GIT_REVISION/GIT_DESCRIBE files present only for official releases
|
|
|
|
# where the git directory metadata is stripped
|
2012-08-22 21:44:58 +00:00
|
|
|
# more info: https://github.com/mapnik/mapnik/wiki/MapnikReleaseSteps
|
|
|
|
revision_release_file = '../../GIT_REVISION'
|
|
|
|
if os.path.exists(revision_release_file):
|
|
|
|
git_revision = open(revision_release_file,'r').read()
|
|
|
|
else:
|
|
|
|
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-18 22:22:47 +00:00
|
|
|
|
2013-03-14 02:49:59 +00:00
|
|
|
describe_release_file = '../../GIT_DESCRIBE'
|
|
|
|
if os.path.exists(describe_release_file):
|
|
|
|
git_describe = open(describe_release_file,'r').read()
|
|
|
|
else:
|
|
|
|
git_cmd = "git describe"
|
|
|
|
stdin, stderr = Popen(git_cmd, shell=True, stdout=PIPE, stderr=PIPE).communicate()
|
|
|
|
if not stderr:
|
|
|
|
git_describe = stdin.strip()
|
|
|
|
|
2013-03-15 20:31:10 +00:00
|
|
|
# for fonts and input plugins we should try
|
|
|
|
# to store the relative path, if feasible
|
|
|
|
fontspath = config_env['MAPNIK_FONTS']
|
|
|
|
lib_root = os.path.join(config_env['INSTALL_PREFIX'], config_env['LIBDIR_SCHEMA'])
|
|
|
|
if lib_root in fontspath:
|
|
|
|
fontspath = "${CONFIG_PREFIX}/" + os.path.relpath(fontspath,config_env['INSTALL_PREFIX'])
|
|
|
|
inputpluginspath = config_env['MAPNIK_INPUT_PLUGINS']
|
|
|
|
if lib_root in inputpluginspath:
|
|
|
|
inputpluginspath = "${CONFIG_PREFIX}/" + os.path.relpath(inputpluginspath,config_env['INSTALL_PREFIX'])
|
|
|
|
|
|
|
|
lib_path = "${CONFIG_PREFIX}/" + config_env['LIBDIR_SCHEMA']
|
|
|
|
|
2011-08-13 17:07:05 +00:00
|
|
|
configuration = {
|
2013-03-14 02:49:59 +00:00
|
|
|
"git_revision": git_revision,
|
|
|
|
"git_describe": git_describe,
|
2013-05-10 20:45:18 +00:00
|
|
|
"version_string": config_env['MAPNIK_VERSION_STRING'],
|
|
|
|
"version": config_env['MAPNIK_VERSION'],
|
2011-11-23 11:33:58 +00:00
|
|
|
"mapnik_libname": 'mapnik',
|
2013-03-15 20:31:10 +00:00
|
|
|
"mapnik_libpath": lib_path,
|
2011-08-13 17:07:05 +00:00
|
|
|
"ldflags": ldflags,
|
|
|
|
"dep_libs": dep_libs,
|
2013-03-14 02:49:59 +00:00
|
|
|
"dep_includes": dep_includes,
|
2013-03-15 20:31:10 +00:00
|
|
|
"fonts": fontspath,
|
|
|
|
"input_plugins": inputpluginspath,
|
2013-03-14 02:49:59 +00:00
|
|
|
"defines":defines,
|
2013-05-10 20:24:41 +00:00
|
|
|
"cxxflags":cxxflags,
|
|
|
|
"cxx":env['CXX']
|
2011-08-13 17:07:05 +00:00
|
|
|
}
|
2010-07-18 21:34:08 +00:00
|
|
|
|
2013-01-24 06:00:25 +00:00
|
|
|
## if we are statically linking depedencies
|
|
|
|
## then they do not need to be reported in ldflags
|
2013-04-11 00:05:33 +00:00
|
|
|
#if env['RUNTIME_LINK'] == 'static':
|
|
|
|
# configuration['ldflags'] = ''
|
|
|
|
# configuration['dep_libs'] = ''
|
2010-07-18 21:34:08 +00:00
|
|
|
|
2011-08-13 17:07:05 +00: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 21:40:24 +00:00
|
|
|
|
2011-08-29 21:12:22 +00:00
|
|
|
Depends(full_target, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
|
|
|
|
|
2010-07-18 21:34:08 +00: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-18 22:22:47 +00:00
|
|
|
|
2011-08-13 17:07:05 +00:00
|
|
|
env.Command(full_target, config_file,
|
2010-07-18 21:34:08 +00:00
|
|
|
[
|
|
|
|
Copy("$TARGET","$SOURCE"),
|
|
|
|
Chmod("$TARGET", 0755),
|
|
|
|
])
|
|
|
|
|
2011-08-13 17:07:05 +00:00
|
|
|
config_env['create_uninstall_target'](env,os.path.join(target_path,config_file))
|