import os Import('env') # Build environment configuration -------------------------------------------- # The directory of this SConscript should be searched first for any headers. env.PrependUnique(CPPPATH=Dir('.')) # Insert LIBRARY_PATH explicitly because some compilers # ignore it in the system environment. env.PrependUnique(LIBPATH=env['ENV'].get('LIBRARY_PATH', '').split(':')) # Use Intel C++ compiler when it is available icpc = env.WhereIs('icpc') if icpc: env.Tool('intelc', topdir=icpc[:icpc.rfind('/bin')]) # Declare external libraries. env.ParseConfig("python-config --includes") env.ParseConfig("python-config --ldflags") env.ParseConfig("gsl-config --cflags --libs") fast_linkflags = ['-s'] # Platform specific intricacies. if env['PLATFORM'] == 'darwin': fixmacflags = lambda x: (str(x) not in ('-u', '_PyMac_Error')) env.Replace(CCFLAGS=filter(fixmacflags, env['CCFLAGS'])) env.Replace(LIBS=filter(fixmacflags, env['LIBS'])) fast_linkflags[:] = [] # configure version specific options. if not (GetOption('clean') or env.GetOption('help')): SConscript('SConscript.configure') # Compiler specific options if icpc: # options for Intel C++ compiler on hpc dev-intel07 env.PrependUnique(CCFLAGS=['-w1', '-fp-model', 'precise']) env.PrependUnique(LIBS=['imf']) fast_optimflags = ['-fast', '-no-ipo'] else: # g++ options env.PrependUnique(CCFLAGS=['-Wall']) fast_optimflags = ['-ffast-math'] # Configure build variants if env['build'] == 'debug': env.Append(CCFLAGS='-g') elif env['build'] == 'fast': env.AppendUnique(CCFLAGS=['-O3'] + fast_optimflags) env.AppendUnique(CPPDEFINES={'NDEBUG' : None}) env.AppendUnique(LINKFLAGS=fast_linkflags) if env['profile']: env.AppendUnique(CCFLAGS='-pg') env.AppendUnique(LINKFLAGS='-pg') # Define lists for storing library source and include files. env['lib_includes'] = [] env['lib_sources'] = [] env['lib_datafiles'] = [] # Subsidiary SConscripts ----------------------------------------------------- # Load the version script first to resolve the majorminor tuple SConscript('diffpy/SConscript.version') # Path where datafiles should be installed env['runtimepath'] = os.path.join( env['datadir'], 'diffpy/libdiffpy%i%i' % env['majorminor']) SConscript('runtime/SConscript') # Load all other sconscripts that update lib_includes and lib_sources SConscript('diffpy/SConscript') # Top Level Targets ---------------------------------------------------------- # lib -- shared library object libdiffpy = env.SharedLibrary('diffpy', env['lib_sources']) Export('libdiffpy') Alias('lib', libdiffpy) # Define targets related to testing. Do so only when testing is requested. # This enables library build on machines without cxxtest. if set(('test', 'alltests')).intersection(COMMAND_LINE_TARGETS): SConscript('tests/SConscript') # Installation targets. prefix = env['prefix'] # install-lib libinstall = Install(env['libdir'], libdiffpy) if env['PLATFORM'] == 'darwin': env.AddPostAction(libinstall, 'install_name_tool -id $TARGET.abspath $TARGET') Alias('install-lib', libinstall) # install-includes ninc = len(Dir('.').path) + 1 inc_target_path = lambda f: os.path.join(env['includedir'], f.path[ninc:]) include_targets = map(inc_target_path, env['lib_includes']) Alias('install-include', InstallAs(include_targets, env['lib_includes'])) # install-data nrt = len(Dir('runtime').path) + 1 data_target_path = lambda f: os.path.join(env['runtimepath'], f.path[nrt:]) data_targets = map(data_target_path, env['lib_datafiles']) Alias('install-data', InstallAs(data_targets, env['lib_datafiles'])) # install Alias('install', ['install-include', 'install-lib', 'install-data']) # vim: ft=python