From 4c628cda4eac001296f8fa039a5575e247eb5619 Mon Sep 17 00:00:00 2001
From: Fons Rademakers <Fons.Rademakers@cern.ch>
Date: Fri, 13 Feb 2004 16:34:41 +0000
Subject: [PATCH] add new option "root -config" which prints the environment
 variables and options used by ./configure. This allows us to see which
 non-defaults were used when configuring ROOT.

git-svn-id: http://root.cern.ch/svn/root/trunk@8197 27541ba8-7e3a-0410-8455-c3a389f83636
---
 base/inc/TROOT.h          |  4 ++-
 base/src/TApplication.cxx | 16 ++++++++--
 base/src/TROOT.cxx        | 67 +++++++++++++++++++--------------------
 config/config.in          |  2 ++
 configure                 | 54 +++++++++++++++++++++++++++++--
 rootx/src/rootx.cxx       | 15 ++++++---
 6 files changed, 113 insertions(+), 45 deletions(-)

diff --git a/base/inc/TROOT.h b/base/inc/TROOT.h
index b55dbf9ab31..e4e05d8cc18 100644
--- a/base/inc/TROOT.h
+++ b/base/inc/TROOT.h
@@ -1,4 +1,4 @@
-// @(#)root/base:$Name:  $:$Id: TROOT.h,v 1.37 2004/01/10 10:52:29 brun Exp $
+// @(#)root/base:$Name:  $:$Id: TROOT.h,v 1.38 2004/01/27 19:52:47 brun Exp $
 // Author: Rene Brun   08/12/94
 
 /*************************************************************************
@@ -67,6 +67,7 @@ private:
 protected:
    typedef ROOT::TMapTypeToTClass IdMap_t;
 
+   TString         fConfigOptions;        //ROOT ./configure build options
    TString         fVersion;              //ROOT version (from CMZ VERSQQ) ex 0.05/01
    Int_t           fVersionInt;           //ROOT version in integer format (501)
    Int_t           fVersionDate;          //Date of ROOT version (ex 951226)
@@ -147,6 +148,7 @@ public:
    TClass           *GetClass(const char *name, Bool_t load = kTRUE) const;
    TClass           *GetClass(const type_info &typeinfo, Bool_t load = kTRUE) const;
    TColor           *GetColor(Int_t color) const;
+   const char       *GetConfigOptions() const { return fConfigOptions; }
    const char       *GetCutClassName() const { return fCutClassName; }
    const char       *GetDefCanvasName() const { return fDefCanvasName; }
    Bool_t            GetEditHistograms() const { return fEditHistograms; }
diff --git a/base/src/TApplication.cxx b/base/src/TApplication.cxx
index 3465b89e39d..b738f93e5b1 100644
--- a/base/src/TApplication.cxx
+++ b/base/src/TApplication.cxx
@@ -1,4 +1,4 @@
-// @(#)root/base:$Name:  $:$Id: TApplication.cxx,v 1.52 2004/02/05 10:05:06 brun Exp $
+// @(#)root/base:$Name:  $:$Id: TApplication.cxx,v 1.53 2004/02/09 09:50:17 rdm Exp $
 // Author: Fons Rademakers   22/12/95
 
 /*************************************************************************
@@ -242,13 +242,16 @@ void TApplication::GetOptions(Int_t *argc, char **argv)
 {
    // Get and handle command line options. Arguments handled are removed
    // from the argument array. The following arguments are handled:
-   //    -? : help
-   //    -h : help
    //    -b : run in batch mode without graphics
    //    -n : do not execute logon and logoff macros as specified in .rootrc
    //    -q : exit after processing command line macro files
    //    -l : do not show splash screen
    // The last three options are only relevant in conjunction with TRint.
+   // The following help and info arguments are supported:
+   //    -?      : print usage
+   //    -h      : print usage
+   //    -config : print ./configure options
+
 
    fNoLog = kFALSE;
    fQuit  = kFALSE;
@@ -269,6 +272,13 @@ void TApplication::GetOptions(Int_t *argc, char **argv)
          fprintf(stderr, "  -l : do not show splash screen\n");
          fprintf(stderr, " dir : if dir is a valid directory cd to it before executing\n");
          fprintf(stderr, "\n");
+         fprintf(stderr, "  -?      : print usage\n");
+         fprintf(stderr, "  -h      : print usage\n");
+         fprintf(stderr, "  -config : print ./configure options\n");
+         fprintf(stderr, "\n");
+         Terminate(0);
+      } else if (!strcmp(argv[i], "-config")) {
+         fprintf(stderr, "ROOT ./configure options:\n%s\n", gROOT->GetConfigOptions());
          Terminate(0);
       } else if (!strcmp(argv[i], "-b")) {
          MakeBatch();
diff --git a/base/src/TROOT.cxx b/base/src/TROOT.cxx
index 6a224d79c17..a5f9476b2b6 100644
--- a/base/src/TROOT.cxx
+++ b/base/src/TROOT.cxx
@@ -1,4 +1,4 @@
-// @(#)root/base:$Name:  $:$Id: TROOT.cxx,v 1.113 2004/01/31 08:59:09 brun Exp $
+// @(#)root/base:$Name:  $:$Id: TROOT.cxx,v 1.114 2004/02/13 07:12:57 brun Exp $
 // Author: Rene Brun   08/12/94
 
 /*************************************************************************
@@ -59,9 +59,7 @@
 //-----------------------End of Main program--------------------------------
 ////////////////////////////////////////////////////////////////////////////////
 
-#ifdef HAVE_CONFIG
 #include "config.h"
-#endif
 
 #include <string>
 #include <map>
@@ -261,9 +259,9 @@ VoidFuncPtr_t TROOT::fgMakeDefCanvas = 0;
 
 // This local static object initializes the ROOT system
 namespace ROOT {
-   TROOT *GetROOT() { 
+   TROOT *GetROOT() {
       static TROOT root("root", "The ROOT of EVERYTHING");
-      return &root; 
+      return &root;
    }
    TString &GetMacroPath() {
       static TString macroPath;
@@ -334,18 +332,19 @@ TROOT::TROOT(const char *name, const char *title, VoidFuncPtr_t *initfunc)
    InitSystem();
 
    // Initialize interface to CINT C++ interpreter
-   fVersionInt  = 0;  // check in TROOT dtor in case TCint fails
-   fClasses     = 0;  // might be checked via TCint ctor
-   fInterpreter = new TCint("C/C++", "CINT C/C++ Interpreter");
-
-   fVersion     = ROOT_RELEASE;
-   fVersionInt  = IVERSQ();
-   fVersionDate = IDATQQ();
-   fVersionTime = ITIMQQ();
-
-   fClasses     = new THashList(800,3);
-   fIdMap       = new IdMap_t;
-   fStreamerInfo= new TObjArray(100);
+   fVersionInt      = 0;  // check in TROOT dtor in case TCint fails
+   fClasses         = 0;  // might be checked via TCint ctor
+   fInterpreter     = new TCint("C/C++", "CINT C/C++ Interpreter");
+
+   fConfigOptions   = R__CONFIGUREOPTIONS;
+   fVersion         = ROOT_RELEASE;
+   fVersionInt      = IVERSQ();
+   fVersionDate     = IDATQQ();
+   fVersionTime     = ITIMQQ();
+
+   fClasses         = new THashList(800,3);
+   fIdMap           = new IdMap_t;
+   fStreamerInfo    = new TObjArray(100);
    fClassGenerators = new TList;
 
    // initialize plugin manager early
@@ -786,28 +785,28 @@ const char *TROOT::FindObjectPathName(const TObject *) const
    return "??";
 }
 
-TClass *TROOT::FindSTLClass(const char *name, Bool_t load) const 
+TClass *TROOT::FindSTLClass(const char *name, Bool_t load) const
 {
    // return a TClass object corresponding to 'name' assuming it is an STL container.
-   // In particular we looking for possible alternative name (default template 
+   // In particular we looking for possible alternative name (default template
    // parameter, typedefs template arguments, typedefed name).
-   
+
    TClass *cl = 0;
-   
+
    // We have not found the STL container yet.
    // First we are going to look for a similar name but different 'default' template
    // parameter (differences due to different STL implementation)
-   
+
    string defaultname( TClassEdit::ShortType( name, TClassEdit::kDropStlDefault )) ;
 
    if (defaultname != name) {
       cl = (TClass*)gROOT->GetListOfClasses()->FindObject(defaultname.c_str());
       if (load && !cl) cl = gROOT->LoadClass(defaultname.c_str());
-   } 
-     
+   }
+
    if (cl==0) {
 
-      // now look for a typedef 
+      // now look for a typedef
       // well for now the typedefing in CINT has some issues
       // for examples if we generated the dictionary for
       //    set<string,someclass> then set<string> is typedef to it (instead of set<string,less<string> >)
@@ -816,7 +815,7 @@ TClass *TROOT::FindSTLClass(const char *name, Bool_t load) const
       if (objType) {
          const char *typedfName = objType->GetTypeName();
          string defaultTypedefName(  TClassEdit::ShortType( typedfName, TClassEdit::kDropStlDefault ) );
-         
+
          if (typedfName && strcmp(typedfName, name) && defaultTypedefName==name) {
             cl = (TClass*)gROOT->GetListOfClasses()->FindObject(typedfName);
             if (load && !cl) cl = gROOT->LoadClass(typedfName);
@@ -825,7 +824,7 @@ TClass *TROOT::FindSTLClass(const char *name, Bool_t load) const
    }
    if (cl==0) {
       // Try the alternate name where all the typedefs are resolved:
-      
+
       const char *altname = gInterpreter->GetInterpreterTypeName(name);
       if (altname && strcmp(altname,name)!=0) {
          cl = gROOT->GetClass(altname,load);
@@ -865,7 +864,7 @@ TClass *TROOT::GetClass(const char *name, Bool_t load) const
       load = kTRUE;
 
       if (TClassEdit::IsSTLCont(name)) {
- 
+
          const char *altname = gInterpreter->GetInterpreterTypeName(name);
          if (altname && strcmp(altname,name)!=0) {
 
@@ -876,7 +875,7 @@ TClass *TROOT::GetClass(const char *name, Bool_t load) const
             assert(newcl!=cl);
             cl->ReplaceWith(newcl);
             delete cl;
-            return newcl;    
+            return newcl;
          }
       }
 
@@ -884,10 +883,10 @@ TClass *TROOT::GetClass(const char *name, Bool_t load) const
 
       if (!TClassEdit::IsSTLCont(name)) {
 
-         // If the name is actually an STL container we prefer the 
-         // short name rather than the true name (at least) in 
+         // If the name is actually an STL container we prefer the
+         // short name rather than the true name (at least) in
          // a first try!
-         
+
          TDataType *objType = GetType(name, load);
          if (objType) {
             const char *typdfName = objType->GetTypeName();
@@ -898,7 +897,7 @@ TClass *TROOT::GetClass(const char *name, Bool_t load) const
          }
 
       } else {
-            
+
          cl = FindSTLClass(name,kFALSE);
 
          if (cl) {
@@ -1811,7 +1810,7 @@ const char *TROOT::GetMacroPath()
    // Get macro search path. Static utility function.
 
    TString &macroPath = ROOT::GetMacroPath();
-   
+
    if (macroPath.Length() == 0) {
       macroPath = gEnv->GetValue("Root.MacroPath", (char*)0);
       if (macroPath.Length() == 0)
diff --git a/config/config.in b/config/config.in
index 61a32cff59a..118b80c458f 100644
--- a/config/config.in
+++ b/config/config.in
@@ -18,3 +18,5 @@
 #@setresuid@ HAS_SETRESUID  /**/
 
 #define R__KRB5INIT   "@krb5init@"
