diff --git a/SConstruct b/SConstruct index b658d40fb..0b641e6e4 100644 --- a/SConstruct +++ b/SConstruct @@ -942,6 +942,7 @@ if not preconfigured: env['HAS_PYCAIRO'] = False env['HAS_LIBXML2'] = False env['SVN_REVISION'] = None + env['LIBMAPNIK_LIBS'] = [] if env['LINKING'] == 'static': env['MAPNIK_LIB_NAME'] = '${LIBPREFIX}mapnik2${LIBSUFFIX}' else: diff --git a/demo/c++/SConscript b/demo/c++/SConscript index 34050f56b..7e04fc86a 100644 --- a/demo/c++/SConscript +++ b/demo/c++/SConscript @@ -34,21 +34,9 @@ demo_env = env.Clone() headers = env['CPPPATH'] -boost_regex = 'boost_regex%s' % env['BOOST_APPEND'] - -libraries = ['mapnik2'] - -if env['THREADING'] == 'multi': - libraries.append('boost_thread%s' % env['BOOST_APPEND']) - -if env['HAS_CAIRO'] in env['CXXFLAGS']: - # add cairo and cairomm-1.0 to libs - libraries.append('cairomm-1.0') - libraries.append('cairo') - -if env['PLATFORM'] in ('Darwin','SunOS'): - libraries.append(boost_regex) - libraries.append(env['ICU_LIB_NAME']) +libraries = env['LIBMAPNIK_LIBS'] +boost_program_options = 'boost_program_options%s' % env['BOOST_APPEND'] +libraries.extend([boost_program_options,'mapnik2']) rundemo = demo_env.Program('rundemo', source, CPPPATH=headers, LIBS=libraries, LINKFLAGS=env["CUSTOM_LDFLAGS"]) diff --git a/src/SConscript b/src/SConscript index ceb38ef34..fda80ffc3 100644 --- a/src/SConscript +++ b/src/SConscript @@ -52,27 +52,28 @@ install_prefix = env['DESTDIR'] + '/' + prefix filesystem = 'boost_filesystem%s' % env['BOOST_APPEND'] regex = 'boost_regex%s' % env['BOOST_APPEND'] -libraries = ['freetype','ltdl','png','tiff','z','jpeg','proj',env['ICU_LIB_NAME'],filesystem,regex] +# clear out and re-set libs for this env +lib_env['LIBS'] = ['freetype','ltdl','png','tiff','z','jpeg','proj',env['ICU_LIB_NAME'],filesystem,regex] if env['HAS_CAIRO']: # add cairo and cairomm-1.0 to libs - libraries.append('cairomm-1.0') - libraries.append('cairo') + lib_env['LIBS'].append('cairomm-1.0') + lib_env['LIBS'].append('cairo') if env['XMLPARSER'] == 'libxml2': - libraries.append('xml2') + lib_env['LIBS'].append('xml2') if env['THREADING'] == 'multi': - libraries.append('boost_thread%s' % env['BOOST_APPEND']) + lib_env['LIBS'].append('boost_thread%s' % env['BOOST_APPEND']) if env['PLATFORM'] in ('Darwin','SunOS'): if env['HAS_BOOST_SYSTEM']: - libraries.append('boost_system%s' % env['BOOST_APPEND']) + lib_env['LIBS'].append('boost_system%s' % env['BOOST_APPEND']) if env['INTERNAL_LIBAGG']: - libraries.insert(0, 'agg') + lib_env['LIBS'].insert(0, 'agg') else: - libraries.append([lib for lib in env['LIBS'] if lib.startswith('agg')]) + lib_env['LIBS'].append([lib for lib in env['LIBS'] if lib.startswith('agg')]) if env['PLATFORM'] == 'Darwin': @@ -155,7 +156,11 @@ source = Split( if env['LIBTOOL_SUPPORTS_ADVISE']: env3 = lib_env.Clone() env3.Append(CXXFLAGS='-DLIBTOOL_SUPPORTS_ADVISE') - source.insert(0,env3.SharedObject('datasource_cache.cpp')) + cpp = 'datasource_cache.cpp' + if env['LINKING'] == 'static': + source.insert(0,env3.StaticObject(cpp)) + else: + source.insert(0,env3.SharedObject(cpp)) else: source.insert(0,'datasource_cache.cpp') @@ -236,7 +241,10 @@ if env['HAS_CAIRO']: for cpp in fixup: if cpp in source: source.remove(cpp) - source.insert(0,env2.SharedObject(cpp)) + if env['LINKING'] == 'static': + source.insert(0,env2.StaticObject(cpp)) + else: + source.insert(0,env2.SharedObject(cpp)) except OSError, e: print '\nFailed to detect cairo/cairomm configuration, please re-run "python scons/scons.py configure"' sys.exit(1) @@ -260,20 +268,23 @@ elif env['XMLPARSER'] == 'libxml2' and env['HAS_LIBXML2']: for cpp in fixup: if cpp in source: source.remove(cpp) - source.insert(0,env2.SharedObject(cpp)) + if env['LINKING'] == 'static': + source.insert(0,env2.StaticObject(cpp)) + else: + source.insert(0,env2.SharedObject(cpp)) if env['CUSTOM_LDFLAGS']: linkflags = '%s %s' % (env['CUSTOM_LDFLAGS'], mapnik_lib_link_flag) else: linkflags = mapnik_lib_link_flag -if env['LIBMAPNIK_LINKFLAGS']: - linkflags = '%s %s' % (env['LIBMAPNIK_LINKFLAGS'],linkflags) - if env['LINKING'] == 'static': - mapnik = lib_env.StaticLibrary('mapnik2', source, LIBS=libraries, LINKFLAGS=linkflags) + mapnik = lib_env.StaticLibrary('mapnik2', source, LINKFLAGS=linkflags) else: - mapnik = lib_env.SharedLibrary('mapnik2', source, LIBS=libraries, LINKFLAGS=linkflags) + mapnik = lib_env.SharedLibrary('mapnik2', source, LINKFLAGS=linkflags) + +# cache libraries value for other builds to use +env['LIBMAPNIK_LIBS'] = lib_env['LIBS'] if env['PLATFORM'] != 'Darwin': # Symlink command, only works if both files are in same directory diff --git a/tests/cpp_tests/SConscript b/tests/cpp_tests/SConscript index 436677dae..f7c53f781 100644 --- a/tests/cpp_tests/SConscript +++ b/tests/cpp_tests/SConscript @@ -5,17 +5,9 @@ Import ('env') headers = env['CPPPATH'] -boost_filesystem = 'boost_filesystem%s' % env['BOOST_APPEND'] -boost_system = 'boost_system%s' % env['BOOST_APPEND'] -boost_regex = 'boost_regex%s' % env['BOOST_APPEND'] - -libraries = [boost_filesystem, boost_regex, 'mapnik2'] - -if env['PLATFORM'] == 'Darwin': - libraries.append(env['ICU_LIB_NAME']) - -if env['HAS_BOOST_SYSTEM']: - libraries.append(boost_system) +libraries = env['LIBMAPNIK_LIBS'] +libraries.append('mapnik2') for cpp_test in glob.glob('*_test.cpp'): - env.Program(cpp_test.replace('.cpp',''), [cpp_test], CPPPATH=headers, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) + test_program = env.Program(cpp_test.replace('.cpp',''), [cpp_test], CPPPATH=headers, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) + Depends(test_program, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME'])) diff --git a/utils/pgsql2sqlite/SConscript b/utils/pgsql2sqlite/SConscript index b860cc018..69e829c04 100644 --- a/utils/pgsql2sqlite/SConscript +++ b/utils/pgsql2sqlite/SConscript @@ -35,15 +35,14 @@ source = Split( headers = ['#plugins/input/postgis'] + env['CPPPATH'] + +libraries = env['LIBMAPNIK_LIBS'] boost_program_options = 'boost_program_options%s' % env['BOOST_APPEND'] - -libraries = [boost_program_options,'sqlite3','pq','mapnik2'] - -if env['PLATFORM'] == 'Darwin': - libraries.append(env['ICU_LIB_NAME']) +libraries.extend([boost_program_options,'sqlite3','pq','mapnik2']) if 'uninstall' not in COMMAND_LINE_TARGETS: pgsql2sqlite = program_env.Program('pgsql2sqlite', source, CPPPATH=headers, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) + Depends(pgsql2sqlite, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME'])) env.Install(install_prefix + '/bin', pgsql2sqlite) env.Alias('install', install_prefix + '/bin') diff --git a/utils/svg2png/SConscript b/utils/svg2png/SConscript index fe50edc63..26a1a0fee 100644 --- a/utils/svg2png/SConscript +++ b/utils/svg2png/SConscript @@ -36,22 +36,14 @@ source = Split( headers = env['CPPPATH'] +libraries = env['LIBMAPNIK_LIBS'] boost_program_options = 'boost_program_options%s' % env['BOOST_APPEND'] -boost_filesystem = 'boost_filesystem%s' % env['BOOST_APPEND'] -libraries = [boost_program_options,boost_filesystem,'mapnik2'] - -boost_system = 'boost_system%s' % env['BOOST_APPEND'] - -if env['HAS_BOOST_SYSTEM']: - libraries.append(boost_system) - -if env['INTERNAL_LIBAGG']: - libraries.insert(0, 'agg') -else: - libraries.append([lib for lib in env['LIBS'] if lib.startswith('agg')]) +libraries.extend([boost_program_options,'mapnik2']) svg2png = program_env.Program('svg2png', source, CPPPATH=headers, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) +Depends(svg2png, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME'])) + if 'uninstall' not in COMMAND_LINE_TARGETS: env.Install(install_prefix + '/bin', svg2png) env.Alias('install', install_prefix + '/bin')