new build system
This commit is contained in:
parent
96981eb3a9
commit
e7119730a3
1 changed files with 125 additions and 77 deletions
202
SConstruct
202
SConstruct
|
@ -1,110 +1,158 @@
|
||||||
# This file is part of Mapnik (c++ mapping toolkit)
|
# This file is part of Mapnik (c++ mapping toolkit)
|
||||||
# Copyright (C) 2005 Artem Pavlenko
|
# Copyright (C) 2005 Artem Pavlenko, Jean-Francois Doyon
|
||||||
#
|
#
|
||||||
# Mapnik is free software; you can redistribute it and/or
|
# Mapnik is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or any later version.
|
# of the License, or any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
import os
|
import os, sys
|
||||||
|
|
||||||
#edit 'settings.py' to match your system settings
|
opts = Options()
|
||||||
opts = Options('settings.py')
|
|
||||||
|
|
||||||
opts.Add('PREFIX', 'Set the install "prefix"', '/opt/mapnik')
|
opts.Add('PREFIX', 'The install path "prefix"', '/usr/local')
|
||||||
opts.Add(PathOption('BOOST_ROOT','boost source root directory','/opt/boost'))
|
opts.Add(PathOption('BOOST_INCLUDES', 'Search path for boost include files', '/usr/include'))
|
||||||
opts.Add(PathOption('AGG_ROOT','agg source root directory','/opt/agg23'))
|
opts.Add(PathOption('BOOST_LIBS', 'Search path for boost library files', '/usr/lib'))
|
||||||
opts.Add(PathOption('FREETYPE2_ROOT','freetype2 root directory','/opt/freetype2'))
|
opts.Add(PathOption('FREETYPE_INCLUDES', 'Search path for FreeType include files', '/usr/include'))
|
||||||
opts.Add(PathOption('PYTHON_ROOT','python root directory','/opt/python'))
|
opts.Add(PathOption('FREETYPE_LIBS', 'Search path for FreeType library files', '/usr/lib'))
|
||||||
opts.Add('PYTHON_VERSION','python version','2.4')
|
opts.Add(PathOption('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include'))
|
||||||
opts.Add(ListOption('DATASOURCES','list of available datasources','all',['postgis','shape','raster']))
|
opts.Add(PathOption('PNG_LIBS', 'Search path for libpng include files', '/usr/lib'))
|
||||||
opts.Add(ListOption('EXTENSIONS','list of available extensions','none',['python']))
|
opts.Add(PathOption('JPEG_INCLUDES', 'Search path for libjpeg include files', '/usr/include'))
|
||||||
opts.Add('POSTGRESQL_ROOT','path to postgresql prefix','/usr/local')
|
opts.Add(PathOption('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/lib'))
|
||||||
|
opts.Add(PathOption('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include'))
|
||||||
platform = ARGUMENTS.get("OS",Platform())
|
opts.Add(PathOption('TIFF_LIBS', 'Search path for libtiff library files', '/usr/lib'))
|
||||||
|
opts.Add(PathOption('PGSQL_INCLUDES', 'Search path for PostgreSQL include files', '/usr/include'))
|
||||||
build_dir = 'build'
|
opts.Add(PathOption('PGSQL_LIBS', 'Search path for PostgreSQL library files', '/usr/lib'))
|
||||||
build_prefix = build_dir+'/'+str(platform)
|
opts.Add(PathOption('PYTHON','Python executable','/usr/local/bin/python2.4'))
|
||||||
|
opts.Add(ListOption('INPUT_PLUGINS','Input drivers to include','all',['postgis','shape','raster']))
|
||||||
#cxx = 'g++'
|
opts.Add(ListOption('BINDINGS','Language bindings to build','all',['python']))
|
||||||
|
|
||||||
env = Environment(ENV=os.environ, options=opts)
|
env = Environment(ENV=os.environ, options=opts)
|
||||||
|
|
||||||
cxx_debug='-Wall -Wno-non-virtual-dtor -Wno-ctor-dtor-privacy -ftemplate-depth-100 -O0 -fno-inline -g -pthread -DDEBUG'
|
|
||||||
cxx_release='-Wall -Wno-non-virtual-dtor -Wno-ctor-dtor-privacy -ftemplate-depth-100 -O3 -finline-functions -Wno-inline -pthread -DNDEBUG '
|
|
||||||
|
|
||||||
#release_env = env.Copy(CXXFLAGS = cxx_release)
|
|
||||||
#debug_env = env.Copy(CXXFLAGS = cxx_debug)
|
|
||||||
|
|
||||||
if ARGUMENTS.get('debug',0):
|
|
||||||
env.Append(CXXFLAGS = cxx_debug)
|
|
||||||
build_prefix+='/debug'
|
|
||||||
else:
|
|
||||||
env.Append(CXXFLAGS = cxx_release)
|
|
||||||
build_prefix+='/release'
|
|
||||||
|
|
||||||
Help(opts.GenerateHelpText(env))
|
Help(opts.GenerateHelpText(env))
|
||||||
|
|
||||||
conf = Configure(env)
|
conf = Configure(env)
|
||||||
|
|
||||||
if not conf.CheckLibWithHeader('ltdl','ltdl.h','C'):
|
# Libraries and headers dependency checks
|
||||||
print 'Could not find libltdl/headers , exiting!'
|
|
||||||
Exit(1)
|
|
||||||
|
|
||||||
if not conf.CheckLib('z'):
|
env['CPPPATH'] = ['#agg/include', '#include']
|
||||||
print 'Could not find libz , exiting!'
|
|
||||||
Exit(1)
|
|
||||||
|
|
||||||
if not conf.CheckLibWithHeader('png','png.h','C'):
|
for path in [env['BOOST_INCLUDES'], env['FREETYPE_INCLUDES'], env['PNG_INCLUDES'], env['JPEG_INCLUDES'], env['TIFF_INCLUDES'], env['PGSQL_INCLUDES']]:
|
||||||
print 'Could not find png lib and/or headers, exiting!'
|
if path not in env['CPPPATH']: env['CPPPATH'].append(path)
|
||||||
Exit(1)
|
|
||||||
|
|
||||||
if not conf.CheckLib('jpeg'):
|
env['LIBPATH'] = ['#agg', '#src']
|
||||||
print 'Could not find jpeg lib, exiting!'
|
|
||||||
Exit(1)
|
for path in [env['BOOST_LIBS'], env['FREETYPE_LIBS'], env['PNG_LIBS'], env['JPEG_LIBS'], env['TIFF_LIBS'], env['PGSQL_LIBS']]:
|
||||||
|
if path not in env['LIBPATH']: env['LIBPATH'].append(path)
|
||||||
if not conf.CheckLibWithHeader('tiff','tiff.h','C'):
|
|
||||||
print 'Could not find tiff lib and/or headers, exiting!'
|
C_LIBSHEADERS = [
|
||||||
Exit(1)
|
['ltdl', 'ltdl.h', True],
|
||||||
|
['png', 'png.h', True],
|
||||||
env = conf.Finish()
|
['tiff', 'tiff.h', True],
|
||||||
|
['z', 'zlib.h', True],
|
||||||
|
['jpeg', ['stdio.h','jpeglib.h'], True],
|
||||||
|
['pq', 'libpq-fe.h', False]
|
||||||
|
]
|
||||||
|
|
||||||
|
BOOST_LIBSHEADERS = [
|
||||||
|
['thread', 'boost/thread/mutex.hpp', True],
|
||||||
|
['filesystem', 'boost/filesystem/operations.hpp', True],
|
||||||
|
['wserialization', ['boost/archive/text_oarchive.hpp',
|
||||||
|
'boost/archive/text_iarchive.hpp',
|
||||||
|
'boost/archive/xml_oarchive.hpp',
|
||||||
|
'boost/archive/xml_iarchive.hpp'], True
|
||||||
|
],
|
||||||
|
['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)
|
||||||
|
|
||||||
|
for libinfo in BOOST_LIBSHEADERS:
|
||||||
|
if not conf.CheckLibWithHeader('boost_%s' % libinfo[0], libinfo[1], 'C++'):
|
||||||
|
if not conf.CheckLibWithHeader('boost_%s-%s-mt' % (libinfo[0], env['CC']), libinfo[1], 'C++') and libinfo[2]:
|
||||||
|
print 'Could not find header or shared library for boost %s, exiting!' % libinfo[0]
|
||||||
|
Exit(1)
|
||||||
|
|
||||||
|
# Check out the Python situation
|
||||||
|
|
||||||
|
if 'python' in env['BINDINGS']:
|
||||||
|
if not os.access(env['PYTHON'], os.X_OK):
|
||||||
|
print 'Cannot run python, make sure that you have the permissions to execute it.'
|
||||||
|
Exit(1)
|
||||||
|
|
||||||
|
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]
|
||||||
|
|
||||||
|
print 'Bindings Python version... %s' % env['PYTHON_VERSION']
|
||||||
|
|
||||||
|
majver, minver = env['PYTHON_VERSION'].split('.')
|
||||||
|
|
||||||
|
if int(majver) > 1:
|
||||||
|
if int(minver) < 3:
|
||||||
|
print "Python version 2.2 or greater required"
|
||||||
|
Exit(1)
|
||||||
|
else:
|
||||||
|
print "Python version 2.2 or greater required"
|
||||||
|
Exit(1)
|
||||||
|
|
||||||
|
print 'Python %s prefix... %s' % (env['PYTHON_VERSION'], env['PYTHON_PREFIX'])
|
||||||
|
|
||||||
|
env = conf.Finish()
|
||||||
|
|
||||||
|
# Setup the c++ args for our own codebase
|
||||||
|
|
||||||
|
if ARGUMENTS.get('DEBUG',0):
|
||||||
|
env.Append(CXXFLAGS = '-Wall -ftemplate-depth-100 -O0 -fno-inline -g -pthread -DDEBUG')
|
||||||
|
else:
|
||||||
|
env.Append(CXXFLAGS = '-Wall -ftemplate-depth-100 -O3 -finline-functions -Wno-inline -pthread -DNDEBUG')
|
||||||
|
|
||||||
|
# Build the input plug-ins
|
||||||
|
|
||||||
|
inputplugins = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])]
|
||||||
|
|
||||||
Export('env')
|
Export('env')
|
||||||
#build agg lib
|
|
||||||
env.SConscript('agg/SConscript')
|
# Build agg first, doesn't need anything special
|
||||||
#build boost libs (filesystem, regex, python etc)
|
|
||||||
env.SConscript('boost/SConscript')
|
SConscript('agg/SConscript')
|
||||||
#main lib
|
|
||||||
|
# Build shapeindex and remove it's dependency from the LIBS
|
||||||
|
|
||||||
|
if 'boost_program_options' in env['LIBS'] or 'boost_program_options-gcc-mt' in env['LIBS']:
|
||||||
|
SConscript('utils/shapeindex/SConscript')
|
||||||
|
|
||||||
|
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')
|
||||||
|
|
||||||
|
# Build the core library
|
||||||
|
|
||||||
SConscript('src/SConscript')
|
SConscript('src/SConscript')
|
||||||
|
|
||||||
import string
|
# Build python bindings
|
||||||
|
|
||||||
#python bindings
|
|
||||||
|
|
||||||
if 'python' in [string.strip(m) for m in Split(env['EXTENSIONS'])]:
|
|
||||||
SConscript('python/SConscript')
|
|
||||||
|
|
||||||
#shapeindex
|
|
||||||
SConscript('util/shapeindex/SConscript')
|
|
||||||
|
|
||||||
#datasources
|
|
||||||
def build_datasource(name):
|
|
||||||
env.BuildDir('build/datasources/' + name,'src/datasources/'+name,duplicate=0)
|
|
||||||
SConscript('datasources/' + name + '/SConscript')
|
|
||||||
|
|
||||||
[build_datasource(name) for name in Split(env['DATASOURCES'])]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bindings = [ binding.strip() for binding in Split(env['BINDINGS'])]
|
||||||
|
|
||||||
|
if 'python' in bindings:
|
||||||
|
SConscript('bindings/python/SConscript')
|
||||||
|
|
Loading…
Reference in a new issue