source: trunk/Mars/cmake/rootlogon.C.in@ 19953

Last change on this file since 19953 was 19755, checked in by tbretz, 5 years ago
Make it more robust against missing version numbers.
File size: 7.5 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@physik.rwth-aachen.de>
19!
20! Copyright: MAGIC Software Development, 2000-2018
21!
22!
23\* ======================================================================== */
24
25///////////////////////////////////////////////////////////////////////////
26//
27// rootlogon.C
28// ===========
29//
30// This file is the startup script ("autoexec.bat") executed when root is
31// started. The definition which file to start is done in ".rootrc".
32// There are three files which are automatically processed by root at
33// startup: A systemwide .rootrc, one in your home directory and one
34// in the current directory.
35// So rootlogon.C is correctly executed if your start root from your
36// Mars directory.
37//
38// The script setupts some small environmental things and makes
39// sure that the Mars shared object (libmars.so) is loaded. This shared
40// object gives you access to all Mars features from within the root
41// interpreter.
42//
43///////////////////////////////////////////////////////////////////////////
44#include <iomanip>
45
46#define ROOT_LIB_VERSION_MAJOR (@ROOT_VERSION_MAJOR@+0)
47#define ROOT_LIB_VERSION_MINOR (@ROOT_VERSION_MINOR@+0)
48#define ROOT_LIB_VERSION_PATCH (@ROOT_VERSION_PATCH@+0)
49
50#if defined(ROOT_VERSION_CODE) && (ROOT_LIB_VERSION_MAJOR!=0)
51#if ROOT_VERSION_CODE != ROOT_VERSION(${ROOT_VERSION_MAJOR},${ROOT_VERSION_MINOR},${ROOT_VERSION_PATCH})
52#warning Started ROOT version does not match ROOT version linked with libmars.so
53#endif
54#endif
55
56#if defined (R__ADD_LIBRARY_PATH) && defined (R__LOAD_LIBRARY)
57R__ADD_LIBRARY_PATH(${PROJECT_BINARY_DIR}/lib)
58R__LOAD_LIBRARY(libmars.so)
59#endif
60
61Bool_t isloaded()
62{
63 TString str = gSystem->GetLibraries("libmars.so");
64
65 return !str.IsNull();
66}
67
68bool load()
69{
70 if (isloaded())
71 return true;
72
73 cout << "\033[33m\033[1m" << "Loading 'libmars.so'... " << "\033[0m" << flush;
74
75 if (gSystem->Load("${PROJECT_BINARY_DIR}/lib/libmars.so")!=0)
76 {
77 cout << "\033[31m\033[1m" << "error!" << endl;
78 cout << "\033[0m" << endl;
79 return false;
80 }
81 else
82 {
83 MParContainer::Class()->IgnoreTObjectStreamer();
84 MArray::Class()->IgnoreTObjectStreamer();
85 cout << "\033[33m\033[1m" << "done." << endl;
86 cout << "\033[0m" << endl;
87 return true;
88 }
89}
90
91void rootlogon()
92{
93 // This is a workaround to make axis behave as they
94 // are UTC and not local time
95 // gSystem->Setenv("TZ", "UTC");
96
97 cout << endl;
98
99 if (gROOT->GetVersionInt()<60000 && !load())
100 return;
101
102 MLog::RedirectErrorHandler(MLog::kColor);
103
104 cout << "\033[32m" << "Welcome to the Mars Root environment." << "\033[0m" << endl;
105 cout << endl;
106
107 if (gROOT->GetVersionInt()>=60000)
108 return;
109
110 // This initialized the thread factory. This is needed to supress
111 // an error which is displayed if the thread factory is initialized
112 // from another than the main thread (e.g. in the constructor
113 // of MStatusDisplay)
114 TThread::Self();
115
116 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/macros");
117 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/include");
118 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/manalysis");
119 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mastro");
120 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mbase");
121 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mbadpixels");
122 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mcamera");
123 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mcalib");
124 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mcore");
125 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mdrs");
126 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhcalib");
127 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mdata");
128 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mfbase");
129 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mfileio");
130 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mfilter");
131 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mgeom");
132 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mgui");
133 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhbase");
134 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhflux");
135 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhft");
136 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhist");
137 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhistmc");
138 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhvstime");
139 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mimage");
140 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mjobs");
141 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mjoptim");
142 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mjtrain");
143 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mmain");
144 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mmc");
145 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mmontecarlo");
146 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mmuon");
147 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mpedestal");
148 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mpointing");
149 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mranforest");
150 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mraw");
151 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mreflector");
152 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mreport");
153 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/msignal");
154 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/msql");
155 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mstarcam");
156 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mtools");
157 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mtrigger");
158 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/melectronics");
159 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/msim");
160 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/msimreflector");
161 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/msimcamera");
162 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mcorsika");
163 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mextralgo");
164
165 TString opt(gSystem->GetFlagsOpt());
166 TString dbg(gSystem->GetFlagsDebug());
167 TString lib(gSystem->GetLinkedLibs());
168
169 TString add = " -O5 -std=c++0x -Wall -Winit-self -fPIC -Wpointer-arith -Wcast-align -Woverloaded-virtual";
170 add += " -D__MARS__";
171 add += " -DHAVE_ZLIB";
172 add += " -DPACKAGE_NAME='\""+MARS::GetPackageName()+"\"'";
173 add += " -DPACKAGE_VERSION='\""+MARS::GetPackageName()+"\"'";
174 add += " -DREVISION='\""+MARS::GetRevision()+"\"'";
175 add += " -I\"${PROJECT_SOURCE_DIR}\"";
176
177 opt += add;
178 dbg += add;
179
180 lib += " -lnova -lz";
181
182 gSystem->SetLinkedLibs(lib);
183 gSystem->SetFlagsOpt(opt);
184 gSystem->SetFlagsDebug(dbg);
185}
Note: See TracBrowser for help on using the repository browser.