9 def CheckEnvVar(conf, var, text=None):
10 """check for the existance of an environment variable"""
13 conf.Message(
'Checking for %s...' % text)
15 conf.Message(
'Checking for environment variable %s...' % var)
16 result = var
in conf.env[
'ENV']
21 def CheckConfigTool(conf, tool):
22 """check for the existance of a tool"""
24 conf.Message(
'Checking for %s...' % tool)
25 (result, version) = conf.TryAction(
'%s --version' % tool)
30 def CheckPackage(conf, package, text=None):
31 """check for the existance of a package via the pkg-config tool"""
35 conf.Message(
'Checking for %s...' % text)
36 (result, output) = conf.TryAction(
'pkg-config --exists %s' % package)
41 def CheckFile(conf, dir, text=None):
42 """check for the existance a file"""
45 conf.Message(
'Checking for %s...' % text)
47 conf.Message(
'Checking for directory %s...' % dir)
48 if conf.env.FindFile(dir,
'.')
is None:
56 def configure_belle2(conf):
57 """check the Belle II environment"""
60 if not conf.CheckEnvVar(
'BELLE2_TOOLS',
'Belle II environment setup'):
61 print(
'Belle II software environment is not set up.')
62 print(
'-> Source "setup_belle2" from the tools/ directory.')
66 if not conf.CheckEnvVar(
'BELLE2_ANALYSIS_DIR',
'analysis setup') \
67 and not conf.CheckEnvVar(
'BELLE2_LOCAL_DIR',
'local release setup'):
68 print(
'analysis or local release is not set up.')
69 print(
'-> Execute "b2setup" in your local analysis or release directory.')
75 def configure_system(conf):
76 """configure the system packages"""
79 conf.env.ParseConfig(
'xml2-config --cflags')
80 xml_env = Environment(ENV=os.environ)
81 xml_env.ParseConfig(
'xml2-config --libs')
82 conf.env[
'XML_LIBS'] = xml_env[
'LIBS']
85 conf.env[
'HAS_TEVE'] =
False
86 conf.env[
'TEVE_LIBS'] = []
87 if conf.CheckLibWithHeader(
"Eve",
"TEveViewer.h", language=
"c++", autoadd=0, call=
"TEveViewer();"):
88 conf.env[
'HAS_TEVE'] =
True
89 conf.env[
'TEVE_LIBS'] = [
'Gui',
'Eve',
'Ged',
'RGL',
'TreePlayer']
92 conf.env[
'HAS_SQLITE'] =
False
93 conf.env[
'SQLITE_LIBS'] = []
94 if conf.CheckLibWithHeader(
'sqlite3',
'sqlite3.h',
'C',
95 'sqlite3_open_v2(":memory:",0,SQLITE_OPEN_READONLY,0);'
97 conf.env[
'HAS_SQLITE'] =
True
98 conf.env.Append(CPPDEFINES=
'-DHAS_SQLITE')
99 sqlite_env = Environment(ENV=os.environ)
100 sqlite_env.ParseConfig(
'pkg-config sqlite3 --libs')
101 conf.env[
'SQLITE_LIBS'] = sqlite_env[
'LIBS']
104 conf.env[
'HAS_CALLGRIND'] =
False
105 if conf.CheckHeader(
'valgrind/callgrind.h'):
106 conf.env[
'HAS_CALLGRIND'] =
True
107 conf.env.Append(CPPDEFINES=
'-DHAS_CALLGRIND')
110 conf.env[
'HAS_OPENMP'] =
False
111 if conf.CheckHeader(
'omp.h', language=
"C++"):
112 conf.env[
'HAS_OPENMP'] =
True
113 conf.env.Append(CPPDEFINES=
'-DHAS_OPENMP')
116 conf.env[
'HAS_DOT'] =
False
117 if conf.CheckProg(
'dot'):
118 conf.env[
'HAS_DOT'] =
True
123 def configure_externals(conf):
124 """configure the external packages"""
127 extdir = conf.env[
'EXTDIR']
128 sys.path[:0] = [os.environ[
'BELLE2_TOOLS'], extdir]
129 from externals
import config_externals
130 return config_externals(conf)
131 except Exception
as e:
132 print(
'Configuration of externals failed:', e)
139 """configure the environment"""
141 conf = Configure(env, custom_tests={
142 'CheckEnvVar': CheckEnvVar,
143 'CheckConfigTool': CheckConfigTool,
144 'CheckPackage': CheckPackage,
145 'CheckFile': CheckFile,
148 if not configure_belle2(conf)
or not configure_externals(conf) \
149 or not configure_system(conf):