Blob Blame History Raw
diff -Nur root-6.08.02.orig/bindings/pyroot/CMakeLists.txt root-6.08.02/bindings/pyroot/CMakeLists.txt
--- root-6.08.02.orig/bindings/pyroot/CMakeLists.txt	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/bindings/pyroot/CMakeLists.txt	2016-12-06 12:46:10.280969916 +0100
@@ -36,18 +36,18 @@
 file(GLOB pyfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py)
 foreach(pyfile ${pyfiles})
   install(FILES ${pyfile} DESTINATION ${runtimedir})
-  install(CODE "execute_process(COMMAND python -m py_compile \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${runtimedir}/${pyfile} )")
-  install(CODE "execute_process(COMMAND python -O -m py_compile \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${runtimedir}/${pyfile} )")
-  file(COPY ${pyfile} DESTINATION ${CMAKE_BINARY_DIR}/${runtimedir})
+  install(CODE "execute_process(COMMAND python -m py_compile \$ENV{DESTDIR}${runtimedir}/${pyfile})")
+  install(CODE "execute_process(COMMAND python -O -m py_compile \$ENV{DESTDIR}${runtimedir}/${pyfile})")
+  file(COPY ${pyfile} DESTINATION ${localruntimedir})
 endforeach()
 
-set( JupyROOTDirName "JupyROOT")
+set(JupyROOTDirName "JupyROOT")
 install (DIRECTORY ${JupyROOTDirName} DESTINATION ${runtimedir})
-file(COPY ${JupyROOTDirName} DESTINATION ${CMAKE_BINARY_DIR}/${runtimedir})
+file(COPY ${JupyROOTDirName} DESTINATION ${localruntimedir})
 
 set( JsMVADirName "JsMVA")
 install (DIRECTORY ${JsMVADirName} DESTINATION ${runtimedir})
-file(COPY ${JsMVADirName} DESTINATION ${CMAKE_BINARY_DIR}/${runtimedir})
+file(COPY ${JsMVADirName} DESTINATION ${localruntimedir})
 
 #---Install headers----------------------------------------------------------
 ROOT_INSTALL_HEADERS()
diff -Nur root-6.08.02.orig/bindings/pyroot/ROOT.py root-6.08.02/bindings/pyroot/ROOT.py
--- root-6.08.02.orig/bindings/pyroot/ROOT.py	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/bindings/pyroot/ROOT.py	2016-12-06 12:46:10.281969905 +0100
@@ -516,7 +516,7 @@
 
           # system logon, user logon, and local logon (skip Rint.Logon)
             name = '.rootlogon.C'
-            logons = [ os.path.join( str(self.gRootDir), 'etc', 'system' + name ),
+            logons = [ os.path.join( str(self.TROOT.GetEtcDir()), 'system' + name ),
                        os.path.expanduser( os.path.join( '~', name ) ) ]
             if logons[-1] != os.path.join( os.getcwd(), name ):
                logons.append( name )
diff -Nur root-6.08.02.orig/cmake/modules/RootBuildOptions.cmake root-6.08.02/cmake/modules/RootBuildOptions.cmake
--- root-6.08.02.orig/cmake/modules/RootBuildOptions.cmake	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/cmake/modules/RootBuildOptions.cmake	2016-12-06 12:46:10.281969905 +0100
@@ -234,7 +234,7 @@
 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # point to directories outside the build tree to the install RPATH
 
 # Check whether to add RPATH to the installation (the build tree always has the RPATH enabled)
-if(rpath OR gnuinstall)
+if(rpath)
   set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}) # install LIBDIR
   set(CMAKE_SKIP_INSTALL_RPATH FALSE)          # don't skip the full RPATH for the install tree
 elseif(APPLE)
diff -Nur root-6.08.02.orig/cmake/modules/RootNewMacros.cmake root-6.08.02/cmake/modules/RootNewMacros.cmake
--- root-6.08.02.orig/cmake/modules/RootNewMacros.cmake	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/cmake/modules/RootNewMacros.cmake	2016-12-06 12:46:10.281969905 +0100
@@ -19,6 +19,7 @@
   set(libprefix lib)
   set(ld_library_path PATH)
   set(libsuffix .dll)
+  set(localruntimedir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
   set(runtimedir ${CMAKE_INSTALL_BINDIR})
 elseif(APPLE)
   set(ld_library_path DYLD_LIBRARY_PATH)
@@ -26,6 +27,7 @@
   set(scomment \#)
   set(libprefix lib)
   set(libsuffix .so)
+  set(localruntimedir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
   set(runtimedir ${CMAKE_INSTALL_LIBDIR})
 else()
   set(ld_library_path LD_LIBRARY_PATH)
@@ -33,6 +35,7 @@
   set(scomment \#)
   set(libprefix lib)
   set(libsuffix .so)
+  set(localruntimedir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
   set(runtimedir ${CMAKE_INSTALL_LIBDIR})
 endif()
 
@@ -325,7 +328,15 @@
     set(pcm_name)
   else()
     if(CMAKE_PROJECT_NAME STREQUAL ROOT)
-      set(command rootcling -rootbuild)
+      if(gnuinstall)
+        if(WIN32)
+          set(command set ROOTIGNOREPREFIX=1 && $<TARGET_FILE:rootcling> -rootbuild)
+        else()
+          set(command ROOTIGNOREPREFIX=1 $<TARGET_FILE:rootcling> -rootbuild)
+        endif()
+      else()
+        set(command rootcling -rootbuild)
+      endif()
       set(ROOTCINTDEP rootcling)
     else()
       set(command rootcling)
@@ -441,9 +452,6 @@
   if(TARGET G__${library})
     add_dependencies(${library} G__${library})
   endif()
-  if(TARGET move_headers)
-    add_dependencies(${library} move_headers)
-  endif()
   set_property(GLOBAL APPEND PROPERTY ROOT_EXPORTED_TARGETS ${library})
   set_target_properties(${library} PROPERTIES OUTPUT_NAME ${library_name})
   set_target_properties(${library} PROPERTIES LINK_INTERFACE_LIBRARIES "${ARG_DEPENDENCIES}")
@@ -484,9 +492,6 @@
   if(lib_srcs MATCHES "(^|/)(G__[^.]*)[.]cxx.*")
      add_dependencies(${library} ${CMAKE_MATCH_2})
   endif()
-  if(TARGET move_headers)
-    add_dependencies(${library} move_headers)
-  endif()
 
   #--- Only for building shared libraries
   set_property(TARGET ${library} PROPERTY POSITION_INDEPENDENT_CODE 1)
@@ -532,9 +537,6 @@
   ROOT_GET_SOURCES(lib_srcs src ${ARG_UNPARSED_ARGUMENTS})
   include_directories(${CMAKE_BINARY_DIR}/include)
   add_library( ${library} SHARED ${lib_srcs})
-  if(TARGET move_headers)
-    add_dependencies(${library} move_headers)
-  endif()
   set_target_properties(${library}  PROPERTIES ${ROOT_LIBRARY_PROPERTIES})
   # Do not add -Dname_EXPORTS to the command-line when building files in this
   # target. Doing so is actively harmful for the modules build because it
@@ -617,6 +619,10 @@
                            PATTERN ".svn" EXCLUDE
                            REGEX "LinkDef" EXCLUDE
                            ${ARG_OPTIONS})
+    file(COPY ${d} DESTINATION ${CMAKE_BINARY_DIR}/include
+                   PATTERN ".svn" EXCLUDE
+                   REGEX "LinkDef" EXCLUDE
+                   ${ARG_OPTIONS})
     set_property(GLOBAL APPEND PROPERTY ROOT_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/${d})
   endforeach()
 endfunction()
@@ -656,9 +662,6 @@
   if (ARG_ADDITIONAL_COMPILE_FLAGS)
     set_target_properties(${executable} PROPERTIES COMPILE_FLAGS ${ARG_ADDITIONAL_COMPILE_FLAGS})
   endif()
-  if(TARGET move_headers)
-    add_dependencies(${executable} move_headers)
-  endif()
 
   #----Installation details------------------------------------------------------
   if(NOT ARG_NOINSTALL AND CMAKE_RUNTIME_OUTPUT_DIRECTORY)
@@ -878,6 +881,9 @@
     set_property(TEST ${test} PROPERTY ENVIRONMENT ROOT_DIR=${CMAKE_BINARY_DIR})
   else()
     add_test(NAME ${test} COMMAND ${_command})
+    if (gnuinstall)
+      set_property(TEST ${test} PROPERTY ENVIRONMENT ROOTIGNOREPREFIX=1)
+    endif()
   endif()
 
   #- Handle TIMOUT and DEPENDS arguments
diff -Nur root-6.08.02.orig/cmake/scripts/local_install.cmake root-6.08.02/cmake/scripts/local_install.cmake
--- root-6.08.02.orig/cmake/scripts/local_install.cmake	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/cmake/scripts/local_install.cmake	1970-01-01 01:00:00.000000000 +0100
@@ -1,20 +0,0 @@
-# Arguments:
-#  PREFIX    - Installation prefix
-#  COMPONENTS - Installation component
-
-set(COMPONENTS ${COMPONENTS})
-set(ENV{DESTDIR} "")
-foreach(component ${COMPONENTS})
-  execute_process(
-    COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${PREFIX}
-                             -DCMAKE_INSTALL_COMPONENT=${component}
-                             -P cmake_install.cmake
-    RESULT_VARIABLE result
-    OUTPUT_QUIET
-  )
-
-  if(result)
-    set(msg "Local installation of ${component} failed: ${result}\n")
-    message(FATAL_ERROR "${msg}")
-  endif()
-endforeach()
diff -Nur root-6.08.02.orig/CMakeLists.txt root-6.08.02/CMakeLists.txt
--- root-6.08.02.orig/CMakeLists.txt	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/CMakeLists.txt	2016-12-06 12:46:10.290969803 +0100
@@ -91,7 +91,7 @@
   endif()
 endforeach()
 
-#---Move (copy) the headers and other directories to binary tree---------------------------------
+#---Move (copy) directories to binary tree------------------------------------------------------
 set(stamp_file ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/move_artifacts.stamp)
 add_custom_command(OUTPUT ${stamp_file}
                    COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/etc ${CMAKE_BINARY_DIR}/etc
@@ -119,11 +119,7 @@
   endif()
 endforeach()
 
-add_custom_target(move_headers DEPENDS ${stamp_file} ${tutorial_files_builddir}
-                               COMMAND ${CMAKE_COMMAND} -DPREFIX=${CMAKE_BINARY_DIR}
-                                                        -DCOMPONENTS="headers"
-                                                        -P ${CMAKE_SOURCE_DIR}/cmake/scripts/local_install.cmake)
-include_directories(${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR})
+add_custom_target(move_artifacts DEPENDS ${stamp_file} ${tutorial_files_builddir})
 
 
 #---Recurse into the given subdirectories.  This does not actually cause another cmake executable
@@ -179,13 +175,23 @@
                    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/build/unix/makepchinput.py ${CMAKE_SOURCE_DIR} . ${__clingetcpch} -- ${CMAKE_CXX_FLAGS_SEPARATE}
                    DEPENDS ${CMAKE_SOURCE_DIR}/build/unix/makepchinput.py ${__allFiles})
 
-add_custom_command(OUTPUT etc/allDict.cxx.pch
-                   COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/etc/dictpch/makepch.py etc/allDict.cxx.pch -I${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}
-                   DEPENDS ${CMAKE_SOURCE_DIR}/etc/dictpch/makepch.py
-                           etc/dictpch/allLinkDefs.h
-                           etc/dictpch/allHeaders.h
-                           etc/dictpch/allCppflags.txt
-                           rootcling)
+if (WIN32)
+  add_custom_command(OUTPUT etc/allDict.cxx.pch
+                     COMMAND set ROOTIGNOREPREFIX=1 && ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/etc/dictpch/makepch.py etc/allDict.cxx.pch -I${CMAKE_BINARY_DIR}/include
+                     DEPENDS ${CMAKE_SOURCE_DIR}/etc/dictpch/makepch.py
+                             etc/dictpch/allLinkDefs.h
+                             etc/dictpch/allHeaders.h
+                             etc/dictpch/allCppflags.txt
+                             rootcling)
+else()
+  add_custom_command(OUTPUT etc/allDict.cxx.pch
+                     COMMAND ROOTIGNOREPREFIX=1 ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/etc/dictpch/makepch.py etc/allDict.cxx.pch -I${CMAKE_BINARY_DIR}/include
+                     DEPENDS ${CMAKE_SOURCE_DIR}/etc/dictpch/makepch.py
+                             etc/dictpch/allLinkDefs.h
+                             etc/dictpch/allHeaders.h
+                             etc/dictpch/allCppflags.txt
+                             rootcling)
+endif()
 add_custom_target(onepcm ALL DEPENDS etc/allDict.cxx.pch)
 set_source_files_properties(${__allFiles} PROPERTIES GENERATED TRUE)
 add_dependencies(onepcm ${__allTargets})
@@ -198,26 +204,27 @@
                     DEPENDS build/unix/module.modulemap
                     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/build/unix/module.modulemap ${CMAKE_BINARY_DIR}/include/module.modulemap
                     )
-  add_dependencies(copymodulemap move_headers)
 endif(cxxmodules)
 
 #---hsimple.root---------(use the executable for clearer dependencies and proper return code)---
-if(NOT gnuinstall)   # TODO hsimple.root for gnuinstall
-  add_custom_target(hsimple ALL DEPENDS tutorials/hsimple.root)
-  add_dependencies(hsimple onepcm)
-  if(WIN32)
-    add_custom_command(OUTPUT tutorials/hsimple.root
-                       COMMAND set PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} && 
-                               $<TARGET_FILE:root.exe> -l -q -b -n -x hsimple.C -e return
-                       WORKING_DIRECTORY tutorials DEPENDS root.exe Cling Hist Tree Gpad Graf HistPainter)
-  else()
-    add_custom_command(OUTPUT tutorials/hsimple.root
-                       COMMAND ${ld_library_path}=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}:$ENV{${ld_library_path}} 
-                               $<TARGET_FILE:root.exe> -l -q -b -n -x hsimple.C -e return
-                       WORKING_DIRECTORY tutorials DEPENDS root.exe Cling Hist Tree Gpad Graf HistPainter)
-  endif()
-  install(FILES ${CMAKE_BINARY_DIR}/tutorials/hsimple.root DESTINATION ${CMAKE_INSTALL_TUTDIR} COMPONENT tests)
+add_custom_target(hsimple ALL DEPENDS tutorials/hsimple.root)
+add_dependencies(hsimple onepcm)
+if(WIN32)
+  add_custom_command(OUTPUT tutorials/hsimple.root
+                     COMMAND set PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} &&
+                             set ROOTIGNOREPREFIX=1 &&
+                             $<TARGET_FILE:root.exe> -l -q -b -n -x hsimple.C -e return
+                     WORKING_DIRECTORY tutorials
+                     DEPENDS $<TARGET_FILE:root.exe> Cling Hist Tree Gpad Graf HistPainter move_artifacts)
+else()
+  add_custom_command(OUTPUT tutorials/hsimple.root
+                     COMMAND ${ld_library_path}=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}:$ENV{${ld_library_path}}
+                             ROOTIGNOREPREFIX=1
+                             $<TARGET_FILE:root.exe> -l -q -b -n -x hsimple.C -e return
+                     WORKING_DIRECTORY tutorials
+                     DEPENDS $<TARGET_FILE:root.exe> Cling Hist Tree Gpad Graf HistPainter move_artifacts)
 endif()
+install(FILES ${CMAKE_BINARY_DIR}/tutorials/hsimple.root DESTINATION ${CMAKE_INSTALL_TUTDIR} COMPONENT tests)
 
 #---version--------------------------------------------------------------------------------------
 add_custom_target(version COMMAND ${CMAKE_SOURCE_DIR}/build/unix/makeversion.sh ${CMAKE_BINARY_DIR}
@@ -262,9 +269,6 @@
 #---Configure Testing using CTest----------------------------------------------------------------
 configure_file(${CMAKE_SOURCE_DIR}/cmake/modules/CTestCustom.cmake ${CMAKE_BINARY_DIR} COPYONLY)
 if(testing)
-  if(gnuinstall)
-    message(FATAL_ERROR "You cannot enable to run the tests in the build directory (testing=ON) and at the same time select a GNU style installation (gnuinstall=ON). This is because the code is built with the final installation location (CMAKE_INSTALL_PREFIX) for many ancillary files (tutorials, etc, icons, macros, etc.) and these are not available before installation. Tests can be run against the installation once is completed. See the instructions in the web")
-  endif()
   include(RootCTest)
   if(roottest)
     find_package(Git REQUIRED)
diff -Nur root-6.08.02.orig/config/RConfigure.in root-6.08.02/config/RConfigure.in
--- root-6.08.02.orig/config/RConfigure.in	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/config/RConfigure.in	2016-12-06 12:46:10.290969803 +0100
@@ -14,10 +14,11 @@
 #define ROOTTUTDIR    "@tutdir@"
 #define ROOTSRCDIR    "@srcdir@"
 #define ROOTICONPATH  "@iconpath@"
-#define EXTRAICONPATH "@extraiconpath@"
 #define TTFFONTDIR    "@ttffontdir@"
 #endif
 
+#define EXTRAICONPATH "@extraiconpath@"
+
 #@setresuid@ R__HAS_SETRESUID   /**/
 #@hasmathmore@ R__HAS_MATHMORE   /**/
 #@haspthread@ R__HAS_PTHREAD    /**/
diff -Nur root-6.08.02.orig/config/rootrc.in root-6.08.02/config/rootrc.in
--- root-6.08.02.orig/config/rootrc.in	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/config/rootrc.in	2016-12-06 12:46:10.291969792 +0100
@@ -9,24 +9,24 @@
 # and to PATH on Windows.
 # Paths are different for Unix and Windows. The example shows the defaults
 # for all ROOT applications for either Unix or Windows.
-Unix.*.Root.DynamicPath:    .:@libdir@:
-WinNT.*.Root.DynamicPath:   .;@bindir@;
+#Unix.*.Root.DynamicPath:    .:@libdir@
+#WinNT.*.Root.DynamicPath:   .;@bindir@
 
 # Path used to find macros.
 # Paths are different for Unix and Windows. The example shows the defaults
 # for all ROOT applications for either Unix or Windows.
-Unix.*.Root.MacroPath:      .:@macrodir@:
-WinNT.*.Root.MacroPath:     .;@macrodir@;
+#Unix.*.Root.MacroPath:      .:@macrodir@
+#WinNT.*.Root.MacroPath:     .;@macrodir@
 
 # Path used to find plugin macros.
 # Paths are different for Unix and Windows. The example shows the defaults
 # for all ROOT applications for either Unix or Windows.
-Unix.*.Root.PluginPath:      :@plugindir@:
-WinNT.*.Root.PluginPath:     ;@plugindir@;
+#Unix.*.Root.PluginPath:     @plugindir@
+#WinNT.*.Root.PluginPath:    @plugindir@
 
 # Path where to look for TrueType fonts.
 Unix.*.Root.UseTTFonts:     true
-*.*.Root.TTFontPath:        @ttffontdir@
+#*.*.Root.TTFontPath:        @ttffontdir@
 
 # Use Net* API functions.
 WinNT.UseNetAPI:         true
@@ -222,7 +222,8 @@
 Gui.DocumentForegroundColor: black
 Gui.TooltipBackgroundColor:  LightYellow
 Gui.TooltipForegroundColor:  black
-Gui.IconPath:                $(HOME)/icons:@iconpath@:.
+#Unix.*.Gui.IconPath:         .:$(HOME)/icons:@iconpath@:@extraiconpath@
+#WinNT.*.Gui.IconPath:        .;$(HOME)/icons;@iconpath@;@extraiconpath@
 Gui.MimeTypeFile:            $(HOME)/.root.mimes
 # If above does not exists defaults to this:
 #Gui.MimeTypeFile:            @etcdir@/root.mimes
diff -Nur root-6.08.02.orig/configure root-6.08.02/configure
--- root-6.08.02.orig/configure	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/configure	2016-12-06 12:46:10.307969611 +0100
@@ -8229,6 +8229,7 @@
     -e "s|@bindir@|$bindir|"               \
     -e "s|@etcdir@|$etcdir|"               \
     -e "s|@ttffontdir@|$fontdir|"          \
+    -e "s|@extraiconpath@|$extraiconpath|" \
     -e "s|@iconpath@|$iconpath|"           \
     -e "s|@hasxrd@|$hasxrd|"               \
     -e "s|@hasnotxrd@|$hasnotxrd|"         \
diff -Nur root-6.08.02.orig/core/base/inc/TROOT.h root-6.08.02/core/base/inc/TROOT.h
--- root-6.08.02.orig/core/base/inc/TROOT.h	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/base/inc/TROOT.h	2016-12-06 12:46:10.307969611 +0100
@@ -349,6 +349,21 @@
    static Int_t       ConvertVersionInt2Code(Int_t v);
    static Int_t       RootVersionCode();
    static const char**&GetExtraInterpreterArgs();
+
+   static const TString& GetRootSys();
+   static const TString& GetBinDir();
+   static const TString& GetLibDir();
+   static const TString& GetIncludeDir();
+   static const TString& GetEtcDir();
+   static const TString& GetDataDir();
+   static const TString& GetDocDir();
+   static const TString& GetMacroDir();
+   static const TString& GetTutorialDir();
+   static const TString& GetSourceDir();
+   static const TString& GetIconPath();
+   static const TString& GetTTFFontDir();
+
+   // Backward compatibility function - do not use for new code
    static const char *GetTutorialsDir();
 
    ClassDef(TROOT,0)  //Top level (or root) structure for all classes
diff -Nur root-6.08.02.orig/core/base/src/TApplication.cxx root-6.08.02/core/base/src/TApplication.cxx
--- root-6.08.02.orig/core/base/src/TApplication.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/base/src/TApplication.cxx	2016-12-06 12:46:10.308969599 +0100
@@ -276,11 +276,7 @@
    // mode and Root.UseTTFonts is true and Root.TTFontPath exists. Abort silently
    // if libttf or libGX11TTF are not found in $ROOTSYS/lib or $ROOTSYS/ttf/lib.
    const char *ttpath = gEnv->GetValue("Root.TTFontPath",
-#ifdef TTFFONTDIR
-                                       TTFFONTDIR);
-#else
-                                       "$(ROOTSYS)/fonts");
-#endif
+                                       TROOT::GetTTFFontDir());
    char *ttfont = gSystem->Which(ttpath, "arialbd.ttf", kReadPermission);
    // Check for use of DFSG - fonts
    if (!ttfont)
@@ -888,29 +884,19 @@
          Error("ProcessLine", "Cannot show demos in batch mode!");
          return 1;
       }
-#ifdef ROOTTUTDIR
-      ProcessLine(".x " ROOTTUTDIR "/demos.C");
-#else
-      ProcessLine(".x $(ROOTSYS)/tutorials/demos.C");
-#endif
+      ProcessLine(".x " + TROOT::GetTutorialDir() + "/demos.C");
       return 0;
    }
 
    if (!strncmp(line, ".license", 8)) {
-#ifdef ROOTDOCDIR
-      return PrintFile(ROOTDOCDIR "/LICENSE");
-#else
-      return PrintFile("$(ROOTSYS)/LICENSE");
-#endif
+      return PrintFile(TROOT::GetDocDir() + "/LICENSE");
    }
 
    if (!strncmp(line, ".credits", 8)) {
-#ifdef ROOTDOCDIR
-      return PrintFile(ROOTDOCDIR "/CREDITS");
-#else
-      return PrintFile("$(ROOTSYS)/README/CREDITS");
-#endif
-
+      TString credits = TROOT::GetDocDir() + "/CREDITS";
+      if (gSystem->AccessPathName(credits, kReadPermission))
+         credits = TROOT::GetDocDir() + "/README/CREDITS";
+      return PrintFile(credits);
    }
 
    if (!strncmp(line, ".pwd", 4)) {
diff -Nur root-6.08.02.orig/core/base/src/TEnv.cxx root-6.08.02/core/base/src/TEnv.cxx
--- root-6.08.02.orig/core/base/src/TEnv.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/base/src/TEnv.cxx	2016-12-06 12:46:10.308969599 +0100
@@ -401,21 +401,7 @@
 
       TString sname = "system";
       sname += name;
-#ifdef ROOTETCDIR
-      char *s = gSystem->ConcatFileName(ROOTETCDIR, sname);
-#else
-      TString etc = gRootDir;
-#ifdef WIN32
-      etc += "\\etc";
-#else
-      etc += "/etc";
-#endif
-#if defined(R__MACOSX) && (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
-      // on iOS etc does not exist and system<name> resides in $ROOTSYS
-      etc = gRootDir;
-#endif
-      char *s = gSystem->ConcatFileName(etc, sname);
-#endif
+      char *s = gSystem->ConcatFileName(TROOT::GetEtcDir(), sname);
       ReadFile(s, kEnvGlobal);
       delete [] s;
       if (!gSystem->Getenv("ROOTENV_NO_HOME")) {
@@ -685,17 +671,7 @@
 
       TString sname = "system";
       sname += fRcName;
-#ifdef ROOTETCDIR
-      char *s = gSystem->ConcatFileName(ROOTETCDIR, sname);
-#else
-      TString etc = gRootDir;
-#ifdef WIN32
-      etc += "\\etc";
-#else
-      etc += "/etc";
-#endif
-      char *s = gSystem->ConcatFileName(etc, sname);
-#endif
+      char *s = gSystem->ConcatFileName(TROOT::GetEtcDir(), sname);
       rootrcdir = s;
       delete [] s;
    } else if (level == kEnvUser) {
diff -Nur root-6.08.02.orig/core/base/src/TPluginManager.cxx root-6.08.02/core/base/src/TPluginManager.cxx
--- root-6.08.02.orig/core/base/src/TPluginManager.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/base/src/TPluginManager.cxx	2016-12-06 12:46:10.308969599 +0100
@@ -470,6 +470,10 @@
       TPH__IsReadingDirs() = kTRUE;
 
       TString plugindirs = gEnv->GetValue("Root.PluginPath", (char*)0);
+      if (plugindirs.Length() == 0) {
+         plugindirs = "plugins";
+         gSystem->PrependPathName(TROOT::GetEtcDir(), plugindirs);
+      }
 #ifdef WIN32
       dirs = plugindirs.Tokenize(";");
 #else
diff -Nur root-6.08.02.orig/core/base/src/TROOT.cxx root-6.08.02/core/base/src/TROOT.cxx
--- root-6.08.02.orig/core/base/src/TROOT.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/base/src/TROOT.cxx	2016-12-06 12:46:10.309969588 +0100
@@ -643,6 +643,22 @@
    // Initialize Operating System interface
    InitSystem();
 
+   // Initialize static directory functions
+   GetRootSys();
+   GetBinDir();
+   GetLibDir();
+   GetIncludeDir();
+   GetEtcDir();
+   GetDataDir();
+   GetDocDir();
+   GetMacroDir();
+   GetTutorialDir();
+   GetSourceDir();
+   GetIconPath();
+   GetTTFFontDir();
+
+   gRootDir = GetRootSys().Data();
+
    TDirectory::Build();
 
    // Initialize interface to CINT C++ interpreter
@@ -1876,21 +1892,9 @@
                "after the call to TROOT::InitInterpreter()!");
       }
 
-      const char *libcling = 0;
-      char *libclingStorage = 0;
-#ifdef ROOTLIBDIR
-      libcling = ROOTLIBDIR "/libCling."
-# ifdef R__WIN32
-      "dll";
-# else
-      "so";
-# endif
-#else
-      libclingStorage = gSystem->DynamicPathName("libCling");
-      libcling = libclingStorage;
-#endif
+      char *libcling = gSystem->DynamicPathName("libCling");
       gInterpreterLib = dlopen(libcling, RTLD_LAZY|RTLD_LOCAL);
-      delete [] libclingStorage;
+      delete [] libcling;
 
       if (!gInterpreterLib) {
          TString err = dlerror();
@@ -2237,22 +2241,7 @@
 #endif
 
    TString gitinfo = "gitinfo.txt";
-   char *filename = 0;
-#ifdef ROOTETCDIR
-   filename = gSystem->ConcatFileName(ROOTETCDIR, gitinfo);
-#else
-   TString etc = gRootDir;
-#ifdef WIN32
-   etc += "\\etc";
-#else
-   etc += "/etc";
-#endif
-#if defined(R__MACOSX) && (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
-   // on iOS etc does not exist and gitinfo resides in $ROOTSYS
-   etc = gRootDir;
-#endif
-   filename = gSystem->ConcatFileName(etc, gitinfo);
-#endif
+   char *filename = gSystem->ConcatFileName(TROOT::GetEtcDir(), gitinfo);
 
    FILE *fp = fopen(filename, "r");
    if (fp) {
@@ -2570,17 +2559,9 @@
 #endif
       if (macroPath.Length() == 0)
 #if !defined(R__WIN32)
-   #ifdef ROOTMACRODIR
-         macroPath = ".:" ROOTMACRODIR;
-   #else
-         macroPath = TString(".:") + gRootDir + "/macros";
-   #endif
+         macroPath = ".:" + TROOT::GetMacroDir();
 #else
-   #ifdef ROOTMACRODIR
-         macroPath = ".;" ROOTMACRODIR;
-   #else
-         macroPath = TString(".;") + gRootDir + "/macros";
-   #endif
+         macroPath = ".;" + TROOT::GetMacroDir();
 #endif
    }
 
@@ -2676,14 +2657,260 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+
+#ifdef ROOTPREFIX
+static Bool_t IgnorePrefix() {
+   static Bool_t ignorePrefix = gSystem->Getenv("ROOTIGNOREPREFIX");
+   return ignorePrefix;
+}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get the rootsys directory in the installation. Static utility function.
+
+const TString& TROOT::GetRootSys() {
+#ifdef ROOTPREFIX
+   if (IgnorePrefix()) {
+#endif
+      static TString rootsys;
+      if (rootsys.IsNull())
+         rootsys = gSystem->Getenv("ROOTSYS");
+      if (rootsys.IsNull())
+         rootsys = gRootDir;
+      return rootsys;
+#ifdef ROOTPREFIX
+   } else {
+      const static TString rootsys = ROOTPREFIX;
+      return rootsys;
+   }
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get the binary directory in the installation. Static utility function.
+
+const TString& TROOT::GetBinDir() {
+#ifdef ROOTBINDIR
+   if (IgnorePrefix()) {
+#endif
+      static TString rootbindir;
+      if (rootbindir.IsNull()) {
+         rootbindir = "bin";
+         gSystem->PrependPathName(GetRootSys(), rootbindir);
+      }
+      return rootbindir;
+#ifdef ROOTBINDIR
+   } else {
+      const static TString rootbindir = ROOTBINDIR;
+      return rootbindir;
+   }
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get the library directory in the installation. Static utility function.
+
+const TString& TROOT::GetLibDir() {
+#ifdef ROOTLIBDIR
+   if (IgnorePrefix()) {
+#endif
+      static TString rootlibdir;
+      if (rootlibdir.IsNull()) {
+         rootlibdir = "lib";
+         gSystem->PrependPathName(GetRootSys(), rootlibdir);
+      }
+      return rootlibdir;
+#ifdef ROOTLIBDIR
+   } else {
+      const static TString rootlibdir = ROOTLIBDIR;
+      return rootlibdir;
+   }
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get the include directory in the installation. Static utility function.
+
+const TString& TROOT::GetIncludeDir() {
+#ifdef ROOTINCDIR
+   if (IgnorePrefix()) {
+#endif
+      static TString rootincdir;
+      if (rootincdir.IsNull()) {
+         rootincdir = "include";
+         gSystem->PrependPathName(GetRootSys(), rootincdir);
+      }
+      return rootincdir;
+#ifdef ROOTINCDIR
+   } else {
+      const static TString rootincdir = ROOTINCDIR;
+      return rootincdir;
+   }
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get the sysconfig directory in the installation. Static utility function.
+
+const TString& TROOT::GetEtcDir() {
+#ifdef ROOTETCDIR
+   if (IgnorePrefix()) {
+#endif
+      static TString rootetcdir;
+      if (rootetcdir.IsNull()) {
+         rootetcdir = "etc";
+         gSystem->PrependPathName(GetRootSys(), rootetcdir);
+      }
+      return rootetcdir;
+#ifdef ROOTETCDIR
+   } else {
+      const static TString rootetcdir = ROOTETCDIR;
+      return rootetcdir;
+   }
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get the data directory in the installation. Static utility function.
+
+const TString& TROOT::GetDataDir() {
+#ifdef ROOTDATADIR
+   if (IgnorePrefix()) {
+#endif
+      return GetRootSys();
+#ifdef ROOTDATADIR
+   } else {
+      const static TString rootdatadir = ROOTDATADIR;
+      return rootdatadir;
+   }
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get the documentation directory in the installation. Static utility function.
+
+const TString& TROOT::GetDocDir() {
+#ifdef ROOTDOCDIR
+   if (IgnorePrefix()) {
+#endif
+      return GetRootSys();
+#ifdef ROOTDOCDIR
+   } else {
+      const static TString rootdocdir = ROOTDOCDIR;
+      return rootdocdir;
+   }
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get the macro directory in the installation. Static utility function.
+
+const TString& TROOT::GetMacroDir() {
+#ifdef ROOTMACRODIR
+   if (IgnorePrefix()) {
+#endif
+      static TString rootmacrodir;
+      if (rootmacrodir.IsNull()) {
+         rootmacrodir = "macros";
+         gSystem->PrependPathName(GetRootSys(), rootmacrodir);
+      }
+      return rootmacrodir;
+#ifdef ROOTMACRODIR
+   } else {
+      const static TString rootmacrodir = ROOTMACRODIR;
+      return rootmacrodir;
+   }
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
 /// Get the tutorials directory in the installation. Static utility function.
 
-const char *TROOT::GetTutorialsDir()
-{
+const TString& TROOT::GetTutorialDir() {
 #ifdef ROOTTUTDIR
-   return ROOTTUTDIR;
-#else
-   static TString tutdir = TString(gRootDir) + "/tutorials";
-   return tutdir;
+   if (IgnorePrefix()) {
+#endif
+      static TString roottutdir;
+      if (roottutdir.IsNull()) {
+         roottutdir = "tutorials";
+         gSystem->PrependPathName(GetRootSys(), roottutdir);
+      }
+      return roottutdir;
+#ifdef ROOTTUTDIR
+   } else {
+      const static TString roottutdir = ROOTTUTDIR;
+      return roottutdir;
+   }
 #endif
 }
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get the source directory in the installation. Static utility function.
+
+const TString& TROOT::GetSourceDir() {
+#ifdef ROOTSRCDIR
+   if (IgnorePrefix()) {
+#endif
+      static TString rootsrcdir;
+      if (rootsrcdir.IsNull()) {
+         rootsrcdir = "src";
+         gSystem->PrependPathName(GetRootSys(), rootsrcdir);
+      }
+      return rootsrcdir;
+#ifdef ROOTSRCDIR
+   } else {
+      const static TString rootsrcdir = ROOTSRCDIR;
+      return rootsrcdir;
+   }
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get the icon path in the installation. Static utility function.
+
+const TString& TROOT::GetIconPath() {
+#ifdef ROOTICONPATH
+   if (IgnorePrefix()) {
+#endif
+      static TString rooticonpath;
+      if (rooticonpath.IsNull()) {
+         rooticonpath = "icons";
+         gSystem->PrependPathName(GetRootSys(), rooticonpath);
+      }
+      return rooticonpath;
+#ifdef ROOTICONPATH
+   } else {
+      const static TString rooticonpath = ROOTICONPATH;
+      return rooticonpath;
+   }
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get the fonts directory in the installation. Static utility function.
+
+const TString& TROOT::GetTTFFontDir() {
+#ifdef TTFFONTDIR
+   if (IgnorePrefix()) {
+#endif
+      static TString ttffontdir;
+      if (ttffontdir.IsNull()) {
+         ttffontdir = "fonts";
+         gSystem->PrependPathName(GetRootSys(), ttffontdir);
+      }
+      return ttffontdir;
+#ifdef TTFFONTDIR
+   } else {
+      const static TString ttffontdir = TTFFONTDIR;
+      return ttffontdir;
+   }
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get the tutorials directory in the installation. Static utility function.
+/// Backward compatibility function - do not use for new code
+
+const char *TROOT::GetTutorialsDir() {
+   return GetTutorialDir();
+}
diff -Nur root-6.08.02.orig/core/base/src/TSystem.cxx root-6.08.02/core/base/src/TSystem.cxx
--- root-6.08.02.orig/core/base/src/TSystem.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/base/src/TSystem.cxx	2016-12-06 12:46:10.310969577 +0100
@@ -1904,22 +1904,10 @@
       if (!system) {
          // Mark the library in $ROOTSYS/lib as system.
          const char *dirname = DirName(path);
-#ifdef ROOTLIBDIR
-         TString rootlibdir = ROOTLIBDIR;
-#else
-         TString rootlibdir = "lib";
-         PrependPathName(gRootDir, rootlibdir);
-#endif
-         system = R__MatchFilename(rootlibdir,dirname);
+         system = R__MatchFilename(TROOT::GetLibDir(), dirname);
 
          if (!system) {
-#ifdef ROOTBINDIR
-            TString rootbindir = ROOTBINDIR;
-#else
-            TString rootbindir = "bin";
-            PrependPathName(gRootDir, rootbindir);
-#endif
-            system = R__MatchFilename(rootbindir,dirname);
+            system = R__MatchFilename(TROOT::GetBinDir(), dirname);
          }
       }
 
@@ -2571,12 +2559,9 @@
 #else
    TString touch = "echo > "; touch += "\"" + depfilename + "\"";
 #endif
-#ifdef ROOTBINDIR
-   TString builddep = ROOTBINDIR;
-#else
-   TString builddep = TString(gRootDir) + "/bin";
-#endif
-   builddep += "/rmkdepend \"-f";
+   TString builddep = "rmkdepend";
+   gSystem->PrependPathName(TROOT::GetBinDir(), builddep);
+   builddep += " \"-f";
    builddep += depfilename;
    builddep += "\" -o_" + extension + "." + gSystem->GetSoExt() + " ";
    if (build_loc.BeginsWith(gSystem->WorkingDirectory())) {
@@ -2598,12 +2583,7 @@
       builddep += "/\" ";
    }
    builddep += " -Y -- ";
-#ifndef ROOTINCDIR
-   TString rootsysInclude = gSystem->Getenv("ROOTSYS");
-   rootsysInclude += "/include";
-#else
-   TString rootsysInclude = ROOTINCDIR;
-#endif
+   TString rootsysInclude = TROOT::GetIncludeDir();
    builddep += " \"-I"+rootsysInclude+"\" "; // cflags
    builddep += includes;
    builddep += defines;
@@ -3434,27 +3414,17 @@
       TString name = ".rootmap";
       TString sname = "system.rootmap";
       TString file;
-#ifdef ROOTETCDIR
-      AssignAndDelete(file, ConcatFileName(ROOTETCDIR, sname) );
-#else
-      TString etc = gRootDir;
-#ifdef WIN32
-      etc += "\\etc";
-#else
-      etc += "/etc";
-#endif
-      AssignAndDelete(file, ConcatFileName(etc, sname));
+      AssignAndDelete(file, ConcatFileName(TROOT::GetEtcDir(), sname) );
       if (gSystem->AccessPathName(file)) {
          // for backward compatibility check also $ROOTSYS/system<name> if
          // $ROOTSYS/etc/system<name> does not exist
-         AssignAndDelete(file, ConcatFileName(gRootDir, sname));
+         AssignAndDelete(file, ConcatFileName(TROOT::GetRootSys(), sname));
          if (gSystem->AccessPathName(file)) {
             // for backward compatibility check also $ROOTSYS/<name> if
             // $ROOTSYS/system<name> does not exist
-            AssignAndDelete(file, ConcatFileName(gRootDir, name));
+            AssignAndDelete(file, ConcatFileName(TROOT::GetRootSys(), name));
          }
       }
-#endif
       mapfileStream << file << std::endl;
       AssignAndDelete(file, ConcatFileName(gSystem->HomeDirectory(), name) );
       mapfileStream << file << std::endl;
@@ -3468,23 +3438,9 @@
    mapfileStream.close();
 
    // ======= Generate the rootcling command line
-   TString rcling;
-#ifndef ROOTBINDIR
-   rcling = gSystem->Getenv("ROOTSYS");
-#ifndef R__WIN32
-   rcling += "/bin/";
-#else
-   rcling += "\\bin\\";
-#endif
-#else
-   rcling = ROOTBINDIR;
-#ifndef R__WIN32
-   rcling += "/";
-#else
-   rcling += "\\";
-#endif
-#endif
-   rcling += "rootcling -v0 \"--lib-list-prefix=";
+   TString rcling = "rootcling";
+   PrependPathName(TROOT::GetBinDir(), rcling);
+   rcling += " -v0 \"--lib-list-prefix=";
    rcling += mapfile;
    rcling += "\" -f \"";
    rcling.Append(dict).Append("\" -c -p ");
diff -Nur root-6.08.02.orig/core/CMakeLists.txt root-6.08.02/core/CMakeLists.txt
--- root-6.08.02.orig/core/CMakeLists.txt	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/CMakeLists.txt	2016-12-06 12:46:10.310969577 +0100
@@ -63,14 +63,14 @@
                      COMMAND ${CMAKE_SOURCE_DIR}/build/win/gitinfo.bat ${CMAKE_SOURCE_DIR}
                      COMMAND ${CMAKE_SOURCE_DIR}/build/win/githeader.bat RGitCommit.h.tmp
                      COMMENT "Recording the git revision now"
-                     DEPENDS ${dep_objects}
+                     DEPENDS ${dep_objects} move_artifacts
                      WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
 else()
   add_custom_command(OUTPUT  ${CMAKE_BINARY_DIR}/RGitCommit.h.tmp
                      COMMAND ${CMAKE_SOURCE_DIR}/build/unix/gitinfo.sh ${CMAKE_SOURCE_DIR}
                      COMMAND ${CMAKE_SOURCE_DIR}/build/unix/githeader.sh RGitCommit.h.tmp
                      COMMENT "Recording the git revision now"
-                     DEPENDS ${dep_objects}
+                     DEPENDS ${dep_objects} move_artifacts
                      WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
 endif()
 add_custom_target(gitcommit ALL DEPENDS ${CMAKE_BINARY_DIR}/RGitCommit.h.tmp)
diff -Nur root-6.08.02.orig/core/meta/src/TClass.cxx root-6.08.02/core/meta/src/TClass.cxx
--- root-6.08.02.orig/core/meta/src/TClass.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/meta/src/TClass.cxx	2016-12-06 12:46:10.311969565 +0100
@@ -1722,17 +1722,7 @@
 {
    static const char *suffix = "class.rules";
    TString sname = suffix;
-#ifdef ROOTETCDIR
-   gSystem->PrependPathName(ROOTETCDIR, sname);
-#else
-   TString etc = gRootDir;
-#ifdef WIN32
-   etc += "\\etc";
-#else
-   etc += "/etc";
-#endif
-   gSystem->PrependPathName(etc, sname);
-#endif
+   gSystem->PrependPathName(TROOT::GetEtcDir(), sname);
 
    Int_t res = -1;
 
diff -Nur root-6.08.02.orig/core/meta/src/TCling.cxx root-6.08.02/core/meta/src/TCling.cxx
--- root-6.08.02.orig/core/meta/src/TCling.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/meta/src/TCling.cxx	2016-12-06 12:46:10.313969543 +0100
@@ -1056,27 +1056,26 @@
    std::vector<std::string> clingArgsStorage;
    clingArgsStorage.push_back("cling4root");
 
-   std::string interpInclude;
    // rootcling sets its arguments through TROOT::GetExtraInterpreterArgs().
    if (!fromRootCling) {
       ROOT::TMetaUtils::SetPathsForRelocatability(clingArgsStorage);
 
       // Add -I early so ASTReader can find the headers.
-      std::string interpInclude = ROOT::TMetaUtils::GetInterpreterExtraIncludePath(false);
-      clingArgsStorage.push_back(interpInclude);
+      std::string interpInclude(TROOT::GetEtcDir());
+      clingArgsStorage.push_back("-I" + interpInclude);
 
       // Add include path to etc/cling. FIXME: This is a short term solution. The
       // llvm/clang header files shouldn't be there at all. We have to get rid of
       // that dependency and avoid copying the header files.
-      clingArgsStorage.push_back(interpInclude + "/cling");
+      clingArgsStorage.push_back("-I" + interpInclude + "/cling");
 
       // Add the root include directory and etc/ to list searched by default.
-      clingArgsStorage.push_back(std::string("-I") + ROOT::TMetaUtils::GetROOTIncludeDir(false));
+      clingArgsStorage.push_back(std::string("-I" + TROOT::GetIncludeDir()));
 
       // Add the current path to the include path
       // TCling::AddIncludePath(".");
 
-      std::string pchFilename = interpInclude.substr(2) + "/allDict.cxx.pch";
+      std::string pchFilename = interpInclude + "/allDict.cxx.pch";
       if (gSystem->Getenv("ROOT_PCH")) {
          pchFilename = gSystem->Getenv("ROOT_PCH");
       }
@@ -1095,7 +1094,11 @@
            eArg = clingArgsStorage.end(); iArg != eArg; ++iArg)
       interpArgs.push_back(iArg->c_str());
 
-   std::string llvmResourceDir = ROOT::TMetaUtils::GetLLVMResourceDir(false);
+#ifdef R__EXTERN_LLVMDIR
+   TString llvmResourceDir = R__EXTERN_LLVMDIR;
+#else
+   TString llvmResourceDir = TROOT::GetEtcDir() + "/cling";
+#endif
    // Add statically injected extra arguments, usually coming from rootcling.
    for (const char** extraArgs = TROOT::GetExtraInterpreterArgs();
         extraArgs && *extraArgs; ++extraArgs) {
@@ -1109,7 +1112,7 @@
 
    fInterpreter = new cling::Interpreter(interpArgs.size(),
                                          &(interpArgs[0]),
-                                         llvmResourceDir.c_str());
+                                         llvmResourceDir);
 
    if (!fromRootCling) {
       fInterpreter->installLazyFunctionCreator(llvmLazyFunctionCreator);
@@ -4722,21 +4725,7 @@
 
    TString sname = "system";
    sname += name;
-#ifdef ROOTETCDIR
-   char *s = gSystem->ConcatFileName(ROOTETCDIR, sname);
-#else
-   TString etc = gRootDir;
-#ifdef WIN32
-   etc += "\\etc";
-#else
-   etc += "/etc";
-#endif
-#if defined(R__MACOSX) && (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
-   // on iOS etc does not exist and system<name> resides in $ROOTSYS
-   etc = gRootDir;
-#endif
-   char *s = gSystem->ConcatFileName(etc, sname);
-#endif
+   char *s = gSystem->ConcatFileName(TROOT::GetEtcDir(), sname);
 
    Int_t ret = ReadRootmapFile(s);
    if (ret == -3) // old format
diff -Nur root-6.08.02.orig/core/metautils/inc/TMetaUtils.h root-6.08.02/core/metautils/inc/TMetaUtils.h
--- root-6.08.02.orig/core/metautils/inc/TMetaUtils.h	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/metautils/inc/TMetaUtils.h	2016-12-06 12:46:10.313969543 +0100
@@ -334,10 +334,6 @@
 //______________________________________________________________________________
 llvm::StringRef DataMemberInfo__ValidArrayIndex(const clang::DeclaratorDecl &m, int *errnum = 0, llvm::StringRef  *errstr = 0);
 
-//______________________________________________________________________________
-// Return the ROOT include directory
-std::string GetROOTIncludeDir(bool rootbuild);
-
 enum class EIOCtorCategory : short {kAbsent, kDefault, kIOPtrType, kIORefType};
 
 //______________________________________________________________________________
@@ -544,18 +540,6 @@
                                  const char* headers[]);
 
 //______________________________________________________________________________
-// Return the -I needed to find RuntimeUniverse.h
-std::string GetInterpreterExtraIncludePath(bool rootbuild);
-
-//______________________________________________________________________________
-// Return the LLVM / clang resource directory
-std::string GetLLVMResourceDir(bool rootbuild);
-
-//______________________________________________________________________________
-// Return the ROOT include directory
-std::string GetROOTIncludeDir(bool rootbuild);
-
-//______________________________________________________________________________
 // Return (in the argument 'output') a mangled version of the C++ symbol/type (pass as 'input')
 // that can be used in C++ as a variable name.
 void GetCppName(std::string &output, const char *input);
diff -Nur root-6.08.02.orig/core/metautils/src/TMetaUtils.cxx root-6.08.02/core/metautils/src/TMetaUtils.cxx
--- root-6.08.02.orig/core/metautils/src/TMetaUtils.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/metautils/src/TMetaUtils.cxx	2016-12-06 12:46:10.314969531 +0100
@@ -3303,40 +3303,6 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-/// Return the -I needed to find RuntimeUniverse.h
-
-std::string ROOT::TMetaUtils::GetInterpreterExtraIncludePath(bool rootbuild)
-{
-#ifdef ROOTETCDIR
-   if (rootbuild) {
-      // Building ROOT, ignore ROOTETCDIR!
-#endif
-      const char* rootsys = getenv("ROOTSYS");
-      if (!rootsys) {
-         Error(0, "Environment variable ROOTSYS not set!");
-         return "-Ietc";
-      }
-      return std::string("-I") + rootsys + "/etc";
-#ifdef ROOTETCDIR
-   }
-   return std::string("-I") + ROOTETCDIR;
-#endif
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// Return the LLVM / clang resource directory
-
-std::string ROOT::TMetaUtils::GetLLVMResourceDir(bool rootbuild)
-{
-#ifdef R__EXTERN_LLVMDIR
-   return R__EXTERN_LLVMDIR;
-#else
-   return GetInterpreterExtraIncludePath(rootbuild)
-      .substr(2, std::string::npos) + "/cling";
-#endif
-}
-
-////////////////////////////////////////////////////////////////////////////////
 /// Get the template specialisation decl and template decl behind the qualtype
 /// Returns true if successfully found, false otherwise
 
@@ -3967,29 +3933,6 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-
-std::string ROOT::TMetaUtils::GetROOTIncludeDir(bool rootbuild)
-{
-   const std::string defaultInclude ("include");
-   if (!rootbuild) {
-#ifndef ROOTINCDIR
-      const char* rootSysContent = getenv("ROOTSYS");
-      if (rootSysContent) {
-         std::string incl_rootsys (rootSysContent);
-         return incl_rootsys + "/" + defaultInclude;
-      } else {
-         Error(0,"Environment variable ROOTSYS not set");
-         return defaultInclude;
-      }
-#else
-      return ROOTINCDIR;
-#endif
-   }
-
-   return defaultInclude;
-}
-
-////////////////////////////////////////////////////////////////////////////////
 /// Return the dictionary file name for a module
 
 std::string ROOT::TMetaUtils::GetModuleFileName(const char* moduleName)
diff -Nur root-6.08.02.orig/core/rint/src/TRint.cxx root-6.08.02/core/rint/src/TRint.cxx
--- root-6.08.02.orig/core/rint/src/TRint.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/rint/src/TRint.cxx	2016-12-06 12:46:10.314969531 +0100
@@ -305,17 +305,7 @@
    TString name = ".rootlogon.C";
    TString sname = "system";
    sname += name;
-#ifdef ROOTETCDIR
-   char *s = gSystem->ConcatFileName(ROOTETCDIR, sname);
-#else
-   TString etc = gRootDir;
-#ifdef WIN32
-   etc += "\\etc";
-#else
-   etc += "/etc";
-#endif
-   char *s = gSystem->ConcatFileName(etc, sname);
-#endif
+   char *s = gSystem->ConcatFileName(TROOT::GetEtcDir(), sname);
    if (!gSystem->AccessPathName(s, kReadPermission)) {
       ProcessFile(s);
    }
diff -Nur root-6.08.02.orig/core/rint/src/TTabCom.cxx root-6.08.02/core/rint/src/TTabCom.cxx
--- root-6.08.02.orig/core/rint/src/TTabCom.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/rint/src/TTabCom.cxx	2016-12-06 12:46:10.315969520 +0100
@@ -1671,8 +1671,7 @@
    case kROOT_Load:
       {
          const TString fileName = s3("[^\"]*$");
-//             const TString  dynamicPath  = DeterminePath( fileName, TROOT::GetDynamicPath() ); /* should use this one */
-         const TString dynamicPath = DeterminePath(fileName,gEnv->GetValue("Root.DynamicPath",(char *) 0));
+         const TString dynamicPath = DeterminePath(fileName, gSystem->GetDynamicPath());
          const TSeqCollection *pListOfFiles = GetListOfFilesInPath(dynamicPath);
 
 //             pos = Complete( "[^\"/]*$", pListOfFiles, "\");", out);
diff -Nur root-6.08.02.orig/core/unix/src/TUnixSystem.cxx root-6.08.02/core/unix/src/TUnixSystem.cxx
--- root-6.08.02.orig/core/unix/src/TUnixSystem.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/unix/src/TUnixSystem.cxx	2016-12-06 12:46:10.316969509 +0100
@@ -458,7 +458,9 @@
 
 static void SetRootSys()
 {
-#ifndef ROOTPREFIX
+#ifdef ROOTPREFIX
+   if (gSystem->Getenv("ROOTIGNOREPREFIX")) {
+#endif
    void *addr = (void *)SetRootSys;
    Dl_info info;
    if (dladdr(addr, &info) && info.dli_fname && info.dli_fname[0]) {
@@ -471,8 +473,8 @@
          gSystem->Setenv("ROOTSYS", gSystem->DirName(rs));
       }
    }
-#else
-   return;
+#ifdef ROOTPREFIX
+   }
 #endif
 }
 #endif
@@ -500,7 +502,9 @@
    TRegexp sovers = "libCore\\.[0-9]+\\.*[0-9]*\\.so";
    TRegexp dyvers = "libCore\\.[0-9]+\\.*[0-9]*\\.dylib";
 
-#ifndef ROOTPREFIX
+#ifdef ROOTPREFIX
+   if (gSystem->Getenv("ROOTIGNOREPREFIX")) {
+#endif
 #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
    // first loaded is the app so set ROOTSYS to app bundle
    if (i == 1) {
@@ -526,6 +530,8 @@
       }
    }
 #endif
+#ifdef ROOTPREFIX
+   }
 #endif
 
    // when libSystem.B.dylib is loaded we have finished loading all dylibs
@@ -613,13 +619,8 @@
    SetRootSys();
 #endif
 
-#ifndef ROOTPREFIX
-   gRootDir = Getenv("ROOTSYS");
-   if (gRootDir == 0)
-      gRootDir= "/usr/local/root";
-#else
-   gRootDir = ROOTPREFIX;
-#endif
+   // This is a fallback in case TROOT::GetRootSys() can't determine ROOTSYS
+   gRootDir = "/usr/local/root";
 
    return kFALSE;
 }
@@ -2240,22 +2241,17 @@
       if (AccessPathName(gdbscript, kReadPermission)) {
          fprintf(stderr, "Root.StacktraceScript %s does not exist\n", gdbscript.Data());
          gdbscript = "";
-      } else {
-         gdbscript += " ";
       }
    }
    if (gdbscript == "") {
-#ifdef ROOTETCDIR
-      gdbscript.Form("%s/gdb-backtrace.sh", ROOTETCDIR);
-#else
-      gdbscript.Form("%s/etc/gdb-backtrace.sh", Getenv("ROOTSYS"));
-#endif
+      gdbscript = "gdb-backtrace.sh";
+      gSystem->PrependPathName(TROOT::GetEtcDir(), gdbscript);
       if (AccessPathName(gdbscript, kReadPermission)) {
          fprintf(stderr, "Error in <TUnixSystem::StackTrace> script %s is missing\n", gdbscript.Data());
          return;
       }
-      gdbscript += " ";
    }
+   gdbscript += " ";
 
    TString gdbmess = gEnv->GetValue("Root.StacktraceMessage", "");
    gdbmess = gdbmess.Strip();
@@ -4602,11 +4598,7 @@
       TString rdynpath = gEnv->GetValue("Root.DynamicPath", (char*)0);
       rdynpath.ReplaceAll(": ", ":");  // in case DynamicPath was extended
       if (rdynpath.IsNull()) {
-#ifdef ROOTLIBDIR
-         rdynpath = ".:"; rdynpath += ROOTLIBDIR;
-#else
-         rdynpath = ".:"; rdynpath += gRootDir; rdynpath += "/lib";
-#endif
+         rdynpath = ".:"; rdynpath += TROOT::GetLibDir();
       }
       TString ldpath;
 #if defined (R__AIX)
@@ -4627,16 +4619,9 @@
       else {
          dynpath = ldpath; dynpath += ":"; dynpath += rdynpath;
       }
-
-#ifdef ROOTLIBDIR
-      if (!dynpath.Contains(ROOTLIBDIR)) {
-         dynpath += ":"; dynpath += ROOTLIBDIR;
+      if (!dynpath.Contains(TROOT::GetLibDir())) {
+         dynpath += ":"; dynpath += TROOT::GetLibDir();
       }
-#else
-      if (!dynpath.Contains(TString::Format("%s/lib", gRootDir))) {
-         dynpath += ":"; dynpath += gRootDir; dynpath += "/lib";
-      }
-#endif
       if (gCling) {
          dynpath += ":"; dynpath += gCling->GetSTLIncludePath();
       } else
diff -Nur root-6.08.02.orig/core/utils/CMakeLists.txt root-6.08.02/core/utils/CMakeLists.txt
--- root-6.08.02.orig/core/utils/CMakeLists.txt	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/utils/CMakeLists.txt	2016-12-06 12:46:10.316969509 +0100
@@ -66,27 +66,27 @@
                     DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT applications)
 endif()
 
-set(R__LLVMRESOURCEDIR ${CMAKE_BINARY_DIR}/etc/cling)
-configure_file(src/rootcling.cxx rootcling_tmp.cxx @ONLY)
+configure_file(src/rootcling.cxx src/rootcling_tmp.cxx @ONLY)
 
 if(WIN32)
-  set_source_files_properties(rootcling_tmp.cxx PROPERTIES COMPILE_FLAGS "-D_WIN32 -DNOMINMAX -DROOT_STAGE1_BUILD -DR__LLVMRESOURCEDIR")
+  set_source_files_properties(src/rootcling_tmp.cxx PROPERTIES COMPILE_FLAGS "-D_WIN32 -DNOMINMAX -DROOT_STAGE1_BUILD")
 else()
   if(CXX_HAS_fno_rtti)
-    set_source_files_properties(rootcling_tmp.cxx PROPERTIES COMPILE_FLAGS "-DROOT_STAGE1_BUILD -DR__LLVMRESOURCEDIR -fno-rtti")
+    set_source_files_properties(src/rootcling_tmp.cxx PROPERTIES COMPILE_FLAGS "-DROOT_STAGE1_BUILD -fno-rtti")
   else()
-    set_source_files_properties(rootcling_tmp.cxx PROPERTIES COMPILE_FLAGS "-DROOT_STAGE1_BUILD -DR__LLVMRESOURCEDIR")
+    set_source_files_properties(src/rootcling_tmp.cxx PROPERTIES COMPILE_FLAGS "-DROOT_STAGE1_BUILD")
   endif()
 endif()
 
 ROOT_EXECUTABLE(rootcling_tmp src/LinkdefReader.cxx src/DictSelectionReader.cxx
-                              src/TModuleGenerator.cxx ${CMAKE_CURRENT_BINARY_DIR}/rootcling_tmp.cxx
+                              src/TModuleGenerator.cxx src/rootcling_tmp.cxx
                               ${CMAKE_SOURCE_DIR}/core/metautils/src/TMetaUtils.cxx
                               $<TARGET_OBJECTS:Clib>
                               $<TARGET_OBJECTS:MetaUtils>
                               $<TARGET_OBJECTS:MetaUtilsLLVM>
                               LIBRARIES ${CLING_LIBRARIES}  ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT}
                               NOINSTALL)
+set_target_properties(rootcling_tmp PROPERTIES RUNTIME_OUTPUT_DIRECTORY src)
 add_dependencies(rootcling_tmp CLING LLVMRES)
 set_source_files_properties(src/LinkdefReader.cxx PROPERTIES COMPILE_FLAGS -fno-rtti)
 set_source_files_properties(src/TModuleGenerator.cxx PROPERTIES COMPILE_FLAGS -fno-rtti)
diff -Nur root-6.08.02.orig/core/utils/ModuleVars.mk root-6.08.02/core/utils/ModuleVars.mk
--- root-6.08.02.orig/core/utils/ModuleVars.mk	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/utils/ModuleVars.mk	2016-12-06 12:46:10.316969509 +0100
@@ -48,7 +48,7 @@
 ROOTCINTEXE     := bin/rootcint$(EXEEXT)
 GENREFLEXEXE    := bin/genreflex$(EXEEXT)
 ROOTCLINGSTAGE1 := $(ROOTCLINGTMPEXE)
-ROOTCLINGSTAGE2 := $(ROOTCLINGEXE) -rootbuild
+ROOTCLINGSTAGE2 := ROOTIGNOREPREFIX=1 $(ROOTCLINGEXE) -rootbuild
 
 ##### Dependencies for all dictionaries
 ROOTCLINGSTAGE1DEP := $(ROOTCLINGTMPEXE)
diff -Nur root-6.08.02.orig/core/utils/src/rootcling.cxx root-6.08.02/core/utils/src/rootcling.cxx
--- root-6.08.02.orig/core/utils/src/rootcling.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/utils/src/rootcling.cxx	2016-12-06 12:46:10.317969497 +0100
@@ -270,12 +270,6 @@
 bool buildingROOT = false;
 #endif
 
-#ifdef R__EXTERN_LLVMDIR
-# define R__LLVMDIR R__EXTERN_LLVMDIR
-#else
-# define R__LLVMDIR "./interpreter/llvm/inst" // only works for rootbuild for now!
-#endif
-
 namespace {
    // Copy-pasted from TClass.h We cannot #include TClass.h because we are compiling in -fno-rtti mode
    template <typename T> struct IsPointerTClassCopy {
@@ -3909,11 +3903,6 @@
       clingArgs.push_back("-DG__VECTOR_HAS_CLASS_ITERATOR");
    }
 
-#if defined(ROOTINCDIR)
-   if (!buildingROOT)
-      SetRootSys();
-#endif
-
    if (ic < argc && !strcmp(argv[ic], "-c")) {
       // Simply ignore the -c options.
       ic++;
@@ -4069,7 +4058,11 @@
    }
 
    ic = nextStart;
-   clingArgs.push_back(std::string("-I") + TMetaUtils::GetROOTIncludeDir(buildingROOT));
+#ifdef ROOT_STAGE1_BUILD
+   clingArgs.push_back(std::string("-I") + getenv("ROOTSYS") + "/include");
+#else
+   clingArgs.push_back(std::string("-I") + TROOT__GetIncludeDir());
+#endif
 
    std::vector<std::string> pcmArgs;
    for (size_t parg = 0, n = clingArgs.size(); parg < n; ++parg) {
@@ -4093,7 +4086,11 @@
    }
 
    // cling-only arguments
-   clingArgs.push_back(TMetaUtils::GetInterpreterExtraIncludePath(buildingROOT));
+#ifdef ROOT_STAGE1_BUILD
+   clingArgs.push_back(std::string("-I") + getenv("ROOTSYS") + "/etc");
+#else
+   clingArgs.push_back(std::string("-I") + TROOT__GetEtcDir());
+#endif
    // We do not want __ROOTCLING__ in the pch!
    if (!onepcm) {
       clingArgs.push_back("-D__ROOTCLING__");
@@ -4118,10 +4115,14 @@
    }
 
    std::string resourceDir;
-#ifdef R__LLVMRESOURCEDIR
-   resourceDir = "@R__LLVMRESOURCEDIR@";
+#ifdef R__EXTERN_LLVMDIR
+   resourceDir = R__EXTERN_LLVMDIR;
 #else
-   resourceDir = TMetaUtils::GetLLVMResourceDir(buildingROOT);
+#ifdef ROOT_STAGE1_BUILD
+   resourceDir = std::string(getenv("ROOTSYS")) + "/etc/cling";
+#else
+   resourceDir = std::string(TROOT__GetEtcDir()) + "/cling";
+#endif
 #endif
 
 #ifndef ROOT_STAGE1_BUILD
@@ -4162,11 +4163,6 @@
 
    interp.getOptions().ErrorOut = true;
    interp.enableRawInput(true);
-#ifdef ROOTINCDIR
-   const bool useROOTINCDIR = !buildingROOT;
-#else
-   const bool useROOTINCDIR = false;
-#endif
    if (isGenreflex) {
       if (interp.declare("namespace std {} using namespace std;") != cling::Interpreter::kSuccess) {
          // There was an error.
@@ -4182,17 +4178,10 @@
                               "#include <stddef.h>\n"
                               "#include <string.h>\n"
                              ) != cling::Interpreter::kSuccess
-            || (!useROOTINCDIR
-                && interp.declare("#include \"Rtypes.h\"\n"
-                                  "#include \"TClingRuntime.h\"\n"
-                                  "#include \"TObject.h\"") != cling::Interpreter::kSuccess)
-#ifdef ROOTINCDIR
-            || (useROOTINCDIR
-                && interp.declare("#include \"" ROOTINCDIR "/Rtypes.h\"\n"
-                                  "#include \"" ROOTINCDIR "/TClingRuntime.h\"\n"
-                                  "#include \"" ROOTINCDIR "/TObject.h\"") != cling::Interpreter::kSuccess
-               )
-#endif
+            || interp.declare("#include \"Rtypes.h\"\n"
+                              "#include \"TClingRuntime.h\"\n"
+                              "#include \"TObject.h\""
+                             ) != cling::Interpreter::kSuccess
          ) {
          // There was an error.
          ROOT::TMetaUtils::Error(0, "Error loading the default header files.\n");
diff -Nur root-6.08.02.orig/core/utils/src/rootclingTCling.cxx root-6.08.02/core/utils/src/rootclingTCling.cxx
--- root-6.08.02.orig/core/utils/src/rootclingTCling.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/utils/src/rootclingTCling.cxx	2016-12-06 12:46:10.317969497 +0100
@@ -40,6 +40,18 @@
 }
 
 extern "C"
+const char *TROOT__GetIncludeDir()
+{
+   return TROOT::GetIncludeDir().Data();
+}
+
+extern "C"
+const char *TROOT__GetEtcDir()
+{
+   return TROOT::GetEtcDir().Data();
+}
+
+extern "C"
 cling::Interpreter *TCling__GetInterpreter()
 {
    static bool isInitialized = false;
diff -Nur root-6.08.02.orig/core/utils/src/rootclingTCling.h root-6.08.02/core/utils/src/rootclingTCling.h
--- root-6.08.02.orig/core/utils/src/rootclingTCling.h	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/utils/src/rootclingTCling.h	2016-12-06 12:46:10.318969486 +0100
@@ -21,6 +21,8 @@
 
 extern "C" {
    const char ** *TROOT__GetExtraInterpreterArgs();
+   const char *TROOT__GetIncludeDir();
+   const char *TROOT__GetEtcDir();
    cling::Interpreter *TCling__GetInterpreter();
    void InitializeStreamerInfoROOTFile(const char *filename);
    void AddStreamerInfoToROOTFile(const char *normName);
diff -Nur root-6.08.02.orig/core/winnt/src/TWinNTSystem.cxx root-6.08.02/core/winnt/src/TWinNTSystem.cxx
--- root-6.08.02.orig/core/winnt/src/TWinNTSystem.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/winnt/src/TWinNTSystem.cxx	2016-12-06 12:46:10.318969486 +0100
@@ -362,11 +362,7 @@
          TString rdynpath = gEnv ? gEnv->GetValue("Root.DynamicPath", (char*)0) : "";
          rdynpath.ReplaceAll("; ", ";");  // in case DynamicPath was extended
          if (rdynpath == "") {
-#ifdef ROOTBINDIR
-            rdynpath = ".;"; rdynpath += ROOTBINDIR;
-#else
-            rdynpath = ".;"; rdynpath += gRootDir; rdynpath += "/bin";
-#endif
+            rdynpath = ".;"; rdynpath += TROOT::GetBinDir();
          }
          TString path = gSystem->Getenv("PATH");
          if (path == "")
@@ -376,15 +372,10 @@
          }
 
       }
-#ifdef ROOTLIBDIR
-      if (!dynpath.Contains(ROOTLIBDIR)) {
-         dynpath += ";"; dynpath += ROOTLIBDIR;
-      }
-#else
-      if (!dynpath.Contains(TString::Format("%s/lib", gRootDir))) {
-         dynpath += ";"; dynpath += gRootDir; dynpath += "/lib";
+
+      if (!dynpath.Contains(TROOT::GetLibDir())) {
+         dynpath += ";"; dynpath += TROOT::GetLibDir();
       }
-#endif
 
       return dynpath;
    }
@@ -823,16 +814,8 @@
       }
 
       // determine the fileopen.C file path:
-      TString fileopen;
-#ifndef ROOT_PREFIX
-      fileopen += sys->TWinNTSystem::DriveName(buf);
-      fileopen += ":";
-      fileopen += sys->TWinNTSystem::DirName(sys->TWinNTSystem::DirName(buf));
-      fileopen += "\\macros";
-#else
-      fileopen += ROOTMACRODIR;
-#endif
-      fileopen += "\\fileopen.C";
+      TString fileopen = "fileopen.C";
+      gSystem->PrependPathName(TROOT::GetMacroDir(), fileopen);
 
       if (regROOTwrite) {
          // only write to registry if fileopen.C is readable
@@ -1007,7 +990,9 @@
 
    char *buf = new char[MAX_MODULE_NAME32 + 1];
 
-#ifndef ROOTPREFIX
+#ifdef ROOTPREFIX
+   if (gSystem->Getenv("ROOTIGNOREPREFIX") {
+#endif
    // set ROOTSYS
    HMODULE hModCore = ::GetModuleHandle("libCore.dll");
    if (hModCore) {
@@ -1035,6 +1020,8 @@
          }
       }
    }
+#ifdef ROOTPREFIX
+   }
 #endif
 
    UpdateRegistry(this, buf);
@@ -1112,23 +1099,17 @@
 
    fSigcnt = 0;
 
-#ifndef ROOTPREFIX
-   gRootDir = Getenv("ROOTSYS");
-   if (gRootDir == 0) {
-      static char lpFilename[MAX_PATH];
-      if (::GetModuleFileName(NULL,               // handle to module to find filename for
-                            lpFilename,           // pointer to buffer to receive module path
-                            sizeof(lpFilename)))  // size of buffer, in characters
-      {
-         const char *dirName = DirName(DirName(lpFilename));
-         gRootDir = StrDup(dirName);
-      } else {
-         gRootDir = 0;
-      }
+   // This is a fallback in case TROOT::GetRootSys() can't determine ROOTSYS
+   static char lpFilename[MAX_PATH];
+   if (::GetModuleFileName(
+          NULL,                   // handle to module to find filename for
+          lpFilename,             // pointer to buffer to receive module path
+          sizeof(lpFilename))) {  // size of buffer, in characters
+      const char *dirName = DirName(DirName(lpFilename));
+      gRootDir = StrDup(dirName);
+   } else {
+      gRootDir = 0;
    }
-#else
-   gRootDir= ROOTPREFIX;
-#endif
 
    // Increase the accuracy of Sleep() without needing to link to winmm.lib
    typedef UINT (WINAPI* LPTIMEBEGINPERIOD)( UINT uPeriod );
diff -Nur root-6.08.02.orig/core/zip/CMakeLists.txt root-6.08.02/core/zip/CMakeLists.txt
--- root-6.08.02.orig/core/zip/CMakeLists.txt	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/core/zip/CMakeLists.txt	2016-12-06 12:46:10.319969475 +0100
@@ -22,6 +22,7 @@
 # Define all the header files which should be installed when
 # doing a "make install"
 install(FILES ${ZLIB_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT headers)
+file(COPY ${ZLIB_HEADERS} DESTINATION ${CMAKE_BINARY_DIR}/include)
 set_property(GLOBAL APPEND PROPERTY ROOT_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/inc)
 
 ROOT_OBJECT_LIBRARY(Zip ${ZLIB_SRCS})
diff -Nur root-6.08.02.orig/documentation/doxygen/converttonotebook.py root-6.08.02/documentation/doxygen/converttonotebook.py
--- root-6.08.02.orig/documentation/doxygen/converttonotebook.py	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/documentation/doxygen/converttonotebook.py	2016-12-06 12:46:10.319969475 +0100
@@ -601,7 +601,7 @@
 def rs401dGetFiles(code):
     if tutName == "rs401d_FeldmanCousins":
         code = code.replace(
-         """#if !defined(__CINT__) || defined(__MAKECINT__)\n#include "../tutorials/roostats/NuMuToNuE_Oscillation.h"\n#include "../tutorials/roostats/NuMuToNuE_Oscillation.cxx" // so that it can be executed directly\n#else\n#include "../tutorials/roostats/NuMuToNuE_Oscillation.cxx+" // so that it can be executed directly\n#endif""" , """std::string tutDir = gROOT->GetTutorialsDir();\nTString headerDir = TString::Format("#include \\\"%s/roostats/NuMuToNuE_Oscillation.h\\\"", tutDir.c_str());\nTString impDir = TString::Format("#include \\\"%s/roostats/NuMuToNuE_Oscillation.cxx\\\"", tutDir.c_str());\ngROOT->ProcessLine(headerDir);\ngROOT->ProcessLine(impDir);""")
+         """#if !defined(__CINT__) || defined(__MAKECINT__)\n#include "../tutorials/roostats/NuMuToNuE_Oscillation.h"\n#include "../tutorials/roostats/NuMuToNuE_Oscillation.cxx" // so that it can be executed directly\n#else\n#include "../tutorials/roostats/NuMuToNuE_Oscillation.cxx+" // so that it can be executed directly\n#endif""" , """TString tutDir = gROOT->GetTutorialDir();\nTString headerDir = TString::Format("#include \\\"%s/roostats/NuMuToNuE_Oscillation.h\\\"", tutDir.Data());\nTString impDir = TString::Format("#include \\\"%s/roostats/NuMuToNuE_Oscillation.cxx\\\"", tutDir.Data());\ngROOT->ProcessLine(headerDir);\ngROOT->ProcessLine(impDir);""")
     return code
 
 
diff -Nur root-6.08.02.orig/geom/geom/src/TGeoElement.cxx root-6.08.02/geom/geom/src/TGeoElement.cxx
--- root-6.08.02.orig/geom/geom/src/TGeoElement.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/geom/geom/src/TGeoElement.cxx	2016-12-06 12:46:10.319969475 +0100
@@ -39,6 +39,7 @@
 #include "Riostream.h"
 
 #include "TSystem.h"
+#include "TROOT.h"
 #include "TObjArray.h"
 #include "TVirtualGeoPainter.h"
 #include "TGeoManager.h"
@@ -1128,12 +1129,8 @@
 {
    if (HasRNElements()) return;
    TGeoElementRN *elem;
-   TString rnf;
-#ifdef ROOTETCDIR
-   rnf.Form("%s/RadioNuclides.txt", ROOTETCDIR);
-#else
-   rnf.Form("%s/etc/RadioNuclides.txt", gSystem->Getenv("ROOTSYS"));
-#endif
+   TString rnf = "RadioNuclides.txt";
+   gSystem->PrependPathName(TROOT::GetEtcDir(), rnf);
    FILE *fp = fopen(rnf, "r");
    if (!fp) {
       Error("ImportElementsRN","File RadioNuclides.txt not found");
diff -Nur root-6.08.02.orig/graf2d/asimage/src/TASImage.cxx root-6.08.02/graf2d/asimage/src/TASImage.cxx
--- root-6.08.02.orig/graf2d/asimage/src/TASImage.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/graf2d/asimage/src/TASImage.cxx	2016-12-06 12:46:10.320969463 +0100
@@ -357,33 +357,33 @@
 
 static void init_icon_paths()
 {
-   const char *icons = "/icons";
-#ifdef R__WIN32
-      icons = "\\icons";
-#endif
-
-   TString homeIcons = gSystem->HomeDirectory();
-   homeIcons += icons;
-
-   TString rootIcons = gSystem->Getenv("ROOTSYS");
-   rootIcons += icons;
-
-   TString guiIcons = gEnv->GetValue("Gui.IconPath", "");
-
-   gIconPaths[0] = StrDup(".");
-   gIconPaths[1] = StrDup(homeIcons.Data());
-   gIconPaths[2] = StrDup(rootIcons.Data());
-   gIconPaths[3] = StrDup(guiIcons.Data());
-
-#ifdef ROOTICONPATH
-   gIconPaths[4] = StrDup(ROOTICONPATH);
+   TString icon_path = gEnv->GetValue("Gui.IconPath", "");
+   if (icon_path.IsNull()) {
+      icon_path = "icons";
+      gSystem->PrependPathName(gSystem->HomeDirectory(), icon_path);
+#ifndef R__WIN32
+      icon_path = ".:" + icon_path + ":" + TROOT::GetIconPath() + ":" + EXTRAICONPATH;
+#else
+      icon_path = ".;" + icon_path + ";" + TROOT::GetIconPath() + ";" + EXTRAICONPATH;
 #endif
+   }
 
-#ifdef EXTRAICONPATH
-   gIconPaths[5] = StrDup(EXTRAICONPATH);
+   Int_t cnt = 0;
+   Ssiz_t from = 0;
+   TString token;
+#ifndef R__WIN32
+   const char *delim = ":";
+#else
+   const char *delim = ";";
 #endif
-
-   gIconPaths[6] = 0;
+   while (icon_path.Tokenize(token, from, delim) && cnt < 6) {
+      char *path = gSystem->ExpandPathName(token.Data());
+      if (path) {
+         gIconPaths[cnt] = path;
+         cnt++;
+      }
+   }
+   gIconPaths[cnt] = 0;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -2592,14 +2592,19 @@
 
    TString fn = font_name;
    fn.Strip();
-   char *tmpstr = 0;
+
+   // This is for backward compatibility...
+   if (fn.Last('/') == 0) fn = fn(1, fn.Length() - 1);
+
+   const char *ttpath = gEnv->GetValue("Root.TTFontPath",
+                                       TROOT::GetTTFFontDir());
+   char *tmpstr = gSystem->Which(ttpath, fn, kReadPermission);
+   fn = tmpstr;
+   delete [] tmpstr;
 
    if (fn.EndsWith(".pfa") || fn.EndsWith(".PFA") || fn.EndsWith(".pfb") || fn.EndsWith(".PFB") || fn.EndsWith(".ttf") || fn.EndsWith(".TTF") || fn.EndsWith(".otf") || fn.EndsWith(".OTF")) {
-      tmpstr = gSystem->ExpandPathName(fn.Data());
-      fn = tmpstr;
       ttfont = kTRUE;
    }
-   delete [] tmpstr;
 
    if (color) {
       parse_argb_color(color, &text_color);
diff -Nur root-6.08.02.orig/graf2d/cocoa/src/QuartzWindow.mm root-6.08.02/graf2d/cocoa/src/QuartzWindow.mm
--- root-6.08.02.orig/graf2d/cocoa/src/QuartzWindow.mm	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/graf2d/cocoa/src/QuartzWindow.mm	2016-12-06 12:46:10.321969452 +0100
@@ -814,11 +814,7 @@
    }
 
    if (pngFileName) {
-#ifdef ROOTICONPATH
-      const char * const path = gSystem->Which(ROOTICONPATH, pngFileName, kReadPermission);
-#else
-      const char * const path = gSystem->Which("$ROOTSYS/icons", pngFileName, kReadPermission);
-#endif
+      const char * const path = gSystem->Which(TROOT::GetIconPath(), pngFileName, kReadPermission);
       const Util::ScopedArray<const char> arrayGuard(path);
 
       if (!path || path[0] == 0) {
@@ -3083,11 +3079,7 @@
    }
 
    if (pngFileName) {
-#ifdef ROOTICONPATH
-      const char * const path = gSystem->Which(ROOTICONPATH, pngFileName, kReadPermission);
-#else
-      const char * const path = gSystem->Which("$ROOTSYS/icons", pngFileName, kReadPermission);
-#endif
+      const char * const path = gSystem->Which(TROOT::GetIconPath(), pngFileName, kReadPermission);
       const Util::ScopedArray<const char> arrayGuard(path);
 
       if (!path || path[0] == 0) {
diff -Nur root-6.08.02.orig/graf2d/gpad/src/TClassTree.cxx root-6.08.02/graf2d/gpad/src/TClassTree.cxx
--- root-6.08.02.orig/graf2d/gpad/src/TClassTree.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/graf2d/gpad/src/TClassTree.cxx	2016-12-06 12:46:10.321969452 +0100
@@ -195,11 +195,7 @@
    fNdata    = 0;
    SetLabelDx();
    SetYoffset(0);
-#ifdef ROOTSRCDIR
-   SetSourceDir(".:src:" ROOTSRCDIR);
-#else
-   SetSourceDir(".:src:$ROOTSYS/src");
-#endif
+   SetSourceDir(".:src:" + TROOT::GetSourceDir());
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -225,11 +221,7 @@
    fNdata    = 0;
    SetLabelDx();
    SetYoffset(0);
-#ifdef ROOTSRCDIR
-   SetSourceDir(".:src:" ROOTSRCDIR);
-#else
-   SetSourceDir(".:src:$ROOTSYS/src");
-#endif
+   SetSourceDir(".:src:" + TROOT::GetSourceDir());
 
    // draw list of classes (if specified)
    if (classes && strlen(classes)) {
diff -Nur root-6.08.02.orig/graf2d/graf/src/TTF.cxx root-6.08.02/graf2d/graf/src/TTF.cxx
--- root-6.08.02.orig/graf2d/graf/src/TTF.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/graf2d/graf/src/TTF.cxx	2016-12-06 12:46:10.322969441 +0100
@@ -15,12 +15,10 @@
 Interface to the freetype 2 library.
 */
 
-// RConfigure.h is needed for TTFFONTDIR
-#include "RConfigure.h"
-
 #  include <ft2build.h>
 #  include FT_FREETYPE_H
 #  include FT_GLYPH_H
+#include "TROOT.h"
 #include "TTF.h"
 #include "TSystem.h"
 #include "TEnv.h"
@@ -415,13 +413,7 @@
 
    // try to load font (font must be in Root.TTFontPath resource)
    const char *ttpath = gEnv->GetValue("Root.TTFontPath",
-# ifdef TTFFONTDIR
-                                       TTFFONTDIR
-# else
-                                       "$(ROOTSYS)/fonts"
-# endif
-                                      );
-
+                                       TROOT::GetTTFFontDir());
    char *ttfont = gSystem->Which(ttpath, fontname, kReadPermission);
 
    if (!ttfont) {
@@ -543,12 +535,7 @@
       // try to load font (font must be in Root.TTFontPath resource)
       // to see which fontset we have available
       const char *ttpath = gEnv->GetValue("Root.TTFontPath",
-#ifdef TTFFONTDIR
-                                          TTFFONTDIR
-#else
-                                          "$(ROOTSYS)/fonts"
-#endif
-                                         );
+                                          TROOT::GetTTFFontDir());
       char *ttfont = gSystem->Which(ttpath, gEnv->GetValue(fonttable[fontid][0], fonttable[fontid][1]), kReadPermission);
       if (ttfont) {
          delete [] ttfont;
diff -Nur root-6.08.02.orig/graf2d/postscript/src/TPostScript.cxx root-6.08.02/graf2d/postscript/src/TPostScript.cxx
--- root-6.08.02.orig/graf2d/postscript/src/TPostScript.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/graf2d/postscript/src/TPostScript.cxx	2016-12-06 12:46:10.322969441 +0100
@@ -1568,12 +1568,7 @@
 
    // try to load font (font must be in Root.TTFontPath resource)
    const char *ttpath = gEnv->GetValue("Root.TTFontPath",
-#ifdef TTFFONTDIR
-                                       TTFFONTDIR
-#else // TTFFONTDIR
-                                       "$(ROOTSYS)/fonts"
-#endif // TTFFONTDIR
-                                       );
+                                       TROOT::GetTTFFontDir());
 
    for (Int_t fontid = 1; fontid < 30; fontid++) {
       if (fontid != 15 && MustEmbed[fontid-1]) {
diff -Nur root-6.08.02.orig/graf2d/qt/src/TGQt.cxx root-6.08.02/graf2d/qt/src/TGQt.cxx
--- root-6.08.02.orig/graf2d/qt/src/TGQt.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/graf2d/qt/src/TGQt.cxx	2016-12-06 12:46:10.323969430 +0100
@@ -707,13 +707,6 @@
                           GetSystemMetrics(SM_CYSMICON));
    HDC dc = tempIcon->handle();
    DrawIcon (dc, 0, 0, icon);
-#else
-# ifdef ROOTICONPATH
-   gSystem->ExpandPathName(ROOTICONPATH);
-# else
-   gSystem->ExpandPathName("$ROOTSYS/icons/");
-//   tempIcon =new QPixmap (16,16),
-# endif
 #endif
    return tempIcon;
 }
@@ -803,13 +796,7 @@
    static TQtApplication *app = 0;
    if (!app) {
       //    app = new TQtApplication(gApplication->ApplicationName(),gApplication->Argc(),gApplication->Argv());
-      static TString argvString (
-#ifdef ROOTBINDIR
-             ROOTBINDIR "/root.exe"
-#else
-             "$ROOTSYS/bin/root.exe"
-#endif
-             );
+      static TString argvString (TROOT::GetBinDir() + "/root.exe");
       gSystem->ExpandPathName(argvString);
       static char *argv[] = {(char *)argvString.Data()};
       static int nArg = 1;
@@ -997,14 +984,8 @@
     }
 
     if (isXdfSupport && !symbolFontFound) {
-// Load the local ROOT font
-       QString fontdir =
-#ifdef TTFFONTDIR
-         TTFFONTDIR
-#else
-         "$ROOTSYS/fonts"
-#endif
-        ;
+        // Load the local ROOT font
+        QString fontdir = TROOT::GetTTFFontDir().Data();
         QString symbolFontFile = fontdir + "/" + QString(fSymbolFontFamily).toLower() + ".ttf";
         symbolFontFound = QFontDatabase::addApplicationFont(symbolFontFile);
     }
@@ -1014,12 +995,7 @@
         fontFamily = fSymbolFontFamily = "Arial";
         qDebug() << " Substitute it with \""<<fontFamily <<"\"";
         qDebug() << " Make sure your local \"~/.fonts.conf\" or \"/etc/fonts/fonts.conf\" file points to \""
-                 <<
-#ifdef TTFFONTDIR
-               TTFFONTDIR
-#else
-               "$ROOTSYS/fonts"
-#endif
+                 << TROOT::GetTTFFontDir()
                  << "\" directory to get the proper support for ROOT TLatex class";
         // create a custom codec
         new QSymbolCodec();
diff -Nur root-6.08.02.orig/graf3d/gl/src/TGLFontManager.cxx root-6.08.02/graf3d/gl/src/TGLFontManager.cxx
--- root-6.08.02.orig/graf3d/gl/src/TGLFontManager.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/graf3d/gl/src/TGLFontManager.cxx	2016-12-06 12:46:10.323969430 +0100
@@ -14,6 +14,7 @@
 #include "TGLFontManager.h"
 
 
+#include "TROOT.h"
 #include "TVirtualX.h"
 #include "TMath.h"
 #include "TSystem.h"
@@ -451,11 +452,7 @@
    if (it == fFontMap.end())
    {
       TString ttpath, file;
-# ifdef TTFFONTDIR
-      ttpath = gEnv->GetValue("Root.TTGLFontPath", TTFFONTDIR );
-# else
-      ttpath = gEnv->GetValue("Root.TTGLFontPath", "$(ROOTSYS)/fonts");
-# endif
+      ttpath = gEnv->GetValue("Root.TTGLFontPath", TROOT::GetTTFFontDir());
       {
          //For extenede we have both ttf and otf.
          char *fp = gSystem->Which(ttpath, fileID < fgExtendedFontStart ?
diff -Nur root-6.08.02.orig/graf3d/gl/src/TGLSAViewer.cxx root-6.08.02/graf3d/gl/src/TGLSAViewer.cxx
--- root-6.08.02.orig/graf3d/gl/src/TGLSAViewer.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/graf3d/gl/src/TGLSAViewer.cxx	2016-12-06 12:46:10.323969430 +0100
@@ -669,14 +669,7 @@
          switch (parm1) {
          case kGLHelpAbout: {
 #ifdef R__UNIX
-            TString rootx;
-#ifdef ROOTBINDIR
-            rootx = ROOTBINDIR;
-#else
-            rootx = gSystem->Getenv("ROOTSYS");
-            if (!rootx.IsNull()) rootx += "/bin";
-#endif
-            rootx += "/root -a &";
+            TString rootx = TROOT::GetBinDir() + "/root -a &";
             gSystem->Exec(rootx);
 #else
 #ifdef WIN32
diff -Nur root-6.08.02.orig/graf3d/gl/src/TGLText.cxx root-6.08.02/graf3d/gl/src/TGLText.cxx
--- root-6.08.02.orig/graf3d/gl/src/TGLText.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/graf3d/gl/src/TGLText.cxx	2016-12-06 12:46:10.323969430 +0100
@@ -197,13 +197,7 @@
 
    // try to load font (font must be in Root.TTFontPath resource)
    const char *ttpath = gEnv->GetValue("Root.TTFontPath",
-# ifdef TTFFONTDIR
-                                        TTFFONTDIR
-# else
-                                        "$(ROOTSYS)/fonts"
-# endif
-                                        );
-
+                                       TROOT::GetTTFFontDir());
    char *ttfont = gSystem->Which(ttpath, fontname, kReadPermission);
 
    if (fGLTextFont) delete fGLTextFont;
diff -Nur root-6.08.02.orig/gui/gui/src/TGApplication.cxx root-6.08.02/gui/gui/src/TGApplication.cxx
--- root-6.08.02.orig/gui/gui/src/TGApplication.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/gui/gui/src/TGApplication.cxx	2016-12-06 12:46:10.324969418 +0100
@@ -84,12 +84,7 @@
 
    if (strcmp(appClassName, "proofserv")) {
       const char *ttpath = gEnv->GetValue("Root.TTFontPath",
-#ifdef TTFFONTDIR
-                                          TTFFONTDIR);
-#else
-                                          "$(ROOTSYS)/fonts");
-#endif
-
+                                          TROOT::GetTTFFontDir());
       char *ttfont = gSystem->Which(ttpath, "arialbd.ttf", kReadPermission);
       // Added by cholm for use of DFSG - fonts - based on fix by Kevin
       if (!ttfont)
diff -Nur root-6.08.02.orig/gui/gui/src/TGResourcePool.cxx root-6.08.02/gui/gui/src/TGResourcePool.cxx
--- root-6.08.02.orig/gui/gui/src/TGResourcePool.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/gui/gui/src/TGResourcePool.cxx	2016-12-06 12:46:10.324969418 +0100
@@ -83,46 +83,29 @@
    TString framebgpixmap  = gEnv->GetValue("Gui.FrameBackgroundPixmap", "");
    TString docbgpixmap    = gEnv->GetValue("Gui.DocumentBackgroundPixmap", "");
 
-   TString icon_path;
-   TString mime_file;
-   TString line;
-
+   TString icon_path = gEnv->GetValue("Gui.IconPath", "");
+   if (icon_path.IsNull()) {
+      icon_path = "icons";
+      gSystem->PrependPathName(gSystem->HomeDirectory(), icon_path);
 #ifndef R__WIN32
-# ifdef ROOTICONPATH
-   icon_path = TString::Format("%s/icons:%s:.:", gSystem->HomeDirectory(),
-                               ROOTICONPATH);
-#  ifdef EXTRAICONPATH
-   icon_path += gEnv->GetValue("Gui.IconPath", EXTRAICONPATH);
-#  else
-   icon_path += gEnv->GetValue("Gui.IconPath", "");
-#  endif
-# else
-   icon_path = TString::Format("%s/icons:%s/icons:.:", gSystem->HomeDirectory(),
-                                                       gSystem->Getenv("ROOTSYS"));
-   icon_path += gEnv->GetValue("Gui.IconPath", "");
-# endif
-   line = TString::Format("%s/.root.mimes", gSystem->HomeDirectory());
+      icon_path = ".:" + icon_path + ":" + TROOT::GetIconPath() + ":" + EXTRAICONPATH;
+#else
+      icon_path = ".;" + icon_path + ";" + TROOT::GetIconPath() + ";" + EXTRAICONPATH;
+#endif
+   }
 
-   mime_file = gEnv->GetValue("Gui.MimeTypeFile", line.Data());
+   TString mime_file = ".root.mimes";
+   gSystem->PrependPathName(gSystem->HomeDirectory(), mime_file);
+   mime_file = gEnv->GetValue("Gui.MimeTypeFile", mime_file.Data());
    char *mf = gSystem->ExpandPathName(mime_file.Data());
    if (mf) {
       mime_file = mf;
       delete [] mf;
    }
-   if (gSystem->AccessPathName(mime_file, kReadPermission))
-#ifdef ROOTETCDIR
-      mime_file = TString::Format("%s/root.mimes", ROOTETCDIR);
-#else
-      mime_file = TString::Format("%s/etc/root.mimes", gSystem->Getenv("ROOTSYS"));
-#endif
-#else // R__WIN32
-   icon_path = TString::Format("%s\\icons:.:\\", gSystem->Getenv("ROOTSYS"));
-   icon_path += gEnv->GetValue("Gui.IconPath", "");
-   line = TString::Format("%s\\root.mimes", gSystem->HomeDirectory());
-   mime_file = gEnv->GetValue("Gui.MimeTypeFile", line.Data());
-   if (gSystem->AccessPathName(mime_file, kReadPermission))
-      mime_file = TString::Format("%s\\etc\\root.mimes", gSystem->Getenv("ROOTSYS"));
-#endif
+   if (gSystem->AccessPathName(mime_file, kReadPermission)) {
+      mime_file = "root.mimes";
+      gSystem->PrependPathName(TROOT::GetEtcDir(), mime_file);
+   }
 
    // Setup colors...
    fClient->GetColorByName("white", fWhite);  // white and black always exist
diff -Nur root-6.08.02.orig/gui/gui/src/TGSpeedo.cxx root-6.08.02/gui/gui/src/TGSpeedo.cxx
--- root-6.08.02.orig/gui/gui/src/TGSpeedo.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/gui/gui/src/TGSpeedo.cxx	2016-12-06 12:46:10.324969418 +0100
@@ -119,8 +119,7 @@
 {
    TString sc;
    Float_t step, mark[5];
-   TString fp = gEnv->GetValue("Root.TTFontPath", "");
-   TString ar = fp + "/arialbd.ttf";
+   TString ar = "arialbd.ttf";
    Int_t i, nexe, offset;
 
    const TGFont *counterFont = fClient->GetFont("-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*");
@@ -528,8 +527,7 @@
          delete fImage2;
       fImage2 = (TImage*)fImage->Clone("fImage2");
       if (!fImage2 || !fImage2->IsValid()) return;
-      TString fp = gEnv->GetValue("Root.TTFontPath", "");
-      TString ar = fp + "/arialbd.ttf";
+      TString ar = "arialbd.ttf";
       // format counter value
       Int_t nexe = 0;
       Int_t ww = fCounter;
@@ -609,8 +607,7 @@
          delete fImage2;
       fImage2 = (TImage*)fImage->Clone("fImage2");
       if (!fImage2 || !fImage2->IsValid()) return;
-      TString fp = gEnv->GetValue("Root.TTFontPath", "");
-      TString ar = fp + "/arialbd.ttf";
+      TString ar = "arialbd.ttf";
       // format counter value
       Int_t nexe = 0;
       Int_t ww = fCounter;
diff -Nur root-6.08.02.orig/gui/gui/src/TGTextEditor.cxx root-6.08.02/gui/gui/src/TGTextEditor.cxx
--- root-6.08.02.orig/gui/gui/src/TGTextEditor.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/gui/gui/src/TGTextEditor.cxx	2016-12-06 12:46:10.324969418 +0100
@@ -842,14 +842,7 @@
 void TGTextEditor::About()
 {
 #ifdef R__UNIX
-   TString rootx;
-# ifdef ROOTBINDIR
-   rootx = ROOTBINDIR;
-# else
-   rootx = gSystem->Getenv("ROOTSYS");
-   if (!rootx.IsNull()) rootx += "/bin";
-# endif
-   rootx += "/root -a &";
+   TString rootx = TROOT::GetBinDir() + "/root -a &";
    gSystem->Exec(rootx);
 #else
 #ifdef WIN32
diff -Nur root-6.08.02.orig/gui/gui/src/TRootBrowser.cxx root-6.08.02/gui/gui/src/TRootBrowser.cxx
--- root-6.08.02.orig/gui/gui/src/TRootBrowser.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/gui/gui/src/TRootBrowser.cxx	2016-12-06 12:46:10.325969407 +0100
@@ -702,14 +702,7 @@
       case kHelpAbout:
          {
 #ifdef R__UNIX
-            TString rootx;
-# ifdef ROOTBINDIR
-            rootx = ROOTBINDIR;
-# else
-            rootx = gSystem->Getenv("ROOTSYS");
-            if (!rootx.IsNull()) rootx += "/bin";
-# endif
-            rootx += "/root -a &";
+            TString rootx = TROOT::GetBinDir() + "/root -a &";
             gSystem->Exec(rootx);
 #else
 #ifdef WIN32
diff -Nur root-6.08.02.orig/gui/gui/src/TRootBrowserLite.cxx root-6.08.02/gui/gui/src/TRootBrowserLite.cxx
--- root-6.08.02.orig/gui/gui/src/TRootBrowserLite.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/gui/gui/src/TRootBrowserLite.cxx	2016-12-06 12:46:10.325969407 +0100
@@ -1962,14 +1962,7 @@
                   case kHelpAbout:
                      {
 #ifdef R__UNIX
-                        TString rootx;
-# ifdef ROOTBINDIR
-                        rootx = ROOTBINDIR;
-# else
-                        rootx = gSystem->Getenv("ROOTSYS");
-                        if (!rootx.IsNull()) rootx += "/bin";
-# endif
-                        rootx += "/root -a &";
+                        TString rootx = TROOT::GetBinDir() + "/root -a &";
                         gSystem->Exec(rootx);
 #else
 #ifdef WIN32
diff -Nur root-6.08.02.orig/gui/gui/src/TRootCanvas.cxx root-6.08.02/gui/gui/src/TRootCanvas.cxx
--- root-6.08.02.orig/gui/gui/src/TRootCanvas.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/gui/gui/src/TRootCanvas.cxx	2016-12-06 12:46:10.326969396 +0100
@@ -1192,14 +1192,7 @@
                   case kHelpAbout:
                      {
 #ifdef R__UNIX
-                        TString rootx;
-# ifdef ROOTBINDIR
-                        rootx = ROOTBINDIR;
-# else
-                        rootx = gSystem->Getenv("ROOTSYS");
-                        if (!rootx.IsNull()) rootx += "/bin";
-# endif
-                        rootx += "/root -a &";
+                        TString rootx = TROOT::GetBinDir() + "/root -a &";
                         gSystem->Exec(rootx);
 #else
 #ifdef WIN32
diff -Nur root-6.08.02.orig/gui/guihtml/src/TGHtmlBrowser.cxx root-6.08.02/gui/guihtml/src/TGHtmlBrowser.cxx
--- root-6.08.02.orig/gui/guihtml/src/TGHtmlBrowser.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/gui/guihtml/src/TGHtmlBrowser.cxx	2016-12-06 12:46:10.326969396 +0100
@@ -629,14 +629,7 @@
                   case kM_HELP_ABOUT:
                      {
 #ifdef R__UNIX
-                        TString rootx;
-# ifdef ROOTBINDIR
-                        rootx = ROOTBINDIR;
-# else
-                        rootx = gSystem->Getenv("ROOTSYS");
-                        if (!rootx.IsNull()) rootx += "/bin";
-# endif
-                        rootx += "/root -a &";
+                        TString rootx = TROOT::GetBinDir() + "/root -a &";
                         gSystem->Exec(rootx);
 #else
 #ifdef WIN32
diff -Nur root-6.08.02.orig/gui/sessionviewer/src/TSessionViewer.cxx root-6.08.02/gui/sessionviewer/src/TSessionViewer.cxx
--- root-6.08.02.orig/gui/sessionviewer/src/TSessionViewer.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/gui/sessionviewer/src/TSessionViewer.cxx	2016-12-06 12:46:10.327969384 +0100
@@ -5812,14 +5812,7 @@
                   case kHelpAbout:
                      {
 #ifdef R__UNIX
-                        TString rootx;
-# ifdef ROOTBINDIR
-                        rootx = ROOTBINDIR;
-# else
-                        rootx = gSystem->Getenv("ROOTSYS");
-                        if (!rootx.IsNull()) rootx += "/bin";
-# endif
-                        rootx += "/root -a &";
+		         TString rootx = TROOT::GetBinDir() + "/root -a &";
                         gSystem->Exec(rootx);
 #else
 #ifdef WIN32
diff -Nur root-6.08.02.orig/html/src/THtml.cxx root-6.08.02/html/src/THtml.cxx
--- root-6.08.02.orig/html/src/THtml.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/html/src/THtml.cxx	2016-12-06 12:46:10.328969373 +0100
@@ -1349,18 +1349,7 @@
    R__LOCKGUARD(GetMakeClassMutex());
 
    fPathInfo.fEtcDir = "html";
-
-#ifdef ROOTETCDIR
-   gSystem->PrependPathName(ROOTETCDIR, fPathInfo.fEtcDir);
-#else
-   gSystem->PrependPathName("etc", fPathInfo.fEtcDir);
-# ifdef ROOTPREFIX
-   gSystem->PrependPathName(ROOTPREFIX, fPathInfo.fEtcDir);
-# else
-   if (getenv("ROOTSYS"))
-      gSystem->PrependPathName(getenv("ROOTSYS"), fPathInfo.fEtcDir);
-# endif
-#endif
+   gSystem->PrependPathName(TROOT::GetEtcDir(), fPathInfo.fEtcDir);
 
    return fPathInfo.fEtcDir;
 }
@@ -1669,12 +1658,7 @@
                   if (posSpace != std::string::npos)
                      lib.erase(posSpace);
                   if (rootLibs.find(lib) == rootLibs.end()) {
-#ifdef ROOTLIBDIR
-                     TString rootlibdir = ROOTLIBDIR;
-#else
-                     TString rootlibdir = "lib";
-                     gSystem->PrependPathName(gRootDir, rootlibdir);
-#endif
+                     TString rootlibdir = TROOT::GetLibDir();
                      TString sLib(lib);
                      if (sLib.Index('.') == -1) {
                         sLib += ".";
diff -Nur root-6.08.02.orig/io/io/src/TFile.cxx root-6.08.02/io/io/src/TFile.cxx
--- root-6.08.02.orig/io/io/src/TFile.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/io/io/src/TFile.cxx	2016-12-06 12:46:10.328969373 +0100
@@ -3098,11 +3098,7 @@
          return;
       }
       // Get Makefile.arch
-#ifdef ROOTETCDIR
-      TString mkarchsrc = TString::Format("%s/Makefile.arch", ROOTETCDIR);
-#else
-      TString mkarchsrc("$(ROOTSYS)/etc/Makefile.arch");
-#endif
+      TString mkarchsrc = TString::Format("%s/Makefile.arch", TROOT::GetEtcDir().Data());
       if (gSystem->ExpandPathName(mkarchsrc))
          Warning("MakeProject", "problems expanding '%s'", mkarchsrc.Data());
       TString mkarchdst = TString::Format("%s/Makefile.arch", clean_dirname.Data());
diff -Nur root-6.08.02.orig/main/CMakeLists.txt root-6.08.02/main/CMakeLists.txt
--- root-6.08.02.orig/main/CMakeLists.txt	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/main/CMakeLists.txt	2016-12-06 12:46:10.329969362 +0100
@@ -40,7 +40,7 @@
   endforeach()
 
   install(FILES python/cmdLineUtils.py DESTINATION ${runtimedir})
-  install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m py_compile \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${runtimedir}/cmdLineUtils.py )")
-  install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -O -m py_compile \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${runtimedir}/cmdLineUtils.py )")
-  configure_file(python/cmdLineUtils.py ${CMAKE_BINARY_DIR}/${runtimedir}/cmdLineUtils.py @ONLY)
+  install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m py_compile \$ENV{DESTDIR}${runtimedir}/cmdLineUtils.py)")
+  install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -O -m py_compile \$ENV{DESTDIR}${runtimedir}/cmdLineUtils.py)")
+  configure_file(python/cmdLineUtils.py ${localruntimedir}/cmdLineUtils.py @ONLY)
 endif()
diff -Nur root-6.08.02.orig/main/src/nbmain.cxx root-6.08.02/main/src/nbmain.cxx
--- root-6.08.02.orig/main/src/nbmain.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/main/src/nbmain.cxx	2016-12-06 12:46:10.329969362 +0100
@@ -173,15 +173,9 @@
 
 int main()
 {
-#ifdef ROOTPREFIX
-   string rootbin(ROOTBINDIR);
-   string rootlib(ROOTLIBDIR);
-   string rootetc(ROOTETCDIR);
-#else
-   string rootbin(getenv("ROOTSYS") + pathsep + "bin");
-   string rootlib(getenv("ROOTSYS") + pathsep + "lib");
-   string rootetc(getenv("ROOTSYS") + pathsep + "etc");
-#endif
+   string rootbin(TROOT::GetBinDir());
+   string rootlib(TROOT::GetLibDir());
+   string rootetc(TROOT::GetEtcDir());
 
    // If needed, install ROOT notebook files in the user's home directory
 #ifdef WIN32
diff -Nur root-6.08.02.orig/Makefile root-6.08.02/Makefile
--- root-6.08.02.orig/Makefile	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/Makefile	2016-12-06 12:46:10.336969282 +0100
@@ -708,11 +708,9 @@
 .NOTPARALLEL:
 endif
 
-ifeq ($(USECONFIG),FALSE)
 all: tutorials/hsimple.root
 tutorials/hsimple.root: rootexecs postbin
-	@(cd tutorials; ! ../bin/root -l -q -b -n -x hsimple.C)
-endif
+	@(cd tutorials; ! ROOTIGNOREPREFIX=1 ../bin/root -l -q -b -n -x hsimple.C)
 
 all:            rootexecs postbin
 	@echo " "
@@ -1152,7 +1150,7 @@
 
 $(ROOTPCH): $(MAKEPCH) $(ROOTCLINGSTAGE1DEP) $(ALLHDRS) $(CLINGETCPCH) $(ORDER_) $(ALLLIBS)
 	@$(MAKEPCHINPUT) $(ROOT_SRCDIR) "$(MODULES)" $(CLINGETCPCH) -- $(ROOTCLING_CXXFLAGS)
-	@$(MAKEPCH) $@
+	@ROOTIGNOREPREFIX=1 $(MAKEPCH) $@
 
 $(MAKEPCH): $(ROOT_SRCDIR)/$(MAKEPCH)
 	@mkdir -p $(dir $@)
@@ -1257,8 +1255,6 @@
 	   $(INSTALLDATA) build/misc/root-help.el $(DESTDIR)$(ELISPDIR); \
 	   echo "Installing GDML conversion scripts in $(DESTDIR)$(LIBDIR)"; \
 	   $(INSTALLDATA) $(ROOT_SRCDIR)/geom/gdml/*.py $(DESTDIR)$(LIBDIR); \
-	   (cd $(DESTDIR)$(TUTDIR); \
-	      ! LD_LIBRARY_PATH=$(DESTDIR)$(LIBDIR):$$LD_LIBRARY_PATH $(DESTDIR)$(BINDIR)/root -l -b -q -n -x hsimple.C); \
 	fi
 
 uninstall:
@@ -1385,7 +1381,6 @@
 		--exclude proofd.xinetd \
 		--exclude rootd.rc.d \
 		--exclude rootd.xinetd \
-		--exclude gitinfo.txt \
 		$(ROOT_SRCDIR)/etc . ; \
 	echo "Rsync'ing $(ROOT_SRCDIR)/macros..."; \
 	$(RSYNC) \
diff -Nur root-6.08.02.orig/math/mathcore/src/Integrator.cxx root-6.08.02/math/mathcore/src/Integrator.cxx
--- root-6.08.02.orig/math/mathcore/src/Integrator.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/math/mathcore/src/Integrator.cxx	2016-12-06 12:46:10.336969282 +0100
@@ -22,9 +22,6 @@
 
 
 #include "RConfigure.h"
-// #ifndef ROOTINCDIR
-// #define MATH_NO_PLUGIN_MANAGER
-// #endif
 
 #include <algorithm>
 #include <functional>
diff -Nur root-6.08.02.orig/montecarlo/eg/src/TDatabasePDG.cxx root-6.08.02/montecarlo/eg/src/TDatabasePDG.cxx
--- root-6.08.02.orig/montecarlo/eg/src/TDatabasePDG.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/montecarlo/eg/src/TDatabasePDG.cxx	2016-12-06 12:46:10.336969282 +0100
@@ -564,11 +564,8 @@
    const char *fn;
 
    if (!FileName[0]) {
-#ifdef ROOTETCDIR
-      default_name.Form("%s/pdg_table.txt", ROOTETCDIR);
-#else
-      default_name.Form("%s/etc/pdg_table.txt", gSystem->Getenv("ROOTSYS"));
-#endif
+      default_name = "pdg_table.txt";
+      gSystem->PrependPathName(TROOT::GetEtcDir(), default_name);
       fn = gEnv->GetValue("Root.DatabasePDG", default_name.Data());
    } else {
       fn = FileName;
diff -Nur root-6.08.02.orig/net/auth/CMakeLists.txt root-6.08.02/net/auth/CMakeLists.txt
--- root-6.08.02.orig/net/auth/CMakeLists.txt	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/net/auth/CMakeLists.txt	2016-12-06 12:46:10.336969282 +0100
@@ -23,7 +23,6 @@
 add_library(rsa STATIC ${CMAKE_CURRENT_SOURCE_DIR}/src/rsaaux.cxx
                        ${CMAKE_CURRENT_SOURCE_DIR}/src/rsalib.cxx
                        ${CMAKE_CURRENT_SOURCE_DIR}/src/rsafun.cxx)
-add_dependencies(rsa move_headers)
 
 if(ssl)
   include_directories(${OPENSSL_INCLUDE_DIR})
diff -Nur root-6.08.02.orig/net/auth/src/DaemonUtils.cxx root-6.08.02/net/auth/src/DaemonUtils.cxx
--- root-6.08.02.orig/net/auth/src/DaemonUtils.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/net/auth/src/DaemonUtils.cxx	2016-12-06 12:46:10.337969271 +0100
@@ -95,18 +95,8 @@
 {
    // Executables and conf dirs
 
-   string execdir, etcdir;
-#ifdef ROOTBINDIR
-   execdir = string(ROOTBINDIR);
-#endif
-#ifdef ROOTETCDIR
-   etcdir = string(ROOTETCDIR);
-#endif
-
-   // Define rootbindir if not done already
-   if (!execdir.length())
-      execdir = string(confdir).append("/bin");
-   // Make it available to all the session via env
+   // Make rootbindir available to all the session via env
+   string execdir = TROOT::GetBinDir().Data();
    if (execdir.length()) {
       int len = 15 + execdir.length();
       char *tmp = new char[len+1];
@@ -117,10 +107,8 @@
          return -1;
    }
 
-   // Define rootetcdir if not done already
-   if (!etcdir.length())
-      etcdir = string(confdir).append("/etc");
-   // Make it available to all the session via env
+   // Make rootetcdir available to all the session via env
+   string etcdir = TROOT::GetEtcDir().Data();
    if (etcdir.length()) {
       int len = 15 + etcdir.length();
       char *tmp = new char[len+1];
diff -Nur root-6.08.02.orig/net/auth/src/TAuthenticate.cxx root-6.08.02/net/auth/src/TAuthenticate.cxx
--- root-6.08.02.orig/net/auth/src/TAuthenticate.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/net/auth/src/TAuthenticate.cxx	2016-12-06 12:46:10.338969260 +0100
@@ -4107,19 +4107,9 @@
          ::Info("TAuthenticate::ReadRootAuthrc",
                 "file %s cannot be read (errno: %d)", authrc, errno);
       delete [] authrc;
-#ifdef ROOTETCDIR
-      authrc = gSystem->ConcatFileName(ROOTETCDIR,"system.rootauthrc");
-#else
-      char etc[1024];
-#ifdef WIN32
-      snprintf(etc, 1024, "%s\\etc", gRootDir);
-#else
-      snprintf(etc, 1024, "%s/etc", gRootDir);
-#endif
-      authrc = gSystem->ConcatFileName(etc,"system.rootauthrc");
-#endif
+      authrc = gSystem->ConcatFileName(TROOT::GetEtcDir(), "system.rootauthrc");
       if (gDebug > 2)
-         ::Info("TAuthenticate::ReadRootAuthrc", "Checking system file:%s",authrc);
+         ::Info("TAuthenticate::ReadRootAuthrc", "Checking system file: %s", authrc);
       if (gSystem->AccessPathName(authrc, kReadPermission)) {
          if (gDebug > 1)
             ::Info("TAuthenticate::ReadRootAuthrc",
diff -Nur root-6.08.02.orig/net/http/src/THttpServer.cxx root-6.08.02/net/http/src/THttpServer.cxx
--- root-6.08.02.orig/net/http/src/THttpServer.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/net/http/src/THttpServer.cxx	2016-12-06 12:46:10.338969260 +0100
@@ -148,11 +148,7 @@
    if (jsrootsys != 0) fJSROOTSYS = jsrootsys;
 
    if (fJSROOTSYS.Length() == 0) {
-#ifdef ROOTETCDIR
-      TString jsdir = TString::Format("%s/http", ROOTETCDIR);
-#else
-      TString jsdir("$(ROOTSYS)/etc/http");
-#endif
+      TString jsdir = TString::Format("%s/http", TROOT::GetEtcDir().Data());
       if (gSystem->ExpandPathName(jsdir)) {
          Warning("THttpServer", "problems resolving '%s', use JSROOTSYS to specify $ROOTSYS/etc/http location", jsdir.Data());
          fJSROOTSYS = ".";
@@ -163,18 +159,7 @@
 
    AddLocation("currentdir/", ".");
    AddLocation("jsrootsys/", fJSROOTSYS);
-
-   const char *rootsys = gSystem->Getenv("ROOTSYS");
-   if (rootsys != 0) {
-      AddLocation("rootsys/", rootsys);
-   } else {
-#ifdef ROOTPREFIX
-      TString sysdir = ROOTPREFIX;
-#else
-      TString sysdir = "$(ROOTSYS)";
-#endif
-      if (!gSystem->ExpandPathName(sysdir)) AddLocation("rootsys/", sysdir);
-   }
+   AddLocation("rootsys/", TROOT::GetRootSys());
 
    fDefaultPage = fJSROOTSYS + "/files/online.htm";
    fDrawPage = fJSROOTSYS + "/files/draw.htm";
diff -Nur root-6.08.02.orig/net/net/src/TApplicationServer.cxx root-6.08.02/net/net/src/TApplicationServer.cxx
--- root-6.08.02.orig/net/net/src/TApplicationServer.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/net/net/src/TApplicationServer.cxx	2016-12-06 12:46:10.338969260 +0100
@@ -1275,17 +1275,7 @@
    TString name = ".rootlogon.C";
    TString sname = "system";
    sname += name;
-#ifdef ROOTETCDIR
-   char *s = gSystem->ConcatFileName(ROOTETCDIR, sname);
-#else
-   TString etc = gRootDir;
-#ifdef WIN32
-   etc += "\\etc";
-#else
-   etc += "/etc";
-#endif
-   char *s = gSystem->ConcatFileName(etc, sname);
-#endif
+   char *s = gSystem->ConcatFileName(TROOT::GetEtcDir(), sname);
    if (!gSystem->AccessPathName(s, kReadPermission)) {
       ProcessFile(s);
    }
diff -Nur root-6.08.02.orig/net/net/src/TServerSocket.cxx root-6.08.02/net/net/src/TServerSocket.cxx
--- root-6.08.02.orig/net/net/src/TServerSocket.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/net/net/src/TServerSocket.cxx	2016-12-06 12:46:10.338969260 +0100
@@ -335,22 +335,7 @@
       }
    }
 
-   TString confdir;
-#ifndef ROOTPREFIX
-   // try to guess the config directory...
-   if (gSystem->Getenv("ROOTSYS")) {
-      confdir = TString(gSystem->Getenv("ROOTSYS"));
-   } else {
-      // Try to guess it from 'root.exe' path
-      char *rootexe = gSystem->Which(gSystem->Getenv("PATH"),
-                                     "root.exe", kExecutePermission);
-      confdir = rootexe;
-      confdir.Resize(confdir.Last('/'));
-      delete [] rootexe;
-   }
-#else
-   confdir = TString(ROOTPREFIX);
-#endif
+   TString confdir = TROOT::GetRootSys();
    if (!confdir.Length()) {
       Error("Authenticate", "config dir undefined");
       return kFALSE;
diff -Nur root-6.08.02.orig/net/rootd/src/rootd.cxx root-6.08.02/net/rootd/src/rootd.cxx
--- root-6.08.02.orig/net/rootd/src/rootd.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/net/rootd/src/rootd.cxx	2016-12-06 12:46:10.339969248 +0100
@@ -2523,10 +2523,13 @@
 
    if (argc > 0) {
       confdir = std::string(*argv);
-   } else {
-      // try to guess the config directory...
-#ifndef ROOTPREFIX
+   }
+
+#ifdef ROOTPREFIX
+   if (getenv("IGNOREROOTPREFIX")) {
+#endif
       if (!confdir.length()) {
+         // try to guess the config directory...
          if (getenv("ROOTSYS")) {
             confdir = getenv("ROOTSYS");
             if (gDebug > 0)
@@ -2537,31 +2540,26 @@
                ErrorInfo("main: no config directory specified");
          }
       }
-#else
-      confdir = ROOTPREFIX;
-#endif
+      rootbindir = std::string(confdir).append("/bin");
+      rootetcdir = std::string(confdir).append("/etc");
+#ifdef ROOTPREFIX
+   }
+   else {
+      if (!confdir.length())
+         confdir = ROOTPREFIX;
+      rootbindir = ROOTBINDIR;
+      rootetcdir = ROOTETCDIR;
    }
-#ifdef ROOTBINDIR
-   rootbindir= ROOTBINDIR;
-#endif
-#ifdef ROOTETCDIR
-   rootetcdir= ROOTETCDIR;
 #endif
 
-   // Define rootbindir if not done already
-   if (!rootbindir.length())
-      rootbindir = std::string(confdir).append("/bin");
-   // Make it available to all the session via env
+   // Make rootbindir available to all the session via env
    if (rootbindir.length()) {
       char *tmp1 = new char[15 + rootbindir.length()];
       sprintf(tmp1, "ROOTBINDIR=%s", rootbindir.c_str());
       putenv(tmp1);
    }
 
-   // Define rootetcdir if not done already
-   if (!rootetcdir.length())
-      rootetcdir = std::string(confdir).append("/etc");
-   // Make it available to all the session via env
+   // Make rootetcdir available to all the session via env
    if (rootetcdir.length()) {
       char *tmp1 = new char[15 + rootetcdir.length()];
       sprintf(tmp1, "ROOTETCDIR=%s", rootetcdir.c_str());
diff -Nur root-6.08.02.orig/net/rpdutils/CMakeLists.txt root-6.08.02/net/rpdutils/CMakeLists.txt
--- root-6.08.02.orig/net/rpdutils/CMakeLists.txt	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/net/rpdutils/CMakeLists.txt	2016-12-06 12:46:10.339969248 +0100
@@ -31,7 +31,6 @@
 
 #---static library needed for rootd and proofd --------------------------------------------
 add_library(rpdutil STATIC ${rpdutilsrcs})
-add_dependencies(rpdutil move_headers)
 
 ROOT_LINKER_LIBRARY(SrvAuth rpdutils.cxx ssh.cxx LIBRARIES rpdutil rsa ${CRYPTLIBS} ${GLOBUS_LIBRARIES} ${OPENSSL_LIBRARIES} DEPENDENCIES Net)
 
diff -Nur root-6.08.02.orig/proof/proof/src/TProofLite.cxx root-6.08.02/proof/proof/src/TProofLite.cxx
--- root-6.08.02.orig/proof/proof/src/TProofLite.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/proof/proof/src/TProofLite.cxx	2016-12-06 12:46:10.340969237 +0100
@@ -409,17 +409,7 @@
    if (fgWrksMax == -2) {
       // Find the max number of workers, if any
       TString sysname = "system.rootrc";
-#ifdef ROOTETCDIR
-      char *s = gSystem->ConcatFileName(ROOTETCDIR, sysname);
-#else
-      TString etc = gRootDir;
-#ifdef WIN32
-      etc += "\\etc";
-#else
-      etc += "/etc";
-#endif
-      char *s = gSystem->ConcatFileName(etc, sysname);
-#endif
+      char *s = gSystem->ConcatFileName(TROOT::GetEtcDir(), sysname);
       TEnv sysenv(0);
       sysenv.ReadFile(s, kEnvGlobal);
       fgWrksMax = sysenv.GetValue("ProofLite.MaxWorkers", -1);
@@ -765,17 +755,9 @@
       return -1;
    }
    // ROOTSYS
-#ifdef R__HAVE_CONFIG
-   fprintf(fenv, "export ROOTSYS=%s\n", ROOTPREFIX);
-#else
-   fprintf(fenv, "export ROOTSYS=%s\n", gSystem->Getenv("ROOTSYS"));
-#endif
+   fprintf(fenv, "export ROOTSYS=%s\n", TROOT::GetRootSys().Data());
    // Conf dir
-#ifdef R__HAVE_CONFIG
-   fprintf(fenv, "export ROOTCONFDIR=%s\n", ROOTETCDIR);
-#else
-   fprintf(fenv, "export ROOTCONFDIR=%s\n", gSystem->Getenv("ROOTSYS"));
-#endif
+   fprintf(fenv, "export ROOTCONFDIR=%s\n", TROOT::GetRootSys().Data());
    // TMPDIR
    fprintf(fenv, "export TMPDIR=%s\n", gSystem->TempDirectory());
    // Log file in the log dir
diff -Nur root-6.08.02.orig/proof/proof/src/TProofServ.cxx root-6.08.02/proof/proof/src/TProofServ.cxx
--- root-6.08.02.orig/proof/proof/src/TProofServ.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/proof/proof/src/TProofServ.cxx	2016-12-06 12:46:10.341969226 +0100
@@ -2964,13 +2964,7 @@
 #ifdef R__UNIX
    // Add bindir to PATH
    TString path(gSystem->Getenv("PATH"));
-   TString bindir;
-# ifdef ROOTBINDIR
-   bindir = ROOTBINDIR;
-# else
-   bindir = gSystem->Getenv("ROOTSYS");
-   if (!bindir.IsNull()) bindir += "/bin";
-# endif
+   TString bindir(TROOT::GetBinDir());
    // Augment PATH, if required
    // ^<compiler>, <compiler>, ^<sysbin>, <sysbin>
    TString paths = gEnv->GetValue("ProofServ.BinPaths", "");
diff -Nur root-6.08.02.orig/proof/proof/src/TSlaveLite.cxx root-6.08.02/proof/proof/src/TSlaveLite.cxx
--- root-6.08.02.orig/proof/proof/src/TSlaveLite.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/proof/proof/src/TSlaveLite.cxx	2016-12-06 12:46:10.341969226 +0100
@@ -88,13 +88,8 @@
 {
    // Command to be executed
    TString cmd;
-#ifdef R__HAVE_CONFIG
    cmd.Form(". %s/worker-%s.env; export ROOTBINDIR=\"%s\"; %s/proofserv proofslave lite %d %d 0&",
-            fWorkDir.Data(), fOrdinal.Data(), ROOTBINDIR, ROOTBINDIR,
-#else
-   cmd.Form(". %s/worker-%s.env; export ROOTBINDIR=\"%s/bin\"; %s/bin/proofserv proofslave lite %d %d 0&",
-            fWorkDir.Data(), fOrdinal.Data(), gSystem->Getenv("ROOTSYS"), gSystem->Getenv("ROOTSYS"),
-#endif
+            fWorkDir.Data(), fOrdinal.Data(), TROOT::GetBinDir().Data(), TROOT::GetBinDir().Data(),
             gSystem->GetPid(), gDebug);
    // Execute
    if (gSystem->Exec(cmd) != 0) {
diff -Nur root-6.08.02.orig/proof/proofbench/CMakeLists.txt root-6.08.02/proof/proofbench/CMakeLists.txt
--- root-6.08.02.orig/proof/proofbench/CMakeLists.txt	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/proof/proofbench/CMakeLists.txt	2016-12-06 12:46:10.341969226 +0100
@@ -14,7 +14,7 @@
 # Generation and installation of the PAR files required by the benchmark 
 add_custom_target(ProofBenchPARFiles ALL DEPENDS ${CMAKE_BINARY_DIR}/etc/proof/proofbench/ProofBenchCPUSel.par
                                                  ${CMAKE_BINARY_DIR}/etc/proof/proofbench/ProofBenchDataSel.par)
-add_dependencies(ProofBenchPARFiles move_headers) # The /etc directory from sources is copied when moving the headers
+add_dependencies(ProofBenchPARFiles move_artifacts)
 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/etc/proof/proofbench/ProofBenchCPUSel.par
                           ${CMAKE_BINARY_DIR}/etc/proof/proofbench/ProofBenchDataSel.par
     COMMAND etc/proof/utils/makepbenchpars.sh ARGS ProofBenchCPUSel ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} 
diff -Nur root-6.08.02.orig/proof/proofbench/src/TProofBench.cxx root-6.08.02/proof/proofbench/src/TProofBench.cxx
--- root-6.08.02.orig/proof/proofbench/src/TProofBench.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/proof/proofbench/src/TProofBench.cxx	2016-12-06 12:46:10.342969214 +0100
@@ -1338,11 +1338,7 @@
       // Is it the default selector?
       if (fDataGenSel == kPROOF_BenchSelDataGenDef) {
          // Load the parfile
-#ifdef R__HAVE_CONFIG
-         TString par = TString::Format("%s/%s%s.par", ROOTETCDIR, kPROOF_BenchParDir, kPROOF_BenchDataSelPar);
-#else
-         TString par = TString::Format("$ROOTSYS/etc/%s%s.par", kPROOF_BenchParDir, kPROOF_BenchDataSelPar);
-#endif
+         TString par = TString::Format("%s/%s%s.par", TROOT::GetEtcDir().Data(), kPROOF_BenchParDir, kPROOF_BenchDataSelPar);
          Info("MakeDataSet", "uploading '%s' ...", par.Data());
          if (fProof->UploadPackage(par) != 0) {
             Error("MakeDataSet", "problems uploading '%s' - cannot continue", par.Data());
diff -Nur root-6.08.02.orig/proof/proofbench/src/TProofBenchDataSet.cxx root-6.08.02/proof/proofbench/src/TProofBenchDataSet.cxx
--- root-6.08.02.orig/proof/proofbench/src/TProofBenchDataSet.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/proof/proofbench/src/TProofBenchDataSet.cxx	2016-12-06 12:46:10.342969214 +0100
@@ -25,6 +25,7 @@
 #include "TMap.h"
 #include "TProof.h"
 #include "TProofBenchTypes.h"
+#include "TROOT.h"
 
 
 ClassImp(TProofBenchDataSet)
@@ -144,11 +145,7 @@
    TString selName("TSelHandleDataSet");
    if (!TClass::GetClass(selName)) {
       // Load the parfile
-#ifdef R__HAVE_CONFIG
-      TString par = TString::Format("%s/%s%s.par", ROOTETCDIR, kPROOF_BenchParDir, kPROOF_BenchDataSelPar);
-#else
-      TString par = TString::Format("$ROOTSYS/etc/%s%s.par", kPROOF_BenchParDir, kPROOF_BenchDataSelPar);
-#endif
+      TString par = TString::Format("%s/%s%s.par", TROOT::GetEtcDir().Data(), kPROOF_BenchParDir, kPROOF_BenchDataSelPar);
       Info("Handle", "Uploading '%s' ...", par.Data());
       if (fProof->UploadPackage(par) != 0) {
          Error("Handle", "problems uploading '%s' - cannot continue", par.Data());
diff -Nur root-6.08.02.orig/proof/proofbench/src/TProofBenchRunCPU.cxx root-6.08.02/proof/proofbench/src/TProofBenchRunCPU.cxx
--- root-6.08.02.orig/proof/proofbench/src/TProofBenchRunCPU.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/proof/proofbench/src/TProofBenchRunCPU.cxx	2016-12-06 12:46:10.342969214 +0100
@@ -274,11 +274,7 @@
       // Is it the default selector?
       if (fSelName == kPROOF_BenchSelCPUDef) {
          // Load the parfile
-#ifdef R__HAVE_CONFIG
-         TString par = TString::Format("%s/%s%s.par", ROOTETCDIR, kPROOF_BenchParDir, kPROOF_BenchCPUSelPar);
-#else
-         TString par = TString::Format("$ROOTSYS/etc/%s%s.par", kPROOF_BenchParDir, kPROOF_BenchCPUSelPar);
-#endif
+         TString par = TString::Format("%s/%s%s.par", TROOT::GetEtcDir().Data(), kPROOF_BenchParDir, kPROOF_BenchCPUSelPar);
          Info("Run", "Uploading '%s' ...", par.Data());
          if (fProof->UploadPackage(par) != 0) {
             Error("Run", "problems uploading '%s' - cannot continue", par.Data());
diff -Nur root-6.08.02.orig/proof/proofbench/src/TProofBenchRunDataRead.cxx root-6.08.02/proof/proofbench/src/TProofBenchRunDataRead.cxx
--- root-6.08.02.orig/proof/proofbench/src/TProofBenchRunDataRead.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/proof/proofbench/src/TProofBenchRunDataRead.cxx	2016-12-06 12:46:10.342969214 +0100
@@ -162,11 +162,7 @@
       // Is it the default selector?
       if (fSelName == kPROOF_BenchSelDataDef) {
          // Load the parfile
-#ifdef R__HAVE_CONFIG
-         TString par = TString::Format("%s/%s%s.par", ROOTETCDIR, kPROOF_BenchParDir, kPROOF_BenchDataSelPar);
-#else
-         TString par = TString::Format("$ROOTSYS/etc/%s%s.par", kPROOF_BenchParDir, kPROOF_BenchDataSelPar);
-#endif
+         TString par = TString::Format("%s/%s%s.par", TROOT::GetEtcDir().Data(), kPROOF_BenchParDir, kPROOF_BenchDataSelPar);
          Info("Run", "Uploading '%s' ...", par.Data());
          if (fProof->UploadPackage(par) != 0) {
             Error("Run", "problems uploading '%s' - cannot continue", par.Data());
diff -Nur root-6.08.02.orig/proof/proofd/src/proofd.cxx root-6.08.02/proof/proofd/src/proofd.cxx
--- root-6.08.02.orig/proof/proofd/src/proofd.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/proof/proofd/src/proofd.cxx	2016-12-06 12:46:10.343969203 +0100
@@ -1001,49 +1001,48 @@
 
    if (argc > 0) {
       gConfDir = std::string(*argv);
-   } else {
-      // try to guess the config directory...
-#ifndef ROOTDATADIR
-      if (getenv("ROOTSYS")) {
-         gConfDir = getenv("ROOTSYS");
-         if (gDebug > 0)
-            ErrorInfo("main: no config directory specified using ROOTSYS (%s)",
-                      gConfDir.c_str());
-      } else {
-         Error(ErrFatal, -1, "main: no config directory specified");
-      }
-#else
-      gConfDir = ROOTDATADIR;
-#endif
    }
-#ifdef ROOTBINDIR
-   gRootBinDir= ROOTBINDIR;
-#endif
-#ifdef ROOTETCDIR
-   rootetcdir= ROOTETCDIR;
-#endif
 
-   // Define gRootBinDir if not done already
-   if (!gRootBinDir.length())
+#ifdef ROOTPREFIX
+   if (getenv("IGNOREROOTPREFIX")) {
+#endif
+      if (!gConfDir.length()) {
+         // try to guess the config directory...
+         if (getenv("ROOTSYS")) {
+            gConfDir = getenv("ROOTSYS");
+            if (gDebug > 0)
+               ErrorInfo("main: no config directory specified using"
+                         " ROOTSYS (%s)", gConfDir.c_str());
+         } else {
+            Error(ErrFatal, -1, "main: no config directory specified");
+         }
+      }
       gRootBinDir = std::string(gConfDir).append("/bin");
+      rootetcdir = std::string(gConfDir).append("/etc");
+#ifdef ROOTPREFIX
+   }
+   else  {
+      if (!gConfDir.length())
+         gConfDir = ROOTPREFIX;
+      gRootBinDir = ROOTBINDIR;
+      rootetcdir = ROOTETCDIR;
+   }
+#endif
 
-   // make sure it contains the executable we want to run
+   // make sure gRootBinDir contains the executable we want to run
    std::string arg0 = std::string(gRootBinDir).append("/proofserv");
    if (access(arg0.c_str(), X_OK) == -1) {
       Error(ErrFatal,-1,"main: incorrect config directory specified (%s)",
                         gConfDir.c_str());
    }
-   // Make it available to all the session via env
+   // Make gRootBinDir available to all the session via env
    if (gRootBinDir.length()) {
       char *tmp = new char[15 + gRootBinDir.length()];
       snprintf(tmp, 15 + gRootBinDir.length(), "ROOTBINDIR=%s", gRootBinDir.c_str());
       putenv(tmp);
    }
 
-   // Define rootetcdir if not done already
-   if (!rootetcdir.length())
-      rootetcdir = std::string(gConfDir).append("/etc");
-   // Make it available to all the session via env
+   // Make rootetcdir available to all the session via env
    if (rootetcdir.length()) {
       char *tmp = new char[15 + rootetcdir.length()];
       snprintf(tmp, 15 + rootetcdir.length(), "ROOTETCDIR=%s", rootetcdir.c_str());
diff -Nur root-6.08.02.orig/proof/proofd/src/XrdROOT.cxx root-6.08.02/proof/proofd/src/XrdROOT.cxx
--- root-6.08.02.orig/proof/proofd/src/XrdROOT.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/proof/proofd/src/XrdROOT.cxx	2016-12-06 12:46:10.343969203 +0100
@@ -384,11 +384,19 @@
    } else {
       // Check the ROOT dirs
       if (fROOT.size() <= 0) {
+         XrdOucString dir, bd, ld, id, dd;
 #ifdef R__HAVE_CONFIG
-         XrdOucString dir(ROOTPREFIX), bd(ROOTBINDIR), ld(ROOTLIBDIR),
-                      id(ROOTINCDIR), dd(ROOTDATADIR);
-#else
-         XrdOucString dir(getenv("ROOTSYS")), bd, ld, id, dd;
+         if (getenv("ROOTIGNOREPREFIX"))
+#endif
+            dir = getenv("ROOTSYS");
+#ifdef R__HAVE_CONFIG
+         else {
+            dir = ROOTPREFIX;
+            bd = ROOTBINDIR;
+            ld = ROOTLIBDIR;
+            id = ROOTINCDIR;
+            dd = ROOTDATADIR;
+         }
 #endif
          // None defined: use ROOTSYS as default, if any; otherwise we fail
          if (dir.length() > 0) {
diff -Nur root-6.08.02.orig/roofit/histfactory/CMakeLists.txt root-6.08.02/roofit/histfactory/CMakeLists.txt
--- root-6.08.02.orig/roofit/histfactory/CMakeLists.txt	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/roofit/histfactory/CMakeLists.txt	2016-12-06 12:46:10.343969203 +0100
@@ -25,10 +25,4 @@
                             WORLD_EXECUTE WORLD_READ
                 DESTINATION ${CMAKE_INSTALL_BINDIR})
 
-
-#ROOT_INSTALL_HEADERS()
-install(DIRECTORY inc/RooStats/HistFactory/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/RooStats/HistFactory 
-                       COMPONENT headers
-                       PATTERN ".svn" EXCLUDE
-                       REGEX "LinkDef" EXCLUDE )
-set_property(GLOBAL APPEND PROPERTY ROOT_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/inc)
+ROOT_INSTALL_HEADERS()
diff -Nur root-6.08.02.orig/roofit/histfactory/config/prepareHistFactory root-6.08.02/roofit/histfactory/config/prepareHistFactory
--- root-6.08.02.orig/roofit/histfactory/config/prepareHistFactory	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/roofit/histfactory/config/prepareHistFactory	2016-12-06 12:46:10.343969203 +0100
@@ -2,16 +2,10 @@
 
 # HistFactory workplace setup script
 
-ROOTPREFDIR=`root-config --prefix`
-ROOTETCDIR=`root-config --etcdir`
+ROOTETCDIR=`root -b -q -l -n -e "std::cout << TROOT::GetEtcDir() << std::endl;" | tail -1`
 echo "Using etcdir "$ROOTETCDIR
-ROOTTUTDIR=$ROOTPREFDIR/tutorials
-if test -e $ROOTTUTDIR; then
-    echo "Using tutorials dir" $ROOTTUTDIR 
-else     
-    ROOTTUTDIR=${ROOTPREFDIR}/share/doc/root/tutorials
-    echo "Using tutorials dir" $ROOTTUTDIR 
-fi
+ROOTTUTDIR=`root -b -q -l -n -e "std::cout << TROOT::GetTutorialDir() << std::endl;" | tail -1`
+echo "Using tutorials dir" $ROOTTUTDIR 
 
 if [ $# -eq 1 ]
 then
diff -Nur root-6.08.02.orig/roofit/roostats/CMakeLists.txt root-6.08.02/roofit/roostats/CMakeLists.txt
--- root-6.08.02.orig/roofit/roostats/CMakeLists.txt	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/roofit/roostats/CMakeLists.txt	2016-12-06 12:46:10.344969192 +0100
@@ -8,9 +8,4 @@
 ROOT_LINKER_LIBRARY(RooStats  *.cxx G__RooStats.cxx LIBRARIES Core 
                                DEPENDENCIES RooFit RooFitCore Tree RIO Hist Matrix MathCore Minuit Foam Graf Gpad )
 
-#ROOT_INSTALL_HEADERS()
-install(DIRECTORY inc/RooStats/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/RooStats
-                       COMPONENT headers
-                       PATTERN ".svn" EXCLUDE
-                       REGEX "LinkDef" EXCLUDE )
-set_property(GLOBAL APPEND PROPERTY ROOT_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/inc)
+ROOT_INSTALL_HEADERS()
diff -Nur root-6.08.02.orig/rootx/src/rootx.cxx root-6.08.02/rootx/src/rootx.cxx
--- root-6.08.02.orig/rootx/src/rootx.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/rootx/src/rootx.cxx	2016-12-06 12:46:10.344969192 +0100
@@ -218,7 +218,6 @@
    return 0;
 }
 
-#ifndef ROOTPREFIX
 static const char *GetExePath()
 {
    static std::string exepath;
@@ -265,7 +264,6 @@
       delete [] ep;
    }
 }
-#endif
 
 static void SetDisplay()
 {
@@ -314,7 +312,9 @@
 
 static void SetLibraryPath()
 {
-#ifndef ROOTLIBDIR
+#ifdef ROOTPREFIX
+   if (getenv("ROOTIGNOREPREFIX")) {
+#endif
    // Set library path for the different platforms.
 
    char *msg;
@@ -361,6 +361,8 @@
    }
 #  endif
    putenv(msg);
+#ifdef ROOTPREFIX
+   }
 #endif
 }
 
@@ -458,7 +460,9 @@
    char **argvv;
    char  arg0[kMAXPATHLEN];
 
-#ifndef ROOTPREFIX
+#ifdef ROOTPREFIX
+   if (getenv("ROOTIGNOREPREFIX")) {
+#endif
    // Try to set ROOTSYS depending on pathname of the executable
    SetRootSys();
 
@@ -467,6 +471,8 @@
               argv[0], argv[0]);
       return 1;
    }
+#ifdef ROOTPREFIX
+   }
 #endif
 
    // In batch mode don't show splash screen, idem for no logo mode,
@@ -491,23 +497,20 @@
    if (notebook) {
       // Build command
 #ifdef ROOTBINDIR
-      snprintf(arg0, sizeof(arg0), "%s/%s", ROOTBINDIR, ROOTNBBINARY);
-#else
-      snprintf(arg0, sizeof(arg0), "%s/bin/%s", getenv("ROOTSYS"), ROOTNBBINARY);
+      if (getenv("ROOTIGNOREPREFIX"))
+#endif
+         snprintf(arg0, sizeof(arg0), "%s/bin/%s", getenv("ROOTSYS"), ROOTNBBINARY);
+#ifdef ROOTBINDIR
+      else
+         snprintf(arg0, sizeof(arg0), "%s/%s", ROOTBINDIR, ROOTNBBINARY);
 #endif
 
       // Execute ROOT notebook binary
       execl(arg0, arg0, NULL);
-  
+
       // Exec failed
-#ifndef ROOTBINDIR
-      fprintf(stderr,
-              "%s: can't start ROOT notebook -- this option is only available when building with CMake, please check that %s/bin/%s exists\n",
-              argv[0], getenv("ROOTSYS"), ROOTNBBINARY);
-#else
-      fprintf(stderr, "%s: can't start ROOT notebook -- this option is only available when building with CMake, please check that %s/%s exists\n",
-              argv[0], ROOTBINDIR, ROOTNBBINARY);
-#endif
+      fprintf(stderr, "%s: can't start ROOT notebook -- this option is only available when building with CMake, please check that %s exists\n",
+              argv[0], arg0);
 
       return 1;
    }
@@ -604,9 +607,12 @@
    // Build argv vector
    argvv = new char* [argc+2];
 #ifdef ROOTBINDIR
-   snprintf(arg0, sizeof(arg0), "%s/%s", ROOTBINDIR, ROOTBINARY);
-#else
-   snprintf(arg0, sizeof(arg0), "%s/bin/%s", getenv("ROOTSYS"), ROOTBINARY);
+   if (getenv("ROOTIGNOREPREFIX"))
+#endif
+      snprintf(arg0, sizeof(arg0), "%s/bin/%s", getenv("ROOTSYS"), ROOTBINARY);
+#ifdef ROOTBINDIR
+   else
+      snprintf(arg0, sizeof(arg0), "%s/%s", ROOTBINDIR, ROOTBINARY);
 #endif
    argvv[0] = arg0;
    argvv[1] = (char *) "-splash";
@@ -622,14 +628,8 @@
    execv(arg0, argvv);
 
    // Exec failed
-#ifndef ROOTBINDIR
-   fprintf(stderr,
-           "%s: can't start ROOT -- check that %s/bin/%s exists!\n",
-           argv[0], getenv("ROOTSYS"), ROOTBINARY);
-#else
-   fprintf(stderr, "%s: can't start ROOT -- check that %s/%s exists!\n",
-           argv[0], ROOTBINDIR, ROOTBINARY);
-#endif
+   fprintf(stderr, "%s: can't start ROOT -- check that %s exists!\n",
+           argv[0], arg0);
 
    return 1;
 }
diff -Nur root-6.08.02.orig/test/rhtml/rhtml.cxx root-6.08.02/test/rhtml/rhtml.cxx
--- root-6.08.02.orig/test/rhtml/rhtml.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/test/rhtml/rhtml.cxx	2016-12-06 12:46:10.344969192 +0100
@@ -475,14 +475,7 @@
                   case M_HELP_ABOUT:
                      {
 #ifdef R__UNIX
-                        TString rootx;
-# ifdef ROOTBINDIR
-                        rootx = ROOTBINDIR;
-# else
-                        rootx = gSystem->Getenv("ROOTSYS");
-                        if (!rootx.IsNull()) rootx += "/bin";
-# endif
-                        rootx += "/root -a &";
+                        TString rootx = TROOT::GetBinDir() + "/root -a &";
                         gSystem->Exec(rootx);
 #else
 #ifdef WIN32
diff -Nur root-6.08.02.orig/test/RootIDE/TGRootIDE.cxx root-6.08.02/test/RootIDE/TGRootIDE.cxx
--- root-6.08.02.orig/test/RootIDE/TGRootIDE.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/test/RootIDE/TGRootIDE.cxx	2016-12-06 12:46:10.344969192 +0100
@@ -1270,14 +1270,7 @@
 void TGRootIDE::About()
 {
 #ifdef R__UNIX
-   TString rootx;
-# ifdef ROOTBINDIR
-   rootx = ROOTBINDIR;
-# else
-   rootx = gSystem->Getenv("ROOTSYS");
-   if (!rootx.IsNull()) rootx += "/bin";
-# endif
-   rootx += "/root -a &";
+   TString rootx = TROOT::GetBinDir() + "/root -a &";
    gSystem->Exec(rootx);
 #else
 #ifdef WIN32
diff -Nur root-6.08.02.orig/tmva/tmva/CMakeLists.txt root-6.08.02/tmva/tmva/CMakeLists.txt
--- root-6.08.02.orig/tmva/tmva/CMakeLists.txt	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tmva/tmva/CMakeLists.txt	2016-12-06 12:46:10.345969180 +0100
@@ -79,11 +79,7 @@
                     LIBRARIES Core ${DNN_CUDA_LIBRARIES} ${DNN_CPU_LIBRARIES}
                     DEPENDENCIES RIO Hist Tree TreePlayer MLP Minuit XMLIO)
 
-install(DIRECTORY inc/TMVA/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/TMVA
-                            COMPONENT headers
-                            PATTERN ".svn" EXCLUDE
-                            REGEX "LinkDef" EXCLUDE )
-set_property(GLOBAL APPEND PROPERTY ROOT_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/inc)
+ROOT_INSTALL_HEADERS()
 
 if(NOT gnuinstall)
   install(DIRECTORY test DESTINATION tmva 
diff -Nur root-6.08.02.orig/tmva/tmvagui/CMakeLists.txt root-6.08.02/tmva/tmvagui/CMakeLists.txt
--- root-6.08.02.orig/tmva/tmvagui/CMakeLists.txt	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tmva/tmvagui/CMakeLists.txt	2016-12-06 12:46:10.345969180 +0100
@@ -31,11 +31,7 @@
 ROOT_LINKER_LIBRARY(TMVAGui *.cxx G__TMVAGui.cxx LIBRARIES Core
                     DEPENDENCIES RIO Hist Tree TreeViewer  MLP Minuit XMLIO TMVA Gui)
 
-install(DIRECTORY inc/TMVA/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/TMVA
-                            COMPONENT headers
-                            PATTERN ".svn" EXCLUDE
-                            REGEX "LinkDef" EXCLUDE )
-set_property(GLOBAL APPEND PROPERTY ROOT_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/inc)
+ROOT_INSTALL_HEADERS()
 
 if(NOT gnuinstall)
   install(DIRECTORY test DESTINATION tmva 
diff -Nur root-6.08.02.orig/tree/treeviewer/src/TTreeViewer.cxx root-6.08.02/tree/treeviewer/src/TTreeViewer.cxx
--- root-6.08.02.orig/tree/treeviewer/src/TTreeViewer.cxx	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tree/treeviewer/src/TTreeViewer.cxx	2016-12-06 12:46:10.345969180 +0100
@@ -2048,14 +2048,7 @@
                   case kHelpAbout:
                      {
 #ifdef R__UNIX
-                        TString rootx;
-# ifdef ROOTBINDIR
-                        rootx = ROOTBINDIR;
-# else
-                        rootx = gSystem->Getenv("ROOTSYS");
-                        if (!rootx.IsNull()) rootx += "/bin";
-# endif
-                        rootx += "/root -a &";
+                        TString rootx = TROOT::GetBinDir() + "/root -a &";
                         gSystem->Exec(rootx);
 #else
 #ifdef WIN32
diff -Nur root-6.08.02.orig/tutorials/eve/SplitGLView.C root-6.08.02/tutorials/eve/SplitGLView.C
--- root-6.08.02.orig/tutorials/eve/SplitGLView.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/eve/SplitGLView.C	2016-12-06 12:46:10.346969169 +0100
@@ -291,8 +291,7 @@
    const char *str = fText.Data();
    char *string = strdup(str);
    Int_t nlines = 0, size = fTextH;
-   TString fp = gEnv->GetValue("Root.TTFontPath", "");
-   TString ar = fp + "/arial.ttf";
+   TString ar = "arial.ttf";
    char *s = strtok((char *)string, "\n");
    TImage *img = (TImage*)fImage->Clone("img");
    img->DrawText(fTextX, fTextY+(nlines*size), s, size, fTextCol, ar);
@@ -1020,14 +1019,7 @@
       case kHelpAbout:
          {
 #ifdef R__UNIX
-            TString rootx;
-# ifdef ROOTBINDIR
-            rootx = ROOTBINDIR;
-# else
-            rootx = gSystem->Getenv("ROOTSYS");
-            if (!rootx.IsNull()) rootx += "/bin";
-# endif
-            rootx += "/root -a &";
+            TString rootx = TROOT::GetBinDir() + "/root -a &";
             gSystem->Exec(rootx);
 #else
 #ifdef WIN32
diff -Nur root-6.08.02.orig/tutorials/fit/fit1.C root-6.08.02/tutorials/fit/fit1.C
--- root-6.08.02.orig/tutorials/fit/fit1.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/fit/fit1.C	2016-12-06 12:46:10.346969169 +0100
@@ -35,7 +35,7 @@
    // We connect the ROOT file generated in a previous tutorial
    // (see <a href="fillrandom.C.nbconvert.ipynb">Filling histograms with random numbers from a function</a>) 
    //
-   TString dir = gROOT->GetTutorialsDir();
+   TString dir = gROOT->GetTutorialDir();
    dir.Append("/fit/");
    TFile *file = TFile::Open("fillrandom.root");
    if (!file) {
diff -Nur root-6.08.02.orig/tutorials/fit/fitslicesy.C root-6.08.02/tutorials/fit/fitslicesy.C
--- root-6.08.02.orig/tutorials/fit/fitslicesy.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/fit/fitslicesy.C	2016-12-06 12:46:10.346969169 +0100
@@ -23,7 +23,7 @@
    gStyle->SetTitleH(0.1);
 
 // Connect the input file and get the 2-d histogram in memory
-   TString dir = gROOT->GetTutorialsDir();
+   TString dir = gROOT->GetTutorialDir();
    dir.Append("/hsimple.C");
    dir.ReplaceAll("/./","/");
    if (!gInterpreter->IsLoaded(dir.Data())) gInterpreter->LoadMacro(dir.Data());
diff -Nur root-6.08.02.orig/tutorials/fit/myfit.C root-6.08.02/tutorials/fit/myfit.C
--- root-6.08.02.orig/tutorials/fit/myfit.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/fit/myfit.C	2016-12-06 12:46:10.346969169 +0100
@@ -25,7 +25,7 @@
 }
 void myfit()
 {
-   TString dir = gROOT->GetTutorialsDir();
+   TString dir = gROOT->GetTutorialDir();
    dir.Append("/hsimple.C");
    dir.ReplaceAll("/./","/");
    if (!gInterpreter->IsLoaded(dir.Data())) gInterpreter->LoadMacro(dir.Data());
diff -Nur root-6.08.02.orig/tutorials/foam/foam_demopers.C root-6.08.02/tutorials/foam/foam_demopers.C
--- root-6.08.02.orig/tutorials/foam/foam_demopers.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/foam/foam_demopers.C	2016-12-06 12:46:10.347969158 +0100
@@ -24,7 +24,7 @@
    gSystem->Load("libFoam");
 
    // need to load the foam_demo tutorial for the definition of the function
-   TString macroName = gROOT->GetTutorialsDir();
+   TString macroName = gROOT->GetTutorialDir();
    macroName.Append("/foam/foam_demo.C");
    gROOT->ProcessLine(TString::Format(".L %s+",macroName.Data()));
 
diff -Nur root-6.08.02.orig/tutorials/geom/runplugin.C root-6.08.02/tutorials/geom/runplugin.C
--- root-6.08.02.orig/tutorials/geom/runplugin.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/geom/runplugin.C	2016-12-06 12:46:10.347969158 +0100
@@ -27,7 +27,7 @@
 {
 
 
-   TString tutdir = gROOT->GetTutorialsDir();
+   TString tutdir = gROOT->GetTutorialDir();
    gROOT->ProcessLine(".x " + tutdir + "/geom/rootgeom.C");
    plugin = new iterplugin();
    gGeoManager->GetGeomPainter()->SetIteratorPlugin(plugin);
diff -Nur root-6.08.02.orig/tutorials/graphics/earth.C root-6.08.02/tutorials/graphics/earth.C
--- root-6.08.02.orig/tutorials/graphics/earth.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/graphics/earth.C	2016-12-06 12:46:10.347969158 +0100
@@ -26,7 +26,7 @@
    TH2F *hs = new TH2F("hs","Sinusoidal",180, -180, 180, 181, -90.5, 90.5);
    TH2F *hp = new TH2F("hp","Parabolic", 180, -180, 180, 181, -90.5, 90.5);
 
-   TString dat = gROOT->GetTutorialsDir();
+   TString dat = gROOT->GetTutorialDir();
    dat.Append("/graphics/earth.dat");
    dat.ReplaceAll("/./","/");
 
diff -Nur root-6.08.02.orig/tutorials/graphics/psview.C root-6.08.02/tutorials/graphics/psview.C
--- root-6.08.02.orig/tutorials/graphics/psview.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/graphics/psview.C	2016-12-06 12:46:10.347969158 +0100
@@ -32,7 +32,7 @@
    gROOT->SetBatch(1);
 
    // create a PostScript file
-   TString dir = gROOT->GetTutorialsDir();
+   TString dir = gROOT->GetTutorialDir();
    dir.Append("/graphics/feynman.C");
    gROOT->Macro(dir);
    gPad->Print("feynman.eps");
diff -Nur root-6.08.02.orig/tutorials/graphs/motorcycle.C root-6.08.02/tutorials/graphs/motorcycle.C
--- root-6.08.02.orig/tutorials/graphs/motorcycle.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/graphs/motorcycle.C	2016-12-06 12:46:10.347969158 +0100
@@ -43,7 +43,7 @@
 void motorcycle()
 {
 // data taken from R library MASS: mcycle.txt
-   TString dir = gROOT->GetTutorialsDir();
+   TString dir = gROOT->GetTutorialDir();
    dir.Append("/graphs/");
    dir.ReplaceAll("/./","/");
 
diff -Nur root-6.08.02.orig/tutorials/hist/FirstContour.C root-6.08.02/tutorials/hist/FirstContour.C
--- root-6.08.02.orig/tutorials/hist/FirstContour.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/hist/FirstContour.C	2016-12-06 12:46:10.347969158 +0100
@@ -13,7 +13,7 @@
 
 void FirstContour()
 {
-   TString dir = gROOT->GetTutorialsDir();
+   TString dir = gROOT->GetTutorialDir();
    dir.Append("/hsimple.C");
    dir.ReplaceAll("/./","/");
    if (!gInterpreter->IsLoaded(dir.Data())) gInterpreter->LoadMacro(dir.Data());
diff -Nur root-6.08.02.orig/tutorials/hist/h1draw.C root-6.08.02/tutorials/hist/h1draw.C
--- root-6.08.02.orig/tutorials/hist/h1draw.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/hist/h1draw.C	2016-12-06 12:46:10.348969146 +0100
@@ -25,7 +25,7 @@
 
 void h1draw()
 {
-   TString dir = gROOT->GetTutorialsDir();
+   TString dir = gROOT->GetTutorialDir();
    dir.Append("/hsimple.C");
    dir.ReplaceAll("/./","/");
    if (gBenchmark->GetBench("hsimple") < 0) gInterpreter->LoadMacro(dir.Data());
diff -Nur root-6.08.02.orig/tutorials/hist/hbars.C root-6.08.02/tutorials/hist/hbars.C
--- root-6.08.02.orig/tutorials/hist/hbars.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/hist/hbars.C	2016-12-06 12:46:10.348969146 +0100
@@ -10,7 +10,7 @@
 
 TCanvas *hbars() {
      // Try to open first the file cernstaff.root in tutorials/tree directory
-   TString filedir = gROOT->GetTutorialsDir();
+   TString filedir = gROOT->GetTutorialDir();
    filedir += TString("/tree/");
    TString filename = "cernstaff.root";
    bool fileNotFound = gSystem->AccessPathName(filename); // note opposite return code
diff -Nur root-6.08.02.orig/tutorials/hsimple.C root-6.08.02/tutorials/hsimple.C
--- root-6.08.02.orig/tutorials/hsimple.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/hsimple.C	2016-12-06 12:46:10.348969146 +0100
@@ -34,7 +34,7 @@
 TFile *hsimple(Int_t getFile=0)
 {
    TString filename = "hsimple.root";
-   TString dir = gROOT->GetTutorialsDir();
+   TString dir = gROOT->GetTutorialDir();
    dir.ReplaceAll("/./","/");
    TFile *hfile = 0;
    if (getFile) {
diff -Nur root-6.08.02.orig/tutorials/image/rose_image.C root-6.08.02/tutorials/image/rose_image.C
--- root-6.08.02.orig/tutorials/image/rose_image.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/image/rose_image.C	2016-12-06 12:46:10.348969146 +0100
@@ -30,9 +30,8 @@
    img->SetConstRatio(0);
    img->SetImageQuality(TAttImage::kImgBest);
 
-   TString fp = gEnv->GetValue("Root.TTFontPath", "");
-   TString bc = fp + "/BlackChancery.ttf";
-   TString ar = fp + "/arial.ttf";
+   TString bc = "BlackChancery.ttf";
+   TString ar = "arial.ttf";
 
    // draw text over image with funny font
    img->DrawText(120, 160, "Hello World!", 32,
diff -Nur root-6.08.02.orig/tutorials/io/importCode.C root-6.08.02/tutorials/io/importCode.C
--- root-6.08.02.orig/tutorials/io/importCode.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/io/importCode.C	2016-12-06 12:46:10.348969146 +0100
@@ -54,7 +54,7 @@
 }
 void importCode() {
    TFile *f = new TFile("code.root","recreate");
-   TString dir = gROOT->GetTutorialsDir();
+   TString dir = gROOT->GetTutorialDir();
    importdir(dir); //change the directory as you like
    delete f;
 }
diff -Nur root-6.08.02.orig/tutorials/io/mergeSelective.C root-6.08.02/tutorials/io/mergeSelective.C
--- root-6.08.02.orig/tutorials/io/mergeSelective.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/io/mergeSelective.C	2016-12-06 12:46:10.348969146 +0100
@@ -49,7 +49,7 @@
    // Create the files to be merged
    TStopwatch timer;
    timer.Start();
-   TString tutdir = gROOT->GetTutorialsDir();
+   TString tutdir = gROOT->GetTutorialDir();
    if (gROOT->LoadMacro(tutdir + "/hsimple.C")) return;
    Int_t i;
    for (i=0; i<nfiles; i++) CreateFile(Form("tomerge%03d.root",i));
diff -Nur root-6.08.02.orig/tutorials/io/testMergeCont.C root-6.08.02/tutorials/io/testMergeCont.C
--- root-6.08.02.orig/tutorials/io/testMergeCont.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/io/testMergeCont.C	2016-12-06 12:46:10.349969135 +0100
@@ -39,7 +39,7 @@
 
 void testMergeCont()
 {
-   TString tutdir = gROOT->GetTutorialsDir();
+   TString tutdir = gROOT->GetTutorialDir();
    gROOT->LoadMacro(tutdir+"/hsimple.C");
    TList *list1 = (TList *)GetCollection();
    TList *inputs = new TList();
diff -Nur root-6.08.02.orig/tutorials/multicore/mp103_processSelector.C root-6.08.02/tutorials/multicore/mp103_processSelector.C
--- root-6.08.02.orig/tutorials/multicore/mp103_processSelector.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/multicore/mp103_processSelector.C	2016-12-06 12:46:10.349969135 +0100
@@ -26,7 +26,7 @@
   // MacOSX may generate connection to WindowServer errors
   gROOT->SetBatch(kTRUE);
 
-  TString selectorPath = gROOT->GetTutorialsDir();
+  TString selectorPath = gROOT->GetTutorialDir();
   selectorPath += "/tree/h1analysis.C+";
   std::cout << "selector used is: "<< selectorPath<<"\n";
   TSelector *sel = TSelector::GetSelector(selectorPath);
diff -Nur root-6.08.02.orig/tutorials/pyroot/benchmarks.py root-6.08.02/tutorials/pyroot/benchmarks.py
--- root-6.08.02.orig/tutorials/pyroot/benchmarks.py	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/pyroot/benchmarks.py	2016-12-06 12:46:10.349969135 +0100
@@ -45,7 +45,7 @@
 ## --------------------------------------------------------------------------
 if __name__ == '__main__':
 
-   macrodir = os.path.join(ROOT.gROOT.GetTutorialsDir(), 'pyroot')
+   macrodir = os.path.join(str(ROOT.gROOT.GetTutorialDir()), 'pyroot')
 
  # window for keeping track of bench marks that are run
    bench = ROOT.TCanvas( 'bench','Benchmarks Summary', -1000, 50, 200, 500 )
diff -Nur root-6.08.02.orig/tutorials/pyroot/fit1.py root-6.08.02/tutorials/pyroot/fit1.py
--- root-6.08.02.orig/tutorials/pyroot/fit1.py	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/pyroot/fit1.py	2016-12-06 12:46:10.349969135 +0100
@@ -51,7 +51,7 @@
 fitlabel = TPaveText( 0.6, 0.3, 0.9, 0.80, 'NDC' )
 fitlabel.SetTextAlign( 12 )
 fitlabel.SetFillColor( 42 )
-fitlabel.ReadFile(path.join(gROOT.GetTutorialsDir(), 'pyroot', 'fit1_py.py'))
+fitlabel.ReadFile(path.join(str(gROOT.GetTutorialDir()), 'pyroot', 'fit1_py.py'))
 fitlabel.Draw()
 c1.Update()
 gBenchmark.Show( 'fit1' )
diff -Nur root-6.08.02.orig/tutorials/pyroot/geometry.py root-6.08.02/tutorials/pyroot/geometry.py
--- root-6.08.02.orig/tutorials/pyroot/geometry.py	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/pyroot/geometry.py	2016-12-06 12:46:10.349969135 +0100
@@ -10,7 +10,7 @@
 import os
 import ROOT
 
-macrodir = os.path.join(ROOT.gROOT.GetTutorialsDir(), 'pyroot')
+macrodir = os.path.join(str(ROOT.gROOT.GetTutorialDir()), 'pyroot')
 
 # the na49.C file was generated, so no python conversion is provided
 ROOT.gROOT.Macro( ROOT.gSystem.UnixPathName( os.path.join( macrodir, os.pardir, 'geom', 'na49.C' ) ) )
diff -Nur root-6.08.02.orig/tutorials/pyroot/rootmarks.py root-6.08.02/tutorials/pyroot/rootmarks.py
--- root-6.08.02.orig/tutorials/pyroot/rootmarks.py	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/pyroot/rootmarks.py	2016-12-06 12:46:10.349969135 +0100
@@ -13,7 +13,7 @@
 import os
 import ROOT
 
-macrodir = os.path.join(ROOT.gROOT.GetTutorialsDir(), 'pyroot')
+macrodir = os.path.join(str(ROOT.gROOT.GetTutorialDir()), 'pyroot')
 
 # use ROOT macro to make sure that bench numbers get updated in one place
 ROOT.gROOT.Macro( ROOT.gSystem.UnixPathName( os.path.join( macrodir, os.pardir, 'rootmarks.C' ) ) )
diff -Nur root-6.08.02.orig/tutorials/pyroot/staff.py root-6.08.02/tutorials/pyroot/staff.py
--- root-6.08.02.orig/tutorials/pyroot/staff.py	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/pyroot/staff.py	2016-12-06 12:46:10.350969124 +0100
@@ -47,7 +47,7 @@
     tree.Branch( 'Nation', AddressOf( staff, 'Nation' ), 'Nation/C' )
 
     # note that the branches Division and Nation cannot be on the first branch
-    fname = os.path.join(ROOT.gROOT.GetTutorialsDir(), 'tree', 'cernstaff.dat')
+    fname = os.path.join(str(ROOT.gROOT.GetTutorialDir()), 'tree', 'cernstaff.dat')
     for line in open(fname).readlines():
         t = list(filter( lambda x: x, re.split( '\s+', line ) ) )
         staff.Category = int(t[0])             # assign as integers
diff -Nur root-6.08.02.orig/tutorials/roofit/rf505_asciicfg.C root-6.08.02/tutorials/roofit/rf505_asciicfg.C
--- root-6.08.02.orig/tutorials/roofit/rf505_asciicfg.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/roofit/rf505_asciicfg.C	2016-12-06 12:46:10.350969124 +0100
@@ -60,9 +60,9 @@
    params->writeToFile("rf505_asciicfg_example.txt") ;
 
 
-   TString dir1 = gROOT->GetTutorialsDir() ;
+   TString dir1 = gROOT->GetTutorialDir() ;
    dir1.Append("/roofit/rf505_asciicfg.txt") ;
-   TString dir2 = gROOT->GetTutorialsDir() ;
+   TString dir2 = gROOT->GetTutorialDir() ;
    dir2.Append("/roofit/rf505_asciicfg_example.txt") ;
    // R e a d    p a r a m e t e r s   f r o m    a s c i i   f i l e 
    // ----------------------------------------------------------------
diff -Nur root-6.08.02.orig/tutorials/spectrum/Background_compton.C root-6.08.02/tutorials/spectrum/Background_compton.C
--- root-6.08.02.orig/tutorials/spectrum/Background_compton.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/spectrum/Background_compton.C	2016-12-06 12:46:10.350969124 +0100
@@ -19,7 +19,7 @@
 
    TH1F *d1 = new TH1F("d1","",nbins,xmin,xmax);
 
-   TString dir  = gROOT->GetTutorialsDir();
+   TString dir  = gROOT->GetTutorialDir();
    TString file = dir+"/spectrum/TSpectrum.root";
    TFile *f     = new TFile(file.Data());
    TH1F *back = (TH1F*) f->Get("back3");
diff -Nur root-6.08.02.orig/tutorials/spectrum/Background_decr.C root-6.08.02/tutorials/spectrum/Background_decr.C
--- root-6.08.02.orig/tutorials/spectrum/Background_decr.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/spectrum/Background_decr.C	2016-12-06 12:46:10.350969124 +0100
@@ -18,7 +18,7 @@
 
    TH1F *d    = new TH1F("d","",nbins,xmin,xmax);
 
-   TString dir  = gROOT->GetTutorialsDir();
+   TString dir  = gROOT->GetTutorialDir();
    TString file = dir+"/spectrum/TSpectrum.root";
    TFile *f     = new TFile(file.Data());
    TH1F *back = (TH1F*) f->Get("back1");
diff -Nur root-6.08.02.orig/tutorials/spectrum/Background_incr.C root-6.08.02/tutorials/spectrum/Background_incr.C
--- root-6.08.02.orig/tutorials/spectrum/Background_incr.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/spectrum/Background_incr.C	2016-12-06 12:46:10.350969124 +0100
@@ -18,7 +18,7 @@
 
    TH1F *d    = new TH1F("d","",nbins,xmin,xmax);
 
-   TString dir  = gROOT->GetTutorialsDir();
+   TString dir  = gROOT->GetTutorialDir();
    TString file = dir+"/spectrum/TSpectrum.root";
    TFile *f     = new TFile(file.Data());
    TH1F *back = (TH1F*) f->Get("back1");
diff -Nur root-6.08.02.orig/tutorials/spectrum/Background_order.C root-6.08.02/tutorials/spectrum/Background_order.C
--- root-6.08.02.orig/tutorials/spectrum/Background_order.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/spectrum/Background_order.C	2016-12-06 12:46:10.350969124 +0100
@@ -22,7 +22,7 @@
    TH1F *d3 = new TH1F("d3","",nbins,xmin,xmax);
    TH1F *d4 = new TH1F("d4","",nbins,xmin,xmax);
 
-   TString dir  = gROOT->GetTutorialsDir();
+   TString dir  = gROOT->GetTutorialDir();
    TString file = dir+"/spectrum/TSpectrum.root";
    TFile *f     = new TFile(file.Data());
    TH1F *back = (TH1F*) f->Get("back2");
diff -Nur root-6.08.02.orig/tutorials/spectrum/Background_smooth.C root-6.08.02/tutorials/spectrum/Background_smooth.C
--- root-6.08.02.orig/tutorials/spectrum/Background_smooth.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/spectrum/Background_smooth.C	2016-12-06 12:46:10.351969112 +0100
@@ -20,7 +20,7 @@
    TH1F *d1 = new TH1F("d1","",nbins,xmin,xmax);
    TH1F *d2 = new TH1F("d2","",nbins,xmin,xmax);
 
-   TString dir  = gROOT->GetTutorialsDir();
+   TString dir  = gROOT->GetTutorialDir();
    TString file = dir+"/spectrum/TSpectrum.root";
    TFile *f     = new TFile(file.Data());
    TH1F *back = (TH1F*) f->Get("back1");
diff -Nur root-6.08.02.orig/tutorials/spectrum/Background_width2.C root-6.08.02/tutorials/spectrum/Background_width2.C
--- root-6.08.02.orig/tutorials/spectrum/Background_width2.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/spectrum/Background_width2.C	2016-12-06 12:46:10.351969112 +0100
@@ -22,7 +22,7 @@
    TH1F *d3 = new TH1F("d3","",nbins,xmin,xmax);
    TH1F *d4 = new TH1F("d4","",nbins,xmin,xmax);
 
-   TString dir  = gROOT->GetTutorialsDir();
+   TString dir  = gROOT->GetTutorialDir();
    TString file = dir+"/spectrum/TSpectrum.root";
    TFile *f     = new TFile(file.Data());
    TH1F *back = (TH1F*) f->Get("back2");
diff -Nur root-6.08.02.orig/tutorials/spectrum/Background_width.C root-6.08.02/tutorials/spectrum/Background_width.C
--- root-6.08.02.orig/tutorials/spectrum/Background_width.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/spectrum/Background_width.C	2016-12-06 12:46:10.352969101 +0100
@@ -17,7 +17,7 @@
    Double_t source[nbins];
    gROOT->ForceStyle();
 
-   TString dir  = gROOT->GetTutorialsDir();
+   TString dir  = gROOT->GetTutorialDir();
    TString file = dir+"/spectrum/TSpectrum.root";
    TFile *f     = new TFile(file.Data());
    TH1F *back = (TH1F*) f->Get("back1");
diff -Nur root-6.08.02.orig/tutorials/spectrum/Deconvolution.C root-6.08.02/tutorials/spectrum/Deconvolution.C
--- root-6.08.02.orig/tutorials/spectrum/Deconvolution.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/spectrum/Deconvolution.C	2016-12-06 12:46:10.352969101 +0100
@@ -17,7 +17,7 @@
    Double_t response[nbins];
    gROOT->ForceStyle();
 
-   TString dir  = gROOT->GetTutorialsDir();
+   TString dir  = gROOT->GetTutorialDir();
    TString file = dir+"/spectrum/TSpectrum.root";
    TFile *f     = new TFile(file.Data());
    TH1F *h = (TH1F*) f->Get("decon1");
diff -Nur root-6.08.02.orig/tutorials/spectrum/DeconvolutionRL_wide_boost.C root-6.08.02/tutorials/spectrum/DeconvolutionRL_wide_boost.C
--- root-6.08.02.orig/tutorials/spectrum/DeconvolutionRL_wide_boost.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/spectrum/DeconvolutionRL_wide_boost.C	2016-12-06 12:46:10.353969090 +0100
@@ -17,7 +17,7 @@
    Double_t response[nbins];
    gROOT->ForceStyle();
 
-   TString dir  = gROOT->GetTutorialsDir();
+   TString dir  = gROOT->GetTutorialDir();
    TString file = dir+"/spectrum/TSpectrum.root";
    TFile *f     = new TFile(file.Data());
    h = (TH1F*) f->Get("decon3");
diff -Nur root-6.08.02.orig/tutorials/spectrum/DeconvolutionRL_wide.C root-6.08.02/tutorials/spectrum/DeconvolutionRL_wide.C
--- root-6.08.02.orig/tutorials/spectrum/DeconvolutionRL_wide.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/spectrum/DeconvolutionRL_wide.C	2016-12-06 12:46:10.353969090 +0100
@@ -17,7 +17,7 @@
    Double_t response[nbins];
    gROOT->ForceStyle();
 
-   TString dir  = gROOT->GetTutorialsDir();
+   TString dir  = gROOT->GetTutorialDir();
    TString file = dir+"/spectrum/TSpectrum.root";
    TFile *f     = new TFile(file.Data());
    h = (TH1F*) f->Get("decon3");
diff -Nur root-6.08.02.orig/tutorials/spectrum/Deconvolution_wide_boost.C root-6.08.02/tutorials/spectrum/Deconvolution_wide_boost.C
--- root-6.08.02.orig/tutorials/spectrum/Deconvolution_wide_boost.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/spectrum/Deconvolution_wide_boost.C	2016-12-06 12:46:10.353969090 +0100
@@ -20,7 +20,7 @@
    TH1F *h = new TH1F("h","Deconvolution",nbins,xmin,xmax);
    TH1F *d = new TH1F("d","",nbins,xmin,xmax);
 
-   TString dir  = gROOT->GetTutorialsDir();
+   TString dir  = gROOT->GetTutorialDir();
    TString file = dir+"/spectrum/TSpectrum.root";
    TFile *f     = new TFile(file.Data());
    h = (TH1F*) f->Get("decon3");
diff -Nur root-6.08.02.orig/tutorials/spectrum/Deconvolution_wide.C root-6.08.02/tutorials/spectrum/Deconvolution_wide.C
--- root-6.08.02.orig/tutorials/spectrum/Deconvolution_wide.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/spectrum/Deconvolution_wide.C	2016-12-06 12:46:10.353969090 +0100
@@ -17,7 +17,7 @@
    Double_t response[nbins];
    gROOT->ForceStyle();
 
-   TString dir  = gROOT->GetTutorialsDir();
+   TString dir  = gROOT->GetTutorialDir();
    TString file = dir+"/spectrum/TSpectrum.root";
    TFile *f     = new TFile(file.Data());
    TH1F *h = (TH1F*) f->Get("decon3");
diff -Nur root-6.08.02.orig/tutorials/spectrum/Smoothing.C root-6.08.02/tutorials/spectrum/Smoothing.C
--- root-6.08.02.orig/tutorials/spectrum/Smoothing.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/spectrum/Smoothing.C	2016-12-06 12:46:10.353969090 +0100
@@ -16,7 +16,7 @@
    Double_t source[nbins];
    gROOT->ForceStyle();
 
-   TString dir  = gROOT->GetTutorialsDir();
+   TString dir  = gROOT->GetTutorialDir();
    TString file = dir+"/spectrum/TSpectrum.root";
    TFile *f     = new TFile(file.Data());
    TH1F *h = (TH1F*) f->Get("back1");
diff -Nur root-6.08.02.orig/tutorials/tmva/keras/MulticlassKeras.py root-6.08.02/tutorials/tmva/keras/MulticlassKeras.py
--- root-6.08.02.orig/tutorials/tmva/keras/MulticlassKeras.py	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/tmva/keras/MulticlassKeras.py	2016-12-06 12:46:10.354969079 +0100
@@ -19,7 +19,7 @@
 
 # Load data
 if not isfile('tmva_example_multiple_background.root'):
-    createDataMacro = gROOT.GetTutorialsDir() + '/tmva/createData.C'
+    createDataMacro = str(gROOT.GetTutorialDir()) + '/tmva/createData.C'
     print(createDataMacro)
     gROOT.ProcessLine('.L {}'.format(createDataMacro))
     gROOT.ProcessLine('create_MultipleBackground(4000)')
diff -Nur root-6.08.02.orig/tutorials/tmva/TMVAClassificationCategoryApplication.C root-6.08.02/tutorials/tmva/TMVAClassificationCategoryApplication.C
--- root-6.08.02.orig/tutorials/tmva/TMVAClassificationCategoryApplication.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/tmva/TMVAClassificationCategoryApplication.C	2016-12-06 12:46:10.354969079 +0100
@@ -85,7 +85,7 @@
    TString fname = TString(gSystem->DirName(__FILE__) ) + "/data/";
    // if directory data not found try using tutorials dir
    if (gSystem->AccessPathName( fname + "toy_sigbkg_categ_offset.root"  )) {
-      fname = TString(gROOT->GetTutorialsDir()) + "/tmva/data/";
+      fname = gROOT->GetTutorialDir() + "/tmva/data/";
    }
    if (UseOffsetMethod) fname += "toy_sigbkg_categ_offset.root";
    else                 fname += "toy_sigbkg_categ_varoff.root";
diff -Nur root-6.08.02.orig/tutorials/tmva/TMVAClassificationCategory.C root-6.08.02/tutorials/tmva/TMVAClassificationCategory.C
--- root-6.08.02.orig/tutorials/tmva/TMVAClassificationCategory.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/tmva/TMVAClassificationCategory.C	2016-12-06 12:46:10.354969079 +0100
@@ -89,7 +89,7 @@
    TString fname = TString(gSystem->DirName(__FILE__) ) + "/data/";
    if (gSystem->AccessPathName( fname + "toy_sigbkg_categ_offset.root")) {
       // if directory data not found try using tutorials dir
-      fname = TString(gROOT->GetTutorialsDir()) + "/tmva/data/";
+      fname = gROOT->GetTutorialDir() + "/tmva/data/";
    }
    if (UseOffsetMethod) fname += "toy_sigbkg_categ_offset.root";
    else                 fname += "toy_sigbkg_categ_varoff.root";
diff -Nur root-6.08.02.orig/tutorials/tmva/TMVAMulticlass.C root-6.08.02/tutorials/tmva/TMVAMulticlass.C
--- root-6.08.02.orig/tutorials/tmva/TMVAMulticlass.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/tmva/TMVAMulticlass.C	2016-12-06 12:46:10.354969079 +0100
@@ -98,7 +98,7 @@
    }
    else {
       std::cout << "Creating testdata...." << std::endl;
-      TString createDataMacro = TString(gROOT->GetTutorialsDir()) + "/tmva/createData.C";
+      TString createDataMacro = gROOT->GetTutorialDir() + "/tmva/createData.C";
       gROOT->ProcessLine(TString::Format(".L %s",createDataMacro.Data()));
       gROOT->ProcessLine("create_MultipleBackground(2000)");
       std::cout << " created tmva_example_multiple_background.root for tests of the multiclass features"<<std::endl;
diff -Nur root-6.08.02.orig/tutorials/tmva/TMVAMultipleBackgroundExample.C root-6.08.02/tutorials/tmva/TMVAMultipleBackgroundExample.C
--- root-6.08.02.orig/tutorials/tmva/TMVAMultipleBackgroundExample.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/tmva/TMVAMultipleBackgroundExample.C	2016-12-06 12:46:10.354969079 +0100
@@ -476,7 +476,7 @@
         << "========================" << endl
         << endl;
 
-   TString createDataMacro = TString(gROOT->GetTutorialsDir()) + "/tmva/createData.C";
+   TString createDataMacro = gROOT->GetTutorialDir() + "/tmva/createData.C";
    gROOT->ProcessLine(TString::Format(".L %s",createDataMacro.Data()));
    gROOT->ProcessLine("create_MultipleBackground(2000)");
 
diff -Nur root-6.08.02.orig/tutorials/tree/basic2.C root-6.08.02/tutorials/tree/basic2.C
--- root-6.08.02.orig/tutorials/tree/basic2.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/tree/basic2.C	2016-12-06 12:46:10.354969079 +0100
@@ -10,7 +10,7 @@
 /// \author Rene Brun
 
 void basic2() {
-   TString dir = gROOT->GetTutorialsDir();
+   TString dir = gROOT->GetTutorialDir();
    dir.Append("/tree/");
    dir.ReplaceAll("/./","/");
 
diff -Nur root-6.08.02.orig/tutorials/tree/basic.C root-6.08.02/tutorials/tree/basic.C
--- root-6.08.02.orig/tutorials/tree/basic.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/tree/basic.C	2016-12-06 12:46:10.355969067 +0100
@@ -12,7 +12,7 @@
 void basic() {
 // read file $ROOTSYS/tutorials/tree/basic.dat
 // this file has 3 columns of float data
-   TString dir = gROOT->GetTutorialsDir();
+   TString dir = gROOT->GetTutorialDir();
    dir.Append("/tree/");
    dir.ReplaceAll("/./","/");
    ifstream in;
diff -Nur root-6.08.02.orig/tutorials/tree/cernbuild.C root-6.08.02/tutorials/tree/cernbuild.C
--- root-6.08.02.orig/tutorials/tree/cernbuild.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/tree/cernbuild.C	2016-12-06 12:46:10.355969067 +0100
@@ -25,7 +25,7 @@
    //The input file cern.dat is a copy of the CERN staff data base
    //from 1988
    TString filename = "cernstaff.root";
-   TString dir = gROOT->GetTutorialsDir();
+   TString dir = gROOT->GetTutorialDir();
    dir.Append("/tree/");
    dir.ReplaceAll("/./","/");
    FILE *fp = fopen(Form("%scernstaff.dat",dir.Data()),"r");
diff -Nur root-6.08.02.orig/tutorials/tree/cernstaff.C root-6.08.02/tutorials/tree/cernstaff.C
--- root-6.08.02.orig/tutorials/tree/cernstaff.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/tree/cernstaff.C	2016-12-06 12:46:10.355969067 +0100
@@ -9,7 +9,7 @@
 /// \author Rene Brun
 
 void cernstaff () {
-   TString dir = gROOT->GetTutorialsDir();
+   TString dir = gROOT->GetTutorialDir();
    dir.Append("/tree/cernstaff.C");
    if (gSystem->AccessPathName("cernstaff.root")) {
       gROOT->SetMacroPath(dir);
diff -Nur root-6.08.02.orig/tutorials/tree/jets.C root-6.08.02/tutorials/tree/jets.C
--- root-6.08.02.orig/tutorials/tree/jets.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/tree/jets.C	2016-12-06 12:46:10.355969067 +0100
@@ -99,7 +99,7 @@
 //void jets(Int_t nev=100, Int_t npileup=200, Bool_t secondrun);
 void jets(Int_t nev=100, Int_t npileup=200) {
    gSystem->Load("libPhysics");
-   TString tutdir = gROOT->GetTutorialsDir();
+   TString tutdir = gROOT->GetTutorialDir();
    gROOT->ProcessLine(".L " + tutdir + "/tree/JetEvent.cxx+");
    gROOT->ProcessLine("#define JETS_SECOND_RUN yes");
    gROOT->ProcessLine("#include \"" __FILE__ "\"");
diff -Nur root-6.08.02.orig/tutorials/tree/ntuple1.C root-6.08.02/tutorials/tree/ntuple1.C
--- root-6.08.02.orig/tutorials/tree/ntuple1.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/tree/ntuple1.C	2016-12-06 12:46:10.355969067 +0100
@@ -31,7 +31,7 @@
    //
    // Connect ROOT histogram/ntuple demonstration file
    // generated by example $ROOTSYS/tutorials/hsimple.C.
-   TString dir = gROOT->GetTutorialsDir();
+   TString dir = gROOT->GetTutorialDir();
    dir.Append("/hsimple.C");
    dir.ReplaceAll("/./","/");
    if (gBenchmark->GetBench("hsimple") < 0) gInterpreter->LoadMacro(dir.Data());
diff -Nur root-6.08.02.orig/tutorials/xml/DOMParsePerson.C root-6.08.02/tutorials/xml/DOMParsePerson.C
--- root-6.08.02.orig/tutorials/xml/DOMParsePerson.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/xml/DOMParsePerson.C	2016-12-06 12:46:10.356969056 +0100
@@ -234,7 +234,7 @@
 {
    PersonList personlist;
    gROOT->ProcessLine(".O 0");
-   TString dir = gROOT->GetTutorialsDir();
+   TString dir = gROOT->GetTutorialDir();
    if (personlist.ParseFile(dir+"/xml/person.xml") == 0)
       cout << personlist << endl;
 }
diff -Nur root-6.08.02.orig/tutorials/xml/DOMRecursive.C root-6.08.02/tutorials/xml/DOMRecursive.C
--- root-6.08.02.orig/tutorials/xml/DOMRecursive.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/xml/DOMRecursive.C	2016-12-06 12:46:10.356969056 +0100
@@ -54,7 +54,7 @@
 void DOMRecursive()
 {
   TDOMParser *domParser = new TDOMParser();
-  TString dir = gROOT->GetTutorialsDir();
+  TString dir = gROOT->GetTutorialDir();
   domParser->SetValidate(false); // do not validate with DTD
   domParser->ParseFile(dir+"/xml/person.xml");
 
diff -Nur root-6.08.02.orig/tutorials/xml/SAXHandler.C root-6.08.02/tutorials/xml/SAXHandler.C
--- root-6.08.02.orig/tutorials/xml/SAXHandler.C	2016-12-03 00:07:29.000000000 +0100
+++ root-6.08.02/tutorials/xml/SAXHandler.C	2016-12-06 12:46:10.356969056 +0100
@@ -104,6 +104,6 @@
    SaxHandler *saxHandler = new SaxHandler();
 
    saxParser->ConnectToHandler("SaxHandler", saxHandler);
-   TString dir = gROOT->GetTutorialsDir();
+   TString dir = gROOT->GetTutorialDir();
    saxParser->ParseFile(dir+"/xml/saxexample.xml");
 }