File indexing completed on 2024-04-06 12:14:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 print_help() {
0013 echo "" && \
0014 echo "install_hepmc2 version 3.0" && echo && \
0015 echo "options: -v version define HepMC2 version ( "${HEPMC2VER}" )" && \
0016 echo " -d path define HepMC2 installation directory" && \
0017 echo " -> ( "${IDIR}" )" && \
0018 echo " -W location (web)location of HepMC2 tarball ( "${HEPMC2WEBLOCATION}" )" && \
0019 echo " -S filename file name of HepMC2 tarball ( "${HEPMC2FILE}" )" && \
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 HEPMC2 source code tree after installation ( "${FLGKEEPT}" )" && \
0026 echo " -h display this help and exit" && echo
0027 }
0028
0029
0030
0031 HDIR=`pwd`
0032
0033
0034
0035 IDIR="/tmp"
0036 HEPMC2VER="2.03.06"
0037 HEPMC2WEBLOCATION=""
0038 HEPMC2FILE=""
0039 LVLCLEAN=0
0040 FLGDEBUG="FALSE"
0041 FLGXMLFL="FALSE"
0042 FLGKEEPT="FALSE"
0043 FLGMCORE="FALSE"
0044
0045
0046
0047 while getopts :v:d:W:S:C:DXZKh OPT
0048 do
0049 case $OPT in
0050 v) HEPMC2VER=$OPTARG ;;
0051 d) IDIR=$OPTARG ;;
0052 W) HEPMC2WEBLOCATION=$OPTARG ;;
0053 S) HEPMC2FILE=$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_hepmc2: 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
0071
0072 esac
0073 done
0074
0075
0076
0077 if [ "$HEPMC2WEBLOCATION" = "" ]; then
0078 HEPMC2WEBLOCATION="http://lcgapp.cern.ch/project/simu/HepMC/download"
0079 else
0080 if [ -e ${HEPMC2WEBLOCATION} ]; then
0081 if [ -d ${HEPMC2WEBLOCATION} ]; then
0082 cd ${HEPMC2WEBLOCATION}; HEPMC2WEBLOCATION=`pwd`; cd ${HDIR}
0083 fi
0084 fi
0085 fi
0086 if [ "$HEPMC2FILE" = "" ]; then
0087 HEPMC2FILE="HepMC-"${HEPMC2VER}".tar.gz"
0088 fi
0089
0090
0091
0092 export HEPMC2VER=${HEPMC2VER}
0093
0094 cd ${IDIR}; IDIR=`pwd`
0095
0096 echo " HepMC2 installation: "
0097 echo " -> HepMC2 version: '"${HEPMC2VER}"'"
0098 echo " -> installation directory: '"${IDIR}"'"
0099 echo " -> HepMC2 location: '"${HEPMC2WEBLOCATION}"'"
0100 echo " -> HepMC2 file name: '"${HEPMC2FILE}"'"
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 va=`echo ${HEPMC2VER} | cut -f1 -d"."`
0109 vb=`echo ${HEPMC2VER} | cut -f2 -d"."`
0110 vc=`echo ${HEPMC2VER} | cut -f3 -d"."`
0111
0112 if [ $va -ge 2 ] && [ $vb -ge 4 ]; then
0113
0114 momflag="--with-momentum=GEV"
0115 lenflag="--with-length=CM"
0116
0117 else
0118 momflag=""
0119 lenflag=""
0120 fi
0121
0122
0123
0124
0125 export HEPMC2DIR=${IDIR}"/HepMC-"${HEPMC2VER}
0126 export HEPMC2IDIR=${IDIR}"/HEPMC_"${HEPMC2VER}
0127
0128
0129
0130 echo "CXX (old): "$CXX
0131 echo "CXXFLAGS (old): "$CXXFLAGS
0132 echo "LDFLAGS (old): "$LDFLAGS
0133
0134
0135
0136
0137
0138 if [ "$FLGDEBUG" = "TRUE" ]; then
0139 CFDEBUG="-g"
0140 export CXXFLAGS=${CXXFLAGS}" "${CFDEBUG}
0141 fi
0142 echo "CXX (new): "$CXX
0143 echo "CXXFLAGS (new): "$CXXFLAGS
0144 echo "LDFLAGS (new): "$LDFLAGS
0145
0146
0147 COPTS=""
0148 MOPTS=""
0149 POPTS=""
0150 if [ "$FLGMCORE" = "TRUE" ]; then
0151 nprc=`cat /proc/cpuinfo | grep -c processor`
0152 let nprc=$nprc
0153 if [ $nprc -gt 1 ]; then
0154 echo " <I> multiple CPU cores detected: "$nprc
0155 POPTS=" -j"$nprc" "
0156 fi
0157 fi
0158
0159
0160
0161 cd ${IDIR}
0162
0163 if [ ! -d ${HEPMC2IDIR} ]; then
0164 if [ `echo ${HEPMC2WEBLOCATION} | grep -c "http:"` -gt 0 ]; then
0165 echo " -> downloading HepMC2 "${HEPMC2VER}" from "${HEPMC2WEBLOCATION}/${HEPMC2FILE}
0166 wget ${HEPMC2WEBLOCATION}/${HEPMC2FILE}
0167 elif [ `echo ${HEPMC2WEBLOCATION} | grep -c "srm:"` -gt 0 ]; then
0168 echo " -> srm-copying HepMC2 "${HEPMC2VER}" from "${HEPMC2WEBLOCATION}/${HEPMC2FILE}
0169 srmcp ${HEPMC2WEBLOCATION}/${HEPMC2FILE} file:////${HEPMC2FILE}
0170 else
0171 echo " -> copying HepMC2 "${HEPMC2VER}" from "${HEPMC2WEBLOCATION}/${HEPMC2FILE}
0172 cp ${HEPMC2WEBLOCATION}/${HEPMC2FILE} ./
0173 fi
0174 tar -xzf ${HEPMC2FILE}
0175 if [ ! "$FLGKEEPT" = "TRUE" ]; then
0176 rm ${HEPMC2FILE}
0177 fi
0178 cd ${HEPMC2DIR}
0179 if [ ! -e configure ]; then
0180 ./bootstrap
0181 fi
0182
0183 echo " -> configuring HepMC2 with options "${COPTS} && \
0184 ./configure --prefix=${HEPMC2IDIR} ${momflag} ${lenflag} ${COPTS} && \
0185 echo " -> making HepMC2 with options "${POPTS} ${MOPTS} && \
0186 make ${POPTS} ${MOPTS} && \
0187 echo " -> installing HepMC2 with options "${MOPTS} && \
0188 make install ${MOPTS}
0189 if [ ${LVLCLEAN} -gt 0 ]; then
0190 echo " -> cleaning up HEPMC2 installation, level: "${LVLCLEAN}" ..."
0191 if [ ${LVLCLEAN} -ge 1 ]; then
0192 make clean
0193 fi
0194 fi
0195 cd ${HDIR}
0196 if [ "$FLGKEEPT" = "TRUE" ]; then
0197 echo "-> keeping source code..."
0198 else
0199 rm -rf ${HEPMC2DIR}
0200 fi
0201 else
0202 echo " <W> path exists => using already installed HepMC2"
0203 fi
0204 export HEPMC2DIR=${HEPMC2IDIR}
0205 cd ${HDIR}
0206
0207
0208
0209 if [ "${FLGXMLFL}" = "TRUE" ]; then
0210
0211 xmlfile="hepmc_"${HEPMC2VER}".xml"
0212 echo " <I>"
0213 echo " <I> creating HepMC tool definition XML file"
0214 if [ -e ${xmlfile} ]; then rm ${xmlfile}; fi; touch ${xmlfile}
0215 echo " <tool name=\"HepMC\" version=\""${HEPMC2VER}"\">" >> ${xmlfile}
0216 tmppath=`find ${HEPMC2DIR} -type f -name libHepMC.so\*`
0217 tmpcnt=`echo ${tmppath} | grep -o "/" | grep -c "/"`
0218 tmppath=`echo ${tmppath} | cut -f 1-${tmpcnt} -d "/"`
0219 for LIB in `cd ${tmppath}; ls *.so | cut -f 1 -d "." | sed -e 's/lib//'; cd ${HDIR}`; do
0220 echo " <lib name=\""${LIB}"\"/>" >> ${xmlfile}
0221 done
0222 echo " <client>" >> ${xmlfile}
0223 echo " <Environment name=\"HEPMC_BASE\" value=\""${HEPMC2DIR}"\"/>" >> ${xmlfile}
0224 echo " <Environment name=\"LIBDIR\" default=\"\$HEPMC_BASE/lib\"/>" >> ${xmlfile}
0225 echo " <Environment name=\"INCLUDE\" default=\"\$HEPMC_BASE/include\"/>" >> ${xmlfile}
0226 echo " </client>" >> ${xmlfile}
0227 echo " <runtime name=\"CMSSW_FWLITE_INCLUDE_PATH\" value=\"\$HEPMC_BASE/include\" type=\"path\"/>" >> ${xmlfile}
0228 echo " <use name=\"CLHEP\"/>" >> ${xmlfile}
0229 echo " </tool>" >> ${xmlfile}
0230 if [ ! "$PWD" = "${HDIR}" ]; then
0231 mv ${xmlfile} ${HDIR}/
0232 fi
0233
0234 if [ ! "$CMSSW_BASE" = "" ]; then
0235 cd $CMSSW_BASE
0236 tmphmc=`scramv1 tool info hepmc | grep "HEPMC_BASE" | cut -f2 -d"="`
0237 tmpxml=`find $CMSSW_BASE/config -type f -name hepmc.xml -printf %h`
0238 echo " <I>"
0239 echo " <I> HEPMC version currently being used: "${tmphmc}
0240 echo " <I> ...defined in "${tmpxml}
0241 cd ${tmpxml}; tmpxml=$PWD; cd ${HDIR}
0242 echo " <I>"
0243 echo " <I> If you want to override this version with the freshly produced "${xmlfile}","
0244 echo " <I> ...please type the following commands:"
0245 echo " <I>"
0246 echo " cd $CMSSW_BASE"
0247 echo " scramv1 tool remove hepmc"
0248 echo " cp ${HDIR}/${xmlfile} ${tmpxml}/"
0249 echo " scramv1 setup hepmc"
0250 echo " cd -"
0251 echo " <I>"
0252 fi
0253
0254 fi
0255
0256
0257 echo " -> HEPMC2 installation directory is: "
0258 echo " "${HEPMC2IDIR}