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