#include "TSystem.h" #include "TROOT.h" #include "TString.h" int MakeTMBTreeClasses_so(){ // ============= CUSTOMIZE HERE ============= // Settings that might change for different releases // // basename of the macro (without extension, assumed to be ".C") TString strMacro("TMBTreeClasses"); // package containing the macro // (don't forget to add it to the list of packages below) TString strMacroPackage("tmb_tree"); // package names TString listPackages("tmb_tree kinem_util"); // ============= END CUSTOMIZE ============== // load libPhysics if not already done so if (!gROOT->GetClass("TLorentzVector")) gSystem->Load("libPhysics"); // now try to find the packages // look in // 1. current dir, // 2. private release dir // 3. public release dir TString here("./"); TString priv; TString publ; TString* inclDirs[3]; inclDirs[0]=&here; inclDirs[1]=&priv; inclDirs[2]=&publ; //////// WATCH OUT! /////////////////////////////// // the include path must point to headers // #include "package/file.hpp" // and sources // #include "package/src/file.cpp" // as we #include all sources to build the library! /////////////////////////////////////////////////// TString strIncludePath(" -I./ -I./include"); if (gSystem->Getenv("SRT_PRIVATE_CONTEXT")) { TString envvar("$(SRT_PRIVATE_CONTEXT)/"); gSystem->ExpandPathName(envvar); priv=envvar; strIncludePath+=" -I"+envvar; strIncludePath+=" -I"+envvar+"include/"; } if (gSystem->Getenv("SRT_PUBLIC_CONTEXT")) { TString envvar("$(SRT_PUBLIC_CONTEXT)/"); gSystem->ExpandPathName(envvar); publ=envvar; strIncludePath+=" -I"+envvar; strIncludePath+=" -I"+envvar+"include/"; } Int_t iMacroPath=-1; Bool_t bAllFound=kTRUE; Int_t pos=0; while(pos!=TString::kNPOS) { TString package=listPackages(pos, listPackages.Length()-pos); Int_t subpos=package.First(' '); if (subpos!=TString::kNPOS) { package.Remove(subpos); pos+=subpos+1; } else pos=subpos; Int_t iPackageDir=-1; // is the package avaliable at one of the include paths? for (Int_t iDir=0; iDir<3; iDir++) { if (inclDirs[iDir] && inclDirs[iDir]->Length() && !gSystem->AccessPathName(*inclDirs[iDir]+package)) { iPackageDir=iDir; strIncludePath=" -I"+*inclDirs[iDir]+package+strIncludePath; if (strMacroPackage.Length() && package==strMacroPackage) iMacroPath=iDir; break; } } bAllFound&=iPackageDir>=0; if (iPackageDir<0) std::cout << "ERROR: Can't find package " << package.Data() << std::endl; else std::cout << "INFO: Using package " << package.Data() << " from " << inclDirs[iPackageDir]->Data() << std::endl; } if (!bAllFound) { std::cout << "ERROR: Can't find all necessary packages. " << std::endl << "Please copy the code from somewhere, or do a setup D0RunII so I can find them in the public release area." << std::endl; return 1; } //std::cout<SetIncludePath(strIncludePath); // find the macro // first, look for macro and linkdef in "./" TString strMacroPath("./"); strMacroPath+=strMacro; TString strLinkdefPath(strMacroPath+"_linkdef.h"); strMacroPath+=".C"; if (!gSystem->AccessPathName(strMacroPath) && !gSystem->AccessPathName(strLinkdefPath)) { std::cout << "INFO: You have a version of the TMBTreeClasses macro in the current directory, I will use that." << std::endl; } else if (iMacroPath>=0) { // the macro is in strMacroPackage strMacroPath=*inclDirs[iMacroPath]; strMacroPath+=strMacroPackage+"/macros/"+strMacro; strLinkdefPath=strMacroPath+"_linkdef.h"; strMacroPath+=".C"; } else { std::cout << "ERROR: Cannot find macro " << strMacro.Data() << ".C and/or " << strMacro.Data() << "_linkdef.h" << std::endl << "in ./ or package " << strMacroPackage.Data() << std::endl << "Please copy it to ./" << std::endl; return 2; } std::cout << "INFO: Using macro " << strMacroPath.Data() << std::endl; // load the macro (creating a shared lib) return gSystem->CompileMacro(strMacroPath, "k", "TMBTreeClasses_C"); }