#! /usr/bin/env bash echo "Note that this script is very stupid: you have to edit it to choose different generators!" echo "Please try the official Genser bootstrap script if you have trouble:" echo " http://lcgapp.cern.ch/project/simu/generator/genser-bootstrap.html" echo ## Specify the LCG tag here explicitly, rather than trying to calculate it #LCGTAG=x86_64-Linux-gcc44-opt ## Version numbers #PY6VERSIONS="414.2 415.2 416.2 418.2 419.2 420.2 421.2 422.2 423.2" PY6VERSIONS="423.2" JMVERSION=4.31.3 HWVERSION=6.510.3 CHVERSION=1.003 PY8VERSION=135 ALPVERSION=2.1.3d.2 ## Disable certain gen builds BUILD_PYTHIA="yes" BUILD_HERWIG="yes" BUILD_JIMMY="yes" BUILD_CHARYBDIS="no" BUILD_PYTHIA8="no" BUILD_ALPGEN="yes" BUILD_SHERPA="no" BUILD_HERWIGPP="no" ## Pass options to "make" here MAKE="make -j2" ## Genser online distribution area GENSER_HTTP_DBN=http://service-spi.web.cern.ch/service-spi/external/MCGenerators/distribution ## Should we apply nasty hacks to make the Genser packages work? ## Set to 0 to see whether or not Genser's packages have been fixed. USE_HACKS="yes" ########################################## if [[ -z "$LCGTAG" ]]; then os=UNKNOWN distribution=`uname` if `echo $distribution | grep -i "Linux" &> /dev/null`; then os=LINUX; fi if test -e "/etc/redhat-release"; then distribution="redhat" sltest=`cat /etc/redhat-release | grep "Scientific Linux" 2> /dev/null` if test -n "$sltest"; then os=SLC sl_version=`cat /etc/redhat-release | cut -f5 -d" "` sl_major=`echo $sl_version | cut -f1 -d.` distribution="slc${sl_major}" fi fi ## Test for Mac OS X SW_VERS=`which sw_vers` if test -x "$SWVERS"; then os=OSX osx_version=`sw_vers -productVersion | cut -f1,2 -d.` osx_major=`echo $osx_version | cut -f1 -d.` osx_minor=`echo $osx_version | cut -f2 -d.` distribution="mac$osx_major$osx_minor" fi ## TODO: deal with Windows ;( ## Get architecture machine=`uname -m` ## Get compiler and version if test "$os" != "WINDOWS"; then if test -z "$CXX"; then CXX=`which g++` fi if test -x "$CXX"; then gcc_version=`$CXX --version | head -1 | cut -d" " -f3` gcc_major=`echo $gcc_version | cut -d. -f1` gcc_minor=`echo $gcc_version | cut -d. -f2` gcc_micro=`echo $gcc_version | cut -d. -f3` gcc_code="gcc${gcc_major}${gcc_minor}" compiler_code="$gcc_code" else compiler_code="gccXX" fi else ## Try to find VC version... somehow! #import distutils.msvccompiler as msvc #vcversions = sorted(msvc.get_devstudio_versions()) #vcversion = vcversions[0] compiler_code="vc" #%s" % vcversion fi ## The "future-proof" platform tag LCGPLATFORM="${machine}-${distribution}-${compiler_code}-opt" if test "$historical" = "yes"; then ## Different arch codes machine="ia32" if test `echo $machine | grep 64 &> /dev/null`; then machine="amd64"; fi ## Historical exceptions for GCC version if test "$compiler_code" = "gcc32" -a "$compiler_code" = "gcc40"; then compiler_code="$compiler_code$gcc_micro" fi LCGPLATFORM="${distribution}_${machine}_${compiler_code}" fi LCGTAG="$LCGPLATFORM" fi echo "Using LCG platform tag = $LCGTAG" ########################################## function wget-untargz() { majorname=$1 minorname=$2 dirname="$majorname/$minorname" tarname="$majorname-$minorname-src.tgz" if [[ ! -d "$dirname" ]]; then echo "Getting $majorname $minorname" ## Try first using wget, and falling back to trying curl (for Mac) WGETTER="wget --quiet -O-" if test ! -x "`which wget 2> /dev/null`"; then WGETTER="curl --silent" if test ! -x "`which curl 2> /dev/null`"; then echo "You need curl or wget to download the $tarname tarball" 1>&2 exit 1 fi fi ## Use whichever was present $WGETTER $GENSER_HTTP_DBN/$tarname | tar xz fi } ##################################### ## Identify directory to return to after building each generator BUILDHOME=$PWD ARCHIVEDIR=$BUILDHOME/downloads mkdir -p $ARCHIVEDIR ##################################### ## Download generators cd $ARCHIVEDIR ## Pythia 6 if [[ "$BUILD_PYTHIA" == "yes" ]]; then for v in $PY6VERSIONS; do wget-untargz pythia6 $v done fi ## Herwig if [[ "$BUILD_HERWIG" == "yes" ]]; then wget-untargz herwig $HWVERSION ## Jimmy if [[ "$BUILD_JIMMY" == "yes" ]]; then wget-untargz jimmy $JMVERSION fi fi ## alpgen if [[ "$BUILD_ALPGEN" == "yes" ]]; then wget-untargz alpgen $ALPVERSION fi ## Charybdis if [[ "$BUILD_CHARYBDIS" == "yes" ]]; then wget-untargz charybdis $CHVERSION fi ## Pythia 8 if [[ "$BUILD_PYTHIA8" == "yes" ]]; then wget-untargz pythia8 $PY8VERSION fi ## SHERPA # ## Herwig++ # ################################# ## Build Fortran Herwig and Pythia generators cd $BUILDHOME fgens="" if [[ "$BUILD_PYTHIA" == "yes" ]]; then fgens="$fgens $ARCHIVEDIR/pythia6/*" fi if [[ "$BUILD_HERWIG" == "yes" ]]; then fgens="$fgens $ARCHIVEDIR/herwig/*" fi for fgen in $fgens; do GENVERSION=`basename $fgen` GENNAME=`basename $(dirname $fgen)` if [[ ! -d "$fgen" ]]; then continue fi if [[ -d $GENNAME/$GENVERSION ]]; then echo "$GENNAME/$GENVERSION already exists in build area... skipping" continue fi ## Copy gen source into new directory structure rm -rf _TMP cp -r $fgen _TMP if test "$USE_HACKS" == "yes"; then cd _TMP ## If this is Herwig, symlink in a lower case version of ## the HERWIG65.INC header if [[ -e include/HERWIG65.INC ]]; then (cd include && ln -sf HERWIG65.INC herwig65.inc) fi ## Remove incorrect use of C++ compiler to build Fortran ## Pythia and Herwig shared libraries if [[ -e Makeshared.subdir ]]; then sed -i -e s/'\$(CXX)'/'\$(FC)'/ Makeshared.subdir fi ## Edit the Makefiles if we are on Mac OS X to replace .so ## with .dylib and use appropriate linker options if test x$(uname) == "xDarwin"; then sed -i -e s/'\.so'/'\.dylib'/g Makefile sed -i -e s/'\.so'/'\.dylib'/g configure sed -i -e s/'-shared'/'-dynamiclib -flat_namespace -undefined dynamic_lookup -single_module'/g Makeshared.subdir sed -i -e "s/-Wl,-soname,\$(notdir \$\@)/ /g" Makeshared.subdir osxversion=$(sw_vers -productVersion | cut -d . -f 2) osxtarget="10.${osxversion}" export MACOSX_DEPLOYMENT_TARGET=$osxtarget if test ! -x "`which g77 2> /dev/null`"; then if test ! -x "`which gfortran 2>/dev/null`"; then echo "Could not find a fortran compiler" exit 1 fi sed -i -e "s/g77/gfortran/g" configure sed -i -e "s/f77/gfortran/g" configure sed -i -e "s/lfrtbegin/lgfortranbegin/g" configure sed -i -e "s/lg2c/lgfortran/g" configure fi fi fi cd $BUILDHOME ## Make hacked "share" and platform-specific copies mkdir -p $GENNAME/$GENVERSION cp -r _TMP $GENNAME/$GENVERSION/share mv _TMP $GENNAME/$GENVERSION/$LCGTAG cd $GENNAME/$GENVERSION/$LCGTAG if test "$USE_HACKS" == "yes"; then ## HERWIG home-made configure script needs this variable to be set! Argh! export MCGENERATORS=$BUILDHOME ## Genser configure breaks with strict sh interpreter (bash ./configure --enable-shared --with-hepevt=4000 --prefix=$PWD && $MAKE && $MAKE install) || true else (./configure --enable-shared --with-hepevt=4000 --prefix=$PWD && $MAKE && $MAKE install) || true fi if [[ -n $(echo $GENVERSION | grep "ac") ]]; then cd $BUILDHOME/$GENNAME ln -s $GENVERSION ${GENVERSION/.ac/} fi cd $BUILDHOME done ## Herwig version symlink if [[ -d herwig/$HWVERSION ]]; then cd herwig ln -sf $HWVERSION 6510 fi ##################################### ## Jimmy (for FHerwig) cd $BUILDHOME if [[ "$BUILD_JIMMY" == "yes" ]]; then if [[ -d $ARCHIVEDIR/jimmy/$JMVERSION && -d $ARCHIVEDIR/herwig/$HWVERSION ]]; then rm -rf _TMP if [[ -d jimmy/$JMVERSION ]]; then echo "jimmy/$JMVERSION already exists in build area... skipping" else rm -rf _TMP cp -r downloads/jimmy/$JMVERSION/ _TMP/ if test "$USE_HACKS" == "yes"; then cd _TMP if test x$(uname) == "xDarwin"; then sed -i -e s/'\.so'/'\.dylib'/g configure sed -i -e s/'\.so'/'\.dylib'/g src/Makefile sed -i -e s/'-shared'/'-dynamiclib -flat_namespace -undefined dynamic_lookup -single_module'/g src/Makefile sed -i -e "s/-Wl,-soname,\$(notdir \$\@)/ /g" src/Makefile osxversion=$(sw_vers -productVersion | cut -d . -f 2) osxtarget="10.${osxversion}" export MACOSX_DEPLOYMENT_TARGET=$osxtarget if test ! -x "`which g77 2> /dev/null`"; then if test ! -x "`which gfortran 2>/dev/null`"; then echo "Could not find a fortran compiler" exit 1 fi sed -i -e "s/g77/gfortran/g" configure sed -i -e "s/f77/gfortran/g" configure sed -i -e "s/-Wno-globals//g" configure sed -i -e "s/lfrtbegin/lgfortranbegin/g" configure sed -i -e "s/lg2c/lgfortran/g" configure fi fi fi cd $BUILDHOME mkdir -p jimmy/$JMVERSION cp -r _TMP jimmy/$JMVERSION/share mv _TMP jimmy/$JMVERSION/$LCGTAG cd jimmy ln -sf $JMVERSION 431 cd $JMVERSION/$LCGTAG echo "Building Jimmy" if test "$USE_HACKS" == "yes"; then bash ./configure --with-hepevt=4000 --with-herwig=$BUILDHOME/herwig/$HWVERSION/$LCGTAG && $MAKE else ./configure --with-hepevt=4000 --with-herwig=$BUILDHOME/herwig/$HWVERSION/$LCGTAG && $MAKE fi fi fi fi ##################################### ## Charybdis cd $BUILDHOME if [[ "$BUILD_CHARYBDIS" == "yes" ]]; then rm -rf _TMP if [[ -d $ARCHIVEDIR/charybdis/$CHVERSION ]]; then cp -r $ARCHIVEDIR/charybdis/$CHVERSION _TMP ## Build Pythia version if [[ -d charybdis/$CHVERSION ]]; then echo "charybdis/$CHVERSION already exists in build area... skipping" else #if [[ -d $BUILDHOME/pythia6/$PYVERSION ]]; then mkdir -p charybdis/$CHVERSION cp -r _TMP charybdis/$CHVERSION/share cp -r _TMP charybdis/$CHVERSION/$LCGTAG cd charybdis/$CHVERSION/$LCGTAG ./configure --pythia_hadronization && $MAKE fi ## Build Herwig version cd $BUILDHOME if [[ -d charybdis/${CHVERSION}h ]]; then echo "charybdis/${CHVERSION}h already exists in build area... skipping" else #if [[ -d $BUILDHOME/herwig/$HWVERSION ]]; then mkdir -p charybdis/${CHVERSION}h cp -r _TMP charybdis/${CHVERSION}h/share cp -r _TMP charybdis/${CHVERSION}h/$LCGTAG cd charybdis/${CHVERSION}h/$LCGTAG cp $BUILDHOME/herwig/$HWVERSION/share/include/herwig6510.inc include/ cp $BUILDHOME/herwig/$HWVERSION/share/include/HERWIG65.INC include/ ./configure && $MAKE fi fi fi ##################################### ## AlpGen if [[ "$BUILD_ALPGEN" == "yes" ]]; then rm -rf _TMP if [[ -d $ARCHIVEDIR/alpgen/$ALPVERSION ]]; then if [[ -d alpgen/$ALPVERSION ]]; then echo "alpgen/$ALPVERSION already exists in build area... skipping" else #if [[ -d $BUILDHOME/pythia6/$PYVERSION ]]; then cp -r $ARCHIVEDIR/alpgen/$ALPVERSION _TMP mkdir -p alpgen/$ALPVERSION cp -r _TMP alpgen/$ALPVERSION/share mv _TMP alpgen/$ALPVERSION/$LCGTAG echo alpgen/$ALPVERSION/$LCGTAG cd alpgen/$ALPVERSION/$LCGTAG ./configure --enable-shared --with-hepevt=4000 --with-pythia6=/rooms/bar/manchester/ghesketh/rivet/genser/pythia6/423.2/i686-slcrelease-gcc34-opt/ --with-herwig=/rooms/bar/manchester/ghesketh/rivet/genser/herwig/6510/i686-slcrelease-gcc34-opt/ && $MAKE fi fi fi ##################################### ## Sherpa #if [[ "$BUILD_SHERPA" == "yes" ]]; then #echo "Getting Sherpa 1.1.2" #wget-untargz sherpa 1.1.2 #fi ##################################### ## Pythia 8 cd $BUILDHOME if [[ "$BUILD_PYTHIA8" == "yes" ]]; then rm -rf _TMP if [[ -d $ARCHIVEDIR/pythia8/$PY8VERSION ]]; then if [[ -d pythia8/$PY8VERSION ]]; then echo "pythia8/$PY8VERSION already exists in build area... skipping" else cp -r $ARCHIVEDIR/pythia8/$PY8VERSION _TMP if test "$USE_HACKS" == "yes"; then if test x$(uname) == "xDarwin"; then sed -i -e s/'-shared'/'-dynamiclib -flat_namespace -undefined dynamic_lookup -single_module'/g Makefile sed -i -e "s/-Wl,-soname,\$(notdir \$\@)/ /g" Makefile sed -i -e s/'\.so'/'\.dylib'/g Makefile osxversion=$(sw_vers -productVersion | cut -d . -f 2) osxtarget="10.${osxversion}" export MACOSX_DEPLOYMENT_TARGET=$osxtarget if test ! -x "`which g77 2> /dev/null`"; then if test ! -x "`which gfortran 2>/dev/null`"; then echo "Could not find a fortran compiler" exit 1 fi sed -i -e "s/g77/gfortran/g" configure sed -i -e "s/f77/gfortran/g" configure sed -i -e "s/lfrtbegin/lgfortranbegin/g" configure sed -i -e "s/lg2c/lgfortran/g" configure fi fi fi mkdir -p pythia8/$PY8VERSION cp -r _TMP pythia8/$PY8VERSION/share mv _TMP pythia8/$PY8VERSION/$LCGTAG cd pythia8/$PY8VERSION/$LCGTAG ./configure --enable-shared && $MAKE fi fi fi cd $BUILDHOME ##################################### ## ThePEG and Herwig++ #echo "Getting ThePEG 1.6.1" #wget-untargz thepeg 1.6.1 #echo "Getting Herwig++ 2.4.2" #wget-untargz herwig++ 2.4.2 #cd $BUILDHOME ##################################### echo echo echo "Done! You'll want to add the Genser root path" echo "$BUILDHOME" echo "to your \$AGILE_GEN_PATH environment variable so that" echo "you can use agile-runmc with your new Genser area."