2006-03-31 10:32:02 +00:00
# This file is part of Mapnik (c++ mapping toolkit)
2006-01-31 23:18:24 +00:00
#
2017-08-17 09:52:07 +00:00
# Copyright (C) 2017 Artem Pavlenko
2006-01-31 23:18:24 +00:00
#
2006-03-31 10:32:02 +00: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 15:06:59 +00:00
2017-11-22 13:56:20 +00:00
from __future__ import print_function # support python2
2006-03-31 10:32:02 +00:00
2009-02-26 23:35:09 +00:00
import os
import sys
2009-02-28 23:55:03 +00:00
import re
2009-02-26 23:35:09 +00:00
import platform
from glob import glob
2013-05-16 16:59:21 +00:00
from copy import copy
2009-02-03 23:00:03 +00:00
from subprocess import Popen, PIPE
2009-02-26 23:35:09 +00:00
from SCons.SConf import SetCacheMode
import pickle
2009-03-04 05:11:21 +00:00
try:
import distutils.sysconfig
HAS_DISTUTILS = True
except:
HAS_DISTUTILS = False
2009-04-14 00:01:21 +00:00
2018-06-27 18:48:29 +00:00
try:
# Python 3.3+
from shlex import quote as shquote
except:
# Python 2.7
from pipes import quote as shquote
try:
# Python 3.3+
from subprocess import DEVNULL
except:
# Python 2.7
DEVNULL = open(os.devnull, 'w')
2012-08-16 01:32:28 +00:00
LIBDIR_SCHEMA_DEFAULT='lib'
2012-08-16 22:52:32 +00:00
severities = ['debug', 'warn', 'error', 'none']
2011-06-01 19:43:11 +00:00
2013-11-01 04:14:24 +00:00
ICU_INCLUDES_DEFAULT='/usr/include'
ICU_LIBS_DEFAULT='/usr/'
2015-05-24 20:51:34 +00:00
DEFAULT_CC = "cc"
DEFAULT_CXX = "c++"
2020-09-10 16:50:21 +00:00
DEFAULT_CXX_STD = "14"
DEFAULT_CXX_CXXFLAGS = " -DU_USING_ICU_NAMESPACE=0"
DEFAULT_CXX_LINKFLAGS = ""
2013-05-10 20:24:41 +00:00
if sys.platform == 'darwin':
2013-11-01 04:14:24 +00:00
# homebrew default
ICU_INCLUDES_DEFAULT='/usr/local/opt/icu4c/include/'
ICU_LIBS_DEFAULT='/usr/local/opt/icu4c/'
2013-05-10 20:24:41 +00:00
2012-07-05 18:54:43 +00:00
py3 = None
2011-06-01 19:43:11 +00: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',]
2017-03-27 15:14:51 +00:00
BOOST_MIN_VERSION = '1.61'
2013-01-09 20:49:39 +00:00
#CAIRO_MIN_VERSION = '1.8.0'
2011-06-01 19:43:11 +00:00
2015-02-10 01:52:09 +00:00
HARFBUZZ_MIN_VERSION = (0, 9, 34)
HARFBUZZ_MIN_VERSION_STRING = "%s.%s.%s" % HARFBUZZ_MIN_VERSION
2011-06-01 19:43:11 +00:00
DEFAULT_LINK_PRIORITY = ['internal','other','frameworks','user','system']
pretty_dep_names = {
2015-02-17 19:32:54 +00:00
'clntsh':'Oracle database library | configure with OCCI_LIBS & OCCI_INCLUDES | more info: https://github.com/mapnik/mapnik/wiki/OCCI',
2012-08-16 19:27:58 +00: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 21:15:02 +00: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 19:43:11 +00:00
'cairo':'Cairo C 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/',
2015-02-20 21:22:23 +00:00
'pg':'Postgres C Library required for PostGIS plugin | configure with pg_config program or configure with PG_LIBS & PG_INCLUDES | more info: https://github.com/mapnik/mapnik/wiki/PostGIS',
2013-06-02 21:15:02 +00:00
'sqlite3':'SQLite3 C Library | configure with SQLITE_LIBS & SQLITE_INCLUDES | more info: https://github.com/mapnik/mapnik/wiki/SQLite',
2011-06-01 19:43:11 +00: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',
2013-07-19 05:09:17 +00:00
'webp':'WEBP C library | configure with WEBP_LIBS & WEBP_INCLUDES',
2011-06-01 19:43:11 +00:00
'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/',
Improved support for international text
- Implementation by @herm for GSOC 2012 (http://mapnik.org/news/2012/10/06/gsoc2012-status9/)
- C++11 port, improvements, optimizations by @artemp
- Testing and integration with master by @springmeyer
- Thank you to all the support from @behdad along the way
- Thanks for help testing @toton6868, @stephankn, @nirvn, @mfrasca, @simonsonc and many others
Refs: #2073,#2070,#2038,#2037,#1953,#1820,#1819,#1714,#1634,#1547,#1532,#1319,#1208,#1154,#1146
2013-11-22 08:06:32 +00:00
'harfbuzz':'HarfBuzz text shaping library | configure with HB_LIBS & HB_INCLUDES',
2015-02-10 01:52:09 +00:00
'harfbuzz-min-version':'HarfBuzz >= %s (required for font-feature-settings support)' % HARFBUZZ_MIN_VERSION_STRING,
2011-06-01 19:43:11 +00:00
'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',
2015-02-20 21:22:23 +00:00
'pq':'libpq library (postgres client) | try setting PG_CONFIG SCons option or configure with PG_LIBS & PG_INCLUDES',
2015-01-23 17:12:11 +00:00
'xml2-config':'xml2-config program | try setting XML2_CONFIG SCons option or avoid the need for xml2-config command by configuring with XML2_LIBS & XML2_INCLUDES',
'libxml2':'libxml2 library | try setting XML2_CONFIG SCons option to point to location of xml2-config program or configure with XML2_LIBS & XML2_INCLUDES',
2011-06-01 19:43:11 +00:00
'gdal-config':'gdal-config program | try setting GDAL_CONFIG SCons option',
2015-01-23 17:12:11 +00:00
'freetype-config':'freetype-config program | try setting FREETYPE_CONFIG SCons option or configure with FREETYPE_LIBS & FREETYPE_INCLUDES',
'freetype':'libfreetype library | try setting FREETYPE_CONFIG SCons option or configure with FREETYPE_LIBS & FREETYPE_INCLUDES',
2013-06-02 21:15:02 +00:00
'osm':'more info: https://github.com/mapnik/mapnik/wiki/OsmPlugin',
2011-06-01 19:43:11 +00: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)',
2017-09-10 15:19:04 +00:00
'pgsql2sqlite_rtree':'The pgsql2sqlite program requires libsqlite3 built with RTREE support (-DSQLITE_ENABLE_RTREE=1)',
'PROJ_LIB':'The directory where proj4 stores its data files. Must exist for proj4 to work correctly',
'GDAL_DATA':'The directory where GDAL stores its data files. Must exist for GDAL to work correctly',
'ICU_DATA':'The directory where icu stores its data files. If ICU reports a path, it must exist. ICU can also be built without .dat files and in that case this path is empty'
2011-06-01 19:43:11 +00:00
}
2012-05-23 22:02:43 +00:00
2011-06-01 19:43:11 +00:00
# Core plugin build configuration
# opts.AddVariables still hardcoded however...
PLUGINS = { # plugins with external dependencies
2015-10-12 20:38:15 +00:00
# configured by calling project, hence 'path':None
'postgis': {'default':True,'path':None,'inc':'libpq-fe.h','lib':'pq','lang':'C'},
'pgraster': {'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++'},
'sqlite': {'default':True,'path':'SQLITE','inc':'sqlite3.h','lib':'sqlite3','lang':'C'},
# plugins without external dependencies requiring CheckLibWithHeader...
'shape': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
'csv': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
'raster': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
'geojson': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
2017-08-17 09:52:07 +00:00
'geobuf': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
2015-10-12 20:38:15 +00:00
'topojson':{'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'}
}
2011-06-01 19:43:11 +00:00
2013-08-14 00:02:14 +00:00
def init_environment(env):
env.Decider('MD5-timestamp')
env.SourceCode(".", None)
2019-08-18 20:48:18 +00:00
env['ORIGIN'] = Literal('$ORIGIN')
env['ENV']['ORIGIN'] = '$ORIGIN'
2013-08-14 00:02:14 +00:00
if os.environ.get('RANLIB'):
2015-10-12 20:38:15 +00:00
env['RANLIB'] = os.environ['RANLIB']
2013-08-14 00:02:14 +00:00
if os.environ.get('AR'):
2015-10-12 20:38:15 +00:00
env['AR'] = os.environ['AR']
2013-08-14 00:02:14 +00:00
2009-04-14 00:01:21 +00:00
#### SCons build options and initial setup ####
2009-07-08 18:40:10 +00:00
env = Environment(ENV=os.environ)
2019-03-07 19:01:24 +00:00
2013-08-14 00:02:14 +00:00
init_environment(env)
2009-04-14 00:01:21 +00:00
2015-02-20 20:56:08 +00:00
def fix_path(path):
2017-11-16 10:59:55 +00:00
return str(os.path.abspath(path))
2015-02-20 20:56:08 +00:00
2009-02-03 21:14:45 +00:00
def color_print(color,text,newline=True):
2009-01-26 22:58:55 +00:00
# 1 - red
# 2 - green
# 3 - yellow
# 4 - blue
2009-02-03 21:14:45 +00:00
text = "\033[9%sm%s\033[0m" % (color,text)
if not newline:
2017-11-22 13:56:20 +00:00
print (text, end='')
2009-02-03 21:14:45 +00:00
else:
2017-11-16 10:59:55 +00:00
print (text)
2009-01-26 22:58:55 +00:00
2009-04-14 00:01:21 +00:00
def regular_print(color,text,newline=True):
if not newline:
2017-11-22 13:56:20 +00:00
print (text, end = '')
2009-04-14 00:01:21 +00:00
else:
2017-11-16 10:59:55 +00:00
print (text)
2009-04-14 00:01:21 +00:00
2018-06-27 18:48:29 +00:00
def shell_command(cmd, *args, **kwargs):
""" Run command through shell.
`cmd` should be a valid, properly shell-quoted command.
Additional positional arguments, if provided, will each
be individually quoted as necessary and appended to `cmd`,
separated by spaces.
2018-06-28 12:10:03 +00:00
`logstream` optional keyword argument should be either:
- a file-like object, into which the command-line
and the command's STDERR output will be written; or
- None, in which case STDERR will go to DEVNULL.
2018-06-27 18:48:29 +00:00
Additional keyword arguments will be passed to `Popen`.
Returns a tuple `(result, output)` where:
`result` = True if the command completed successfully,
False otherwise
2018-06-28 12:10:03 +00:00
`output` = captured STDOUT with trailing whitespace removed
2018-06-27 18:48:29 +00:00
"""
# `cmd` itself is intentionally not wrapped in `shquote` here
# in order to support passing user-provided commands that may
# include arguments. For example:
#
# ret, out = shell_command(env['CXX'], '--version')
#
# needs to work even if `env['CXX'] == 'ccache c++'`
#
if args:
cmdstr = ' '.join([cmd] + [shquote(a) for a in args])
else:
cmdstr = cmd
2018-06-28 12:10:03 +00:00
# redirect STDERR to `logstream` if provided
try:
logstream = kwargs.pop('logstream')
except KeyError:
logstream = None
else:
if logstream is not None:
logstream.write(cmdstr + '\n')
kwargs['stderr'] = logstream
else:
kwargs['stderr'] = DEVNULL
# execute command and capture output
2018-06-27 18:48:29 +00:00
proc = Popen(cmdstr, shell=True, stdout=PIPE, **kwargs)
out, err = proc.communicate()
2018-06-28 12:10:03 +00:00
try:
outtext = out.decode(sys.stdout.encoding or 'UTF-8').rstrip()
except UnicodeDecodeError:
outtext = out.decode('UTF-8', errors='replace').rstrip()
if logstream is not None and outtext:
logstream.write('->\t' + outtext.replace('\n', '\n->\t') + '\n')
return proc.returncode == 0, outtext
2018-06-27 18:48:29 +00:00
def silent_command(cmd, *args):
return shell_command(cmd, *args, stderr=DEVNULL)
2009-02-03 23:00:03 +00:00
2018-06-28 12:10:03 +00:00
def config_command(cmd, *args):
return shell_command(cmd, *args, logstream=conf.logstream)
2011-08-15 07:00:06 +00:00
def strip_first(string,find,replace=''):
if string.startswith(find):
2015-10-12 20:38:15 +00:00
return string.replace(find,replace,1)
2011-08-15 07:00:06 +00:00
return string
2010-07-18 20:39:05 +00:00
# http://www.scons.org/wiki/InstallTargets
def create_uninstall_target(env, path, is_glob=False):
2010-07-18 21:26:50 +00:00
if 'uninstall' in COMMAND_LINE_TARGETS:
2015-10-12 20:38:15 +00:00
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-23 22:02:43 +00:00
2013-05-16 16:59:21 +00:00
def rm_path(item,set,_env):
for i in _env[set]:
2015-10-12 20:38:15 +00:00
if i.startswith(item):
_env[set].remove(i)
2010-02-23 02:40:46 +00:00
def sort_paths(items,priority):
"""Sort paths such that compiling and linking will globally prefer custom or local libs
2013-05-10 20:24:41 +00:00
over system libraries by fixing up the order libs are passed to the compiler and the linker.
2012-05-23 22:02:43 +00:00
2010-02-23 02:40:46 +00: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-23 22:02:43 +00:00
2010-02-23 02:40:46 +00: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-23 22:02:43 +00:00
2010-02-23 02:40:46 +00: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-23 22:02:43 +00:00
2010-02-23 02:40:46 +00:00
Sorting using a priority list allows this to be controlled, and fine tuned.
"""
2012-05-23 22:02:43 +00:00
2010-02-23 02:40:46 +00: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:
2015-10-12 20:38:15 +00:00
# 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:
if '/usr/local' in i:
path_types['user'].insert(0,i)
else:
path_types['user'].append(i)
# key system libs (likely others will fall into 'other')
elif '/usr/' in i or '/System' in i or i.startswith('/lib'):
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)
2010-02-23 02:40:46 +00:00
# build up new list based on priority list
for path in priority:
2017-11-23 10:30:35 +00:00
if path in path_types:
2015-10-12 20:38:15 +00:00
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)
2010-02-23 02:40:46 +00:00
# append remaining paths potentially not requested
# by any custom priority list defined by user
for k,v in path_types.items():
2015-10-12 20:38:15 +00:00
new.extend(v)
2010-02-23 02:40:46 +00:00
return new
2010-01-05 23:51:10 +00:00
def pretty_dep(dep):
pretty = pretty_dep_names.get(dep)
if pretty:
2015-10-12 20:38:15 +00:00
return '%s (%s)' % (dep,pretty)
2010-01-05 23:51:10 +00:00
elif 'boost' in dep:
2015-10-12 20:38:15 +00:00
return '%s (%s)' % (dep,'more info see: https://github.com/mapnik/mapnik/wiki/Mapnik-Installation & http://www.boost.org')
2010-01-05 23:51:10 +00:00
return dep
2019-09-01 09:54:23 +00:00
def pretty_deps(indent, deps):
return indent + indent.join(pretty_dep(dep) for dep in deps)
2009-02-03 21:14:45 +00:00
DEFAULT_PLUGINS = []
for k,v in PLUGINS.items():
if v['default']:
2009-02-25 22:56:47 +00:00
DEFAULT_PLUGINS.append(k)
2009-02-03 21:14:45 +00:00
2008-01-21 20:15:07 +00:00
# All of the following options may be modified at the command-line, for example:
2009-01-26 22:58:55 +00:00
# `python scons/scons.py PREFIX=/opt`
opts = Variables()
2009-02-25 22:56:47 +00:00
opts.AddVariables(
# Compiler options
2013-05-10 20:24:41 +00:00
('CXX', 'The C++ compiler to use to compile mapnik', DEFAULT_CXX),
2020-09-10 16:50:21 +00:00
('CXX_STD', 'The C++ compiler standard (string).', DEFAULT_CXX_STD),
2013-05-10 20:24:41 +00:00
('CC', 'The C compiler used for configure checks of C libs.', DEFAULT_CC),
2010-09-18 18:02:15 +00:00
('CUSTOM_CXXFLAGS', 'Custom C++ flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir>', ''),
2013-03-14 02:49:59 +00:00
('CUSTOM_DEFINES', 'Custom Compiler DEFINES, e.g. -DENABLE_THIS', ''),
2012-06-13 21:17:58 +00: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 18:02:15 +00:00
('CUSTOM_LDFLAGS', 'Custom linker flags, e.g. -L<lib dir> if you have libraries in a nonstandard directory <lib dir>', ''),
2011-08-11 19:14:00 +00:00
EnumVariable('LINKING', "Set library format for libmapnik",'shared', ['shared','static']),
2011-08-12 20:01:09 +00:00
EnumVariable('RUNTIME_LINK', "Set preference for linking dependencies",'shared', ['shared','static']),
2013-05-10 20:24:41 +00:00
EnumVariable('OPTIMIZATION','Set compiler optimization level','3', ['0','1','2','3','4','s']),
2009-02-25 22:56:47 +00:00
# Note: setting DEBUG=True will override any custom OPTIMIZATION level
BoolVariable('DEBUG', 'Compile a debug version of Mapnik', 'False'),
2016-03-03 22:19:12 +00:00
BoolVariable('COVERAGE', 'Compile a libmapnik and plugins with --coverage', 'False'),
2009-02-25 22:56:47 +00:00
ListVariable('INPUT_PLUGINS','Input drivers to include',DEFAULT_PLUGINS,PLUGINS.keys()),
2011-08-11 14:31:46 +00:00
('WARNING_CXXFLAGS', 'Compiler flags you can set to reduce warning levels which are placed after -Wall.', ''),
2012-05-23 22:02:43 +00:00
2009-02-25 22:56:47 +00:00
# SCons build behavior options
2015-05-23 23:53:00 +00:00
('HOST', 'Set the target host for cross compiling', ''),
2009-02-25 22:56:47 +00: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'),
2015-08-11 16:34:35 +00:00
BoolVariable('NO_ATEXIT', 'Will prevent Singletons from being deleted atexit of main thread', 'False'),
2016-03-03 23:02:03 +00:00
BoolVariable('NO_DLCLOSE', 'Will prevent plugins from being unloaded', 'False'),
2017-11-09 18:07:26 +00:00
BoolVariable('ENABLE_GLIBC_WORKAROUND', "Workaround known GLIBC symbol exports to allow building against libstdc++-4.8 without binaries needing throw_out_of_range_fmt", 'False'),
2010-09-18 16:50:05 +00:00
# http://www.scons.org/wiki/GoFastButton
2011-08-12 00:01:04 +00:00
# http://stackoverflow.com/questions/1318863/how-to-optimize-an-scons-script
2011-09-15 22:15:04 +00:00
BoolVariable('FAST', "Make SCons faster at the cost of less precise dependency tracking", 'False'),
2011-08-11 14:35:02 +00:00
BoolVariable('PRIORITIZE_LINKING', 'Sort list of lib and inc directories to ensure preferential compiling and linking (useful when duplicate libs)', 'True'),
2012-05-23 22:02:43 +00: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 22:56:47 +00:00
# Install Variables
('PREFIX', 'The install path "prefix"', '/usr/local'),
2012-08-16 01:32:28 +00:00
('LIBDIR_SCHEMA', 'The library sub-directory appended to the "prefix", sometimes lib64 on 64bit linux systems', LIBDIR_SCHEMA_DEFAULT),
2009-02-25 22:56:47 +00:00
('DESTDIR', 'The root directory to install into. Useful mainly for binary package building', '/'),
2011-10-13 21:19:21 +00: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)', ''),
2013-08-09 15:31:17 +00:00
('PATH_REMOVE', 'A path prefix to exclude from all known command and compile paths (create multiple excludes separated by :)', ''),
2011-11-16 20:47:31 +00:00
('PATH_REPLACE', 'Two path prefixes (divided with a :) to search/replace from all known command and compile paths', ''),
2014-06-09 20:55:56 +00:00
('MAPNIK_NAME', 'Name of library', 'mapnik'),
2012-05-23 22:02:43 +00:00
2009-02-25 22:56:47 +00:00
# Boost variables
2009-07-01 23:52:51 +00: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 22:56:47 +00: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-05-23 22:02:43 +00:00
2009-02-25 22:56:47 +00: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'),
2013-11-01 04:14:24 +00:00
PathVariable('ICU_INCLUDES', 'Search path for ICU include files', ICU_INCLUDES_DEFAULT, PathVariable.PathAccept),
PathVariable('ICU_LIBS','Search path for ICU include files',ICU_LIBS_DEFAULT + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
2013-05-16 18:33:23 +00:00
('ICU_LIB_NAME', 'The library name for icu (such as icuuc, sicuuc, or icucore)', 'icuuc', PathVariable.PathAccept),
Improved support for international text
- Implementation by @herm for GSOC 2012 (http://mapnik.org/news/2012/10/06/gsoc2012-status9/)
- C++11 port, improvements, optimizations by @artemp
- Testing and integration with master by @springmeyer
- Thank you to all the support from @behdad along the way
- Thanks for help testing @toton6868, @stephankn, @nirvn, @mfrasca, @simonsonc and many others
Refs: #2073,#2070,#2038,#2037,#1953,#1820,#1819,#1714,#1634,#1547,#1532,#1319,#1208,#1154,#1146
2013-11-22 08:06:32 +00:00
PathVariable('HB_INCLUDES', 'Search path for HarfBuzz include files', '/usr/include', PathVariable.PathAccept),
PathVariable('HB_LIBS','Search path for HarfBuzz include files','/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
2013-01-29 07:17:37 +00: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-23 22:02:43 +00:00
BoolVariable('JPEG', 'Build Mapnik with JPEG read and write support', 'True'),
2009-02-25 22:56:47 +00:00
PathVariable('JPEG_INCLUDES', 'Search path for libjpeg include files', '/usr/include', PathVariable.PathAccept),
2012-08-16 01:32:28 +00:00
PathVariable('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
2013-01-29 07:17:37 +00:00
BoolVariable('TIFF', 'Build Mapnik with TIFF read and write support', 'True'),
2009-02-25 22:56:47 +00:00
PathVariable('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include', PathVariable.PathAccept),
2012-08-16 01:32:28 +00:00
PathVariable('TIFF_LIBS', 'Search path for libtiff library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
2013-07-19 05:09:17 +00:00
BoolVariable('WEBP', 'Build Mapnik with WEBP read', 'True'),
PathVariable('WEBP_INCLUDES', 'Search path for libwebp include files', '/usr/include', PathVariable.PathAccept),
PathVariable('WEBP_LIBS','Search path for libwebp library files','/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
2013-01-29 07:21:27 +00:00
BoolVariable('PROJ', 'Build Mapnik with proj4 support to enable transformations between many different projections', 'True'),
2012-08-15 21:16:49 +00:00
PathVariable('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/include', PathVariable.PathAccept),
2012-08-16 01:32:28 +00:00
PathVariable('PROJ_LIBS', 'Search path for PROJ.4 library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
2015-02-20 21:22:23 +00:00
('PG_INCLUDES', 'Search path for libpq (postgres client) include files', ''),
('PG_LIBS', 'Search path for libpq (postgres client) library files', ''),
2015-01-23 17:12:11 +00:00
('FREETYPE_INCLUDES', 'Search path for Freetype include files', ''),
('FREETYPE_LIBS', 'Search path for Freetype library files', ''),
('XML2_INCLUDES', 'Search path for libxml2 include files', ''),
('XML2_LIBS', 'Search path for libxml2 library files', ''),
2009-07-02 00:48:42 +00:00
('PKG_CONFIG_PATH', 'Use this path to point pkg-config to .pc files instead of the PKG_CONFIG_PATH environment setting',''),
2012-05-23 22:02:43 +00:00
2009-02-25 22:56:47 +00:00
# Variables affecting rendering back-ends
2012-05-23 22:02:43 +00:00
2013-07-23 23:37:25 +00:00
BoolVariable('GRID_RENDERER', 'build support for native grid renderer', 'True'),
2012-11-01 17:07:29 +00:00
BoolVariable('SVG_RENDERER', 'build support for native svg renderer', 'False'),
2012-12-20 04:12:13 +00:00
BoolVariable('CPP_TESTS', 'Compile the C++ tests', 'True'),
2013-05-16 01:19:49 +00:00
BoolVariable('BENCHMARK', 'Compile the C++ benchmark scripts', 'False'),
2012-05-23 22:02:43 +00:00
2009-02-25 22:56:47 +00:00
# Variables for optional dependencies
2013-01-09 20:49:39 +00:00
# Note: cairo and and pycairo are optional but configured automatically through pkg-config
2009-02-25 22:56:47 +00:00
# Therefore, we use a single boolean for whether to attempt to build cairo support.
2011-03-04 22:15:11 +00:00
BoolVariable('CAIRO', 'Attempt to build with Cairo rendering support', 'True'),
2013-01-09 17:00:30 +00: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 21:18:32 +00: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 22:56:47 +00:00
PathVariable('OCCI_INCLUDES', 'Search path for OCCI include files', '/usr/lib/oracle/10.2.0.3/client/include', PathVariable.PathAccept),
2012-08-16 01:32:28 +00: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 22:56:47 +00:00
PathVariable('SQLITE_INCLUDES', 'Search path for SQLITE include files', '/usr/include/', PathVariable.PathAccept),
2012-08-16 01:32:28 +00:00
PathVariable('SQLITE_LIBS', 'Search path for SQLITE library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
2009-12-16 20:02:06 +00:00
PathVariable('RASTERLITE_INCLUDES', 'Search path for RASTERLITE include files', '/usr/include/', PathVariable.PathAccept),
2012-08-16 01:32:28 +00:00
PathVariable('RASTERLITE_LIBS', 'Search path for RASTERLITE library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
2012-04-08 00:20:56 +00:00
# Variables for logging and statistics
2012-04-12 01:08:11 +00:00
BoolVariable('ENABLE_LOG', 'Enable logging, which is enabled by default when building in *debug*', 'False'),
2012-04-08 00:20:56 +00:00
BoolVariable('ENABLE_STATS', 'Enable global statistics during map processing', 'False'),
2013-03-27 08:01:03 +00:00
('DEFAULT_LOG_SEVERITY', 'The default severity of the logger (eg. ' + ', '.join(severities) + ')', 'error'),
2012-04-08 00:20:56 +00:00
2013-05-16 18:33:23 +00:00
# Plugin linking
EnumVariable('PLUGIN_LINKING', "Set plugin linking with libmapnik", 'shared', ['shared','static']),
2009-02-25 22:56:47 +00:00
# Other variables
2015-10-16 20:34:53 +00:00
BoolVariable('MEMORY_MAPPED_FILE', 'Utilize memory-mapped files in Shapefile Plugin (higher memory usage, better performance)', 'True'),
2012-09-13 20:40:15 +00:00
('SYSTEM_FONTS','Provide location for python bindings to register fonts (if provided then the bundled DejaVu fonts are not installed)',''),
2011-11-23 11:33:58 +00:00
('LIB_DIR_NAME','Name to use for the subfolder beside libmapnik where fonts and plugins are installed','mapnik'),
2009-02-25 22:56:47 +00:00
PathVariable('PYTHON','Full path to Python executable used to build bindings', sys.executable),
2014-01-22 05:15:28 +00:00
BoolVariable('FULL_LIB_PATH', 'Embed the full and absolute path to libmapnik when linking ("install_name" on OS X/rpath on Linux)', 'True'),
BoolVariable('ENABLE_SONAME', 'Embed a soname in libmapnik on Linux', 'True'),
2009-02-25 22:56:47 +00:00
EnumVariable('THREADING','Set threading support','multi', ['multi','single']),
2015-07-30 18:22:23 +00:00
EnumVariable('XMLPARSER','Set xml parser','ptree', ['libxml2','ptree']),
2012-04-04 22:20:18 +00:00
BoolVariable('DEMO', 'Compile demo c++ application', 'True'),
2009-03-03 19:31:05 +00:00
BoolVariable('PGSQL2SQLITE', 'Compile and install a utility to convert postgres tables to sqlite', 'False'),
2013-02-23 01:15:29 +00:00
BoolVariable('SHAPEINDEX', 'Compile and install a utility to generate shapefile indexes in the custom format (.index) Mapnik supports', 'True'),
2015-10-12 20:38:15 +00:00
BoolVariable('MAPNIK_INDEX', 'Compile and install a utility to generate spatial indexes for CSV and GeoJSON in the custom format (.index) Mapnik supports', 'True'),
2013-02-23 01:15:29 +00:00
BoolVariable('SVG2PNG', 'Compile and install a utility to generate render an svg file to a png on the command line', 'False'),
2015-10-12 17:38:58 +00:00
BoolVariable('MAPNIK_RENDER', 'Compile and install a utility to render a map to an image', 'True'),
2009-04-14 00:01:21 +00:00
BoolVariable('COLOR_PRINT', 'Print build status information in color', 'True'),
2013-01-03 16:23:36 +00:00
BoolVariable('BIGINT', 'Compile support for 64-bit integers in mapnik::value', 'True'),
2019-03-07 19:01:24 +00:00
BoolVariable('QUIET', 'Reduce build verbosity', 'False'),
2009-02-25 22:56:47 +00:00
)
2011-08-12 20:01:09 +00:00
2009-02-26 23:35:09 +00:00
# variables to pickle after successful configure step
# these include all scons core variables as well as custom
2010-12-21 20:34:36 +00:00
# env variables needed in SConscript files
2009-02-26 23:35:09 +00:00
pickle_store = [# Scons internal variables
2015-10-12 20:38:15 +00:00
'CC', # compiler user to check if c deps compile during configure
'CXX', # C++ compiler to compile mapnik
2020-09-10 16:50:21 +00:00
'CXX_STD', # C++ standard e.g 17 (as in -std=c++17)
2015-10-12 20:38:15 +00:00
'CFLAGS',
'CPPDEFINES',
'CPPFLAGS', # c preprocessor flags
'CPPPATH',
'CXXFLAGS', # C++ flags built up during configure
'LIBPATH',
'LIBS',
'LINKFLAGS',
2019-08-18 21:01:11 +00:00
'RPATH',
2015-10-12 20:38:15 +00:00
'CUSTOM_LDFLAGS', # user submitted
'CUSTOM_DEFINES', # user submitted
'CUSTOM_CXXFLAGS', # user submitted
'CUSTOM_CFLAGS', # user submitted
'MAPNIK_LIB_NAME',
'LINK',
'RUNTIME_LINK',
# Mapnik's SConstruct build variables
'PLUGINS',
'ABI_VERSION',
'MAPNIK_VERSION_STRING',
'MAPNIK_VERSION',
'PLATFORM',
'BOOST_ABI',
'BOOST_APPEND',
'LIBDIR_SCHEMA',
'REQUESTED_PLUGINS',
'COLOR_PRINT',
'HAS_CAIRO',
'MAPNIK_HAS_DLFCN',
'HAS_PYCAIRO',
'PYCAIRO_PATHS',
'HAS_LIBXML2',
'PKG_CONFIG_PATH',
'PATH',
'PATH_REMOVE',
'PATH_REPLACE',
'MAPNIK_LIB_DIR',
'MAPNIK_LIB_DIR_DEST',
'INSTALL_PREFIX',
'MAPNIK_INPUT_PLUGINS',
'MAPNIK_INPUT_PLUGINS_DEST',
'MAPNIK_FONTS',
'MAPNIK_FONTS_DEST',
'MAPNIK_BUNDLED_SHARE_DIRECTORY',
'MAPNIK_LIB_BASE',
'MAPNIK_LIB_BASE_DEST',
'EXTRA_FREETYPE_LIBS',
'LIBMAPNIK_CPPATHS',
'LIBMAPNIK_DEFINES',
'LIBMAPNIK_CXXFLAGS',
'CAIRO_LIBPATHS',
'CAIRO_ALL_LIBS',
'CAIRO_CPPPATHS',
'GRID_RENDERER',
'SVG_RENDERER',
'SQLITE_LINKFLAGS',
'BOOST_LIB_VERSION_FROM_HEADER',
'BIGINT',
2017-09-10 15:19:04 +00:00
'HOST',
'QUERIED_GDAL_DATA',
'QUERIED_ICU_DATA',
2019-03-07 19:01:24 +00:00
'QUERIED_PROJ_LIB',
'QUIET'
2015-10-12 20:38:15 +00:00
]
2009-02-26 23:35:09 +00: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:
2015-10-12 20:38:15 +00:00
pickle_store.append(opt.key)
2009-02-26 23:35:09 +00:00
2018-06-29 14:24:04 +00:00
def rollback_option(env, variable):
global opts
for item in opts.options:
if item.key == variable:
env[variable] = item.default
2009-03-30 16:52:31 +00:00
# Method of adding configure behavior to Scons adapted from:
2009-02-26 23:35:09 +00:00
# http://freeorion.svn.sourceforge.net/svnroot/freeorion/trunk/FreeOrion/SConstruct
preconfigured = False
force_configure = False
command_line_args = sys.argv[1:]
2010-01-05 23:51:10 +00:00
HELP_REQUESTED = False
if ('-h' in command_line_args) or ('--help' in command_line_args):
HELP_REQUESTED = True
2012-05-23 22:02:43 +00:00
2011-02-03 08:16:39 +00:00
if 'configure' in command_line_args and not HELP_REQUESTED:
2009-02-26 23:35:09 +00:00
force_configure = True
2010-01-05 23:51:10 +00:00
elif HELP_REQUESTED:
2011-02-03 08:16:39 +00:00
# to ensure config gets skipped when help is requested
preconfigured = True
2009-02-26 23:35:09 +00:00
2014-07-30 00:54:49 +00:00
# need no-op for clean on fresh checkout
# https://github.com/mapnik/mapnik/issues/2112
2014-09-30 04:20:01 +00:00
if not os.path.exists(SCONS_LOCAL_LOG) and not os.path.exists(SCONS_CONFIGURE_CACHE) \
and ('-c' in command_line_args or '--clean' in command_line_args):
2017-11-16 10:59:55 +00:00
print ('all good: nothing to clean, but you might want to run "make distclean"')
2014-07-30 00:54:49 +00:00
Exit(0)
2009-03-30 16:52:31 +00: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-26 23:35:09 +00:00
if not force_configure:
if os.path.exists(SCONS_CONFIGURE_CACHE):
2015-10-12 20:38:15 +00:00
try:
2017-11-21 12:12:52 +00:00
pickled_environment = open(SCONS_CONFIGURE_CACHE, 'rb')
2015-10-12 20:38:15 +00:00
pickled_values = pickle.load(pickled_environment)
for key, value in pickled_values.items():
env[key] = value
preconfigured = True
except:
preconfigured = False
2009-01-26 22:58:55 +00:00
else:
2015-10-12 20:38:15 +00:00
preconfigured = False
2009-01-26 22:58:55 +00:00
2010-02-21 01:00:09 +00: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:
2015-10-12 20:38:15 +00:00
#print 'missing opt', opt
preconfigured = False
2010-02-21 01:00:09 +00:00
2009-03-30 16:52:31 +00:00
# if custom arguments are supplied make sure to accept them
2009-03-09 04:45:09 +00:00
if opts.args:
2012-05-23 22:02:43 +00:00
# since we have custom arguments update environment with all opts to
2009-03-30 16:52:31 +00:00
# make sure to absorb the custom ones
opts.Update(env)
2012-05-23 22:02:43 +00:00
# now since we've got custom arguments we'll disregard any
2009-03-30 16:52:31 +00:00
# pickled environment and force another configuration
2009-03-09 04:45:09 +00:00
preconfigured = False
2009-03-30 16:52:31 +00:00
2009-03-09 04:45:09 +00:00
elif preconfigured:
2010-01-05 23:51:10 +00:00
if not HELP_REQUESTED:
2015-10-12 20:38:15 +00:00
color_print(4,'Using previous successful configuration...')
color_print(4,'Re-configure by running "python scons/scons.py configure".')
2009-03-09 04:45:09 +00:00
2017-11-23 10:30:35 +00:00
if 'COLOR_PRINT' in env and env['COLOR_PRINT'] == False:
2010-10-07 00:42:47 +00:00
color_print = regular_print
if sys.platform == "win32":
color_print = regular_print
color_print(4,'\nWelcome to Mapnik...\n')
2009-01-26 22:58:55 +00:00
2009-02-26 23:35:09 +00:00
#### Custom Configure Checks ###
2008-01-28 14:51:10 +00:00
2017-11-23 10:30:35 +00:00
def prioritize_paths(context, silent=True):
2010-02-23 02:40:46 +00:00
env = context.env
prefs = env['LINK_PRIORITY'].split(',')
2010-08-21 05:35:38 +00:00
if not silent:
2015-10-12 20:38:15 +00:00
context.Message( 'Sorting lib and inc compiler paths...')
2017-11-23 10:30:35 +00:00
env['LIBPATH'] = sort_paths(env['LIBPATH'], prefs)
env['CPPPATH'] = sort_paths(env['CPPPATH'], prefs)
2010-08-21 05:35:38 +00:00
if silent:
2015-10-12 20:38:15 +00:00
context.did_show_result=1
2010-02-23 02:40:46 +00:00
ret = context.Result( True )
return ret
2009-01-10 12:08:55 +00:00
def CheckPKGConfig(context, version):
2009-02-25 22:56:47 +00:00
context.Message( 'Checking for pkg-config... ' )
2018-06-27 18:48:29 +00:00
context.sconf.cached = False
2018-06-28 12:10:03 +00:00
ret, _ = config_command('pkg-config --atleast-pkgconfig-version', version)
2009-02-25 22:56:47 +00:00
context.Result( ret )
return ret
2009-01-10 12:08:55 +00:00
def CheckPKG(context, name):
context.Message( 'Checking for %s... ' % name )
2018-06-27 18:48:29 +00:00
context.sconf.cached = False
2018-06-28 12:10:03 +00:00
ret, _ = config_command('pkg-config --exists', name)
2009-01-10 12:08:55 +00:00
context.Result( ret )
return ret
2011-06-01 19:43:11 +00:00
def CheckPKGVersion(context, name, version):
context.Message( 'Checking for at least version %s for %s... ' % (version,name) )
2018-06-27 18:48:29 +00:00
context.sconf.cached = False
2018-06-28 12:10:03 +00:00
ret, _ = config_command('pkg-config --atleast-version', version, name)
2011-06-01 19:43:11 +00:00
context.Result( ret )
return ret
2009-02-28 21:18:32 +00:00
def parse_config(context, config, checks='--libs --cflags'):
env = context.env
tool = config.lower().replace('_','-')
2010-01-05 23:51:10 +00:00
toolname = tool
2013-04-19 21:09:25 +00:00
if config in ('GDAL_CONFIG'):
2015-10-12 20:38:15 +00:00
toolname += ' %s' % checks
2010-01-05 23:51:10 +00:00
context.Message( 'Checking for %s... ' % toolname)
2018-06-27 18:48:29 +00:00
context.sconf.cached = False
cmd = '%s %s' % (env[config], checks)
2018-06-28 12:10:03 +00:00
ret, value = config_command(cmd)
2010-01-05 23:51:10 +00:00
parsed = False
2009-02-28 21:18:32 +00:00
if ret:
2015-10-12 20:38:15 +00:00
try:
if 'gdal-config' in cmd:
env.ParseConfig(cmd)
# 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':
2020-02-27 20:03:43 +00:00
if value and b'-framework GDAL' in value:
2015-10-12 20:38:15 +00:00
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")
else:
env.ParseConfig(cmd)
parsed = True
2017-11-16 10:59:55 +00:00
except OSError as e:
2015-10-12 20:38:15 +00:00
ret = False
2017-11-16 10:59:55 +00:00
print (' (xml2-config not found!)')
2010-01-05 23:51:10 +00:00
if not parsed:
2015-10-12 20:38:15 +00:00
if config in ('GDAL_CONFIG'):
# optional deps...
if tool not in env['SKIPPED_DEPS']:
env['SKIPPED_DEPS'].append(tool)
2018-06-29 14:24:04 +00:00
rollback_option(env, config)
2015-10-12 20:38:15 +00:00
else: # freetype and libxml2, not optional
if tool not in env['MISSING_DEPS']:
env['MISSING_DEPS'].append(tool)
2009-02-28 21:18:32 +00:00
context.Result( ret )
return ret
2009-02-28 23:55:03 +00: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)
2018-06-27 18:48:29 +00:00
context.sconf.cached = False
2018-06-28 12:10:03 +00:00
ret, value = config_command(env[config], '--libs')
2010-01-05 23:51:10 +00:00
parsed = False
2009-02-28 23:55:03 +00:00
if ret:
2015-10-12 20:38:15 +00:00
try:
if ' ' in value:
parts = value.split(' ')
if len(parts) > 1:
value = parts[1]
2017-11-21 12:12:52 +00:00
libnames = re.findall(libpattern, value)
2015-10-12 20:38:15 +00:00
if libnames:
libname = libnames[0]
else:
# osx 1.8 install gives '-framework GDAL'
libname = 'gdal'
2017-11-16 10:59:55 +00:00
except Exception as e:
2015-10-12 20:38:15 +00:00
ret = False
2017-11-21 12:12:52 +00:00
print (' unable to determine library name:# {0!s}'.format(e))
2015-10-12 20:38:15 +00:00
return None
2009-02-28 23:55:03 +00:00
context.Result( libname )
2009-03-09 00:27:06 +00:00
return libname
2009-02-28 23:55:03 +00:00
2009-02-28 21:18:32 +00:00
def parse_pg_config(context, config):
2011-08-11 19:14:00 +00:00
# TODO - leverage `LDFLAGS_SL` if RUNTIME_LINK==static
2009-02-28 21:18:32 +00:00
env = context.env
tool = config.lower()
context.Message( 'Checking for %s... ' % tool)
2018-06-27 18:48:29 +00:00
context.sconf.cached = False
2018-06-28 12:10:03 +00:00
ret, lib_path = config_command(env[config], '--libdir')
ret, inc_path = config_command(env[config], '--includedir')
2009-02-28 21:18:32 +00:00
if ret:
2015-10-12 20:38:15 +00:00
env.AppendUnique(CPPPATH = fix_path(inc_path))
env.AppendUnique(LIBPATH = fix_path(lib_path))
lpq = env['PLUGINS']['postgis']['lib']
env.Append(LIBS = lpq)
2009-02-28 21:18:32 +00:00
else:
2015-10-12 20:38:15 +00:00
env['SKIPPED_DEPS'].append(tool)
2018-06-29 14:24:04 +00:00
rollback_option(env, config)
2009-02-28 21:18:32 +00:00
context.Result( ret )
return ret
def ogr_enabled(context):
env = context.env
context.Message( 'Checking if gdal is ogr enabled... ')
2018-06-27 18:48:29 +00:00
context.sconf.cached = False
2018-06-28 12:10:03 +00:00
ret, out = config_command(env['GDAL_CONFIG'], '--ogr-enabled')
2019-08-19 15:35:45 +00:00
if ret:
2018-06-28 12:12:13 +00:00
ret = (out == 'yes')
2009-02-28 21:18:32 +00:00
if not ret:
2015-10-12 20:38:15 +00:00
if 'ogr' not in env['SKIPPED_DEPS']:
env['SKIPPED_DEPS'].append('ogr')
2009-02-28 21:18:32 +00:00
context.Result( ret )
return ret
2009-12-15 19:25:35 +00:00
def FindBoost(context, prefixes, thread_flag):
2009-07-01 23:52:51 +00:00
"""Routine to auto-find boost header dir, lib dir, and library naming structure.
2012-05-23 22:02:43 +00:00
2009-07-01 23:52:51 +00:00
"""
context.Message( 'Searching for boost libs and headers... ' )
env = context.env
2012-05-23 22:02:43 +00:00
2009-07-01 23:52:51 +00:00
BOOST_LIB_DIR = None
BOOST_INCLUDE_DIR = None
BOOST_APPEND = None
env['BOOST_APPEND'] = str()
2016-05-19 23:37:06 +00:00
search_lib = 'libboost_filesystem'
2010-08-25 22:20:19 +00: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-01 23:52:51 +00:00
for searchDir in prefixes:
2015-10-12 20:38:15 +00:00
libItems = glob(os.path.join(searchDir, env['LIBDIR_SCHEMA'], '%s*.*' % search_lib))
if not libItems:
libItems = glob(os.path.join(searchDir, 'lib/%s*.*' % search_lib))
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/')
2018-06-29 14:43:33 +00:00
shortest_lib_name = min(libItems, key=len)
2015-10-12 20:38:15 +00:00
match = re.search(r'%s(.*)\..*' % search_lib, shortest_lib_name)
if hasattr(match,'groups'):
BOOST_APPEND = match.groups()[0]
break
2012-05-23 22:02:43 +00:00
2009-07-01 23:52:51 +00:00
msg = str()
2012-05-23 22:02:43 +00:00
2009-07-22 01:31:35 +00:00
if BOOST_LIB_DIR:
2015-10-12 20:38:15 +00:00
msg += '\nFound boost libs: %s' % BOOST_LIB_DIR
env['BOOST_LIBS'] = BOOST_LIB_DIR
2014-02-05 20:31:55 +00:00
elif not env['BOOST_LIBS']:
2015-10-12 20:38:15 +00:00
env['BOOST_LIBS'] = '/usr/' + env['LIBDIR_SCHEMA']
msg += '\nUsing default boost lib dir: %s' % env['BOOST_LIBS']
2014-02-05 20:31:55 +00:00
else:
2015-10-12 20:38:15 +00:00
msg += '\nUsing boost lib dir: %s' % env['BOOST_LIBS']
2012-05-23 22:02:43 +00:00
2009-07-22 01:31:35 +00:00
if BOOST_INCLUDE_DIR:
2015-10-12 20:38:15 +00:00
msg += '\nFound boost headers: %s' % BOOST_INCLUDE_DIR
env['BOOST_INCLUDES'] = BOOST_INCLUDE_DIR
2014-02-05 20:31:55 +00:00
elif not env['BOOST_INCLUDES']:
2015-10-12 20:38:15 +00:00
env['BOOST_INCLUDES'] = '/usr/include'
msg += '\nUsing default boost include dir: %s' % env['BOOST_INCLUDES']
2014-02-05 20:31:55 +00:00
else:
2015-10-12 20:38:15 +00:00
msg += '\nUsing boost include dir: %s' % env['BOOST_INCLUDES']
2012-05-23 22:02:43 +00:00
2009-07-01 23:52:51 +00:00
if not env['BOOST_TOOLKIT'] and not env['BOOST_ABI'] and not env['BOOST_VERSION']:
2015-10-12 20:38:15 +00:00
if BOOST_APPEND:
msg += '\nFound boost lib name extension: %s' % BOOST_APPEND
env['BOOST_APPEND'] = BOOST_APPEND
2009-07-01 23:52:51 +00:00
else:
2015-10-12 20:38:15 +00:00
# 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.
if len(append_params) > 1:
env['BOOST_APPEND'] = '-'.join(append_params)
msg += '\nFound boost lib name extension: %s' % env['BOOST_APPEND']
2009-07-01 23:52:51 +00:00
2015-02-20 20:56:08 +00:00
env.AppendUnique(CPPPATH = fix_path(env['BOOST_INCLUDES']))
env.AppendUnique(LIBPATH = fix_path(env['BOOST_LIBS']))
2009-07-01 23:52:51 +00:00
if env['COLOR_PRINT']:
2015-10-12 20:38:15 +00:00
msg = "\033[94m%s\033[0m" % (msg)
2009-07-01 23:52:51 +00:00
ret = context.Result(msg)
return ret
2009-02-17 20:31:04 +00: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:
2015-10-12 20:38:15 +00:00
version_n += int(v_arr[0])*100000
2009-02-17 20:31:04 +00:00
if len(v_arr) > 1:
2015-10-12 20:38:15 +00:00
version_n += int(v_arr[1])*100
2009-02-17 20:31:04 +00:00
if len(v_arr) > 2:
2015-10-12 20:38:15 +00:00
version_n += int(v_arr[2])
2012-05-23 22:02:43 +00:00
2009-02-17 20:31:04 +00:00
if not silent:
2015-10-12 20:38:15 +00:00
context.Message('Checking for Boost version >= %s... ' % (version))
2009-02-17 20:31:04 +00:00
ret = context.TryRun("""
2009-02-24 18:05:22 +00:00
#include <boost/version.hpp>
2012-05-23 22:02:43 +00:00
int main()
2009-02-24 18:05:22 +00:00
{
return BOOST_VERSION >= %d ? 0 : 1;
}
""" % version_n, '.cpp')[0]
2009-02-17 20:31:04 +00:00
if silent:
2015-10-12 20:38:15 +00:00
context.did_show_result=1
2009-02-17 20:31:04 +00:00
context.Result(ret)
return ret
2009-01-26 22:58:55 +00:00
2017-09-10 15:19:04 +00:00
def CheckIcuData(context, silent=False):
2017-11-16 10:59:55 +00:00
2017-09-10 15:19:04 +00:00
if not silent:
context.Message('Checking for ICU data directory...')
2018-06-27 21:09:42 +00:00
ret, out = context.TryRun("""
2017-09-10 15:19:04 +00:00
#include <unicode/putil.h>
#include <iostream>
int main() {
std::string result = u_getDataDirectory();
std::cout << result;
if (result.empty()) {
return -1;
}
return 0;
}
""", '.cpp')
if silent:
context.did_show_result=1
2018-06-27 21:09:42 +00:00
if ret:
value = out.strip()
context.Result('u_getDataDirectory returned %s' % value)
return value
2017-09-10 15:19:04 +00:00
else:
2018-06-28 12:10:03 +00:00
ret, value = config_command('icu-config --icudatadir')
2018-02-23 14:25:13 +00:00
if ret:
2018-06-27 18:48:29 +00:00
context.Result('icu-config returned %s' % value)
return value
2018-02-23 14:25:13 +00:00
else:
context.Result('Failed to detect (mapnik-config will have null value)')
return ''
2017-09-10 15:19:04 +00:00
def CheckGdalData(context, silent=False):
2019-08-19 15:35:45 +00:00
env = context.env
2017-09-10 15:19:04 +00:00
if not silent:
2018-06-27 21:09:42 +00:00
context.Message('Checking for GDAL data directory... ')
2019-08-19 15:35:45 +00:00
context.sconf.cached = False
ret, out = config_command(env['GDAL_CONFIG'], '--datadir')
2018-06-27 21:09:42 +00:00
value = out.strip()
2017-09-10 15:19:04 +00:00
if silent:
context.did_show_result=1
2018-06-27 21:09:42 +00:00
if ret:
2019-08-19 15:35:45 +00:00
context.Result('%s returned %s' % (env['GDAL_CONFIG'], value))
2017-09-10 15:19:04 +00:00
else:
context.Result('Failed to detect (mapnik-config will have null value)')
2018-06-27 21:09:42 +00:00
return value
2017-09-10 15:19:04 +00:00
2019-08-19 15:35:45 +00:00
2017-09-10 15:19:04 +00:00
def CheckProjData(context, silent=False):
2017-11-16 10:59:55 +00:00
2017-09-10 15:19:04 +00:00
if not silent:
context.Message('Checking for PROJ_LIB directory...')
2018-06-27 21:09:42 +00:00
ret, out = context.TryRun("""
2017-09-10 15:19:04 +00:00
// This is narly, could eventually be replaced using https://github.com/OSGeo/proj.4/pull/551]
#include <proj_api.h>
#include <iostream>
2018-02-20 13:24:06 +00:00
#include <cstring>
2017-09-10 15:19:04 +00:00
static void my_proj4_logger(void * user_data, int /*level*/, const char * msg)
{
std::string* posMsg = static_cast<std::string*>(user_data);
*posMsg += msg;
}
// https://github.com/OSGeo/gdal/blob/ddbf6d39aa4b005a77ca4f27c2d61a3214f336f8/gdal/alg/gdalapplyverticalshiftgrid.cpp#L616-L633
std::string find_proj_path(const char * pszFilename) {
std::string osMsg;
std::string osFilename;
projCtx ctx = pj_ctx_alloc();
pj_ctx_set_app_data(ctx, &osMsg);
pj_ctx_set_debug(ctx, PJ_LOG_DEBUG_MAJOR);
pj_ctx_set_logger(ctx, my_proj4_logger);
PAFile f = pj_open_lib(ctx, pszFilename, "rb");
if( f )
{
pj_ctx_fclose(ctx, f);
}
size_t nPos = osMsg.find("fopen(");
if( nPos != std::string::npos )
{
osFilename = osMsg.substr(nPos + strlen("fopen("));
nPos = osFilename.find(")");
if( nPos != std::string::npos )
osFilename = osFilename.substr(0, nPos);
}
pj_ctx_free(ctx);
return osFilename;
}
int main() {
std::string result = find_proj_path(" ");
std::cout << result;
if (result.empty()) {
return -1;
}
return 0;
}
""", '.cpp')
2018-06-27 21:09:42 +00:00
value = out.strip()
2017-09-10 15:19:04 +00:00
if silent:
context.did_show_result=1
2018-06-27 21:09:42 +00:00
if ret:
context.Result('pj_open_lib returned %s' % value)
2017-09-10 15:19:04 +00:00
else:
context.Result('Failed to detect (mapnik-config will have null value)')
2018-06-27 21:09:42 +00:00
return value
2017-09-10 15:19:04 +00:00
2013-05-16 15:28:38 +00:00
def CheckCairoHasFreetype(context, silent=False):
if not silent:
2015-10-12 20:38:15 +00:00
context.Message('Checking for cairo freetype font support ... ')
2013-05-16 16:59:21 +00:00
context.env.AppendUnique(CPPPATH=copy(env['CAIRO_CPPPATHS']))
2018-06-27 21:09:42 +00:00
ret, out = context.TryRun("""
2013-05-16 15:28:38 +00:00
2013-05-16 16:59:21 +00:00
#include <cairo-features.h>
2013-05-16 15:28:38 +00:00
int main()
{
#ifdef CAIRO_HAS_FT_FONT
return 0;
#else
return 1;
#endif
}
2018-06-27 21:09:42 +00:00
""", '.cpp')
2013-05-16 15:28:38 +00:00
if silent:
2015-10-12 20:38:15 +00:00
context.did_show_result=1
2013-05-16 15:28:38 +00:00
context.Result(ret)
2013-05-16 16:59:21 +00:00
for item in env['CAIRO_CPPPATHS']:
2015-10-12 20:38:15 +00:00
rm_path(item,'CPPPATH',context.env)
2013-05-16 15:28:38 +00:00
return ret
2014-12-16 21:03:51 +00:00
def CheckHasDlfcn(context, silent=False):
if not silent:
2015-10-12 20:38:15 +00:00
context.Message('Checking for dlfcn.h support ... ')
2014-12-16 21:03:51 +00:00
ret = context.TryCompile("""
#include <dlfcn.h>
int main()
{
return 0;
}
""", '.cpp')
if silent:
2015-10-12 20:38:15 +00:00
context.did_show_result=1
2014-12-16 21:03:51 +00:00
context.Result(ret)
return ret
2009-02-17 20:31:04 +00:00
def GetBoostLibVersion(context):
2018-06-27 21:09:42 +00:00
ret, out = context.TryRun("""
2009-02-24 18:05:22 +00:00
#include <boost/version.hpp>
#include <iostream>
2012-05-23 22:02:43 +00:00
int main()
2009-02-24 18:05:22 +00:00
{
std::cout << BOOST_LIB_VERSION << std::endl;
return 0;
}
""", '.cpp')
2009-02-17 20:31:04 +00:00
# hack to avoid printed output
context.did_show_result=1
2018-06-27 21:09:42 +00:00
context.Result(ret)
return out.strip()
2009-02-17 20:31:04 +00:00
2015-05-16 20:41:40 +00:00
def CheckBoostScopedEnum(context, silent=False):
if not silent:
2015-10-12 20:38:15 +00:00
context.Message('Checking whether Boost was compiled with C++11 scoped enums ... ')
2015-05-16 20:41:40 +00:00
ret = context.TryLink("""
#include <boost/filesystem.hpp>
int main()
{
boost::filesystem::path a, b;
boost::filesystem::copy_file(a, b);
return 0;
}
""", '.cpp')
if silent:
2015-10-12 20:38:15 +00:00
context.did_show_result=1
2015-05-16 20:41:40 +00:00
context.Result(ret)
return ret
2018-06-27 21:04:39 +00:00
def icu_at_least(context, min_version_str):
context.Message('Checking for ICU version >= %s... ' % min_version_str)
ret, out = context.TryRun("""
2010-11-30 01:25:54 +00:00
#include <unicode/uversion.h>
#include <iostream>
2012-05-23 22:02:43 +00:00
int main()
2010-11-30 01:25:54 +00:00
{
std::cout << U_ICU_VERSION_MAJOR_NUM << "." << U_ICU_VERSION_MINOR_NUM << std::endl;
return 0;
}
""", '.cpp')
2018-06-27 21:04:39 +00:00
try:
found_version_str = out.strip()
found_version = tuple(map(int, found_version_str.split('.')))
min_version = tuple(map(int, min_version_str.split('.')))
except:
context.Result('error (could not get version from unicode/uversion.h)')
2015-10-12 20:38:15 +00:00
return False
2012-05-23 22:02:43 +00:00
2018-06-27 21:04:39 +00:00
if found_version >= min_version:
context.Result('yes (found ICU %s)' % found_version_str)
2015-10-12 20:38:15 +00:00
return True
2012-05-23 22:02:43 +00:00
2018-06-27 21:04:39 +00:00
context.Result('no (found ICU %s)' % found_version_str)
2010-11-30 01:25:54 +00:00
return False
2011-02-28 20:00:56 +00:00
2015-02-09 14:00:41 +00:00
def harfbuzz_version(context):
2018-06-27 20:45:58 +00:00
context.Message('Checking for HarfBuzz version >= %s... ' % HARFBUZZ_MIN_VERSION_STRING)
ret, out = context.TryRun("""
2015-02-09 14:00:41 +00:00
#include "harfbuzz/hb.h"
#include <iostream>
2018-06-27 20:45:58 +00:00
#ifndef HB_VERSION_ATLEAST
#define HB_VERSION_ATLEAST(...) 0
#endif
2015-02-09 14:00:41 +00:00
int main()
{
std::cout << HB_VERSION_ATLEAST(%s, %s, %s) << ";" << HB_VERSION_STRING;
return 0;
}
2015-02-10 01:52:09 +00:00
""" % HARFBUZZ_MIN_VERSION, '.cpp')
2018-06-27 20:45:58 +00:00
if not ret:
context.Result('error (could not get version from hb.h)')
else:
ok_str, found_version_str = out.strip().split(';', 1)
ret = int(ok_str)
if ret:
context.Result('yes (found HarfBuzz %s)' % found_version_str)
else:
context.Result('no (found HarfBuzz %s)' % found_version_str)
return ret
2015-02-09 14:00:41 +00:00
2015-11-09 19:11:07 +00:00
def harfbuzz_with_freetype_support(context):
2018-06-27 20:45:58 +00:00
context.Message('Checking for HarfBuzz with freetype support... ')
ret, out = context.TryRun("""
2015-11-09 19:11:07 +00:00
#include "harfbuzz/hb-ft.h"
#include <iostream>
int main()
{
return 0;
}
""", '.cpp')
2018-06-27 20:45:58 +00:00
context.Result(ret)
return ret
2015-11-09 19:11:07 +00:00
2011-02-28 20:00:56 +00:00
def boost_regex_has_icu(context):
2019-11-15 13:55:09 +00:00
context.env.Append(LIBS='icui18n')
2012-03-27 23:14:01 +00:00
if env['RUNTIME_LINK'] == 'static':
2015-10-12 20:38:15 +00:00
# re-order icu libs to ensure linux linker is happy
for lib_name in ['icui18n',env['ICU_LIB_NAME'],'icudata']:
if lib_name in context.env['LIBS']:
context.env['LIBS'].remove(lib_name)
context.env.Append(LIBS=lib_name)
2018-06-27 21:09:42 +00:00
context.Message('Checking if boost_regex was built with ICU unicode support... ')
ret, out = context.TryRun("""
2011-02-28 20:00:56 +00:00
#include <boost/regex/icu.hpp>
#include <unicode/unistr.h>
2012-05-23 22:02:43 +00:00
int main()
2011-02-28 20:00:56 +00:00
{
2013-08-15 01:56:40 +00:00
U_NAMESPACE_QUALIFIER UnicodeString ustr;
2012-05-23 22:02:43 +00:00
try {
2015-10-12 20:38:15 +00:00
boost::u32regex pattern = boost::make_u32regex(ustr);
2011-03-12 02:46:52 +00:00
}
// an exception is fine, still indicates support is
// likely compiled into regex
catch (...) {
2015-10-12 20:38:15 +00:00
return 0;
2011-03-12 02:46:52 +00:00
}
2011-02-28 20:00:56 +00:00
return 0;
}
""", '.cpp')
2018-06-27 21:09:42 +00:00
context.Result(ret)
return ret
2011-04-02 18:25:23 +00:00
2013-06-02 21:15:02 +00:00
def sqlite_has_rtree(context, silent=False):
2011-04-18 23:45:24 +00:00
""" check an sqlite3 install has rtree support.
2012-05-23 22:02:43 +00:00
2011-04-18 23:45:24 +00:00
PRAGMA compile_options;
http://www.sqlite.org/c3ref/compileoption_get.html
"""
2012-05-23 22:02:43 +00:00
2018-06-27 21:09:42 +00:00
if not silent:
context.Message('Checking if SQLite supports RTREE... ')
ret, out = context.TryRun("""
2011-04-02 18:25:23 +00:00
2011-11-13 23:13:49 +00:00
#include <sqlite3.h>
#include <stdio.h>
2011-04-02 18:25:23 +00:00
2012-05-23 22:02:43 +00:00
int main()
2011-04-02 18:25:23 +00:00
{
2011-11-13 23:13:49 +00:00
sqlite3* db;
int rc;
rc = sqlite3_open(":memory:", &db);
if (rc != SQLITE_OK)
{
2015-10-12 20:38:15 +00:00
printf("error 1: %s\\n", sqlite3_errmsg(db));
2011-11-13 23:13:49 +00:00
}
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)
{
2015-10-12 20:38:15 +00:00
printf("error 2: %s\\n", sqlite3_errmsg(db));
sqlite3_close(db);
2011-11-13 23:13:49 +00:00
}
else
{
2015-10-12 20:38:15 +00:00
printf("yes, has rtree!\\n");
sqlite3_close(db);
return 0;
2011-11-13 23:13:49 +00:00
}
2012-05-23 22:02:43 +00:00
2011-11-13 23:13:49 +00:00
return -1;
2011-04-02 18:25:23 +00:00
}
2011-11-13 23:13:49 +00:00
""", '.c')
2013-06-02 21:15:02 +00:00
if silent:
2015-10-12 20:38:15 +00:00
context.did_show_result=1
2018-06-27 21:09:42 +00:00
context.Result(ret)
return ret
2012-05-23 22:02:43 +00:00
2020-09-10 16:50:21 +00:00
__cplusplus = {'14':'201402L', '17':'201703L'}
def supports_cxx_std (context, silent=False):
cplusplus_string = __cplusplus[env['CXX_STD']]
2018-06-27 21:09:42 +00:00
if not silent:
2020-09-10 16:50:21 +00:00
context.Message('Checking if compiler (%s) supports -std=c++%s flag... ' % (context.env.get('CXX','CXX'), env['CXX_STD']))
2018-06-27 21:09:42 +00:00
ret, out = context.TryRun("""
2013-10-14 23:03:01 +00:00
int main()
{
2020-09-10 16:50:21 +00:00
#if __cplusplus >= %s
2013-10-14 23:03:01 +00:00
return 0;
#else
return -1;
#endif
}
2020-09-10 16:50:21 +00:00
""" % cplusplus_string ,'.cpp')
2013-10-14 23:03:01 +00:00
if silent:
2015-10-12 20:38:15 +00:00
context.did_show_result=1
2018-06-27 21:09:42 +00:00
context.Result(ret)
return ret
2013-10-14 23:03:01 +00:00
2010-11-30 01:25:54 +00:00
conf_tests = { 'prioritize_paths' : prioritize_paths,
2015-10-12 20:38:15 +00:00
'CheckPKGConfig' : CheckPKGConfig,
'CheckPKG' : CheckPKG,
'CheckPKGVersion' : CheckPKGVersion,
'FindBoost' : FindBoost,
'CheckBoost' : CheckBoost,
2017-09-10 15:19:04 +00:00
'CheckIcuData' : CheckIcuData,
'CheckProjData' : CheckProjData,
'CheckGdalData' : CheckGdalData,
2015-10-12 20:38:15 +00:00
'CheckCairoHasFreetype' : CheckCairoHasFreetype,
'CheckHasDlfcn' : CheckHasDlfcn,
'GetBoostLibVersion' : GetBoostLibVersion,
'parse_config' : parse_config,
'parse_pg_config' : parse_pg_config,
'ogr_enabled' : ogr_enabled,
'get_pkg_lib' : get_pkg_lib,
2018-06-27 21:04:39 +00:00
'icu_at_least' : icu_at_least,
2015-10-12 20:38:15 +00:00
'harfbuzz_version' : harfbuzz_version,
2015-11-09 19:11:07 +00:00
'harfbuzz_with_freetype_support': harfbuzz_with_freetype_support,
2015-10-12 20:38:15 +00:00
'boost_regex_has_icu' : boost_regex_has_icu,
'sqlite_has_rtree' : sqlite_has_rtree,
2020-09-10 16:50:21 +00:00
'supports_cxx_std' : supports_cxx_std,
2015-10-12 20:38:15 +00:00
'CheckBoostScopedEnum' : CheckBoostScopedEnum,
}
2009-02-26 23:35:09 +00:00
2014-10-23 08:02:14 +00:00
def GetMapnikLibVersion():
ver = []
for line in open('include/mapnik/version.hpp').readlines():
2015-10-12 20:38:15 +00:00
if line.startswith('#define MAPNIK_MAJOR_VERSION'):
ver.append(line.split(' ')[2].strip())
if line.startswith('#define MAPNIK_MINOR_VERSION'):
ver.append(line.split(' ')[2].strip())
if line.startswith('#define MAPNIK_PATCH_VERSION'):
ver.append(line.split(' ')[2].strip())
2014-10-23 08:02:14 +00:00
version_string = ".".join(ver)
return version_string
2009-02-26 23:35:09 +00:00
2009-03-09 04:59:23 +00:00
if not preconfigured:
2009-02-26 23:35:09 +00:00
2009-03-09 04:59:23 +00:00
color_print(4,'Configuring build environment...')
2009-02-26 23:35:09 +00:00
2009-12-02 22:32:57 +00:00
if not env['FAST']:
2015-10-12 20:38:15 +00:00
SetCacheMode('force')
2012-05-23 22:02:43 +00:00
2009-03-09 04:59:23 +00:00
if env['USE_CONFIG']:
2015-10-12 20:38:15 +00:00
if not env['CONFIG'].endswith('.py'):
color_print(1,'SCons CONFIG file specified is not a python file, will not be read...')
else:
# 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)
2017-11-16 10:59:55 +00:00
optfile = open(conf, 'r')
2015-10-12 20:38:15 +00:00
#print optfile.read().replace("\n", " ").replace("'","").replace(" = ","=")
optfile.close()
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`
env = Environment(ENV=os.environ,options=opts)
init_environment(env)
env['USE_CONFIG'] = True
2009-03-09 04:59:23 +00:00
else:
2015-10-12 20:38:15 +00:00
color_print(4,'SCons USE_CONFIG specified as false, will not inherit variables python config file...')
2009-03-09 04:59:23 +00:00
2017-03-27 15:14:51 +00:00
2009-03-09 04:59:23 +00:00
conf = Configure(env, custom_tests = conf_tests)
2012-05-23 22:02:43 +00:00
2009-03-09 04:59:23 +00:00
if env['DEBUG']:
2015-10-12 20:38:15 +00:00
mode = 'debug mode'
2009-03-09 04:59:23 +00:00
else:
2015-10-12 20:38:15 +00:00
mode = 'release mode'
2012-05-23 22:02:43 +00:00
2016-03-03 22:19:12 +00:00
if env['COVERAGE']:
mode += ' (with coverage)'
2009-03-09 04:59:23 +00:00
env['PLATFORM'] = platform.uname()[0]
2010-01-07 17:14:54 +00:00
color_print(4,"Configuring on %s in *%s*..." % (env['PLATFORM'],mode))
2012-05-23 22:02:43 +00:00
2018-06-28 12:10:03 +00:00
ret, cxx_version = config_command(env['CXX'], '--version')
2018-06-27 18:48:29 +00:00
if ret:
color_print(5, "C++ compiler: %s" % cxx_version)
2018-04-30 04:08:36 +00:00
else:
2018-06-27 18:48:29 +00:00
color_print(5, "Could not detect C++ compiler")
2017-03-27 15:14:51 +00:00
2009-03-09 04:59:23 +00:00
env['MISSING_DEPS'] = []
env['SKIPPED_DEPS'] = []
2010-07-14 05:33:55 +00:00
env['HAS_CAIRO'] = False
2013-01-09 20:49:39 +00:00
env['CAIRO_LIBPATHS'] = []
2013-05-16 18:33:23 +00:00
env['CAIRO_ALL_LIBS'] = []
2013-01-09 20:49:39 +00:00
env['CAIRO_CPPPATHS'] = []
2010-07-14 05:33:55 +00:00
env['HAS_PYCAIRO'] = False
2015-02-03 02:59:29 +00:00
env['PYCAIRO_PATHS'] = []
2010-07-15 00:20:50 +00:00
env['HAS_LIBXML2'] = False
2011-08-11 21:11:11 +00:00
env['LIBMAPNIK_LIBS'] = []
2013-05-16 18:33:23 +00:00
env['LIBMAPNIK_LINKFLAGS'] = []
2011-08-29 18:52:35 +00:00
env['LIBMAPNIK_CPPATHS'] = []
2013-03-14 02:49:59 +00:00
env['LIBMAPNIK_DEFINES'] = []
2011-08-29 18:52:35 +00:00
env['LIBMAPNIK_CXXFLAGS'] = []
2011-08-12 20:01:09 +00:00
env['PLUGINS'] = PLUGINS
2011-08-29 18:52:35 +00:00
env['EXTRA_FREETYPE_LIBS'] = []
2011-11-15 18:23:10 +00:00
env['SQLITE_LINKFLAGS'] = []
2017-09-10 15:19:04 +00:00
env['QUERIED_PROJ_LIB'] = None
env['QUERIED_ICU_DATA'] = None
env['QUERIED_GDAL_DATA'] = None
2011-08-15 07:00:06 +00: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):
2015-10-12 20:38:15 +00:00
env['LIB_DIR_NAME'] = strip_first(env['LIB_DIR_NAME'],os.path.sep)
2012-05-23 22:02:43 +00:00
2011-08-15 07:00:06 +00:00
# base install location
2011-08-12 20:01:09 +00:00
env['MAPNIK_LIB_BASE'] = os.path.join(env['PREFIX'],env['LIBDIR_SCHEMA'])
2011-08-15 07:00:06 +00: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 20:01:09 +00:00
if env['SYSTEM_FONTS']:
2015-10-12 20:38:15 +00:00
env['MAPNIK_FONTS'] = os.path.normpath(env['SYSTEM_FONTS'])
2011-08-12 20:01:09 +00:00
else:
2015-10-12 20:38:15 +00:00
env['MAPNIK_FONTS'] = os.path.join(env['MAPNIK_LIB_DIR'],'fonts')
2012-05-23 22:02:43 +00:00
# install prefix is a pre-pended base location to
2011-08-15 07:00:06 +00: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
2015-02-20 20:56:08 +00:00
install_prefix = os.path.normpath(fix_path(env['DESTDIR'])) + fix_path(env['PREFIX'])
2011-08-15 07:00:06 +00:00
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']:
2015-10-12 20:38:15 +00:00
env['MAPNIK_FONTS_DEST'] = os.path.normpath(env['SYSTEM_FONTS'])
2011-08-15 07:00:06 +00:00
else:
2015-10-12 20:38:15 +00:00
env['MAPNIK_FONTS_DEST'] = os.path.join(env['MAPNIK_LIB_DIR_DEST'],'fonts')
2012-05-23 22:02:43 +00:00
2011-08-11 19:14:00 +00:00
if env['LINKING'] == 'static':
2014-06-09 20:55:56 +00:00
env['MAPNIK_LIB_NAME'] = '${LIBPREFIX}${MAPNIK_NAME}${LIBSUFFIX}'
2011-08-11 19:14:00 +00:00
else:
2014-06-09 20:55:56 +00:00
env['MAPNIK_LIB_NAME'] = '${SHLIBPREFIX}${MAPNIK_NAME}${SHLIBSUFFIX}'
2012-05-23 22:02:43 +00:00
2009-07-02 00:48:42 +00:00
if env['PKG_CONFIG_PATH']:
2015-10-12 20:38:15 +00:00
env['ENV']['PKG_CONFIG_PATH'] = fix_path(env['PKG_CONFIG_PATH'])
# otherwise this variable == os.environ["PKG_CONFIG_PATH"]
2011-10-13 21:19:21 +00:00
if env['PATH']:
2015-10-12 20:38:15 +00:00
env['ENV']['PATH'] = fix_path(env['PATH']) + ':' + env['ENV']['PATH']
2011-10-13 21:19:21 +00:00
2009-03-09 04:59:23 +00:00
if env['SYSTEM_FONTS']:
2015-10-12 20:38:15 +00:00
if not os.path.isdir(env['SYSTEM_FONTS']):
color_print(1,'Warning: Directory specified for SYSTEM_FONTS does not exist!')
2012-05-23 22:02:43 +00:00
2009-03-09 04:59:23 +00:00
# Set up for libraries and headers dependency checks
2014-10-23 06:51:44 +00:00
env['CPPPATH'] = ['#include']
2014-10-13 08:06:36 +00:00
env['LIBPATH'] = ['#src','#src/json','#src/wkt']
2012-05-23 22:02:43 +00:00
2012-06-13 21:10:15 +00:00
# set any custom cxxflags and ldflags to come first
2013-09-26 17:26:53 +00:00
if sys.platform == 'darwin' and not env['HOST']:
2020-09-10 16:50:21 +00:00
DEFAULT_CXX_CXXFLAGS += ' -stdlib=libc++'
DEFAULT_CXX_LINKFLAGS = ' -stdlib=libc++'
2013-03-14 02:49:59 +00:00
env.Append(CPPDEFINES = env['CUSTOM_DEFINES'])
2020-09-10 16:50:21 +00:00
env.Append(CXXFLAGS = "-std=c++%s %s" % (env['CXX_STD'], DEFAULT_CXX_CXXFLAGS))
2010-09-18 18:02:15 +00:00
env.Append(CXXFLAGS = env['CUSTOM_CXXFLAGS'])
2012-06-13 21:17:58 +00:00
env.Append(CFLAGS = env['CUSTOM_CFLAGS'])
2020-09-10 16:50:21 +00:00
env.Append(LINKFLAGS = DEFAULT_CXX_LINKFLAGS)
2019-08-18 21:01:11 +00:00
custom_ldflags = env.ParseFlags(env['CUSTOM_LDFLAGS'])
env.Append(LINKFLAGS = custom_ldflags.pop('LINKFLAGS'),
LIBS = custom_ldflags.pop('LIBS'))
env.AppendUnique(FRAMEWORKS = custom_ldflags.pop('FRAMEWORKS'),
LIBPATH = custom_ldflags.pop('LIBPATH'),
RPATH = custom_ldflags.pop('RPATH'))
2020-01-30 17:38:20 +00:00
# ParseFlags puts everything it does not recognize into CCFLAGS,
# but let's assume the user knows better: add those to LINKFLAGS.
# In order to prevent duplication of flags which ParseFlags puts
# into both CCFLAGS and LINKFLAGS, call AppendUnique.
env.AppendUnique(LINKFLAGS = custom_ldflags.pop('CCFLAGS'))
2019-08-18 21:01:11 +00:00
invalid_ldflags = {k:v for k,v in custom_ldflags.items() if v}
if invalid_ldflags:
color_print(3, 'Warning: CUSTOM_LDFLAGS contained some flags that SCons recognized as not for linker.')
color_print(3, 'The following flags will be ignored:')
for key, value in invalid_ldflags.items():
color_print(3, '\t%s = %r' % (key, value))
2011-02-28 20:00:56 +00:00
2011-08-15 07:00:06 +00:00
### platform specific bits
thread_suffix = 'mt'
if env['PLATFORM'] == 'FreeBSD':
2015-10-12 20:38:15 +00:00
thread_suffix = ''
env.Append(LIBS = 'pthread')
2011-08-15 07:00:06 +00:00
2015-10-16 20:34:53 +00:00
if env['MEMORY_MAPPED_FILE']:
env.Append(CPPDEFINES = '-DMAPNIK_MEMORY_MAPPED_FILE')
2013-09-20 03:51:49 +00:00
2011-08-15 07:00:06 +00: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']:
2015-10-12 20:38:15 +00:00
env.Append(CPPDEFINES = '-DU_HIDE_DRAFT_API')
env.Append(CPPDEFINES = '-DUDISABLE_RENAMING')
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-23 22:02:43 +00:00
2009-03-09 04:59:23 +00:00
# Adding the required prerequisite library directories to the include path for
# compiling and the library path for linking, respectively.
Improved support for international text
- Implementation by @herm for GSOC 2012 (http://mapnik.org/news/2012/10/06/gsoc2012-status9/)
- C++11 port, improvements, optimizations by @artemp
- Testing and integration with master by @springmeyer
- Thank you to all the support from @behdad along the way
- Thanks for help testing @toton6868, @stephankn, @nirvn, @mfrasca, @simonsonc and many others
Refs: #2073,#2070,#2038,#2037,#1953,#1820,#1819,#1714,#1634,#1547,#1532,#1319,#1208,#1154,#1146
2013-11-22 08:06:32 +00:00
for required in ('ICU', 'SQLITE', 'HB'):
2015-10-12 20:38:15 +00:00
inc_path = env['%s_INCLUDES' % required]
lib_path = env['%s_LIBS' % required]
env.AppendUnique(CPPPATH = fix_path(inc_path))
env.AppendUnique(LIBPATH = fix_path(lib_path))
2009-03-09 04:59:23 +00:00
2015-01-23 17:12:11 +00:00
REQUIRED_LIBSHEADERS = [
2015-10-12 20:38:15 +00:00
['z', 'zlib.h', True,'C'],
[env['ICU_LIB_NAME'],'unicode/unistr.h',True,'C++'],
['harfbuzz', 'harfbuzz/hb.h',True,'C++']
2015-01-23 17:12:11 +00:00
]
2019-09-01 08:25:46 +00:00
OPTIONAL_LIBSHEADERS = []
2015-01-23 17:12:11 +00:00
2018-05-03 15:03:25 +00:00
CHECK_PKG_CONFIG = conf.CheckPKGConfig('0.15.0')
2015-01-23 17:12:11 +00:00
if env.get('FREETYPE_LIBS') or env.get('FREETYPE_INCLUDES'):
2015-10-12 20:38:15 +00:00
REQUIRED_LIBSHEADERS.insert(0,['freetype','ft2build.h',True,'C'])
if env.get('FREETYPE_INCLUDES'):
inc_path = env['FREETYPE_INCLUDES']
env.AppendUnique(CPPPATH = fix_path(inc_path))
if env.get('FREETYPE_LIBS'):
lib_path = env['FREETYPE_LIBS']
env.AppendUnique(LIBPATH = fix_path(lib_path))
2018-05-03 15:03:25 +00:00
elif CHECK_PKG_CONFIG and conf.CheckPKG('freetype2'):
# Freetype 2.9+ doesn't use freetype-config and uses pkg-config instead
cmd = 'pkg-config freetype2 --libs --cflags'
if env['RUNTIME_LINK'] == 'static':
cmd += ' --static'
temp_env = Environment(ENV=os.environ)
try:
temp_env.ParseConfig(cmd)
for lib in temp_env['LIBS']:
env.AppendUnique(LIBPATH = fix_path(lib))
for inc in temp_env['CPPPATH']:
env.AppendUnique(CPPPATH = fix_path(inc))
except OSError as e:
pass
2015-01-23 17:12:11 +00:00
elif conf.parse_config('FREETYPE_CONFIG'):
2015-10-12 20:38:15 +00:00
# check if freetype links to bz2
if env['RUNTIME_LINK'] == 'static':
temp_env = env.Clone()
temp_env['LIBS'] = []
try:
# TODO - freetype-config accepts --static as of v2.5.3
temp_env.ParseConfig('%s --libs' % env['FREETYPE_CONFIG'])
if 'bz2' in temp_env['LIBS']:
env['EXTRA_FREETYPE_LIBS'].append('bz2')
2017-11-16 10:59:55 +00:00
except OSError as e:
2015-10-12 20:38:15 +00:00
pass
2011-08-29 18:52:35 +00:00
2019-09-01 08:25:46 +00:00
if env['XMLPARSER'] == 'libxml2':
2015-10-12 20:38:15 +00:00
if env.get('XML2_LIBS') or env.get('XML2_INCLUDES'):
OPTIONAL_LIBSHEADERS.insert(0,['libxml2','libxml/parser.h',True,'C'])
if env.get('XML2_INCLUDES'):
inc_path = env['XML2_INCLUDES']
env.AppendUnique(CPPPATH = fix_path(inc_path))
if env.get('XML2_LIBS'):
lib_path = env['XML2_LIBS']
env.AppendUnique(LIBPATH = fix_path(lib_path))
2020-01-21 14:13:09 +00:00
elif CHECK_PKG_CONFIG and conf.CheckPKG('libxml-2.0'):
# libxml2 2.9.10+ doesn't use xml2-config and uses pkg-config instead
cmd = 'pkg-config libxml-2.0 --libs --cflags'
temp_env = Environment(ENV=os.environ)
try:
temp_env.ParseConfig(cmd)
for inc in temp_env['CPPPATH']:
env.AppendUnique(CPPPATH = fix_path(inc))
env['HAS_LIBXML2'] = True
for lib in temp_env['LIBS']:
env.AppendUnique(LIBPATH = fix_path(lib))
env['HAS_LIBXML2'] = True
except OSError as e:
pass
2015-10-12 20:38:15 +00:00
elif conf.parse_config('XML2_CONFIG',checks='--cflags'):
env['HAS_LIBXML2'] = True
else:
env['MISSING_DEPS'].append('libxml2')
2010-01-30 00:59:36 +00:00
2015-03-05 00:25:15 +00:00
if not env['HOST']:
2015-10-12 20:38:15 +00:00
if conf.CheckHasDlfcn():
env.Append(CPPDEFINES = '-DMAPNIK_HAS_DLCFN')
else:
2019-09-01 09:54:23 +00:00
env['SKIPPED_DEPS'].append('dlfcn')
2014-12-16 21:03:51 +00:00
2010-06-03 19:50:27 +00:00
if env['JPEG']:
2015-10-12 20:38:15 +00:00
OPTIONAL_LIBSHEADERS.append(['jpeg', ['stdio.h', 'jpeglib.h'], False,'C','-DHAVE_JPEG'])
inc_path = env['%s_INCLUDES' % 'JPEG']
lib_path = env['%s_LIBS' % 'JPEG']
env.AppendUnique(CPPPATH = fix_path(inc_path))
env.AppendUnique(LIBPATH = fix_path(lib_path))
2010-06-03 19:50:27 +00:00
else:
2019-09-01 09:54:23 +00:00
env['SKIPPED_DEPS'].append('jpeg')
2010-06-03 19:50:27 +00:00
2013-01-29 07:21:27 +00:00
if env['PROJ']:
2015-10-12 20:38:15 +00:00
OPTIONAL_LIBSHEADERS.append(['proj', 'proj_api.h', False,'C','-DMAPNIK_USE_PROJ4'])
inc_path = env['%s_INCLUDES' % 'PROJ']
lib_path = env['%s_LIBS' % 'PROJ']
env.AppendUnique(CPPPATH = fix_path(inc_path))
env.AppendUnique(LIBPATH = fix_path(lib_path))
2013-01-29 07:21:27 +00:00
else:
2019-09-01 09:54:23 +00:00
env['SKIPPED_DEPS'].append('proj')
2013-01-29 07:21:27 +00:00
2013-01-29 07:17:37 +00:00
if env['PNG']:
2015-10-12 20:38:15 +00:00
OPTIONAL_LIBSHEADERS.append(['png', 'png.h', False,'C','-DHAVE_PNG'])
inc_path = env['%s_INCLUDES' % 'PNG']
lib_path = env['%s_LIBS' % 'PNG']
env.AppendUnique(CPPPATH = fix_path(inc_path))
env.AppendUnique(LIBPATH = fix_path(lib_path))
2013-01-29 07:17:37 +00:00
else:
2019-09-01 09:54:23 +00:00
env['SKIPPED_DEPS'].append('png')
2013-01-29 07:17:37 +00:00
2013-07-19 05:09:17 +00:00
if env['WEBP']:
2015-10-12 20:38:15 +00:00
OPTIONAL_LIBSHEADERS.append(['webp', 'webp/decode.h', False,'C','-DHAVE_WEBP'])
inc_path = env['%s_INCLUDES' % 'WEBP']
lib_path = env['%s_LIBS' % 'WEBP']
env.AppendUnique(CPPPATH = fix_path(inc_path))
env.AppendUnique(LIBPATH = fix_path(lib_path))
2013-07-19 05:09:17 +00:00
else:
2019-09-01 09:54:23 +00:00
env['SKIPPED_DEPS'].append('webp')
2013-07-19 05:09:17 +00:00
2013-01-29 07:17:37 +00:00
if env['TIFF']:
2015-10-12 20:38:15 +00:00
OPTIONAL_LIBSHEADERS.append(['tiff', 'tiff.h', False,'C','-DHAVE_TIFF'])
inc_path = env['%s_INCLUDES' % 'TIFF']
lib_path = env['%s_LIBS' % 'TIFF']
env.AppendUnique(CPPPATH = fix_path(inc_path))
env.AppendUnique(LIBPATH = fix_path(lib_path))
2013-01-29 07:17:37 +00:00
else:
2019-09-01 09:54:23 +00:00
env['SKIPPED_DEPS'].append('tiff')
2013-01-29 07:17:37 +00:00
2010-02-23 02:40:46 +00:00
# if requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests
if env['PRIORITIZE_LINKING']:
2017-11-23 10:30:35 +00:00
conf.prioritize_paths(silent=True)
2012-05-23 22:02:43 +00:00
2020-09-10 16:50:21 +00:00
# test for CXX_STD support, which is required
if not env['HOST'] and not conf.supports_cxx_std():
color_print(1,"C++ compiler does not support C++%s standard (-std=c++%s), which is required."
" Please upgrade your compiler" % (env['CXX_STD'], env['CXX_STD']))
2015-10-12 20:38:15 +00:00
Exit(1)
2013-10-14 23:03:01 +00:00
2013-03-25 18:19:51 +00:00
if not env['HOST']:
2015-10-12 20:38:15 +00:00
for libname, headers, required, lang in REQUIRED_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)
else:
if libname == env['ICU_LIB_NAME']:
if env['ICU_LIB_NAME'] not in env['MISSING_DEPS']:
2018-06-27 21:04:39 +00:00
if not conf.icu_at_least("4.0"):
2015-10-12 20:38:15 +00:00
# expression_string.cpp and map.cpp use fromUTF* function only available in >= ICU 4.2
env['MISSING_DEPS'].append(env['ICU_LIB_NAME'])
elif libname == 'harfbuzz':
if not conf.harfbuzz_version():
env['SKIPPED_DEPS'].append('harfbuzz-min-version')
2015-11-09 19:11:07 +00:00
if not conf.harfbuzz_with_freetype_support():
env['MISSING_DEPS'].append('harfbuzz-with-freetype-support')
2015-02-09 14:00:41 +00:00
2013-01-03 16:23:36 +00:00
if env['BIGINT']:
2015-10-12 20:38:15 +00:00
env.Append(CPPDEFINES = '-DBIGINT')
2013-01-03 16:23:36 +00:00
2009-07-01 23:52:51 +00:00
if env['THREADING'] == 'multi':
2015-10-12 20:38:15 +00:00
thread_flag = thread_suffix
2009-07-01 23:52:51 +00:00
else:
2015-10-12 20:38:15 +00:00
thread_flag = ''
2012-05-23 22:02:43 +00:00
2009-12-15 19:25:35 +00:00
conf.FindBoost(BOOST_SEARCH_PREFIXES,thread_flag)
2012-05-23 22:02:43 +00:00
2013-06-03 19:22:29 +00:00
has_boost_devel = True
2013-03-25 18:19:51 +00:00
if not env['HOST']:
2015-10-12 20:38:15 +00:00
if not conf.CheckHeader(header='boost/version.hpp',language='C++'):
env['MISSING_DEPS'].append('boost development headers')
has_boost_devel = False
2013-03-25 18:19:51 +00:00
2013-06-03 02:24:11 +00:00
if has_boost_devel:
2015-10-12 20:38:15 +00:00
if not env['HOST']:
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 requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests
if env['PRIORITIZE_LINKING']:
2017-11-23 10:30:35 +00:00
conf.prioritize_paths(silent=True)
2015-10-12 20:38:15 +00:00
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])
# Boost versions before 1.57 are broken when the system package and
# Mapnik are compiled against different standards. On Ubuntu 14.04
# using boost 1.54, it breaks scoped enums. It's a bit of a hack to
# just turn it off like this, but seems the only available work-
# around. See https://svn.boost.org/trac/boost/ticket/6779 for more
# details.
2016-04-21 16:04:38 +00:00
if not env['HOST']:
if not conf.CheckBoostScopedEnum():
2018-06-20 00:21:50 +00:00
boost_version = [int(x) for x in env.get('BOOST_LIB_VERSION_FROM_HEADER').split('_') if x]
2016-04-21 16:04:38 +00:00
if boost_version < [1, 51]:
env.Append(CXXFLAGS = '-DBOOST_NO_SCOPED_ENUMS')
elif boost_version < [1, 57]:
env.Append(CXXFLAGS = '-DBOOST_NO_CXX11_SCOPED_ENUMS')
2015-05-16 20:41:40 +00:00
2013-06-14 18:40:45 +00:00
if not env['HOST'] and env['ICU_LIB_NAME'] not in env['MISSING_DEPS']:
2015-10-12 20:38:15 +00:00
# http://lists.boost.org/Archives/boost/2009/03/150076.php
# we need libicui18n if using static boost libraries, so it is
# important to try this check with the library linked
if conf.boost_regex_has_icu():
# TODO - should avoid having this be globally defined...
env.Append(CPPDEFINES = '-DBOOST_REGEX_HAS_ICU')
else:
env['SKIPPED_DEPS'].append('boost_regex_icu')
for libname, headers, required, lang, define in OPTIONAL_LIBSHEADERS:
if not env['HOST']:
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)
else:
env.Append(CPPDEFINES = define)
else:
env.Append(CPPDEFINES = define)
2013-07-19 16:13:17 +00:00
2009-03-09 04:59:23 +00:00
env['REQUESTED_PLUGINS'] = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])]
2012-05-23 22:02:43 +00:00
2013-06-02 21:56:21 +00:00
SQLITE_HAS_RTREE = None
2013-06-14 18:40:45 +00:00
if env['HOST']:
2015-10-12 20:38:15 +00:00
SQLITE_HAS_RTREE = True
2013-06-14 18:40:45 +00:00
2017-09-10 15:19:04 +00:00
if not env['HOST']:
env['QUERIED_PROJ_LIB'] = conf.CheckProjData()
if os.environ.get('PROJ_LIB'):
env['QUERIED_PROJ_LIB'] = os.environ['PROJ_LIB']
color_print(4,'Detected PROJ_LIB in environ, using env value instead: %s' % os.environ['PROJ_LIB'] )
env['QUERIED_ICU_DATA'] = conf.CheckIcuData()
if os.environ.get('ICU_DATA'):
env['QUERIED_ICU_DATA'] = os.environ['ICU_DATA']
color_print(4,'Detected ICU_DATA in environ, using env value instead: %s' % os.environ['ICU_DATA'] )
env['QUERIED_GDAL_DATA'] = conf.CheckGdalData()
if os.environ.get('GDAL_DATA'):
env['QUERIED_GDAL_DATA'] = os.environ['GDAL_DATA']
color_print(4,'Detected GDAL_DATA in environ, using env value instead: %s' % os.environ['GDAL_DATA'] )
# now validate the paths actually exist
if env['QUERIED_PROJ_LIB'] and not os.path.exists(env['QUERIED_PROJ_LIB']):
color_print(1,'%s not detected on your system' % env['QUERIED_PROJ_LIB'] )
env['MISSING_DEPS'].append('PROJ_LIB')
if env['QUERIED_GDAL_DATA'] and not os.path.exists(env['QUERIED_GDAL_DATA']):
color_print(1,'%s not detected on your system' % env['QUERIED_GDAL_DATA'] )
env['MISSING_DEPS'].append('GDAL_DATA')
if env['QUERIED_ICU_DATA'] and not os.path.exists(env['QUERIED_ICU_DATA']):
color_print(1,'%s not detected on your system' % env['QUERIED_ICU_DATA'] )
env['MISSING_DEPS'].append('ICU_DATA')
2010-12-21 20:34:36 +00:00
if len(env['REQUESTED_PLUGINS']):
2015-10-12 20:38:15 +00:00
if env['HOST']:
for plugin in env['REQUESTED_PLUGINS']:
details = env['PLUGINS'][plugin]
if details['lib']:
env.AppendUnique(LIBS=details['lib'])
else:
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'):
conf.parse_config('GDAL_CONFIG',checks='--cflags')
libname = conf.get_pkg_lib('GDAL_CONFIG','gdal')
if libname:
if not conf.CheckLibWithHeader(libname, details['inc'], details['lang']):
env['SKIPPED_DEPS'].append('gdal')
if libname in env['LIBS']:
env['LIBS'].remove(libname)
else:
details['lib'] = libname
elif plugin == 'postgis' or plugin == 'pgraster':
if env.get('PG_LIBS') or env.get('PG_INCLUDES'):
libname = details['lib']
if env.get('PG_INCLUDES'):
inc_path = env['PG_INCLUDES']
env.AppendUnique(CPPPATH = fix_path(inc_path))
if env.get('PG_LIBS'):
lib_path = env['PG_LIBS']
env.AppendUnique(LIBPATH = fix_path(lib_path))
if not conf.CheckLibWithHeader(libname, details['inc'], details['lang']):
env['SKIPPED_DEPS'].append(libname)
if libname in env['LIBS']:
env['LIBS'].remove(libname)
else:
details['lib'] = libname
else:
conf.parse_pg_config('PG_CONFIG')
elif plugin == 'ogr':
if conf.ogr_enabled():
if conf.parse_config('GDAL_CONFIG',checks='--libs'):
conf.parse_config('GDAL_CONFIG',checks='--cflags')
libname = conf.get_pkg_lib('GDAL_CONFIG','ogr')
if libname:
if not conf.CheckLibWithHeader(libname, details['inc'], details['lang']):
if 'gdal' not in env['SKIPPED_DEPS']:
env['SKIPPED_DEPS'].append('gdal')
if libname in env['LIBS']:
env['LIBS'].remove(libname)
else:
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']]
libpath = env['%s_LIBS' % details['path']]
env.PrependUnique(CPPPATH = fix_path(incpath),delete_existing=True)
env.PrependUnique(LIBPATH = fix_path(libpath),delete_existing=True)
if not conf.CheckLibWithHeader(details['lib'], details['inc'], details['lang']):
env.Replace(**backup)
env['SKIPPED_DEPS'].append(details['lib'])
if plugin == 'sqlite':
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' and not env['PLATFORM'] == 'Darwin':
if CHECK_PKG_CONFIG and conf.CheckPKG('sqlite3'):
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)
2017-11-16 10:59:55 +00:00
except OSError as e:
2015-10-12 20:38:15 +00:00
for lib in ["sqlite3","dl","pthread"]:
if not lib in env['LIBS']:
env["SQLITE_LINKFLAGS"].append("lib")
env.Append(LIBS=lib)
else:
for lib in ["sqlite3","dl","pthread"]:
if not lib in env['LIBS']:
env["SQLITE_LINKFLAGS"].append("lib")
env.Append(LIBS=lib)
SQLITE_HAS_RTREE = conf.sqlite_has_rtree()
if not SQLITE_HAS_RTREE:
env.Replace(**sqlite_backup)
if details['lib'] in env['LIBS']:
env['LIBS'].remove(details['lib'])
env['SKIPPED_DEPS'].append('sqlite_rtree')
else:
env.Replace(**sqlite_backup)
elif details['lib'] and details['inc']:
if not conf.CheckLibWithHeader(details['lib'], details['inc'], details['lang']):
env['SKIPPED_DEPS'].append(details['lib'])
# 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(LIBPATH = '#src', delete_existing=True)
2013-06-14 18:40:45 +00:00
if not env['HOST']:
2015-10-12 20:38:15 +00:00
if env['PGSQL2SQLITE']:
if 'sqlite3' not in env['LIBS']:
env.AppendUnique(LIBS='sqlite3')
env.AppendUnique(CPPPATH = fix_path(env['SQLITE_INCLUDES']))
env.AppendUnique(LIBPATH = fix_path(env['SQLITE_LIBS']))
if 'pq' not in env['LIBS']:
if not conf.parse_pg_config('PG_CONFIG'):
env['PGSQL2SQLITE'] = False
if not SQLITE_HAS_RTREE:
env['SKIPPED_DEPS'].append('pgsql2sqlite_rtree')
env['PGSQL2SQLITE'] = False
2011-04-02 18:25:23 +00:00
2012-05-25 00:05:51 +00: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')
2016-05-09 09:42:46 +00:00
env.Prepend(CPPPATH = '#deps/mapbox/variant/include')
2016-06-27 08:44:52 +00:00
env.Prepend(CPPPATH = '#deps/mapbox/geometry/include')
2017-08-17 09:52:07 +00:00
env.Prepend(CPPPATH = '#deps/mapbox/protozero/include')
2017-09-29 11:31:03 +00:00
env.Prepend(CPPPATH = '#deps/mapbox/polylabel/include')
2013-01-11 01:20:34 +00:00
# prepend deps dir for auxillary headers
env.Prepend(CPPPATH = '#deps')
2010-09-19 18:29:22 +00:00
if env['CAIRO']:
2015-10-12 20:38:15 +00:00
if env['CAIRO_LIBS'] or env['CAIRO_INCLUDES']:
c_inc = env['CAIRO_INCLUDES']
if env['CAIRO_LIBS']:
env["CAIRO_LIBPATHS"].append(fix_path(env['CAIRO_LIBS']))
if not env['CAIRO_INCLUDES']:
c_inc = env['CAIRO_LIBS'].replace('lib','',1)
if c_inc:
c_inc = os.path.normpath(fix_path(env['CAIRO_INCLUDES']))
if c_inc.endswith('include'):
c_inc = os.path.dirname(c_inc)
env["CAIRO_CPPPATHS"].extend(
[
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'),
]
)
env["CAIRO_ALL_LIBS"] = ['cairo']
if env['RUNTIME_LINK'] == 'static':
2019-09-01 09:54:23 +00:00
env["CAIRO_ALL_LIBS"].append('pixman-1')
2015-10-12 20:38:15 +00:00
# todo - run actual checkLib?
env['HAS_CAIRO'] = True
else:
if not CHECK_PKG_CONFIG:
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')
else:
2017-11-22 13:56:20 +00:00
print ('Checking for cairo lib and include paths... ', end = '')
2015-10-12 20:38:15 +00:00
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']:
env["CAIRO_ALL_LIBS"].append(lib)
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
2017-11-16 10:59:55 +00:00
print ('yes')
except OSError as e:
2015-10-12 20:38:15 +00:00
color_print(1,'no')
env['SKIPPED_DEPS'].append('cairo')
color_print(1,'pkg-config reported: %s' % e)
2012-05-23 22:02:43 +00:00
2010-09-19 18:29:22 +00:00
else:
2015-10-12 20:38:15 +00:00
color_print(4,'Not building with cairo support, pass CAIRO=True to enable')
2012-05-23 22:02:43 +00:00
2013-05-16 15:28:38 +00:00
if not env['HOST'] and env['HAS_CAIRO']:
2015-10-12 20:38:15 +00:00
if not conf.CheckCairoHasFreetype():
env['SKIPPED_DEPS'].append('cairo')
env['HAS_CAIRO'] = False
2013-05-16 15:28:38 +00:00
2009-03-09 04:59:23 +00:00
#### End Config Stage for Required Dependencies ####
2012-05-23 22:02:43 +00:00
2009-03-09 04:59:23 +00:00
if env['MISSING_DEPS']:
2015-10-12 20:38:15 +00:00
# if required dependencies are missing, print warnings and then let SCons finish without building or saving local config
2019-09-01 09:54:23 +00:00
color_print(1,'\nExiting... the following required dependencies were not found:' + pretty_deps('\n - ', env['MISSING_DEPS']))
2015-10-12 20:38:15 +00:00
color_print(1,"\nSee '%s' for details on possible problems." % (fix_path(SCONS_LOCAL_LOG)))
if env['SKIPPED_DEPS']:
2019-09-01 09:54:23 +00:00
color_print(4,'\nAlso, these OPTIONAL dependencies were not found:' + pretty_deps('\n - ', env['SKIPPED_DEPS']))
2015-10-12 20:38:15 +00: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)
color_print(4," ie. $ python scons/scons.py BOOST_INCLUDES=/usr/local/include BOOST_LIBS=/usr/local/lib")
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')
color_print(4,'More info: https://github.com/mapnik/mapnik/wiki/Mapnik-Installation')
if not HELP_REQUESTED:
Exit(1)
2009-03-09 04:59:23 +00:00
else:
2015-10-12 20:38:15 +00:00
# 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'
os.unlink(SCONS_LOCAL_CONFIG)
else:
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)
else:
color_print(4,"Did not use user config file, no custom path variables will be saved...")
if env['SKIPPED_DEPS']:
2019-09-01 09:54:23 +00:00
color_print(4,'\nNote: will build without these OPTIONAL dependencies:' + pretty_deps('\n - ', env['SKIPPED_DEPS']))
2015-10-12 20:38:15 +00:00
print
# fetch the mapnik version header in order to set the
# ABI version used to build libmapnik.so on linux in src/build.py
abi = GetMapnikLibVersion()
2015-10-12 20:56:13 +00:00
abi_split = abi.split('.')
env['ABI_VERSION'] = abi_split
2015-10-12 20:38:15 +00:00
env['MAPNIK_VERSION_STRING'] = abi
2015-10-12 20:56:13 +00:00
env['MAPNIK_VERSION'] = str(int(abi_split[0])*100000+int(abi_split[1])*100+int(abi_split[2]))
2015-10-12 20:38:15 +00:00
# Common DEFINES.
env.Append(CPPDEFINES = '-D%s' % env['PLATFORM'].upper())
if env['THREADING'] == 'multi':
env.Append(CPPDEFINES = '-DMAPNIK_THREADSAFE')
if env['NO_ATEXIT']:
env.Append(CPPDEFINES = '-DMAPNIK_NO_ATEXIT')
2016-03-03 23:02:03 +00:00
if env['NO_DLCLOSE'] or env['COVERAGE']:
env.Append(CPPDEFINES = '-DMAPNIK_NO_DLCLOSE')
2017-11-09 18:07:26 +00:00
if env['ENABLE_GLIBC_WORKAROUND']:
env.Append(CPPDEFINES = '-DMAPNIK_ENABLE_GLIBC_WORKAROUND')
2015-10-12 20:38:15 +00:00
# Mac OSX (Darwin) special settings
if env['PLATFORM'] == 'Darwin':
pthread = ''
else:
pthread = '-pthread'
# Common debugging flags.
# http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html
debug_flags = ['-g', '-fno-omit-frame-pointer']
debug_defines = ['-DDEBUG', '-DMAPNIK_DEBUG']
ndebug_defines = ['-DNDEBUG']
2017-09-12 08:54:40 +00:00
# faster compile
# http://www.boost.org/doc/libs/1_47_0/libs/spirit/doc/html/spirit/what_s_new/spirit_2_5.html#spirit.what_s_new.spirit_2_5.breaking_changes
env.Append(CPPDEFINES = '-DBOOST_SPIRIT_NO_PREDEFINED_TERMINALS=1')
env.Append(CPPDEFINES = '-DBOOST_PHOENIX_NO_PREDEFINED_TERMINALS=1')
2015-10-12 20:38:15 +00:00
# c++11 support / https://github.com/mapnik/mapnik/issues/1683
# - upgrade to PHOENIX_V3 since that is needed for c++11 compile
env.Append(CPPDEFINES = '-DBOOST_SPIRIT_USE_PHOENIX_V3=1')
# Enable logging in debug mode (always) and release mode (when specified)
if env['DEFAULT_LOG_SEVERITY']:
if env['DEFAULT_LOG_SEVERITY'] not in severities:
2019-09-01 09:54:23 +00:00
severities_list = ', '.join("'%s'" % s for s in severities)
2015-10-12 20:38:15 +00:00
color_print(1,"Cannot set default logger severity to '%s', available options are %s." % (env['DEFAULT_LOG_SEVERITY'], severities_list))
Exit(1)
else:
log_severity = severities.index(env['DEFAULT_LOG_SEVERITY'])
else:
2019-09-01 09:54:23 +00:00
severities_list = ', '.join("'%s'" % s for s in severities)
2015-10-12 20:38:15 +00:00
color_print(1,"No logger severity specified, available options are %s." % severities_list)
Exit(1)
log_enabled = ['-DMAPNIK_LOG', '-DMAPNIK_DEFAULT_LOG_SEVERITY=%d' % log_severity]
if env['DEBUG']:
debug_defines += log_enabled
else:
if env['ENABLE_LOG']:
ndebug_defines += log_enabled
# Enable statistics reporting
if env['ENABLE_STATS']:
debug_defines.append('-DMAPNIK_STATS')
ndebug_defines.append('-DMAPNIK_STATS')
# Add rdynamic to allow using statics between application and plugins
# http://stackoverflow.com/questions/8623657/multiple-instances-of-singleton-across-shared-libraries-on-linux
if env['PLATFORM'] != 'Darwin' and env['CXX'] == 'g++':
env.MergeFlags('-rdynamic')
if env['DEBUG']:
env.Append(CXXFLAGS = debug_flags)
env.Append(CPPDEFINES = debug_defines)
else:
env.Append(CPPDEFINES = ndebug_defines)
# Common flags for g++/clang++ CXX compiler.
# TODO: clean up code more to make -Wextra -Wsign-compare -Wsign-conversion -Wconversion viable
2016-03-10 01:42:24 +00:00
# -Wfloat-equal -Wold-style-cast -Wexit-time-destructors -Wglobal-constructors -Wreserved-id-macro -Wheader-hygiene -Wmissing-noreturn
2017-03-27 15:14:51 +00:00
common_cxx_flags = '-fvisibility=hidden -fvisibility-inlines-hidden -Wall %s %s -ftemplate-depth-300 -Wsign-compare ' % (env['WARNING_CXXFLAGS'], pthread)
2015-10-12 20:38:15 +00:00
2015-12-01 18:59:45 +00:00
if 'clang++' in env['CXX']:
2017-10-11 14:26:39 +00:00
common_cxx_flags += ' -Wno-unsequenced -Wtautological-compare -Wheader-hygiene '
2015-10-12 20:38:15 +00:00
if env['DEBUG']:
env.Append(CXXFLAGS = common_cxx_flags + '-O0')
else:
env.Append(CXXFLAGS = common_cxx_flags + '-O%s' % (env['OPTIMIZATION']))
2015-12-28 03:40:10 +00:00
2015-10-12 20:38:15 +00:00
# if requested, sort LIBPATH and CPPPATH one last time before saving...
if env['PRIORITIZE_LINKING']:
2017-11-23 10:30:35 +00:00
conf.prioritize_paths(silent=True)
2015-10-12 20:38:15 +00:00
# finish config stage and pickle results
env = conf.Finish()
2017-11-16 10:59:55 +00:00
env_cache = open(SCONS_CONFIGURE_CACHE, 'wb')
2015-10-12 20:38:15 +00:00
pickle_dict = {}
for i in pickle_store:
pickle_dict[i] = env.get(i)
2017-11-16 10:59:55 +00:00
pickle.dump(pickle_dict, env_cache)
2015-10-12 20:38:15 +00:00
env_cache.close()
# fix up permissions on configure outputs
# this is hackish but avoids potential problems
# with a non-root configure following a root install
# that also triggered a re-configure
try:
2017-11-16 10:59:55 +00:00
os.chmod(SCONS_CONFIGURE_CACHE,0o666)
2015-10-12 20:38:15 +00:00
except: pass
try:
2017-11-16 10:59:55 +00:00
os.chmod(SCONS_LOCAL_CONFIG,0o666)
2015-10-12 20:38:15 +00:00
except: pass
try:
2017-11-16 10:59:55 +00:00
os.chmod('.sconsign.dblite',0o666)
2015-10-12 20:38:15 +00:00
except: pass
try:
2017-11-16 10:59:55 +00:00
os.chmod(SCONS_LOCAL_LOG,0o666)
2015-10-12 20:38:15 +00:00
except: pass
try:
for item in glob('%s/*' % SCONF_TEMP_DIR):
2017-11-16 10:59:55 +00:00
os.chmod(item,0o666)
2015-10-12 20:38:15 +00:00
except: pass
if 'configure' in command_line_args:
color_print(4,'\nConfigure completed: run `make` to build or `make install`')
if not HELP_REQUESTED:
Exit(0)
2009-02-26 23:35:09 +00:00
2009-03-30 16:52:31 +00:00
# autogenerate help on default/current SCons options
Help(opts.GenerateHelpText(env))
2009-02-26 23:35:09 +00:00
#### Builds ####
2011-03-01 16:36:45 +00:00
if not HELP_REQUESTED:
2010-07-18 20:39:05 +00:00
if 'uninstall' in COMMAND_LINE_TARGETS:
2015-10-12 20:38:15 +00:00
# dummy action in case there is nothing to uninstall, to avoid phony error..
env.Alias("uninstall", "")
2010-07-18 20:39:05 +00:00
env['create_uninstall_target'] = create_uninstall_target
2011-02-08 03:27:08 +00:00
if env['PKG_CONFIG_PATH']:
2015-10-12 20:38:15 +00:00
env['ENV']['PKG_CONFIG_PATH'] = fix_path(env['PKG_CONFIG_PATH'])
# otherwise this variable == os.environ["PKG_CONFIG_PATH"]
2012-05-23 22:02:43 +00:00
2011-10-13 21:19:21 +00:00
if env['PATH']:
2015-10-12 20:38:15 +00:00
env['ENV']['PATH'] = fix_path(env['PATH']) + ':' + env['ENV']['PATH']
2011-10-13 21:19:21 +00:00
if env['PATH_REMOVE']:
2015-10-12 20:38:15 +00:00
for p in env['PATH_REMOVE'].split(':'):
if p in env['ENV']['PATH']:
env['ENV']['PATH'].replace(p,'')
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 20:47:31 +00:00
if env['PATH_REPLACE']:
2015-10-12 20:38:15 +00:00
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)
replace_path('CAIRO_LIBPATHS',search,replace)
replace_path('CAIRO_CPPPATHS',search,replace)
2012-05-23 22:02:43 +00:00
2019-03-07 19:01:24 +00:00
# Adjust verbosity
if env['QUIET']:
env.Append(CXXCOMSTR = "Compiling $SOURCE")
env.Append(SHCXXCOMSTR = "Compiling shared $SOURCE")
env.Append(LINKCOMSTR = "Linking $TARGET")
env.Append(SHLINKCOMSTR = "Linking shared $TARGET")
2011-08-30 05:32:01 +00:00
# export env so it is available in build.py files
2010-01-05 23:51:10 +00:00
Export('env')
2012-05-23 22:02:43 +00:00
2011-11-11 23:37:10 +00:00
plugin_base = env.Clone()
2010-07-18 20:39:05 +00:00
2016-03-03 22:19:12 +00:00
if env['COVERAGE']:
plugin_base.Append(LINKFLAGS='--coverage')
plugin_base.Append(CXXFLAGS='--coverage')
2011-11-11 23:37:10 +00:00
Export('plugin_base')
2010-07-18 20:39:05 +00:00
2010-01-05 23:51:10 +00:00
if env['FAST']:
2015-10-12 20:38:15 +00:00
# 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-23 22:02:43 +00:00
2010-01-05 23:51:10 +00:00
# Build agg first, doesn't need anything special
2012-05-25 00:05:51 +00:00
if env['RUNTIME_LINK'] == 'shared':
2015-10-12 20:38:15 +00:00
SConscript('deps/agg/build.py')
2012-05-23 22:02:43 +00:00
2014-10-13 08:06:36 +00:00
# Build spirit grammars
SConscript('src/json/build.py')
SConscript('src/wkt/build.py')
2010-01-05 23:51:10 +00:00
# Build the core library
2011-08-30 05:32:01 +00:00
SConscript('src/build.py')
2012-05-23 22:02:43 +00:00
2012-08-28 00:58:49 +00:00
# Install headers
SConscript('include/build.py')
2010-01-05 23:51:10 +00:00
# Build the requested and able-to-be-compiled input plug-ins
GDAL_BUILT = False
OGR_BUILT = False
2015-07-27 23:21:31 +00:00
POSTGIS_BUILT = False
PGRASTER_BUILT = False
2013-05-23 00:54:32 +00:00
for plugin in env['PLUGINS']:
2015-10-12 20:38:15 +00: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)
elif 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)
# hack to avoid breaking on plugins with the same dep
if plugin == 'ogr': OGR_BUILT = True
if plugin == 'gdal': GDAL_BUILT = True
if plugin == 'postgis': POSTGIS_BUILT = True
if plugin == 'pgraster': PGRASTER_BUILT = True
if plugin == 'ogr' or plugin == 'gdal':
if GDAL_BUILT and OGR_BUILT:
env['LIBS'].remove(details['lib'])
elif plugin == 'postgis' or plugin == 'pgraster':
if POSTGIS_BUILT and PGRASTER_BUILT:
env['LIBS'].remove(details['lib'])
else:
env['LIBS'].remove(details['lib'])
elif not details['lib']:
if env['PLUGIN_LINKING'] == 'shared':
# build internal datasource input plugins
SConscript('plugins/input/%s/build.py' % plugin)
else:
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-23 22:02:43 +00:00
2011-08-12 20:01:09 +00:00
create_uninstall_target(env, env['MAPNIK_LIB_DIR_DEST'], False)
2011-08-15 07:00:06 +00:00
create_uninstall_target(env, env['MAPNIK_INPUT_PLUGINS_DEST'] , False)
2010-10-07 00:42:47 +00:00
if 'install' in COMMAND_LINE_TARGETS:
2015-10-12 20:38:15 +00: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
for plugin in PLUGINS.keys():
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':
color_print(4,"Notice: removing out of date plugin: '%s'" % plugin_path)
os.unlink(plugin_path)
2012-05-23 22:02:43 +00:00
2010-01-05 23:51:10 +00:00
# Build the c++ rundemo app if requested
2013-06-14 18:40:45 +00:00
if not env['HOST']:
2015-10-12 20:38:15 +00:00
if env['DEMO']:
SConscript('demo/c++/build.py')
2012-05-23 22:02:43 +00:00
2010-01-05 23:51:10 +00:00
# Build shapeindex and remove its dependency from the LIBS
2013-06-14 18:40:45 +00:00
if not env['HOST']:
2015-10-12 20:38:15 +00:00
if 'boost_program_options%s' % env['BOOST_APPEND'] in env['LIBS']:
if env['SHAPEINDEX']:
SConscript('utils/shapeindex/build.py')
if env['MAPNIK_INDEX']:
SConscript('utils/mapnik-index/build.py')
# Build the pgsql2psqlite app if requested
if env['PGSQL2SQLITE']:
SConscript('utils/pgsql2sqlite/build.py')
if env['SVG2PNG']:
SConscript('utils/svg2png/build.py')
if env['MAPNIK_RENDER']:
SConscript('utils/mapnik-render/build.py')
# devtools not ready for public
#SConscript('utils/ogrindex/build.py')
env['LIBS'].remove('boost_program_options%s' % env['BOOST_APPEND'])
else :
color_print(1,"WARNING: Cannot find boost_program_options. 'shapeindex' and other command line programs will not be available")
2012-05-23 22:02:43 +00:00
2010-01-05 23:51:10 +00:00
# Configure fonts and if requested install the bundled DejaVu fonts
2011-08-30 05:32:01 +00:00
SConscript('fonts/build.py')
2012-05-23 22:02:43 +00:00
2010-07-15 23:09:33 +00:00
# build C++ tests
2015-04-25 20:08:12 +00:00
SConscript('test/build.py')
2012-05-23 22:02:43 +00:00
2013-05-16 01:19:49 +00:00
if env['BENCHMARK']:
2015-10-12 20:38:15 +00:00
SConscript('benchmark/build.py')
2013-01-09 03:07:11 +00:00
2015-05-04 07:28:28 +00:00
if os.path.exists('./bindings/python/build.py'):
2015-10-12 20:38:15 +00:00
SConscript('./bindings/python/build.py')
2015-05-04 07:28:28 +00:00
2014-10-23 06:46:33 +00:00
# install mapnik-config script
SConscript('utils/mapnik-config/build.py')
2010-07-22 22:14:19 +00:00
# write the viewer.ini file
2015-05-16 20:41:40 +00:00
SConscript('demo/viewer/build.py')