Compiled macros for different root versions

Hi,

I typically compile (if necessary) and load several homegrown utilities libraries by doing, e.g.,

gROOT->ProcessLine(".L mylib.C+");

in my rootlogon.C file.

This works OK except that lately I have to work with multiple root versions. In this case the utility libraries are recompiled whenever I switch root versions. This can occur when I’m running different jobs on a large cluster. I wonder if there is a known solution to my problem.

In other words, is it possible to:

(a) still keep a single source directory for my utilties
(b) have multiple build directories, such that the one actually used by root is dependent on the root version?

I can imagine other strategies (such as one like the soversion option available when building root) but don’t know if I’m facing an already solved problem. Any help appreciated!

Regards,
mike kordosky

Hi Mike,

you might be able to piece a solution together using TSystem::CompileMacro()'s build dir parameter, which you set to something depending on TROOT::GetVersion() (remember to replace the dangerous characters). Please let me know if these hints are insufficient.

Cheers, Axel.

When I need this kind of setup I use the following in my rootlogon.C:

TString dirname = gROOT->GetVersion(); dirname.ReplaceAll(".","-"); dirname.ReplaceAll("/","-"); dirname.Append(".libs"); gSystem->SetBuildDir(dirname);Cheers,
Philippe

Hi guys,

Using your excellent advice I was able to come up with:

/////////////  root/loon version dependent compilation //////////////////////
// this allows you to use multiple root versions on the same system
// without libraries constantly being recompiled.
TString dirname = gROOT->GetVersion();
dirname.ReplaceAll(".","_");
dirname.ReplaceAll("/","_");
dirname.Append("_libs");
TString appname(gApplication->Argv(0));
if(appname.Contains("loon")){
  appname="loon";
}
else appname="root";
appname+="_";
dirname.Prepend(appname);
dirname.Prepend("/root_build/"); // base dir for compliled macros
dirname.Prepend(gSystem->Getenv("HOME"));
cout<<"Setting build directory to: "<<dirname<<endl>mkdir(dirname.Data(),true); // make dir if it doesn't exist
gSystem->SetBuildDir(dirname);

///////////////////////////////////////////////////////////////////////////////

It does exactly what I wanted and so simple!

Regards,

mike kordosky