add LINKING option to control whether libmapnik is build static or shared and RUNTIME_LINK options to trigger dependency flags to compile against static libs
This commit is contained in:
parent
17e5fb7302
commit
82ac99611e
14 changed files with 62 additions and 30 deletions
23
SConstruct
23
SConstruct
|
@ -291,6 +291,8 @@ opts.AddVariables(
|
|||
('CC', 'The C compiler used for configure checks of C libs (defaults to gcc).', 'gcc'),
|
||||
('CUSTOM_CXXFLAGS', 'Custom C++ flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir>', ''),
|
||||
('CUSTOM_LDFLAGS', 'Custom linker flags, e.g. -L<lib dir> if you have libraries in a nonstandard directory <lib dir>', ''),
|
||||
EnumVariable('LINKING', "Set library format for libmapnik",'shared', ['shared','static']),
|
||||
EnumVariable('RUNTIME_LINK', "Set preference for linking dependecies",'shared', ['shared','static']),
|
||||
EnumVariable('OPTIMIZATION','Set g++ optimization level','3', ['0','1','2','3','4','s']),
|
||||
# Note: setting DEBUG=True will override any custom OPTIMIZATION level
|
||||
BoolVariable('DEBUG', 'Compile a debug version of Mapnik', 'False'),
|
||||
|
@ -393,6 +395,9 @@ pickle_store = [# Scons internal variables
|
|||
'LINKFLAGS',
|
||||
'CUSTOM_LDFLAGS', # user submitted
|
||||
'CUSTOM_CXXFLAGS', # user submitted
|
||||
'MAPNIK_LIB_NAME',
|
||||
'LINK',
|
||||
'RUNTIME_LINK',
|
||||
# Mapnik's SConstruct build variables
|
||||
'PLUGINS',
|
||||
'ABI_VERSION',
|
||||
|
@ -597,6 +602,7 @@ def get_pkg_lib(context, config, lib):
|
|||
return libname
|
||||
|
||||
def parse_pg_config(context, config):
|
||||
# TODO - leverage `LDFLAGS_SL` if RUNTIME_LINK==static
|
||||
env = context.env
|
||||
tool = config.lower()
|
||||
context.Message( 'Checking for %s... ' % tool)
|
||||
|
@ -604,8 +610,8 @@ def parse_pg_config(context, config):
|
|||
if ret:
|
||||
lib_path = call('%s --libdir' % env[config])
|
||||
inc_path = call('%s --includedir' % env[config])
|
||||
env.AppendUnique(CPPPATH = inc_path)
|
||||
env.AppendUnique(LIBPATH = lib_path)
|
||||
env.AppendUnique(CPPPATH = os.path.realpath(inc_path))
|
||||
env.AppendUnique(LIBPATH = os.path.realpath(lib_path))
|
||||
lpq = env['PLUGINS']['postgis']['lib']
|
||||
env.Append(LIBS = lpq)
|
||||
else:
|
||||
|
@ -936,6 +942,11 @@ if not preconfigured:
|
|||
env['HAS_PYCAIRO'] = False
|
||||
env['HAS_LIBXML2'] = False
|
||||
env['SVN_REVISION'] = None
|
||||
if env['LINKING'] == 'static':
|
||||
env['MAPNIK_LIB_NAME'] = '${LIBPREFIX}mapnik2${LIBSUFFIX}'
|
||||
else:
|
||||
env['MAPNIK_LIB_NAME'] = '${SHLIBPREFIX}mapnik2${SHLIBSUFFIX}'
|
||||
|
||||
|
||||
env['LIBDIR_SCHEMA'] = LIBDIR_SCHEMA
|
||||
env['PLUGINS'] = PLUGINS
|
||||
|
@ -984,8 +995,8 @@ if not preconfigured:
|
|||
for required in ('PNG', 'JPEG', 'TIFF','PROJ','ICU'):
|
||||
inc_path = env['%s_INCLUDES' % required]
|
||||
lib_path = env['%s_LIBS' % required]
|
||||
env.AppendUnique(CPPPATH = inc_path)
|
||||
env.AppendUnique(LIBPATH = lib_path)
|
||||
env.AppendUnique(CPPPATH = os.path.realpath(inc_path))
|
||||
env.AppendUnique(LIBPATH = os.path.realpath(lib_path))
|
||||
|
||||
conf.parse_config('FREETYPE_CONFIG')
|
||||
|
||||
|
@ -1140,7 +1151,7 @@ if not preconfigured:
|
|||
# Note, the 'delete_existing' keyword makes sure that these paths are prepended
|
||||
# to the beginning of the path list even if they already exist
|
||||
incpath = env['%s_INCLUDES' % details['path']]
|
||||
env.PrependUnique(CPPPATH = incpath,delete_existing=True)
|
||||
env.PrependUnique(CPPPATH = os.path.realpath(incpath),delete_existing=True)
|
||||
env.PrependUnique(LIBPATH = env['%s_LIBS' % details['path']],delete_existing=True)
|
||||
if not conf.CheckLibWithHeader(details['lib'], details['inc'], details['lang']):
|
||||
env.Replace(**backup)
|
||||
|
@ -1369,7 +1380,7 @@ if not preconfigured:
|
|||
# as they are later set in the python SConscript
|
||||
# ugly hack needed until we have env specific conf
|
||||
backup = env.Clone().Dictionary()
|
||||
env.AppendUnique(CPPPATH = env['PYTHON_INCLUDES'])
|
||||
env.AppendUnique(CPPPATH = os.path.realpath(env['PYTHON_INCLUDES']))
|
||||
|
||||
if not conf.CheckHeader(header='Python.h',language='C'):
|
||||
color_print(1,'Could not find required header files for the Python language (version %s)' % env['PYTHON_VERSION'])
|
||||
|
|
|
@ -197,7 +197,10 @@ if env['SVN_REVISION']:
|
|||
|
||||
if env['HAS_CAIRO'] or env['HAS_PYCAIRO']:
|
||||
# attach libs to _mapnik.so linking environment
|
||||
py_env.ParseConfig('pkg-config --libs cairomm-1.0')
|
||||
cmd = 'pkg-config --libs cairomm-1.0'
|
||||
if lib_env['RUNTIME_LINK'] == 'static':
|
||||
cmd += ' --static'
|
||||
py_env.ParseConfig(cmd)
|
||||
env2 = py_env.Clone()
|
||||
fixup = ['mapnik_image.cpp','python_cairo.cpp']
|
||||
if not env['SVN_REVISION']:
|
||||
|
|
|
@ -33,16 +33,21 @@ gdal_src = Split(
|
|||
"""
|
||||
)
|
||||
|
||||
libraries = [env['PLUGINS']['gdal']['lib']]
|
||||
# clear out and rebuild libs
|
||||
plugin_env['LIBS'] = [env['PLUGINS']['gdal']['lib']]
|
||||
|
||||
# Link Library to Dependencies
|
||||
libraries.append('mapnik2')
|
||||
libraries.append(env['ICU_LIB_NAME'])
|
||||
plugin_env['LIBS'].append('mapnik2')
|
||||
plugin_env['LIBS'].append(env['ICU_LIB_NAME'])
|
||||
|
||||
input_plugin = plugin_env.SharedLibrary('../gdal', source=gdal_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
|
||||
if env['RUNTIME_LINK'] == 'static':
|
||||
cmd = 'gdal-config --dep-libs'
|
||||
plugin_env.ParseConfig(cmd)
|
||||
|
||||
input_plugin = plugin_env.SharedLibrary('../gdal', source=gdal_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LINKFLAGS=env['CUSTOM_LDFLAGS'])
|
||||
|
||||
# if the plugin links to libmapnik2 ensure it is built first
|
||||
Depends(input_plugin, env.subst('../../../src/${SHLIBPREFIX}mapnik2${SHLIBSUFFIX}'))
|
||||
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
|
||||
|
||||
if 'uninstall' not in COMMAND_LINE_TARGETS:
|
||||
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', input_plugin)
|
||||
|
|
|
@ -45,7 +45,7 @@ libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
|
|||
input_plugin = plugin_env.SharedLibrary('../geos', source=geos_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
|
||||
|
||||
# if the plugin links to libmapnik2 ensure it is built first
|
||||
Depends(input_plugin, env.subst('../../../src/${SHLIBPREFIX}mapnik2${SHLIBSUFFIX}'))
|
||||
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
|
||||
|
||||
if 'uninstall' not in COMMAND_LINE_TARGETS:
|
||||
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', input_plugin)
|
||||
|
|
|
@ -42,7 +42,7 @@ libraries.append('boost_thread%s' % env['BOOST_APPEND'])
|
|||
input_plugin = plugin_env.SharedLibrary('../kismet', source=kismet_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
|
||||
|
||||
# if the plugin links to libmapnik2 ensure it is built first
|
||||
Depends(input_plugin, env.subst('../../../src/${SHLIBPREFIX}mapnik2${SHLIBSUFFIX}'))
|
||||
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
|
||||
|
||||
if 'uninstall' not in COMMAND_LINE_TARGETS:
|
||||
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', input_plugin)
|
||||
|
|
|
@ -43,7 +43,7 @@ libraries.append(env['ICU_LIB_NAME'])
|
|||
input_plugin = plugin_env.SharedLibrary('../occi', source=occi_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
|
||||
|
||||
# if the plugin links to libmapnik2 ensure it is built first
|
||||
Depends(input_plugin, env.subst('../../../src/${SHLIBPREFIX}mapnik2${SHLIBSUFFIX}'))
|
||||
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
|
||||
|
||||
if 'uninstall' not in COMMAND_LINE_TARGETS:
|
||||
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', input_plugin)
|
||||
|
|
|
@ -36,18 +36,22 @@ ogr_src = Split(
|
|||
"""
|
||||
)
|
||||
|
||||
libraries = [env['PLUGINS']['ogr']['lib']]
|
||||
plugin_env['LIBS'] = [env['PLUGINS']['ogr']['lib']]
|
||||
|
||||
# Link Library to Dependencies
|
||||
libraries.append('mapnik2')
|
||||
libraries.append(env['ICU_LIB_NAME'])
|
||||
libraries.append('boost_system%s' % env['BOOST_APPEND'])
|
||||
libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
|
||||
plugin_env['LIBS'].append('mapnik2')
|
||||
plugin_env['LIBS'].append(env['ICU_LIB_NAME'])
|
||||
plugin_env['LIBS'].append('boost_system%s' % env['BOOST_APPEND'])
|
||||
plugin_env['LIBS'].append('boost_filesystem%s' % env['BOOST_APPEND'])
|
||||
|
||||
input_plugin = plugin_env.SharedLibrary('../ogr', source=ogr_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
|
||||
if env['RUNTIME_LINK'] == 'static':
|
||||
cmd = 'gdal-config --dep-libs'
|
||||
plugin_env.ParseConfig(cmd)
|
||||
|
||||
input_plugin = plugin_env.SharedLibrary('../ogr', source=ogr_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LINKFLAGS=env['CUSTOM_LDFLAGS'])
|
||||
|
||||
# if the plugin links to libmapnik2 ensure it is built first
|
||||
Depends(input_plugin, env.subst('../../../src/${SHLIBPREFIX}mapnik2${SHLIBSUFFIX}'))
|
||||
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
|
||||
|
||||
if 'uninstall' not in COMMAND_LINE_TARGETS:
|
||||
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', input_plugin)
|
||||
|
|
|
@ -45,7 +45,7 @@ libraries.append(env['ICU_LIB_NAME'])
|
|||
input_plugin = plugin_env.SharedLibrary('../osm', source=osm_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
|
||||
|
||||
# if the plugin links to libmapnik2 ensure it is built first
|
||||
Depends(input_plugin, env.subst('../../../src/${SHLIBPREFIX}mapnik2${SHLIBSUFFIX}'))
|
||||
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
|
||||
|
||||
if 'uninstall' not in COMMAND_LINE_TARGETS:
|
||||
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', input_plugin)
|
||||
|
|
|
@ -44,7 +44,7 @@ if env['THREADING'] == 'multi':
|
|||
input_plugin = plugin_env.SharedLibrary('../postgis', source=postgis_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
|
||||
|
||||
# if the plugin links to libmapnik2 ensure it is built first
|
||||
Depends(input_plugin, env.subst('../../../src/${SHLIBPREFIX}mapnik2${SHLIBSUFFIX}'))
|
||||
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
|
||||
|
||||
if 'uninstall' not in COMMAND_LINE_TARGETS:
|
||||
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', input_plugin)
|
||||
|
|
|
@ -44,7 +44,7 @@ libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
|
|||
input_plugin = plugin_env.SharedLibrary('../raster', source=raster_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
|
||||
|
||||
# if the plugin links to libmapnik2 ensure it is built first
|
||||
Depends(input_plugin, env.subst('../../../src/${SHLIBPREFIX}mapnik2${SHLIBSUFFIX}'))
|
||||
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
|
||||
|
||||
if 'uninstall' not in COMMAND_LINE_TARGETS:
|
||||
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', input_plugin)
|
||||
|
|
|
@ -44,7 +44,7 @@ libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
|
|||
input_plugin = plugin_env.SharedLibrary('../rasterlite', source=rasterlite_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
|
||||
|
||||
# if the plugin links to libmapnik2 ensure it is built first
|
||||
Depends(input_plugin, env.subst('../../../src/${SHLIBPREFIX}mapnik2${SHLIBSUFFIX}'))
|
||||
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
|
||||
|
||||
if 'uninstall' not in COMMAND_LINE_TARGETS:
|
||||
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', input_plugin)
|
||||
|
|
|
@ -51,7 +51,7 @@ if env['SHAPE_MEMORY_MAPPED_FILE']:
|
|||
input_plugin = plugin_env.SharedLibrary('../shape', SHLIBSUFFIX='.input', source=shape_src, SHLIBPREFIX='', LIBS = libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
|
||||
|
||||
# if the plugin links to libmapnik2 ensure it is built first
|
||||
Depends(input_plugin, env.subst('../../../src/${SHLIBPREFIX}mapnik2${SHLIBSUFFIX}'))
|
||||
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
|
||||
|
||||
if 'uninstall' not in COMMAND_LINE_TARGETS:
|
||||
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', input_plugin)
|
||||
|
|
|
@ -44,7 +44,7 @@ libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
|
|||
input_plugin = plugin_env.SharedLibrary('../sqlite', source=sqlite_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
|
||||
|
||||
# if the plugin links to libmapnik2 ensure it is built first
|
||||
Depends(input_plugin, env.subst('../../../src/${SHLIBPREFIX}mapnik2${SHLIBSUFFIX}'))
|
||||
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
|
||||
|
||||
if 'uninstall' not in COMMAND_LINE_TARGETS:
|
||||
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', input_plugin)
|
||||
|
|
|
@ -224,7 +224,10 @@ if env['SVG_RENDERER']: # svg backend
|
|||
if env['HAS_CAIRO']:
|
||||
# attach libs to library linking environment
|
||||
try:
|
||||
lib_env.ParseConfig('pkg-config --libs cairomm-1.0')
|
||||
cmd = 'pkg-config --libs cairomm-1.0'
|
||||
if lib_env['RUNTIME_LINK'] == 'static':
|
||||
cmd += ' --static'
|
||||
lib_env.ParseConfig(cmd)
|
||||
env2 = lib_env.Clone()
|
||||
env2.Append(CXXFLAGS = '-DHAVE_CAIRO')
|
||||
# attach cflags to specific compile environment
|
||||
|
@ -264,6 +267,12 @@ if env['CUSTOM_LDFLAGS']:
|
|||
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)
|
||||
else:
|
||||
mapnik = lib_env.SharedLibrary('mapnik2', source, LIBS=libraries, LINKFLAGS=linkflags)
|
||||
|
||||
if env['PLATFORM'] != 'Darwin':
|
||||
|
|
Loading…
Reference in a new issue