#-*-python-*- # ROOT configuration for SCons from distutils.version import LooseVersion import os.path import subprocess from buildhelp import ROOTARCH, RATROOT, ROOTSYS #### Builder: RootDict(dictionary_name, [list of header files]) # # Produces a ROOT dictionary for the header files listed. Include # LinkDef.h at the end if needed to control dictionary generation def generate_action(source, target, env, for_signature): 'Generates rootcint call to output ROOT dictionary for source.' # Strip off leading include/ sources = [str(s).replace('include/','') for s in source] return os.path.join(ROOTSYS, 'rootcint') + ' -f ' + str(target[0]) \ + ' -c -p $_CPPINCFLAGS $_CCFLAGS $_CPPDEFFLAGS ' + ' '.join(sources) rootdict = Builder(generator = generate_action, src_suffix = '.hh') #### # Obtain ROOT build flags rootenv = Environment() # Temporary SCons object to parse root-config output rootenv.ParseConfig(os.path.join(ROOTSYS, 'root-config') + " --cflags --ldflags --libs") root_version = LooseVersion(subprocess.Popen(["root-config", "--version"], stdout=subprocess.PIPE).communicate()[0].rstrip()) root_target_min = LooseVersion("5.34") root_target_max = LooseVersion("6") if not root_target_min <= root_version < root_target_max: print "Warning: Wrong ROOT version used,", root_version, "it should be", "%s/*" % root_target_min # Put it into form that can be easily merged into main environment rootopts = { 'BUILDERS' : {'RootDict' : rootdict} } for key in ['ASFLAGS','CCFLAGS','CPPPATH','LIBPATH','LIBS', 'LINKFLAGS']: rootopts[key] = rootenv[key] if rootenv.has_key('CPPDEFINES'): rootopts['CPPDEFINES'] = rootenv['CPPDEFINES'] rootopts['LIBS'].append('-lMinuit2') rootopts['LIBS'].append('-lFFTW') # fast Fourier transform library rootopts['LIBS'].append('-lSpectrum') rootopts['LIBS'].append('-lPyROOT') rootopts['LIBS'].append('-lMathCore') rootopts['LIBS'].append('-lMathMore') # ROOT headers use long long as 64 bit data type, which g++ complains # is C99 but not ISO C++ data type. Need this flag to get things to # compile if ROOTARCH.find("gcc") >= 0: rootopts['CCFLAGS'].append('-Wno-long-long') if root_version >= LooseVersion("6"): rootopts['USE_ROOT6'] = True # Need to use c++11 rootopts['CXXFLAGS'] = '-std=c++11' else: rootopts['USE_ROOT6'] = False # Returns a dictionary when you import this file using: # rootopts = SConscript('config/ROOT.scons') # # Merge into your build environment with: # env.Append(rootopts) Return("rootopts")