#!/bin/bash # Script to make the CERN ROOT executables and libraries. # Exit Codes found in /usr/include/sysexits.h #set -x # CERN ROOT requires GCC 4.8 or greater if ( [ "$(type gcc &> /dev/null ; echo $?)" -eq 0 ] && [ "${2}" != "-cleaner" ] ) ; then GCC_VER_STR=$(gcc --version | head -1 | cut -d. -f1) GCC_MAJOR_VER="${GCC_VER_STR: -1}" GCC_MINOR_VER=$(gcc --version | head -1 | cut -d. -f2) if ( [ "${GCC_MAJOR_VER}" -lt 4 ] ) ; then echo -e "\nPlease upgrade your version of GCC or set your PATH to where a minimum 4.8 version of GCC is located.\n" exit 69 elif ( [ "${GCC_MAJOR_VER}" -eq 4 ] && [ "${GCC_MINOR_VER}" -lt 8 ] ) ; then if ( [ $(ls -1 /opt/rh | grep devtoolset &> /dev/null ; echo $?) -eq 0 ] ) ; then DEVTOOLSET_DIR=/opt/rh/devtoolset if [ -d "${DEVTOOLSET_DIR}-2" ] ; then source ${DEVTOOLSET_DIR}-2/enable echo -e "\nEnabling GCC from the Red Hat Developer Toolset Distribution in ${DEVTOOLSET_DIR}-2" elif [ -d "${DEVTOOLSET_DIR}-3" ] ; then source ${DEVTOOLSET_DIR}-3/enable echo -e "\nEnabling GCC from the Red Hat Developer Toolset Distribution in ${DEVTOOLSET_DIR}-3" elif [ -d "${DEVTOOLSET_DIR}-4" ] ; then source ${DEVTOOLSET_DIR}-4/enable echo -e "\nEnabling GCC from the Red Hat Developer Toolset Distribution in ${DEVTOOLSET_DIR}-4" elif [ -d "${DEVTOOLSET_DIR}-5" ] ; then source ${DEVTOOLSET_DIR}-5/enable echo -e "\nEnabling GCC from the Red Hat Developer Toolset Distribution in ${DEVTOOLSET_DIR}-5" else echo -e "\nPlease upgrade your version of GCC or set your PATH to where a minimum 4.8 version of GCC is located.\n" exit 69 fi fi # else # echo -e "\nPlease upgrade your version of GCC or set your PATH to where a minimum 4.8 version of GCC is located.\n" # exit 69 fi fi # Function to configure, make and then install the Package - contains Package Specific build configuration func_configure_make_install () { cd ${WORK_DIR} if [ ! -e ALREADY_BUILT ] ; then if [ "$(type python &> /dev/null ; echo $?)" -eq 0 ] ; then python --version &> /tmp/PYTHONVERSIONTMP PYTHON_INSTALLED_VERSION=$(cat /tmp/PYTHONVERSIONTMP | awk ' { print $2 } ') PYTHON_INSTALLED_MAJOR_VERSION=$(echo ${PYTHON_INSTALLED_VERSION} | cut -d. -f1) PYTHON_INSTALLED_MINOR_VERSION=$(echo ${PYTHON_INSTALLED_VERSION} | cut -d. -f2) if ( [ "${PYTHON_INSTALLED_MAJOR_VERSION}" -eq "2" ] && [ "${PYTHON_INSTALLED_MINOR_VERSION}" -lt "7" ] ) ; then [ -e /opt/rh/python27/enable ] \ && source /opt/rh/python27/enable \ || echo -e "\nCannot find Python 2.7 or greater.\n" \ || exit 70 fi rm /tmp/PYTHONVERSIONTMP &> /dev/null fi func_create_thisroot if [ "${ARGUMENTS[1]}" == "-test" ] ; then TEST_STATUS=ON else TEST_STATUS=OFF fi mkdir BUILD cd BUILD cmake \ -DCMAKE_INSTALL_PREFIX=${OUTPUT_DIR} \ -Dgnuinstall=ON \ -DCMAKE_SKIP_RPATH=TRUE \ -DBUILD_TEST=${TEST_STATUS} \ ../ func_print_compiler_linker_flags gmake -j ${ACC_SET_GMAKE_JOBS} gmake install export RETVAL=$? [ "${RETVAL}" -eq 0 ] && cp ${WORK_DIR}/thisroot.sh ${OUTPUT_DIR}/bin fi if [ "${ARGUMENTS[1]}" == "-test" ] ; then echo -e "\nBuilding tests for `echo ${PACKAGE_VERSION}`...\n" echo -e "\nNo build-time tests found for ROOT.\n" export RETVAL=$? fi } func_create_thisroot () { # Create an ONLINE/OFFLINE aware "thisroot.sh" file cat <<\EOF > ${WORK_DIR}/thisroot.sh # Source this script to set up the ROOT build that this script is part of. # # Conveniently an alias like this can be defined in .bashrc: # alias thisroot=". bin/thisroot.sh" # # This script if for the bash like shells, see thisroot.csh for csh like shells. # # Author: Fons Rademakers, 18/8/2006 #ONLINE_ARCHIVE_BASE_DIR='/nfs/cesr/online/lib' #OFFLINE_ARCHIVE_BASE_DIR='/nfs/acc/libs' #case $(uname -n) in # cesr*) USE_CESR_ONLINE_LOC='true';; # *) USE_CESR_ONLINE_LOC='false';; #esac #if ( [ "${USE_CESR_ONLINE_LOC}" == "true" ] ) then # RELEASE_ARCHIVE_BASE_DIR=${ONLINE_ARCHIVE_BASE_DIR} #else # RELEASE_ARCHIVE_BASE_DIR=${OFFLINE_ARCHIVE_BASE_DIR} #fi drop_from_path() { # Assert that we got enough arguments if test $# -ne 2 ; then echo "drop_from_path: needs 2 arguments" return 1 fi p=$1 drop=$2 newpath=`echo $p | sed -e "s;:${drop}:;:;g" \ -e "s;:${drop};;g" \ -e "s;${drop}:;;g" \ -e "s;${drop};;g"` } if [ -n "${ROOTSYS}" ] ; then old_rootsys=${ROOTSYS} fi if [ "x${BASH_ARGV[0]}" = "x" ]; then if [ ! -f bin/thisroot.sh ]; then echo ERROR: must "cd where/root/is" before calling ". bin/thisroot.sh" for this version of bash! ROOTSYS=; export ROOTSYS return 1 fi ROOTSYS="$PWD"; export ROOTSYS else # get param to "." thisroot=$(dirname ${BASH_ARGV[0]}) ROOTSYS=$(cd ${thisroot}/..;pwd); export ROOTSYS fi if [ -n "${old_rootsys}" ] ; then if [ -n "${PATH}" ]; then drop_from_path $PATH ${old_rootsys}/bin PATH=$newpath fi if [ -n "${LD_LIBRARY_PATH}" ]; then drop_from_path $LD_LIBRARY_PATH ${old_rootsys}/lib LD_LIBRARY_PATH=$newpath fi if [ -n "${DYLD_LIBRARY_PATH}" ]; then drop_from_path $DYLD_LIBRARY_PATH ${old_rootsys}/lib DYLD_LIBRARY_PATH=$newpath fi if [ -n "${SHLIB_PATH}" ]; then drop_from_path $SHLIB_PATH ${old_rootsys}/lib SHLIB_PATH=$newpath fi if [ -n "${LIBPATH}" ]; then drop_from_path $LIBPATH ${old_rootsys}/lib LIBPATH=$newpath fi if [ -n "${PYTHONPATH}" ]; then drop_from_path $PYTHONPATH ${old_rootsys}/lib PYTHONPATH=$newpath fi if [ -n "${MANPATH}" ]; then drop_from_path $MANPATH ${old_rootsys}/man MANPATH=$newpath fi fi if [ -z "${MANPATH}" ]; then # Grab the default man path before setting the path to avoid duplicates if `which manpath > /dev/null 2>&1` ; then default_manpath=`manpath` else default_manpath=`man -w 2> /dev/null` fi fi if [ -z "${PATH}" ]; then PATH=${ACC_PKG}/root/../production/bin; export PATH else PATH=${ACC_PKG}/root/../production/bin:$PATH; export PATH fi if [ -z "${LD_LIBRARY_PATH}" ]; then LD_LIBRARY_PATH=${ACC_PKG}/root/../production/lib/root; export LD_LIBRARY_PATH # Linux, ELF HP-UX else LD_LIBRARY_PATH=${ACC_PKG}/root/../production/lib/root:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH fi if [ -z "${DYLD_LIBRARY_PATH}" ]; then DYLD_LIBRARY_PATH=${ACC_PKG}/root/../production/lib/root; export DYLD_LIBRARY_PATH # Mac OS X else DYLD_LIBRARY_PATH=${ACC_PKG}/root/../production/lib/root:$DYLD_LIBRARY_PATH; export DYLD_LIBRARY_PATH fi if [ -z "${SHLIB_PATH}" ]; then SHLIB_PATH=${ACC_PKG}/root/../production/lib/root; export SHLIB_PATH # legacy HP-UX else SHLIB_PATH=${ACC_PKG}/root/../production/lib/root:$SHLIB_PATH; export SHLIB_PATH fi if [ -z "${LIBPATH}" ]; then LIBPATH=${ACC_PKG}/root/../production/lib/root; export LIBPATH # AIX else LIBPATH=${ACC_PKG}/root/../production/lib/root:$LIBPATH; export LIBPATH fi if [ -z "${PYTHONPATH}" ]; then PYTHONPATH=${ACC_PKG}/root/../production/lib/root; export PYTHONPATH else PYTHONPATH=${ACC_PKG}/root/../production/lib/root:$PYTHONPATH; export PYTHONPATH fi if [ -z "${MANPATH}" ]; then MANPATH=`dirname ${ACC_PKG}/root/../production/share/man/man1`:${default_manpath}; export MANPATH else MANPATH=`dirname ${ACC_PKG}/root/../production/share/man/man1`:$MANPATH; export MANPATH fi if [ "x`root-config --arch | grep -v win32gcc | grep -i win32`" != "x" ]; then ROOTSYS="`cygpath -w $ROOTSYS`" fi unset old_rootsys unset thisroot EOF } # Function that contains Package Specific files and directories to be removed func_remove_package () { rm -rf ${OUTPUT_DIR}/include/root rm -f ${OUTPUT_DIR}/bin/root-config rm -f ${OUTPUT_DIR}/bin/memprobe rm -f ${OUTPUT_DIR}/bin/thisroot.* rm -f ${OUTPUT_DIR}/bin/setxrd.* rm -f ${OUTPUT_DIR}/bin/genreflex* rm -f ${OUTPUT_DIR}/bin/rmkdepend rm -f ${OUTPUT_DIR}/bin/proofserv* rm -f ${OUTPUT_DIR}/bin/root* rm -f ${OUTPUT_DIR}/bin/rlibmap rm -f ${OUTPUT_DIR}/bin/genmap rm -f ${OUTPUT_DIR}/bin/proofd rm -f ${OUTPUT_DIR}/bin/ssh2rpd rm -f ${OUTPUT_DIR}/bin/g2root rm -f ${OUTPUT_DIR}/bin/pq2 rm -f ${OUTPUT_DIR}/bin/xpdtest rm -f ${OUTPUT_DIR}/bin/hadd rm -f ${OUTPUT_DIR}/bin/h2root rm -f ${OUTPUT_DIR}/bin/setenvwrap.csh rm -f ${OUTPUT_DIR}/share/man/man1/root-config* rm -f ${OUTPUT_DIR}/share/man/man1/memprobe* rm -f ${OUTPUT_DIR}/share/man/man1/thisroot.* rm -f ${OUTPUT_DIR}/share/man/man1/setxrd.* rm -f ${OUTPUT_DIR}/share/man/man1/genreflex* rm -f ${OUTPUT_DIR}/share/man/man1/rmkdepend* rm -f ${OUTPUT_DIR}/share/man/man1/proofserv* rm -f ${OUTPUT_DIR}/share/man/man1/root* rm -f ${OUTPUT_DIR}/share/man/man1/rlibmap* rm -f ${OUTPUT_DIR}/share/man/man1/genmap* rm -f ${OUTPUT_DIR}/share/man/man1/proofd* rm -f ${OUTPUT_DIR}/share/man/man1/ssh2rpd* rm -f ${OUTPUT_DIR}/share/man/man1/g2root* rm -f ${OUTPUT_DIR}/share/man/man1/pq2* rm -f ${OUTPUT_DIR}/share/man/man1/xpdtest* rm -f ${OUTPUT_DIR}/share/man/man1/hadd* rm -f ${OUTPUT_DIR}/share/man/man1/h2root* rm -f ${OUTPUT_DIR}/share/man/man1/hist2workspace.1 rm -f ${OUTPUT_DIR}/share/man/man1/prepareHistFactory.1 rm -f ${OUTPUT_DIR}/share/man/man1/setup-pq2.1 rm -f ${OUTPUT_DIR}/share/man/man1/system.rootdaemonrc.1 rm -f ${OUTPUT_DIR}/share/man/man1/xproofd.1 rm -rf ${OUTPUT_DIR}/share/doc/root rm -rf ${OUTPUT_DIR}/share/root rm -rf ${OUTPUT_DIR}/share/aclocal/root* rm -rf ${OUTPUT_DIR}/share/emacs rm -rf ${OUTPUT_DIR}/lib/root rm -rf ${OUTPUT_DIR}/etc rm -rf ${BUILD_TYPE} }