| 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, platform |
|---|
| 24 | |
|---|
| 25 | if platform.uname()[4] == 'x86_64': |
|---|
| 26 | LIBDIR_SCHEMA='lib64' |
|---|
| 27 | else: |
|---|
| 28 | LIBDIR_SCHEMA='lib' |
|---|
| 29 | |
|---|
| 30 | opts = Options() |
|---|
| 31 | opts.Add('PREFIX', 'The install path "prefix"', '/usr/local') |
|---|
| 32 | opts.Add(PathOption('BOOST_INCLUDES', 'Search path for boost include files', '/usr/include')) |
|---|
| 33 | opts.Add(PathOption('BOOST_LIBS', 'Search path for boost library files', '/usr/' + LIBDIR_SCHEMA)) |
|---|
| 34 | opts.Add('BOOST_TOOLKIT','Specify boost toolkit e.g. gcc41.','',False) |
|---|
| 35 | |
|---|
| 36 | opts.Add(PathOption('FREETYPE_CONFIG', 'The path to the freetype-config executable.', '/usr/bin/freetype-config')) |
|---|
| 37 | opts.Add(PathOption('FRIBIDI_INCLUDES', 'Search path for fribidi include files', '/usr/include')) |
|---|
| 38 | opts.Add(PathOption('FRIBIDI_LIBS','Search path for fribidi include files','/usr/' + LIBDIR_SCHEMA)) |
|---|
| 39 | opts.Add(PathOption('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include')) |
|---|
| 40 | opts.Add(PathOption('PNG_LIBS','Search path for libpng include files','/usr/' + LIBDIR_SCHEMA)) |
|---|
| 41 | opts.Add(PathOption('JPEG_INCLUDES', 'Search path for libjpeg include files', '/usr/include')) |
|---|
| 42 | opts.Add(PathOption('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/' + LIBDIR_SCHEMA)) |
|---|
| 43 | opts.Add(PathOption('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include')) |
|---|
| 44 | opts.Add(PathOption('TIFF_LIBS', 'Search path for libtiff library files', '/usr/' + LIBDIR_SCHEMA)) |
|---|
| 45 | opts.Add(PathOption('PGSQL_INCLUDES', 'Search path for PostgreSQL include files', '/usr/include')) |
|---|
| 46 | opts.Add(PathOption('PGSQL_LIBS', 'Search path for PostgreSQL library files', '/usr/' + LIBDIR_SCHEMA)) |
|---|
| 47 | opts.Add(PathOption('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/local/include')) |
|---|
| 48 | opts.Add(PathOption('PROJ_LIBS', 'Search path for PROJ.4 include files', '/usr/local/' + LIBDIR_SCHEMA)) |
|---|
| 49 | opts.Add(PathOption('PYTHON','Python executable', sys.executable)) |
|---|
| 50 | opts.Add(ListOption('INPUT_PLUGINS','Input drivers to include','all',['postgis','shape','raster'])) |
|---|
| 51 | opts.Add(ListOption('BINDINGS','Language bindings to build','all',['python'])) |
|---|
| 52 | opts.Add('DEBUG', 'Compile a debug version of mapnik', '') |
|---|
| 53 | opts.Add('DESTDIR', 'The root directory to install into. Useful mainly for binary package building', '/') |
|---|
| 54 | opts.Add('BIDI', 'BIDI support', '') |
|---|
| 55 | |
|---|
| 56 | env = Environment(ENV=os.environ, options=opts) |
|---|
| 57 | env['LIBDIR_SCHEMA'] = LIBDIR_SCHEMA |
|---|
| 58 | |
|---|
| 59 | Help(opts.GenerateHelpText(env)) |
|---|
| 60 | |
|---|
| 61 | conf = Configure(env) |
|---|
| 62 | |
|---|
| 63 | # Libraries and headers dependency checks |
|---|
| 64 | |
|---|
| 65 | env['CPPPATH'] = ['#agg/include', '#tinyxml', '#include', '#'] |
|---|
| 66 | |
|---|
| 67 | for path in [env['BOOST_INCLUDES'], |
|---|
| 68 | env['PNG_INCLUDES'], |
|---|
| 69 | env['JPEG_INCLUDES'], |
|---|
| 70 | env['TIFF_INCLUDES'], |
|---|
| 71 | env['PGSQL_INCLUDES'], |
|---|
| 72 | env['PROJ_INCLUDES']]: |
|---|
| 73 | if path not in env['CPPPATH']: env['CPPPATH'].append(path) |
|---|
| 74 | |
|---|
| 75 | env['LIBPATH'] = ['#agg', '#src'] |
|---|
| 76 | |
|---|
| 77 | for path in [env['BOOST_LIBS'], |
|---|
| 78 | env['PNG_LIBS'], |
|---|
| 79 | env['JPEG_LIBS'], |
|---|
| 80 | env['TIFF_LIBS'], |
|---|
| 81 | env['PGSQL_LIBS'], |
|---|
| 82 | env['PROJ_LIBS']]: |
|---|
| 83 | if path not in env['LIBPATH']: env['LIBPATH'].append(path) |
|---|
| 84 | |
|---|
| 85 | env.ParseConfig(env['FREETYPE_CONFIG'] + ' --libs --cflags') |
|---|
| 86 | |
|---|
| 87 | if env['BIDI']: |
|---|
| 88 | env.Append(CXXFLAGS = '-DUSE_FRIBIDI') |
|---|
| 89 | if env['FRIBIDI_INCLUDES'] not in env['CPPPATH']: |
|---|
| 90 | env['CPPPATH'].append(env['FRIBIDI_INCLUDES']) |
|---|
| 91 | if env['FRIBIDI_LIBS'] not in env['LIBPATH']: |
|---|
| 92 | env['CPPPATH'].append(env['FRIBIDI_LIBS']) |
|---|
| 93 | env['LIBS'].append('fribidi') |
|---|
| 94 | |
|---|
| 95 | C_LIBSHEADERS = [ |
|---|
| 96 | ['m', 'math.h', True], |
|---|
| 97 | ['ltdl', 'ltdl.h', True], |
|---|
| 98 | ['png', 'png.h', True], |
|---|
| 99 | ['tiff', 'tiff.h', True], |
|---|
| 100 | ['z', 'zlib.h', True], |
|---|
| 101 | ['jpeg', ['stdio.h', 'jpeglib.h'], True], |
|---|
| 102 | ['proj', 'proj_api.h', True], |
|---|
| 103 | ['pq', 'libpq-fe.h', False] |
|---|
| 104 | ] |
|---|
| 105 | |
|---|
| 106 | if env['BIDI'] : C_LIBSHEADERS.append(['fribidi','fribidi/fribidi.h',True]) |
|---|
| 107 | |
|---|
| 108 | BOOST_LIBSHEADERS = [ |
|---|
| 109 | ['thread', 'boost/thread/mutex.hpp', True], |
|---|
| 110 | #['system', 'boost/system/system_error.hpp', True], |
|---|
| 111 | ['filesystem', 'boost/filesystem/operations.hpp', True], |
|---|
| 112 | ['regex', 'boost/regex.hpp', True], |
|---|
| 113 | ['program_options', 'boost/program_options.hpp', False] |
|---|
| 114 | ] |
|---|
| 115 | |
|---|
| 116 | for libinfo in C_LIBSHEADERS: |
|---|
| 117 | if not conf.CheckLibWithHeader(libinfo[0], libinfo[1], 'C') and libinfo[2]: |
|---|
| 118 | print 'Could not find header or shared library for %s, exiting!' % libinfo[0] |
|---|
| 119 | Exit(1) |
|---|
| 120 | |
|---|
| 121 | env['BOOST_APPEND'] = '' |
|---|
| 122 | |
|---|
| 123 | if len(env['BOOST_TOOLKIT']): toolkit = env['BOOST_TOOLKIT'] |
|---|
| 124 | else: toolkit = env['CC'] |
|---|
| 125 | |
|---|
| 126 | for count, libinfo in enumerate(BOOST_LIBSHEADERS): |
|---|
| 127 | if not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0], env['BOOST_APPEND']), libinfo[1], 'C++'): |
|---|
| 128 | if not conf.CheckLibWithHeader('boost_%s-%s-mt' % (libinfo[0], toolkit), libinfo[1], 'C++') and libinfo[2] and count == 0: |
|---|
| 129 | print 'Could not find header or shared library for boost %s, exiting!' % libinfo[0] |
|---|
| 130 | Exit(1) |
|---|
| 131 | else: |
|---|
| 132 | env['BOOST_APPEND'] = '-%s-mt' % toolkit |
|---|
| 133 | |
|---|
| 134 | Export('env') |
|---|
| 135 | |
|---|
| 136 | inputplugins = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])] |
|---|
| 137 | |
|---|
| 138 | bindings = [ binding.strip() for binding in Split(env['BINDINGS'])] |
|---|
| 139 | |
|---|
| 140 | # Check out the Python situation |
|---|
| 141 | |
|---|
| 142 | if 'python' in env['BINDINGS']: |
|---|
| 143 | if not os.access(env['PYTHON'], os.X_OK): |
|---|
| 144 | print "Cannot run python interpreter at '%s', make sure that you have the permissions to execute it." % env['PYTHON'] |
|---|
| 145 | Exit(1) |
|---|
| 146 | |
|---|
| 147 | env['PYTHON_PREFIX'] = os.popen("%s -c 'import sys; print sys.prefix'" % env['PYTHON']).read().strip() |
|---|
| 148 | env['PYTHON_VERSION'] = os.popen("%s -c 'import sys; print sys.version'" % env['PYTHON']).read()[0:3] |
|---|
| 149 | |
|---|
| 150 | print 'Bindings Python version... %s' % env['PYTHON_VERSION'] |
|---|
| 151 | |
|---|
| 152 | majver, minver = env['PYTHON_VERSION'].split('.') |
|---|
| 153 | |
|---|
| 154 | if (int(majver), int(minver)) < (2, 2): |
|---|
| 155 | print "Python version 2.2 or greater required" |
|---|
| 156 | Exit(1) |
|---|
| 157 | |
|---|
| 158 | print 'Python %s prefix... %s' % (env['PYTHON_VERSION'], env['PYTHON_PREFIX']) |
|---|
| 159 | |
|---|
| 160 | SConscript('bindings/python/SConscript') |
|---|
| 161 | |
|---|
| 162 | |
|---|
| 163 | env = conf.Finish() |
|---|
| 164 | |
|---|
| 165 | # Setup the c++ args for our own codebase |
|---|
| 166 | |
|---|
| 167 | if env['DEBUG']: |
|---|
| 168 | env.Append(CXXFLAGS = '-ansi -Wall -ftemplate-depth-100 -O0 -fno-inline -g -pthread -DDEBUG -DMAPNIK_DEBUG -DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL') |
|---|
| 169 | else: |
|---|
| 170 | env.Append(CXXFLAGS = '-ansi -Wall -ftemplate-depth-100 -O3 -finline-functions -Wno-inline -pthread -DNDEBUG -DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL') |
|---|
| 171 | |
|---|
| 172 | # Build agg first, doesn't need anything special |
|---|
| 173 | |
|---|
| 174 | SConscript('agg/SConscript') |
|---|
| 175 | |
|---|
| 176 | # Build shapeindex and remove its dependency from the LIBS |
|---|
| 177 | |
|---|
| 178 | if 'boost_program_options%s' % env['BOOST_APPEND'] in env['LIBS']: |
|---|
| 179 | SConscript('utils/shapeindex/SConscript') |
|---|
| 180 | env['LIBS'].remove('boost_program_options%s' % env['BOOST_APPEND']) |
|---|
| 181 | |
|---|
| 182 | # Build the input plug-ins |
|---|
| 183 | |
|---|
| 184 | if 'postgis' in inputplugins and 'pq' in env['LIBS']: |
|---|
| 185 | SConscript('plugins/input/postgis/SConscript') |
|---|
| 186 | env['LIBS'].remove('pq') |
|---|
| 187 | |
|---|
| 188 | if 'shape' in inputplugins: |
|---|
| 189 | SConscript('plugins/input/shape/SConscript') |
|---|
| 190 | |
|---|
| 191 | if 'raster' in inputplugins: |
|---|
| 192 | SConscript('plugins/input/raster/SConscript') |
|---|
| 193 | |
|---|
| 194 | # Build the core library |
|---|
| 195 | |
|---|
| 196 | SConscript('src/SConscript') |
|---|
| 197 | |
|---|
| 198 | # Install some free default fonts |
|---|
| 199 | |
|---|
| 200 | SConscript('fonts/SConscript') |
|---|