scons: simplify linkflags/ldflags setting / attempt to fix #2025

This commit is contained in:
Dane Springmeyer 2013-10-22 16:35:46 -04:00
parent afd23586f3
commit 710d558218
28 changed files with 37 additions and 84 deletions

View file

@ -1156,10 +1156,10 @@ if not preconfigured:
DEFAULT_CXX11_CXXFLAGS += ' -stdlib=libc++'
DEFAULT_CXX11_LINKFLAGS = ' -stdlib=libc++'
env.Append(CPPDEFINES = env['CUSTOM_DEFINES'])
env.Append(CUSTOM_CXXFLAGS = DEFAULT_CXX11_CXXFLAGS)
env.Append(CXXFLAGS = DEFAULT_CXX11_CXXFLAGS)
env.Append(CXXFLAGS = env['CUSTOM_CXXFLAGS'])
env.Append(CFLAGS = env['CUSTOM_CFLAGS'])
env.Append(CUSTOM_LDFLAGS = DEFAULT_CXX11_LINKFLAGS)
env.Append(LINKFLAGS = DEFAULT_CXX11_LINKFLAGS)
env.Append(LINKFLAGS = env['CUSTOM_LDFLAGS'])
### platform specific bits

View file

@ -10,16 +10,14 @@ test_env['LIBS'] = copy(env['LIBMAPNIK_LIBS'])
test_env.AppendUnique(LIBS='mapnik')
#test_env.AppendUnique(LIBS='sqlite3')
test_env.AppendUnique(CXXFLAGS='-g')
linkflags = copy(env['CUSTOM_LDFLAGS'])
linkflags
if env['PLATFORM'] == 'Darwin':
linkflags += ' -F/ -framework CoreFoundation'
test_env.Append(LINKFLAGS='-F/ -framework CoreFoundation')
for cpp_test in glob.glob('run*.cpp'):
name = cpp_test.replace('.cpp','')
source_files = [cpp_test]
test_env_local = test_env.Clone()
test_program = test_env_local.Program(name, source=source_files, LINKFLAGS=linkflags)
test_program = test_env_local.Program(name, source=source_files)
Depends(test_program, env.subst('../src/%s' % env['MAPNIK_LIB_NAME']))
# build locally if installing
if 'install' in COMMAND_LINE_TARGETS:

View file

