diff --git a/SConstruct b/SConstruct index 8a7edbd9e..be4abb39b 100644 --- a/SConstruct +++ b/SConstruct @@ -331,7 +331,9 @@ pickle_store = [# Scons internal variables 'PYTHON_SYS_PREFIX', 'COLOR_PRINT', 'HAS_BOOST_SYSTEM', - 'SVN_REVISION' + 'SVN_REVISION', + 'HAS_CAIRO', + 'HAS_PYCAIRO' ] # Add all other user configurable options to pickle pickle_store @@ -778,7 +780,7 @@ if not preconfigured: if env['CAIRO'] and conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('cairomm-1.0'): env.ParseConfig('pkg-config --libs --cflags cairomm-1.0') - env.Append(CXXFLAGS = '-DHAVE_CAIRO') + env['HAS_CAIRO'] = True else: env['SKIPPED_DEPS'].extend(['cairo','cairomm']) @@ -928,7 +930,7 @@ if not preconfigured: if env['CAIRO'] and conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('pycairo'): env.ParseConfig('pkg-config --cflags pycairo') - env.Append(CXXFLAGS = '-DHAVE_PYCAIRO') + env['HAS_PYCAIRO'] = True else: env['SKIPPED_DEPS'].extend(['pycairo']) diff --git a/bindings/python/SConscript b/bindings/python/SConscript index b59b0f103..59a629feb 100644 --- a/bindings/python/SConscript +++ b/bindings/python/SConscript @@ -48,7 +48,7 @@ if env['PLATFORM'] == 'Darwin': libraries.append('boost_regex%s' % env['BOOST_APPEND']) if env['THREADING'] == 'multi': libraries.append('boost_thread%s' % env['BOOST_APPEND']) - if '-DHAVE_CAIRO' in env['CXXFLAGS']: + if env['HAS_CAIRO']: libraries.append([lib for lib in env['LIBS'] if lib.startswith('cairo')]) ##### Python linking on OS X is tricky ### @@ -139,12 +139,30 @@ env.Alias(target='install', source=ogcserver_module) # install the shared object beside the module directory sources = glob.glob('*.cpp') -if env.get('SVN_REVISION'): + +if env['SVN_REVISION']: sources.remove('mapnik_python.cpp') - env2 = env.Clone(); + env2 = env.Clone() env2.Append(CCFLAGS='-DSVN_REVISION=%s' % env['SVN_REVISION']) + if env['HAS_CAIRO']: + env2.Append(CXXFLAGS = '-DHAVE_CAIRO') + if env['HAS_PYCAIRO']: + env2.Append(CXXFLAGS = '-DHAVE_PYCAIRO') sources.insert(0,env2.SharedObject('mapnik_python.cpp')) +if env['HAS_CAIRO'] or env['HAS_PYCAIRO']: + env2 = env.Clone() + fixup = ['mapnik_image.cpp','python_cairo.cpp'] + for cpp in fixup: + if cpp in sources: + sources.remove(cpp) + if env['HAS_CAIRO']: + env2.Append(CXXFLAGS = '-DHAVE_CAIRO') + if env['HAS_PYCAIRO']: + env2.Append(CXXFLAGS = '-DHAVE_PYCAIRO') + for cpp in fixup: + sources.insert(0,env2.SharedObject(cpp)) + _mapnik = env.LoadableModule('mapnik/_mapnik2', sources, LIBS=libraries, LDMODULEPREFIX='', LDMODULESUFFIX='.so', CPPPATH=headers,LINKFLAGS=linkflags) pymapniklib = env.Install(env['PYTHON_INSTALL_LOCATION'] + '/mapnik2',_mapnik) env.Alias(target='install',source=pymapniklib) diff --git a/demo/c++/SConscript b/demo/c++/SConscript index ff374427e..476894fbd 100644 --- a/demo/c++/SConscript +++ b/demo/c++/SConscript @@ -37,7 +37,7 @@ boost_regex = 'boost_regex%s' % env['BOOST_APPEND'] libraries = [boost_thread,'mapnik2'] -if '-DHAVE_CAIRO' in env['CXXFLAGS']: +if env['HAS_CAIRO'] in env['CXXFLAGS']: # add cairo and cairomm-1.0 to libs libraries.append([lib for lib in env['LIBS'] if lib.startswith('cairo')]) diff --git a/src/SConscript b/src/SConscript index 0069412a0..501430924 100644 --- a/src/SConscript +++ b/src/SConscript @@ -38,7 +38,7 @@ regex = 'boost_regex%s' % env['BOOST_APPEND'] libraries = ['freetype','ltdl','png','tiff','z','jpeg','proj',env['ICU_LIB_NAME'],filesystem,regex] -if '-DHAVE_CAIRO' in env['CXXFLAGS']: +if env['HAS_CAIRO']: # add cairo and cairomm-1.0 to libs libraries.append([lib for lib in env['LIBS'] if lib.startswith('cairo')]) @@ -72,9 +72,9 @@ else: # Linux and others source = Split( """ + color.cpp datasource_cache.cpp box2d.cpp - color.cpp expression_node.cpp expression_string.cpp filter_factory.cpp @@ -116,6 +116,7 @@ source = Split( """ ) + if env['JPEG']: source += Split( """ @@ -146,10 +147,14 @@ if True : # agg backend ) if 'cairo' in env['LIBS']: - source += Split( - """ - cairo_renderer.cpp - """) + env2 = env.Clone() + env2.Append(CXXFLAGS = '-DHAVE_CAIRO') + fixup = ['cairo_renderer.cpp','graphics.cpp','image_util.cpp'] + for cpp in fixup: + if cpp in source: + source.remove(cpp) + for cpp in fixup: + source.insert(0,env2.SharedObject(cpp)) if env['XMLPARSER'] == 'tinyxml': source += Split( @@ -165,7 +170,6 @@ elif env['XMLPARSER'] == 'libxml2': libxml2_loader.cpp """) - mapnik = env.SharedLibrary('mapnik2', source, LIBS=libraries, LINKFLAGS=linkflags) if env['PLATFORM'] != 'Darwin': # Symlink command, only works if both files are in same directory @@ -193,4 +197,5 @@ else: env.Alias(target='install', source=env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'], mapnik)) includes = glob.glob('../include/mapnik/*.hpp') + env.Alias(target='install', source=env.Install(install_prefix+'/include/mapnik', includes))