Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:12

0001 #!/bin/bash
0002 #
0003 #  file:        install_qd.sh
0004 #  description: BASH script for the installation of the qd package,
0005 #               can be used standalone or called from other scripts
0006 #
0007 #  author:      Markus Merschmeyer, RWTH Aachen University
0008 #  date:        2013/05/23
0009 #  version:     1.0
0010 #
0011 
0012 print_help() {
0013     echo "" && \
0014     echo "install_qd version 1.0" && echo && \
0015     echo "options: -v  version    define qd version ( "${QDVER}" )" && \
0016     echo "         -d  path       define qd installation directory" && \
0017     echo "                         -> ( "${IDIR}" )" && \
0018     echo "         -W  location   (web)location of qd tarball ( "${QDWEBLOCATION}" )" && \
0019     echo "         -S  filename   file name of qd tarball ( "${QDFILE}" )" && \
0020     echo "         -C  level      cleaning level of SHERPA installation ( "${LVLCLEAN}" )" && \
0021     echo "                         -> 0: nothing, 1: +objects (make clean)" && \
0022     echo "         -D             debug flag, compile with '-g' option ( "${FLGDEBUG}" )" && \
0023     echo "         -X             create XML file for tool override in CMSSW ( "${FLGXMLFL}" )" && \
0024     echo "         -Z             use multiple CPU cores if available ( "${FLGMCORE}" )" && \
0025     echo "         -K             keep qd source code tree after installation ( "${FGLKEEPT}" )" && \
0026     echo "         -h             display this help and exit" && echo
0027 }
0028 
0029 
0030 # save current path
0031 HDIR=`pwd`
0032 
0033 
0034 # dummy setup (if all options are missing)
0035 IDIR="/tmp"                # installation directory
0036 QDVER="2.3.13"             # qd version to be installed
0037 QDWEBLOCATION=""           # (web)location of qd tarball
0038 QDFILE=""                  # file name of qd tarball
0039 LVLCLEAN=0                 # cleaning level (0-2)
0040 FLGDEBUG="FALSE"           # debug flag for compilation
0041 FLGXMLFL="FALSE"           # create XML tool definition file for SCRAM?
0042 FGLKEEPT="FALSE"           # keep the source code tree?
0043 FLGMCORE="FALSE"           # use multiple cores for compilation
0044 
0045 
0046 # get & evaluate options
0047 while getopts :v:d:W:S:C:DXZKh OPT
0048 do
0049   case $OPT in
0050   v) QDVER=$OPTARG ;;
0051   d) IDIR=$OPTARG ;;
0052   W) QDWEBLOCATION=$OPTARG ;;
0053   S) QDFILE=$OPTARG ;;
0054   C) LVLCLEAN=$OPTARG ;;
0055   D) FLGDEBUG=TRUE ;;
0056   X) FLGXMLFL=TRUE ;;
0057   Z) FLGMCORE=TRUE ;;
0058   K) FLGKEEPT=TRUE ;;
0059   h) print_help && exit 0 ;;
0060   \?)
0061     shift `expr $OPTIND - 1`
0062     if [ "$1" = "--help" ]; then print_help && exit 0;
0063     else 
0064       echo -n "install_qd: error: unrecognized option "
0065       if [ $OPTARG != "-" ]; then echo "'-$OPTARG'. try '-h'"
0066       else echo "'$1'. try '-h'"
0067       fi
0068       print_help && exit 1
0069     fi
0070 #    shift 1
0071 #    OPTIND=1
0072   esac
0073 done
0074 
0075 
0076 # set qd download location
0077 if [ "$QDWEBLOCATION" = "" ]; then
0078   QDWEBLOCATION="http://crd.lbl.gov/~dhbailey/mpdist"
0079 else
0080   if [ -e ${QDWEBLOCATION} ]; then   # is the location a local subdirectory?
0081     if [ -d ${QDWEBLOCATION} ]; then
0082       cd ${QDWEBLOCATION}; QDWEBLOCATION=`pwd`; cd ${HDIR}
0083     fi
0084   fi
0085 fi
0086 if [ "$QDFILE" = "" ]; then
0087   QDFILE="qd-${QDVER}.tar.gz"
0088 fi
0089 
0090 
0091 # make qd version a global variable
0092 export QDVER=${QDVER}
0093 # always use absolute path name...
0094 cd ${IDIR}; IDIR=`pwd`
0095 
0096 echo " qd installation: "
0097 echo "  -> qd version: '"${QDVER}"'"
0098 echo "  -> installation directory: '"${IDIR}"'"
0099 echo "  -> qd location: '"${QDWEBLOCATION}"'"
0100 echo "  -> qd file name: '"${QDFILE}"'"
0101 echo "  -> cleaning level: '"${LVLCLEAN}"'"
0102 echo "  -> debugging mode: '"${FLGDEBUG}"'"
0103 echo "  -> CMSSW override: '"${FLGXMLFL}"'"
0104 echo "  -> keep sources:   '"${FLGKEEPT}"'"
0105 echo "  -> use multiple CPU cores: '"${FLGMCORE}"'"
0106 
0107 
0108 
0109 # set path to local HEPMC2 installation
0110 export QDDIR=${IDIR}"/qd-"${QDVER}
0111 export QDIDIR=${IDIR}"/QD_"${QDVER}
0112 
0113 
0114 # add compiler & linker flags
0115 echo "CXX      (old):  "$CXX
0116 echo "CXXFLAGS (old):  "$CXXFLAGS
0117 echo "LDFLAGS  (old):  "$LDFLAGS
0118 ##MM FIXME
0119 #  export CXX=""
0120 #  export CXXFLAGS=""
0121 #  export LDFLAGS=""
0122 ##MM FIXME
0123 if [ "$FLGDEBUG" = "TRUE" ]; then
0124   CFDEBUG="-g"
0125   export CXXFLAGS=${CXXFLAGS}" "${CFDEBUG}
0126 fi
0127 echo "CXX      (new):  "$CXX
0128 echo "CXXFLAGS (new):  "$CXXFLAGS
0129 echo "LDFLAGS  (new):  "$LDFLAGS
0130 
0131 # add compiler & linker flags
0132 COPTS="--enable-shared"
0133 MOPTS=""
0134 POPTS=""
0135 if [ "$FLGMCORE" = "TRUE" ]; then
0136     nprc=`cat /proc/cpuinfo | grep  -c processor`
0137     let nprc=$nprc
0138     if [ $nprc -gt 1 ]; then
0139       echo " <I> multiple CPU cores detected: "$nprc
0140       POPTS=" -j"$nprc" "
0141     fi
0142 fi
0143 
0144 
0145 # download, extract compile/install qd
0146 cd ${IDIR}
0147 if [ ! -d ${QDIDIR} ]; then
0148   if [ `echo ${QDWEBLOCATION} | grep -c "http:"` -gt 0 ]; then
0149     echo " -> downloading qd "${QDVER}" from "${QDWEBLOCATION}/${QDFILE}
0150     wget ${QDWEBLOCATION}/${QDFILE}
0151   elif [ `echo ${QDWEBLOCATION} | grep -c "srm:"` -gt 0 ]; then
0152     echo " -> srm-copying qd "${QDVER}" from "${QDWEBLOCATION}/${QDFILE}
0153     srmcp ${QDWEBLOCATION}/${QDFILE} file:////${QDFILE}
0154   else
0155     echo " -> copying qd "${QDVER}" from "${QDWEBLOCATION}/${QDFILE}
0156     cp ${QDWEBLOCATION}/${QDFILE} ./
0157   fi
0158   tar -xzf ${QDFILE}
0159   if [ ! "$FLGKEEPT" = "TRUE" ]; then
0160     rm ${QDFILE}
0161   fi
0162   cd ${QDDIR}
0163 #  if [ ! -e configure ]; then
0164 #    ./bootstrap
0165 #  fi
0166 
0167   echo " -> configuring qd with options "${COPTS} && \
0168   ./configure --prefix=${QDIDIR} ${momflag} ${lenflag} ${COPTS} && \
0169   echo " -> making qd with options "${POPTS} ${MOPTS} && \
0170   make ${POPTS} ${MOPTS} && \
0171   echo " -> installing qd with options "${MOPTS} && \
0172   make install ${MOPTS}
0173   if [ ${LVLCLEAN} -gt 0 ]; then 
0174     echo " -> cleaning up qd installation, level: "${LVLCLEAN}" ..."
0175     if [ ${LVLCLEAN} -ge 1 ]; then  # normal cleanup (objects)
0176       make clean
0177     fi
0178   fi
0179   cd ${HDIR}
0180   if [ "$FLGKEEPT" = "TRUE" ]; then
0181     echo "-> keeping source code..."
0182   else
0183     rm -rf ${QDDIR}
0184   fi
0185 else
0186   echo " <W> path exists => using already installed qd"
0187 fi
0188 export QDDIR=${QDIDIR}
0189 cd ${HDIR}
0190 
0191 
0192 # create XML file fro SCRAM
0193 if [ "${FLGXMLFL}" = "TRUE" ]; then
0194   xmlfile="qd_"${QDVER}".xml"
0195   echo " <I>"
0196   echo " <I> creating qd tool definition XML file"
0197   if [ -e ${xmlfile} ]; then rm ${xmlfile}; fi; touch ${xmlfile}
0198   echo "  <tool name=\"qd\" version=\""${QDVER}"\">" >> ${xmlfile}
0199   tmppath=`find ${QDDIR} -type f -name libqd.so\*`
0200 #
0201         echo "QDDIR: "$QDDIR
0202         echo "TMPPATH: "$tmppath
0203 #
0204   tmpcnt=`echo ${tmppath} | grep -o "/" | grep -c "/"`
0205   tmppath=`echo ${tmppath} | cut -f 1-${tmpcnt} -d "/"`
0206   for LIB in `cd ${tmppath}; ls *.so | cut -f 1 -d "." | sed -e 's/lib//'; cd ${HDIR}`; do
0207     echo "    <lib name=\""${LIB}"\"/>" >> ${xmlfile}
0208   done
0209   echo "    <client>" >> ${xmlfile}
0210   echo "      <Environment name=\"QD_BASE\" value=\""${QDDIR}"\"/>" >> ${xmlfile}
0211   echo "      <Environment name=\"LIBDIR\" default=\"\$QD_BASE/lib\"/>" >> ${xmlfile}
0212   echo "      <Environment name=\"INCLUDE\" default=\"\$QD_BASE/include\"/>" >> ${xmlfile}
0213   echo "    </client>" >> ${xmlfile}
0214 #  echo "    <runtime name=\"CMSSW_FWLITE_INCLUDE_PATH\" value=\"\$QD_BASE/include\" type=\"path\"/>" >> ${xmlfile}
0215 #  echo "    <use name=\"CLHEP\"/>" >> ${xmlfile}
0216   echo "  </tool>" >> ${xmlfile}
0217   if [ ! "$PWD" = "${HDIR}" ]; then
0218     mv ${xmlfile} ${HDIR}/
0219   fi
0220 
0221   if [ ! "$CMSSW_BASE" = "" ]; then
0222     cd $CMSSW_BASE
0223     tmpqd=`scramv1 tool info qd | grep "QD_BASE" | cut -f2 -d"="`
0224     tmpxml=`find $CMSSW_BASE/config -type f -name qd.xml -printf %h`
0225     echo " <I>"
0226     echo " <I> qd version currently being used: "${tmpqd}
0227     echo " <I> ...defined in "${tmpxml}
0228     cd ${tmpxml}; tmpxml=$PWD; cd ${HDIR}
0229     echo " <I>"
0230     echo " <I> If you want to override this version with the freshly produced "${xmlfile}","
0231     echo " <I> ...please type the following commands:"
0232     echo " <I>"
0233     echo "       cd $CMSSW_BASE"
0234     echo "       scramv1 tool remove qd"
0235     echo "       cp ${HDIR}/${xmlfile} ${tmpxml}/"
0236     echo "       scramv1 setup qd"
0237     echo "       cd -"
0238     echo " <I>"
0239   fi
0240 
0241 fi
0242 
0243 
0244 echo " -> qd installation directory is: "
0245 echo "  "${QDIDIR}