+
+#define R__CONFIGUREOPTIONS   "@configoptions@"
diff --git a/configure b/configure
index 851a2fc5f0b..1c28e46cf6a 100755
--- a/configure
+++ b/configure
@@ -65,6 +65,57 @@ enable_soversion=no
 enable_table=no
 enable_thread=           # must be set explicitely via --enable-thread
 
+#
+# ./configure arguments and defaults set via supported env vars
+#
+envvars="
+THREAD           \
+OPENGL           \
+IVROOT           \
+MYSQL            \
+PGSQL            \
+QTDIR            \
+SAPDB            \
+RFIO             \
+CERNLIB          \
+PYTHIA           \
+PYTHIA6          \
+VENUS            \
+DCACHE           \
+CHIRP            \
+ALIEN            \
+ASIMAGE          \
+LDAP             \
+GLOBUS_LOCATION  \
+SRP              \
+AFS              \
+TABLE            \
+"
+configenvvars=
+for c in $envvars ; do
+   if test ! "x${!c}" = "x" ; then
+      if test ! "x$configenvvars" = "x" ; then
+         configenvvars="$configenvvars $c=${!c}"
+      else
+         configenvvars=$c=${!c}
+      fi
+   fi
+done
+
+configargs="$*"
+
+configoptions=
+if test ! "x$configenvvars" = "x" ; then
+   configoptions=$configenvvars
+fi
+if test ! "x$configargs" = "x" ; then
+   if test ! "x$configoptions" = "x" ; then
+      configoptions="$configoptions $configargs"
+   else
+      configoptions=$configargs
+   fi
+fi
+
 ######################################################################
 #
 ### echo %%% Some common functions
