2005-06-17 12:40:51 +00:00
|
|
|
#
|
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
|
|
|
#
|
2006-03-31 10:32:02 +00:00
|
|
|
# Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
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
|
2006-01-31 23:18:24 +00:00
|
|
|
#
|
2005-06-17 12:40:51 +00:00
|
|
|
# $Id$
|
2005-06-14 15:06:59 +00:00
|
|
|
|
2006-03-31 10:32:02 +00:00
|
|
|
|
2006-09-06 09:14:41 +00:00
|
|
|
import os, sys, platform
|
2006-01-31 23:18:24 +00:00
|
|
|
|
2006-09-06 09:14:41 +00:00
|
|
|
if platform.uname()[4] == 'x86_64':
|
2006-10-04 11:22:18 +00:00
|
|
|
LIBDIR_SCHEMA='lib64'
|
|
|
|
else:
|
|
|
|
LIBDIR_SCHEMA='lib'
|
2006-09-06 09:14:41 +00:00
|
|
|
|
2007-09-25 18:47:12 +00:00
|
|
|
opts = Options('config.py')
|
2006-01-31 23:18:24 +00:00
|
|
|
opts.Add('PREFIX', 'The install path "prefix"', '/usr/local')
|
|
|
|
opts.Add(PathOption('BOOST_INCLUDES', 'Search path for boost include files', '/usr/include'))
|
2006-10-04 11:22:18 +00:00
|
|
|
opts.Add(PathOption('BOOST_LIBS', 'Search path for boost library files', '/usr/' + LIBDIR_SCHEMA))
|
2007-01-17 11:59:41 +00:00
|
|
|
opts.Add('BOOST_TOOLKIT','Specify boost toolkit e.g. gcc41.','',False)
|
2007-08-28 10:12:38 +00:00
|
|
|
opts.Add(('FREETYPE_CONFIG', 'The path to the freetype-config executable.', 'freetype-config'))
|
2007-09-25 18:47:12 +00:00
|
|
|
opts.Add(('XML2_CONFIG', 'The path to the xml2-config executable.', 'xml2-config'))
|
2006-12-17 11:56:57 +00:00
|
|
|
opts.Add(PathOption('FRIBIDI_INCLUDES', 'Search path for fribidi include files', '/usr/include'))
|
|
|
|
opts.Add(PathOption('FRIBIDI_LIBS','Search path for fribidi include files','/usr/' + LIBDIR_SCHEMA))
|
2006-01-31 23:18:24 +00:00
|
|
|
opts.Add(PathOption('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include'))
|
2006-10-04 11:22:18 +00:00
|
|
|
opts.Add(PathOption('PNG_LIBS','Search path for libpng include files','/usr/' + LIBDIR_SCHEMA))
|
2006-01-31 23:18:24 +00:00
|
|
|
opts.Add(PathOption('JPEG_INCLUDES', 'Search path for libjpeg include files', '/usr/include'))
|
2006-10-04 11:22:18 +00:00
|
|
|
opts.Add(PathOption('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/' + LIBDIR_SCHEMA))
|
2006-01-31 23:18:24 +00:00
|
|
|
opts.Add(PathOption('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include'))
|
2006-10-04 11:22:18 +00:00
|
|
|
opts.Add(PathOption('TIFF_LIBS', 'Search path for libtiff library files', '/usr/' + LIBDIR_SCHEMA))
|
2006-01-31 23:18:24 +00:00
|
|
|
opts.Add(PathOption('PGSQL_INCLUDES', 'Search path for PostgreSQL include files', '/usr/include'))
|
2006-10-04 11:22:18 +00:00
|
|
|
opts.Add(PathOption('PGSQL_LIBS', 'Search path for PostgreSQL library files', '/usr/' + LIBDIR_SCHEMA))
|
2006-03-26 22:36:55 +00:00
|
|
|
opts.Add(PathOption('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/local/include'))
|
2007-04-25 19:18:44 +00:00
|
|
|
opts.Add(PathOption('PROJ_LIBS', 'Search path for PROJ.4 library files', '/usr/local/' + LIBDIR_SCHEMA))
|
2007-10-05 11:27:00 +00:00
|
|
|
opts.Add(PathOption('GDAL_INCLUDES', 'Search path for GDAL include files', '/usr/include'))
|
2007-05-20 20:19:04 +00:00
|
|
|
opts.Add(PathOption('GDAL_LIBS', 'Search path for GDAL library files', '/usr/' + LIBDIR_SCHEMA))
|
2007-04-25 19:18:44 +00:00
|
|
|
opts.Add(PathOption('GIGABASE_INCLUDES', 'Search path for Gigabase include files', '/usr/local/include'))
|
|
|
|
opts.Add(PathOption('GIGABASE_LIBS', 'Search path for Gigabase library files', '/usr/local/' + LIBDIR_SCHEMA))
|
2006-02-05 21:01:54 +00:00
|
|
|
opts.Add(PathOption('PYTHON','Python executable', sys.executable))
|
2007-04-25 19:18:44 +00:00
|
|
|
opts.Add(ListOption('INPUT_PLUGINS','Input drivers to include','all',['postgis','shape','raster','gdal','gigabase']))
|
2006-01-31 23:18:24 +00:00
|
|
|
opts.Add(ListOption('BINDINGS','Language bindings to build','all',['python']))
|
2007-09-16 11:23:51 +00:00
|
|
|
opts.Add(BoolOption('DEBUG', 'Compile a debug version of mapnik', 'False'))
|
2006-12-17 12:05:47 +00:00
|
|
|
opts.Add('DESTDIR', 'The root directory to install into. Useful mainly for binary package building', '/')
|
2007-09-16 11:23:51 +00:00
|
|
|
opts.Add(BoolOption('BIDI', 'BIDI support', 'False'))
|
2007-03-22 10:54:44 +00:00
|
|
|
opts.Add(EnumOption('THREADING','Set threading support','multi', ['multi','single']))
|
2007-09-25 18:47:12 +00:00
|
|
|
opts.Add(EnumOption('XMLPARSER','Set xml parser ','tinyxml', ['tinyxml','spirit','libxml2']))
|
2005-06-14 15:06:59 +00:00
|
|
|
|
2006-01-31 23:18:24 +00:00
|
|
|
env = Environment(ENV=os.environ, options=opts)
|
2007-03-22 10:54:44 +00:00
|
|
|
|
2006-10-04 11:22:18 +00:00
|
|
|
env['LIBDIR_SCHEMA'] = LIBDIR_SCHEMA
|
2007-03-16 10:11:37 +00:00
|
|
|
env['PLATFORM'] = platform.uname()[0]
|
|
|
|
print "Building on %s ..." % env['PLATFORM']
|
2006-01-31 23:18:24 +00:00
|
|
|
Help(opts.GenerateHelpText(env))
|
2005-06-14 15:06:59 +00:00
|
|
|
|
2006-01-31 23:18:24 +00:00
|
|
|
conf = Configure(env)
|
2005-06-14 15:06:59 +00:00
|
|
|
|
2006-01-31 23:18:24 +00:00
|
|
|
# Libraries and headers dependency checks
|
2005-06-14 15:06:59 +00:00
|
|
|
|
2006-10-27 22:13:13 +00:00
|
|
|
env['CPPPATH'] = ['#agg/include', '#tinyxml', '#include', '#']
|
2005-06-14 15:06:59 +00:00
|
|
|
|
2006-10-16 13:44:52 +00:00
|
|
|
for path in [env['BOOST_INCLUDES'],
|
|
|
|
env['PNG_INCLUDES'],
|
|
|
|
env['JPEG_INCLUDES'],
|
|
|
|
env['TIFF_INCLUDES'],
|
|
|
|
env['PGSQL_INCLUDES'],
|
2007-04-25 19:18:44 +00:00
|
|
|
env['PROJ_INCLUDES'],
|
|
|
|
env['GDAL_INCLUDES'],
|
|
|
|
env['GIGABASE_INCLUDES']] :
|
2006-01-31 23:18:24 +00:00
|
|
|
if path not in env['CPPPATH']: env['CPPPATH'].append(path)
|
2005-06-14 15:06:59 +00:00
|
|
|
|
2006-01-31 23:18:24 +00:00
|
|
|
env['LIBPATH'] = ['#agg', '#src']
|
2005-06-14 15:06:59 +00:00
|
|
|
|
2006-10-16 13:44:52 +00:00
|
|
|
for path in [env['BOOST_LIBS'],
|
|
|
|
env['PNG_LIBS'],
|
|
|
|
env['JPEG_LIBS'],
|
|
|
|
env['TIFF_LIBS'],
|
|
|
|
env['PGSQL_LIBS'],
|
2007-04-25 19:18:44 +00:00
|
|
|
env['PROJ_LIBS'],
|
|
|
|
env['GDAL_LIBS'],
|
|
|
|
env['GIGABASE_LIBS']]:
|
2006-01-31 23:18:24 +00:00
|
|
|
if path not in env['LIBPATH']: env['LIBPATH'].append(path)
|
2006-10-16 13:44:52 +00:00
|
|
|
|
2006-02-26 21:47:35 +00:00
|
|
|
env.ParseConfig(env['FREETYPE_CONFIG'] + ' --libs --cflags')
|
|
|
|
|
2006-12-17 11:56:57 +00:00
|
|
|
if env['BIDI']:
|
|
|
|
env.Append(CXXFLAGS = '-DUSE_FRIBIDI')
|
|
|
|
if env['FRIBIDI_INCLUDES'] not in env['CPPPATH']:
|
|
|
|
env['CPPPATH'].append(env['FRIBIDI_INCLUDES'])
|
|
|
|
if env['FRIBIDI_LIBS'] not in env['LIBPATH']:
|
2007-09-16 11:23:51 +00:00
|
|
|
env['LIBPATH'].append(env['FRIBIDI_LIBS'])
|
2006-12-17 11:56:57 +00:00
|
|
|
env['LIBS'].append('fribidi')
|
|
|
|
|
2007-09-16 11:23:51 +00:00
|
|
|
if env['XMLPARSER'] == 'tinyxml':
|
|
|
|
env.Append(CXXFLAGS = '-DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL')
|
2007-09-25 18:47:12 +00:00
|
|
|
elif env['XMLPARSER'] == 'libxml2':
|
|
|
|
env.ParseConfig(env['XML2_CONFIG'] + ' --libs --cflags')
|
|
|
|
env.Append(CXXFLAGS = '-DHAVE_LIBXML2');
|
2007-09-16 11:23:51 +00:00
|
|
|
|
2006-01-31 23:18:24 +00:00
|
|
|
C_LIBSHEADERS = [
|
2006-10-03 08:37:34 +00:00
|
|
|
['m', 'math.h', True],
|
2006-01-31 23:18:24 +00:00
|
|
|
['ltdl', 'ltdl.h', True],
|
|
|
|
['png', 'png.h', True],
|
|
|
|
['tiff', 'tiff.h', True],
|
|
|
|
['z', 'zlib.h', True],
|
2006-02-26 21:47:35 +00:00
|
|
|
['jpeg', ['stdio.h', 'jpeglib.h'], True],
|
2006-10-16 13:44:52 +00:00
|
|
|
['proj', 'proj_api.h', True],
|
|
|
|
['pq', 'libpq-fe.h', False]
|
2006-01-31 23:18:24 +00:00
|
|
|
]
|
2005-06-14 15:06:59 +00:00
|
|
|
|
2007-04-25 19:18:44 +00:00
|
|
|
CXX_LIBSHEADERS = [
|
|
|
|
['gdal', 'gdal_priv.h',False],
|
|
|
|
['gigabase_r','gigabase/gigabase.h',False]
|
|
|
|
]
|
|
|
|
|
2006-12-17 11:56:57 +00:00
|
|
|
if env['BIDI'] : C_LIBSHEADERS.append(['fribidi','fribidi/fribidi.h',True])
|
|
|
|
|
2006-01-31 23:18:24 +00:00
|
|
|
BOOST_LIBSHEADERS = [
|
|
|
|
['thread', 'boost/thread/mutex.hpp', True],
|
2007-10-05 11:29:55 +00:00
|
|
|
# ['system', 'boost/system/system_error.hpp', True], # uncomment this on Darwin + boost_1_35
|
2007-01-23 22:49:09 +00:00
|
|
|
['filesystem', 'boost/filesystem/operations.hpp', True],
|
2006-01-31 23:18:24 +00:00
|
|
|
['regex', 'boost/regex.hpp', True],
|
|
|
|
['program_options', 'boost/program_options.hpp', False]
|
|
|
|
]
|
|
|
|
|
|
|
|
for libinfo in C_LIBSHEADERS:
|
|
|
|
if not conf.CheckLibWithHeader(libinfo[0], libinfo[1], 'C') and libinfo[2]:
|
|
|
|
print 'Could not find header or shared library for %s, exiting!' % libinfo[0]
|
|
|
|
Exit(1)
|
|
|
|
|
2007-04-25 19:18:44 +00:00
|
|
|
for libinfo in CXX_LIBSHEADERS:
|
|
|
|
if not conf.CheckLibWithHeader(libinfo[0], libinfo[1], 'C++') and libinfo[2]:
|
|
|
|
print 'Could not find header or shared library for %s, exiting!' % libinfo[0]
|
|
|
|
Exit(1)
|
2007-01-17 11:59:41 +00:00
|
|
|
|
2007-03-16 12:09:58 +00:00
|
|
|
if len(env['BOOST_TOOLKIT']):
|
2007-03-22 10:54:44 +00:00
|
|
|
env['BOOST_APPEND'] = '-%s' % env['BOOST_TOOLKIT']
|
2007-03-16 12:09:58 +00:00
|
|
|
else:
|
|
|
|
env['BOOST_APPEND']=''
|
|
|
|
|
2006-02-14 23:59:53 +00:00
|
|
|
for count, libinfo in enumerate(BOOST_LIBSHEADERS):
|
2007-03-22 10:54:44 +00:00
|
|
|
if env['THREADING'] == 'multi' :
|
|
|
|
if not conf.CheckLibWithHeader('boost_%s%s-mt' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++') and libinfo[2] :
|
2006-01-31 23:18:24 +00:00
|
|
|
print 'Could not find header or shared library for boost %s, exiting!' % libinfo[0]
|
|
|
|
Exit(1)
|
2007-03-22 10:54:44 +00:00
|
|
|
elif not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0], env['BOOST_APPEND']), libinfo[1], 'C++') :
|
|
|
|
print 'Could not find header or shared library for boost %s, exiting!' % libinfo[0]
|
|
|
|
Exit(1)
|
|
|
|
|
2006-02-05 22:03:43 +00:00
|
|
|
Export('env')
|
|
|
|
|
|
|
|
inputplugins = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])]
|
|
|
|
|
|
|
|
bindings = [ binding.strip() for binding in Split(env['BINDINGS'])]
|
|
|
|
|
2007-03-16 10:11:37 +00:00
|
|
|
|
|
|
|
# Build agg first, doesn't need anything special
|
|
|
|
|
|
|
|
SConscript('agg/SConscript')
|
|
|
|
|
|
|
|
# Build the core library
|
|
|
|
|
|
|
|
SConscript('src/SConscript')
|
|
|
|
|
|
|
|
# Build shapeindex and remove its dependency from the LIBS
|
|
|
|
|
|
|
|
if 'boost_program_options%s-mt' % env['BOOST_APPEND'] in env['LIBS']:
|
|
|
|
SConscript('utils/shapeindex/SConscript')
|
|
|
|
env['LIBS'].remove('boost_program_options%s-mt' % env['BOOST_APPEND'])
|
|
|
|
|
|
|
|
# Build the input plug-ins
|
|
|
|
|
|
|
|
if 'postgis' in inputplugins and 'pq' in env['LIBS']:
|
|
|
|
SConscript('plugins/input/postgis/SConscript')
|
|
|
|
env['LIBS'].remove('pq')
|
|
|
|
|
|
|
|
if 'shape' in inputplugins:
|
|
|
|
SConscript('plugins/input/shape/SConscript')
|
|
|
|
|
|
|
|
if 'raster' in inputplugins:
|
|
|
|
SConscript('plugins/input/raster/SConscript')
|
|
|
|
|
2007-04-25 19:18:44 +00:00
|
|
|
if 'gdal' in inputplugins and 'gdal' in env['LIBS']:
|
|
|
|
SConscript('plugins/input/gdal/SConscript')
|
|
|
|
|
|
|
|
if 'gigabase' in inputplugins and 'gigabase_r' in env['LIBS']:
|
|
|
|
SConscript('plugins/input/gigabase/SConscript')
|
|
|
|
|
2006-01-31 23:18:24 +00:00
|
|
|
# Check out the Python situation
|
2005-06-14 15:06:59 +00:00
|
|
|
|
2006-01-31 23:18:24 +00:00
|
|
|
if 'python' in env['BINDINGS']:
|
|
|
|
if not os.access(env['PYTHON'], os.X_OK):
|
2006-02-05 22:03:43 +00:00
|
|
|
print "Cannot run python interpreter at '%s', make sure that you have the permissions to execute it." % env['PYTHON']
|
2006-01-31 23:18:24 +00:00
|
|
|
Exit(1)
|
2005-06-14 15:06:59 +00:00
|
|
|
|
2006-01-31 23:18:24 +00:00
|
|
|
env['PYTHON_PREFIX'] = os.popen("%s -c 'import sys; print sys.prefix'" % env['PYTHON']).read().strip()
|
|
|
|
env['PYTHON_VERSION'] = os.popen("%s -c 'import sys; print sys.version'" % env['PYTHON']).read()[0:3]
|
2005-06-14 15:06:59 +00:00
|
|
|
|
2006-01-31 23:18:24 +00:00
|
|
|
print 'Bindings Python version... %s' % env['PYTHON_VERSION']
|
2005-06-14 15:06:59 +00:00
|
|
|
|
2006-01-31 23:18:24 +00:00
|
|
|
majver, minver = env['PYTHON_VERSION'].split('.')
|
|
|
|
|
2006-02-20 01:17:04 +00:00
|
|
|
if (int(majver), int(minver)) < (2, 2):
|
2006-01-31 23:18:24 +00:00
|
|
|
print "Python version 2.2 or greater required"
|
|
|
|
Exit(1)
|
|
|
|
|
|
|
|
print 'Python %s prefix... %s' % (env['PYTHON_VERSION'], env['PYTHON_PREFIX'])
|
|
|
|
|
2006-02-05 22:03:43 +00:00
|
|
|
SConscript('bindings/python/SConscript')
|
|
|
|
|
2006-10-16 13:44:52 +00:00
|
|
|
|
2006-01-31 23:18:24 +00:00
|
|
|
env = conf.Finish()
|
|
|
|
|
|
|
|
# Setup the c++ args for our own codebase
|
2007-03-16 10:20:52 +00:00
|
|
|
if env['PLATFORM'] == 'Darwin': pthread = ''
|
|
|
|
else: pthread = '-pthread'
|
2006-01-31 23:18:24 +00:00
|
|
|
|
2007-10-05 11:27:00 +00:00
|
|
|
common_cxx_flags = '-ansi -Wall %s -ftemplate-depth-100 -D%s -DBOOST_SPIRIT_THREADSAFE ' % (pthread, env['PLATFORM'].upper());
|
2007-09-25 18:47:12 +00:00
|
|
|
|
2006-02-05 21:01:54 +00:00
|
|
|
if env['DEBUG']:
|
2007-09-25 18:47:12 +00:00
|
|
|
env.Append(CXXFLAGS = common_cxx_flags + '-O0 -fno-inline -g -DDEBUG -DMAPNIK_DEBUG')
|
2006-01-31 23:18:24 +00:00
|
|
|
else:
|
2007-09-25 18:47:12 +00:00
|
|
|
env.Append(CXXFLAGS = common_cxx_flags + '-O2 -finline-functions -Wno-inline -DNDEBUG')
|
2006-03-03 00:18:08 +00:00
|
|
|
|
|
|
|
# Install some free default fonts
|
|
|
|
|
|
|
|
SConscript('fonts/SConscript')
|
2007-08-28 10:12:38 +00:00
|
|
|
|