@ -112,11 +112,6 @@ else:
# all other platforms we don't directly link python
python_link_flag = ''
if env['CUSTOM_LDFLAGS']:
linkflags = '%s %s' % (env['CUSTOM_LDFLAGS'], python_link_flag)
else:
linkflags = python_link_flag
paths = '''
"""Configuration paths of Mapnik fonts and input plugins (auto-generated by SCons)."""
@ -183,7 +178,8 @@ if 'uninstall' not in COMMAND_LINE_TARGETS:
py_env.Append(CPPDEFINES = '-DHAVE_PYCAIRO')
py_env.AppendUnique(LIBS = 'boost_thread%s' % env['BOOST_APPEND'])
_mapnik = py_env.LoadableModule('mapnik/_mapnik', sources, LDMODULEPREFIX='', LDMODULESUFFIX='.so',LINKFLAGS=linkflags)
py_env.Append(LINKFLAGS=python_link_flag)
_mapnik = py_env.LoadableModule('mapnik/_mapnik', sources, LDMODULEPREFIX='', LDMODULESUFFIX='.so')
Depends(_mapnik, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -42,7 +42,7 @@ if env['HAS_CAIRO']:
libraries = ['mapnik']
libraries.extend(copy(env['LIBMAPNIK_LIBS']))
rundemo = demo_env.Program('rundemo', source, LIBS=libraries, LINKFLAGS=env["CUSTOM_LDFLAGS"])
rundemo = demo_env.Program('rundemo', source, LIBS=libraries)
Depends(rundemo, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))

9
deps/agg/build.py vendored
View file

@ -21,12 +21,5 @@ import os
from glob import glob
Import('env')
agg_env = env.Clone()
if env['SUNCC']:
cxxflags = env['CUSTOM_CXXFLAGS'] + ' -O -KPIC -DNDEBUG'
else:
cxxflags = env['CUSTOM_CXXFLAGS'] + ' -O%s -fPIC -DNDEBUG' % env['OPTIMIZATION']
agg_env.StaticLibrary('agg', glob('./src/' + '*.cpp'), LIBS=[], CXXFLAGS=cxxflags, LINKFLAGS=env['CUSTOM_LDFLAGS'])
agg_env.StaticLibrary('agg', glob('./src/' + '*.cpp'), LIBS=[])

View file

@ -24,9 +24,4 @@ Import('env')
clipper_env = env.Clone()
if env['SUNCC']:
cxxflags = env['CUSTOM_CXXFLAGS'] + ' -O -KPIC -DNDEBUG'
else:
cxxflags = env['CUSTOM_CXXFLAGS'] + ' -O%s -fPIC -DNDEBUG' % env['OPTIMIZATION']
clipper_env.StaticLibrary('clipper', ['./src/clipper.cpp',], LIBS=[], CXXFLAGS=cxxflags, LINKFLAGS=env['CUSTOM_LDFLAGS'])
clipper_env.StaticLibrary('clipper', ['./src/clipper.cpp',], LIBS=[])

View file

@ -54,8 +54,7 @@ else:
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env.get('CUSTOM_LDFLAGS'))
LIBS=libraries)
# if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -53,8 +53,7 @@ if env['PLUGIN_LINKING'] == 'shared':
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
LIBS=libraries)
# if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -57,8 +57,7 @@ else:
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
LIBS=libraries)
# if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -47,8 +47,7 @@ if env['PLUGIN_LINKING'] == 'shared':
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
LIBS=libraries)
# if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -66,8 +66,7 @@ if env['PLUGIN_LINKING'] == 'shared':
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
LIBS=libraries)
# if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -50,8 +50,7 @@ if env['PLUGIN_LINKING'] == 'shared':
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
LIBS=libraries)
# if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -57,8 +57,7 @@ if env['PLUGIN_LINKING'] == 'shared':
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
LIBS=libraries)
# if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -65,10 +65,7 @@ else:
# so instead add to libraries
libraries.append('python%s' % env['PYTHON_VERSION'])
if env['CUSTOM_LDFLAGS']:
linkflags = '%s %s' % (env['CUSTOM_LDFLAGS'], python_link_flag)
else:
linkflags = python_link_flag
plugin_env.Append(LINKFLAGS=python_link_flag)
if env['PLUGIN_LINKING'] == 'shared':
libraries.append('mapnik')
@ -77,8 +74,7 @@ if env['PLUGIN_LINKING'] == 'shared':
SHLIBSUFFIX='.input',
source=plugin_sources,
CPPPATH=allcpp_paths,
LIBS=libraries,
LINKFLAGS=linkflags)
LIBS=libraries)
# if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
@ -94,7 +90,7 @@ plugin_obj = {
'LIBS': libraries,
'SOURCES': plugin_sources,
'CPPPATH': python_cpppath,
'LINKFLAGS': linkflags.replace('-Z','').split(' '),
'LINKFLAGS': python_link_flag.replace('-Z','').split(' '),
}
Return('plugin_obj')

View file

@ -46,8 +46,7 @@ if env['PLUGIN_LINKING'] == 'shared':
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
LIBS=libraries)
# if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -45,8 +45,7 @@ if env['PLUGIN_LINKING'] == 'shared':
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
LIBS=libraries)
# if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -62,8 +62,7 @@ if env['PLUGIN_LINKING'] == 'shared':
SHLIBSUFFIX='.input',
SHLIBPREFIX='',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
LIBS=libraries)
# if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -41,17 +41,16 @@ libraries.append('boost_system%s' % env['BOOST_APPEND'])
linkflags = []
if env['SQLITE_LINKFLAGS']:
linkflags.append(env['SQLITE_LINKFLAGS'])
plugin_env.Append(LINKFLAGS=linkflags)
if env['PLUGIN_LINKING'] == 'shared':
libraries.append('mapnik')
linkflags.append(env['CUSTOM_LDFLAGS'])
TARGET = plugin_env.SharedLibrary('../%s' % PLUGIN_NAME,
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=(' ').join(linkflags))
LIBS=libraries)
# if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -63,13 +63,7 @@ if env['PLUGIN_LINKING'] == 'shared':
# list of source files to compile
source=plugin_sources,
# libraries to link to
LIBS=libraries,
# any custom linkflags, eg. LDFLAGS
# in this case CUSTOM_LDFLAGS comes
# from Mapnik's main SConstruct file
# and can be removed here if you do
# not need it
LINKFLAGS=env.get('CUSTOM_LDFLAGS')
LIBS=libraries
)
# if the plugin links to libmapnik ensure it is built first

View file

@ -58,8 +58,7 @@ else:
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
LIBS=libraries)
# if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -374,15 +374,12 @@ else:
# clone the env one more time to isolate mapnik_lib_link_flag
lib_env_final = lib_env.Clone()
if env['CUSTOM_LDFLAGS']:
lib_env_final.Prepend(LINKFLAGS='%s %s' % (env['CUSTOM_LDFLAGS'], mapnik_lib_link_flag))
else:
lib_env_final.Prepend(LINKFLAGS=mapnik_lib_link_flag)
lib_env_final.Prepend(LINKFLAGS=mapnik_lib_link_flag)
# cache library values for other builds to use
env['LIBMAPNIK_LIBS'] = copy(lib_env['LIBS'])
env['LIBMAPNIK_LINKFLAGS'] = copy(lib_env['LINKFLAGS'])
env.Append(LIBMAPNIK_LINKFLAGS=env['CUSTOM_LDFLAGS'])
env['LIBMAPNIK_CXXFLAGS'] = libmapnik_cxxflags
env['LIBMAPNIK_DEFINES'] = libmapnik_defines

View file

@ -36,12 +36,12 @@ else:
agg_env.Append(CPPPATH = '#deps/agg/include')
agg_env.Append(LIBPATH = '#deps/agg')
agg_env['CPPPATH'] = ['#deps/agg/include',env['BOOST_INCLUDES']]
test_program = agg_env.Program(name, source=source_files, LINKFLAGS=env['CUSTOM_LDFLAGS'])
test_program = agg_env.Program(name, source=source_files)
else:
test_env_local = test_env.Clone()
if 'csv_parse' in cpp_test:
source_files += glob.glob('../../plugins/input/csv/' + '*.cpp')
test_program = test_env_local.Program(name, source=source_files, LINKFLAGS=env['CUSTOM_LDFLAGS'])
test_program = test_env_local.Program(name, source=source_files)
Depends(test_program, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
# build locally if installing
if 'install' in COMMAND_LINE_TARGETS:

View file

@ -4,15 +4,12 @@ from copy import copy
Import ('env')
headers = env['CPPPATH']
filesystem = 'boost_filesystem%s' % env['BOOST_APPEND']
system = 'boost_system%s' % env['BOOST_APPEND']
regex = 'boost_regex%s' % env['BOOST_APPEND']
libraries = copy(env['LIBMAPNIK_LIBS'])
libraries.append('mapnik')
for cpp_test in glob.glob('*_test.cpp'):
test_program = 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], LIBS=libraries)
Depends(test_program, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -51,7 +51,7 @@ dep_includes += ' '
if config_env['HAS_CAIRO']:
dep_includes += ''.join([' -I%s' % i for i in env['CAIRO_CPPPATHS'] if not i.startswith('#')])
ldflags = config_env['CUSTOM_LDFLAGS'] + ''.join([' -L%s' % i for i in config_env['LIBPATH'] if not i.startswith('#')])
ldflags = ''.join([' -L%s' % i for i in config_env['LIBPATH'] if not i.startswith('#')])
ldflags += config_env['LIBMAPNIK_LINKFLAGS']
dep_libs = ''.join([' -l%s' % i for i in env['LIBMAPNIK_LIBS']])

View file

@ -46,7 +46,7 @@ if env['RUNTIME_LINK'] == 'static':
cmd = 'gdal-config --dep-libs'
program_env.ParseConfig(cmd)
ogrindex = program_env.Program('ogrindex', source, CPPPATH=headers, LINKFLAGS=env['CUSTOM_LDFLAGS'])
ogrindex = program_env.Program('ogrindex', source, CPPPATH=headers)
Depends(ogrindex, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -54,9 +54,8 @@ if env.get('BOOST_LIB_VERSION_FROM_HEADER'):
boost_system = 'boost_system%s' % env['BOOST_APPEND']
libraries.extend([boost_system])
linkflags = env['CUSTOM_LDFLAGS']
if env['SQLITE_LINKFLAGS']:
linkflags.append(env['SQLITE_LINKFLAGS'])
program_env.Append(LINKFLAGS=env['SQLITE_LINKFLAGS'])
if env['RUNTIME_LINK'] == 'static':
if env['PLATFORM'] == 'Darwin':
@ -66,7 +65,7 @@ if env['RUNTIME_LINK'] == 'static':
program_env.ParseConfig('pg_config --libs')
libraries.append('dl')
pgsql2sqlite = program_env.Program('pgsql2sqlite', source, LIBS=libraries, LINKFLAGS=linkflags)
pgsql2sqlite = program_env.Program('pgsql2sqlite', source, LIBS=libraries)
Depends(pgsql2sqlite, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS:

View file

@ -52,7 +52,7 @@ if env.get('BOOST_LIB_VERSION_FROM_HEADER'):
# https://github.com/mapnik/mapnik/issues/1082
program_env.Append(CXXFLAGS = '-fpermissive')
shapeindex = program_env.Program('shapeindex', source, CPPPATH=headers, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
shapeindex = program_env.Program('shapeindex', source, CPPPATH=headers, LIBS=libraries)
Depends(shapeindex, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -46,7 +46,7 @@ libraries.extend(copy(env['LIBMAPNIK_LIBS']))
if env['RUNTIME_LINK'] == 'static' and env['PLATFORM'] == 'Linux':
libraries.append('dl')
svg2png = program_env.Program('svg2png', source, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
svg2png = program_env.Program('svg2png', source, LIBS=libraries)
Depends(svg2png, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))