@@ -570,8 +621,6 @@ EOF
 ### echo %%% See if we got the architecture
 #
 if test $# -lt 1 ; then
-   #echo "You must give architecture as first argument - try $0 --help"
-   #exit 1
    guess_architecture
 else
    case $1 in
@@ -2376,6 +2425,7 @@ sed \
     -e "s|@ttffontdir@|$fontdir|"          \
     -e "s|@setresuid@|$setresuid|"         \
     -e "s|@krb5init@|$krb5init|"           \
+    -e "s|@configoptions@|$configoptions|" \
     < config.tmp > $CONFOUT
 rm -f config.tmp
 echo "done"
diff --git a/rootx/src/rootx.cxx b/rootx/src/rootx.cxx
index 904a3157142..9a524aef3f6 100644
--- a/rootx/src/rootx.cxx
+++ b/rootx/src/rootx.cxx
@@ -1,4 +1,4 @@
-// @(#)root/rootx:$Name:  $:$Id: rootx.cxx,v 1.11 2003/10/13 18:20:18 rdm Exp $
+// @(#)root/rootx:$Name:  $:$Id: rootx.cxx,v 1.12 2004/01/08 23:06:52 rdm Exp $
 // Author: Fons Rademakers   19/02/98
 
 //////////////////////////////////////////////////////////////////////////
