From 346ac289470900d58afdc8035e98dc78e3b75645 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 17 Feb 2009 20:31:04 +0000 Subject: [PATCH] scons: make sure to check for boost_python (closes #229), improve checking of boost version (closes #236), and fetch ABI version from mapnik/version (closes #72), as well as adding PathAccept for all PathVariables to account for various 64bit systems. --- SConstruct | 138 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 111 insertions(+), 27 deletions(-) diff --git a/SConstruct b/SConstruct index 07a763545..900ddeea4 100644 --- a/SConstruct +++ b/SConstruct @@ -132,8 +132,8 @@ opts.Add(BoolVariable('SCONS_CACHE', 'Use SCons dependency caching to speed buil opts.Add(BoolVariable('USE_USER_ENV', 'Allow the SCons build env to inherit from the current user environment', 'True')) # Boost variables -opts.Add(PathVariable('BOOST_INCLUDES', 'Search path for boost include files', '/usr/include')) -opts.Add(PathVariable('BOOST_LIBS', 'Search path for boost library files', '/usr/' + LIBDIR_SCHEMA)) +opts.Add(PathVariable('BOOST_INCLUDES', 'Search path for boost include files', '/usr/include', PathVariable.PathAccept)) +opts.Add(PathVariable('BOOST_LIBS', 'Search path for boost library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept)) opts.Add('BOOST_TOOLKIT','Specify boost toolkit, e.g., gcc41.','',False) opts.Add('BOOST_ABI', 'Specify boost ABI, e.g., d.','',False) opts.Add('BOOST_VERSION','Specify boost version, e.g., 1_35.','',False) @@ -141,16 +141,16 @@ opts.Add('BOOST_VERSION','Specify boost version, e.g., 1_35.','',False) # Variables for required dependencies opts.Add(('FREETYPE_CONFIG', 'The path to the freetype-config executable.', 'freetype-config')) opts.Add(('XML2_CONFIG', 'The path to the xml2-config executable.', 'xml2-config')) -opts.Add(PathVariable('ICU_INCLUDES', 'Search path for ICU include files', '/usr/include')) -opts.Add(PathVariable('ICU_LIBS','Search path for ICU include files','/usr/' + LIBDIR_SCHEMA)) -opts.Add(PathVariable('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include')) -opts.Add(PathVariable('PNG_LIBS','Search path for libpng include files','/usr/' + LIBDIR_SCHEMA)) -opts.Add(PathVariable('JPEG_INCLUDES', 'Search path for libjpeg include files', '/usr/include')) -opts.Add(PathVariable('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/' + LIBDIR_SCHEMA)) -opts.Add(PathVariable('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include')) -opts.Add(PathVariable('TIFF_LIBS', 'Search path for libtiff library files', '/usr/' + LIBDIR_SCHEMA)) -opts.Add(PathVariable('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/local/include')) -opts.Add(PathVariable('PROJ_LIBS', 'Search path for PROJ.4 library files', '/usr/local/' + LIBDIR_SCHEMA)) +opts.Add(PathVariable('ICU_INCLUDES', 'Search path for ICU include files', '/usr/include', PathVariable.PathAccept)) +opts.Add(PathVariable('ICU_LIBS','Search path for ICU include files','/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept)) +opts.Add(PathVariable('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include', PathVariable.PathAccept)) +opts.Add(PathVariable('PNG_LIBS','Search path for libpng include files','/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept)) +opts.Add(PathVariable('JPEG_INCLUDES', 'Search path for libjpeg include files', '/usr/include', PathVariable.PathAccept)) +opts.Add(PathVariable('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept)) +opts.Add(PathVariable('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include', PathVariable.PathAccept)) +opts.Add(PathVariable('TIFF_LIBS', 'Search path for libtiff library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept)) +opts.Add(PathVariable('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/local/include', PathVariable.PathAccept)) +opts.Add(PathVariable('PROJ_LIBS', 'Search path for PROJ.4 library files', '/usr/local/' + LIBDIR_SCHEMA, PathVariable.PathAccept)) # Variables affecting rendering back-ends opts.Add(BoolVariable('INTERNAL_LIBAGG', 'Use provided libagg', 'True')) @@ -161,11 +161,11 @@ opts.Add(BoolVariable('INTERNAL_LIBAGG', 'Use provided libagg', 'True')) opts.Add(BoolVariable('CAIRO', 'Attempt to build with Cairo rendering support', 'True')) opts.Add(ListVariable('INPUT_PLUGINS','Input drivers to include',DEFAULT_PLUGINS,PLUGINS.keys())) opts.Add(PathVariable('PGSQL_INCLUDES', 'Search path for PostgreSQL include files', '/usr/include/postgresql', PathVariable.PathAccept)) -opts.Add(PathVariable('PGSQL_LIBS', 'Search path for PostgreSQL library files', '/usr/' + LIBDIR_SCHEMA)) +opts.Add(PathVariable('PGSQL_LIBS', 'Search path for PostgreSQL library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept)) opts.Add(PathVariable('GDAL_INCLUDES', 'Search path for GDAL include files', '/usr/local/include', PathVariable.PathAccept)) -opts.Add(PathVariable('GDAL_LIBS', 'Search path for GDAL library files', '/usr/local/' + LIBDIR_SCHEMA)) +opts.Add(PathVariable('GDAL_LIBS', 'Search path for GDAL library files', '/usr/local/' + LIBDIR_SCHEMA, PathVariable.PathAccept)) opts.Add(PathVariable('OGR_INCLUDES', 'Search path for OGR include files', '/usr/local/include', PathVariable.PathAccept)) -opts.Add(PathVariable('OGR_LIBS', 'Search path for OGR library files', '/usr/local/' + LIBDIR_SCHEMA)) +opts.Add(PathVariable('OGR_LIBS', 'Search path for OGR library files', '/usr/local/' + LIBDIR_SCHEMA, PathVariable.PathAccept)) opts.Add(PathVariable('OCCI_INCLUDES', 'Search path for OCCI include files', '/usr/lib/oracle/10.2.0.3/client/include', PathVariable.PathAccept)) opts.Add(PathVariable('OCCI_LIBS', 'Search path for OCCI library files', '/usr/lib/oracle/10.2.0.3/client/'+ LIBDIR_SCHEMA, PathVariable.PathAccept)) opts.Add(PathVariable('SQLITE_INCLUDES', 'Search path for SQLITE include files', '/usr/include/', PathVariable.PathAccept)) @@ -270,9 +270,76 @@ def CheckPKG(context, name): context.Result( ret ) return ret +def CheckBoost(context, version, silent=False): + # Boost versions are in format major.minor.subminor + v_arr = version.split(".") + version_n = 0 + if len(v_arr) > 0: + version_n += int(v_arr[0])*100000 + if len(v_arr) > 1: + version_n += int(v_arr[1])*100 + if len(v_arr) > 2: + version_n += int(v_arr[2]) + + if not silent: + context.Message('Checking for Boost version >= %s... ' % (version)) + ret = context.TryRun(""" + #include + int main() + { + return BOOST_VERSION >= %d ? 0 : 1; + } + """ % version_n, '.cpp')[0] + if silent: + context.did_show_result=1 + context.Result(ret) + return ret + +def GetBoostLibVersion(context): + ret = context.TryRun(""" + #include + #include + + int main() + { + std::cout << BOOST_LIB_VERSION << std::endl; + } + """, '.cpp') + # hack to avoid printed output + context.did_show_result=1 + context.Result(ret[0]) + return ret[1].strip() + +def GetMapnikLibVersion(context): + ret = context.TryRun(""" + #include + #include + + int main() + { + std::cout << MAPNIK_VERSION << std::endl; + } + """, '.cpp') + # hack to avoid printed output + context.did_show_result=1 + context.Result(ret[0]) + version = int(ret[1].strip()) + patch_level = version % 100 + minor_version = version / 100 % 1000 + major_version = version / 100000 + return [major_version, minor_version,patch_level] + conf = Configure(env, custom_tests = { 'CheckPKGConfig' : CheckPKGConfig, - 'CheckPKG' : CheckPKG }) + 'CheckPKG' : CheckPKG, + 'CheckBoost' : CheckBoost, + 'GetBoostLibVersion' : GetBoostLibVersion, + 'GetMapnikLibVersion' : GetMapnikLibVersion }) + + +# fetch the mapnik version header in order to set the +# ABI version used to build libmapnik.so on linux in src/SConscript +env['ABI_VERSION'] = conf.GetMapnikLibVersion() #### Libraries and headers dependency checks #### @@ -368,15 +435,16 @@ for plugin in requested_plugins: else: C_LIBSHEADERS.append(check) -# Test function for a particular Boost Version. -def test_boost_ver(ver): - return ver in env['BOOST_INCLUDES'] or ver in env['BOOST_VERSION'] -if ((test_boost_ver('1_35') or test_boost_ver('1_36')) and - env['PLATFORM'] == 'Darwin'): - boost_system_required = True -else: - boost_system_required = False +# get boost version from boost headers rather than previous approach +# of fetching from the user provided INCLUDE path +boost_lib_version_from_header = conf.GetBoostLibVersion() +if boost_lib_version_from_header: + boost_version_from_header = int(boost_lib_version_from_header.split('_')[1]) + if boost_version_from_header >= 35 and env['PLATFORM'] == 'Darwin': + boost_system_required = True + else: + boost_system_required = False # The other required boost headers. BOOST_LIBSHEADERS = [ @@ -386,7 +454,7 @@ BOOST_LIBSHEADERS = [ ['iostreams','boost/iostreams/device/mapped_file.hpp',True], ['program_options', 'boost/program_options.hpp', False] ] - + if env['THREADING'] == 'multi': BOOST_LIBSHEADERS.append(['thread', 'boost/thread/mutex.hpp', True]) thread_flag = thread_suffix @@ -439,7 +507,16 @@ if env['BOOST_TOOLKIT']: append_params.append(env['BOOST_TOOLKIT']) if thread_flag: append_params.append(thread_flag) if env['BOOST_ABI']: append_params.append(env['BOOST_ABI']) if env['BOOST_VERSION']: append_params.append(env['BOOST_VERSION']) - + +# if the user is not setting custom boost configuration +# enforce boost version greater than or equal to 1.33 +if not conf.CheckBoost('1.33'): + color_print (1,'Boost version 1.33 or greater is requred') + if not env['BOOST_VERSION']: + env['MISSING_DEPS'].append('boost version >=1.33') +else: + color_print (4,'Found boost lib version... %s' % boost_lib_version_from_header ) + # Constructing the BOOST_APPEND setting that will be used to find the # Boost libraries. if len(append_params) > 1: @@ -460,7 +537,14 @@ for count, libinfo in enumerate(BOOST_LIBSHEADERS): elif not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0], env['BOOST_APPEND']), libinfo[1], 'C++') : color_print(1,'Could not find header or shared library for boost %s' % libinfo[0]) env['MISSING_DEPS'].append('boost ' + libinfo[0]) - + +if 'python' in env['BINDINGS']: + # checklibwithheader does not work for boost_python since we can't feed it + # multiple header files, so we fall back on a simple check for boost_python headers + if not conf.CheckHeader(header='boost/python/detail/config.hpp',language='C++'): + color_print(1,'Could not find required header files for boost python') + env['MISSING_DEPS'].append('boost python') + #### End Config Stage #### if env['MISSING_DEPS']: