11from SCons.Script
import Configure, Environment
16def CheckEnvVar(conf, var, text=None):
17 """check for the existance of an environment variable"""
20 conf.Message(f
'Checking for {text}...')
22 conf.Message(f
'Checking for environment variable {var}...')
23 result = var
in conf.env[
'ENV']
28def CheckConfigTool(conf, tool):
29 """check for the existance of a tool"""
31 conf.Message(f
'Checking for {tool}...')
32 (result, version) = conf.TryAction(f
'{tool} --version')
37def CheckPackage(conf, package, text=None):
38 """check for the existance of a package via the pkg-config tool"""
42 conf.Message(f
'Checking for {text}...')
43 (result, output) = conf.TryAction(f
'pkg-config --exists {package}')
48def CheckFile(conf, dir, text=None):
49 """check for the existance a file"""
52 conf.Message(f
'Checking for {text}...')
54 conf.Message(f
'Checking for directory {dir}...')
55 if conf.env.FindFile(dir,
'.')
is None:
63def configure_belle2(conf):
64 """check the Belle II environment"""
67 if not conf.CheckEnvVar(
'BELLE2_TOOLS',
'Belle II environment setup'):
68 print(
'Belle II software environment is not set up.')
69 print(
'-> Source "setup_belle2" from the tools/ directory.')
73 if not conf.CheckEnvVar(
'BELLE2_ANALYSIS_DIR',
'analysis setup') \
74 and not conf.CheckEnvVar(
'BELLE2_LOCAL_DIR',
'local release setup'):
75 print(
'analysis or local release is not set up.')
76 print(
'-> Execute "b2setup" in your local analysis or release directory.')
82def configure_system(conf):
83 """configure the system packages"""
86 conf.env.ParseConfig(
'xml2-config --cflags')
87 xml_env = Environment(ENV=os.environ)
88 xml_env.ParseConfig(
'xml2-config --libs')
89 conf.env[
'XML_LIBS'] = xml_env[
'LIBS']
92 conf.env[
'HAS_TEVE'] =
False
93 conf.env[
'TEVE_LIBS'] = []
94 if conf.CheckLibWithHeader(
"Eve",
"TEveViewer.h", language=
"c++", autoadd=0, call=
"TEveViewer();"):
95 conf.env[
'HAS_TEVE'] =
True
96 conf.env[
'TEVE_LIBS'] = [
'Gui',
'Eve',
'Ged',
'RGL',
'TreePlayer']
99 conf.env[
'HAS_SQLITE'] =
False
100 conf.env[
'SQLITE_LIBS'] = []
101 if conf.CheckLibWithHeader(
'sqlite3',
'sqlite3.h',
'C',
102 'sqlite3_open_v2(":memory:",0,SQLITE_OPEN_READONLY,0);'
104 conf.env[
'HAS_SQLITE'] =
True
105 conf.env.Append(CPPDEFINES=
'-DHAS_SQLITE')
106 sqlite_env = Environment(ENV=os.environ)
107 sqlite_env.ParseConfig(
'pkg-config sqlite3 --libs')
108 conf.env[
'SQLITE_LIBS'] = sqlite_env[
'LIBS']
111 conf.env[
'HAS_CALLGRIND'] =
False
112 if conf.CheckHeader(
'valgrind/callgrind.h'):
113 conf.env[
'HAS_CALLGRIND'] =
True
114 conf.env.Append(CPPDEFINES=
'-DHAS_CALLGRIND')
117 conf.env[
'HAS_OPENMP'] =
False
118 if conf.CheckHeader(
'omp.h', language=
"C++"):
119 conf.env[
'HAS_OPENMP'] =
True
120 conf.env.Append(CPPDEFINES=
'-DHAS_OPENMP')
123 conf.env[
'HAS_DOT'] =
False
124 if conf.CheckProg(
'dot'):
125 conf.env[
'HAS_DOT'] =
True
130def configure_externals(conf):
131 """configure the external packages"""
134 extdir = conf.env[
'EXTDIR']
135 sys.path[:0] = [os.environ[
'BELLE2_TOOLS'], extdir]
136 from externals
import config_externals
137 return config_externals(conf)
138 except Exception
as e:
139 print(
'Configuration of externals failed:', e)
146 """configure the environment"""
148 conf = Configure(env, custom_tests={
149 'CheckEnvVar': CheckEnvVar,
150 'CheckConfigTool': CheckConfigTool,
151 'CheckPackage': CheckPackage,
152 'CheckFile': CheckFile,
155 if not configure_belle2(conf)
or not configure_externals(conf) \
156 or not configure_system(conf):