@@ -198,7 +198,7 @@ static void SetLibraryPath()
    static char msg[512];
 
 #  if defined(__linux) || defined(__alpha) || defined(__sgi) || \
-      defined(__sun) || defined(__FreeBSD__)
+      defined(__sun) || defined(__FreeBSD__) || defined(__APPLE__)
    if (getenv("LD_LIBRARY_PATH"))
       sprintf(msg, "LD_LIBRARY_PATH=%s/lib:%s", getenv("ROOTSYS"),
                                                 getenv("LD_LIBRARY_PATH"));
@@ -277,6 +277,10 @@ static void PrintUsage(char *pname)
    fprintf(stderr, "  -l : do not show splash screen\n");
    fprintf(stderr, " dir : if dir is a valid directory cd to it before executing\n");
    fprintf(stderr, "\n");
+   fprintf(stderr, "  -?      : print usage\n");
+   fprintf(stderr, "  -h      : print usage\n");
+   fprintf(stderr, "  -config : print ./configure options\n");
+   fprintf(stderr, "\n");
 }
 
 int main(int argc, char **argv)
@@ -302,9 +306,10 @@ int main(int argc, char **argv)
          PrintUsage(argv[0]);
          return 1;
       }
-      if (!strcmp(argv[i], "-b")) batch   = true;
-      if (!strcmp(argv[i], "-l")) gNoLogo = true;
-      if (!strcmp(argv[i], "-a")) about   = true;
+      if (!strcmp(argv[i], "-b"))      batch   = true;
+      if (!strcmp(argv[i], "-l"))      gNoLogo = true;
+      if (!strcmp(argv[i], "-a"))      about   = true;
+      if (!strcmp(argv[i], "-config")) gNoLogo = true;
    }
    if (batch)
       gNoLogo = true;
-- 
GitLab