build_gsl.sh
Go to the documentation of this file.
1 #!/usr/bin/env bash
2 
3 #
4 # A script to build GSL (adapted from R.Hatcher's build_pythia6.sh)
5 #
6 # Usage: ./build_gsl.sh [version] [--refetch]
7 #
8 # Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
9 #
10 
11 version=1.8
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 
29 topdir=`pwd`/v${major}_${minor}
30 
31 echo version $version major $major minor $minor
32 echo topdir $topdir
33 
34 if [ ! -d ${topdir} ] ; then
35  mkdir $topdir
36 fi
37 cd $topdir
38 for subdir in stage download ; do
39  if [ ! -d ${subdir} ] ; then
40  mkdir ${subdir}
41  fi
42 done
43 
44 cd ${topdir}/download
45 
46 #
47 # wget or curl for retreiving remote files?
48 # (OS X doesn't generally have wget on it, so fall back on curl in that case)
49 #
50 whichfetchit=`which wget | grep -v "no wget in"`
51 if [ ! -z "${whichfetchit}" ] ; then
52  echo use \"wget\" for fetching files
53  fetchit='wget '
54 else
55  whichfetchit=`which curl | grep -v "no curl in"`
56  if [ ! -z "${whichfetchit}" ] ; then
57  # -f = fail without creating dummy, -O output local named like remoteza
58  echo use \"curl -f -O\" for fetching files
59  fetchit='curl -f -O '
60  else
61  echo "Neither wget nor curl available -- can't download files"
62  exit 1
63  fi
64 fi
65 
66 echo "$fetchit ftp://ftp.gnu.org/gnu/gsl/gsl-${major}.${minor}.tar.gz"
67 $fetchit ftp://ftp.gnu.org/gnu/gsl/gsl-${major}.${minor}.tar.gz
68 
69 tar xzvf gsl-${major}.${minor}.tar.gz
70 mv gsl-${major}.${minor} ${topdir}/src
71 
72 cd ${topdir}/src
73 ./configure --prefix=${topdir}/stage/
74 make
75 make install
76 
77