2006-03-31 12:32:02 +02:00
# This file is part of Mapnik (c++ mapping toolkit)
2006-02-01 00:18:24 +01:00
#
2009-02-28 22:18:32 +01:00
# Copyright (C) 2009 Artem Pavlenko, Jean-Francois Doyon, Dane Springmeyer
2006-02-01 00:18:24 +01:00
#
2006-03-31 12:32:02 +02: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
2005-06-14 17:06:59 +02:00
2006-03-31 12:32:02 +02:00
2009-02-27 00:35:09 +01:00
import os
import sys
2009-03-01 00:55:03 +01:00
import re
2009-02-27 00:35:09 +01:00
import platform
from glob import glob
2013-05-16 18:59:21 +02:00
from copy import copy
2009-02-04 00:00:03 +01:00
from subprocess import Popen, PIPE
2009-02-27 00:35:09 +01:00
from SCons.SConf import SetCacheMode
import pickle
2009-03-04 06:11:21 +01:00
try:
import distutils.sysconfig
HAS_DISTUTILS = True
except:
HAS_DISTUTILS = False
2009-04-14 02:01:21 +02:00
2012-08-16 03:32:28 +02:00
LIBDIR_SCHEMA_DEFAULT='lib'
2012-08-17 00:52:32 +02:00
severities = ['debug', 'warn', 'error', 'none']
2011-06-01 21:43:11 +02:00
2013-05-10 22:24:41 +02:00
DEFAULT_CC = "gcc"
DEFAULT_CXX = "g++"
if sys.platform == 'darwin':
DEFAULT_CC = "clang"
DEFAULT_CXX = "clang++"
2012-07-05 20:54:43 +02:00
py3 = None
2011-06-01 21:43:11 +02:00
# local file to hold custom user configuration variables
# Todo check timestamp, reload if changed?
SCONS_LOCAL_CONFIG = 'config.py'
# build log
SCONS_LOCAL_LOG = 'config.log'
# local pickled file to cache configured environment
SCONS_CONFIGURE_CACHE = 'config.cache'
# directory SCons uses to stash build tests
SCONF_TEMP_DIR = '.sconf_temp'
# auto-search directories for boost libs/headers
BOOST_SEARCH_PREFIXES = ['/usr/local','/opt/local','/sw','/usr',]
2012-05-25 02:07:56 +02:00
BOOST_MIN_VERSION = '1.47'
2013-01-09 21:49:39 +01:00
#CAIRO_MIN_VERSION = '1.8.0'
2011-06-01 21:43:11 +02:00
DEFAULT_LINK_PRIORITY = ['internal','other','frameworks','user','system']
pretty_dep_names = {
2013-06-02 23:15:02 +02:00
'ociei':'Oracle database library | configure with OCCI_LIBS & OCCI_INCLUDES | more info: https://github.com/mapnik/mapnik/wiki/OCCI',
2012-08-16 21:27:58 +02:00
'gdal':'GDAL C++ library | configured using gdal-config program | try setting GDAL_CONFIG SCons option | more info: https://github.com/mapnik/mapnik/wiki/GDAL',
2013-06-02 23:15:02 +02:00
'ogr':'OGR-enabled GDAL C++ Library | configured using gdal-config program | try setting GDAL_CONFIG SCons option | more info: https://github.com/mapnik/mapnik/wiki/OGR',
2011-06-01 21:43:11 +02:00
'cairo':'Cairo C library | configured using pkg-config | try setting PKG_CONFIG_PATH SCons option',
'pycairo':'Python bindings to Cairo library | configured using pkg-config | try setting PKG_CONFIG_PATH SCons option',
'proj':'Proj.4 C Projections library | configure with PROJ_LIBS & PROJ_INCLUDES | more info: http://trac.osgeo.org/proj/',
2013-06-02 23:15:02 +02:00
'pg':'Postgres C Library required for PostGIS plugin | configure with pg_config program | more info: https://github.com/mapnik/mapnik/wiki/PostGIS',
'sqlite3':'SQLite3 C Library | configure with SQLITE_LIBS & SQLITE_INCLUDES | more info: https://github.com/mapnik/mapnik/wiki/SQLite',
2011-06-01 21:43:11 +02:00
'jpeg':'JPEG C library | configure with JPEG_LIBS & JPEG_INCLUDES',
'tiff':'TIFF C library | configure with TIFF_LIBS & TIFF_INCLUDES',
'png':'PNG C library | configure with PNG_LIBS & PNG_INCLUDES',
'icuuc':'ICU C++ library | configure with ICU_LIBS & ICU_INCLUDES or use ICU_LIB_NAME to specify custom lib name | more info: http://site.icu-project.org/',
'z':'Z compression library | more info: http://www.zlib.net/',
'm':'Basic math library, part of C++ stlib',
'pkg-config':'pkg-config tool | more info: http://pkg-config.freedesktop.org',
'pg_config':'pg_config program | try setting PG_CONFIG SCons option',
'xml2-config':'xml2-config program | try setting XML2_CONFIG SCons option',
2013-05-22 01:22:04 +02:00
'libxml2':'libxml2 library | try setting XML2_CONFIG SCons option to point to location of xml2-config program',
2011-06-01 21:43:11 +02:00
'gdal-config':'gdal-config program | try setting GDAL_CONFIG SCons option',
'freetype-config':'freetype-config program | try setting FREETYPE_CONFIG SCons option',
2013-06-02 23:15:02 +02:00
'osm':'more info: https://github.com/mapnik/mapnik/wiki/OsmPlugin',
'curl':'libcurl is required for the "osm" plugin - more info: https://github.com/mapnik/mapnik/wiki/OsmPlugin',
2011-06-01 21:43:11 +02:00
'boost_regex_icu':'libboost_regex built with optional ICU unicode support is needed for unicode regex support in mapnik.',
'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)'
}
2012-05-24 00:02:43 +02:00
2011-06-01 21:43:11 +02:00
# Core plugin build configuration
# opts.AddVariables still hardcoded however...
PLUGINS = { # plugins with external dependencies
2012-07-19 17:08:25 +02:00
# configured by calling project, hence 'path':None
2011-06-01 21:43:11 +02:00
'postgis': {'default':True,'path':None,'inc':'libpq-fe.h','lib':'pq','lang':'C'},
'gdal': {'default':True,'path':None,'inc':'gdal_priv.h','lib':'gdal','lang':'C++'},
'ogr': {'default':True,'path':None,'inc':'ogrsf_frmts.h','lib':'gdal','lang':'C++'},
# configured with custom paths, hence 'path': PREFIX/INCLUDES/LIBS
'occi': {'default':False,'path':'OCCI','inc':'occi.h','lib':'ociei','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'},
2012-05-24 00:02:43 +02:00
2011-06-01 21:43:11 +02:00
# todo: osm plugin does also depend on libxml2 (but there is a separate check for that)
2013-05-23 01:19:10 +02:00
'osm': {'default':False,'path':None,'inc':'curl/curl.h','lib':'curl','lang':'C'},
2011-06-01 21:43:11 +02:00
# plugins without external dependencies requiring CheckLibWithHeader...
'shape': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
2011-10-19 03:22:02 +02:00
'csv': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
2011-06-01 21:43:11 +02:00
'raster': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
2012-06-13 14:30:58 +02:00
'geojson': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
2013-05-22 22:48:56 +02:00
'python': {'default':False,'path':None,'inc':None,'lib':None,'lang':'C++'},
2011-06-01 21:43:11 +02:00
}
2009-04-14 02:01:21 +02:00
#### SCons build options and initial setup ####
2009-07-08 20:40:10 +02:00
env = Environment(ENV=os.environ)
2012-07-07 03:08:19 +02:00
env.Decider('MD5-timestamp')
env.SourceCode(".", None)
2009-04-14 02:01:21 +02:00
2009-02-03 22:14:45 +01:00
def color_print(color,text,newline=True):
2009-01-26 23:58:55 +01:00
# 1 - red
# 2 - green
# 3 - yellow
# 4 - blue
2009-02-03 22:14:45 +01:00
text = "\033[9%sm%s\033[0m" % (color,text)
if not newline:
print text,
else:
print text
2009-01-26 23:58:55 +01:00
2009-04-14 02:01:21 +02:00
def regular_print(color,text,newline=True):
if not newline:
print text,
else:
print text
2010-01-06 00:51:10 +01:00
def call(cmd, silent=False):
2010-08-26 00:20:19 +02:00
stdin, stderr = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE).communicate()
2009-02-04 00:00:03 +01:00
if not stderr:
2009-02-25 23:56:47 +01:00
return stdin.strip()
2010-01-06 00:51:10 +01:00
elif not silent:
2012-08-16 21:27:58 +02:00
color_print(1,'Problem encounted with SCons scripts, please post bug report to: https://github.com/mapnik/mapnik/issues \nError was: %s' % stderr)
2009-02-04 00:00:03 +01:00
2011-08-15 09:00:06 +02:00
def strip_first(string,find,replace=''):
if string.startswith(find):
return string.replace(find,replace,1)
return string
2010-07-18 22:39:05 +02:00
# http://www.scons.org/wiki/InstallTargets
def create_uninstall_target(env, path, is_glob=False):
2010-07-18 23:26:50 +02:00
if 'uninstall' in COMMAND_LINE_TARGETS:
if is_glob:
all_files = Glob(path,strings=True)
for filei in all_files:
env.Command( "uninstall-"+filei, filei,
[
Delete("$SOURCE"),
])
env.Alias("uninstall", "uninstall-"+filei)
else:
if os.path.exists(path):
env.Command( "uninstall-"+path, path,
[
Delete("$SOURCE"),
])
env.Alias("uninstall", "uninstall-"+path)
2012-05-24 00:02:43 +02:00
2009-07-08 23:08:13 +02:00
def shortest_name(libs):
name = '-'*200
for lib in libs:
if len(name) > len(lib):
name = lib
return name
2013-05-16 18:59:21 +02:00
def rm_path(item,set,_env):
for i in _env[set]:
if item in i:
_env[set].remove(i)
2010-02-23 03:40:46 +01:00
def sort_paths(items,priority):
"""Sort paths such that compiling and linking will globally prefer custom or local libs
2013-05-10 22:24:41 +02:00
over system libraries by fixing up the order libs are passed to the compiler and the linker.
2012-05-24 00:02:43 +02:00
2010-02-23 03:40:46 +01:00
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.
2012-05-24 00:02:43 +02:00
2010-02-23 03:40:46 +01:00
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
approach of assuming /usr/LIBSCHEMA and letting paths be parsed and added by pkg-config).
2012-05-24 00:02:43 +02:00
2010-02-23 03:40:46 +01:00
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.
2012-05-24 00:02:43 +02:00
2010-02-23 03:40:46 +01:00
Sorting using a priority list allows this to be controlled, and fine tuned.
"""
2012-05-24 00:02:43 +02:00
2010-02-23 03:40:46 +01:00
new = []
path_types = {'internal':[],'other':[],'frameworks':[],'user':[],'system':[]}
# parse types of paths into logical/meaningful groups
# based on commonly encountered lib directories on linux and osx
for i in items:
# internal paths for code kept inside
# the mapnik sources
if i.startswith('#'):
path_types['internal'].append(i)
# Mac OS X user installed frameworks
elif '/Library/Frameworks' in i:
path_types['frameworks'].append(i)
# various 'local' installs like /usr/local or /opt/local
elif 'local' in i or '/sw' in i:
2010-04-15 23:44:59 +02:00
if '/usr/local' in i:
path_types['user'].insert(0,i)
else:
path_types['user'].append(i)
2010-02-23 03:40:46 +01:00
# key system libs (likely others will fall into 'other')
2011-11-14 04:12:39 +01:00
elif '/usr/' in i or '/System' in i or i.startswith('/lib'):
2010-02-23 03:40:46 +01:00
path_types['system'].append(i)
# anything not yet matched...
# likely a combo of rare system lib paths and
# very custom user paths that should ideally be
# in 'user'
else:
path_types['other'].append(i)
# build up new list based on priority list
for path in priority:
if path_types.has_key(path):
dirs = path_types[path]
new.extend(dirs)
path_types.pop(path)
else:
color_print(1,'\nSorry, "%s" is NOT a valid value for option "LINK_PRIORITY": values include: %s' % (path,','.join(path_types.keys())))
color_print(1,'\tinternal: the local directory of the Mapnik sources (prefix #) (eg. used to link internal agg)')
color_print(1,'\tframeworks: on osx the /Library/Frameworks directory')
color_print(1,'\tuser: any path with "local" or "/sw" inside it')
color_print(1,'\tsystem: any path not yet matched with "/usr/","/lib", or "/System" (osx) inside it')
color_print(1,'\tother: any paths you specified not matched by criteria used to parse the others')
color_print(1,'\tother: any paths you specified not matched by criteria used to parse the others')
color_print(1,'The Default priority is: %s' % ','.join(DEFAULT_LINK_PRIORITY))
color_print(1,'Any priority groups not listed will be appended to the list at the end')
Exit(1)
# append remaining paths potentially not requested
# by any custom priority list defined by user
for k,v in path_types.items():
new.extend(v)
return new
2010-01-06 00:51:10 +01:00
def pretty_dep(dep):
pretty = pretty_dep_names.get(dep)
if pretty:
return '%s (%s)' % (dep,pretty)
elif 'boost' in dep:
2013-06-02 23:15:02 +02:00
return '%s (%s)' % (dep,'more info see: https://github.com/mapnik/mapnik/wiki/Mapnik-Installation & http://www.boost.org')
2010-01-06 00:51:10 +01:00
return dep
2009-02-03 22:14:45 +01:00
DEFAULT_PLUGINS = []
for k,v in PLUGINS.items():
if v['default']:
2009-02-25 23:56:47 +01:00
DEFAULT_PLUGINS.append(k)
2009-02-03 22:14:45 +01:00
2008-01-21 21:15:07 +01:00
# All of the following options may be modified at the command-line, for example:
2009-01-26 23:58:55 +01:00
# `python scons/scons.py PREFIX=/opt`
opts = Variables()
2009-02-25 23:56:47 +01:00
opts.AddVariables(
# Compiler options
2013-05-10 22:24:41 +02:00
('CXX', 'The C++ compiler to use to compile mapnik', DEFAULT_CXX),
('CC', 'The C compiler used for configure checks of C libs.', DEFAULT_CC),
2010-09-18 20:02:15 +02:00
('CUSTOM_CXXFLAGS', 'Custom C++ flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir>', ''),
2013-03-14 03:49:59 +01:00
('CUSTOM_DEFINES', 'Custom Compiler DEFINES, e.g. -DENABLE_THIS', ''),
2012-06-13 23:17:58 +02:00
('CUSTOM_CFLAGS', 'Custom C flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir> (only used for configure checks)', ''),
2010-09-18 20:02:15 +02:00
('CUSTOM_LDFLAGS', 'Custom linker flags, e.g. -L<lib dir> if you have libraries in a nonstandard directory <lib dir>', ''),
2011-08-11 21:14:00 +02:00
EnumVariable('LINKING', "Set library format for libmapnik",'shared', ['shared','static']),
2011-08-12 22:01:09 +02:00
EnumVariable('RUNTIME_LINK', "Set preference for linking dependencies",'shared', ['shared','static']),
2013-05-10 22:24:41 +02:00
EnumVariable('OPTIMIZATION','Set compiler optimization level','3', ['0','1','2','3','4','s']),
2009-02-25 23:56:47 +01:00
# Note: setting DEBUG=True will override any custom OPTIMIZATION level
BoolVariable('DEBUG', 'Compile a debug version of Mapnik', 'False'),
2011-11-14 09:49:46 +01:00
BoolVariable('DEBUG_UNDEFINED', 'Compile a version of Mapnik using clang/llvm undefined behavior asserts', 'False'),
2009-02-25 23:56:47 +01:00
ListVariable('INPUT_PLUGINS','Input drivers to include',DEFAULT_PLUGINS,PLUGINS.keys()),
2011-08-11 16:31:46 +02:00
('WARNING_CXXFLAGS', 'Compiler flags you can set to reduce warning levels which are placed after -Wall.', ''),
2012-05-24 00:02:43 +02:00
2009-02-25 23:56:47 +01:00
# SCons build behavior options
2013-03-25 19:19:51 +01:00
('HOST', 'Set the target host for cross compiling"', ''),
2009-02-25 23:56:47 +01:00
('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'),
2010-09-18 18:50:05 +02:00
# http://www.scons.org/wiki/GoFastButton
2011-08-12 02:01:04 +02:00
# http://stackoverflow.com/questions/1318863/how-to-optimize-an-scons-script
2011-09-16 00:15:04 +02:00
BoolVariable('FAST', "Make SCons faster at the cost of less precise dependency tracking", 'False'),
2011-08-11 16:35:02 +02:00
BoolVariable('PRIORITIZE_LINKING', 'Sort list of lib and inc directories to ensure preferential compiling and linking (useful when duplicate libs)', 'True'),
2012-05-24 00:02:43 +02:00
('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)),
2009-02-25 23:56:47 +01:00
# Install Variables
('PREFIX', 'The install path "prefix"', '/usr/local'),
2012-08-16 03:32:28 +02:00
('LIBDIR_SCHEMA', 'The library sub-directory appended to the "prefix", sometimes lib64 on 64bit linux systems', LIBDIR_SCHEMA_DEFAULT),
2009-02-25 23:56:47 +01:00
('PYTHON_PREFIX','Custom install path "prefix" for python bindings (default of no prefix)',''),
('DESTDIR', 'The root directory to install into. Useful mainly for binary package building', '/'),
2011-10-13 23:19:21 +02:00
('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)', ''),
2011-11-16 21:47:31 +01:00
('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', ''),
2012-05-24 00:02:43 +02:00
2009-02-25 23:56:47 +01:00
# Boost variables
2009-07-02 01:52:51 +02:00
# default is '/usr/include', see FindBoost method below
('BOOST_INCLUDES', 'Search path for boost include files', '',False),
# default is '/usr/' + LIBDIR_SCHEMA, see FindBoost method below
('BOOST_LIBS', 'Search path for boost library files', '',False),
2009-02-25 23:56:47 +01:00
('BOOST_TOOLKIT','Specify boost toolkit, e.g., gcc41.','',False),
('BOOST_ABI', 'Specify boost ABI, e.g., d.','',False),
('BOOST_VERSION','Specify boost version, e.g., 1_35.','',False),
2012-07-05 20:54:43 +02:00
('BOOST_PYTHON_LIB','Specify library name to specific Boost Python lib (e.g. "boost_python-py26")','boost_python'),
2012-05-24 00:02:43 +02:00
2009-02-25 23:56:47 +01:00
# Variables for required dependencies
('FREETYPE_CONFIG', 'The path to the freetype-config executable.', 'freetype-config'),
('XML2_CONFIG', 'The path to the xml2-config executable.', 'xml2-config'),
PathVariable('ICU_INCLUDES', 'Search path for ICU include files', '/usr/include', PathVariable.PathAccept),
2012-08-16 03:32:28 +02:00
PathVariable('ICU_LIBS','Search path for ICU include files','/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
2013-05-16 20:33:23 +02:00
('ICU_LIB_NAME', 'The library name for icu (such as icuuc, sicuuc, or icucore)', 'icuuc', PathVariable.PathAccept),
2013-01-29 08:17:37 +01:00
BoolVariable('PNG', 'Build Mapnik with PNG read and write support', 'True'),
PathVariable('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include', PathVariable.PathAccept),
PathVariable('PNG_LIBS','Search path for libpng library files','/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
2012-05-24 00:02:43 +02:00
BoolVariable('JPEG', 'Build Mapnik with JPEG read and write support', 'True'),
2009-02-25 23:56:47 +01:00
PathVariable('JPEG_INCLUDES', 'Search path for libjpeg include files', '/usr/include', PathVariable.PathAccept),
2012-08-16 03:32:28 +02:00
PathVariable('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
2013-01-29 08:17:37 +01:00
BoolVariable('TIFF', 'Build Mapnik with TIFF read and write support', 'True'),
2009-02-25 23:56:47 +01:00
PathVariable('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include', PathVariable.PathAccept),
2012-08-16 03:32:28 +02:00
PathVariable('TIFF_LIBS', 'Search path for libtiff library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
2013-01-29 08:21:27 +01:00
BoolVariable('PROJ', 'Build Mapnik with proj4 support to enable transformations between many different projections', 'True'),
2012-08-15 23:16:49 +02:00
PathVariable('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/include', PathVariable.PathAccept),
2012-08-16 03:32:28 +02:00
PathVariable('PROJ_LIBS', 'Search path for PROJ.4 library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
2009-07-02 02:48:42 +02:00
('PKG_CONFIG_PATH', 'Use this path to point pkg-config to .pc files instead of the PKG_CONFIG_PATH environment setting',''),
2012-05-24 00:02:43 +02:00
2009-02-25 23:56:47 +01:00
# Variables affecting rendering back-ends
2012-05-24 00:02:43 +02:00
2011-09-01 07:14:25 +02:00
BoolVariable('RENDERING_STATS', 'Output rendering statistics during style processing', 'False'),
2012-04-08 02:20:56 +02:00
2012-11-01 18:07:29 +01:00
BoolVariable('SVG_RENDERER', 'build support for native svg renderer', 'False'),
2012-12-20 05:12:13 +01:00
BoolVariable('CPP_TESTS', 'Compile the C++ tests', 'True'),
2013-05-16 03:19:49 +02:00
BoolVariable('BENCHMARK', 'Compile the C++ benchmark scripts', 'False'),
2012-05-24 00:02:43 +02:00
2009-02-25 23:56:47 +01:00
# Variables for optional dependencies
2013-01-09 21:49:39 +01:00
# Note: cairo and and pycairo are optional but configured automatically through pkg-config
2009-02-25 23:56:47 +01:00
# Therefore, we use a single boolean for whether to attempt to build cairo support.
2011-03-04 23:15:11 +01:00
BoolVariable('CAIRO', 'Attempt to build with Cairo rendering support', 'True'),
2013-01-09 18:00:30 +01:00
PathVariable('CAIRO_INCLUDES', 'Search path for cairo include files', '',PathVariable.PathAccept),
PathVariable('CAIRO_LIBS', 'Search path for cairo library files','',PathVariable.PathAccept),
2009-02-28 22:18:32 +01:00
('GDAL_CONFIG', 'The path to the gdal-config executable for finding gdal and ogr details.', 'gdal-config'),
('PG_CONFIG', 'The path to the pg_config executable.', 'pg_config'),
2009-02-25 23:56:47 +01:00
PathVariable('OCCI_INCLUDES', 'Search path for OCCI include files', '/usr/lib/oracle/10.2.0.3/client/include', PathVariable.PathAccept),
2012-08-16 03:32:28 +02:00
PathVariable('OCCI_LIBS', 'Search path for OCCI library files', '/usr/lib/oracle/10.2.0.3/client/'+ LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
2009-02-25 23:56:47 +01:00
PathVariable('SQLITE_INCLUDES', 'Search path for SQLITE include files', '/usr/include/', PathVariable.PathAccept),
2012-08-16 03:32:28 +02:00
PathVariable('SQLITE_LIBS', 'Search path for SQLITE library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
2009-12-16 21:02:06 +01:00
PathVariable('RASTERLITE_INCLUDES', 'Search path for RASTERLITE include files', '/usr/include/', PathVariable.PathAccept),
2012-08-16 03:32:28 +02:00
PathVariable('RASTERLITE_LIBS', 'Search path for RASTERLITE library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
2012-04-08 02:20:56 +02:00
# Variables for logging and statistics
2012-04-12 03:08:11 +02:00
BoolVariable('ENABLE_LOG', 'Enable logging, which is enabled by default when building in *debug*', 'False'),
2012-04-08 02:20:56 +02:00
BoolVariable('ENABLE_STATS', 'Enable global statistics during map processing', 'False'),
2013-03-27 09:01:03 +01:00
('DEFAULT_LOG_SEVERITY', 'The default severity of the logger (eg. ' + ', '.join(severities) + ')', 'error'),
2012-04-08 02:20:56 +02:00
2013-05-16 20:33:23 +02:00
# Plugin linking
EnumVariable('PLUGIN_LINKING', "Set plugin linking with libmapnik", 'shared', ['shared','static']),
2009-02-25 23:56:47 +01:00
# Other variables
2009-07-08 02:53:13 +02:00
BoolVariable('SHAPE_MEMORY_MAPPED_FILE', 'Utilize memory-mapped files in Shapefile Plugin (higher memory usage, better performance)', 'True'),
2012-09-13 22:40:15 +02:00
('SYSTEM_FONTS','Provide location for python bindings to register fonts (if provided then the bundled DejaVu fonts are not installed)',''),
2011-11-23 12:33:58 +01:00
('LIB_DIR_NAME','Name to use for the subfolder beside libmapnik where fonts and plugins are installed','mapnik'),
2009-02-25 23:56:47 +01:00
PathVariable('PYTHON','Full path to Python executable used to build bindings', sys.executable),
2009-04-26 05:33:29 +02:00
BoolVariable('FRAMEWORK_PYTHON', 'Link against Framework Python on Mac OS X', 'True'),
2011-09-01 03:30:23 +02:00
BoolVariable('PYTHON_DYNAMIC_LOOKUP', 'On OSX, do not directly link python lib, but rather dynamically lookup symbols', 'True'),
2009-12-05 04:07:58 +01:00
('FRAMEWORK_SEARCH_PATH','Custom framework search path on Mac OS X', ''),
2009-07-08 01:23:07 +02:00
BoolVariable('FULL_LIB_PATH', 'Use the full path for the libmapnik.dylib "install_name" when linking on Mac OS X', 'True'),
2009-02-25 23:56:47 +01:00
ListVariable('BINDINGS','Language bindings to build','all',['python']),
EnumVariable('THREADING','Set threading support','multi', ['multi','single']),
2011-10-12 05:22:49 +02:00
EnumVariable('XMLPARSER','Set xml parser','libxml2', ['libxml2','ptree']),
2009-02-27 00:35:09 +01:00
('JOBS', 'Set the number of parallel compilations', "1", lambda key, value, env: int(value), int),
2012-04-05 00:20:18 +02:00
BoolVariable('DEMO', 'Compile demo c++ application', 'True'),
2009-03-03 20:31:05 +01:00
BoolVariable('PGSQL2SQLITE', 'Compile and install a utility to convert postgres tables to sqlite', 'False'),
2013-02-23 02:15:29 +01:00
BoolVariable('SHAPEINDEX', 'Compile and install a utility to generate shapefile indexes in the custom format (.index) Mapnik supports', 'True'),
BoolVariable('SVG2PNG', 'Compile and install a utility to generate render an svg file to a png on the command line', 'False'),
2009-04-14 02:01:21 +02:00
BoolVariable('COLOR_PRINT', 'Print build status information in color', 'True'),
2010-10-24 10:04:16 +02:00
BoolVariable('SAMPLE_INPUT_PLUGINS', 'Compile and install sample plugins', 'False'),
2013-01-03 17:23:36 +01:00
BoolVariable('BIGINT', 'Compile support for 64-bit integers in mapnik::value', 'True'),
2009-02-25 23:56:47 +01:00
)
2011-08-12 22:01:09 +02:00
2009-02-27 00:35:09 +01:00
# variables to pickle after successful configure step
# these include all scons core variables as well as custom
2010-12-21 21:34:36 +01:00
# env variables needed in SConscript files
2009-02-27 00:35:09 +01:00
pickle_store = [# Scons internal variables
2010-09-18 18:50:05 +02:00
'CC', # compiler user to check if c deps compile during configure
'CXX', # C++ compiler to compile mapnik
2012-06-13 23:17:58 +02:00
'CFLAGS',
2009-02-27 00:35:09 +01:00
'CPPDEFINES',
2010-09-18 18:50:05 +02:00
'CPPFLAGS', # c preprocessor flags
2009-02-27 00:35:09 +01:00
'CPPPATH',
2010-09-18 18:50:05 +02:00
'CXXFLAGS', # C++ flags built up during configure
2009-02-27 00:35:09 +01:00
'LIBPATH',
'LIBS',
'LINKFLAGS',
2010-09-18 20:02:15 +02:00
'CUSTOM_LDFLAGS', # user submitted
2013-03-14 03:49:59 +01:00
'CUSTOM_DEFINES', # user submitted
2010-09-18 20:02:15 +02:00
'CUSTOM_CXXFLAGS', # user submitted
2012-06-13 23:17:58 +02:00
'CUSTOM_CFLAGS', # user submitted
2011-08-11 21:14:00 +02:00
'MAPNIK_LIB_NAME',
'LINK',
'RUNTIME_LINK',
2009-02-27 00:35:09 +01:00
# Mapnik's SConstruct build variables
2009-02-28 22:18:32 +01:00
'PLUGINS',
2009-02-27 00:35:09 +01:00
'ABI_VERSION',
2010-07-18 23:26:50 +02:00
'MAPNIK_VERSION_STRING',
2013-05-10 22:45:18 +02:00
'MAPNIK_VERSION',
2009-02-27 00:35:09 +01:00
'PLATFORM',
'BOOST_ABI',
'BOOST_APPEND',
'LIBDIR_SCHEMA',
'REQUESTED_PLUGINS',
'SUNCC',
'PYTHON_VERSION',
'PYTHON_INCLUDES',
'PYTHON_INSTALL_LOCATION',
2009-12-05 04:07:58 +01:00
'PYTHON_SYS_PREFIX',
2009-04-14 02:01:21 +02:00
'COLOR_PRINT',
2010-07-14 06:40:33 +02:00
'HAS_CAIRO',
2010-07-15 02:20:50 +02:00
'HAS_PYCAIRO',
2010-11-17 20:53:13 +01:00
'HAS_LIBXML2',
2010-12-21 22:04:18 +01:00
'PYTHON_IS_64BIT',
'SAMPLE_INPUT_PLUGINS',
2011-08-11 17:49:57 +02:00
'PKG_CONFIG_PATH',
2011-10-13 23:19:21 +02:00
'PATH',
'PATH_REMOVE',
2011-11-16 21:47:31 +01:00
'PATH_REPLACE',
2011-08-12 22:01:09 +02:00
'MAPNIK_LIB_DIR',
'MAPNIK_LIB_DIR_DEST',
'INSTALL_PREFIX',
'MAPNIK_INPUT_PLUGINS',
'MAPNIK_INPUT_PLUGINS_DEST',
'MAPNIK_FONTS',
'MAPNIK_FONTS_DEST',
'MAPNIK_LIB_BASE',
2011-08-29 20:52:35 +02:00
'MAPNIK_LIB_BASE_DEST',
'EXTRA_FREETYPE_LIBS',
'LIBMAPNIK_CPPATHS',
2013-03-14 03:49:59 +01:00
'LIBMAPNIK_DEFINES',
2011-08-29 20:52:35 +02:00
'LIBMAPNIK_CXXFLAGS',
2013-01-09 21:49:39 +01:00
'CAIRO_LIBPATHS',
2013-05-16 20:33:23 +02:00
'CAIRO_ALL_LIBS',
2013-01-09 21:49:39 +01:00
'CAIRO_CPPPATHS',
2012-11-01 18:07:29 +01:00
'SVG_RENDERER',
2012-01-09 02:13:19 +01:00
'SQLITE_LINKFLAGS',
2013-01-03 17:23:36 +01:00
'BOOST_LIB_VERSION_FROM_HEADER',
'BIGINT'
2009-02-27 00:35:09 +01:00
]
# Add all other user configurable options to pickle pickle_store
# We add here more options than are needed for the build stage
# but helpful so that scons -h shows the exact cached options
for opt in opts.options:
if opt.key not in pickle_store:
pickle_store.append(opt.key)
2009-03-30 18:52:31 +02:00
# Method of adding configure behavior to Scons adapted from:
2009-02-27 00:35:09 +01:00
# http://freeorion.svn.sourceforge.net/svnroot/freeorion/trunk/FreeOrion/SConstruct
preconfigured = False
force_configure = False
command_line_args = sys.argv[1:]
2010-01-06 00:51:10 +01:00
HELP_REQUESTED = False
if ('-h' in command_line_args) or ('--help' in command_line_args):
HELP_REQUESTED = True
2012-05-24 00:02:43 +02:00
2013-02-27 16:37:27 +01:00
if ('install' not in command_line_args) and ('-c' in command_line_args) or ('--clean' in command_line_args):
2013-02-22 01:42:33 +01:00
HELP_REQUESTED = True
2010-01-06 00:51:10 +01:00
2011-02-03 09:16:39 +01:00
if 'configure' in command_line_args and not HELP_REQUESTED:
2009-02-27 00:35:09 +01:00
force_configure = True
2010-01-06 00:51:10 +01:00
elif HELP_REQUESTED:
2011-02-03 09:16:39 +01:00
# to ensure config gets skipped when help is requested
preconfigured = True
2009-02-27 00:35:09 +01:00
2009-03-30 18:52:31 +02:00
# initially populate environment with defaults and any possible custom arguments
opts.Update(env)
# if we are not configuring overwrite environment with pickled settings
2009-02-27 00:35:09 +01:00
if not force_configure:
if os.path.exists(SCONS_CONFIGURE_CACHE):
try:
pickled_environment = open(SCONS_CONFIGURE_CACHE, 'r')
pickled_values = pickle.load(pickled_environment)
for key, value in pickled_values.items():
env[key] = value
preconfigured = True
except:
preconfigured = False
2009-01-26 23:58:55 +01:00
else:
2009-02-27 00:35:09 +01:00
preconfigured = False
2009-01-26 23:58:55 +01:00
2010-02-21 02:00:09 +01:00
# check for missing keys in pickled settings
# which can occur when keys are added or changed between
# rebuilds, e.g. for folks following trunk
for opt in pickle_store:
if not opt in env:
2011-02-03 09:16:39 +01:00
#print 'missing opt', opt
2010-02-21 02:00:09 +01:00
preconfigured = False
2009-03-30 18:52:31 +02:00
# if custom arguments are supplied make sure to accept them
2009-03-09 05:45:09 +01:00
if opts.args:
2012-05-24 00:02:43 +02:00
# since we have custom arguments update environment with all opts to
2009-03-30 18:52:31 +02:00
# make sure to absorb the custom ones
opts.Update(env)
2012-05-24 00:02:43 +02:00
# now since we've got custom arguments we'll disregard any
2009-03-30 18:52:31 +02:00
# pickled environment and force another configuration
2009-03-09 05:45:09 +01:00
preconfigured = False
2009-03-30 18:52:31 +02:00
2009-03-09 05:45:09 +01:00
elif preconfigured:
2010-01-06 00:51:10 +01:00
if not HELP_REQUESTED:
2009-03-09 05:45:09 +01:00
color_print(4,'Using previous successful configuration...')
color_print(4,'Re-configure by running "python scons/scons.py configure".')
2010-10-07 02:42:47 +02:00
if env.has_key('COLOR_PRINT') and env['COLOR_PRINT'] == False:
color_print = regular_print
if sys.platform == "win32":
color_print = regular_print
color_print(4,'\nWelcome to Mapnik...\n')
2009-01-26 23:58:55 +01:00
2009-02-27 00:35:09 +01:00
#### Custom Configure Checks ###
2008-01-28 15:51:10 +01:00
2012-05-24 00:02:43 +02:00
def prioritize_paths(context,silent=True):
2010-02-23 03:40:46 +01:00
env = context.env
prefs = env['LINK_PRIORITY'].split(',')
2010-08-21 07:35:38 +02:00
if not silent:
2011-10-20 06:40:49 +02:00
context.Message( 'Sorting lib and inc compiler paths...')
2010-02-23 03:40:46 +01:00
env['LIBPATH'] = sort_paths(env['LIBPATH'],prefs)
env['CPPPATH'] = sort_paths(env['CPPPATH'],prefs)
2010-08-21 07:35:38 +02:00
if silent:
context.did_show_result=1
2010-02-23 03:40:46 +01:00
ret = context.Result( True )
return ret
2009-01-10 13:08:55 +01:00
def CheckPKGConfig(context, version):
2009-02-25 23:56:47 +01:00
context.Message( 'Checking for pkg-config... ' )
ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0]
context.Result( ret )
return ret
2009-01-10 13:08:55 +01:00
def CheckPKG(context, name):
context.Message( 'Checking for %s... ' % name )
ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
context.Result( ret )
return ret
2011-06-01 21:43:11 +02:00
def CheckPKGVersion(context, name, version):
context.Message( 'Checking for at least version %s for %s... ' % (version,name) )
ret = context.TryAction('pkg-config --atleast-version=%s \'%s\'' % (version,name))[0]
context.Result( ret )
return ret
2009-02-28 22:18:32 +01:00
def parse_config(context, config, checks='--libs --cflags'):
env = context.env
tool = config.lower().replace('_','-')
2010-01-06 00:51:10 +01:00
toolname = tool
2013-04-19 23:09:25 +02:00
if config in ('GDAL_CONFIG'):
2010-01-06 00:51:10 +01:00
toolname += ' %s' % checks
context.Message( 'Checking for %s... ' % toolname)
2009-02-28 22:18:32 +01:00
cmd = '%s %s' % (env[config],checks)
ret = context.TryAction(cmd)[0]
2010-01-06 00:51:10 +01:00
parsed = False
2009-02-28 22:18:32 +01:00
if ret:
2010-01-06 00:51:10 +01:00
try:
2011-02-03 21:21:35 +01:00
if 'gdal-config' in cmd:
env.ParseConfig(cmd)
2011-02-23 22:24:23 +01:00
# hack for potential -framework GDAL syntax
# which will not end up being added to env['LIBS']
# and thus breaks knowledge below that gdal worked
# TODO - upgrade our scons logic to support Framework linking
if env['PLATFORM'] == 'Darwin':
value = call(cmd,silent=True)
if value and '-framework GDAL' in value:
env['LIBS'].append('gdal')
if os.path.exists('/Library/Frameworks/GDAL.framework/unix/lib'):
env['LIBPATH'].insert(0,'/Library/Frameworks/GDAL.framework/unix/lib')
if 'GDAL' in env.get('FRAMEWORKS',[]):
env["FRAMEWORKS"].remove("GDAL")
2011-02-03 21:21:35 +01:00
else:
env.ParseConfig(cmd)
2010-01-06 00:51:10 +01:00
parsed = True
except OSError, e:
ret = False
print ' (xml2-config not found!)'
if not parsed:
2013-04-19 23:09:25 +02:00
if config in ('GDAL_CONFIG'):
2010-12-21 22:43:25 +01:00
# optional deps...
2009-03-01 07:45:59 +01:00
env['SKIPPED_DEPS'].append(tool)
2010-12-21 22:43:25 +01:00
conf.rollback_option(config)
else: # freetype and libxml2, not optional
2012-05-24 00:02:43 +02:00
env['MISSING_DEPS'].append(tool)
2009-02-28 22:18:32 +01:00
context.Result( ret )
return ret
2009-03-01 00:55:03 +01:00
def get_pkg_lib(context, config, lib):
libpattern = r'-l([^\s]*)'
libname = None
env = context.env
context.Message( 'Checking for name of %s library... ' % lib)
cmd = '%s --libs' % env[config]
ret = context.TryAction(cmd)[0]
2010-01-06 00:51:10 +01:00
parsed = False
2009-03-01 00:55:03 +01:00
if ret:
2010-01-06 00:51:10 +01:00
try:
2011-02-03 21:21:35 +01:00
value = call(cmd,silent=True)
2014-06-18 06:34:57 +02:00
if ' ' in value:
parts = value.split(' ')
if len(parts) > 1:
value = parts[1]
2011-02-03 21:21:35 +01:00
libnames = re.findall(libpattern,value)
2010-01-06 00:51:10 +01:00
if libnames:
2011-02-03 21:21:35 +01:00
libname = libnames[0]
else:
# osx 1.8 install gives '-framework GDAL'
libname = 'gdal'
2010-01-06 00:51:10 +01:00
except Exception, e:
ret = False
print ' unable to determine library name:'# %s' % str(e)
return None
2009-03-01 00:55:03 +01:00
context.Result( libname )
2009-03-09 01:27:06 +01:00
return libname
2009-03-01 00:55:03 +01:00
2009-02-28 22:18:32 +01:00
def parse_pg_config(context, config):
2011-08-11 21:14:00 +02:00
# TODO - leverage `LDFLAGS_SL` if RUNTIME_LINK==static
2009-02-28 22:18:32 +01:00
env = context.env
tool = config.lower()
context.Message( 'Checking for %s... ' % tool)
ret = context.TryAction(env[config])[0]
if ret:
lib_path = call('%s --libdir' % env[config])
inc_path = call('%s --includedir' % env[config])
2011-08-11 21:14:00 +02:00
env.AppendUnique(CPPPATH = os.path.realpath(inc_path))
env.AppendUnique(LIBPATH = os.path.realpath(lib_path))
2009-03-06 17:12:39 +01:00
lpq = env['PLUGINS']['postgis']['lib']
env.Append(LIBS = lpq)
2009-02-28 22:18:32 +01:00
else:
2009-03-01 07:45:59 +01:00
env['SKIPPED_DEPS'].append(tool)
2009-03-09 05:45:09 +01:00
conf.rollback_option(config)
2009-02-28 22:18:32 +01:00
context.Result( ret )
return ret
def ogr_enabled(context):
env = context.env
context.Message( 'Checking if gdal is ogr enabled... ')
2009-03-01 07:45:59 +01:00
ret = context.TryAction('%s --ogr-enabled' % env['GDAL_CONFIG'])[0]
2009-02-28 22:18:32 +01:00
if not ret:
env['SKIPPED_DEPS'].append('ogr')
context.Result( ret )
return ret
2009-03-09 05:45:09 +01:00
def rollback_option(context,variable):
global opts
env = context.env
for item in opts.options:
if item.key == variable:
env[variable] = item.default
2013-02-19 12:12:13 +01:00
def update_linux_project_files():
headers_content = []
source_content = []
directories = [
'include',
'src',
'bindings',
'boost',
'plugins',
'deps',
]
def iterate_dirs(headers_content, source_content, d):
2013-03-06 13:21:53 +01:00
if not "uninstall-" in d:
for root, subFolders, files in os.walk(d):
for f in files:
if f.endswith(".h") or f.endswith(".hpp"):
headers_content.append(" ../%s \\" % os.path.join(root, f))
if f.endswith(".cpp") or f.endswith(".c"):
source_content.append(" ../%s \\" % os.path.join(root, f))
for sd in subFolders:
2013-03-06 13:13:20 +01:00
headers_content, source_content = \
2013-03-06 13:21:53 +01:00
iterate_dirs(headers_content, source_content, os.path.join(root, sd))
2013-02-19 12:12:13 +01:00
return headers_content, source_content
for d in directories:
headers_content, source_content = \
iterate_dirs(headers_content, source_content, d)
headers_content.sort()
headers_content = ['HEADERS += \\'] + headers_content + ['','']
2013-02-19 12:13:53 +01:00
source_content.sort()
source_content = ['SOURCES += \\'] + source_content + ['','']
2013-02-19 12:12:13 +01:00
files_name = os.path.join('.', 'workspace', 'All.files')
f = open(files_name, "w")
f.writelines([l + '\n' for l in headers_content])
f.writelines([l + '\n' for l in source_content])
f.close()
2009-12-15 20:25:35 +01:00
def FindBoost(context, prefixes, thread_flag):
2009-07-02 01:52:51 +02:00
"""Routine to auto-find boost header dir, lib dir, and library naming structure.
2012-05-24 00:02:43 +02:00
2009-07-02 01:52:51 +02:00
"""
context.Message( 'Searching for boost libs and headers... ' )
env = context.env
2012-05-24 00:02:43 +02:00
2009-07-02 01:52:51 +02:00
BOOST_LIB_DIR = None
BOOST_INCLUDE_DIR = None
BOOST_APPEND = None
env['BOOST_APPEND'] = str()
2012-05-24 00:02:43 +02:00
2009-08-04 17:56:21 +02:00
if env['THREADING'] == 'multi':
2012-05-24 00:02:43 +02:00
search_lib = 'libboost_thread'
2009-08-04 17:56:21 +02:00
else:
search_lib = 'libboost_filesystem'
2010-08-26 00:20:19 +02:00
# note: must call normpath to strip trailing slash otherwise dirname
# does not remove 'lib' and 'include'
prefixes.insert(0,os.path.dirname(os.path.normpath(env['BOOST_INCLUDES'])))
prefixes.insert(0,os.path.dirname(os.path.normpath(env['BOOST_LIBS'])))
2009-07-02 01:52:51 +02:00
for searchDir in prefixes:
2012-08-16 03:32:28 +02:00
libItems = glob(os.path.join(searchDir, env['LIBDIR_SCHEMA'], '%s*.*' % search_lib))
2009-07-02 01:52:51 +02:00
if not libItems:
2009-08-04 17:56:21 +02:00
libItems = glob(os.path.join(searchDir, 'lib/%s*.*' % search_lib))
2009-07-02 01:52:51 +02:00
incItems = glob(os.path.join(searchDir, 'include/boost*/'))
if len(libItems) >= 1 and len(incItems) >= 1:
BOOST_LIB_DIR = os.path.dirname(libItems[0])
BOOST_INCLUDE_DIR = incItems[0].rstrip('boost/')
2009-07-08 23:08:13 +02:00
shortest_lib_name = shortest_name(libItems)
2009-08-04 17:56:21 +02:00
match = re.search(r'%s(.*)\..*' % search_lib, shortest_lib_name)
2009-07-02 01:52:51 +02:00
if hasattr(match,'groups'):
BOOST_APPEND = match.groups()[0]
break
2012-05-24 00:02:43 +02:00
2009-07-02 01:52:51 +02:00
msg = str()
2012-05-24 00:02:43 +02:00
2009-07-22 03:31:35 +02:00
if BOOST_LIB_DIR:
2013-05-17 19:07:06 +02:00
msg += '\nFound boost libs: %s' % BOOST_LIB_DIR
2009-07-22 03:31:35 +02:00
env['BOOST_LIBS'] = BOOST_LIB_DIR
2009-07-02 01:52:51 +02:00
else:
2012-08-16 03:32:28 +02:00
env['BOOST_LIBS'] = '/usr/' + env['LIBDIR_SCHEMA']
2013-05-17 19:07:06 +02:00
msg += '\nUsing default boost lib dir: %s' % env['BOOST_LIBS']
2012-05-24 00:02:43 +02:00
2009-07-22 03:31:35 +02:00
if BOOST_INCLUDE_DIR:
2013-05-17 19:07:06 +02:00
msg += '\nFound boost headers: %s' % BOOST_INCLUDE_DIR
2009-07-22 03:31:35 +02:00
env['BOOST_INCLUDES'] = BOOST_INCLUDE_DIR
2009-07-02 01:52:51 +02:00
else:
2009-07-22 03:31:35 +02:00
env['BOOST_INCLUDES'] = '/usr/include'
2013-05-17 19:07:06 +02:00
msg += '\nUsing default boost include dir: %s' % env['BOOST_INCLUDES']
2012-05-24 00:02:43 +02:00
2009-07-02 01:52:51 +02:00
if not env['BOOST_TOOLKIT'] and not env['BOOST_ABI'] and not env['BOOST_VERSION']:
if BOOST_APPEND:
2013-05-17 19:07:06 +02:00
msg += '\nFound boost lib name extension: %s' % BOOST_APPEND
2009-08-04 17:56:21 +02:00
env['BOOST_APPEND'] = BOOST_APPEND
2009-07-02 01:52:51 +02:00
else:
# Creating BOOST_APPEND according to the Boost library naming order,
# which goes <toolset>-<threading>-<abi>-<version>. See:
# http://www.boost.org/doc/libs/1_35_0/more/getting_started/unix-variants.html#library-naming
append_params = ['']
if env['BOOST_TOOLKIT']: append_params.append(env['BOOST_TOOLKIT'])
if thread_flag: append_params.append(thread_flag)
if env['BOOST_ABI']: append_params.append(env['BOOST_ABI'])
if env['BOOST_VERSION']: append_params.append(env['BOOST_VERSION'])
# Constructing the BOOST_APPEND setting that will be used to find the
# Boost libraries.
2012-05-24 00:02:43 +02:00
if len(append_params) > 1:
2009-07-02 01:52:51 +02:00
env['BOOST_APPEND'] = '-'.join(append_params)
2013-05-17 19:07:06 +02:00
msg += '\nFound boost lib name extension: %s' % env['BOOST_APPEND']
2009-07-02 01:52:51 +02:00
2011-08-12 02:01:04 +02:00
env.AppendUnique(CPPPATH = os.path.realpath(env['BOOST_INCLUDES']))
2012-05-24 00:02:43 +02:00
env.AppendUnique(LIBPATH = os.path.realpath(env['BOOST_LIBS']))
2009-07-02 01:52:51 +02:00
if env['COLOR_PRINT']:
msg = "\033[94m%s\033[0m" % (msg)
ret = context.Result(msg)
return ret
2009-02-17 21:31:04 +01:00
def CheckBoost(context, version, silent=False):
# Boost versions are in format major.minor.subminor
v_arr = version.split(".")
version_n = 0
if len(v_arr) > 0:
version_n += int(v_arr[0])*100000
if len(v_arr) > 1:
version_n += int(v_arr[1])*100
if len(v_arr) > 2:
version_n += int(v_arr[2])
2012-05-24 00:02:43 +02:00
2009-02-17 21:31:04 +01:00
if not silent:
context.Message('Checking for Boost version >= %s... ' % (version))
ret = context.TryRun("""
2009-02-24 19:05:22 +01:00
#include <boost/version.hpp>
2012-05-24 00:02:43 +02:00
int main()
2009-02-24 19:05:22 +01:00
{
return BOOST_VERSION >= %d ? 0 : 1;
}
""" % version_n, '.cpp')[0]
2009-02-17 21:31:04 +01:00
if silent:
context.did_show_result=1
context.Result(ret)
return ret
2009-01-26 23:58:55 +01:00
2013-05-16 17:28:38 +02:00
def CheckCairoHasFreetype(context, silent=False):
if not silent:
2013-05-16 19:03:08 +02:00
context.Message('Checking for cairo freetype font support ... ')
2013-05-16 18:59:21 +02:00
context.env.AppendUnique(CPPPATH=copy(env['CAIRO_CPPPATHS']))
2013-05-16 17:28:38 +02:00
ret = context.TryRun("""
2013-05-16 18:59:21 +02:00
#include <cairo-features.h>
2013-05-16 17:28:38 +02:00
int main()
{
#ifdef CAIRO_HAS_FT_FONT
return 0;
#else
return 1;
#endif
}
""", '.cpp')[0]
if silent:
context.did_show_result=1
context.Result(ret)
2013-05-16 18:59:21 +02:00
for item in env['CAIRO_CPPPATHS']:
rm_path(item,'CPPPATH',context.env)
2013-05-16 17:28:38 +02:00
return ret
2009-02-17 21:31:04 +01:00
def GetBoostLibVersion(context):
ret = context.TryRun("""
2009-02-24 19:05:22 +01:00
#include <boost/version.hpp>
#include <iostream>
2012-05-24 00:02:43 +02:00
int main()
2009-02-24 19:05:22 +01:00
{
std::cout << BOOST_LIB_VERSION << std::endl;
return 0;
}
""", '.cpp')
2009-02-17 21:31:04 +01:00
# hack to avoid printed output
context.did_show_result=1
context.Result(ret[0])
return ret[1].strip()
def GetMapnikLibVersion(context):
ret = context.TryRun("""
2009-02-24 19:05:22 +01:00
#include <mapnik/version.hpp>
#include <iostream>
2012-05-24 00:02:43 +02:00
int main()
2009-02-24 19:05:22 +01:00
{
2012-03-15 01:26:50 +01:00
std::cout << MAPNIK_VERSION_STRING << std::endl;
2009-02-24 19:05:22 +01:00
return 0;
}
""", '.cpp')
2009-02-17 21:31:04 +01:00
# hack to avoid printed output
context.did_show_result=1
context.Result(ret[0])
2009-02-17 23:41:35 +01:00
if not ret[1]:
return []
2012-03-15 01:26:50 +01:00
return ret[1].strip()
2008-12-05 00:20:44 +01:00
2010-11-30 02:25:54 +01:00
def icu_at_least_four_two(context):
ret = context.TryRun("""
#include <unicode/uversion.h>
#include <iostream>
2012-05-24 00:02:43 +02:00
int main()
2010-11-30 02:25:54 +01:00
{
std::cout << U_ICU_VERSION_MAJOR_NUM << "." << U_ICU_VERSION_MINOR_NUM << std::endl;
return 0;
}
""", '.cpp')
# hack to avoid printed output
context.Message('Checking for ICU version >= 4.2... ')
2010-12-21 21:34:36 +01:00
context.did_show_result=1
2010-11-30 02:25:54 +01:00
result = ret[1].strip()
if not result:
context.Result('error, could not get major and minor version from unicode/uversion.h')
return False
2012-05-24 00:02:43 +02:00
2010-11-30 02:25:54 +01:00
major, minor = map(int,result.split('.'))
2011-08-11 23:13:55 +02:00
if major >= 4 and minor >= 0:
2011-10-20 06:40:49 +02:00
color_print(4,'found: icu %s' % result)
2010-11-30 02:25:54 +01:00
return True
2012-05-24 00:02:43 +02:00
2011-10-20 06:40:49 +02:00
color_print(1,'\nFound insufficient icu version... %s' % result)
2010-11-30 02:25:54 +01:00
return False
2011-02-28 21:00:56 +01:00
def boost_regex_has_icu(context):
2012-03-28 01:14:01 +02:00
if env['RUNTIME_LINK'] == 'static':
2013-06-02 23:56:21 +02:00
context.env.AppendUnique(LIBS='icudata')
2011-02-28 21:00:56 +01:00
ret = context.TryRun("""
#include <boost/regex/icu.hpp>
#include <unicode/unistr.h>
2012-05-24 00:02:43 +02:00
int main()
2011-02-28 21:00:56 +01:00
{
2011-03-12 03:46:52 +01:00
UnicodeString ustr;
2012-05-24 00:02:43 +02:00
try {
2011-03-12 03:46:52 +01:00
boost::u32regex pattern = boost::make_u32regex(ustr);
}
// an exception is fine, still indicates support is
// likely compiled into regex
catch (...) {
return 0;
}
2011-02-28 21:00:56 +01:00
return 0;
}
""", '.cpp')
context.Message('Checking if boost_regex was built with ICU unicode support... ')
context.Result(ret[0])
if ret[0]:
return True
return False
2011-04-02 20:25:23 +02:00
2013-06-02 23:15:02 +02:00
def sqlite_has_rtree(context, silent=False):
2011-04-19 01:45:24 +02:00
""" check an sqlite3 install has rtree support.
2012-05-24 00:02:43 +02:00
2011-04-19 01:45:24 +02:00
PRAGMA compile_options;
http://www.sqlite.org/c3ref/compileoption_get.html
"""
2012-05-24 00:02:43 +02:00
2011-04-02 20:25:23 +02:00
ret = context.TryRun("""
2011-11-14 00:13:49 +01:00
#include <sqlite3.h>
#include <stdio.h>
2011-04-02 20:25:23 +02:00
2012-05-24 00:02:43 +02:00
int main()
2011-04-02 20:25:23 +02:00
{
2011-11-14 00:13:49 +01:00
sqlite3* db;
int rc;
rc = sqlite3_open(":memory:", &db);
if (rc != SQLITE_OK)
{
printf("error 1: %s\\n", sqlite3_errmsg(db));
}
const char * sql = "create virtual table foo using rtree(pkid, xmin, xmax, ymin, ymax)";
rc = sqlite3_exec(db, sql, 0, 0, 0);
if (rc != SQLITE_OK)
{
printf("error 2: %s\\n", sqlite3_errmsg(db));
}
else
{
printf("yes, has rtree!\\n");
return 0;
}
2012-05-24 00:02:43 +02:00
2011-11-14 00:13:49 +01:00
return -1;
2011-04-02 20:25:23 +02:00
}
2011-11-14 00:13:49 +01:00
""", '.c')
2013-06-02 23:15:02 +02:00
if not silent:
context.Message('Checking if SQLite supports RTREE... ')
if silent:
context.did_show_result=1
2011-04-02 20:25:23 +02:00
context.Result(ret[0])
if ret[0]:
return True
return False
2012-05-24 00:02:43 +02:00
2010-11-30 02:25:54 +01:00
conf_tests = { 'prioritize_paths' : prioritize_paths,
'CheckPKGConfig' : CheckPKGConfig,
'CheckPKG' : CheckPKG,
2011-06-01 21:43:11 +02:00
'CheckPKGVersion' : CheckPKGVersion,
2010-11-30 02:25:54 +01:00
'FindBoost' : FindBoost,
'CheckBoost' : CheckBoost,
2013-05-16 17:28:38 +02:00
'CheckCairoHasFreetype' : CheckCairoHasFreetype,
2010-11-30 02:25:54 +01:00
'GetBoostLibVersion' : GetBoostLibVersion,
'GetMapnikLibVersion' : GetMapnikLibVersion,
'parse_config' : parse_config,
'parse_pg_config' : parse_pg_config,
'ogr_enabled' : ogr_enabled,
'get_pkg_lib' : get_pkg_lib,
'rollback_option' : rollback_option,
2011-02-28 21:00:56 +01:00
'icu_at_least_four_two' : icu_at_least_four_two,
'boost_regex_has_icu' : boost_regex_has_icu,
2011-04-02 20:25:23 +02:00
'sqlite_has_rtree' : sqlite_has_rtree,
2009-02-27 00:35:09 +01:00
}
2009-03-09 05:59:23 +01:00
if not preconfigured:
2009-02-27 00:35:09 +01:00
2009-03-09 05:59:23 +01:00
color_print(4,'Configuring build environment...')
2009-02-27 00:35:09 +01:00
2009-12-02 23:32:57 +01:00
if not env['FAST']:
SetCacheMode('force')
2012-05-24 00:02:43 +02:00
2009-03-09 05:59:23 +01:00
if env['USE_CONFIG']:
if not env['CONFIG'].endswith('.py'):
color_print(1,'SCons CONFIG file specified is not a python file, will not be read...')
2009-01-26 23:58:55 +01:00
else:
2009-03-09 05:59:23 +01:00
# Accept more than one file as comma-delimited list
user_confs = env['CONFIG'].split(',')
# If they exist add the files to the existing `opts`
for conf in user_confs:
if os.path.exists(conf):
opts.files.append(conf)
color_print(4,"SCons CONFIG found: '%s', variables will be inherited..." % conf)
optfile = file(conf)
2011-10-20 06:40:49 +02:00
#print optfile.read().replace("\n", " ").replace("'","").replace(" = ","=")
2009-03-09 05:59:23 +01:00
optfile.close()
2012-05-24 00:02:43 +02:00
2009-03-09 05:59:23 +01:00
elif not conf == SCONS_LOCAL_CONFIG:
# if default missing, no worries
# but if the default is overridden and the file is not found, give warning
color_print(1,"SCons CONFIG not found: '%s'" % conf)
# Recreate the base environment using modified `opts`
2009-07-08 20:40:10 +02:00
env = Environment(ENV=os.environ,options=opts)
2012-07-07 03:08:19 +02:00
env.Decider('MD5-timestamp')
env.SourceCode(".", None)
2009-03-09 05:59:23 +01:00
env['USE_CONFIG'] = True
else:
2012-05-24 00:02:43 +02:00
color_print(4,'SCons USE_CONFIG specified as false, will not inherit variables python config file...')
2009-03-09 05:59:23 +01:00
conf = Configure(env, custom_tests = conf_tests)
2012-05-24 00:02:43 +02:00
2009-03-09 05:59:23 +01:00
if env['DEBUG']:
mode = 'debug mode'
else:
mode = 'release mode'
2012-05-24 00:02:43 +02:00
2009-03-09 05:59:23 +01:00
env['PLATFORM'] = platform.uname()[0]
2010-01-07 18:14:54 +01:00
color_print(4,"Configuring on %s in *%s*..." % (env['PLATFORM'],mode))
2012-05-24 00:02:43 +02:00
2009-03-09 05:59:23 +01:00
env['MISSING_DEPS'] = []
env['SKIPPED_DEPS'] = []
2010-07-14 07:33:55 +02:00
env['HAS_CAIRO'] = False
2013-01-09 21:49:39 +01:00
env['CAIRO_LIBPATHS'] = []
2013-05-16 20:33:23 +02:00
env['CAIRO_ALL_LIBS'] = []
2013-01-09 21:49:39 +01:00
env['CAIRO_CPPPATHS'] = []
2010-07-14 07:33:55 +02:00
env['HAS_PYCAIRO'] = False
2010-07-15 02:20:50 +02:00
env['HAS_LIBXML2'] = False
2011-08-11 23:11:11 +02:00
env['LIBMAPNIK_LIBS'] = []
2013-05-16 20:33:23 +02:00
env['LIBMAPNIK_LINKFLAGS'] = []
2011-08-29 20:52:35 +02:00
env['LIBMAPNIK_CPPATHS'] = []
2013-03-14 03:49:59 +01:00
env['LIBMAPNIK_DEFINES'] = []
2011-08-29 20:52:35 +02:00
env['LIBMAPNIK_CXXFLAGS'] = []
2011-08-12 22:01:09 +02:00
env['PLUGINS'] = PLUGINS
2011-08-29 20:52:35 +02:00
env['EXTRA_FREETYPE_LIBS'] = []
2011-11-15 19:23:10 +01:00
env['SQLITE_LINKFLAGS'] = []
2013-01-15 01:07:38 +01:00
env['PYTHON_INCLUDES'] = []
2011-08-15 09:00:06 +02:00
# previously a leading / was expected for LIB_DIR_NAME
# now strip it to ensure expected behavior
if env['LIB_DIR_NAME'].startswith(os.path.sep):
2011-08-16 05:18:24 +02:00
env['LIB_DIR_NAME'] = strip_first(env['LIB_DIR_NAME'],os.path.sep)
2012-05-24 00:02:43 +02:00
2011-08-15 09:00:06 +02:00
# base install location
2011-08-12 22:01:09 +02:00
env['MAPNIK_LIB_BASE'] = os.path.join(env['PREFIX'],env['LIBDIR_SCHEMA'])
2011-08-15 09:00:06 +02:00
# directory for plugins and fonts
env['MAPNIK_LIB_DIR'] = os.path.join(env['MAPNIK_LIB_BASE'],env['LIB_DIR_NAME'])
# input plugins sub directory
env['MAPNIK_INPUT_PLUGINS'] = os.path.join(env['MAPNIK_LIB_DIR'],'input')
# fonts sub directory
2011-08-12 22:01:09 +02:00
if env['SYSTEM_FONTS']:
env['MAPNIK_FONTS'] = os.path.normpath(env['SYSTEM_FONTS'])
else:
env['MAPNIK_FONTS'] = os.path.join(env['MAPNIK_LIB_DIR'],'fonts')
2012-05-24 00:02:43 +02:00
# install prefix is a pre-pended base location to
2011-08-15 09:00:06 +02:00
# 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
install_prefix = os.path.normpath(os.path.realpath(env['DESTDIR'])) + os.path.realpath(env['PREFIX'])
env['INSTALL_PREFIX'] = strip_first(install_prefix,'//','/')
# all values from above based on install_prefix
# if env['DESTDIR'] == '/' these should be unchanged
env['MAPNIK_LIB_BASE_DEST'] = os.path.join(env['INSTALL_PREFIX'],env['LIBDIR_SCHEMA'])
env['MAPNIK_LIB_DIR_DEST'] = os.path.join(env['MAPNIK_LIB_BASE_DEST'],env['LIB_DIR_NAME'])
env['MAPNIK_INPUT_PLUGINS_DEST'] = os.path.join(env['MAPNIK_LIB_DIR_DEST'],'input')
if env['SYSTEM_FONTS']:
env['MAPNIK_FONTS_DEST'] = os.path.normpath(env['SYSTEM_FONTS'])
else:
2011-08-12 23:31:28 +02:00
env['MAPNIK_FONTS_DEST'] = os.path.join(env['MAPNIK_LIB_DIR_DEST'],'fonts')
2012-05-24 00:02:43 +02:00
2011-08-11 21:14:00 +02:00
if env['LINKING'] == 'static':
2011-11-23 12:33:58 +01:00
env['MAPNIK_LIB_NAME'] = '${LIBPREFIX}mapnik${LIBSUFFIX}'
2011-08-11 21:14:00 +02:00
else:
2011-11-23 12:33:58 +01:00
env['MAPNIK_LIB_NAME'] = '${SHLIBPREFIX}mapnik${SHLIBSUFFIX}'
2012-05-24 00:02:43 +02:00
2009-07-02 02:48:42 +02:00
if env['PKG_CONFIG_PATH']:
2011-08-11 17:49:57 +02:00
env['ENV']['PKG_CONFIG_PATH'] = os.path.realpath(env['PKG_CONFIG_PATH'])
2009-07-02 02:48:42 +02:00
# otherwise this variable == os.environ["PKG_CONFIG_PATH"]
2011-10-13 23:19:21 +02:00
if env['PATH']:
env['ENV']['PATH'] = os.path.realpath(env['PATH']) + ':' + env['ENV']['PATH']
2009-03-09 05:59:23 +01:00
if env['SYSTEM_FONTS']:
if not os.path.isdir(env['SYSTEM_FONTS']):
color_print(1,'Warning: Directory specified for SYSTEM_FONTS does not exist!')
#### Libraries and headers dependency checks ####
2012-05-24 00:02:43 +02:00
2009-03-09 05:59:23 +01:00
# Set up for libraries and headers dependency checks
env['CPPPATH'] = ['#include', '#']
env['LIBPATH'] = ['#src']
2012-05-24 00:02:43 +02:00
2012-06-13 23:10:15 +02:00
# set any custom cxxflags and ldflags to come first
2013-03-14 03:49:59 +01:00
env.Append(CPPDEFINES = env['CUSTOM_DEFINES'])
2010-09-18 20:02:15 +02:00
env.Append(CXXFLAGS = env['CUSTOM_CXXFLAGS'])
2012-06-13 23:17:58 +02:00
env.Append(CFLAGS = env['CUSTOM_CFLAGS'])
2012-06-13 23:10:15 +02:00
env.Append(LINKFLAGS = env['CUSTOM_LDFLAGS'])
2011-02-28 21:00:56 +01:00
2011-08-15 09:00:06 +02:00
### platform specific bits
thread_suffix = 'mt'
if env['PLATFORM'] == 'FreeBSD':
thread_suffix = ''
env.Append(LIBS = 'pthread')
2009-03-09 05:59:23 +01:00
# Solaris & Sun Studio settings (the `SUNCC` flag will only be
# set if the `CXX` option begins with `CC`)
SOLARIS = env['PLATFORM'] == 'SunOS'
env['SUNCC'] = SOLARIS and env['CXX'].startswith('CC')
2012-05-24 00:02:43 +02:00
2013-05-10 23:16:58 +02:00
# If the Sun Studio C++ compiler (`CC`) is used instead of gcc.
2009-03-09 05:59:23 +01:00
if env['SUNCC']:
env['CC'] = 'cc'
# To be compatible w/Boost everything needs to be compiled
# with the `-library=stlport4` flag (which needs to come
# before the `-o` flag).
env['CXX'] = 'CC -library=stlport4'
if env['THREADING'] == 'multi':
2010-09-18 18:50:05 +02:00
env.Append(CXXFLAGS = '-mt')
2011-08-15 09:00:06 +02:00
# allow for mac osx /usr/lib/libicucore.dylib compatibility
# requires custom supplied headers since Apple does not include them
# details: http://lists.apple.com/archives/xcode-users/2005/Jun/msg00633.html
# To use system lib download and make && make install one of these:
# http://www.opensource.apple.com/tarballs/ICU/
# then copy the headers to a location that mapnik will find
if 'core' in env['ICU_LIB_NAME']:
2013-03-14 03:49:59 +01:00
env.Append(CPPDEFINES = '-DU_HIDE_DRAFT_API')
env.Append(CPPDEFINES = '-DUDISABLE_RENAMING')
2011-08-15 09:00:06 +02:00
if os.path.exists(env['ICU_LIB_NAME']):
#-sICU_LINK=" -L/usr/lib -licucore
env['ICU_LIB_NAME'] = os.path.basename(env['ICU_LIB_NAME']).replace('.dylib','').replace('lib','')
2012-05-24 00:02:43 +02:00
2009-03-09 05:59:23 +01:00
# Adding the required prerequisite library directories to the include path for
# compiling and the library path for linking, respectively.
2013-04-10 04:37:02 +02:00
for required in ('ICU', 'SQLITE'):
2009-03-09 05:59:23 +01:00
inc_path = env['%s_INCLUDES' % required]
lib_path = env['%s_LIBS' % required]
2011-08-11 21:14:00 +02:00
env.AppendUnique(CPPPATH = os.path.realpath(inc_path))
env.AppendUnique(LIBPATH = os.path.realpath(lib_path))
2009-03-09 05:59:23 +01:00
2011-10-30 06:34:38 +01:00
if conf.parse_config('FREETYPE_CONFIG'):
# check if freetype links to bz2
if env['RUNTIME_LINK'] == 'static':
temp_env = env.Clone()
temp_env['LIBS'] = []
try:
temp_env.ParseConfig('%s --libs' % env['FREETYPE_CONFIG'])
if 'bz2' in temp_env['LIBS']:
env['EXTRA_FREETYPE_LIBS'].append('bz2')
except OSError,e:
pass
2011-08-29 20:52:35 +02:00
2011-10-12 05:22:49 +02:00
# libxml2 should be optional but is currently not
# https://github.com/mapnik/mapnik/issues/913
2012-03-21 23:38:32 +01:00
if conf.parse_config('XML2_CONFIG',checks='--cflags'):
2011-10-12 05:22:49 +02:00
env['HAS_LIBXML2'] = True
2013-05-22 01:22:04 +02:00
else:
env['MISSING_DEPS'].append('libxml2')
2010-01-30 01:59:36 +01:00
2009-03-09 05:59:23 +01:00
LIBSHEADERS = [
['z', 'zlib.h', True,'C'],
2009-11-24 21:32:41 +01:00
[env['ICU_LIB_NAME'],'unicode/unistr.h',True,'C++'],
2009-03-09 05:59:23 +01:00
]
2009-11-24 21:32:41 +01:00
2010-06-03 21:50:27 +02:00
if env['JPEG']:
2013-03-14 03:49:59 +01:00
env.Append(CPPDEFINES = '-DHAVE_JPEG')
2010-06-03 21:50:27 +02:00
LIBSHEADERS.append(['jpeg', ['stdio.h', 'jpeglib.h'], True,'C'])
2013-01-29 08:17:37 +01:00
inc_path = env['%s_INCLUDES' % 'JPEG']
lib_path = env['%s_LIBS' % 'JPEG']
env.AppendUnique(CPPPATH = os.path.realpath(inc_path))
env.AppendUnique(LIBPATH = os.path.realpath(lib_path))
2010-06-03 21:50:27 +02:00
else:
env['SKIPPED_DEPS'].extend(['jpeg'])
2013-01-29 08:21:27 +01:00
if env['PROJ']:
2013-03-14 03:49:59 +01:00
env.Append(CPPDEFINES = '-DMAPNIK_USE_PROJ4')
2013-01-29 08:21:27 +01:00
LIBSHEADERS.append(['proj', 'proj_api.h', True,'C'])
inc_path = env['%s_INCLUDES' % 'PROJ']
lib_path = env['%s_LIBS' % 'PROJ']
env.AppendUnique(CPPPATH = os.path.realpath(inc_path))
env.AppendUnique(LIBPATH = os.path.realpath(lib_path))
else:
env['SKIPPED_DEPS'].extend(['proj'])
2013-01-29 08:17:37 +01:00
if env['PNG']:
2013-03-14 03:49:59 +01:00
env.Append(CPPDEFINES = '-DHAVE_PNG')
2013-01-29 08:17:37 +01:00
LIBSHEADERS.append(['png', 'png.h', True,'C'])
inc_path = env['%s_INCLUDES' % 'PNG']
lib_path = env['%s_LIBS' % 'PNG']
env.AppendUnique(CPPPATH = os.path.realpath(inc_path))
env.AppendUnique(LIBPATH = os.path.realpath(lib_path))
else:
env['SKIPPED_DEPS'].extend(['png'])
if env['TIFF']:
2013-03-14 03:49:59 +01:00
env.Append(CPPDEFINES = '-DHAVE_TIFF')
2013-01-29 08:17:37 +01:00
LIBSHEADERS.append(['tiff', 'tiff.h', True,'C'])
inc_path = env['%s_INCLUDES' % 'TIFF']
lib_path = env['%s_LIBS' % 'TIFF']
env.AppendUnique(CPPPATH = os.path.realpath(inc_path))
env.AppendUnique(LIBPATH = os.path.realpath(lib_path))
else:
env['SKIPPED_DEPS'].extend(['tiff'])
2010-02-23 03:40:46 +01:00
# if requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests
if env['PRIORITIZE_LINKING']:
2013-05-17 19:07:06 +02:00
conf.prioritize_paths(silent=True)
2012-05-24 00:02:43 +02:00
2013-03-25 19:19:51 +01:00
if not env['HOST']:
for libname, headers, required, lang in LIBSHEADERS:
if not conf.CheckLibWithHeader(libname, headers, lang):
if required:
color_print(1, 'Could not find required header or shared library for %s' % libname)
env['MISSING_DEPS'].append(libname)
else:
color_print(4, 'Could not find optional header or shared library for %s' % libname)
env['SKIPPED_DEPS'].append(libname)
2009-07-02 01:52:51 +02:00
2013-03-25 19:19:51 +01:00
if not env['HOST']:
if env['ICU_LIB_NAME'] not in env['MISSING_DEPS']:
if not conf.icu_at_least_four_two():
# expression_string.cpp and map.cpp use fromUTF* function only available in >= ICU 4.2
env['MISSING_DEPS'].append(env['ICU_LIB_NAME'])
2012-05-24 00:02:43 +02:00
2013-01-03 17:23:36 +01:00
if env['BIGINT']:
2013-03-14 03:49:59 +01:00
env.Append(CPPDEFINES = '-DBIGINT')
2013-01-03 17:23:36 +01:00
2009-07-02 01:52:51 +02:00
if env['THREADING'] == 'multi':
thread_flag = thread_suffix
else:
thread_flag = ''
2012-05-24 00:02:43 +02:00
2009-12-15 20:25:35 +01:00
conf.FindBoost(BOOST_SEARCH_PREFIXES,thread_flag)
2012-05-24 00:02:43 +02:00
2013-06-03 21:22:29 +02:00
has_boost_devel = True
2013-03-25 19:19:51 +01:00
if not env['HOST']:
2013-06-03 04:24:11 +02:00
if not conf.CheckHeader(header='boost/version.hpp',language='C++'):
env['MISSING_DEPS'].append('boost development headers')
2013-06-03 21:22:29 +02:00
has_boost_devel = False
2013-03-25 19:19:51 +01:00
2013-06-03 04:24:11 +02:00
if has_boost_devel:
env['BOOST_LIB_VERSION_FROM_HEADER'] = conf.GetBoostLibVersion()
# The other required boost headers.
BOOST_LIBSHEADERS = [
['system', 'boost/system/system_error.hpp', True],
['filesystem', 'boost/filesystem/operations.hpp', True],
['regex', 'boost/regex.hpp', True],
['program_options', 'boost/program_options.hpp', False]
]
if env['THREADING'] == 'multi':
BOOST_LIBSHEADERS.append(['thread', 'boost/thread/mutex.hpp', True])
# on solaris the configure checks for boost_thread
# require the -pthreads flag to be able to check for
# threading support, so we add as a global library instead
# of attaching to cxxflags after configure
if env['PLATFORM'] == 'SunOS':
env.Append(CXXFLAGS = '-pthreads')
# if requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests
if env['PRIORITIZE_LINKING']:
conf.prioritize_paths(silent=True)
if not env['HOST']:
# if the user is not setting custom boost configuration
# enforce boost version greater than or equal to BOOST_MIN_VERSION
if not conf.CheckBoost(BOOST_MIN_VERSION):
color_print(4,'Found boost lib version... %s' % env.get('BOOST_LIB_VERSION_FROM_HEADER') )
color_print(1,'Boost version %s or greater is required' % BOOST_MIN_VERSION)
if not env['BOOST_VERSION']:
env['MISSING_DEPS'].append('boost version >= %s' % BOOST_MIN_VERSION)
else:
color_print(4,'Found boost lib version... %s' % env.get('BOOST_LIB_VERSION_FROM_HEADER') )
if not env['HOST']:
for count, libinfo in enumerate(BOOST_LIBSHEADERS):
if not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++'):
if libinfo[2]:
color_print(1,'Could not find required header or shared library for boost %s' % libinfo[0])
env['MISSING_DEPS'].append('boost ' + libinfo[0])
else:
color_print(4,'Could not find optional header or shared library for boost %s' % libinfo[0])
env['SKIPPED_DEPS'].append('boost ' + libinfo[0])
2011-02-28 21:00:56 +01:00
if env['ICU_LIB_NAME'] not in env['MISSING_DEPS']:
# http://lists.boost.org/Archives/boost/2009/03/150076.php
2013-06-02 23:56:21 +02:00
# we need libicui18n if using static boost libraries, so it is
# important to try this check with the library linked
env.AppendUnique(LIBS='icui18n')
2011-02-28 21:00:56 +01:00
if conf.boost_regex_has_icu():
# TODO - should avoid having this be globally defined...
2013-03-14 03:49:59 +01:00
env.Append(CPPDEFINES = '-DBOOST_REGEX_HAS_ICU')
2011-02-28 21:00:56 +01:00
else:
env['SKIPPED_DEPS'].append('boost_regex_icu')
2012-04-08 02:20:56 +02:00
2009-03-09 05:59:23 +01:00
env['REQUESTED_PLUGINS'] = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])]
2012-05-24 00:02:43 +02:00
2013-06-02 23:56:21 +02:00
SQLITE_HAS_RTREE = None
2013-06-02 23:15:02 +02:00
CHECK_PKG_CONFIG = conf.CheckPKGConfig('0.15.0')
2010-12-21 21:34:36 +01:00
if len(env['REQUESTED_PLUGINS']):
color_print(4,'Checking for requested plugins dependencies...')
for plugin in env['REQUESTED_PLUGINS']:
details = env['PLUGINS'][plugin]
if plugin == 'gdal':
if conf.parse_config('GDAL_CONFIG',checks='--libs'):
2009-03-09 05:59:23 +01:00
conf.parse_config('GDAL_CONFIG',checks='--cflags')
2010-12-21 21:34:36 +01:00
libname = conf.get_pkg_lib('GDAL_CONFIG','gdal')
if libname:
details['lib'] = libname
elif plugin == 'postgis':
conf.parse_pg_config('PG_CONFIG')
elif plugin == 'ogr':
if conf.ogr_enabled():
if not 'gdal' in env['REQUESTED_PLUGINS']:
conf.parse_config('GDAL_CONFIG',checks='--libs')
conf.parse_config('GDAL_CONFIG',checks='--cflags')
libname = conf.get_pkg_lib('GDAL_CONFIG','ogr')
if libname:
details['lib'] = libname
elif details['path'] and details['lib'] and details['inc']:
backup = env.Clone().Dictionary()
# Note, the 'delete_existing' keyword makes sure that these paths are prepended
# to the beginning of the path list even if they already exist
incpath = env['%s_INCLUDES' % details['path']]
2011-08-29 20:52:35 +02:00
libpath = env['%s_LIBS' % details['path']]
2011-08-11 21:14:00 +02:00
env.PrependUnique(CPPPATH = os.path.realpath(incpath),delete_existing=True)
2011-08-29 20:52:35 +02:00
env.PrependUnique(LIBPATH = os.path.realpath(libpath),delete_existing=True)
2010-12-21 21:34:36 +01:00
if not conf.CheckLibWithHeader(details['lib'], details['inc'], details['lang']):
env.Replace(**backup)
env['SKIPPED_DEPS'].append(details['lib'])
2011-11-14 01:13:37 +01:00
if plugin == 'sqlite':
2013-06-02 23:56:21 +02:00
SQLITE_HAS_RTREE = conf.sqlite_has_rtree()
2011-11-15 19:23:10 +01:00
sqlite_backup = env.Clone().Dictionary()
# if statically linking, on linux we likely
# need to link sqlite to pthreads and dl
if env['RUNTIME_LINK'] == 'static':
2013-06-02 23:15:02 +02:00
if CHECK_PKG_CONFIG and conf.CheckPKG('sqlite3'):
2011-11-15 19:23:10 +01:00
sqlite_env = env.Clone()
try:
sqlite_env.ParseConfig('pkg-config --static --libs sqlite3')
for lib in sqlite_env['LIBS']:
if not lib in env['LIBS']:
env["SQLITE_LINKFLAGS"].append(lib)
env.Append(LIBS=lib)
except OSError,e:
pass
2013-06-02 23:56:21 +02:00
if SQLITE_HAS_RTREE is None:
SQLITE_HAS_RTREE = conf.sqlite_has_rtree()
2013-06-02 23:15:02 +02:00
if not SQLITE_HAS_RTREE:
2011-11-15 19:23:10 +01:00
env.Replace(**sqlite_backup)
2011-11-14 01:13:37 +01:00
if details['lib'] in env['LIBS']:
env['LIBS'].remove(details['lib'])
env['SKIPPED_DEPS'].append('sqlite_rtree')
2011-11-15 19:23:10 +01:00
else:
env.Replace(**sqlite_backup)
2011-04-02 20:25:23 +02:00
2010-12-21 21:34:36 +01:00
elif details['lib'] and details['inc']:
if not conf.CheckLibWithHeader(details['lib'], details['inc'], details['lang']):
2011-04-02 20:25:23 +02:00
env['SKIPPED_DEPS'].append(details['lib'])
2012-05-24 00:02:43 +02:00
2010-12-21 21:34:36 +01:00
# 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'
env.PrependUnique(CPPPATH = '#include', delete_existing=True)
env.PrependUnique(CPPPATH = '#', delete_existing=True)
env.PrependUnique(LIBPATH = '#src', delete_existing=True)
2010-02-23 03:40:46 +01:00
2011-11-14 01:13:37 +01:00
if env['PGSQL2SQLITE']:
2012-08-17 01:21:10 +02:00
if 'sqlite3' not in env['LIBS']:
env.AppendUnique(LIBS='sqlite3')
env.AppendUnique(CPPPATH = os.path.realpath(env['SQLITE_INCLUDES']))
env.AppendUnique(LIBPATH = os.path.realpath(env['SQLITE_LIBS']))
2013-06-02 23:15:02 +02:00
if not SQLITE_HAS_RTREE:
2011-11-14 01:13:37 +01:00
env['SKIPPED_DEPS'].append('pgsql2sqlite_rtree')
env['PGSQL2SQLITE'] = False
2011-04-02 20:25:23 +02:00
2012-05-25 02:05:51 +02:00
# we rely on an internal, patched copy of agg with critical fixes
# prepend to make sure we link locally
env.Prepend(CPPPATH = '#deps/agg/include')
env.Prepend(LIBPATH = '#deps/agg')
2013-02-19 11:06:59 +01:00
env.Prepend(CPPPATH = '#deps/clipper/include')
2013-01-11 02:20:34 +01:00
# prepend deps dir for auxillary headers
env.Prepend(CPPPATH = '#deps')
2010-09-19 20:29:22 +02:00
if env['CAIRO']:
2011-08-29 20:52:35 +02:00
if env['CAIRO_LIBS'] or env['CAIRO_INCLUDES']:
c_inc = env['CAIRO_INCLUDES']
if env['CAIRO_LIBS']:
2013-01-09 21:49:39 +01:00
env["CAIRO_LIBPATHS"].append(os.path.realpath(env['CAIRO_LIBS']))
2011-08-29 20:52:35 +02:00
if not env['CAIRO_INCLUDES']:
2012-05-24 00:02:43 +02:00
c_inc = env['CAIRO_LIBS'].replace('lib','',1)
2011-08-29 20:52:35 +02:00
if c_inc:
c_inc = os.path.normpath(os.path.realpath(env['CAIRO_INCLUDES']))
if c_inc.endswith('include'):
c_inc = os.path.dirname(c_inc)
2013-01-09 21:49:39 +01:00
env["CAIRO_CPPPATHS"].extend(
2011-08-29 20:52:35 +02:00
[
os.path.join(c_inc,'include/cairo'),
os.path.join(c_inc,'include/pixman-1'),
#os.path.join(c_inc,'include/freetype2'),
#os.path.join(c_inc,'include/libpng'),
]
)
2013-05-16 20:33:23 +02:00
env["CAIRO_ALL_LIBS"] = ['cairo']
2011-08-29 20:52:35 +02:00
if env['RUNTIME_LINK'] == 'static':
2013-05-16 20:33:23 +02:00
env["CAIRO_ALL_LIBS"].extend(
2013-01-09 21:49:39 +01:00
['pixman-1','expat','fontconfig','iconv']
2011-08-29 20:52:35 +02:00
)
# todo - run actual checkLib?
env['HAS_CAIRO'] = True
2010-09-19 20:29:22 +02:00
else:
2013-06-02 23:15:02 +02:00
if not CHECK_PKG_CONFIG:
2011-08-29 20:52:35 +02:00
env['HAS_CAIRO'] = False
env['SKIPPED_DEPS'].append('pkg-config')
env['SKIPPED_DEPS'].append('cairo')
elif not conf.CheckPKG('cairo'):
env['HAS_CAIRO'] = False
env['SKIPPED_DEPS'].append('cairo')
2013-01-09 21:49:39 +01:00
else:
print 'Checking for cairo lib and include paths... ',
cmd = 'pkg-config --libs --cflags cairo'
if env['RUNTIME_LINK'] == 'static':
cmd += ' --static'
cairo_env = env.Clone()
try:
cairo_env.ParseConfig(cmd)
for lib in cairo_env['LIBS']:
if not lib in env['LIBS']:
2013-05-16 20:33:23 +02:00
env["CAIRO_ALL_LIBS"].append(lib)
2013-01-09 21:49:39 +01:00
for lpath in cairo_env['LIBPATH']:
if not lpath in env['LIBPATH']:
env["CAIRO_LIBPATHS"].append(lpath)
for inc in cairo_env['CPPPATH']:
if not inc in env['CPPPATH']:
env["CAIRO_CPPPATHS"].append(inc)
env['HAS_CAIRO'] = True
print 'yes'
except OSError,e:
color_print(1,'no')
env['SKIPPED_DEPS'].append('cairo')
color_print(1,'pkg-config reported: %s' % e)
2012-05-24 00:02:43 +02:00
2010-09-19 20:29:22 +02:00
else:
color_print(4,'Not building with cairo support, pass CAIRO=True to enable')
2012-05-24 00:02:43 +02:00
2013-05-16 17:28:38 +02:00
if not env['HOST'] and env['HAS_CAIRO']:
if not conf.CheckCairoHasFreetype():
env['SKIPPED_DEPS'].append('cairo')
env['HAS_CAIRO'] = False
2012-12-16 21:23:01 +01:00
if 'python' in env['BINDINGS'] or 'python' in env['REQUESTED_PLUGINS']:
2012-07-20 22:56:21 +02:00
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'])
Exit(1)
2012-07-05 20:54:43 +02:00
py3 = 'True' in os.popen('''%s -c "import sys as s;s.stdout.write(str(s.version_info[0] == 3))"''' % env['PYTHON']).read().strip()
2012-07-20 22:56:21 +02:00
if py3:
sys_prefix = '''%s -c "import sys; print(sys.prefix)"''' % env['PYTHON']
else:
sys_prefix = '''%s -c "import sys; print sys.prefix"''' % env['PYTHON']
env['PYTHON_SYS_PREFIX'] = call(sys_prefix)
if HAS_DISTUTILS:
if py3:
sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print(get_python_version())"''' % env['PYTHON']
else:
sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print get_python_version()"''' % env['PYTHON']
env['PYTHON_VERSION'] = call(sys_version)
if py3:
py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())"''' % env['PYTHON']
else:
py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print get_python_inc()"''' % env['PYTHON']
2013-01-15 01:07:38 +01:00
env['PYTHON_INCLUDES'].append(call(py_includes))
# also append platform specific includes
if py3:
py_plat_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print(get_python_inc(plat_specific=True))"''' % env['PYTHON']
else:
py_plat_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print get_python_inc(plat_specific=True)"''' % env['PYTHON']
env['PYTHON_INCLUDES'].append(call(py_plat_includes))
2012-07-20 22:56:21 +02:00
# Note: we use the plat_specific argument here to make sure to respect the arch-specific site-packages location
if py3:
site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True))"''' % env['PYTHON']
else:
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)
else:
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]
2013-01-15 01:07:38 +01:00
env['PYTHON_INCLUDES'] = [env['PYTHON_SYS_PREFIX'] + '/include/python' + env['PYTHON_VERSION']]
2012-07-20 22:56:21 +02:00
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 env['PYTHON_PREFIX']:
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
else:
env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + os.path.sep + env['PYTHON_SITE_PACKAGES']
if py3:
is_64_bit = '''%s -c "import sys; print(sys.maxsize == 9223372036854775807)"''' % env['PYTHON']
else:
is_64_bit = '''%s -c "import sys; print sys.maxint == 9223372036854775807"''' % env['PYTHON']
if is_64_bit:
env['PYTHON_IS_64BIT'] = True
else:
env['PYTHON_IS_64BIT'] = False
2013-06-03 04:25:43 +02:00
if has_boost_devel and 'python' in env['BINDINGS']:
2012-12-16 21:23:01 +01:00
if py3 and env['BOOST_PYTHON_LIB'] == 'boost_python':
env['BOOST_PYTHON_LIB'] = 'boost_python3%s' % env['BOOST_APPEND']
elif env['BOOST_PYTHON_LIB'] == 'boost_python':
env['BOOST_PYTHON_LIB'] = 'boost_python%s' % env['BOOST_APPEND']
2013-03-25 19:19:51 +01:00
if not env['HOST']:
if not conf.CheckHeader(header='boost/python/detail/config.hpp',language='C++'):
color_print(1,'Could not find required header files for boost python')
env['MISSING_DEPS'].append('boost python')
2012-12-16 21:23:01 +01:00
if env['CAIRO']:
2013-06-02 23:15:02 +02:00
if CHECK_PKG_CONFIG and conf.CheckPKG('pycairo'):
2012-12-16 21:23:01 +01:00
env['HAS_PYCAIRO'] = True
else:
env['SKIPPED_DEPS'].extend(['pycairo'])
2010-09-19 20:29:22 +02:00
else:
2012-12-16 21:23:01 +01:00
color_print(4,'Not building with pycairo support, pass CAIRO=True to enable')
2012-05-24 00:02:43 +02:00
2009-03-09 05:59:23 +01:00
#### End Config Stage for Required Dependencies ####
2012-05-24 00:02:43 +02:00
2009-03-09 05:59:23 +01:00
if env['MISSING_DEPS']:
# if required dependencies are missing, print warnings and then let SCons finish without building or saving local config
2010-01-06 00:51:10 +01:00
color_print(1,'\nExiting... the following required dependencies were not found:\n - %s' % '\n - '.join([pretty_dep(dep) for dep in env['MISSING_DEPS']]))
2011-08-29 20:52:35 +02:00
color_print(1,"\nSee '%s' for details on possible problems." % (os.path.realpath(SCONS_LOCAL_LOG)))
2009-03-09 05:59:23 +01:00
if env['SKIPPED_DEPS']:
2010-01-06 00:51:10 +01:00
color_print(4,'\nAlso, these OPTIONAL dependencies were not found:\n - %s' % '\n - '.join([pretty_dep(dep) for dep in env['SKIPPED_DEPS']]))
2009-03-09 05:59:23 +01:00
color_print(4,"\nSet custom paths to these libraries and header files on the command-line or in a file called '%s'" % SCONS_LOCAL_CONFIG)
2009-12-16 21:02:06 +01:00
color_print(4," ie. $ python scons/scons.py BOOST_INCLUDES=/usr/local/include BOOST_LIBS=/usr/local/lib")
2009-03-09 05:59:23 +01:00
color_print(4, "\nOnce all required dependencies are found a local '%s' will be saved and then install:" % SCONS_LOCAL_CONFIG)
color_print(4," $ sudo python scons/scons.py install")
color_print(4,"\nTo view available path variables:\n $ python scons/scons.py --help or -h")
color_print(4,'\nTo view overall SCons help options:\n $ python scons/scons.py --help-options or -H\n')
2013-06-02 23:15:02 +02:00
color_print(4,'More info: https://github.com/mapnik/mapnik/wiki/Mapnik-Installation')
2010-01-06 00:51:10 +01:00
if not HELP_REQUESTED:
Exit(1)
2009-03-09 05:59:23 +01:00
else:
# Save the custom variables in a SCONS_LOCAL_CONFIG
# that will be reloaded to allow for `install` without re-specifying custom variables
color_print(4,"\nAll Required dependencies found!\n")
if env['USE_CONFIG']:
if os.path.exists(SCONS_LOCAL_CONFIG):
action = 'Overwriting and re-saving'
2012-05-24 00:02:43 +02:00
os.unlink(SCONS_LOCAL_CONFIG)
2009-02-27 00:35:09 +01:00
else:
2009-03-09 05:59:23 +01:00
action = 'Saving new'
color_print(4,"%s file '%s'..." % (action,SCONS_LOCAL_CONFIG))
color_print(4,"Will hold custom path variables from commandline and python config file(s)...")
opts.Save(SCONS_LOCAL_CONFIG,env)
2009-02-27 00:35:09 +01:00
else:
2009-03-09 05:59:23 +01:00
color_print(4,"Did not use user config file, no custom path variables will be saved...")
if env['SKIPPED_DEPS']:
2013-06-02 23:15:02 +02:00
color_print(4,'\nNote: will build without these OPTIONAL dependencies:\n - %s' % '\n - '.join([pretty_dep(dep) for dep in env['SKIPPED_DEPS']]))
2009-03-09 05:59:23 +01:00
print
# fetch the mapnik version header in order to set the
2011-08-30 07:32:01 +02:00
# ABI version used to build libmapnik.so on linux in src/build.py
2009-03-09 05:59:23 +01:00
abi = conf.GetMapnikLibVersion()
2013-06-04 03:26:28 +02:00
abi_fallback = "2.2.0"
2009-03-09 05:59:23 +01:00
if not abi:
color_print(1,'Problem encountered parsing mapnik version, falling back to %s' % abi_fallback)
2012-03-15 01:26:50 +01:00
abi = abi_fallback
2009-03-09 05:59:23 +01:00
2013-05-10 22:45:18 +02:00
abi_no_pre = abi.replace('-pre','').split('.')
env['ABI_VERSION'] = abi_no_pre
2012-03-15 01:26:50 +01:00
env['MAPNIK_VERSION_STRING'] = abi
2013-05-10 22:45:18 +02:00
env['MAPNIK_VERSION'] = str(int(abi_no_pre[0])*100000+int(abi_no_pre[1])*100+int(abi_no_pre[2]))
2009-07-17 22:51:39 +02:00
2013-03-14 03:49:59 +01:00
# Common DEFINES.
env.Append(CPPDEFINES = '-D%s' % env['PLATFORM'].upper())
2010-09-18 18:50:05 +02:00
if env['THREADING'] == 'multi':
2013-03-14 03:49:59 +01:00
env.Append(CPPDEFINES = '-DMAPNIK_THREADSAFE')
2009-07-17 22:51:39 +02:00
2009-03-09 05:59:23 +01:00
# Mac OSX (Darwin) special settings
if env['PLATFORM'] == 'Darwin':
pthread = ''
else:
pthread = '-pthread'
2012-05-24 00:02:43 +02:00
2009-03-09 05:59:23 +01:00
# Common debugging flags.
2012-03-09 02:04:51 +01:00
# http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html
2013-03-26 11:05:02 +01:00
debug_flags = ['-g', '-fno-omit-frame-pointer']
debug_defines = ['-DDEBUG', '-DMAPNIK_DEBUG']
ndebug_defines = ['-DNDEBUG']
2012-04-08 02:20:56 +02:00
2014-08-19 18:06:40 +02:00
boost_version_from_header = int(env['BOOST_LIB_VERSION_FROM_HEADER'].split('_')[1])
if boost_version_from_header > 53 or 'c++11' in env['CUSTOM_CXXFLAGS']:
env.Append(CPPDEFINES = '-DBOOST_SPIRIT_USE_PHOENIX_V3=1')
# - workaround boost gil channel_algorithm.hpp narrowing error
# TODO - remove when building against >= 1.55
# https://github.com/mapnik/mapnik/issues/1970
if 'clang++' in env['CXX']:
env.Append(CXXFLAGS = '-Wno-c++11-narrowing')
2012-04-08 02:20:56 +02:00
# Enable logging in debug mode (always) and release mode (when specified)
2012-04-10 16:19:51 +02:00
if env['DEFAULT_LOG_SEVERITY']:
if env['DEFAULT_LOG_SEVERITY'] not in severities:
2012-05-24 00:02:43 +02:00
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))
2012-04-10 16:19:51 +02:00
Exit(1)
else:
log_severity = severities.index(env['DEFAULT_LOG_SEVERITY'])
else:
2012-05-24 00:02:43 +02:00
severities_list = ', '.join(["'%s'" % s for s in severities])
color_print(1,"No logger severity specified, available options are %s." % severities_list)
Exit(1)
2012-04-10 16:19:51 +02:00
2013-03-26 11:05:02 +01:00
log_enabled = ['-DMAPNIK_LOG', '-DMAPNIK_DEFAULT_LOG_SEVERITY=%d' % log_severity]
2012-04-08 02:20:56 +02:00
if env['DEBUG']:
2013-03-14 03:49:59 +01:00
debug_defines += log_enabled
2012-04-08 02:20:56 +02:00
else:
if env['ENABLE_LOG']:
2013-03-14 03:49:59 +01:00
ndebug_defines += log_enabled
2012-04-08 02:20:56 +02:00
# Enable statistics reporting
if env['ENABLE_STATS']:
2013-03-26 11:05:02 +01:00
debug_defines.append('-DMAPNIK_STATS')
ndebug_defines.append('-DMAPNIK_STATS')
2012-04-08 02:20:56 +02:00
# Add rdynamic to allow using statics between application and plugins
# http://stackoverflow.com/questions/8623657/multiple-instances-of-singleton-across-shared-libraries-on-linux
2012-04-10 11:21:31 +02:00
if env['PLATFORM'] != 'Darwin' and env['CXX'] == 'g++':
2012-04-08 02:55:41 +02:00
env.MergeFlags('-rdynamic')
2012-04-08 02:20:56 +02:00
2013-03-14 03:49:59 +01:00
if env['DEBUG']:
env.Append(CXXFLAGS = debug_flags)
env.Append(CPPDEFINES = debug_defines)
2009-02-27 00:35:09 +01:00
else:
2013-03-14 03:49:59 +01:00
env.Append(CPPDEFINES = ndebug_defines)
if not env['SUNCC']:
2013-05-10 23:16:58 +02:00
# Common flags for CXX compiler.
2013-05-10 22:24:41 +02:00
common_cxx_flags = '-ansi -Wall %s %s -ftemplate-depth-300 ' % (env['WARNING_CXXFLAGS'], pthread)
2013-05-10 23:16:58 +02:00
# https://github.com/mapnik/mapnik/issues/1835
2013-05-13 18:13:44 +02:00
if sys.platform == 'darwin' and env['CXX'] == 'g++':
2013-05-10 23:16:58 +02:00
common_cxx_flags += '-fpermissive '
2009-03-09 05:59:23 +01:00
if env['DEBUG']:
2013-05-10 22:24:41 +02:00
env.Append(CXXFLAGS = common_cxx_flags + '-O0 -fno-inline')
2012-05-24 00:02:43 +02:00
else:
2013-05-24 21:46:51 +02:00
# TODO - add back -fvisibility-inlines-hidden
# https://github.com/mapnik/mapnik/issues/1863
env.Append(CXXFLAGS = common_cxx_flags + '-O%s -fno-strict-aliasing -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts' % (env['OPTIMIZATION']))
2012-01-09 02:13:19 +01:00
2011-11-14 09:49:46 +01:00
if env['DEBUG_UNDEFINED']:
2013-03-14 03:49:59 +01:00
env.Append(CXXFLAGS = '-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error -ftrapv -fwrapv')
2009-03-09 05:59:23 +01:00
2012-12-16 21:23:01 +01:00
if 'python' in env['BINDINGS'] or 'python' in env['REQUESTED_PLUGINS']:
2009-03-09 05:59:23 +01:00
majver, minver = env['PYTHON_VERSION'].split('.')
2010-07-15 02:20:50 +02:00
# we don't want the includes it in the main environment...
2011-08-30 07:32:01 +02:00
# as they are later set in the python build.py
2010-07-15 02:20:50 +02:00
# ugly hack needed until we have env specific conf
backup = env.Clone().Dictionary()
2013-01-15 01:07:38 +01:00
for pyinc in env['PYTHON_INCLUDES']:
env.AppendUnique(CPPPATH = os.path.realpath(pyinc))
2012-05-24 00:02:43 +02:00
2010-07-07 08:16:22 +02:00
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'])
2011-10-22 01:39:35 +02:00
Exit(1)
2012-05-24 00:02:43 +02:00
2009-03-09 05:59:23 +01:00
if (int(majver), int(minver)) < (2, 2):
color_print(1,"Python version 2.2 or greater required")
Exit(1)
2011-10-22 01:39:35 +02:00
2012-12-16 21:23:01 +01:00
if 'python' in env['BINDINGS']:
color_print(4,'Bindings Python version... %s' % env['PYTHON_VERSION'])
color_print(4,'Python %s prefix... %s' % (env['PYTHON_VERSION'], env['PYTHON_SYS_PREFIX']))
color_print(4,'Python bindings will install in... %s' % os.path.normpath(env['PYTHON_INSTALL_LOCATION']))
2012-06-15 20:05:59 +02:00
env.Replace(**backup)
2010-02-23 03:40:46 +01:00
# if requested, sort LIBPATH and CPPPATH one last time before saving...
if env['PRIORITIZE_LINKING']:
2013-05-17 19:07:06 +02:00
conf.prioritize_paths(silent=True)
2012-05-24 00:02:43 +02:00
2009-03-09 05:59:23 +01:00
# finish config stage and pickle results
env = conf.Finish()
env_cache = open(SCONS_CONFIGURE_CACHE, 'w')
pickle_dict = {}
for i in pickle_store:
pickle_dict[i] = env.get(i)
pickle.dump(pickle_dict,env_cache)
env_cache.close()
2009-03-30 18:52:31 +02:00
# fix up permissions on configure outputs
2009-07-24 09:38:26 +02:00
# this is hackish but avoids potential problems
# with a non-root configure following a root install
# that also triggered a re-configure
2009-03-09 05:59:23 +01:00
try:
os.chmod(SCONS_CONFIGURE_CACHE,0666)
except: pass
2009-03-30 18:52:31 +02:00
try:
os.chmod(SCONS_LOCAL_CONFIG,0666)
except: pass
try:
2009-07-26 03:08:51 +02:00
os.chmod('.sconsign.dblite',0666)
2009-07-24 09:38:26 +02:00
except: pass
2010-02-23 03:40:46 +01:00
try:
os.chmod(SCONS_LOCAL_LOG,0666)
except: pass
2009-07-24 09:38:26 +02:00
try:
2009-07-26 03:08:51 +02:00
for item in glob('%s/*' % SCONF_TEMP_DIR):
os.chmod(item,0666)
2009-03-30 18:52:31 +02:00
except: pass
2009-03-09 05:59:23 +01:00
if 'configure' in command_line_args:
2011-10-20 06:40:49 +02:00
color_print(4,'\nConfigure completed: run `make` to build or `make install`')
2010-01-06 00:51:10 +01:00
if not HELP_REQUESTED:
Exit(0)
2009-02-27 00:35:09 +01:00
2009-03-30 18:52:31 +02:00
# autogenerate help on default/current SCons options
Help(opts.GenerateHelpText(env))
2009-02-27 00:35:09 +01:00
#### Builds ####
2011-03-01 17:36:45 +01:00
if not HELP_REQUESTED:
2010-07-18 22:39:05 +02:00
if 'uninstall' in COMMAND_LINE_TARGETS:
# dummy action in case there is nothing to uninstall, to avoid phony error..
env.Alias("uninstall", "")
env['create_uninstall_target'] = create_uninstall_target
2011-02-08 04:27:08 +01:00
if env['PKG_CONFIG_PATH']:
2011-08-11 17:49:57 +02:00
env['ENV']['PKG_CONFIG_PATH'] = os.path.realpath(env['PKG_CONFIG_PATH'])
2011-02-08 04:27:08 +01:00
# otherwise this variable == os.environ["PKG_CONFIG_PATH"]
2012-05-24 00:02:43 +02:00
2011-10-13 23:19:21 +02:00
if env['PATH']:
env['ENV']['PATH'] = os.path.realpath(env['PATH']) + ':' + env['ENV']['PATH']
if env['PATH_REMOVE']:
p = env['PATH_REMOVE']
if p in env['ENV']['PATH']:
env['ENV']['PATH'].replace(p,'')
2013-05-16 18:59:21 +02:00
rm_path(p,'LIBPATH',env)
rm_path(p,'CPPPATH',env)
rm_path(p,'CXXFLAGS',env)
rm_path(p,'CAIRO_LIBPATHS',env)
rm_path(p,'CAIRO_CPPPATHS',env)
2011-11-16 21:47:31 +01:00
if env['PATH_REPLACE']:
searches,replace = env['PATH_REPLACE'].split(':')
for search in searches.split(','):
if search in env['ENV']['PATH']:
env['ENV']['PATH'] = os.path.abspath(env['ENV']['PATH'].replace(search,replace))
def replace_path(set,s,r):
idx = 0
for i in env[set]:
if s in i:
env[set][idx] = os.path.abspath(env[set][idx].replace(s,r))
idx +=1
replace_path('LIBPATH',search,replace)
replace_path('CPPPATH',search,replace)
replace_path('CXXFLAGS',search,replace)
2013-01-09 21:49:39 +01:00
replace_path('CAIRO_LIBPATHS',search,replace)
replace_path('CAIRO_CPPPATHS',search,replace)
2012-05-24 00:02:43 +02:00
2011-08-30 07:32:01 +02:00
# export env so it is available in build.py files
2010-01-06 00:51:10 +01:00
Export('env')
2012-05-24 00:02:43 +02:00
2011-11-12 00:37:10 +01:00
plugin_base = env.Clone()
2010-07-18 22:39:05 +02:00
2011-11-12 00:37:10 +01:00
Export('plugin_base')
2010-07-18 22:39:05 +02:00
2010-01-06 00:51:10 +01:00
if env['FAST']:
# caching is 'auto' by default in SCons
# But let's also cache implicit deps...
EnsureSConsVersion(0,98)
SetOption('implicit_cache', 1)
SetOption('max_drift', 1)
2012-05-24 00:02:43 +02:00
2010-01-06 00:51:10 +01:00
if env['JOBS'] > 1:
2012-05-24 00:02:43 +02:00
SetOption("num_jobs", env['JOBS'])
2010-01-06 00:51:10 +01:00
# Build agg first, doesn't need anything special
2012-05-25 02:05:51 +02:00
if env['RUNTIME_LINK'] == 'shared':
2011-10-12 05:22:49 +02:00
SConscript('deps/agg/build.py')
2012-05-24 00:02:43 +02:00
2010-01-06 00:51:10 +01:00
# Build the core library
2011-08-30 07:32:01 +02:00
SConscript('src/build.py')
2012-05-24 00:02:43 +02:00
2012-08-28 02:58:49 +02:00
# Install headers
SConscript('include/build.py')
2013-01-10 18:39:43 +01:00
# Install auxiliary headers
2013-01-11 02:20:34 +01:00
SConscript('deps/mapnik/build.py')
2013-01-10 18:39:43 +01:00
2010-01-06 00:51:10 +01:00
# Build the requested and able-to-be-compiled input plug-ins
GDAL_BUILT = False
OGR_BUILT = False
2013-05-23 02:54:32 +02:00
for plugin in env['PLUGINS']:
2013-05-24 00:20:17 +02:00
if env['PLUGIN_LINKING'] == 'static' or plugin not in env['REQUESTED_PLUGINS']:
if os.path.exists('plugins/input/%s.input' % plugin):
os.unlink('plugins/input/%s.input' % plugin)
2013-05-23 02:54:32 +02:00
if plugin in env['REQUESTED_PLUGINS']:
details = env['PLUGINS'][plugin]
if details['lib'] in env['LIBS']:
if env['PLUGIN_LINKING'] == 'shared':
SConscript('plugins/input/%s/build.py' % plugin)
if plugin == 'ogr': OGR_BUILT = True
if plugin == 'gdal': GDAL_BUILT = True
if plugin == 'ogr' or plugin == 'gdal':
if GDAL_BUILT and OGR_BUILT:
env['LIBS'].remove(details['lib'])
else:
2010-01-06 00:51:10 +01:00
env['LIBS'].remove(details['lib'])
2013-05-23 02:54:32 +02:00
elif not details['lib']:
if env['PLUGIN_LINKING'] == 'shared':
# build internal datasource input plugins
SConscript('plugins/input/%s/build.py' % plugin)
2010-01-06 00:51:10 +01:00
else:
2013-05-23 02:54:32 +02:00
color_print(1,"Notice: dependencies not met for plugin '%s', not building..." % plugin)
if os.path.exists('plugins/input/%s.input' % plugin):
os.unlink('plugins/input/%s.input' % plugin)
2012-05-24 00:02:43 +02:00
2011-08-12 22:01:09 +02:00
create_uninstall_target(env, env['MAPNIK_LIB_DIR_DEST'], False)
2011-08-15 09:00:06 +02:00
create_uninstall_target(env, env['MAPNIK_INPUT_PLUGINS_DEST'] , False)
2010-10-07 02:42:47 +02:00
if 'install' in COMMAND_LINE_TARGETS:
2013-05-24 00:40:05 +02:00
# if statically linking plugins still make sure
# to create the dynamic plugins directory
if env['PLUGIN_LINKING'] == 'static':
if not os.path.exists(env['MAPNIK_INPUT_PLUGINS_DEST']):
os.makedirs(env['MAPNIK_INPUT_PLUGINS_DEST'])
# before installing plugins, wipe out any previously
# installed plugins that we are no longer building
2010-10-07 02:42:47 +02:00
for plugin in PLUGINS.keys():
2013-05-16 20:33:23 +02:00
plugin_path = os.path.join(env['MAPNIK_INPUT_PLUGINS_DEST'],'%s.input' % plugin)
if os.path.exists(plugin_path):
if plugin not in env['REQUESTED_PLUGINS'] or env['PLUGIN_LINKING'] == 'static':
2013-06-02 23:15:02 +02:00
color_print(4,"Notice: removing out of date plugin: '%s'" % plugin_path)
2013-05-23 02:54:32 +02:00
os.unlink(plugin_path)
2012-05-24 00:02:43 +02:00
2010-01-06 00:51:10 +01:00
# Build the c++ rundemo app if requested
if env['DEMO']:
2011-08-30 07:32:01 +02:00
SConscript('demo/c++/build.py')
2012-05-24 00:02:43 +02:00
2010-01-06 00:51:10 +01:00
# Build shapeindex and remove its dependency from the LIBS
if 'boost_program_options%s' % env['BOOST_APPEND'] in env['LIBS']:
2013-02-23 02:15:29 +01:00
if env['SHAPEINDEX']:
SConscript('utils/shapeindex/build.py')
2012-05-24 00:02:43 +02:00
2012-08-17 18:37:08 +02:00
# Build the pgsql2psqlite app if requested
if env['PGSQL2SQLITE']:
SConscript('utils/pgsql2sqlite/build.py')
2013-02-23 02:15:29 +01:00
if env['SVG2PNG']:
SConscript('utils/svg2png/build.py')
2012-08-17 18:37:08 +02:00
2012-05-24 00:02:43 +02:00
# devtools not ready for public
2011-08-30 07:32:01 +02:00
#SConscript('utils/ogrindex/build.py')
2010-01-06 00:51:10 +01:00
env['LIBS'].remove('boost_program_options%s' % env['BOOST_APPEND'])
else :
2012-08-17 18:37:08 +02:00
color_print(1,"WARNING: Cannot find boost_program_options. 'shapeindex' and other command line programs will not be available")
2012-05-24 00:02:43 +02:00
2010-01-06 00:51:10 +01:00
# Build the Python bindings
if 'python' in env['BINDINGS']:
2011-08-30 07:32:01 +02:00
SConscript('bindings/python/build.py')
2012-05-24 00:02:43 +02:00
2010-12-16 17:32:06 +01:00
# Install the python speed testing scripts if python bindings will be available
2011-08-30 07:32:01 +02:00
SConscript('utils/performance/build.py')
2010-12-16 17:32:06 +01:00
2011-11-23 12:33:58 +01:00
# Install the mapnik upgrade script
2011-08-30 07:32:01 +02:00
SConscript('utils/upgrade_map_xml/build.py')
2012-05-24 00:02:43 +02:00
2010-01-06 00:51:10 +01:00
# Configure fonts and if requested install the bundled DejaVu fonts
2011-08-30 07:32:01 +02:00
SConscript('fonts/build.py')
2012-05-24 00:02:43 +02:00
2010-07-16 01:09:33 +02:00
# build C++ tests
2013-05-22 18:21:56 +02:00
SConscript('tests/cpp_tests/build.py')
2012-05-24 00:02:43 +02:00
2013-05-22 18:21:56 +02:00
if env['CPP_TESTS'] and env['SVG_RENDERER']:
SConscript('tests/cpp_tests/svg_renderer_tests/build.py')
2010-07-18 23:34:08 +02:00
2013-05-16 03:19:49 +02:00
if env['BENCHMARK']:
SConscript('benchmark/build.py')
2013-01-09 04:07:11 +01:00
2010-07-18 23:34:08 +02:00
# install pkg-config script and mapnik-config script
2011-08-30 07:32:01 +02:00
SConscript('utils/mapnik-config/build.py')
2010-07-23 00:14:19 +02:00
# write the viewer.ini file
2011-08-30 07:32:01 +02:00
SConscript('demo/viewer/build.py')
2012-05-24 00:02:43 +02:00
2010-10-24 10:04:16 +02:00
# if requested, build the sample input plugins
if env['SAMPLE_INPUT_PLUGINS']:
SConscript('plugins/input/templates/helloworld/build.py')
2013-05-24 00:36:43 +02:00
else:
if 'install' in COMMAND_LINE_TARGETS:
plugin_path = os.path.join(env['MAPNIK_INPUT_PLUGINS_DEST'],'hello.input')
if os.path.exists(plugin_path):
2013-06-02 23:15:02 +02:00
color_print(4,"Notice: removing out of date plugin: '%s'" % plugin_path)
2013-05-24 00:36:43 +02:00
os.unlink(plugin_path)
if os.path.exists('plugins/input/templates/hello.input'):
os.unlink('plugins/input/templates/hello.input')
2013-02-19 12:12:13 +01:00
# update linux project files
if env['PLATFORM'] == 'Linux':
update_linux_project_files()