PageRenderTime 52ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/test/compile-standalone.sh

https://github.com/amarini/HiggsAnalysis-CombinedLimit
Shell | 82 lines | 57 code | 9 blank | 16 comment | 24 complexity | 18ba750d57231c12b71ee51dc7abdf1a MD5 | raw file
  1. #!/bin/bash
  2. ## This script allows to compile the program as standalone, taking ROOT and BOOST from CERN AFS
  3. ## It also takes python 2.6 from /usr/bin/python2.6 in case your default python is 2.4 like in SLC5
  4. ## It is meant only for DEBUGGING and TESTING, and it is NOT supported.
  5. ##
  6. ## Usage:
  7. ## - if necessary, fix the paths to BOOST, GCC, ROOT
  8. ## - go under HiggsAnalysis/CombinedLimit, and
  9. ## - if necessary, clean up a previous build with
  10. ## ./test/compile-standalone.sh clean
  11. ## - if necessary, compile the program
  12. ## ./test/compile-standalone.sh make
  13. ## - setup your environment
  14. ## eval $(./test/compile-standalone.sh env)
  15. ## - now you can run the program
  16. if [[ "$1" == "" ]]; then echo "$0 (clean | make |env)"; exit 1; fi;
  17. BASEDIR="$( cd "$( dirname "$0" )"/../../.. && pwd )"
  18. BOOST=/afs/cern.ch/cms/slc5_amd64_gcc434/external/boost/1.42.0-cms
  19. MYGCC=/afs/cern.ch/sw/lcg/external/gcc/4.3.2/x86_64-slc5/setup.sh
  20. MYROOT=/afs/cern.ch/sw/lcg/app/releases/ROOT/5.28.00/x86_64-slc5-gcc43-opt/root/bin/thisroot.sh
  21. cd $BASEDIR/HiggsAnalysis/CombinedLimit;
  22. if [[ "$1" == "env" ]]; then
  23. echo "source $MYGCC '' ;";
  24. echo "source $MYROOT;";
  25. echo "export LD_LIBRARY_PATH=\"\${LD_LIBRARY_PATH}:${BOOST}/lib\";";
  26. echo "export PATH=\"${BASEDIR}/HiggsAnalysis/CombinedLimit/tmp/bin:${PATH}\";";
  27. echo "export PYTHONPATH=\"${BASEDIR}/HiggsAnalysis/CombinedLimit/tmp/python:${PYTHONPATH}\";";
  28. elif [[ "$1" == "clean" ]]; then
  29. test -f src/tmp_LinkDef.cc && rm src/tmp_LinkDef.cc
  30. test -f src/tmp_LinkDef.h && rm src/tmp_LinkDef.h
  31. rm -r src/*.o tmp/ 2> /dev/null || /bin/true;
  32. elif [[ "$1" == "make" ]]; then
  33. echo ">>> Setup "
  34. source $MYGCC ''
  35. source $MYROOT
  36. INC="-I${ROOTSYS}/include -I${BASEDIR} -I${BOOST}/include"
  37. echo ">>> Dictionaries "
  38. test -f src/tmp_LinkDef.cc && rm src/tmp_LinkDef.cc
  39. test -f src/tmp_LinkDef.h && rm src/tmp_LinkDef.h
  40. echo rootcint -f src/tmp_LinkDef.cc -c -p ${INC} -fPIC src/LinkDef.h && \
  41. rootcint -f src/tmp_LinkDef.cc -c -p ${INC} -fPIC src/LinkDef.h || exit 1
  42. perl -i -npe 'print qq{#include "LinkDef.h"\n} if 1 .. 1' src/tmp_LinkDef.cc
  43. echo ">>> Compile "
  44. CXXFLAGS="$(root-config --cflags) -O2 -I${BASEDIR} -I${BOOST}/include -fPIC ${CXXFLAGS}"
  45. CXXFLAGS=" -g ${CXXFLAGS}"
  46. for f in src/*.cc; do
  47. test -f ${f/.cc/.o} && rm ${f/.cc/.o}
  48. echo gcc ${CXXFLAGS} -c $f -o ${f/.cc/.o} && \
  49. gcc ${CXXFLAGS} -c $f -o ${f/.cc/.o} ;
  50. done
  51. test -f src/tmp_LinkDef.cc && rm src/tmp_LinkDef.cc
  52. test -f src/tmp_LinkDef.h && rm src/tmp_LinkDef.h
  53. echo ">>> Link "
  54. mkdir -p tmp/bin
  55. LDFLAGS="-L${BOOST}/lib -lboost_program_options -lboost_system -lboost_filesystem ${LDFLAGS}"
  56. LDFLAGS="$(root-config --ldflags --libs) -lRooFitCore -lRooStats -lRooFit -lFoam -lMinuit ${LDFLAGS}"
  57. LDFLAGS="-lstdc++ -fPIC ${LDFLAGS}"
  58. echo gcc ${CXXFLAGS} src/*.o bin/combine.cpp ${LDFLAGS} -o tmp/bin/combine &&
  59. gcc ${CXXFLAGS} src/*.o bin/combine.cpp ${LDFLAGS} -o tmp/bin/combine || exit 3;
  60. echo ">>> Python"
  61. test -d tmp/bin || mkdir -p tmp/bin;
  62. test -d tmp/python/HiggsAnalysis || mkdir -p tmp/python/HiggsAnalysis;
  63. ln -sd $BASEDIR/HiggsAnalysis/CombinedLimit/python tmp/python/HiggsAnalysis/CombinedLimit
  64. touch tmp/python/HiggsAnalysis/__init__.py
  65. touch tmp/python/HiggsAnalysis/CombinedLimit/__init__.py
  66. # hack to get python 2.6
  67. if python -V 2>&1 | grep -q "Python 2.4"; then
  68. cp -s /usr/bin/python2.6 ${BASEDIR}/HiggsAnalysis/CombinedLimit/tmp/bin/python
  69. fi;
  70. else
  71. echo "$0 (clean | make |env)";
  72. exit 1;
  73. fi;