build_root.sh
Go to the documentation of this file.
1 #!/usr/bin/env bash
2 
3 #
4 # A script to build ROOT (adapted from R.Hatcher's build_pythia6.sh)
5 #
6 # Usage: ./build_root.sh [version]
7 # [--arch=linux|linuxx8664gcc|macosx|...]
8 # [--refetch]
9 # [--with-pythia6-version=...]
10 # [--with-gsl-version=...]
11 #
12 # Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
13 #
14 
15 version=5.24.00
16 arch=linux
17 doclean=0
18 refetch=0
19 while [ $# -gt 0 ] ; do
20  case $1 in
21  *clean*)
22  doclean=1 ;;
23  *refetch*)
24  refetch=1 ;;
25  *arch*)
26  refetch=$1 ;;
27  *pythia6*)
28  pythia6_version=$1 ;;
29  *gsl*)
30  gsl_version=$1 ;;
31  *)
32  version=$1 ;;
33  esac
34  shift
35 done
36 
37 major=`awk -v str=$version 'BEGIN {split(str, tk, "."); print tk[1]}'`
38 minor=`awk -v str=$version 'BEGIN {split(str, tk, "."); print tk[2]}'`
39 revis=`awk -v str=$version 'BEGIN {split(str, tk, "."); print tk[3]}'`
40 
41 topdir=`pwd`/v${major}_${minor}_${revis}
42 
43 echo version $version major $major minor $minor revision $revis
44 echo topdir $topdir
45 
46 if [ ! -d ${topdir} ] ; then
47  mkdir $topdir
48 fi
49 cd $topdir
50 for subdir in include lib download ; do
51  if [ ! -d ${subdir} ] ; then
52  mkdir ${subdir}
53  fi
54 done
55 
56 cd ${topdir}/download
57 
58 #
59 # wget or curl for retreiving remote files?
60 # (OS X doesn't generally have wget on it, so fall back on curl in that case)
61 #
62 whichfetchit=`which wget | grep -v "no wget in"`
63 if [ ! -z "${whichfetchit}" ] ; then
64  echo use \"wget\" for fetching files
65  fetchit='wget '
66 else
67  whichfetchit=`which curl | grep -v "no curl in"`
68  if [ ! -z "${whichfetchit}" ] ; then
69  # -f = fail without creating dummy, -O output local named like remoteza
70  echo use \"curl -f -O\" for fetching files
71  fetchit='curl -f -O '
72  else
73  echo "Neither wget nor curl available -- can't download files"
74  exit 1
75  fi
76 fi
77 
78 echo "$fetchit http://root.cern.ch/root/root_v${major}.${minor}.${revis}.source.tar.gz"
79 $fetchit http://root.cern.ch/root/root_v${major}.${minor}.${revis}.source.tar.gz
80 
81 tar xzvf http://root.cern.ch/root/root_v${major}.${minor}.${revis}.source.tar.gz
82 mv root ${topdir}/src
83 
84 cd ${topdir}/src
85 
86 export ROOTSYS=`pwd`
87 export PATH=$ROOTSYS/bin:$PATH
88 export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH
89 
90 ./configure $arch --enable-pythia6 --enable-mathmore --with-gsl-incdir= --with-gsl-libdir= --with-pythia6-libdir=
91 make
92 
93