From cab21de002d3d47af7654aab6e3ea1063ed41e9d Mon Sep 17 00:00:00 2001
From: Fons Rademakers <Fons.Rademakers@cern.ch>
Date: Tue, 13 Apr 2010 16:36:38 +0000
Subject: [PATCH] m Axel: Introduce cling as a regular module to ROOT. It will
 only be built if cint/cling exists; configure's output does not advocate its
 ability to configure for cling. TCint's dictionary will now end up in
 G__TCint.cxx instead of G__Meta to allow it to be swapped with the dictionary
 for TCint from cling. In the near future, ROOT will be changed so that it
 doesn't require the interpreter to be called "TCint"; at least friend
 declarations in TROOT and TClass prevent that for now.

git-svn-id: http://root.cern.ch/svn/root/trunk@32970 27541ba8-7e3a-0410-8455-c3a389f83636
---
 Makefile                      | 12 +++++++-----
 config/Makefile.in            |  2 ++
 config/RConfigure.in          |  1 +
 configure                     | 20 ++++++++++++++++++++
 core/base/inc/TROOT.h         |  1 +
 core/base/src/TROOT.cxx       |  6 +++++-
 core/meta/Module.mk           | 30 +++++++++++++++++++++++-------
 core/meta/inc/LinkDef.h       |  1 -
 core/meta/inc/LinkDef_TCint.h | 17 +++++++++++++++++
 9 files changed, 76 insertions(+), 14 deletions(-)
 create mode 100644 core/meta/inc/LinkDef_TCint.h

diff --git a/Makefile b/Makefile
index 137db6594ca..98a5a800055 100644
--- a/Makefile
+++ b/Makefile
@@ -202,7 +202,10 @@ ifeq ($(BUILDUNURAN),yes)
 MODULES      += math/unuran
 endif
 ifeq ($(BUILDCINTEX),yes)
-   MODULES      += cint/cintex
+MODULES      += cint/cintex
+endif
+ifeq ($(BUILDCLING),yes)
+MODULES      += cint/cling
 endif
 ifeq ($(BUILDROOFIT),yes)
 MODULES      += roofit/roofitcore roofit/roofit roofit/roostats
@@ -461,9 +464,9 @@ STATICEXTRALIBS = $(PCRELDFLAGS) $(PCRELIB) \
 COREL         = $(BASEL1) $(BASEL2) $(BASEL3) $(CONTL) $(METAL) \
                 $(SYSTEML) $(CLIBL) $(METAUTILSL) $(EDITLINEL)
 COREO         = $(BASEO) $(CONTO) $(METAO) $(SYSTEMO) $(ZIPO) $(CLIBO) \
-                $(METAUTILSO) $(EDITLINEO)
-COREDO        = $(BASEDO) $(CONTDO) $(METADO) $(SYSTEMDO) $(CLIBDO) \
-                $(METAUTILSDO) $(EDITLINEDO)
+                $(METAUTILSO) $(EDITLINEO) $(CLINGO)
+COREDO        = $(BASEDO) $(CONTDO) $(METADO) $(METACDO) $(SYSTEMDO) \
+                $(CLIBDO) $(METAUTILSDO) $(EDITLINEDO) $(CLINGDO)
 
 CORELIB      := $(LPATH)/libCore.$(SOEXT)
 COREMAP      := $(CORELIB:.$(SOEXT)=.rootmap)
@@ -563,7 +566,6 @@ skip:
 -include $(patsubst %,%/ModuleVars.mk,$(MODULES))
 include $(patsubst %,%/Module.mk,$(MODULES))
 
