| 1 | # This file is part of Mapnik (c++ mapping toolkit) |
|---|
| 2 | # Copyright (C) 2005 Artem Pavlenko, Jean-Francois Doyon |
|---|
| 3 | # |
|---|
| 4 | # Mapnik is free software; you can redistribute it and/or |
|---|
| 5 | # modify it under the terms of the GNU General Public License |
|---|
| 6 | # as published by the Free Software Foundation; either version 2 |
|---|
| 7 | # of the License, or any later version. |
|---|
| 8 | # |
|---|
| 9 | # This program is distributed in the hope that it will be useful, |
|---|
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | # GNU General Public License for more details. |
|---|
| 13 | # |
|---|
| 14 | # You should have received a copy of the GNU General Public License |
|---|
| 15 | # along with this program; if not, write to the Free Software |
|---|
| 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 17 | # |
|---|
| 18 | # $Id$ |
|---|
| 19 | |
|---|
| 20 | import os, sys |
|---|
| 21 | |
|---|
| 22 | opts = Options() |
|---|
| 23 | |
|---|
| 24 | opts.Add('PREFIX', 'The install path "prefix"', '/usr/local') |
|---|
| 25 | opts.Add(PathOption('BOOST_INCLUDES', 'Search path for boost include files', '/usr/include')) |
|---|
| 26 | opts.Add(PathOption('BOOST_LIBS', 'Search path for boost library files', '/usr/lib')) |
|---|
| 27 | opts.Add(PathOption('FREETYPE_INCLUDES', 'Search path for FreeType include files', '/usr/include')) |
|---|
| 28 | opts.Add(PathOption('FREETYPE_LIBS', 'Search path for FreeType library files', '/usr/lib')) |
|---|
| 29 | opts.Add(PathOption('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include')) |
|---|
| 30 | opts.Add(PathOption('PNG_LIBS', 'Search path for libpng include files', '/usr/lib')) |
|---|
| 31 | opts.Add(PathOption('JPEG_INCLUDES', 'Search path for libjpeg include files', '/usr/include')) |
|---|
| 32 | opts.Add(PathOption('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/lib')) |
|---|
| 33 | opts.Add(PathOption('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include')) |
|---|
| 34 | opts.Add(PathOption('TIFF_LIBS', 'Search path for libtiff library files', '/usr/lib')) |
|---|
| 35 | opts.Add(PathOption('PGSQL_INCLUDES', 'Search path for PostgreSQL include files', '/usr/include')) |
|---|
| 36 | opts.Add(PathOption('PGSQL_LIBS', 'Search path for PostgreSQL library files', '/usr/lib')) |
|---|
| 37 | opts.Add(PathOption('PYTHON','Python executable','/usr/local/bin/python2.4')) |
|---|
| 38 | opts.Add(ListOption('INPUT_PLUGINS','Input drivers to include','all',['postgis','shape','raster'])) |
|---|
| 39 | opts.Add(ListOption('BINDINGS','Language bindings to build','all',['python'])) |
|---|
| 40 | |
|---|
| 41 | env = Environment(ENV=os.environ, options=opts) |
|---|
| 42 | |
|---|
| 43 | Help(opts.GenerateHelpText(env)) |
|---|
| 44 | |
|---|
| 45 | conf = Configure(env) |
|---|
| 46 | |
|---|
| 47 | # Libraries and headers dependency checks |
|---|
| 48 | |
|---|
| 49 | env['CPPPATH'] = ['#agg/include', '#include'] |
|---|
| 50 | |
|---|
| 51 | for path in [env['BOOST_INCLUDES'], env['FREETYPE_INCLUDES'], env['PNG_INCLUDES'], env['JPEG_INCLUDES'], env['TIFF_INCLUDES'], env['PGSQL_INCLUDES']]: |
|---|
| 52 | if path not in env['CPPPATH']: env['CPPPATH'].append(path) |
|---|
| 53 | |
|---|
| 54 | env['LIBPATH'] = ['#agg', '#src'] |
|---|
| 55 | |
|---|
| 56 | for path in [env['BOOST_LIBS'], env['FREETYPE_LIBS'], env['PNG_LIBS'], env['JPEG_LIBS'], env['TIFF_LIBS'], env['PGSQL_LIBS']]: |
|---|
| 57 | if path not in env['LIBPATH']: env['LIBPATH'].append(path) |
|---|
| 58 | |
|---|
| 59 | C_LIBSHEADERS = [ |
|---|
| 60 | ['ltdl', 'ltdl.h', True], |
|---|
| 61 | ['png', 'png.h', True], |
|---|
| 62 | ['tiff', 'tiff.h', True], |
|---|
| 63 | ['z', 'zlib.h', True], |
|---|
| 64 | ['jpeg', ['stdio.h','jpeglib.h'], True], |
|---|
| 65 | ['pq', 'libpq-fe.h', False] |
|---|
| 66 | ] |
|---|
| 67 | |
|---|
| 68 | BOOST_LIBSHEADERS = [ |
|---|
| 69 | ['thread', 'boost/thread/mutex.hpp', True], |
|---|
| 70 | ['filesystem', 'boost/filesystem/operations.hpp', True], |
|---|
| 71 | ['wserialization', ['boost/archive/text_oarchive.hpp', |
|---|
| 72 | 'boost/archive/text_iarchive.hpp', |
|---|
| 73 | 'boost/archive/xml_oarchive.hpp', |
|---|
| 74 | 'boost/archive/xml_iarchive.hpp'], True |
|---|
| 75 | ], |
|---|
| 76 | ['regex', 'boost/regex.hpp', True], |
|---|
| 77 | ['program_options', 'boost/program_options.hpp', False] |
|---|
| 78 | ] |
|---|
| 79 | |
|---|
| 80 | for libinfo in C_LIBSHEADERS: |
|---|
| 81 | if not conf.CheckLibWithHeader(libinfo[0], libinfo[1], 'C') and libinfo[2]: |
|---|
| 82 | print 'Could not find header or shared library for %s, exiting!' % libinfo[0] |
|---|
| 83 | Exit(1) |
|---|
| 84 | |
|---|
| 85 | for libinfo in BOOST_LIBSHEADERS: |
|---|
| 86 | if not conf.CheckLibWithHeader('boost_%s' % libinfo[0], libinfo[1], 'C++'): |
|---|
| 87 | if not conf.CheckLibWithHeader('boost_%s-%s-mt' % (libinfo[0], env['CC']), libinfo[1], 'C++') and libinfo[2]: |
|---|
| 88 | print 'Could not find header or shared library for boost %s, exiting!' % libinfo[0] |
|---|
| 89 | Exit(1) |
|---|
| 90 | |
|---|
| 91 | # Check out the Python situation |
|---|
| 92 | |
|---|
| 93 | if 'python' in env['BINDINGS']: |
|---|
| 94 | if not os.access(env['PYTHON'], os.X_OK): |
|---|
| 95 | print 'Cannot run python, make sure that you have the permissions to execute it.' |
|---|
| 96 | Exit(1) |
|---|
| 97 | |
|---|
| 98 | env['PYTHON_PREFIX'] = os.popen("%s -c 'import sys; print sys.prefix'" % env['PYTHON']).read().strip() |
|---|
| 99 | env['PYTHON_VERSION'] = os.popen("%s -c 'import sys; print sys.version'" % env['PYTHON']).read()[0:3] |
|---|
| 100 | |
|---|
| 101 | print 'Bindings Python version... %s' % env['PYTHON_VERSION'] |
|---|
| 102 | |
|---|
| 103 | majver, minver = env['PYTHON_VERSION'].split('.') |
|---|
| 104 | |
|---|
| 105 | if int(majver) > 1: |
|---|
| 106 | if int(minver) < 3: |
|---|
| 107 | print "Python version 2.2 or greater required" |
|---|
| 108 | Exit(1) |
|---|
| 109 | else: |
|---|
| 110 | print "Python version 2.2 or greater required" |
|---|
| 111 | Exit(1) |
|---|
| 112 | |
|---|
| 113 | print 'Python %s prefix... %s' % (env['PYTHON_VERSION'], env['PYTHON_PREFIX']) |
|---|
| 114 | |
|---|
| 115 | env = conf.Finish() |
|---|
| 116 | |
|---|
| 117 | # Setup the c++ args for our own codebase |
|---|
| 118 | |
|---|
| 119 | if ARGUMENTS.get('DEBUG',0): |
|---|
| 120 | env.Append(CXXFLAGS = '-Wall -ftemplate-depth-100 -O0 -fno-inline -g -pthread -DDEBUG') |
|---|
| 121 | else: |
|---|
| 122 | env.Append(CXXFLAGS = '-Wall -ftemplate-depth-100 -O3 -finline-functions -Wno-inline -pthread -DNDEBUG') |
|---|
| 123 | |
|---|
| 124 | # Build the input plug-ins |
|---|
| 125 | |
|---|
| 126 | inputplugins = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])] |
|---|
| 127 | |
|---|
| 128 | Export('env') |
|---|
| 129 | |
|---|
| 130 | # Build agg first, doesn't need anything special |
|---|
| 131 | |
|---|
| 132 | SConscript('agg/SConscript') |
|---|
| 133 | |
|---|
| 134 | # Build shapeindex and remove it's dependency from the LIBS |
|---|
| 135 | |
|---|
| 136 | if 'boost_program_options' in env['LIBS'] or 'boost_program_options-gcc-mt' in env['LIBS']: |
|---|
| 137 | SConscript('utils/shapeindex/SConscript') |
|---|
| 138 | |
|---|
| 139 | if 'postgis' in inputplugins and 'pq' in env['LIBS']: |
|---|
| 140 | SConscript('plugins/input/postgis/SConscript') |
|---|
| 141 | env['LIBS'].remove('pq') |
|---|
| 142 | |
|---|
| 143 | if 'shape' in inputplugins: |
|---|
| 144 | SConscript('plugins/input/shape/SConscript') |
|---|
| 145 | |
|---|
| 146 | if 'raster' in inputplugins: |
|---|
| 147 | SConscript('plugins/input/raster/SConscript') |
|---|
| 148 | |
|---|
| 149 | # Build the core library |
|---|
| 150 | |
|---|
| 151 | SConscript('src/SConscript') |
|---|
| 152 | |
|---|
| 153 | # Build python bindings |
|---|
| 154 | |
|---|
| 155 | bindings = [ binding.strip() for binding in Split(env['BINDINGS'])] |
|---|
| 156 | |
|---|
| 157 | if 'python' in bindings: |
|---|
| 158 | SConscript('bindings/python/SConscript') |
|---|