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()
|
|
|
|
|
2011-08-13 19:07:05 +02:00
|
|
|
# TODO
|
|
|
|
# major/minor versions
|
2011-10-19 00:22:47 +02:00
|
|
|
# git rev-list --max-count=1 HEAD
|
2011-08-13 19:07:05 +02:00
|
|
|
|
|
|
|
config_variables = '''#!/bin/sh
|
|
|
|
|
|
|
|
## variables
|
|
|
|
|
|
|
|
CONFIG_PREFIX=%(prefix)s
|
|
|
|
CONFIG_MAPNIK_LIBNAME=%(mapnik_libname)s
|
|
|
|
CONFIG_MAPNIK_INCLUDE=${CONFIG_PREFIX}/include
|
|
|
|
CONFIG_MAPNIK_LIB=${CONFIG_PREFIX}/%(libdir_schema)s
|
|
|
|
CONFIG_MAPNIK_VERSION='%(version)s'
|
|
|
|
CONFIG_MAPNIK_LDFLAGS='%(ldflags)s'
|
|
|
|
CONFIG_DEP_LIBS='%(dep_libs)s'
|
|
|
|
CONFIG_OTHER_INCLUDES='%(other_includes)s'
|
|
|
|
CONFIG_FONTS='%(fonts)s'
|
|
|
|
CONFIG_INPUT_PLUGINS='%(input_plugins)s'
|
2011-10-19 00:22:47 +02:00
|
|
|
CONFIG_GIT_REVISION='%(git_revision)s'
|
2012-08-28 03:45:04 +02:00
|
|
|
CONFIG_MAPNIK_AGG_INCLUDE=${CONFIG_PREFIX}/include/mapnik/agg
|
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
|
|
|
|
|
2011-06-29 16:44:40 +02:00
|
|
|
|
2011-08-13 19:07:05 +02:00
|
|
|
# todo - refine this list
|
2011-09-01 17:06:11 +02:00
|
|
|
|
2011-08-30 01:02:57 +02:00
|
|
|
other_includes = ''.join([' -I%s' % i for i in config_env['CPPPATH'] if not i.startswith('#')])
|
2011-03-04 23:05:29 +01:00
|
|
|
|
2011-09-01 17:06:11 +02:00
|
|
|
other_includes += ' '
|
|
|
|
|
2011-08-30 01:02:57 +02:00
|
|
|
other_includes += ' '.join(config_env['LIBMAPNIK_CXXFLAGS'])
|
2010-07-18 23:34:08 +02:00
|
|
|
|
2011-09-01 17:06:11 +02:00
|
|
|
other_includes += ' '
|
|
|
|
|
2011-08-30 07:17:50 +02:00
|
|
|
if config_env['HAS_CAIRO']:
|
2011-10-19 00:22:47 +02:00
|
|
|
other_includes += ''.join([' -I%s' % i for i in env['CAIROMM_CPPPATHS'] if not i.startswith('#')])
|
2011-08-30 07:17:50 +02:00
|
|
|
|
2011-09-01 17:06:11 +02:00
|
|
|
|
2011-08-13 19:07:05 +02:00
|
|
|
ldflags = config_env['CUSTOM_LDFLAGS'] + ''.join([' -L%s' % i for i in config_env['LIBPATH'] if not i.startswith('#')])
|
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
|
|
|
|
2012-08-22 23:44:58 +02:00
|
|
|
git_revision = 'unknown'
|
|
|
|
# present only for official releases where git metadata is stripped
|
|
|
|
# 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-19 00:22:47 +02:00
|
|
|
|
2011-08-13 19:07:05 +02:00
|
|
|
configuration = {
|
|
|
|
"prefix": config_env['PREFIX'],
|
2011-11-23 12:33:58 +01:00
|
|
|
"mapnik_libname": 'mapnik',
|
2011-08-13 19:07:05 +02:00
|
|
|
"libdir_schema": config_env['LIBDIR_SCHEMA'],
|
|
|
|
"ldflags": ldflags,
|
|
|
|
"dep_libs": dep_libs,
|
|
|
|
"other_includes": other_includes,
|
|
|
|
"fonts": config_env['MAPNIK_FONTS'],
|
|
|
|
"input_plugins": config_env['MAPNIK_INPUT_PLUGINS'],
|
2011-10-19 00:22:47 +02:00
|
|
|
"git_revision": git_revision,
|
2011-08-13 19:07:05 +02:00
|
|
|
"version": config_env['MAPNIK_VERSION_STRING'],
|
|
|
|
}
|
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
|
|
|
|
2011-08-29 23:12:22 +02:00
|
|
|
Depends(full_target, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
|
|
|
|
|
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))
|