--include cint/cling/Module.mk  # irrelevant except for LLVM dev
 -include MyRules.mk            # allow local rules
 
 ifeq ($(findstring $(MAKECMDGOALS),clean distclean maintainer-clean dist \
diff --git a/config/Makefile.in b/config/Makefile.in
index 5e29bf329b5..5400201c595 100644
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -278,6 +278,8 @@ GSLLIBDIR      := @gsllibdir@
 GSLLIBS        := @gsllibs@
 GSLVERSION     := @gslversion@
 
+BUILDCLING     := @buildcling@
+
 BUILDCINTEX    := @buildcintex@
 
 BUILDREFLEX    := @buildreflex@
diff --git a/config/RConfigure.in b/config/RConfigure.in
index a0ff1663cef..eec8630a97c 100644
--- a/config/RConfigure.in
+++ b/config/RConfigure.in
@@ -22,5 +22,6 @@
 #@hasmathmore@ R__HAS_MATHMORE   /**/
 #@haspthread@ R__HAS_PTHREAD    /**/
 #@hasxft@ R__HAS_XFT    /**/
+#@hascling@ R__HAS_CLING   /**/
 
 #endif
diff --git a/configure b/configure
index d63ef99e51f..2201b69d0d6 100755
--- a/configure
+++ b/configure
@@ -48,6 +48,7 @@ options="                    \
    enable_chirp              \
    enable_cintex             \
    enable_clarens            \
+   enable_cling              \
    enable_editline           \
    enable_dcache             \
    enable_exceptions         \
@@ -106,6 +107,7 @@ for c in $options ; do eval ${c}="yes" ; done
 for c in $deprecated_options ; do eval ${c}="yes" ; done
 for c in $options ; do eval ${c}_explicit="" ; done
 
+enable_cling=
 enable_afs=no
 enable_gdml=no
 enable_globus=no
@@ -4817,6 +4819,22 @@ fi
 check_explicit "$enable_genvector" "$enable_genvector_explicit" \
       "Explicitly required GenVector dependencies not fulfilled"
 
+######################################################################
+#
+### echo %%% Cling - LLVM/clang based interpreter prototype
+#
+if test ! "x$enable_cling" = "xno"; then
+    if test -d cint/cling; then
+        message "Checking whether to build cling"
+        enable_cling="yes"
+        hascling="define"
+        result "yes"
+    fi
+else
+    enable_cling=""
+    hascling="undef"
+fi
+
 ######################################################################
 #
 ### echo %%% Cintex Library - Contributed library
@@ -5507,6 +5525,7 @@ sed -e "s|@aclocaldir@|$aclocaldir|"            \
     -e "s|@zliblib@|$zliblib|"                  \
     -e "s|@zliblibdir@|$zliblibdir|"            \
     -e "s|@buildcintex@|$enable_cintex|"        \
+    -e "s|@buildcling@|$enable_cling|"        \
     -e "s|@buildreflex@|$enable_reflex|"        \
     -e "s|@buildroofit@|$enable_roofit|"        \
     -e "s|@buildminuit2@|$enable_minuit2|"      \
@@ -5735,6 +5754,7 @@ sed \
     -e "s|@hasmathmore@|$hasmathmore|"     \
     -e "s|@haspthread@|$haspthread|"       \
     -e "s|@hasxft@|$hasxft|"               \
+    -e "s|@hascling@|$hascling|"               \
     < RConfigure.tmp > RConfigure-out.tmp
 rm -f RConfigure.tmp
 
diff --git a/core/base/inc/TROOT.h b/core/base/inc/TROOT.h
index 80a2d099dcb..23ac5336132 100644
--- a/core/base/inc/TROOT.h
+++ b/core/base/inc/TROOT.h
@@ -57,6 +57,7 @@ R__EXTERN TVirtualMutex *gROOTMutex;
 class TROOT : public TDirectory {
 
 friend class TCint;
+friend class TCling;
 
 private:
    Int_t           fLineIsProcessing;     //To synchronize multi-threads
diff --git a/core/base/src/TROOT.cxx b/core/base/src/TROOT.cxx
index fb6fbf18074..f6f1f3bfa24 100644
--- a/core/base/src/TROOT.cxx
+++ b/core/base/src/TROOT.cxx
@@ -104,7 +104,11 @@
 #include "TMap.h"
 #include "TObjString.h"
 #include "TVirtualMutex.h"
-#include "TCint.h"
+#ifdef R__HAS_CLING
+# include "TCling.h"
+#else
+# include "TCint.h"
+#endif
 
 #include <string>
 namespace std {} using namespace std;
diff --git a/core/meta/Module.mk b/core/meta/Module.mk
index 62e1b13d6cd..50519b7d5d6 100644
--- a/core/meta/Module.mk
+++ b/core/meta/Module.mk
@@ -18,13 +18,25 @@ METADS       := $(MODDIRS)/G__Meta.cxx
 METADO       := $(METADS:.cxx=.o)
 METADH       := $(METADS:.cxx=.h)
 
-METAH        := $(filter-out $(MODDIRI)/LinkDef%,$(wildcard $(MODDIRI)/*.h))
-METAH        := $(METAH)
+ifneq ($(BUILDCLING),yes)
+METACL       := $(MODDIRI)/LinkDef_TCint.h
+METACDS      := $(MODDIRS)/G__TCint.cxx
+METACH       := $(MODDIRI)/TCint.h
+else
+METACL       :=
+METACDS      :=
+endif
+METACDO      := $(METACDS:.cxx=.o)
+METACDH      := $(METACDS:.cxx=.h)
+
+METAH        := $(filter-out $(MODDIRI)/TCint.h,$(filter-out $(MODDIRI)/LinkDef%,$(wildcard $(MODDIRI)/*.h)))
 METAS        := $(filter-out $(MODDIRS)/G__%,$(wildcard $(MODDIRS)/*.cxx))
-METAS        := $(METAS)
+ifeq ($(BUILDCLING),yes)
+METAS        := $(filter-out $(MODDIRS)/TCint.cxx,$(METAS))
+endif
 METAO        := $(METAS:.cxx=.o)
 
-METADEP      := $(METAO:.o=.d) $(METADO:.o=.d)
+METADEP      := $(METAO:.o=.d) $(METADO:.o=.d) $(METACDO:.o=.d)
 
 # used in the main Makefile
 ALLHDRS     += $(patsubst $(MODDIRI)/%.h,include/%.h,$(METAH))
@@ -42,14 +54,18 @@ $(METADS):      $(METAH) $(METAL) $(ROOTCINTTMPDEP)
 		@echo "Generating dictionary $@..."
 		$(ROOTCINTTMP) -f $@ -c -DG__API $(METAH) $(METAL)
 
-all-$(MODNAME): $(METAO) $(METADO)
+$(METACDS):     $(METACH) $(METACL) $(ROOTCINTTMPDEP)
+		@echo "Generating dictionary $@..."
+		$(ROOTCINTTMP) -f $@ -c -DG__API $(METACH) $(METACL)
+
+all-$(MODNAME): $(METAO) $(METADO) $(METACDO)
 
 clean-$(MODNAME):
-		@rm -f $(METAO) $(METADO)
+		@rm -f $(METAO) $(METADO) $(METACDO)
 
 clean::         clean-$(MODNAME)
 
 distclean-$(MODNAME): clean-$(MODNAME)
-		@rm -f $(METADEP) $(METADS) $(METADH)
+		@rm -f $(METADEP) $(METADS) $(METADH) $(METACDS) $(METACDH)
 
 distclean::     distclean-$(MODNAME)
diff --git a/core/meta/inc/LinkDef.h b/core/meta/inc/LinkDef.h
index d8e7cc94235..641ace690e3 100644
--- a/core/meta/inc/LinkDef.h
+++ b/core/meta/inc/LinkDef.h
@@ -17,7 +17,6 @@
 
 #pragma link C++ enum EProperty;
 
-#pragma link C++ class TCint;
 #pragma link C++ class TBaseClass;
 #pragma link C++ class TClass;
 #pragma link C++ class TClassStreamer+;
diff --git a/core/meta/inc/LinkDef_TCint.h b/core/meta/inc/LinkDef_TCint.h
new file mode 100644
index 00000000000..e792d346024
--- /dev/null
+++ b/core/meta/inc/LinkDef_TCint.h
@@ -0,0 +1,17 @@
+/* @(#)root/meta:$Id$ */
+
+/*************************************************************************
+ * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
+ * All rights reserved.                                                  *
+ *                                                                       *
+ * For the licensing terms see $ROOTSYS/LICENSE.                         *
+ * For the list of contributors see $ROOTSYS/README/CREDITS.             *
+ *************************************************************************/
+
+#ifdef __CINT__
+
+#pragma link C++ nestedtypedefs;
+#pragma link C++ nestedclasses;
+
+#pragma link C++ class TCint;
+#endif
-- 
GitLab