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