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