65
81
SCONS_CONFIGURE_CACHE = 'config.cache'
66
82
# directory SCons uses to stash build tests
67
83
SCONF_TEMP_DIR = '.sconf_temp'
84
# auto-search directories for boost libs/headers
85
BOOST_SEARCH_PREFIXES = ['/usr/local','/opt/local','/sw','/usr',]
69
88
# Core plugin build configuration
70
89
# opts.AddVariables still hardcoded however...
80
99
'osm': {'default':False,'path':None,'inc':None,'lib':None,'lang':'C++'},
81
100
'shape': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
82
101
'raster': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
102
'kismet': {'default':False,'path':None,'inc':None,'lib':None,'lang':'C++'},
85
105
DEFAULT_PLUGINS = []
98
114
opts.AddVariables(
99
115
# Compiler options
100
116
('CXX', 'The C++ compiler to use (defaults to g++).', 'g++'),
101
EnumVariable('OPTIMIZATION','Set g++ optimization level','2', ['0','1','2','3']),
117
EnumVariable('OPTIMIZATION','Set g++ optimization level','2', ['0','1','2','3','4']),
102
118
# Note: setting DEBUG=True will override any custom OPTIMIZATION level
103
119
BoolVariable('DEBUG', 'Compile a debug version of Mapnik', 'False'),
104
120
BoolVariable('XML_DEBUG', 'Compile a XML verbose debug version of mapnik', 'False'),
115
131
('DESTDIR', 'The root directory to install into. Useful mainly for binary package building', '/'),
117
133
# Boost variables
118
PathVariable('BOOST_INCLUDES', 'Search path for boost include files', '/usr/include', PathVariable.PathAccept),
119
PathVariable('BOOST_LIBS', 'Search path for boost library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept),
134
# default is '/usr/include', see FindBoost method below
135
('BOOST_INCLUDES', 'Search path for boost include files', '',False),
136
# default is '/usr/' + LIBDIR_SCHEMA, see FindBoost method below
137
('BOOST_LIBS', 'Search path for boost library files', '',False),
120
138
('BOOST_TOOLKIT','Specify boost toolkit, e.g., gcc41.','',False),
121
139
('BOOST_ABI', 'Specify boost ABI, e.g., d.','',False),
122
140
('BOOST_VERSION','Specify boost version, e.g., 1_35.','',False),
134
152
PathVariable('TIFF_LIBS', 'Search path for libtiff library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept),
135
153
PathVariable('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/local/include', PathVariable.PathAccept),
136
154
PathVariable('PROJ_LIBS', 'Search path for PROJ.4 library files', '/usr/local/' + LIBDIR_SCHEMA, PathVariable.PathAccept),
155
('PKG_CONFIG_PATH', 'Use this path to point pkg-config to .pc files instead of the PKG_CONFIG_PATH environment setting',''),
138
157
# Variables affecting rendering back-ends
139
158
BoolVariable('INTERNAL_LIBAGG', 'Use provided libagg', 'True'),
150
169
PathVariable('SQLITE_LIBS', 'Search path for SQLITE library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept),
152
171
# Other variables
172
BoolVariable('SHAPE_MEMORY_MAPPED_FILE', 'Utilize memory-mapped files in Shapefile Plugin (higher memory usage, better performance)', 'True'),
153
173
('SYSTEM_FONTS','Provide location for python bindings to register fonts (if given aborts installation of bundled DejaVu fonts)',''),
154
('LIB_DIR_NAME','Name to use for lib folder where fonts and plugins are installed','/mapnik/'),
174
('LIB_DIR_NAME','Name to use for the "lib" folder where fonts and plugins are installed','/mapnik/'),
155
175
PathVariable('PYTHON','Full path to Python executable used to build bindings', sys.executable),
156
BoolVariable('FRAMEWORK_PYTHON', 'Link against Framework Python on Mac OSX', 'True'),
176
BoolVariable('FRAMEWORK_PYTHON', 'Link against Framework Python on Mac OS X', 'True'),
177
PathVariable('FRAMEWORK_SEARCH_PATH','Top framework search path on Mac OS X', '/'),
178
BoolVariable('FULL_LIB_PATH', 'Use the full path for the libmapnik.dylib "install_name" when linking on Mac OS X', 'True'),
157
179
ListVariable('BINDINGS','Language bindings to build','all',['python']),
158
180
EnumVariable('THREADING','Set threading support','multi', ['multi','single']),
159
181
EnumVariable('XMLPARSER','Set xml parser ','libxml2', ['tinyxml','spirit','libxml2']),
160
182
('JOBS', 'Set the number of parallel compilations', "1", lambda key, value, env: int(value), int),
161
183
BoolVariable('DEMO', 'Compile demo c++ application', 'False'),
162
184
BoolVariable('PGSQL2SQLITE', 'Compile and install a utility to convert postgres tables to sqlite', 'False'),
185
BoolVariable('COLOR_PRINT', 'Print build status information in color', 'True'),
164
187
# variables to pickle after successful configure step
165
188
# these include all scons core variables as well as custom
331
361
if item.key == variable:
332
362
env[variable] = item.default
364
def FindBoost(context, prefixes):
365
"""Routine to auto-find boost header dir, lib dir, and library naming structure.
368
context.Message( 'Searching for boost libs and headers... ' )
372
BOOST_INCLUDE_DIR = None
374
env['BOOST_APPEND'] = str()
376
for searchDir in prefixes:
377
libItems = glob(os.path.join(searchDir, LIBDIR_SCHEMA, 'libboost_filesystem*-*.*'))
379
libItems = glob(os.path.join(searchDir, 'lib/libboost_filesystem*-*.*'))
380
incItems = glob(os.path.join(searchDir, 'include/boost*/'))
381
if len(libItems) >= 1 and len(incItems) >= 1:
382
BOOST_LIB_DIR = os.path.dirname(libItems[0])
383
BOOST_INCLUDE_DIR = incItems[0].rstrip('boost/')
384
shortest_lib_name = shortest_name(libItems)
385
match = re.search(r'libboost_filesystem-(.*)\..*', shortest_lib_name)
386
if hasattr(match,'groups'):
387
BOOST_APPEND = match.groups()[0]
392
if not env['BOOST_LIBS']:
394
msg += '\n *libs found: %s' % BOOST_LIB_DIR
395
env['BOOST_LIBS'] = BOOST_LIB_DIR
397
env['BOOST_LIBS'] = '/usr' + LIBDIR_SCHEMA
399
msg += '\n *using boost lib dir: %s' % env['BOOST_LIBS']
401
if not env['BOOST_INCLUDES']:
402
if BOOST_INCLUDE_DIR:
403
msg += '\n *headers found: %s' % BOOST_INCLUDE_DIR
404
env['BOOST_INCLUDES'] = BOOST_INCLUDE_DIR
406
env['BOOST_INCLUDES'] = '/usr/include'
408
msg += '\n *using boost include dir: %s' % env['BOOST_INCLUDES']
410
if not env['BOOST_TOOLKIT'] and not env['BOOST_ABI'] and not env['BOOST_VERSION']:
412
msg += '\n *lib naming extension found: %s' % BOOST_APPEND
413
env['BOOST_APPEND'] = '-' + BOOST_APPEND
415
msg += '\n *no lib naming extension found'
417
# Creating BOOST_APPEND according to the Boost library naming order,
418
# which goes <toolset>-<threading>-<abi>-<version>. See:
419
# http://www.boost.org/doc/libs/1_35_0/more/getting_started/unix-variants.html#library-naming
421
if env['BOOST_TOOLKIT']: append_params.append(env['BOOST_TOOLKIT'])
422
if thread_flag: append_params.append(thread_flag)
423
if env['BOOST_ABI']: append_params.append(env['BOOST_ABI'])
424
if env['BOOST_VERSION']: append_params.append(env['BOOST_VERSION'])
426
# Constructing the BOOST_APPEND setting that will be used to find the
428
if len(append_params) > 1:
429
env['BOOST_APPEND'] = '-'.join(append_params)
430
msg += '\n *using boost lib naming: %s' % env['BOOST_APPEND']
432
env.AppendUnique(CPPPATH = env['BOOST_INCLUDES'])
433
env.AppendUnique(LIBPATH = env['BOOST_LIBS'])
434
if env['COLOR_PRINT']:
435
msg = "\033[94m%s\033[0m" % (msg)
436
ret = context.Result(msg)
334
439
def CheckBoost(context, version, silent=False):
335
440
# Boost versions are in format major.minor.subminor
336
441
v_arr = version.split(".")
513
623
env['CXX'] = 'CC -library=stlport4'
514
624
if env['THREADING'] == 'multi':
515
625
env['CXXFLAGS'] = ['-mt']
517
627
# Adding the required prerequisite library directories to the include path for
518
628
# compiling and the library path for linking, respectively.
519
for required in ('BOOST', 'PNG', 'JPEG', 'TIFF','PROJ','ICU'):
629
for required in ('PNG', 'JPEG', 'TIFF','PROJ','ICU'):
520
630
inc_path = env['%s_INCLUDES' % required]
521
631
lib_path = env['%s_LIBS' % required]
522
632
env.AppendUnique(CPPPATH = inc_path)
549
659
['icudata','unicode/utypes.h' , True,'C++'],
663
for libinfo in LIBSHEADERS:
664
if not conf.CheckLibWithHeader(libinfo[0], libinfo[1], libinfo[3]):
666
color_print (1,'Could not find required header or shared library for %s' % libinfo[0])
667
env['MISSING_DEPS'].append(libinfo[0])
669
color_print(4,'Could not find optional header or shared library for %s' % libinfo[0])
670
env['SKIPPED_DEPS'].append(libinfo[0])
672
if env['THREADING'] == 'multi':
673
thread_flag = thread_suffix
677
conf.FindBoost(BOOST_SEARCH_PREFIXES)
552
679
# get boost version from boost headers rather than previous approach
553
680
# of fetching from the user provided INCLUDE path
554
681
boost_system_required = False
572
701
if env['THREADING'] == 'multi':
573
702
BOOST_LIBSHEADERS.append(['thread', 'boost/thread/mutex.hpp', True])
574
thread_flag = thread_suffix
578
for libinfo in LIBSHEADERS:
579
if not conf.CheckLibWithHeader(libinfo[0], libinfo[1], libinfo[3]):
581
color_print (1,'Could not find required header or shared library for %s' % libinfo[0])
582
env['MISSING_DEPS'].append(libinfo[0])
584
color_print(4,'Could not find optional header or shared library for %s' % libinfo[0])
585
env['SKIPPED_DEPS'].append(libinfo[0])
587
# Creating BOOST_APPEND according to the Boost library naming order,
588
# which goes <toolset>-<threading>-<abi>-<version>. See:
589
# http://www.boost.org/doc/libs/1_35_0/more/getting_started/unix-variants.html#library-naming
591
if env['BOOST_TOOLKIT']: append_params.append(env['BOOST_TOOLKIT'])
592
if thread_flag: append_params.append(thread_flag)
593
if env['BOOST_ABI']: append_params.append(env['BOOST_ABI'])
594
if env['BOOST_VERSION']: append_params.append(env['BOOST_VERSION'])
596
704
# if the user is not setting custom boost configuration
597
# enforce boost version greater than or equal to 1.33
598
if not conf.CheckBoost('1.33'):
599
color_print (1,'Boost version 1.33 or greater is requred')
705
# enforce boost version greater than or equal to 1.34
706
if not conf.CheckBoost('1.34'):
707
color_print (1,'Boost version 1.34 or greater is requred')
600
708
if not env['BOOST_VERSION']:
601
env['MISSING_DEPS'].append('boost version >=1.33')
709
env['MISSING_DEPS'].append('boost version >=1.34')
603
711
color_print (4,'Found boost lib version... %s' % boost_lib_version_from_header )
605
# Constructing the BOOST_APPEND setting that will be used to find the
607
if len(append_params) > 1:
608
env['BOOST_APPEND'] = '-'.join(append_params)
610
env['BOOST_APPEND'] = ''
612
713
for count, libinfo in enumerate(BOOST_LIBSHEADERS):
613
714
if not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++'):
710
811
color_print(4,"Did not use user config file, no custom path variables will be saved...")
712
813
if env['SKIPPED_DEPS']:
713
color_print(1,'\nHowever, these optional dependencies were not found:\n - %s' % '\n - '.join(env['SKIPPED_DEPS']))
814
color_print(3,'\nNote: will build without these optional dependencies:\n - %s' % '\n - '.join(env['SKIPPED_DEPS']))
716
817
# fetch the mapnik version header in order to set the
717
818
# ABI version used to build libmapnik.so on linux in src/SConscript
718
819
abi = conf.GetMapnikLibVersion()
719
abi_fallback = [0,6,0]
820
abi_fallback = [0,6,1]
721
822
color_print(1,'Problem encountered parsing mapnik version, falling back to %s' % abi_fallback)
722
823
env['ABI_VERSION'] = abi_fallback
847
948
# Build the core library
848
949
SConscript('src/SConscript')
850
# Build the c++ rundemo app if requested
852
SConscript('demo/c++/SConscript')
854
# Build the pgsql2psqlite app if requested
855
if env['PGSQL2SQLITE']:
856
SConscript('utils/pgsql2sqlite/SConscript')
858
# Build shapeindex and remove its dependency from the LIBS
859
if 'boost_program_options%s' % env['BOOST_APPEND'] in env['LIBS']:
860
SConscript('utils/shapeindex/SConscript')
861
env['LIBS'].remove('boost_program_options%s' % env['BOOST_APPEND'])
863
color_print(1,"WARNING: Cannot find boost_program_options. 'shapeindex' won't be available")
951
# Build the requested and able-to-be-compiled input plug-ins
865
952
GDAL_BUILT = False
866
953
OGR_BUILT = False
867
# Build the requested and able-to-be-compiled input plug-ins
868
954
for plugin in env['REQUESTED_PLUGINS']:
869
955
details = env['PLUGINS'][plugin]
870
956
if details['lib'] in env['LIBS']:
879
965
elif not details['lib']:
880
966
# build internal shape and raster plugins
881
967
SConscript('plugins/input/%s/SConscript' % plugin)
969
# Build the c++ rundemo app if requested
971
SConscript('demo/c++/SConscript')
973
# Build the pgsql2psqlite app if requested
974
if env['PGSQL2SQLITE']:
975
SConscript('utils/pgsql2sqlite/SConscript')
977
# Build shapeindex and remove its dependency from the LIBS
978
if 'boost_program_options%s' % env['BOOST_APPEND'] in env['LIBS']:
979
SConscript('utils/shapeindex/SConscript')
980
env['LIBS'].remove('boost_program_options%s' % env['BOOST_APPEND'])
982
color_print(1,"WARNING: Cannot find boost_program_options. 'shapeindex' won't be available")
883
984
# Build the Python bindings
884
985
if 'python' in env['BINDINGS']: