How to install ROOT on AFS area

Here are some notes on how to build a new ROOT version on AFS area in STAR.

1. Go to the AFS area where all ROOT versions are installed:
cd /afs/rhic.bnl.gov/star/ROOT/

2. Check the volume of the directory where you plan to install ROOT (for instance, 39/ ):
fs examine 39/

3. Go to 39/ and create a name of the ROOT version that will be used:
cd 39/
mkdir 6.16.00_vp

4. In 6.16.00_vp/ directory download and unpack the root version that will be compiled
wget https://root.cern/download/root_v6.16.00.source.tar.gz
tar zxvf  root_v6.16.00.source.tar.gz
rm -f root_v6.16.00.source.tar.gz

5. For 64 bits:
setup 64b

6. Move to the most upper directory with all ROOT versions (/afs/rhic.bnl.gov/star/ROOT/):
cd $ROOT

7. Then perform linking to the directory where the ROOT is placed (a newly created directory)
ln -s 39/6.16.00_vp
cd 6.16.00_vp

8. Create a directory where the ROOT build will be stored:
mkdir build
cd build

9. Run CMake (for ROOT6) to build a project that could look like:
#!/usr/bin/env bash

version=6.16.00
version_star=6.16.00_vp
nproc=128

wget https://root.cern/download/root_v${version}.source.tar.gz
tar -xzvf root_v${version}.source.tar.gz
rm -fr root_v${version}.source.tar.gz

cmake \
  -S /afs/rhic/star/ROOT/${version_star}/root-${version} \
  -B /afs/rhic/star/ROOT/${version_star}/build \
  -DCMAKE_INSTALL_PREFIX=/afs/rhic/star/ROOT/${version_star}/.$STAR_HOST_SYS/rootdeb_novc \
  -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  -Dall=ON \
  -Dpyroot_legacy=ON \
  -Dbuiltin_gsl=ON \
  -Dbuiltin_vc=OFF \
  -Ddavix=OFF \
  -DMYSQL_CONFIG_EXECUTABLE=/usr/lib64/mysql/mysql_config \
  -Dpythia6=ON \
  -DPYTHIA6_LIBRARY=/afs/rhic/opt/star/sl73_x8664_gcc485/lib/libPythia6.so \
  -DPYTHON_EXECUTABLE=/usr/bin/python \
   /afs/rhic/star/ROOT/${version_star}/root-${version}

cmake --build /afs/rhic/star/ROOT/${version_star}/build -- -j$(nproc)
cmake --build /afs/rhic/star/ROOT/${version_star}/build --target install

To choose the version of ROOT to use and setup environment variables:
setup ROOT version#
Here are some examples:
For ROOT6 one has to setup 64bit libs:
setup 64b
setup ROOT 6.16.00_vp

For ROOT5:
(setup 32b)
setup ROOT 5.34.38