12 from SCons.Script
import Configure, Environment
17 def CheckEnvVar(conf, var, text=None):
18 """check for the existance of an environment variable"""
21 conf.Message(
'Checking for %s...' % text)
23 conf.Message(
'Checking for environment variable %s...' % var)
24 result = var
in conf.env[
'ENV']
29 def CheckConfigTool(conf, tool):
30 """check for the existance of a tool"""
32 conf.Message(
'Checking for %s...' % tool)
33 (result, version) = conf.TryAction(
'%s --version' % tool)
38 def CheckPackage(conf, package, text=None):
39 """check for the existance of a package via the pkg-config tool"""
43 conf.Message(
'Checking for %s...' % text)
44 (result, output) = conf.TryAction(
'pkg-config --exists %s' % package)
49 def CheckFile(conf, dir, text=None):
50 """check for the existance a file"""
53 conf.Message(
'Checking for %s...' % text)
55 conf.Message(
'Checking for directory %s...' % dir)
56 if conf.env.FindFile(dir,
'.')
is None:
64 def configure_belle2(conf):
65 """check the Belle II environment"""
68 if not conf.CheckEnvVar(
'BELLE2_TOOLS',
'Belle II environment setup'):
69 print(
'Belle II software environment is not set up.')
70 print(
'-> Source "setup_belle2" from the tools/ directory.')
74 if not conf.CheckEnvVar(
'BELLE2_ANALYSIS_DIR',
'analysis setup') \
75 and not conf.CheckEnvVar(
'BELLE2_LOCAL_DIR',
'local release setup'):
76 print(
'analysis or local release is not set up.')
77 print(
'-> Execute "b2setup" in your local analysis or release directory.')
83 def configure_system(conf):
84 """configure the system packages"""
87 conf.env.ParseConfig(
'xml2-config --cflags')
88 xml_env = Environment(ENV=os.environ)
89 xml_env.ParseConfig(
'xml2-config --libs')
90 conf.env[
'XML_LIBS'] = xml_env[
'LIBS']
93 conf.env[
'HAS_TEVE'] =
False
94 conf.env[
'TEVE_LIBS'] = []
95 if conf.CheckLibWithHeader(
"Eve",
"TEveViewer.h", language=
"c++", autoadd=0, call=
"TEveViewer();"):
96 conf.env[
'HAS_TEVE'] =
True
97 conf.env[
'TEVE_LIBS'] = [
'Gui',
'Eve',
'Ged',
'RGL',
'TreePlayer']
100 conf.env[
'HAS_SQLITE'] =
False
101 conf.env[
'SQLITE_LIBS'] = []
102 if conf.CheckLibWithHeader(
'sqlite3',
'sqlite3.h',
'C',
103 'sqlite3_open_v2(":memory:",0,SQLITE_OPEN_READONLY,0);'
105 conf.env[
'HAS_SQLITE'] =
True
106 conf.env.Append(CPPDEFINES=
'-DHAS_SQLITE')
107 sqlite_env = Environment(ENV=os.environ)
108 sqlite_env.ParseConfig(
'pkg-config sqlite3 --libs')
109 conf.env[
'SQLITE_LIBS'] = sqlite_env[
'LIBS']
112 conf.env[
'HAS_CALLGRIND'] =
False
113 if conf.CheckHeader(
'valgrind/callgrind.h'):
114 conf.env[
'HAS_CALLGRIND'] =
True
115 conf.env.Append(CPPDEFINES=
'-DHAS_CALLGRIND')
118 conf.env[
'HAS_OPENMP'] =
False
119 if conf.CheckHeader(
'omp.h', language=
"C++"):
120 conf.env[
'HAS_OPENMP'] =
True
121 conf.env.Append(CPPDEFINES=
'-DHAS_OPENMP')
124 conf.env[
'HAS_DOT'] =
False
125 if conf.CheckProg(
'dot'):
126 conf.env[
'HAS_DOT'] =
True
131 def configure_externals(conf):
132 """configure the external packages"""
135 extdir = conf.env[
'EXTDIR']
136 sys.path[:0] = [os.environ[
'BELLE2_TOOLS'], extdir]
137 from externals
import config_externals
138 return config_externals(conf)
139 except Exception
as e:
140 print(
'Configuration of externals failed:', e)
147 """configure the environment"""
149 conf = Configure(env, custom_tests={
150 'CheckEnvVar': CheckEnvVar,
151 'CheckConfigTool': CheckConfigTool,
152 'CheckPackage': CheckPackage,
153 'CheckFile': CheckFile,
156 if not configure_belle2(conf)
or not configure_externals(conf) \
157 or not configure_system(conf):