See the “Installing ROOT from Source” web page.
The simplest trial would be: rm -rf v5-34-00-patches
git clone -b v5-34-00-patches http://root.cern.ch/git/root.git v5-34-00-patches
cd v5-34-00-patches
unset ROOTSYS
./configure --enable-soversion --all
make
See also the “ROOT Tutorials: CFITSIO interface” web page.