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@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
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 | // If libmars.so is not found in the current directory we search in the
|
---|
44 | // directory given in "MARSSYS" environment variable.
|
---|
45 | //
|
---|
46 | ///////////////////////////////////////////////////////////////////////////
|
---|
47 |
|
---|
48 | Bool_t isloaded()
|
---|
49 | {
|
---|
50 | TString str = gSystem->GetLibraries("libmars.so");
|
---|
51 |
|
---|
52 | return !str.IsNull();
|
---|
53 | }
|
---|
54 |
|
---|
55 | void unload()
|
---|
56 | {
|
---|
57 | if (!isloaded())
|
---|
58 | return;
|
---|
59 |
|
---|
60 | cout << "Unloading 'libmars.so'... " << flush;
|
---|
61 | if (gSystem->Unload("libmars.so"))
|
---|
62 | cout << "error." << endl;
|
---|
63 | else
|
---|
64 | cout << "done." << endl << endl;
|
---|
65 | }
|
---|
66 |
|
---|
67 | bool load(TString &dir)
|
---|
68 | {
|
---|
69 | if (isloaded())
|
---|
70 | return;
|
---|
71 |
|
---|
72 | cout << "\033[33m\033[1m" << "Loading '" << dir << "libmars.so'... " << "\033[0m" << flush;
|
---|
73 |
|
---|
74 | if (dir.IsNull())
|
---|
75 | dir = "./";
|
---|
76 |
|
---|
77 | if (gSystem->Load(dir+"libmars.so")!=0)
|
---|
78 | {
|
---|
79 | cout << "\033[33m\033[1m" << "error." << endl;
|
---|
80 | cout << "\033[0m" << endl;
|
---|
81 | return false;
|
---|
82 | }
|
---|
83 | else
|
---|
84 | {
|
---|
85 | MParContainer::Class()->IgnoreTObjectStreamer();
|
---|
86 | MArray::Class()->IgnoreTObjectStreamer();
|
---|
87 | cout << "\033[33m\033[1m" << "done." << endl;
|
---|
88 | cout << "\033[0m" << endl;
|
---|
89 | return true;
|
---|
90 | }
|
---|
91 | }
|
---|
92 | /*
|
---|
93 | void make()
|
---|
94 | {
|
---|
95 | unload();
|
---|
96 |
|
---|
97 | if (gSystem->Exec("make"))
|
---|
98 | {
|
---|
99 | cout << "Error calling make..." << endl;
|
---|
100 | return;
|
---|
101 | }
|
---|
102 |
|
---|
103 | load();
|
---|
104 | }
|
---|
105 | */
|
---|
106 | void rootlogon()
|
---|
107 | {
|
---|
108 | cout << endl;
|
---|
109 |
|
---|
110 | const Bool_t fileexist = !gSystem->AccessPathName("libmars.so", kFileExists);
|
---|
111 |
|
---|
112 | TString dir = fileexist ? "" : gSystem->Getenv("MARSSYS");
|
---|
113 | if (!dir.IsNull())
|
---|
114 | {
|
---|
115 | cout << "\033[34m\033[1m" << "Searching Mars in " << dir << " (MARSSYS)" << "\033[0m" << endl << endl;
|
---|
116 |
|
---|
117 | if (!dir.EndsWith("/"))
|
---|
118 | dir += "/";
|
---|
119 | }
|
---|
120 |
|
---|
121 | if (!load(dir))
|
---|
122 | return;
|
---|
123 |
|
---|
124 | MLog::RedirectErrorHandler(MLog::kColor);
|
---|
125 |
|
---|
126 | gInterpreter->AddIncludePath(dir+"macros");
|
---|
127 | gInterpreter->AddIncludePath(dir+"manalysis");
|
---|
128 | gInterpreter->AddIncludePath(dir+"mastro");
|
---|
129 | gInterpreter->AddIncludePath(dir+"mbase");
|
---|
130 | gInterpreter->AddIncludePath(dir+"mbadpixels");
|
---|
131 | gInterpreter->AddIncludePath(dir+"mcamera");
|
---|
132 | gInterpreter->AddIncludePath(dir+"mcalib");
|
---|
133 | gInterpreter->AddIncludePath(dir+"mhcalib");
|
---|
134 | gInterpreter->AddIncludePath(dir+"mdata");
|
---|
135 | gInterpreter->AddIncludePath(dir+"mfbase");
|
---|
136 | gInterpreter->AddIncludePath(dir+"mfileio");
|
---|
137 | gInterpreter->AddIncludePath(dir+"mfilter");
|
---|
138 | gInterpreter->AddIncludePath(dir+"mgeom");
|
---|
139 | gInterpreter->AddIncludePath(dir+"mgui");
|
---|
140 | gInterpreter->AddIncludePath(dir+"mhbase");
|
---|
141 | gInterpreter->AddIncludePath(dir+"mhflux");
|
---|
142 | gInterpreter->AddIncludePath(dir+"mhft");
|
---|
143 | gInterpreter->AddIncludePath(dir+"mhist");
|
---|
144 | gInterpreter->AddIncludePath(dir+"mhistmc");
|
---|
145 | gInterpreter->AddIncludePath(dir+"mhvstime");
|
---|
146 | gInterpreter->AddIncludePath(dir+"mimage");
|
---|
147 | gInterpreter->AddIncludePath(dir+"mjobs");
|
---|
148 | gInterpreter->AddIncludePath(dir+"mjoptim");
|
---|
149 | gInterpreter->AddIncludePath(dir+"mjtrain");
|
---|
150 | gInterpreter->AddIncludePath(dir+"mmain");
|
---|
151 | gInterpreter->AddIncludePath(dir+"mmc");
|
---|
152 | gInterpreter->AddIncludePath(dir+"mmontecarlo");
|
---|
153 | gInterpreter->AddIncludePath(dir+"mmuon");
|
---|
154 | gInterpreter->AddIncludePath(dir+"mpedestal");
|
---|
155 | gInterpreter->AddIncludePath(dir+"mpointing");
|
---|
156 | gInterpreter->AddIncludePath(dir+"mranforest");
|
---|
157 | gInterpreter->AddIncludePath(dir+"mraw");
|
---|
158 | gInterpreter->AddIncludePath(dir+"mreflector");
|
---|
159 | gInterpreter->AddIncludePath(dir+"mreport");
|
---|
160 | gInterpreter->AddIncludePath(dir+"msignal");
|
---|
161 | gInterpreter->AddIncludePath(dir+"msql");
|
---|
162 | gInterpreter->AddIncludePath(dir+"mstarcam");
|
---|
163 | gInterpreter->AddIncludePath(dir+"mtools");
|
---|
164 | gInterpreter->AddIncludePath(dir+"mtrigger");
|
---|
165 |
|
---|
166 | if (TString("linux")==gSystem->GetBuildArch())
|
---|
167 | {
|
---|
168 | TString options = " -O -pipe -Wall -Woverloaded-virtual -fno-exceptions -fPIC ";
|
---|
169 |
|
---|
170 | TString s = "cd $BuildDir ; ";
|
---|
171 | s += "g++ -c" + options + "-Iinclude -D_REENTRANT $IncludePath $SourceFiles ; ";
|
---|
172 | s += "g++ $ObjectFiles -shared -Wl,-soname,$LibName.so -O -o $SharedLib";
|
---|
173 | gSystem->SetMakeSharedLib(s);
|
---|
174 | }
|
---|
175 |
|
---|
176 | cout << "\033[32m" << "Welcome to the Mars Root environment." << "\033[0m" << endl;
|
---|
177 | cout << endl;
|
---|
178 | }
|
---|