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

Last change on this file since 19266 was 19264, checked in by tbretz, 6 years ago
Comaptibility with root 6 -- a slightly different way to load the library.
File size: 7.1 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#if defined (R__ADD_LIBRARY_PATH) && defined (R__LOAD_LIBRARY)
47R__ADD_LIBRARY_PATH(${PROJECT_BINARY_DIR}/dictionary)
48R__LOAD_LIBRARY(libmars.so)
49#endif
50
51Bool_t isloaded()
52{
53 TString str = gSystem->GetLibraries("libmars.so");
54
55 return !str.IsNull();
56}
57
58bool load()
59{
60 if (isloaded())
61 return true;
62
63 cout << "\033[33m\033[1m" << "Loading 'libmars.so'... " << "\033[0m" << flush;
64
65 if (gSystem->Load("${PROJECT_BINARY_DIR}/libmars.so")!=0)
66 {
67 cout << "\033[31m\033[1m" << "error!" << endl;
68 cout << "\033[0m" << endl;
69 return false;
70 }
71 else
72 {
73 MParContainer::Class()->IgnoreTObjectStreamer();
74 MArray::Class()->IgnoreTObjectStreamer();
75 cout << "\033[33m\033[1m" << "done." << endl;
76 cout << "\033[0m" << endl;
77 return true;
78 }
79}
80
81void rootlogon()
82{
83 // This is a workaround to make axis behave as they
84 // are UTC and not local time
85 // gSystem->Setenv("TZ", "UTC");
86
87 cout << endl;
88
89 if (gROOT->GetVersionInt()<60000 && !load())
90 return;
91
92 MLog::RedirectErrorHandler(MLog::kColor);
93
94 cout << "\033[32m" << "Welcome to the Mars Root environment." << "\033[0m" << endl;
95 cout << endl;
96
97 if (gROOT->GetVersionInt()>=60000)
98 return;
99
100 // This initialized the thread factory. This is needed to supress
101 // an error which is displayed if the thread factory is initialized
102 // from another than the main thread (e.g. in the constructor
103 // of MStatusDisplay)
104 TThread::Self();
105
106 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/macros");
107 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/include");
108 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/manalysis");
109 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mastro");
110 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mbase");
111 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mbadpixels");
112 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mcamera");
113 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mcalib");
114 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mcore");
115 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mdrs");
116 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhcalib");
117 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mdata");
118 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mfbase");
119 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mfileio");
120 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mfilter");
121 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mgeom");
122 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mgui");
123 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhbase");
124 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhflux");
125 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhft");
126 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhist");
127 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhistmc");
128 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mhvstime");
129 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mimage");
130 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mjobs");
131 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mjoptim");
132 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mjtrain");
133 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mmain");
134 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mmc");
135 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mmontecarlo");
136 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mmuon");
137 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mpedestal");
138 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mpointing");
139 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mranforest");
140 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mraw");
141 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mreflector");
142 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mreport");
143 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/msignal");
144 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/msql");
145 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mstarcam");
146 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mtools");
147 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mtrigger");
148 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/melectronics");
149 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/msim");
150 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/msimreflector");
151 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/msimcamera");
152 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mcorsika");
153 gInterpreter->AddIncludePath("${PROJECT_SOURCE_DIR}/mextralgo");
154
155 TString opt(gSystem->GetFlagsOpt());
156 TString dbg(gSystem->GetFlagsDebug());
157 TString lib(gSystem->GetLinkedLibs());
158
159 TString add = " -O5 -std=c++0x -Wall -Winit-self -fPIC -Wpointer-arith -Wcast-align -Woverloaded-virtual";
160 add += " -D__MARS__";
161 add += " -DHAVE_ZLIB";
162 add += " -DPACKAGE_NAME='\""+MARS::GetPackageName()+"\"'";
163 add += " -DPACKAGE_VERSION='\""+MARS::GetPackageName()+"\"'";
164 add += " -DREVISION='\""+MARS::GetRevision()+"\"'";
165 add += " -I\"${PROJECT_SOURCE_DIR}\"";
166
167 opt += add;
168 dbg += add;
169
170 lib += " -lnova -lz";
171
172 gSystem->SetLinkedLibs(lib);
173 gSystem->SetFlagsOpt(opt);
174 gSystem->SetFlagsDebug(dbg);
175}
Note: See TracBrowser for help on using the repository browser.