- fixed unwanted behaviour with default log severity in SConstruct #937

This commit is contained in:
kunitoki 2012-05-24 00:02:43 +02:00
parent f76c6ee25f
commit 0e5dcbd810

View file

@ -81,7 +81,7 @@ pretty_dep_names = {
'sqlite_rtree':'The SQLite plugin requires libsqlite3 built with RTREE support (-DSQLITE_ENABLE_RTREE=1)', 'sqlite_rtree':'The SQLite plugin requires libsqlite3 built with RTREE support (-DSQLITE_ENABLE_RTREE=1)',
'pgsql2sqlite_rtree':'The pgsql2sqlite program requires libsqlite3 built with RTREE support (-DSQLITE_ENABLE_RTREE=1)' 'pgsql2sqlite_rtree':'The pgsql2sqlite program requires libsqlite3 built with RTREE support (-DSQLITE_ENABLE_RTREE=1)'
} }
# Core plugin build configuration # Core plugin build configuration
# opts.AddVariables still hardcoded however... # opts.AddVariables still hardcoded however...
PLUGINS = { # plugins with external dependencies PLUGINS = { # plugins with external dependencies
@ -94,7 +94,7 @@ PLUGINS = { # plugins with external dependencies
'occi': {'default':False,'path':'OCCI','inc':'occi.h','lib':'ociei','lang':'C++'}, 'occi': {'default':False,'path':'OCCI','inc':'occi.h','lib':'ociei','lang':'C++'},
'sqlite': {'default':True,'path':'SQLITE','inc':'sqlite3.h','lib':'sqlite3','lang':'C'}, 'sqlite': {'default':True,'path':'SQLITE','inc':'sqlite3.h','lib':'sqlite3','lang':'C'},
'rasterlite': {'default':False,'path':'RASTERLITE','inc':['sqlite3.h','rasterlite.h'],'lib':'rasterlite','lang':'C'}, 'rasterlite': {'default':False,'path':'RASTERLITE','inc':['sqlite3.h','rasterlite.h'],'lib':'rasterlite','lang':'C'},
# todo: osm plugin does also depend on libxml2 (but there is a separate check for that) # todo: osm plugin does also depend on libxml2 (but there is a separate check for that)
'osm': {'default':True,'path':None,'inc':'curl/curl.h','lib':'curl','lang':'C'}, 'osm': {'default':True,'path':None,'inc':'curl/curl.h','lib':'curl','lang':'C'},
@ -156,7 +156,7 @@ def create_uninstall_target(env, path, is_glob=False):
Delete("$SOURCE"), Delete("$SOURCE"),
]) ])
env.Alias("uninstall", "uninstall-"+path) env.Alias("uninstall", "uninstall-"+path)
def shortest_name(libs): def shortest_name(libs):
name = '-'*200 name = '-'*200
for lib in libs: for lib in libs:
@ -168,20 +168,20 @@ def shortest_name(libs):
def sort_paths(items,priority): def sort_paths(items,priority):
"""Sort paths such that compiling and linking will globally prefer custom or local libs """Sort paths such that compiling and linking will globally prefer custom or local libs
over system libraries by fixing up the order libs are passed to gcc and the linker. over system libraries by fixing up the order libs are passed to gcc and the linker.
Ideally preference could be by-target instead of global, but our SCons implementation Ideally preference could be by-target instead of global, but our SCons implementation
is not currently utilizing different SCons build env()'s as we should. is not currently utilizing different SCons build env()'s as we should.
Overally the current approach within these scripts is to prepend paths of preference Overally the current approach within these scripts is to prepend paths of preference
and append all others, but this does not give enough control (particularly due to the and append all others, but this does not give enough control (particularly due to the
approach of assuming /usr/LIBSCHEMA and letting paths be parsed and added by pkg-config). approach of assuming /usr/LIBSCHEMA and letting paths be parsed and added by pkg-config).
In effect /usr/lib is likely to come before /usr/local/lib which makes linking against In effect /usr/lib is likely to come before /usr/local/lib which makes linking against
custom built icu or boost impossible when those libraries are available in both places. custom built icu or boost impossible when those libraries are available in both places.
Sorting using a priority list allows this to be controlled, and fine tuned. Sorting using a priority list allows this to be controlled, and fine tuned.
""" """
new = [] new = []
path_types = {'internal':[],'other':[],'frameworks':[],'user':[],'system':[]} path_types = {'internal':[],'other':[],'frameworks':[],'user':[],'system':[]}
# parse types of paths into logical/meaningful groups # parse types of paths into logical/meaningful groups
@ -235,7 +235,7 @@ def sort_paths(items,priority):
if platform.dist()[0] in ('Ubuntu','debian'): if platform.dist()[0] in ('Ubuntu','debian'):
LIBDIR_SCHEMA='lib' LIBDIR_SCHEMA='lib'
elif platform.uname()[4] == 'x86_64' and platform.system() == 'Linux': elif platform.uname()[4] == 'x86_64' and platform.system() == 'Linux':
LIBDIR_SCHEMA='lib64' LIBDIR_SCHEMA='lib64'
elif platform.uname()[4] == 'ppc64': elif platform.uname()[4] == 'ppc64':
LIBDIR_SCHEMA='lib64' LIBDIR_SCHEMA='lib64'
else: else:
@ -274,7 +274,7 @@ opts.AddVariables(
BoolVariable('DEBUG_UNDEFINED', 'Compile a version of Mapnik using clang/llvm undefined behavior asserts', 'False'), BoolVariable('DEBUG_UNDEFINED', 'Compile a version of Mapnik using clang/llvm undefined behavior asserts', 'False'),
ListVariable('INPUT_PLUGINS','Input drivers to include',DEFAULT_PLUGINS,PLUGINS.keys()), ListVariable('INPUT_PLUGINS','Input drivers to include',DEFAULT_PLUGINS,PLUGINS.keys()),
('WARNING_CXXFLAGS', 'Compiler flags you can set to reduce warning levels which are placed after -Wall.', ''), ('WARNING_CXXFLAGS', 'Compiler flags you can set to reduce warning levels which are placed after -Wall.', ''),
# SCons build behavior options # SCons build behavior options
('CONFIG', "The path to the python file in which to save user configuration options. Currently : '%s'" % SCONS_LOCAL_CONFIG,SCONS_LOCAL_CONFIG), ('CONFIG', "The path to the python file in which to save user configuration options. Currently : '%s'" % SCONS_LOCAL_CONFIG,SCONS_LOCAL_CONFIG),
BoolVariable('USE_CONFIG', "Use SCons user '%s' file (will also write variables after successful configuration)", 'True'), BoolVariable('USE_CONFIG', "Use SCons user '%s' file (will also write variables after successful configuration)", 'True'),
@ -282,8 +282,8 @@ opts.AddVariables(
# http://stackoverflow.com/questions/1318863/how-to-optimize-an-scons-script # http://stackoverflow.com/questions/1318863/how-to-optimize-an-scons-script
BoolVariable('FAST', "Make SCons faster at the cost of less precise dependency tracking", 'False'), BoolVariable('FAST', "Make SCons faster at the cost of less precise dependency tracking", 'False'),
BoolVariable('PRIORITIZE_LINKING', 'Sort list of lib and inc directories to ensure preferential compiling and linking (useful when duplicate libs)', 'True'), BoolVariable('PRIORITIZE_LINKING', 'Sort list of lib and inc directories to ensure preferential compiling and linking (useful when duplicate libs)', 'True'),
('LINK_PRIORITY','Priority list in which to sort library and include paths (default order is internal, other, frameworks, user, then system - see source of `sort_paths` function for more detail)',','.join(DEFAULT_LINK_PRIORITY)), ('LINK_PRIORITY','Priority list in which to sort library and include paths (default order is internal, other, frameworks, user, then system - see source of `sort_paths` function for more detail)',','.join(DEFAULT_LINK_PRIORITY)),
# Install Variables # Install Variables
('PREFIX', 'The install path "prefix"', '/usr/local'), ('PREFIX', 'The install path "prefix"', '/usr/local'),
('PYTHON_PREFIX','Custom install path "prefix" for python bindings (default of no prefix)',''), ('PYTHON_PREFIX','Custom install path "prefix" for python bindings (default of no prefix)',''),
@ -291,7 +291,7 @@ opts.AddVariables(
('PATH', 'A custom path (or multiple paths divided by ":") to append to the $PATH env to prioritize usage of command line programs (if multiple are present on the system)', ''), ('PATH', 'A custom path (or multiple paths divided by ":") to append to the $PATH env to prioritize usage of command line programs (if multiple are present on the system)', ''),
('PATH_REMOVE', 'A path prefix to exclude from all known command and compile paths', ''), ('PATH_REMOVE', 'A path prefix to exclude from all known command and compile paths', ''),
('PATH_REPLACE', 'Two path prefixes (divided with a :) to search/replace from all known command and compile paths', ''), ('PATH_REPLACE', 'Two path prefixes (divided with a :) to search/replace from all known command and compile paths', ''),
# Boost variables # Boost variables
# default is '/usr/include', see FindBoost method below # default is '/usr/include', see FindBoost method below
('BOOST_INCLUDES', 'Search path for boost include files', '',False), ('BOOST_INCLUDES', 'Search path for boost include files', '',False),
@ -301,7 +301,7 @@ opts.AddVariables(
('BOOST_ABI', 'Specify boost ABI, e.g., d.','',False), ('BOOST_ABI', 'Specify boost ABI, e.g., d.','',False),
('BOOST_VERSION','Specify boost version, e.g., 1_35.','',False), ('BOOST_VERSION','Specify boost version, e.g., 1_35.','',False),
('BOOST_PYTHON_LIB','Specify library name to specific Boost Python lib (e.g. "boost_python-py26")',''), ('BOOST_PYTHON_LIB','Specify library name to specific Boost Python lib (e.g. "boost_python-py26")',''),
# Variables for required dependencies # Variables for required dependencies
('FREETYPE_CONFIG', 'The path to the freetype-config executable.', 'freetype-config'), ('FREETYPE_CONFIG', 'The path to the freetype-config executable.', 'freetype-config'),
('XML2_CONFIG', 'The path to the xml2-config executable.', 'xml2-config'), ('XML2_CONFIG', 'The path to the xml2-config executable.', 'xml2-config'),
@ -310,7 +310,7 @@ opts.AddVariables(
('ICU_LIB_NAME', 'The library name for icu (such as icuuc, sicuuc, or icucore)', 'icuuc'), ('ICU_LIB_NAME', 'The library name for icu (such as icuuc, sicuuc, or icucore)', 'icuuc'),
PathVariable('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include', PathVariable.PathAccept), PathVariable('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include', PathVariable.PathAccept),
PathVariable('PNG_LIBS','Search path for libpng include files','/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept), PathVariable('PNG_LIBS','Search path for libpng include files','/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept),
BoolVariable('JPEG', 'Build Mapnik with JPEG read and write support', 'True'), BoolVariable('JPEG', 'Build Mapnik with JPEG read and write support', 'True'),
PathVariable('JPEG_INCLUDES', 'Search path for libjpeg include files', '/usr/include', PathVariable.PathAccept), PathVariable('JPEG_INCLUDES', 'Search path for libjpeg include files', '/usr/include', PathVariable.PathAccept),
PathVariable('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept), PathVariable('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept),
PathVariable('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include', PathVariable.PathAccept), PathVariable('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include', PathVariable.PathAccept),
@ -318,15 +318,15 @@ opts.AddVariables(
PathVariable('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/local/include', PathVariable.PathAccept), PathVariable('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/local/include', PathVariable.PathAccept),
PathVariable('PROJ_LIBS', 'Search path for PROJ.4 library files', '/usr/local/' + LIBDIR_SCHEMA, PathVariable.PathAccept), PathVariable('PROJ_LIBS', 'Search path for PROJ.4 library files', '/usr/local/' + LIBDIR_SCHEMA, PathVariable.PathAccept),
('PKG_CONFIG_PATH', 'Use this path to point pkg-config to .pc files instead of the PKG_CONFIG_PATH environment setting',''), ('PKG_CONFIG_PATH', 'Use this path to point pkg-config to .pc files instead of the PKG_CONFIG_PATH environment setting',''),
# Variables affecting rendering back-ends # Variables affecting rendering back-ends
BoolVariable('RENDERING_STATS', 'Output rendering statistics during style processing', 'False'), BoolVariable('RENDERING_STATS', 'Output rendering statistics during style processing', 'False'),
BoolVariable('INTERNAL_LIBAGG', 'Use provided libagg', 'True'), BoolVariable('INTERNAL_LIBAGG', 'Use provided libagg', 'True'),
BoolVariable('SVG_RENDERER', 'build support for native svg renderer', 'False'), BoolVariable('SVG_RENDERER', 'build support for native svg renderer', 'False'),
# Variables for optional dependencies # Variables for optional dependencies
('GEOS_CONFIG', 'The path to the geos-config executable.', 'geos-config'), ('GEOS_CONFIG', 'The path to the geos-config executable.', 'geos-config'),
# Note: cairo, cairomm, and pycairo all optional but configured automatically through pkg-config # Note: cairo, cairomm, and pycairo all optional but configured automatically through pkg-config
@ -447,7 +447,7 @@ HELP_REQUESTED = False
if ('-h' in command_line_args) or ('--help' in command_line_args): if ('-h' in command_line_args) or ('--help' in command_line_args):
HELP_REQUESTED = True HELP_REQUESTED = True
if 'configure' in command_line_args and not HELP_REQUESTED: if 'configure' in command_line_args and not HELP_REQUESTED:
force_configure = True force_configure = True
@ -482,10 +482,10 @@ for opt in pickle_store:
# if custom arguments are supplied make sure to accept them # if custom arguments are supplied make sure to accept them
if opts.args: if opts.args:
# since we have custom arguments update environment with all opts to # since we have custom arguments update environment with all opts to
# make sure to absorb the custom ones # make sure to absorb the custom ones
opts.Update(env) opts.Update(env)
# now since we've got custom arguments we'll disregard any # now since we've got custom arguments we'll disregard any
# pickled environment and force another configuration # pickled environment and force another configuration
preconfigured = False preconfigured = False
@ -504,7 +504,7 @@ color_print(4,'\nWelcome to Mapnik...\n')
#### Custom Configure Checks ### #### Custom Configure Checks ###
def prioritize_paths(context,silent=True): def prioritize_paths(context,silent=True):
env = context.env env = context.env
prefs = env['LINK_PRIORITY'].split(',') prefs = env['LINK_PRIORITY'].split(',')
if not silent: if not silent:
@ -572,7 +572,7 @@ def parse_config(context, config, checks='--libs --cflags'):
env['SKIPPED_DEPS'].append(tool) env['SKIPPED_DEPS'].append(tool)
conf.rollback_option(config) conf.rollback_option(config)
else: # freetype and libxml2, not optional else: # freetype and libxml2, not optional
env['MISSING_DEPS'].append(tool) env['MISSING_DEPS'].append(tool)
context.Result( ret ) context.Result( ret )
return ret return ret
@ -637,18 +637,18 @@ def rollback_option(context,variable):
def FindBoost(context, prefixes, thread_flag): def FindBoost(context, prefixes, thread_flag):
"""Routine to auto-find boost header dir, lib dir, and library naming structure. """Routine to auto-find boost header dir, lib dir, and library naming structure.
""" """
context.Message( 'Searching for boost libs and headers... ' ) context.Message( 'Searching for boost libs and headers... ' )
env = context.env env = context.env
BOOST_LIB_DIR = None BOOST_LIB_DIR = None
BOOST_INCLUDE_DIR = None BOOST_INCLUDE_DIR = None
BOOST_APPEND = None BOOST_APPEND = None
env['BOOST_APPEND'] = str() env['BOOST_APPEND'] = str()
if env['THREADING'] == 'multi': if env['THREADING'] == 'multi':
search_lib = 'libboost_thread' search_lib = 'libboost_thread'
else: else:
search_lib = 'libboost_filesystem' search_lib = 'libboost_filesystem'
@ -669,23 +669,23 @@ def FindBoost(context, prefixes, thread_flag):
if hasattr(match,'groups'): if hasattr(match,'groups'):
BOOST_APPEND = match.groups()[0] BOOST_APPEND = match.groups()[0]
break break
msg = str() msg = str()
if BOOST_LIB_DIR: if BOOST_LIB_DIR:
msg += '\n *libs found: %s' % BOOST_LIB_DIR msg += '\n *libs found: %s' % BOOST_LIB_DIR
env['BOOST_LIBS'] = BOOST_LIB_DIR env['BOOST_LIBS'] = BOOST_LIB_DIR
else: else:
env['BOOST_LIBS'] = '/usr/' + LIBDIR_SCHEMA env['BOOST_LIBS'] = '/usr/' + LIBDIR_SCHEMA
msg += '\n *using default boost lib dir: %s' % env['BOOST_LIBS'] msg += '\n *using default boost lib dir: %s' % env['BOOST_LIBS']
if BOOST_INCLUDE_DIR: if BOOST_INCLUDE_DIR:
msg += '\n *headers found: %s' % BOOST_INCLUDE_DIR msg += '\n *headers found: %s' % BOOST_INCLUDE_DIR
env['BOOST_INCLUDES'] = BOOST_INCLUDE_DIR env['BOOST_INCLUDES'] = BOOST_INCLUDE_DIR
else: else:
env['BOOST_INCLUDES'] = '/usr/include' env['BOOST_INCLUDES'] = '/usr/include'
msg += '\n *using default boost include dir: %s' % env['BOOST_INCLUDES'] msg += '\n *using default boost include dir: %s' % env['BOOST_INCLUDES']
if not env['BOOST_TOOLKIT'] and not env['BOOST_ABI'] and not env['BOOST_VERSION']: if not env['BOOST_TOOLKIT'] and not env['BOOST_ABI'] and not env['BOOST_VERSION']:
if BOOST_APPEND: if BOOST_APPEND:
msg += '\n *lib naming extension found: %s' % BOOST_APPEND msg += '\n *lib naming extension found: %s' % BOOST_APPEND
@ -704,12 +704,12 @@ def FindBoost(context, prefixes, thread_flag):
# Constructing the BOOST_APPEND setting that will be used to find the # Constructing the BOOST_APPEND setting that will be used to find the
# Boost libraries. # Boost libraries.
if len(append_params) > 1: if len(append_params) > 1:
env['BOOST_APPEND'] = '-'.join(append_params) env['BOOST_APPEND'] = '-'.join(append_params)
msg += '\n *using boost lib naming: %s' % env['BOOST_APPEND'] msg += '\n *using boost lib naming: %s' % env['BOOST_APPEND']
env.AppendUnique(CPPPATH = os.path.realpath(env['BOOST_INCLUDES'])) env.AppendUnique(CPPPATH = os.path.realpath(env['BOOST_INCLUDES']))
env.AppendUnique(LIBPATH = os.path.realpath(env['BOOST_LIBS'])) env.AppendUnique(LIBPATH = os.path.realpath(env['BOOST_LIBS']))
if env['COLOR_PRINT']: if env['COLOR_PRINT']:
msg = "\033[94m%s\033[0m" % (msg) msg = "\033[94m%s\033[0m" % (msg)
ret = context.Result(msg) ret = context.Result(msg)
@ -725,14 +725,14 @@ def CheckBoost(context, version, silent=False):
version_n += int(v_arr[1])*100 version_n += int(v_arr[1])*100
if len(v_arr) > 2: if len(v_arr) > 2:
version_n += int(v_arr[2]) version_n += int(v_arr[2])
if not silent: if not silent:
context.Message('Checking for Boost version >= %s... ' % (version)) context.Message('Checking for Boost version >= %s... ' % (version))
ret = context.TryRun(""" ret = context.TryRun("""
#include <boost/version.hpp> #include <boost/version.hpp>
int main() int main()
{ {
return BOOST_VERSION >= %d ? 0 : 1; return BOOST_VERSION >= %d ? 0 : 1;
} }
@ -749,7 +749,7 @@ def GetBoostLibVersion(context):
#include <boost/version.hpp> #include <boost/version.hpp>
#include <iostream> #include <iostream>
int main() int main()
{ {
std::cout << BOOST_LIB_VERSION << std::endl; std::cout << BOOST_LIB_VERSION << std::endl;
@ -768,7 +768,7 @@ def GetMapnikLibVersion(context):
#include <mapnik/version.hpp> #include <mapnik/version.hpp>
#include <iostream> #include <iostream>
int main() int main()
{ {
std::cout << MAPNIK_VERSION_STRING << std::endl; std::cout << MAPNIK_VERSION_STRING << std::endl;
return 0; return 0;
@ -788,7 +788,7 @@ def icu_at_least_four_two(context):
#include <unicode/uversion.h> #include <unicode/uversion.h>
#include <iostream> #include <iostream>
int main() int main()
{ {
std::cout << U_ICU_VERSION_MAJOR_NUM << "." << U_ICU_VERSION_MINOR_NUM << std::endl; std::cout << U_ICU_VERSION_MAJOR_NUM << "." << U_ICU_VERSION_MINOR_NUM << std::endl;
return 0; return 0;
@ -802,12 +802,12 @@ int main()
if not result: if not result:
context.Result('error, could not get major and minor version from unicode/uversion.h') context.Result('error, could not get major and minor version from unicode/uversion.h')
return False return False
major, minor = map(int,result.split('.')) major, minor = map(int,result.split('.'))
if major >= 4 and minor >= 0: if major >= 4 and minor >= 0:
color_print(4,'found: icu %s' % result) color_print(4,'found: icu %s' % result)
return True return True
color_print(1,'\nFound insufficient icu version... %s' % result) color_print(1,'\nFound insufficient icu version... %s' % result)
return False return False
@ -820,10 +820,10 @@ def boost_regex_has_icu(context):
#include <boost/regex/icu.hpp> #include <boost/regex/icu.hpp>
#include <unicode/unistr.h> #include <unicode/unistr.h>
int main() int main()
{ {
UnicodeString ustr; UnicodeString ustr;
try { try {
boost::u32regex pattern = boost::make_u32regex(ustr); boost::u32regex pattern = boost::make_u32regex(ustr);
} }
// an exception is fine, still indicates support is // an exception is fine, still indicates support is
@ -843,17 +843,17 @@ int main()
def sqlite_has_rtree(context): def sqlite_has_rtree(context):
""" check an sqlite3 install has rtree support. """ check an sqlite3 install has rtree support.
PRAGMA compile_options; PRAGMA compile_options;
http://www.sqlite.org/c3ref/compileoption_get.html http://www.sqlite.org/c3ref/compileoption_get.html
""" """
ret = context.TryRun(""" ret = context.TryRun("""
#include <sqlite3.h> #include <sqlite3.h>
#include <stdio.h> #include <stdio.h>
int main() int main()
{ {
sqlite3* db; sqlite3* db;
int rc; int rc;
@ -873,7 +873,7 @@ int main()
printf("yes, has rtree!\\n"); printf("yes, has rtree!\\n");
return 0; return 0;
} }
return -1; return -1;
} }
@ -883,7 +883,7 @@ int main()
if ret[0]: if ret[0]:
return True return True
return False return False
conf_tests = { 'prioritize_paths' : prioritize_paths, conf_tests = { 'prioritize_paths' : prioritize_paths,
'CheckPKGConfig' : CheckPKGConfig, 'CheckPKGConfig' : CheckPKGConfig,
'CheckPKG' : CheckPKG, 'CheckPKG' : CheckPKG,
@ -909,7 +909,7 @@ if not preconfigured:
if not env['FAST']: if not env['FAST']:
SetCacheMode('force') SetCacheMode('force')
if env['USE_CONFIG']: if env['USE_CONFIG']:
if not env['CONFIG'].endswith('.py'): if not env['CONFIG'].endswith('.py'):
color_print(1,'SCons CONFIG file specified is not a python file, will not be read...') color_print(1,'SCons CONFIG file specified is not a python file, will not be read...')
@ -924,7 +924,7 @@ if not preconfigured:
optfile = file(conf) optfile = file(conf)
#print optfile.read().replace("\n", " ").replace("'","").replace(" = ","=") #print optfile.read().replace("\n", " ").replace("'","").replace(" = ","=")
optfile.close() optfile.close()
elif not conf == SCONS_LOCAL_CONFIG: elif not conf == SCONS_LOCAL_CONFIG:
# if default missing, no worries # if default missing, no worries
# but if the default is overridden and the file is not found, give warning # but if the default is overridden and the file is not found, give warning
@ -933,18 +933,18 @@ if not preconfigured:
env = Environment(ENV=os.environ,options=opts) env = Environment(ENV=os.environ,options=opts)
env['USE_CONFIG'] = True env['USE_CONFIG'] = True
else: else:
color_print(4,'SCons USE_CONFIG specified as false, will not inherit variables python config file...') color_print(4,'SCons USE_CONFIG specified as false, will not inherit variables python config file...')
conf = Configure(env, custom_tests = conf_tests) conf = Configure(env, custom_tests = conf_tests)
if env['DEBUG']: if env['DEBUG']:
mode = 'debug mode' mode = 'debug mode'
else: else:
mode = 'release mode' mode = 'release mode'
env['PLATFORM'] = platform.uname()[0] env['PLATFORM'] = platform.uname()[0]
color_print(4,"Configuring on %s in *%s*..." % (env['PLATFORM'],mode)) color_print(4,"Configuring on %s in *%s*..." % (env['PLATFORM'],mode))
env['MISSING_DEPS'] = [] env['MISSING_DEPS'] = []
env['SKIPPED_DEPS'] = [] env['SKIPPED_DEPS'] = []
env['HAS_CAIRO'] = False env['HAS_CAIRO'] = False
@ -964,7 +964,7 @@ if not preconfigured:
# now strip it to ensure expected behavior # now strip it to ensure expected behavior
if env['LIB_DIR_NAME'].startswith(os.path.sep): if env['LIB_DIR_NAME'].startswith(os.path.sep):
env['LIB_DIR_NAME'] = strip_first(env['LIB_DIR_NAME'],os.path.sep) env['LIB_DIR_NAME'] = strip_first(env['LIB_DIR_NAME'],os.path.sep)
# base install location # base install location
env['MAPNIK_LIB_BASE'] = os.path.join(env['PREFIX'],env['LIBDIR_SCHEMA']) env['MAPNIK_LIB_BASE'] = os.path.join(env['PREFIX'],env['LIBDIR_SCHEMA'])
# directory for plugins and fonts # directory for plugins and fonts
@ -976,8 +976,8 @@ if not preconfigured:
env['MAPNIK_FONTS'] = os.path.normpath(env['SYSTEM_FONTS']) env['MAPNIK_FONTS'] = os.path.normpath(env['SYSTEM_FONTS'])
else: else:
env['MAPNIK_FONTS'] = os.path.join(env['MAPNIK_LIB_DIR'],'fonts') env['MAPNIK_FONTS'] = os.path.join(env['MAPNIK_LIB_DIR'],'fonts')
# install prefix is a pre-pended base location to # install prefix is a pre-pended base location to
# re-route the install and only intended for package building # re-route the install and only intended for package building
# we normalize to ensure no trailing slash and proper pre-pending to the absolute prefix # we normalize to ensure no trailing slash and proper pre-pending to the absolute prefix
install_prefix = os.path.normpath(os.path.realpath(env['DESTDIR'])) + os.path.realpath(env['PREFIX']) install_prefix = os.path.normpath(os.path.realpath(env['DESTDIR'])) + os.path.realpath(env['PREFIX'])
@ -991,12 +991,12 @@ if not preconfigured:
env['MAPNIK_FONTS_DEST'] = os.path.normpath(env['SYSTEM_FONTS']) env['MAPNIK_FONTS_DEST'] = os.path.normpath(env['SYSTEM_FONTS'])
else: else:
env['MAPNIK_FONTS_DEST'] = os.path.join(env['MAPNIK_LIB_DIR_DEST'],'fonts') env['MAPNIK_FONTS_DEST'] = os.path.join(env['MAPNIK_LIB_DIR_DEST'],'fonts')
if env['LINKING'] == 'static': if env['LINKING'] == 'static':
env['MAPNIK_LIB_NAME'] = '${LIBPREFIX}mapnik${LIBSUFFIX}' env['MAPNIK_LIB_NAME'] = '${LIBPREFIX}mapnik${LIBSUFFIX}'
else: else:
env['MAPNIK_LIB_NAME'] = '${SHLIBPREFIX}mapnik${SHLIBSUFFIX}' env['MAPNIK_LIB_NAME'] = '${SHLIBPREFIX}mapnik${SHLIBSUFFIX}'
if env['PKG_CONFIG_PATH']: if env['PKG_CONFIG_PATH']:
env['ENV']['PKG_CONFIG_PATH'] = os.path.realpath(env['PKG_CONFIG_PATH']) env['ENV']['PKG_CONFIG_PATH'] = os.path.realpath(env['PKG_CONFIG_PATH'])
# otherwise this variable == os.environ["PKG_CONFIG_PATH"] # otherwise this variable == os.environ["PKG_CONFIG_PATH"]
@ -1008,11 +1008,11 @@ if not preconfigured:
if not os.path.isdir(env['SYSTEM_FONTS']): if not os.path.isdir(env['SYSTEM_FONTS']):
color_print(1,'Warning: Directory specified for SYSTEM_FONTS does not exist!') color_print(1,'Warning: Directory specified for SYSTEM_FONTS does not exist!')
#### Libraries and headers dependency checks #### #### Libraries and headers dependency checks ####
# Set up for libraries and headers dependency checks # Set up for libraries and headers dependency checks
env['CPPPATH'] = ['#include', '#'] env['CPPPATH'] = ['#include', '#']
env['LIBPATH'] = ['#src'] env['LIBPATH'] = ['#src']
# set any custom cxxflags to come first # set any custom cxxflags to come first
env.Append(CXXFLAGS = env['CUSTOM_CXXFLAGS']) env.Append(CXXFLAGS = env['CUSTOM_CXXFLAGS'])
@ -1027,7 +1027,7 @@ if not preconfigured:
# set if the `CXX` option begins with `CC`) # set if the `CXX` option begins with `CC`)
SOLARIS = env['PLATFORM'] == 'SunOS' SOLARIS = env['PLATFORM'] == 'SunOS'
env['SUNCC'] = SOLARIS and env['CXX'].startswith('CC') env['SUNCC'] = SOLARIS and env['CXX'].startswith('CC')
# If the Sun Studio C++ compiler (`CC`) is used instead of GCC. # If the Sun Studio C++ compiler (`CC`) is used instead of GCC.
if env['SUNCC']: if env['SUNCC']:
env['CC'] = 'cc' env['CC'] = 'cc'
@ -1050,7 +1050,7 @@ if not preconfigured:
if os.path.exists(env['ICU_LIB_NAME']): if os.path.exists(env['ICU_LIB_NAME']):
#-sICU_LINK=" -L/usr/lib -licucore #-sICU_LINK=" -L/usr/lib -licucore
env['ICU_LIB_NAME'] = os.path.basename(env['ICU_LIB_NAME']).replace('.dylib','').replace('lib','') env['ICU_LIB_NAME'] = os.path.basename(env['ICU_LIB_NAME']).replace('.dylib','').replace('lib','')
# Adding the required prerequisite library directories to the include path for # Adding the required prerequisite library directories to the include path for
# compiling and the library path for linking, respectively. # compiling and the library path for linking, respectively.
for required in ('PNG', 'JPEG', 'TIFF','PROJ','ICU', 'SQLITE'): for required in ('PNG', 'JPEG', 'TIFF','PROJ','ICU', 'SQLITE'):
@ -1094,8 +1094,8 @@ if not preconfigured:
# if requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests # if requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests
if env['PRIORITIZE_LINKING']: if env['PRIORITIZE_LINKING']:
conf.prioritize_paths(silent=False) conf.prioritize_paths(silent=False)
for libname, headers, required, lang in LIBSHEADERS: for libname, headers, required, lang in LIBSHEADERS:
if not conf.CheckLibWithHeader(libname, headers, lang): if not conf.CheckLibWithHeader(libname, headers, lang):
if required: if required:
@ -1109,16 +1109,16 @@ if not preconfigured:
if not conf.icu_at_least_four_two(): if not conf.icu_at_least_four_two():
# expression_string.cpp and map.cpp use fromUTF* function only available in >= ICU 4.2 # expression_string.cpp and map.cpp use fromUTF* function only available in >= ICU 4.2
env['MISSING_DEPS'].append(env['ICU_LIB_NAME']) env['MISSING_DEPS'].append(env['ICU_LIB_NAME'])
if env['THREADING'] == 'multi': if env['THREADING'] == 'multi':
thread_flag = thread_suffix thread_flag = thread_suffix
else: else:
thread_flag = '' thread_flag = ''
conf.FindBoost(BOOST_SEARCH_PREFIXES,thread_flag) conf.FindBoost(BOOST_SEARCH_PREFIXES,thread_flag)
env['BOOST_LIB_VERSION_FROM_HEADER'] = conf.GetBoostLibVersion() env['BOOST_LIB_VERSION_FROM_HEADER'] = conf.GetBoostLibVersion()
# The other required boost headers. # The other required boost headers.
BOOST_LIBSHEADERS = [ BOOST_LIBSHEADERS = [
['system', 'boost/system/system_error.hpp', True], ['system', 'boost/system/system_error.hpp', True],
@ -1126,11 +1126,11 @@ if not preconfigured:
['regex', 'boost/regex.hpp', True], ['regex', 'boost/regex.hpp', True],
['program_options', 'boost/program_options.hpp', False] ['program_options', 'boost/program_options.hpp', False]
] ]
if env['THREADING'] == 'multi': if env['THREADING'] == 'multi':
BOOST_LIBSHEADERS.append(['thread', 'boost/thread/mutex.hpp', True]) BOOST_LIBSHEADERS.append(['thread', 'boost/thread/mutex.hpp', True])
# on solaris the configure checks for boost_thread # on solaris the configure checks for boost_thread
# require the -pthreads flag to be able to check for # require the -pthreads flag to be able to check for
# threading support, so we add as a global library instead # threading support, so we add as a global library instead
# of attaching to cxxflags after configure # of attaching to cxxflags after configure
if env['PLATFORM'] == 'SunOS': if env['PLATFORM'] == 'SunOS':
@ -1138,17 +1138,17 @@ if not preconfigured:
# if requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests # if requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests
if env['PRIORITIZE_LINKING']: if env['PRIORITIZE_LINKING']:
conf.prioritize_paths() conf.prioritize_paths()
# if the user is not setting custom boost configuration # if the user is not setting custom boost configuration
# enforce boost version greater than or equal to BOOST_MIN_VERSION # enforce boost version greater than or equal to BOOST_MIN_VERSION
if not conf.CheckBoost(BOOST_MIN_VERSION): if not conf.CheckBoost(BOOST_MIN_VERSION):
color_print(1,'Boost version %s or greater is required' % BOOST_MIN_VERSION) color_print(1,'Boost version %s or greater is required' % BOOST_MIN_VERSION)
if not env['BOOST_VERSION']: if not env['BOOST_VERSION']:
env['MISSING_DEPS'].append('boost version >=%s' % BOOST_MIN_VERSION) env['MISSING_DEPS'].append('boost version >=%s' % BOOST_MIN_VERSION)
else: else:
color_print(4,'Found boost lib version... %s' % env.get('BOOST_LIB_VERSION_FROM_HEADER') ) color_print(4,'Found boost lib version... %s' % env.get('BOOST_LIB_VERSION_FROM_HEADER') )
for count, libinfo in enumerate(BOOST_LIBSHEADERS): for count, libinfo in enumerate(BOOST_LIBSHEADERS):
if not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++'): if not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++'):
if libinfo[2]: if libinfo[2]:
@ -1167,7 +1167,7 @@ if not preconfigured:
env['SKIPPED_DEPS'].append('boost_regex_icu') env['SKIPPED_DEPS'].append('boost_regex_icu')
env['REQUESTED_PLUGINS'] = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])] env['REQUESTED_PLUGINS'] = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])]
if len(env['REQUESTED_PLUGINS']): if len(env['REQUESTED_PLUGINS']):
color_print(4,'Checking for requested plugins dependencies...') color_print(4,'Checking for requested plugins dependencies...')
for plugin in env['REQUESTED_PLUGINS']: for plugin in env['REQUESTED_PLUGINS']:
@ -1232,7 +1232,7 @@ if not preconfigured:
elif details['lib'] and details['inc']: elif details['lib'] and details['inc']:
if not conf.CheckLibWithHeader(details['lib'], details['inc'], details['lang']): if not conf.CheckLibWithHeader(details['lib'], details['inc'], details['lang']):
env['SKIPPED_DEPS'].append(details['lib']) env['SKIPPED_DEPS'].append(details['lib'])
# re-append the local paths for mapnik sources to the beginning of the list # re-append the local paths for mapnik sources to the beginning of the list
# to make sure they come before any plugins that were 'prepended' # to make sure they come before any plugins that were 'prepended'
env.PrependUnique(CPPPATH = '#include', delete_existing=True) env.PrependUnique(CPPPATH = '#include', delete_existing=True)
@ -1247,7 +1247,7 @@ if not preconfigured:
# Decide which libagg to use # Decide which libagg to use
# if we are using internal agg, then prepend to make sure # if we are using internal agg, then prepend to make sure
# we link locally # we link locally
if env['INTERNAL_LIBAGG']: if env['INTERNAL_LIBAGG']:
env.Prepend(CPPPATH = '#deps/agg/include') env.Prepend(CPPPATH = '#deps/agg/include')
env.Prepend(LIBPATH = '#deps/agg') env.Prepend(LIBPATH = '#deps/agg')
@ -1260,7 +1260,7 @@ if not preconfigured:
if env['CAIRO_LIBS']: if env['CAIRO_LIBS']:
env["CAIROMM_LIBPATHS"].append(os.path.realpath(env['CAIRO_LIBS'])) env["CAIROMM_LIBPATHS"].append(os.path.realpath(env['CAIRO_LIBS']))
if not env['CAIRO_INCLUDES']: if not env['CAIRO_INCLUDES']:
c_inc = env['CAIRO_LIBS'].replace('lib','',1) c_inc = env['CAIRO_LIBS'].replace('lib','',1)
if c_inc: if c_inc:
c_inc = os.path.normpath(os.path.realpath(env['CAIRO_INCLUDES'])) c_inc = os.path.normpath(os.path.realpath(env['CAIRO_INCLUDES']))
if c_inc.endswith('include'): if c_inc.endswith('include'):
@ -1323,17 +1323,17 @@ if not preconfigured:
env['SKIPPED_DEPS'].append('cairo') env['SKIPPED_DEPS'].append('cairo')
env['SKIPPED_DEPS'].append('cairomm') env['SKIPPED_DEPS'].append('cairomm')
color_print(1,'pkg-config reported: %s' % e) color_print(1,'pkg-config reported: %s' % e)
else: else:
color_print(4,'Not building with cairo support, pass CAIRO=True to enable') color_print(4,'Not building with cairo support, pass CAIRO=True to enable')
if 'python' in env['BINDINGS']: if 'python' in env['BINDINGS']:
# checklibwithheader does not work for boost_python since we can't feed it # checklibwithheader does not work for boost_python since we can't feed it
# multiple header files, so we fall back on a simple check for boost_python headers # multiple header files, so we fall back on a simple check for boost_python headers
if not conf.CheckHeader(header='boost/python/detail/config.hpp',language='C++'): if not conf.CheckHeader(header='boost/python/detail/config.hpp',language='C++'):
color_print(1,'Could not find required header files for boost python') color_print(1,'Could not find required header files for boost python')
env['MISSING_DEPS'].append('boost python') env['MISSING_DEPS'].append('boost python')
if env['CAIRO']: if env['CAIRO']:
if conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('pycairo'): if conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('pycairo'):
env['HAS_PYCAIRO'] = True env['HAS_PYCAIRO'] = True
@ -1341,10 +1341,10 @@ if not preconfigured:
env['SKIPPED_DEPS'].extend(['pycairo']) env['SKIPPED_DEPS'].extend(['pycairo'])
else: else:
color_print(4,'Not building with pycairo support, pass CAIRO=True to enable') color_print(4,'Not building with pycairo support, pass CAIRO=True to enable')
#### End Config Stage for Required Dependencies #### #### End Config Stage for Required Dependencies ####
if env['MISSING_DEPS']: if env['MISSING_DEPS']:
# if required dependencies are missing, print warnings and then let SCons finish without building or saving local config # if required dependencies are missing, print warnings and then let SCons finish without building or saving local config
color_print(1,'\nExiting... the following required dependencies were not found:\n - %s' % '\n - '.join([pretty_dep(dep) for dep in env['MISSING_DEPS']])) color_print(1,'\nExiting... the following required dependencies were not found:\n - %s' % '\n - '.join([pretty_dep(dep) for dep in env['MISSING_DEPS']]))
@ -1367,7 +1367,7 @@ if not preconfigured:
if env['USE_CONFIG']: if env['USE_CONFIG']:
if os.path.exists(SCONS_LOCAL_CONFIG): if os.path.exists(SCONS_LOCAL_CONFIG):
action = 'Overwriting and re-saving' action = 'Overwriting and re-saving'
os.unlink(SCONS_LOCAL_CONFIG) os.unlink(SCONS_LOCAL_CONFIG)
else: else:
action = 'Saving new' action = 'Saving new'
color_print(4,"%s file '%s'..." % (action,SCONS_LOCAL_CONFIG)) color_print(4,"%s file '%s'..." % (action,SCONS_LOCAL_CONFIG))
@ -1409,25 +1409,25 @@ if not preconfigured:
# common_cxx_flags += '-DOSX_LEOPARD ' # common_cxx_flags += '-DOSX_LEOPARD '
else: else:
pthread = '-pthread' pthread = '-pthread'
# Common debugging flags. # Common debugging flags.
# http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html # http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html
debug_flags = '-g -fno-omit-frame-pointer -DDEBUG -DMAPNIK_DEBUG' debug_flags = '-g -fno-omit-frame-pointer -DDEBUG -DMAPNIK_DEBUG'
ndebug_flags = '-DNDEBUG' ndebug_flags = '-DNDEBUG'
# Enable logging in debug mode (always) and release mode (when specified) # Enable logging in debug mode (always) and release mode (when specified)
severities = ['info', 'debug', 'warn', 'error', 'fatal', 'none']
if env['DEFAULT_LOG_SEVERITY']: if env['DEFAULT_LOG_SEVERITY']:
severities = ['info', 'debug', 'warn', 'error', 'fatal', 'none']
if env['DEFAULT_LOG_SEVERITY'] not in severities: if env['DEFAULT_LOG_SEVERITY'] not in severities:
color_print(1,"Cannot set default logger severity to '%s', available options are 'info', 'debug', 'warn', 'error', 'fatal', 'none'." % env['DEFAULT_LOG_SEVERITY']) severities_list = ', '.join(["'%s'" % s for s in severities])
color_print(1,"Cannot set default logger severity to '%s', available options are %s." % (env['DEFAULT_LOG_SEVERITY'], severities_list))
Exit(1) Exit(1)
else: else:
log_severity = severities.index(env['DEFAULT_LOG_SEVERITY']) log_severity = severities.index(env['DEFAULT_LOG_SEVERITY'])
else: else:
if env['DEBUG']: severities_list = ', '.join(["'%s'" % s for s in severities])
log_severity = 1 # debug color_print(1,"No logger severity specified, available options are %s." % severities_list)
else: Exit(1)
log_severity = 3 # error
log_enabled = ' -DMAPNIK_LOG -DMAPNIK_DEFAULT_LOG_SEVERITY=%d' % log_severity log_enabled = ' -DMAPNIK_LOG -DMAPNIK_DEFAULT_LOG_SEVERITY=%d' % log_severity
@ -1447,7 +1447,7 @@ if not preconfigured:
if env['PLATFORM'] != 'Darwin' and env['CXX'] == 'g++': if env['PLATFORM'] != 'Darwin' and env['CXX'] == 'g++':
env.MergeFlags('-rdynamic') env.MergeFlags('-rdynamic')
# Customizing the C++ compiler flags depending on: # Customizing the C++ compiler flags depending on:
# (1) the C++ compiler used; and # (1) the C++ compiler used; and
# (2) whether debug binaries are requested. # (2) whether debug binaries are requested.
if env['SUNCC']: if env['SUNCC']:
@ -1457,10 +1457,10 @@ if not preconfigured:
env.Append(CXXFLAGS = common_cxx_flags + '-O %s' % ndebug_flags) env.Append(CXXFLAGS = common_cxx_flags + '-O %s' % ndebug_flags)
else: else:
# Common flags for GCC. # Common flags for GCC.
gcc_cxx_flags = '-ansi -Wall %s %s -ftemplate-depth-300 %s' % (env['WARNING_CXXFLAGS'], pthread, common_cxx_flags) gcc_cxx_flags = '-ansi -Wall %s %s -ftemplate-depth-300 %s' % (env['WARNING_CXXFLAGS'], pthread, common_cxx_flags)
if env['DEBUG']: if env['DEBUG']:
env.Append(CXXFLAGS = gcc_cxx_flags + '-O0 -fno-inline %s' % debug_flags) env.Append(CXXFLAGS = gcc_cxx_flags + '-O0 -fno-inline %s' % debug_flags)
else: else:
env.Append(CXXFLAGS = gcc_cxx_flags + '-O%s -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts %s' % (env['OPTIMIZATION'],ndebug_flags)) env.Append(CXXFLAGS = gcc_cxx_flags + '-O%s -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts %s' % (env['OPTIMIZATION'],ndebug_flags))
if env['DEBUG_UNDEFINED']: if env['DEBUG_UNDEFINED']:
@ -1470,44 +1470,44 @@ if not preconfigured:
if not os.access(env['PYTHON'], os.X_OK): if not os.access(env['PYTHON'], os.X_OK):
color_print(1,"Cannot run python interpreter at '%s', make sure that you have the permissions to execute it." % env['PYTHON']) color_print(1,"Cannot run python interpreter at '%s', make sure that you have the permissions to execute it." % env['PYTHON'])
Exit(1) Exit(1)
py3 = 'True' in os.popen('''%s -c "import sys as s;s.stdout.write(str(s.version_info[0] == 3))"''' % env['PYTHON']).read().strip() py3 = 'True' in os.popen('''%s -c "import sys as s;s.stdout.write(str(s.version_info[0] == 3))"''' % env['PYTHON']).read().strip()
if py3: if py3:
sys_prefix = '''%s -c "import sys; print(sys.prefix)"''' % env['PYTHON'] sys_prefix = '''%s -c "import sys; print(sys.prefix)"''' % env['PYTHON']
else: else:
sys_prefix = '''%s -c "import sys; print sys.prefix"''' % env['PYTHON'] sys_prefix = '''%s -c "import sys; print sys.prefix"''' % env['PYTHON']
env['PYTHON_SYS_PREFIX'] = call(sys_prefix) env['PYTHON_SYS_PREFIX'] = call(sys_prefix)
if HAS_DISTUTILS: if HAS_DISTUTILS:
if py3: if py3:
sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print(get_python_version())"''' % env['PYTHON'] sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print(get_python_version())"''' % env['PYTHON']
else: else:
sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print get_python_version()"''' % env['PYTHON'] sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print get_python_version()"''' % env['PYTHON']
env['PYTHON_VERSION'] = call(sys_version) env['PYTHON_VERSION'] = call(sys_version)
if py3: if py3:
py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())"''' % env['PYTHON'] py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())"''' % env['PYTHON']
else: else:
py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print get_python_inc()"''' % env['PYTHON'] py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print get_python_inc()"''' % env['PYTHON']
env['PYTHON_INCLUDES'] = call(py_includes) env['PYTHON_INCLUDES'] = call(py_includes)
# Note: we use the plat_specific argument here to make sure to respect the arch-specific site-packages location # Note: we use the plat_specific argument here to make sure to respect the arch-specific site-packages location
if py3: if py3:
site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True))"''' % env['PYTHON'] site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True))"''' % env['PYTHON']
else: else:
site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print get_python_lib(plat_specific=True)"''' % env['PYTHON'] site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print get_python_lib(plat_specific=True)"''' % env['PYTHON']
env['PYTHON_SITE_PACKAGES'] = call(site_packages) env['PYTHON_SITE_PACKAGES'] = call(site_packages)
else: else:
env['PYTHON_SYS_PREFIX'] = os.popen('''%s -c "import sys; print sys.prefix"''' % env['PYTHON']).read().strip() env['PYTHON_SYS_PREFIX'] = os.popen('''%s -c "import sys; print sys.prefix"''' % env['PYTHON']).read().strip()
env['PYTHON_VERSION'] = os.popen('''%s -c "import sys; print sys.version"''' % env['PYTHON']).read()[0:3] env['PYTHON_VERSION'] = os.popen('''%s -c "import sys; print sys.version"''' % env['PYTHON']).read()[0:3]
env['PYTHON_INCLUDES'] = env['PYTHON_SYS_PREFIX'] + '/include/python' + env['PYTHON_VERSION'] env['PYTHON_INCLUDES'] = env['PYTHON_SYS_PREFIX'] + '/include/python' + env['PYTHON_VERSION']
env['PYTHON_SITE_PACKAGES'] = env['DESTDIR'] + os.path.sep + env['PYTHON_SYS_PREFIX'] + os.path.sep + env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/' env['PYTHON_SITE_PACKAGES'] = env['DESTDIR'] + os.path.sep + env['PYTHON_SYS_PREFIX'] + os.path.sep + env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/'
# if user-requested custom prefix fall back to manual concatenation for building subdirectories # if user-requested custom prefix fall back to manual concatenation for building subdirectories
if env['PYTHON_PREFIX']: if env['PYTHON_PREFIX']:
py_relative_install = env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/' py_relative_install = env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/'
env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + os.path.sep + env['PYTHON_PREFIX'] + os.path.sep + py_relative_install env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + os.path.sep + env['PYTHON_PREFIX'] + os.path.sep + py_relative_install
else: else:
env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + os.path.sep + env['PYTHON_SITE_PACKAGES'] env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + os.path.sep + env['PYTHON_SITE_PACKAGES']
@ -1515,27 +1515,27 @@ if not preconfigured:
is_64_bit = '''%s -c "import sys; print(sys.maxsize == 9223372036854775807)"''' % env['PYTHON'] is_64_bit = '''%s -c "import sys; print(sys.maxsize == 9223372036854775807)"''' % env['PYTHON']
else: else:
is_64_bit = '''%s -c "import sys; print sys.maxint == 9223372036854775807"''' % env['PYTHON'] is_64_bit = '''%s -c "import sys; print sys.maxint == 9223372036854775807"''' % env['PYTHON']
if is_64_bit: if is_64_bit:
env['PYTHON_IS_64BIT'] = True env['PYTHON_IS_64BIT'] = True
else: else:
env['PYTHON_IS_64BIT'] = False env['PYTHON_IS_64BIT'] = False
majver, minver = env['PYTHON_VERSION'].split('.') majver, minver = env['PYTHON_VERSION'].split('.')
# we don't want the includes it in the main environment... # we don't want the includes it in the main environment...
# as they are later set in the python build.py # as they are later set in the python build.py
# ugly hack needed until we have env specific conf # ugly hack needed until we have env specific conf
backup = env.Clone().Dictionary() backup = env.Clone().Dictionary()
env.AppendUnique(CPPPATH = os.path.realpath(env['PYTHON_INCLUDES'])) env.AppendUnique(CPPPATH = os.path.realpath(env['PYTHON_INCLUDES']))
if not conf.CheckHeader(header='Python.h',language='C'): if not conf.CheckHeader(header='Python.h',language='C'):
color_print(1,'Could not find required header files for the Python language (version %s)' % env['PYTHON_VERSION']) color_print(1,'Could not find required header files for the Python language (version %s)' % env['PYTHON_VERSION'])
env.Replace(**backup) env.Replace(**backup)
Exit(1) Exit(1)
else: else:
env.Replace(**backup) env.Replace(**backup)
if (int(majver), int(minver)) < (2, 2): if (int(majver), int(minver)) < (2, 2):
color_print(1,"Python version 2.2 or greater required") color_print(1,"Python version 2.2 or greater required")
Exit(1) Exit(1)
@ -1557,7 +1557,7 @@ if not preconfigured:
# if requested, sort LIBPATH and CPPPATH one last time before saving... # if requested, sort LIBPATH and CPPPATH one last time before saving...
if env['PRIORITIZE_LINKING']: if env['PRIORITIZE_LINKING']:
conf.prioritize_paths() conf.prioritize_paths()
# finish config stage and pickle results # finish config stage and pickle results
env = conf.Finish() env = conf.Finish()
env_cache = open(SCONS_CONFIGURE_CACHE, 'w') env_cache = open(SCONS_CONFIGURE_CACHE, 'w')
@ -1606,7 +1606,7 @@ if not HELP_REQUESTED:
if env['PKG_CONFIG_PATH']: if env['PKG_CONFIG_PATH']:
env['ENV']['PKG_CONFIG_PATH'] = os.path.realpath(env['PKG_CONFIG_PATH']) env['ENV']['PKG_CONFIG_PATH'] = os.path.realpath(env['PKG_CONFIG_PATH'])
# otherwise this variable == os.environ["PKG_CONFIG_PATH"] # otherwise this variable == os.environ["PKG_CONFIG_PATH"]
if env['PATH']: if env['PATH']:
env['ENV']['PATH'] = os.path.realpath(env['PATH']) + ':' + env['ENV']['PATH'] env['ENV']['PATH'] = os.path.realpath(env['PATH']) + ':' + env['ENV']['PATH']
@ -1640,10 +1640,10 @@ if not HELP_REQUESTED:
replace_path('CXXFLAGS',search,replace) replace_path('CXXFLAGS',search,replace)
replace_path('CAIROMM_LIBPATHS',search,replace) replace_path('CAIROMM_LIBPATHS',search,replace)
replace_path('CAIROMM_CPPPATHS',search,replace) replace_path('CAIROMM_CPPPATHS',search,replace)
# export env so it is available in build.py files # export env so it is available in build.py files
Export('env') Export('env')
plugin_base = env.Clone() plugin_base = env.Clone()
# for this to work you need: # for this to work you need:
# if __GNUC__ >= 4 # if __GNUC__ >= 4
@ -1659,7 +1659,7 @@ if not HELP_REQUESTED:
env['_CPPDEFFLAGS'] = None env['_CPPDEFFLAGS'] = None
plugin_base['_CPPDEFFLAGS'] = None plugin_base['_CPPDEFFLAGS'] = None
if env['FAST']: if env['FAST']:
# caching is 'auto' by default in SCons # caching is 'auto' by default in SCons
# But let's also cache implicit deps... # But let's also cache implicit deps...
@ -1667,22 +1667,22 @@ if not HELP_REQUESTED:
SetOption('implicit_cache', 1) SetOption('implicit_cache', 1)
env.Decider('MD5-timestamp') env.Decider('MD5-timestamp')
SetOption('max_drift', 1) SetOption('max_drift', 1)
else: else:
# Set the cache mode to 'force' unless requested, avoiding hidden caching of Scons 'opts' in '.sconsign.dblite' # Set the cache mode to 'force' unless requested, avoiding hidden caching of Scons 'opts' in '.sconsign.dblite'
# This allows for a SCONS_LOCAL_CONFIG, if present, to be used as the primary means of storing paths to successful build dependencies # This allows for a SCONS_LOCAL_CONFIG, if present, to be used as the primary means of storing paths to successful build dependencies
SetCacheMode('force') SetCacheMode('force')
if env['JOBS'] > 1: if env['JOBS'] > 1:
SetOption("num_jobs", env['JOBS']) SetOption("num_jobs", env['JOBS'])
# Build agg first, doesn't need anything special # Build agg first, doesn't need anything special
if env['RUNTIME_LINK'] == 'shared' and env['INTERNAL_LIBAGG']: if env['RUNTIME_LINK'] == 'shared' and env['INTERNAL_LIBAGG']:
SConscript('deps/agg/build.py') SConscript('deps/agg/build.py')
# Build the core library # Build the core library
SConscript('src/build.py') SConscript('src/build.py')
# Build the requested and able-to-be-compiled input plug-ins # Build the requested and able-to-be-compiled input plug-ins
GDAL_BUILT = False GDAL_BUILT = False
OGR_BUILT = False OGR_BUILT = False
@ -1702,7 +1702,7 @@ if not HELP_REQUESTED:
SConscript('plugins/input/%s/build.py' % plugin) SConscript('plugins/input/%s/build.py' % plugin)
else: else:
color_print(1,"Notice: dependencies not met for plugin '%s', not building..." % plugin) color_print(1,"Notice: dependencies not met for plugin '%s', not building..." % plugin)
create_uninstall_target(env, env['MAPNIK_LIB_DIR_DEST'], False) create_uninstall_target(env, env['MAPNIK_LIB_DIR_DEST'], False)
create_uninstall_target(env, env['MAPNIK_INPUT_PLUGINS_DEST'] , False) create_uninstall_target(env, env['MAPNIK_INPUT_PLUGINS_DEST'] , False)
create_uninstall_target(env, env['MAPNIK_INPUT_PLUGINS_DEST'] , False) create_uninstall_target(env, env['MAPNIK_INPUT_PLUGINS_DEST'] , False)
@ -1716,43 +1716,43 @@ if not HELP_REQUESTED:
if os.path.exists(plugin_path): if os.path.exists(plugin_path):
color_print(1,"Notice: removing out of date plugin: '%s'" % plugin_path) color_print(1,"Notice: removing out of date plugin: '%s'" % plugin_path)
os.unlink(plugin_path) os.unlink(plugin_path)
# Build the c++ rundemo app if requested # Build the c++ rundemo app if requested
if env['DEMO']: if env['DEMO']:
SConscript('demo/c++/build.py') SConscript('demo/c++/build.py')
# Build the pgsql2psqlite app if requested # Build the pgsql2psqlite app if requested
if env['PGSQL2SQLITE']: if env['PGSQL2SQLITE']:
SConscript('utils/pgsql2sqlite/build.py') SConscript('utils/pgsql2sqlite/build.py')
# Build shapeindex and remove its dependency from the LIBS # Build shapeindex and remove its dependency from the LIBS
if 'boost_program_options%s' % env['BOOST_APPEND'] in env['LIBS']: if 'boost_program_options%s' % env['BOOST_APPEND'] in env['LIBS']:
SConscript('utils/shapeindex/build.py') SConscript('utils/shapeindex/build.py')
# devtools not ready for public # devtools not ready for public
#SConscript('utils/ogrindex/build.py') #SConscript('utils/ogrindex/build.py')
SConscript('utils/svg2png/build.py') SConscript('utils/svg2png/build.py')
env['LIBS'].remove('boost_program_options%s' % env['BOOST_APPEND']) env['LIBS'].remove('boost_program_options%s' % env['BOOST_APPEND'])
else : else :
color_print(1,"WARNING: Cannot find boost_program_options. 'shapeindex' won't be available") color_print(1,"WARNING: Cannot find boost_program_options. 'shapeindex' won't be available")
# Build the Python bindings # Build the Python bindings
if 'python' in env['BINDINGS']: if 'python' in env['BINDINGS']:
SConscript('bindings/python/build.py') SConscript('bindings/python/build.py')
# Install the python speed testing scripts if python bindings will be available # Install the python speed testing scripts if python bindings will be available
SConscript('utils/performance/build.py') SConscript('utils/performance/build.py')
# Install the mapnik upgrade script # Install the mapnik upgrade script
SConscript('utils/upgrade_map_xml/build.py') SConscript('utils/upgrade_map_xml/build.py')
# Configure fonts and if requested install the bundled DejaVu fonts # Configure fonts and if requested install the bundled DejaVu fonts
SConscript('fonts/build.py') SConscript('fonts/build.py')
# build C++ tests # build C++ tests
# not ready for release # not ready for release
SConscript('tests/cpp_tests/build.py') SConscript('tests/cpp_tests/build.py')
# not ready for release # not ready for release
#if env['SVG_RENDERER']: #if env['SVG_RENDERER']:
# SConscript('tests/cpp_tests/svg_renderer_tests/build.py') # SConscript('tests/cpp_tests/svg_renderer_tests/build.py')
@ -1762,7 +1762,7 @@ if not HELP_REQUESTED:
# write the viewer.ini file # write the viewer.ini file
SConscript('demo/viewer/build.py') SConscript('demo/viewer/build.py')
# if requested, build the sample input plugins # if requested, build the sample input plugins
if env['SAMPLE_INPUT_PLUGINS']: if env['SAMPLE_INPUT_PLUGINS']:
SConscript('plugins/input/templates/helloworld/build.py') SConscript('plugins/input/templates/helloworld/build.py')