[22122] | 1 |
|
---|
[22245] | 2 | if test $# -gt "0" ; then
|
---|
| 3 | if test -z ${1##GEXT*} ; then
|
---|
| 4 |
|
---|
| 5 | ext=$1 ; shift
|
---|
| 6 | reldir=$1 ; shift
|
---|
[23095] | 7 |
|
---|
[22245] | 8 | eval exthome=`echo \\$$ext`
|
---|
| 9 | if test -z "$exthome" ; then
|
---|
[23095] | 10 | echo "Environment variable $ext for Greenstone extension not set"
|
---|
[22245] | 11 | echo "Sourcing $reldir/setup.bash"
|
---|
| 12 | source $reldir/setup.bash
|
---|
[23095] | 13 |
|
---|
| 14 | eval exthome=`echo \\$$ext`
|
---|
[22245] | 15 | fi
|
---|
| 16 | fi
|
---|
| 17 | fi
|
---|
| 18 |
|
---|
[22122] | 19 | if test -z $GSDLOS ; then
|
---|
| 20 | GSDLOS=`uname -s | tr '[A-Z]' '[a-z]'`
|
---|
[22249] | 21 | # check for running bash under Cygwin
|
---|
[22122] | 22 | if test "`echo $GSDLOS | sed 's/cygwin//'`" != "$GSDLOS" ;
|
---|
| 23 | then
|
---|
| 24 | GSDLOS=windows
|
---|
| 25 | fi
|
---|
[22249] | 26 | # check for running bash under MinGW/MSys
|
---|
| 27 | if test "`echo $GSDLOS | sed 's/mingw//'`" != "$GSDLOS" ;
|
---|
| 28 | then
|
---|
| 29 | GSDLOS=windows
|
---|
| 30 | fi
|
---|
[22245] | 31 | echo "GSDLOS was not set. Setting it to '$GSDLOS'"
|
---|
[22122] | 32 | export GSDLOS
|
---|
| 33 | fi
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | run_untar()
|
---|
| 37 | {
|
---|
| 38 | local package=$1
|
---|
| 39 | local version=$2
|
---|
| 40 | local ext=$3
|
---|
| 41 |
|
---|
| 42 | tar_args="";
|
---|
| 43 |
|
---|
| 44 | if [ $ext = ".tar.gz" ] ; then
|
---|
| 45 | tar_args="xvzf"
|
---|
| 46 | elif [ $ext = ".tgz" ] ; then
|
---|
| 47 | tar_args="xvzf"
|
---|
| 48 | elif [ $ext = ".tar.bz2" ] ; then
|
---|
| 49 | tar_args="xvjf"
|
---|
| 50 | elif [ $ext = ".tar.bz" ] ; then
|
---|
| 51 | tar_args="xvjf"
|
---|
| 52 | elif [ $ext = ".tar" ] ; then
|
---|
| 53 | tar_args="xvf"
|
---|
| 54 | else
|
---|
| 55 | echo "Warning: Unrecognized extension: $ext"
|
---|
| 56 | echo "Assuming tarred, gzipped file"
|
---|
| 57 | tar_args="xvjf"
|
---|
| 58 | fi
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 | echo tar $tar_args $package$version$ext
|
---|
| 62 | tar $tar_args $package$version$ext
|
---|
| 63 |
|
---|
| 64 | if [ $? != 0 ] ; then
|
---|
| 65 | echo " Error encountered running *untar* stage of $progname"
|
---|
| 66 | exit 1
|
---|
| 67 | fi
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | opt_run_tarclean()
|
---|
| 71 | {
|
---|
| 72 | local type=$1
|
---|
| 73 | local package=$2
|
---|
| 74 | local version=$3
|
---|
| 75 |
|
---|
| 76 | if [ $type = "1" ] ; then
|
---|
| 77 |
|
---|
| 78 | local dir=$package$version
|
---|
| 79 | if [ -d $dir ] ; then
|
---|
| 80 | echo /bin/rm -rf $dir
|
---|
| 81 | /bin/rm -rf $dir
|
---|
| 82 |
|
---|
| 83 | if [ $? != 0 ] ; then
|
---|
| 84 | echo " Error encountered running *tarclean* stage of $progname"
|
---|
| 85 | exit 1
|
---|
| 86 | fi
|
---|
| 87 | else
|
---|
| 88 | echo "Unable to find directory $dir"
|
---|
| 89 | fi
|
---|
| 90 | fi
|
---|
| 91 | }
|
---|
| 92 |
|
---|
[23077] | 93 | toplevel_make_dist()
|
---|
| 94 | {
|
---|
[23095] | 95 | local dirname=`basename $exthome`
|
---|
[23077] | 96 |
|
---|
| 97 | local checklist="setup.bash setup.bat perllib $GSDLOS lib"
|
---|
| 98 | local distlist=""
|
---|
| 99 |
|
---|
| 100 | for d in $checklist ; do
|
---|
| 101 | if [ -e $d ] ; then
|
---|
| 102 | distlist="$distlist $dirname/$d"
|
---|
| 103 | fi
|
---|
| 104 | done
|
---|
| 105 |
|
---|
| 106 | pushd ..
|
---|
| 107 |
|
---|
| 108 | tar cvzf $dirname-$GSDLOS.tar.gz $distlist
|
---|
| 109 | mv $dirname-$GSDLOS.tar.gz $dirname/.
|
---|
| 110 |
|
---|
| 111 | popd
|
---|
| 112 | }
|
---|
| 113 |
|
---|
[22122] | 114 | opt_run_untar()
|
---|
| 115 | {
|
---|
| 116 | local force_untar=$1
|
---|
| 117 | local auto_untar=$2
|
---|
| 118 | local package=$3
|
---|
| 119 | local version=$4
|
---|
| 120 |
|
---|
| 121 | local ext="";
|
---|
| 122 |
|
---|
| 123 | if [ ! -z "$5" ] ; then
|
---|
| 124 | ext=$5
|
---|
| 125 | else
|
---|
| 126 | ext=".tar.gz"
|
---|
| 127 | fi
|
---|
| 128 |
|
---|
| 129 | if [ $force_untar = "1" ] ; then
|
---|
| 130 | run_untar $package $version $ext
|
---|
| 131 | elif [ $auto_config = "1" ] ; then
|
---|
| 132 | if [ -d $package$version ] ; then
|
---|
| 133 | echo "Found untarred version of $package$version$ext => no need to untar"
|
---|
| 134 | else
|
---|
| 135 | run_untar $package $version $ext
|
---|
| 136 | fi
|
---|
| 137 | fi
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 |
|
---|
| 141 | opt_run_configure()
|
---|
| 142 | {
|
---|
[22130] | 143 | local force_config=$1; shift
|
---|
| 144 | local auto_config=$1; shift
|
---|
| 145 | local package=$1; shift
|
---|
| 146 | local version=$1; shift
|
---|
| 147 | local prefix=$1; shift
|
---|
[22122] | 148 |
|
---|
| 149 | if [ $force_config = "1" ] ; then
|
---|
| 150 | echo "[pushd $package$version]"
|
---|
| 151 | ( cd $package$version ; \
|
---|
[22130] | 152 | echo ./configure --prefix="$prefix" $CROSSCOMPILE $@ ; \
|
---|
| 153 | ./configure --prefix="$prefix" $CROSSCOMPILE $@ )
|
---|
[22122] | 154 | if [ $? != 0 ] ; then
|
---|
| 155 | echo " Error encountered running *configure* stage of $progname"
|
---|
| 156 | exit 1
|
---|
| 157 | fi
|
---|
| 158 | echo "[popd]"
|
---|
| 159 | else
|
---|
| 160 | if [ $auto_config = "1" ] ; then
|
---|
| 161 | echo "Found top-level for ${progname%.*} => no need to run ./configure"
|
---|
| 162 | fi
|
---|
| 163 | fi
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 |
|
---|
| 167 | opt_run_make()
|
---|
| 168 | {
|
---|
| 169 | local type=$1
|
---|
| 170 | local package=$2
|
---|
| 171 | local version=$3
|
---|
| 172 | local opt_target=""
|
---|
| 173 |
|
---|
| 174 | if [ ! -z "$4" ] ; then
|
---|
| 175 | opt_target=$4
|
---|
| 176 | fi
|
---|
| 177 |
|
---|
| 178 | if [ $type = "1" ] ; then
|
---|
| 179 | ( cd $package$version ; \
|
---|
| 180 | make $opt_target)
|
---|
| 181 |
|
---|
| 182 | if [ $? != 0 ] ; then
|
---|
| 183 | echo " Error encountered running *make $target* stage of $progname"
|
---|
| 184 | exit 1
|
---|
| 185 | fi
|
---|
| 186 | fi
|
---|
| 187 | }
|
---|
| 188 |
|
---|
| 189 |
|
---|
[23077] | 190 | run_installclean()
|
---|
| 191 | {
|
---|
[23095] | 192 | local fulldir="$exthome/$GSDLOS"
|
---|
| 193 | echo ""
|
---|
[23077] | 194 | read -p "Delete $fulldir [y/n]?" ans
|
---|
| 195 | if [ $ans = "y" ] ; then
|
---|
| 196 | /bin/rm -rf "$fulldir"
|
---|
| 197 | fi
|
---|
| 198 |
|
---|
| 199 | exit 0
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 |
|
---|
| 203 | print_usage()
|
---|
| 204 | {
|
---|
| 205 | echo "$0 [untar|configure|comiple|install|clean|distclean|tarclean|makedist]+"
|
---|
| 206 | echo " or"
|
---|
| 207 | echo "$0 [installclean|help]"
|
---|
| 208 | exit 0
|
---|
| 209 | }
|
---|
| 210 |
|
---|
[22122] | 211 | force_untar=0
|
---|
| 212 | auto_untar=0
|
---|
| 213 |
|
---|
| 214 | force_config=0
|
---|
| 215 | auto_config=0
|
---|
| 216 |
|
---|
| 217 | compile=0
|
---|
| 218 | install=0
|
---|
| 219 | clean=0
|
---|
| 220 | distclean=0
|
---|
| 221 | tarclean=0
|
---|
[23077] | 222 | makedist=0
|
---|
[22122] | 223 |
|
---|
| 224 | if [ $# -gt 0 ] ; then
|
---|
| 225 | for cmd in $* ; do
|
---|
| 226 | echo $cmd
|
---|
[23077] | 227 | if [ $cmd = "untar" ] ; then force_untar=1
|
---|
| 228 | elif [ $cmd = "configure" ] ; then force_config=1
|
---|
| 229 | elif [ $cmd = "compile" ] ; then compile=1
|
---|
| 230 | elif [ $cmd = "install" ] ; then install=1
|
---|
| 231 | elif [ $cmd = "clean" ] ; then clean=1
|
---|
| 232 | elif [ $cmd = "distclean" ] ; then distclean=1
|
---|
| 233 | elif [ $cmd = "tarclean" ] ; then tarclean=1
|
---|
| 234 | elif [ $cmd = "makedist" ] ; then makedist=1
|
---|
| 235 |
|
---|
| 236 | elif [ $cmd = "installclean" ] ; then run_installclean
|
---|
| 237 | elif [ $cmd = "help" ] ; then print_usage
|
---|
[22122] | 238 | fi
|
---|
| 239 | done
|
---|
| 240 | else
|
---|
| 241 | # defaults
|
---|
| 242 | auto_untar=1
|
---|
| 243 | auto_config=1
|
---|
| 244 | compile=1
|
---|
| 245 | install=1
|
---|
| 246 | clean=0
|
---|
| 247 | distclean=0
|
---|
| 248 | tarclean=0
|
---|
[23077] | 249 | makedist=0
|
---|
[22122] | 250 | fi
|
---|
| 251 |
|
---|
| 252 | if [ $auto_config = "1" ] ; then
|
---|
| 253 | if [ ! -e $package$version/Makefile ] && [ ! -e $package$version/config.h ] ; then
|
---|
| 254 | force_config=1
|
---|
| 255 | fi
|
---|
| 256 |
|
---|
[23077] | 257 | fi |
---|